MyBB Community Forums

Full Version: Integration
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi.
I am working on an integration job for a client.
I have a file (http://example.com/forums/wb.php) which has the logic to show the welcome block. If you go to that page in your browser, it shows the memeber block if you are logged in, and the anonymous block when you are not.

If I try to integrate that page into anything in the forums directory, it shows the proper block. If I try to integrate it into anything outside of the forums directory, it does not.

The cookie settings are fine (all blank).

example.com\forums\wb.php code:
<?php
define('IN_MYBB', 1); // (1a)
require "./global.php"; // (1b)
eval("\$wb = \"".$templates->get("wb")."\";"); // (3)
output_page($wb); // (4)
?>

include code:
<?php
$url = "http://example.com/forums/wb.php";
$handle = file_get_contents($url);
echo $handle;
?>

I've used this code many times in this site, it works fine, so it's not the include code's fault.

Why is it doing this?
This is urgent. Please help me.
Here is what I do when i need to create MyBB type pages outside of the MyBB root folder. This example is from my garage plugin

$forumdir = "./board";

//end editing


define("IN_MYBB", 1);
define("IN_GARAGE", 1);

if(substr($_SERVER['SCRIPT_NAME'],0,1) == "/")
{
	define('THIS_SCRIPT', substr($_SERVER['SCRIPT_NAME'],1));
}
else
{
	define('THIS_SCRIPT', $_SERVER['SCRIPT_NAME']);
}
$current_dir = getcwd();

//change working directory to allow board includes to work
$forumdirslash = $forumdir."/";
$change_dir = "./";

if([email protected]($forumdir) && !empty($forumdir))
{
	if(@is_dir($forumdir))
	{
		$change_dir = $forumdir;
	}
	else
	{
		die("\$forumdir is invalid!");
	}
}

//include board files
require_once $change_dir."/global.php";
require_once MYBB_ROOT."inc/functions.php";
require_once MYBB_ROOT."inc/functions_post.php";
require_once MYBB_ROOT."inc/functions_user.php";
require_once MYBB_ROOT."inc/class_parser.php";

//include garage files
require_once MYBB_ROOT."inc/functions_garage.php";

//change directory back to current where script is
@chdir($current_dir);