Asking for help on a weird integration problem

Started by ForumIntegration, March 03, 2009, 08:37:53 PM

Previous topic - Next topic

ForumIntegration

I am trying to integrate SMF into some existing sites.

The outline of my code is:


   ... ... ... ...
ob_start();
include (SMF_DIR . "/index.php");
$buffer = ob_get_contents();
ob_end_clean();

$forumContent = ob_myFix($buffer);
echo $forumContent;
   ... ... ... ...

function ob_myFix($buffer)
{
    global $scripturl, $sp_url;
   
    logIt("\$scripturl is $scripturl, \$sp_url is $sp_url");
    logIt(" ------------------original buffer-----------------------------------");
    logIt("$buffer");
    logIt(" ----------------done original buffer--------------------------------");
    $buffer = str_replace($scripturl, $sp_url . '/smf.php', $buffer);
    $buffer = str_replace($sp_url . '/smf.php?action=dlattach', $scripturl . '/index.php?action=dlattach', $buffer);
    $buffer = str_replace('name="seqnum" value="0"', 'name="seqnum" value="1"', $buffer);

    logIt(" ----------------fixed buffer ---------------------------------------");
    logIt("$buffer");
    logIt(" ---------------done fixed buffer------------------------------------");
    return $buffer;
}



If I run this code by itself, everything is fine. When I put the forum within the site header and footer, weird things happened with "new post/reply/remove post" etc. 

i.e. for reply a post, after clicking the "post" button, the browser stucks at http://localhost/forum/smf.php?action=post2&start=0;board=2.0 but not redirect to http://localhost/forum/smf.php?board=2.0

I have spent days on this issue but still totally clueless.  :'( :-[ :( >:( Could someone point me to the correct direction?

What makes the SMF automatically redirect to http://localhost/forum/smf.php?board=2.0 after http://localhost/forum/smf.php?action=post2&start=0;board=2.0 is done? What could stop SMF to redirect?

A million thanks!!!!!!


DragonballZ

sound like your building a bridge....to nowhere!

I dont know why orstio didnt just TELL you since he invented all the bridgework (and no, he is not a dentist)

ForumIntegration

Quote from: Orstio on March 03, 2009, 09:26:17 PM
You need to research the integration hooks:

http://www.simplemachines.org/community/index.php?topic=173483.0

Thanks Orstio! I have read this thread and the discussion thread about this.

In my case, I have integrate_verify_user() and integrate_redirect() implemented. As I mentioned, without the site's header and footer, the code is running perfect. But with the site's header and footer, for certain actions like post2/deletemsg, the browser stucks there and does not redirect to the correct page.

:-[

Orstio

What is the code you are using to implement integrate_redirect?

Orstio

Quote from: DragonballZ on March 03, 2009, 09:29:08 PM
sound like your building a bridge....to nowhere!

I dont know why orstio didnt just TELL you since he invented all the bridgework (and no, he is not a dentist)

Actually, I didn't invent it.  [Unknown] created the integration hooks.  I've tweaked them and added a few more, but the ground work was not done by me.

ForumIntegration

#6
Quote from: Orstio on March 03, 2009, 10:08:17 PM
What is the code you are using to implement integrate_redirect?


function integrate_redirect (&$setLocation, &$refresh)
{
    global $sp_url;
   
    $myurl = $sp_url . '/smf.php';
    if ($setLocation == '')
        $setLocation = $myurl;   
    $setLocation = un_htmlspecialchars(ob_myFix($setLocation));
    //logIt("in integrate_redirect, \$setLocation is $setLocation and \$refresh is $refresh");
   
    return true;
}


The logging shows that the $setLocation is set to the expected value: http://localhost/forum/smf.php?board=2.0

Orstio

That is the integrate_redirect function.

What is the code you are using to implement the integrate_redirect function?

ForumIntegration

Problem solved.

The problem is header() called after something already sent out in the site header.

Orstio, thank you very much for your help!

Advertisement: