Using conditional on $_SERVER['HTTP_HOST'] in ExpressionEngine config file - not working
I am using ExpressionEngine 2 (build: 20101220) with Multisite Manager (v2.0 build: 20101215). I have one Main site and 30 subsites. I want users to be able to log in to any of the subsites and, at the same time, be logged in to the Main site. There is a way to do this so the user is logged in to all sites in the config file but the browser throws an error when it has do 30 redirects to set the cookies.
So, I have created a conditional so that, based on which domain you are logging into, it will create the correct list for $config['multi_login_sites']:
$domain = $_SERVER['HTTP_HOST'];
if ($domain == 'www.SiteB.com') {
$config['multi_login_sites'] = "http://www.MainSite.com/|http://www.SiteB.com/";
} else {
$config['multi_login_sites'] = "http://www.MainSite.com/";
}
I can display $config['multi_login_sites'] on the page and can see that when I'm on SiteB, it is correct. But when I log in, I get these errors and the redirect doesn't work:
A PHP Error was encountered
Severity: Notice
Messa开发者_JS百科ge: Undefined index: 2
Filename: member/mod.member_auth.php
Line Number: 243
A PHP Error was encountered
Severity: Notice
Message: Undefined index: 2
Filename: member/mod.member_auth.php
Line Number: 244
Those lines in mod.member_auth.php are the ones below that say 'redirect' and 'link':
// We're done.
$data = array( 'title' => $this->EE->lang->line('mbr_login'),
'heading' => $this->EE->lang->line('thank_you'),
'content' => $this->EE->lang->line('mbr_you_are_logged_in'),
'redirect' => $sites[$this->EE->input->get('orig')],
'link' => array($sites[$this->EE->input->get('orig')], $this->EE->lang->line('back'))
);
If I get rid of the conditional statement and just use $config['multi_login_sites'] = "http://www.MainSite.com/|http://www.SiteB.com/"; then it works fine.
It seems like this is a PHP issue but maybe it's an EE/CodeIgniter thing? Is there something I just don't know about using this type of variable in a conditional?
Make sure you are on www.siteB.com, with de WWW
if ($domain == 'www.SiteB.com')
精彩评论