Advertisement:

Author Topic: odd php behavior  (Read 7028 times)

Offline ESFclandoteu

  • Semi-Newbie
  • *
  • Posts: 11
odd php behavior
« on: April 02, 2010, 06:22:42 PM »
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.

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 67,697
    • Arantor on GitHub
Re: odd php behavior
« Reply #1 on: April 02, 2010, 07:03:46 PM »
You don't have a require or include statement calling SSI.php first.
To assume is to hope that those who came before had the presence of mind and capacity to implement the dreams of those who would come after.

You either die a hero or live long enough to see yourself become the villain. It seems you have chosen which, and now I must do the same.

Offline ESFclandoteu

  • Semi-Newbie
  • *
  • Posts: 11
Re: odd php behavior
« Reply #2 on: April 03, 2010, 12:29:16 AM »
as I previously mentioned I'm a php noob. I don't know what either of those things are??

Offline MultiformeIngegno

  • Sophist Member
  • *****
  • Posts: 1,086
  • Gender: Male
  • Id quo maius cogitari nequit
    • RockCiclopedia
Re: odd php behavior
« Reply #3 on: April 03, 2010, 05:09:55 AM »
What do you mean by "block"? Are you using a portal?
RockCiclopedia (wiki - forum), Tutta la storia del rock, scritta da voi ...
Rimanere aggiornati sul mondo della musica grazie al nuovo feed "RockCiclopedia Music News"!

Offline ESFclandoteu

  • Semi-Newbie
  • *
  • Posts: 11
Re: odd php behavior
« Reply #4 on: April 03, 2010, 07:45:04 AM »
Yes I am

Offline MultiformeIngegno

  • Sophist Member
  • *****
  • Posts: 1,086
  • Gender: Male
  • Id quo maius cogitari nequit
    • RockCiclopedia
Re: odd php behavior
« Reply #5 on: April 03, 2010, 08:12:55 AM »
In this case if you're using a php block I don't think you need the php tags..
RockCiclopedia (wiki - forum), Tutta la storia del rock, scritta da voi ...
Rimanere aggiornati sul mondo della musica grazie al nuovo feed "RockCiclopedia Music News"!

Orstio

  • Guest
Re: odd php behavior
« Reply #6 on: April 03, 2010, 08:35:39 AM »
Quote
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;


You can't have SSI and SMF on the same page.  SSI won't load if SMF is already running.

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 67,697
    • Arantor on GitHub
Re: odd php behavior
« Reply #7 on: April 03, 2010, 12:31:32 PM »
Quote
SSI 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.
To assume is to hope that those who came before had the presence of mind and capacity to implement the dreams of those who would come after.

You either die a hero or live long enough to see yourself become the villain. It seems you have chosen which, and now I must do the same.

Orstio

  • Guest
Re: odd php behavior
« Reply #8 on: April 03, 2010, 02:10:30 PM »
Quote
SSI 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:

Code: [Select]
// Don't do anything if SMF is already loaded.
if (defined('SMF'))
return true;

So, yes, it is entirely correct.

« Last Edit: April 03, 2010, 02:17:13 PM by Orstio »

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 67,697
    • Arantor on GitHub
Re: odd php behavior
« Reply #9 on: April 03, 2010, 02:48:32 PM »
Then how come you can invoke SSI.php and the functions still get defined?
To assume is to hope that those who came before had the presence of mind and capacity to implement the dreams of those who would come after.

You either die a hero or live long enough to see yourself become the villain. It seems you have chosen which, and now I must do the same.

Orstio

  • Guest
Re: odd php behavior
« Reply #10 on: April 03, 2010, 02:51:13 PM »
From SMF?  You can't.

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 67,697
    • Arantor on GitHub
Re: odd php behavior
« Reply #11 on: April 03, 2010, 02:57:31 PM »
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.
To assume is to hope that those who came before had the presence of mind and capacity to implement the dreams of those who would come after.

You either die a hero or live long enough to see yourself become the villain. It seems you have chosen which, and now I must do the same.

Orstio

  • Guest
Re: odd php behavior
« Reply #12 on: April 03, 2010, 03:02:16 PM »
Then I suggest you try it. :P

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 67,697
    • Arantor on GitHub
Re: odd php behavior
« Reply #13 on: April 03, 2010, 03:08:06 PM »
I modified 2.0 RC3 fresh install like so:

Code: [Select]
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.
To assume is to hope that those who came before had the presence of mind and capacity to implement the dreams of those who would come after.

You either die a hero or live long enough to see yourself become the villain. It seems you have chosen which, and now I must do the same.

Orstio

  • Guest
Re: odd php behavior
« Reply #14 on: April 03, 2010, 03:10:01 PM »
And your SSI.php is not modified in any way?

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 67,697
    • Arantor on GitHub
Re: odd php behavior
« Reply #15 on: April 03, 2010, 03:11:22 PM »
Nope. Is a 2.0 RC3 fresh install just to be sure.

I suggest you try it.
To assume is to hope that those who came before had the presence of mind and capacity to implement the dreams of those who would come after.

You either die a hero or live long enough to see yourself become the villain. It seems you have chosen which, and now I must do the same.

Orstio

  • Guest
Re: odd php behavior
« Reply #16 on: April 03, 2010, 03:15:06 PM »
Can you change it slightly to this?

Code: [Select]
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>';
}

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 67,697
    • Arantor on GitHub
Re: odd php behavior
« Reply #17 on: April 03, 2010, 03:18:03 PM »
Sure, copy/paste exactly as that.

Result is http://www.wordowl.com/misc/smf/ssi_recent_topics2.png
To assume is to hope that those who came before had the presence of mind and capacity to implement the dreams of those who would come after.

You either die a hero or live long enough to see yourself become the villain. It seems you have chosen which, and now I must do the same.

Orstio

  • Guest
Re: odd php behavior
« Reply #18 on: April 03, 2010, 03:22:42 PM »
Well, as I expect, I get absolutely no results except for the "11".

http://www.everything-science.com/forum/

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 67,697
    • Arantor on GitHub
Re: odd php behavior
« Reply #19 on: April 03, 2010, 03:26:56 PM »
OK, so let's get down and dirty.

I'm using PHP 5.2.6 on Windows + Apache 2.2.something. Related?
To assume is to hope that those who came before had the presence of mind and capacity to implement the dreams of those who would come after.

You either die a hero or live long enough to see yourself become the villain. It seems you have chosen which, and now I must do the same.