MyBB Community Forums

Full Version: Tuturial: MyBB with multi domains [small hack]
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hi,

This is a modification that you can run the same MyBB forum with multi domains:

Edit file inc/functions.php at line 228 as following:
while($setting = $db->fetch_array($query))
{
	$mybb->settings[$setting['name']] = $setting['value'];
	if($setting['name'] == 'bburl' || $setting['name'] =='cookiedomain'){
		if($setting['name'] == 'bburl') $settings .= '$settings[\'bburl\'] = \'http://\'.$'.'_SERVER[\'HTTP_HOST\'];'."\n";
		else $settings .= '$settings[\'cookiedomain\'] = \'.\'.$'.'_SERVER[\'HTTP_HOST\'];'."\n";
	}
	else{
		$setting['value'] = addcslashes($setting['value'], '\\"$');
		$settings .= "\$settings['{$setting['name']}'] = \"{$setting['value']}\";\n";
	}
}

This will use the default setting for 'bburl' and 'cookiedomain'.

Demo:
<URLs snipped because no copyright is shown>

Hope this help.
I get this error
Fatal error: Call to a member function fetch_array() on a non-object in C:\inetpub\wwwroot\MyBB\inc\functions.php on line 228
I don't think this would be needed, as you can just use a folder, "/forum/" or a sub-domain.
forums.yoursite.com/forums/
i have my forum in a folder within the wwwroot folder
wwwroot/MyBB/

and the link to get to my page is www.howman.dyndns.info/MyBB but i also got www.howman.ca which goes to wwwroot but if i go www.howman.ca/MyBB/ some of the links do not work like admin control pannel for one and i wanted both to work but i guess this is not for that
With MyBB 1.4.4 the location of this is no longer line 288

You should search for this snippet and replace it.
	while($setting = $db->fetch_array($query))
	{
		$mybb->settings[$setting['name']] = $setting['value'];
		$setting['value'] = addcslashes($setting['value'], '\\"$');
		$settings .= "\$settings['{$setting['name']}'] = \"{$setting['value']}\";\n";
	}
As of MyBB 1.4.4 it is around line 4730.
(2009-04-16, 03:18 AM)Dennis Tsang Wrote: [ -> ]With MyBB 1.4.4 the location of this is no longer line 288

You should search for this snippet and replace it.
	while($setting = $db->fetch_array($query))
	{
		$mybb->settings[$setting['name']] = $setting['value'];
		$setting['value'] = addcslashes($setting['value'], '\\"$');
		$settings .= "\$settings['{$setting['name']}'] = \"{$setting['value']}\";\n";
	}
As of MyBB 1.4.4 it is around line 4730.

Hay thank you very much Dennis Tsang by the way do you know when MyBB 1.4.5 will be released the latest news on the on the first page of the forum was last up dated over a month ago
I hope it was ok to ask that here
RE. 1.4.5: http://community.mybboard.net/thread-48243.html - continue discussing there if necessary
In the future please don't go off topic.
So i replaced line 4731 with this code
while($setting = $db->fetch_array($query))
{
$mybb->settings[$setting['name']] = $setting['value'];
if($setting['name'] == 'bburl' || $setting['name'] =='cookiedomain'){
if($setting['name'] == 'bburl') $settings .= '$settings[\'bburl\'] = \'http://\'.$'.'_SERVER[\'HTTP_HOST\'];'."\n";
else $settings .= '$settings[\'cookiedomain\'] = \'.\'.$'.'_SERVER[\'HTTP_HOST\'];'."\n";
}
else{
$setting['value'] = addcslashes($setting['value'], '\\"$');
$settings .= "\$settings['{$setting['name']}'] = \"{$setting['value']}\";\n";
}
}
Now when it sayes this "This will use the default setting for 'bburl' and 'cookiedomain'" what do i have to replace in the cookie settings
right now www.howman.dyndns.info/MyBB workes but www.howman.ca works but not right you can login but if you click on an image it want you to singh up or if you go to admin cp it take you to the singh inagain
I do with domain only: http://www.xzy.com or http://forum.xzy.com.

In your case, you should add this $_SERVER['REQUEST_URI'] in the cookiedomain

$settings .= '$settings[\'bburl\'] = \'http://\'.$'.'_SERVER[\'HTTP_HOST\'].\'.$'.'_SERVER[\'REQUEST_URI\'];'."\n"; //Please check the corrected statement
Where do i put that code
Pages: 1 2