News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

odd php behavior

Started by ESFclandoteu, April 02, 2010, 06:22:42 PM

Previous topic - Next topic

Orstio

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...');

Arantor

I am running it locally, yes.

The security check for Sources files still works as it's supposed to.
Holder of controversial views, all of which my own.


ESFclandoteu

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?

Arantor

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.
Holder of controversial views, all of which my own.


Orstio

#24
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.

Orstio

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.  :-\

Arantor

It's entirely possible, I'll have to retest that on my Linux VPS shortly.
Holder of controversial views, all of which my own.


MultiformeIngegno

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!
RockCiclopedia (wiki - forum), Tutta la storia del rock, scritta da voi ...
Rimanere aggiornati sul mondo della musica grazie al nuovo feed "RockCiclopedia Music News"!

Arantor

I'm not a genius, Orstio is more than for writing parts of SMF... haven't had chance to test this yet.
Holder of controversial views, all of which my own.


MultiformeIngegno

RockCiclopedia (wiki - forum), Tutta la storia del rock, scritta da voi ...
Rimanere aggiornati sul mondo della musica grazie al nuovo feed "RockCiclopedia Music News"!

ESFclandoteu

#30
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

Orstio

#31
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.

Norv

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.
To-do lists are for deferral. The more things you write down the later they're done... until you have 100s of lists of things you don't do.

File a security report | Developers' Blog | Bug Tracker


Also known as Norv on D* | Norv N. on G+ | Norv on Github

Advertisement: