News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

SSI cannot grab full address only index.php

Started by diontoradan, January 03, 2011, 03:45:50 PM

Previous topic - Next topic

diontoradan

Hello,

i know this is a stupid question, but i tried to search for this question but i cannot find any.

the problem is i use SSI to grab content from my forum, but the forum link act bizarre when i install the code outside forum.
instead of getting domain.com/forum/index.php?xxx, it only display domain.com/index.php?xxx (without the /forum).

how can i get the $scripturl to work properly?

many thanks...


JBlaze

Make sure $scripturl is brought into scope.

global $scripturl;
Jason Clemons
Former Team Member 2009 - 2012

Ant59

I have the same problem. JBlaze, your fix doesn't work.

hadesflames


Ant59

Sure :)


<?php
global $scripturl;
require_once($home_dir.'forum/SSI.php');
$news ssi_boardNews(28nullnull'array');
foreach ($news as $item)
{
echo '
<div class="news_item">
<h3 class="news_header"><a href="'
.$item['href'].'">'.$item['subject'].'</a></h3>
<div class="news_timestamp">Posted '
.$item['time'].' by '.$item['poster']['link'].'</div>
<div class="news_body" style="padding: 2ex 0;">'
$item['body'], '</div>
'
$item['link'], $item['locked'] ? ' | Topic Locked' ' | ' $item['comment_link'], '
</div>'
;
}
?>


hadesflames

Give this a shot:

<?php
      
require_once(__FILE__ 'forum/SSI.php');
      global 
$scripturl;
      
$news ssi_boardNews(28nullnull'array');
      foreach (
$news as $item)
      {
         echo 
'
            <div class="news_item">
               <h3 class="news_header"><a href="'
.$item['href'].'">'.$item['subject'].'</a></h3>
               <div class="news_timestamp">Posted '
.$item['time'].' by '.$item['poster']['link'].'</div>
               <div class="news_body" style="padding: 2ex 0;">'
$item['body'], '</div>
               '
$item['link'], $item['locked'] ? ' | Topic Locked' ' | ' $item['comment_link'], '
            </div>'
;
      }
   
?>

Arantor

Well, if you're not getting the full link, something's actually wrong since it's derived from the $boardurl itself which means $boardurl is probably set wrong in your forum anyway...

What is the entry in Admin > Server Settings > Database and Paths > Forum URL ?

Ant59

#8
Quote from: hadesflames on January 09, 2011, 06:59:48 PM
Give this a shot:

<?php
      
require_once(__FILE__ 'forum/SSI.php');
      global 
$scripturl;
      
$news ssi_boardNews(28nullnull'array');
      foreach (
$news as $item)
      {
         echo 
'
            <div class="news_item">
               <h3 class="news_header"><a href="'
.$item['href'].'">'.$item['subject'].'</a></h3>
               <div class="news_timestamp">Posted '
.$item['time'].' by '.$item['poster']['link'].'</div>
               <div class="news_body" style="padding: 2ex 0;">'
$item['body'], '</div>
               '
$item['link'], $item['locked'] ? ' | Topic Locked' ' | ' $item['comment_link'], '
            </div>'
;
      }
   
?>


Copied your code exactly. Still no joy :(

Quote from: IncognitoMuse on January 09, 2011, 07:50:45 PM
Well, if you're not getting the full link, something's actually wrong since it's derived from the $boardurl itself which means $boardurl is probably set wrong in your forum anyway...

What is the entry in Admin > Server Settings > Database and Paths > Forum URL ?

Tried this already. Everything is set correctly.

Forum URL is set to "http://67.23.243.193/forum"

Illori

can this be moved to the coding board where the user(s) may get better support?

Ant59

Quote from: Illori on January 10, 2011, 05:47:13 AM
can this be moved to the coding board where the user(s) may get better support?

This isn't a coding question. It's a question of how to get the SSI functionality working correctly.

Illori

which is working with code... and not a feature in the core of smf.

Ant59

Quote from: Illori on January 10, 2011, 05:50:54 AM
which is working with code... and not a feature in the core of smf.

Actually, SSI is a core SMF feature. It's not an addition to the coding, or even a modification of it.

Anyway, this isn't helping me with an answer. If you can't help me, please don't post in this topic.

Illori

i was trying to get you further help by getting it moved, i know it is a core feature but the way you are using it requires code... hence moving it to the coding board, but whatever you want. less coding people would read this board and hence less support you would get on your issue.

Arantor

Technically, this can be argued either way :P I'd argue it should be in the Coding Discussion board and were I a moderator I'd move it there, but that's me. Anyway, that's off topic.


OK, do you have any portal mods installed? Anything of the pretty URLs type mods? (Anything that rewrites URLs, basically)

Ant59


Arantor

You mentioned above your board's URL as being that IP address based URL... that is what is in $boardurl in Settings.php, right? (It should be, but no harm in checking.) Oh, and you don't need to bring $scripturl into scope in that page, it's managed by SSI.php.

Any errors in the error log?

Out of interest, that page you mention, that is the entire page and not an include to something else?

Ant59

Quote from: IncognitoMuse on January 10, 2011, 06:05:15 AM
You mentioned above your board's URL as being that IP address based URL... that is what is in $boardurl in Settings.php, right? (It should be, but no harm in checking.)

Yeah it's set right in Settings.php

Quote from: IncognitoMuse on January 10, 2011, 06:05:15 AM
Oh, and you don't need to bring $scripturl into scope in that page, it's managed by SSI.php.

Yeah, I figured that, but tried it anyway.

Quote from: IncognitoMuse on January 10, 2011, 06:05:15 AM
Any errors in the error log?

No related errors.

Quote from: IncognitoMuse on January 10, 2011, 06:05:15 AM
Out of interest, that page you mention, that is the entire page and not an include to something else?

It is the whole page, but does pull parts through functions on an include.

Arantor

And you have no other mods at all?

* IncognitoMuse is really confused.

Since $scripturl is defined in QueryString.php as $boardurl . '/index.php', unless $boardurl is wrong, it should be just fine...

That said, there are circumstances where $scripturl gets rewritten, but that's to include PHPSESSID, rather than anything else... curiouser and curiouser. Random question: are subdomain independent cookies on or off?

Ant59

Tried subdomain independent cookies on and off. Off atm.

Arantor

It'll need to be on anyway for login status to be preserved between forum and outside it in your site.

And you have absolutely no other mods of any kind installed?

Ant59

Absolutely no mods. And I haven't touched any of the code yet. I just installed the forum. Ok, I'll turn it on.

Ant59

The weird thing is though, that the SSI functions work. It loads ssi_boardNews() and prints to array, but the hyper-links, and images have the wrong url still.

Arantor

Question of the day: when you say the links are being generated as domain.com/index.php?xxxx instead of domain.com/forum/index.php?xxxx, where are you checking this? Are you actually viewing the HTML source that's generated or going purely by the link the browser wants to go to?

Ant59

echo $scripturl;

Outputs

http://67.23.243.193/index.php



And



echo $boardurl;

Outputs

http://67.23.243.193

Arantor

Hrm, so it is actually being generated incorrectly as opposed to being merely empty (which is what I was getting at before)

If you globalise $boardurl and echo that, what do you get? I think I know what's at fault here, I think there's a bug in the way it tries to detect the URL when there's an IP address in it...

Ant59

Yeah that makes sense, though I can't figure out why it would cause a difference in the way the url is written.

I globalised $boradurl. Same result.

(Have to leave this for now. Will be back on here later. Thanks loads for your help so far!)

Arantor

OK, let's try something experimental, this may or may not work and without further testing it may have undesired consequences. As far as I know, though, it should not produce any security issues for your forum - it is all about bringing URLs together rather than protecting for security purposes.

QueryString.php, around line 1468:
if (isset($detected_url) && $detected_url != $boardurl)

Change that to:
if (isset($detected_url) && $detected_url != $boardurl && SMF !== 'SSI')

Ant59

Awesome! It worked :) It was in Load.php, not QueryString.php on line 1468. But it all works great now. Thanks so much for your help!! You're brilliant.

Arantor

Don't know why I thought it was QueryString.php, heh, but yeah that's the one. Let me know if it has any odd side effects, but I don't think it should.

noahlearner

HI all,

This is my first post.  be gentle.

I am trying to integrate SMF with MODX and I have included the ssi like this

<?php
require("forums/SSI.php");
?>


and tried to keep it super simple for testing so I used this below to output the standard most recent posts.
<?php
ssi_recentPosts
();
?>


I want the link for"post title" to point to http hxxp:74.54.206.217/forums/index.php?topic=3.msg3;topicseen#new [nonactive], but it instead points to http 74.54.206.217/~acktri/forums/index.php?topic=3.msg3;topicseen#new

I am running 2.0 rc4, server settings are:
local cookies off, subdomain independent cookies off.

I have friendly urls turned on via url rewrites on MODX.

Many Thanks,

Noah

Arantor

That implies you either have the forum URL set wrong in the admin panel or MODX is broken. SSI functions all use $scripturl which is defined based on $boardurl in Settings.php.

Advertisement: