Hi all
I'm having a very strange issue when I try to add the following to a block
<?php ssi_showPoll(); ?>
In this case I'm trying to show the poll in topic 669 so, <?php ssi_showPoll(669); ?>.
When I'm within the admin section and non forum parts of my site, the poll displays fine, but as soon as I'm out and viewing the forums it returns an error;
"Fatal error: Call to undefined function ssi_showPoll() in /home/xxxxxxxx/public_html/includefile.php(24) : eval()'d code on line 2"
This error also stops my forums from displaying.
What's more bizarre is that on the pages that don't return the error, the block I put the code in becomes unnecessarily stretched and with the poll right at the bottom of the block, this also happens if I insert the code within a page. See the attached image to understand what I mean.
I've not got an ounce of knowledge about php or ssi's apart from what I've read at ssi_examples.php within my smf installation.
If anyone could shed any light on this it would be very much appreciated.
You don't have a require or include statement calling SSI.php first.
as I previously mentioned I'm a php noob. I don't know what either of those things are??
What do you mean by "block"? Are you using a portal?
Yes I am
In this case if you're using a php block I don't think you need the php tags..
QuoteIn this case I'm trying to show the poll in topic 669 so, <?php ssi_showPoll(669); ?>.
When I'm within the admin section and non forum parts of my site, the poll displays fine, but as soon as I'm out and viewing the forums it returns an error;
You can't have SSI and SMF on the same page. SSI won't load if SMF is already running.
QuoteSSI won't load if SMF is already running.
Well, that's not entirely correct... you can include the file and use the functions in it, as some portals do actually do.
Quote from: Arantor on April 03, 2010, 12:31:32 PM
QuoteSSI won't load if SMF is already running.
Well, that's not entirely correct... you can include the file and use the functions in it, as some portals do actually do.
SSI.php, lines 25-27:
// Don't do anything if SMF is already loaded.
if (defined('SMF'))
return true;
So, yes, it is entirely correct.
Then how come you can invoke SSI.php and the functions still get defined?
From SMF? You can't.
I've seen it done where it's been included in index.template.php to use SSI functions in the theme. It was even submitted as a mod a bit back to use ssi_recentTopics.
Then I suggest you try it. :P
I modified 2.0 RC3 fresh install like so:
function template_html_below()
{
global $context, $settings, $options, $scripturl, $txt, $modSettings;
global $boarddir;
include($boarddir . '/SSI.php');
ssi_recentTopics();
echo !empty($settings['forum_width']) ? '
</div>' : '', '
</body></html>';
}
As you can see, bringing the variable in to scope to get path, then calling SSI recent topics.
I would attach it but the server runs out of memory and whitescreens on me if I do, so instead... http://www.wordowl.com/misc/smf/ssi_recent_topics.png
Now tell me it doesn't work.
And your SSI.php is not modified in any way?
Nope. Is a 2.0 RC3 fresh install just to be sure.
I suggest you try it.
Can you change it slightly to this?
function template_html_below(){
global $context, $settings, $options, $scripturl, $txt, $modSettings;
global $boarddir;
echo SMF;
include($boarddir . '/SSI.php');
echo SMF;
ssi_recentTopics();
echo !empty($settings['forum_width']) ? '</div>' : '', '</body></html>';
}
Sure, copy/paste exactly as that.
Result is http://www.wordowl.com/misc/smf/ssi_recent_topics2.png
Well, as I expect, I get absolutely no results except for the "11".
http://www.everything-science.com/forum/
OK, so let's get down and dirty.
I'm using PHP 5.2.6 on Windows + Apache 2.2.something. Related?
PHP 5.2.11, Linux, Apache 2.2.14
Are you running this locally? I'd be concerned about it running live on the web this way. If it is executing scripts despite the check for 'SMF' failing, then it would do the same for the security check in all the Sources files.
i.e, if this doesn't stop SSI.php from running when the constant 'SMF' is already defined with a value of '1':
// Don't do anything if SMF is already loaded.
if (defined('SMF'))
return true;
then this won't stop Subs.php from running either:
if (!defined('SMF'))
die('Hacking attempt...');
I am running it locally, yes.
The security check for Sources files still works as it's supposed to.
Hi guys sorry to interrupt your truly fascinating discussion/debate but what do I need to do/enter into a block to get it to show a specific poll?
Or cant I?
We're getting into that; what we're talking about is directly relevant to why you shouldn't be able to do it a really easy way.
Quote from: ESFclandoteu on April 03, 2010, 03:38:04 PM
Hi guys sorry to interrupt your truly fascinating discussion/debate but what do I need to do/enter into a block to get it to show a specific poll?
Or cant I?
Open SSI.php.
Copy the function you want from it. In your case, ssi_showPoll(). Make sure to get the entire function right to the last curly bracket.
Open Sources/Subs.php.
Paste the function into it, just above the closing PHP tag ( ?> ).
Now go ahead and call the function from wherever you want.
Quote from: Arantor on April 03, 2010, 03:37:33 PM
I am running it locally, yes.
The security check for Sources files still works as it's supposed to.
I'm wondering if this is something Windows-related, in particular with the return command outside a function. :-\
It's entirely possible, I'll have to retest that on my Linux VPS shortly.
A genius war, god saves us!!
I can see a weird and unseen light coming from your swords!! Your cloaks are in the ground, the battle is beginning!
Arantor vs. Orstio, soon at simplemachines.org!
I'm not a genius, Orstio is more than for writing parts of SMF... haven't had chance to test this yet.
I was joking!! :D
Quote from: Orstio on April 03, 2010, 03:40:46 PM
Quote from: ESFclandoteu on April 03, 2010, 03:38:04 PM
Hi guys sorry to interrupt your truly fascinating discussion/debate but what do I need to do/enter into a block to get it to show a specific poll?
Or cant I?
Open SSI.php.
Copy the function you want from it. In your case, ssi_showPoll(). Make sure to get the entire function right to the last curly bracket.
Open Sources/Subs.php.
Paste the function into it, just above the closing PHP tag ( ?> ).
Now go ahead and call the function from wherever you want.
Hi, thanks for your reply, I've done this and I get this error
Fatal error: Cannot redeclare ssi_showpoll() (previously declared in /home/_____/public_html/forums/SSI.php:880) in /home/_____/public_html/forums/Sources/Subs.php on line 4421
I did as you said so I'm kinda confuzzled.
I've attached my subs file just incase it's something I've missed.
I should also say that I get this error when going to my admin page, not anywhere else on the site
OK, re-reading your initial post, I see that you're wanting to use SSI from outside SMF as well as inside SMF.
Rename the function in Subs.php to ssi_showPoll2, and then change all of your calls to that as well.
About using SSI inside SMF: if SMF is loaded, it won't do the entire initialization part. That's all, the functions can be called just fine, since they are defined when the file was included. It simply doesn't execute the rest of the initialization statements.
(http://www.php.net/manual/en/function.include.php)
Quote
If there are functions defined in the included file, they can be used in the main file independent if they are before return() or after.