Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: Hristo on January 26, 2013, 03:51:57 PM

Title: Custom page outside forum's directory
Post by: Hristo on January 26, 2013, 03:51:57 PM
I would like to use a custom home page outside forum's directory and I really do not like to use a whole portal for that purpose. This code http://www.simplemachines.org/community/index.php?topic=412852.msg2879370#msg2879370 did the job. Unfortunately one of the mods I would like to use http://custom.simplemachines.org/mods/index.php?mod=1584 triggers some warning messages visible on the page (I do not think it's mod's fault, so I post here). Here you can see the problem:
http://bg-gradina.org/test.php

Is there a way to hide these warning messages without changing any forum files?

If that will help, here are the Subs.php lines 3332 - 3353:

// Print stuff to prevent caching of pages (except on attachment errors, etc.)
if (empty($context['no_last_modified']))
{
3335 header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
3336 header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');

// Are we debugging the template/html content?
if (!isset($_REQUEST['xml']) && isset($_GET['debug']) && !$context['browser']['is_ie'] && !WIRELESS)
header('Content-Type: application/xhtml+xml');
elseif (!isset($_REQUEST['xml']) && !WIRELESS)
3342 header('Content-Type: text/html; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
}

3345 header('Content-Type: text/' . (isset($_REQUEST['xml']) ? 'xml' : 'html') . '; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));

$checked_securityFiles = false;
$showed_banned = false;
foreach ($context['template_layers'] as $layer)
{
loadSubTemplate($layer . '_above', true);

// May seem contrived, but this is done in case the body and main layer aren't there...

Title: Re: Custom page outside forum's directory
Post by: Kindred on January 26, 2013, 03:58:11 PM
you are obviously using the wrong code to generate your custom page.

Please post your actual page code here and we'll give you a better way to do it so that the SSI and headers are properly called.
Title: Re: Custom page outside forum's directory
Post by: Hristo on January 26, 2013, 04:16:56 PM
I have not changed the original code except the directory of course. Here it is:

<?php
//Set the banning active
$ssi_ban = true;

//Path to SSI.php
require("test/SSI.php");

//Page title. This will appear in the browser
$context['page_title_html_safe'] = 'Page title';

//This is self explanatory
template_header();

//Here we define the link tree
$context['linktree'] = array(
 
'href' => $scripturl,
 );
 
//Here is the content, such as the title and the body message of the custom page.

echo'
<span class="clear upperframe"><span></span></span>
<div class="roundframe"><div class="innerframe">'
;
echo'
<div class="cat_bar">
<h3 class="catbg">Hello everyone</h3>
</div>
   <p>This is a custom page example. pretty cool, huh.</p>'
;
echo'
  </div></div>
 <span class="lowerframe"><span></span></span>'
;


//This is self explanatory too.  
template_footer();

?>


I tested it on another test forum with 80+ mods and only the above mentioned mod causes these warnings to appear.
Title: Re: Custom page outside forum's directory
Post by: Arantor on January 26, 2013, 04:29:51 PM
You might want to try using subdomain independent cookies, and I'd rather see the *file* test.php rather than its contents.

The error you're seeing on line 3335+ is specifically related to the notice raised by SSI.php line 170, which is potentially related to cookies and also a fault in the file.
Title: Re: Custom page outside forum's directory
Post by: Sorck on January 26, 2013, 04:46:39 PM
Quoteplease make sure SSI.php is included before *anything* else in all your scripts!
Looks to me like you're outputting some whitespace before your opening <?php tag in test.php (or you've echo'd something before requiring SSI.php).
Title: Re: Custom page outside forum's directory
Post by: Arantor on January 26, 2013, 04:49:04 PM
This is why I wanted to see the actual file ;)
Title: Re: Custom page outside forum's directory
Post by: Hristo on January 26, 2013, 04:52:26 PM
Enabled "Use subdomain independent cookies" - no change

Now I realize it was pure luck to pinpoint which mod causes the messages.

Do not waste your time with this. This was the best option, but I will use a workaround - html plus some SSI to achieve something close.

Here is the file if you are curious
Title: Re: Custom page outside forum's directory
Post by: Arantor on January 26, 2013, 04:55:35 PM
It was pure luck, because I'm certain it wasn't the mod in the first place - there is no reason that I can see why that mod would cause that issue (because if it was, *everything* would be broken, not just SSI), the error in question should affect more than just SSI.php...

But if you're not really interested in debugging further, fair enough.
Title: Re: Custom page outside forum's directory
Post by: Hristo on January 26, 2013, 05:03:02 PM
It should be the mod because when I uninstall it the warnings disappear. Seems odd problem, so I don't want to waste your time.
Title: Re: Custom page outside forum's directory
Post by: Arantor on January 26, 2013, 05:05:36 PM
And yet after skimming the mod's code I can't see why it should, and I also don't see why the mod author hasn't been notified so they can perhaps fix it... *shrug*
Title: Re: Custom page outside forum's directory
Post by: Hristo on January 26, 2013, 05:17:16 PM
OK, if you think it's a mod's bug, then I will report it.
Title: Re: Custom page outside forum's directory
Post by: Arantor on January 26, 2013, 05:23:14 PM
Well, you're saying it is...
Title: Re: Custom page outside forum's directory
Post by: Hristo on January 27, 2013, 06:59:46 AM
Topic solved. I'm not familiar with php, but your comments helped me to find the problem. Thank you to both of you!
Here is where the problem was:
http://www.simplemachines.org/community/index.php?topic=284589.msg3478078#msg3478078