News:

Wondering if this will always be free?  See why free is better.

Main Menu

2.0.17 SSI QueryString error

Started by Dominus Arbitrationis, August 14, 2020, 05:07:04 PM

Previous topic - Next topic

Dominus Arbitrationis

I am currently trying to make a MantisBT plugin that would utilize SMF SSI, but when I put require("[REDACTED]/SSI.php") into the PHP file, it gives me this error:

Quote'require_once(/QueryString.php): failed to open stream: No such file or directory' in '/home/arcengames/public_html/forums/SSI.php' line 64

Both Mantis and SMF are on the same server, and the link for the SSI was obtained from ssi_examples.php. PHP isreadable() returns true for both QueryString.php and SSI.php.

Directory structure looks like this:


  • Main site

    • Forums
    • MantisBT

Any ideas what the issues might be?

drewactual

#1
are you using relative or absolute path in the actual code?


require('/home/arcengames/public_html/forums/SSI.php');


or


require('https://yourpage.com/forum/SSI.php');
// which can be shorthanded in your case to: require('.././forums/SSI.php');


you placed 'redacted' in your post so it's difficult to tell which you used... and, is 'require' required?  i tend to use 'include' so it doesn't break things if it doesn't pick it up, and which makes it easier (for me) to troubleshoot... 


Dominus Arbitrationis

I have tried both absolute and relative paths.

Even if I switched to include the issue would remain, just as a non fatal error. Include gives the same error.

drewactual

try with '  ' instead of "  " ?

can you post up a phpinfo? 

shawnb61

#4
I think you want a folder, not a URL.

If you don't have access to $boarddir or $sourcedir, I would try:
require(dirname(__FILE__) . '/Sources/QueryString.php');

(If you really want to use a URL...  I suspect the remote host is not configured to return the .php as a text file...  Which is a good thing...)
Address the process rather than the outcome.  Then, the outcome becomes more likely.   - Fripp

Dominus Arbitrationis

Sorry for the confusion regarding the redaction. I'll fix that to clarify. I am using file links, not a URL (see below).

This is how I've tried to include SSI.php. It is necessary for the functioning of the page, so it uses require. I have tried using include, include_once, and require_once, but the same issues occur. There is the complete file, and it is located at /home/account/public_html/mantis/plugins/myplugin/pages/.
<?php require( '/home/account/public_html/forums/SSI.php' );?>

I have also tried
<?php require( '../../../../forums/SSI.php' );?>

I've tried using "" instead of '', and I've verified the relative paths work. isreadable returns true for all involved files.

I have tried adding set_include_path('/home/account/public_html/forums'); with no success.

If I take that same file, and put it into /home/account/public_html/forums/ it works without an issue.

I am trying to avoid editing SSI.php entirely.

Arantor

Quote from: shawnb61 on August 15, 2020, 06:16:46 PM
I think you want a folder, not a URL.

If you don't have access to $boarddir or $sourcedir, I would try:
require(dirname(__FILE__) . '/Sources/QueryString.php');

(If you really want to use a URL...  I suspect the remote host is not configured to return the .php as a text file...  Which is a good thing...)

Firstly, SSI *does* actually support being called directly via URL - for example you can call SSI.php?ssi_function=login directly in the browser and get the login form on its own.

Secondly, SSI.php includes Settings.php, which should be defining $sourcedir.

Assuming the OP's forum is the obvious example based on their name (which is an SMF forum), ssi_examples.php works, so SSI is not fundamentally broken.

The question: in the file you are trying to do this in, is $sourcedir somehow already defined? Or is there some weird definition of $sourcedir in Settings.php?

Because SSI.php is loading it on line 41, and it's *empty* by the time line 64 of SSI.php gets hit. I'd be curious to temporarily modify SSI.php, at line 63 and var_dump($GLOBALS) to see what variables exist and what else in global scope might be messing with it.

Dominus Arbitrationis

Quote from: Arantor on August 15, 2020, 07:25:03 PM
Assuming the OP's forum is the obvious example based on their name (which is an SMF forum), ssi_examples.php works, so SSI is not fundamentally broken.
Correct on all accounts.

Quote from: Arantor on August 15, 2020, 07:25:03 PM
The question: in the file you are trying to do this in, is $sourcedir somehow already defined? Or is there some weird definition of $sourcedir in Settings.php?

Because SSI.php is loading it on line 41, and it's *empty* by the time line 64 of SSI.php gets hit. I'd be curious to temporarily modify SSI.php, at line 63 and var_dump($GLOBALS) to see what variables exist and what else in global scope might be messing with it.

It is not. echo $sourcedir returns
SYSTEM NOTICE: 'Undefined variable: sourcedir'

Tossing in the var_dump results in the proper $sourcedir being shown if I call it from the same directory (So, ssi_examples.php has the right $sourcedir), but if I do the include, I instead get ["sourcedir"]=> NULL.

Arantor

Does $sourcedir have a full physical path in it in Settings.php itself?

Dominus Arbitrationis

Yes. Following is those lines:


$boarddir = '/home/account/public_html/forums'; # The absolute path to the forum's folder. (not just '.'!)
$sourcedir = '/home/account/public_html/forums/Sources'; # Path to the Sources directory.
$cachedir = '/home/account/public_html/forums/cache'; # Path to the cache directory.

Arantor

Did you copy SSI.php out of its folder? Because what you're describing otherwise is borderline impossible: SSI.php is loading Settings.php which is setting a global variable - which is somehow being unset by 20 lines later even though there is no reason for that code to be changing.

SMF doesn't modify $sourcedir outside of sanity-checking its initial value at the foot of Settings.php and bootstrapping SSI.php, but since it's an absolute path, it's not being mangled by some path relativism.

In an ideal world I'd suggest setting up XDebug, setting breakpoints and watchers on $sourcedir and see where it's being changed but not sure if that's achievable in your current environment.

Dominus Arbitrationis

SSI.php is located in /home/account/public_html/forums/ next to the Settings.php file. I even downloaded a fresh copy from the full 2.0.17 install zip, and still getting the same issue.

In the current environment, that isn't possible. If I bring the file executing the include up to the /home/account/public_html/dev directory, it does work correctly. So it seems to be an issue only in the one spot. So my best guess is MantisBT is causing issues there.

Arantor

Did some digging around, turns out the bridge we had here wasn't based on SSI because of other issues in Mantis and every upgrade we did (even patches) would usually break Mantis in some weird way so we abandoned it altogether.

https://www.simplemachines.org/community/index.php?topic=514516.msg3637092#msg3637092 Looks like this guy just patched it to query the SMF tables directly which would at least keep passwords the same.

Dominus Arbitrationis

That's what I did too, just in plugin form. Was hoping for a way to use SSI to get the logout link and some other fun stuff, but I'll just end up hiding the logout button to make things easier. On the plus side, there will be a very easy to use SMF to Mantis plugin coming out very soon!

Advertisement: