Tuturial: MyBB with multi domains [small hack]
#1
Wink 
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.
Reply
#2
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
Reply
#3
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'm not even angry. I'm being so sincere right now, even though you broke my heart and killed me. And tore me to pieces, and threw every piece into a fire.
Reply
#4
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
Reply
#5
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.
Dennis Tsang
Former MyBB Team Member
Web: http://dennistt.net
Reply
#6
(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
Reply
#7
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.
Dennis Tsang
Former MyBB Team Member
Web: http://dennistt.net
Reply
#8
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
Reply
#9
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
Reply
#10
Where do i put that code
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)