SSI giving wrong urls

Started by W2NAP, May 23, 2024, 10:20:51 AM

Previous topic - Next topic

W2NAP

Working on a project on local. main part is PHP pages I created, then integrating a few smf things via SSI and what I notice is the url on the integrated pages are wrong.

basepaths
main site /pub_html/
smf forum /pub_html/forum/

Now when in SMF the urls are correct. example
127.0.0.1/forum/index.php?topic=1.0

however when in the main site, data pulled from SSI the data is pulled however any url attached omits the forum/ and displays as.
127.0.0.1/index.php?topic=2261.0
which will not work as smf is in forum/

I feel like I am missing something and can't quite figure it out. and yes the SSI path in the main site pages points to forum/SSI.php is there a setting somewhere I am missing to fix this?

Kindred

What version of SMF?

I can't reproduce the problem in 2.0.19 or 2.1.4
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Aleksi "Lex" Kilpinen

I don't really know, but I think you may want to run repair_settings.php and ensure all paths are set correctly, just in case. If everything is correct, then could maybe emptying cache on both the forum and your browser help?
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

W2NAP

Quote from: Kindred on May 23, 2024, 11:05:54 AMWhat version of SMF?

I can't reproduce the problem in 2.0.19 or 2.1.4

2.1.4

Quote from: Aleksi on May 23, 2024, 11:19:03 AMI don't really know, but I think you may want to run repair_settings.php and ensure all paths are set correctly, just in case. If everything is correct, then could maybe emptying cache on both the forum and your browser help?

paths are correct. clear cache has no change.

source clip from my main index.php where smf ssi is getting data to display
<div class="card">
<h3>test news post number nine</h3>
<hr>
By: <a href="http://10.0.0.17/index.php?action=profile;u=1">w2nap</a> &nbsp; &nbsp; on  May 23, 2024, 01:59 AM<br>
<p>The standard Lorem Ipsum passage, used since the 1500s<br><br>"Lorem ipsum *snip to save space*.</p>
<hr>
<p> <a href="http://10.0.0.17/index.php?topic=7.0">0 comments</a> <a href="http://10.0.0.17/index.php?action=post;topic=7.0">Write Comment</a></p>
</div>

the urls on the integrated pages should be reading out 10.0.0.17/forum/index.php?topic=7.0 but as you can see it is not.

the php code to pull the data and display

$array = ssi_boardNews(1.0, 10, null, 250, 'array');
foreach ($array as $news)
{

echo '<div class="card">';
echo '<h3>'. $news['subject'].'</h3>';
echo '<hr>';
echo 'By: '.$news['poster']['link'].' &nbsp; &nbsp; on  '.$news['time'];
echo '<br>';
echo '<p>'.$news['body'].'</p>';
echo '<hr>';
echo '<p> '.$news['link'].' '.$news['new_comment'].'</p>';
echo '</div>';
}

W2NAP

still digging at it. it seems $scripturl isn't passing the correct url path.

smf is in its own /forum dir. separate from the rest of the site which is in /

if I vardump $scripturl in /forum (where the smf forum is) I get "string(32) "http://10.0.0.17/forum/index.php" "which would be the correct url to the forum.

however same test file with var dump in the main part of the website which is using SSI calls to do a couple things vardump gives "string(26) "http://10.0.0.17/index.php" "which is wrong /forum gets stripped out and /forum needs to be in that url path for it to work. 

I assume on the SMF website here they are using SSI to pull in data from /community to the ../index page working and those url's on index.php on the main landing page all have the correct "https://www.simplemachines.org/community/index.php?topic=xxxxx"

Is there a special step I have to do when I do not have my "integrates" in the same folder as SMF?

Kindred

Is SSI.php actually IN your/forum/directory?

And, in your script, do you use an absolute path for the require_once?
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

W2NAP

Quote from: Kindred on May 23, 2024, 09:11:42 PMIs SSI.php actually IN your/forum/directory?

And, in your script, do you use an absolute path for the require_once?

ssi is in the forum dir.

I have the ssi req_once in a mainfile which all the scripts in / call to. the ssi call in mainfile
require_once FORUMS_DIR . 'SSI.php';

which FORUM_DIR is defined
define('FORUMS_DIR', BASE_DIR . 'forum/'); my includes and couple other paths are defined just as forums-dir and do work as expected.

Kindred

require_once(FORUMS_DIR . 'SSI.php');

You need parens, afaik...
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

W2NAP

Quote from: Kindred on May 24, 2024, 12:50:28 PMrequire_once(FORUMS_DIR . 'SSI.php');

You need parens, afaik...

I did miss the (). but it was pulling in the data without those in so SSI is sort of working. it pulls in the data fine but it just boogers the urls stripping forum/ from it.
what it should be is
http://10.0.0.17/forum/index.php?topic=7.0

but what ssi returns when ran in the main site is.
http://10.0.0.17/index.php?topic=7.0

its like SSI is seeing that it is getting called from one dir down and strips forum/ from the url during $scripturl call, which without forum/ in the url the url is a broken link pointing to nothing. And im getting to where the only way to make it pull the correct url data is going to be hard edit of SSI.php on anything related to $scripturl.

Kindred

Instead of using variables, try hard coding the absolute path to ssi
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Tyrsson

This is just off the top of my head. Might work, might not.

If you are in the root in the "main site" ie /public_html and your forum is at /public_html/forum

Where you are using SSI you can try this.

chdir('forum');

See the following for more information.
https://www.php.net/manual/en/function.chdir.php
PM at your own risk, some I answer, if they are interesting, some I ignore.

W2NAP

Quote from: Kindred on May 24, 2024, 08:42:54 PMInstead of using variables, try hard coding the absolute path to ssi

still same result.

Quote from: Tyrsson on May 24, 2024, 09:50:08 PMThis is just off the top of my head. Might work, might not.

If you are in the root in the "main site" ie /public_html and your forum is at /public_html/forum

Where you are using SSI you can try this.

chdir('forum');

See the following for more information.
https://www.php.net/manual/en/function.chdir.php

didn't work.

I ended up just copying the ssi functions i am going to use into my main sites mainfile.php renaming the function to something else so no conflict with ssi. So something like ssi_boardNews(); becomes ssi_boardNewscms(); and within ssi_boardNewscms i hardcode the $scripturl to point to the correct url path, which works. idk why calling to ssi.php would strip part of the url path when called from the dir below.

Tyrsson

Ill do some testing. I'm in the process of setting up a 2.1 build.
PM at your own risk, some I answer, if they are interesting, some I ignore.

W2NAP

Quote from: Tyrsson on May 26, 2024, 01:27:09 AMIll do some testing. I'm in the process of setting up a 2.1 build.

be interesting to see how it works for you. for me trying to call ssi from 1 dir down strips the url down as well. So my mainfile "hack" works just makes it clunky as ill have to keep up with any changes to ssi going onward.

Advertisement: