webmail asks for username and password twice on cPanel 11
Status: Beta
Brought to you by:
myplacedk
When I use www.domainname.com.au/webmail everything works fine.
But when I use webmail.domainname.com.au it asks me for a username and
password twice!
After I do it twice it then goes in and works fine.
I have to do this everytime I use the cpanel proxy and its annoying!
Logged In: YES
user_id=688886
Originator: NO
The problem is that cPanel 11 redirects the browser to /webmail/<skin_name> by using "Location:" header, and cPanel Proxy doesn't replace /webmail references in the header. Here is my quickfix:
Original code
while (true) {
$data = fgets($server, 10240); // FIXME: Can we optimize here with another buffer-size?
if (strlen(trim($data))==0) break;
// Fix hostname in redirects, cookies...
$data = str_replace(
array('localhost:2095', 'localhost:2082', 'localhost:2086'),
array($webmailhost, $cpanelhost, $whmhost),
$data);
if (substr($data, 0, 11) == 'Set-Cookie:') {
$data = str_replace(
'; domain=localhost',
'; domain='.$_SERVER['HTTP_HOST'],
$data);
}
header($data, false);
}
Fixed code
while (true) {
$data = fgets($server, 10240); // FIXME: Can we optimize here with another buffer-size?
if (strlen(trim($data))==0) break;
// Fix hostname in redirects, cookies...
$data = str_replace(
array('localhost:2095', 'localhost:2082', 'localhost:2086'),
array($webmailhost, $cpanelhost, $whmhost),
$data);
if (substr($data, 0, 11) == 'Set-Cookie:') {
$data = str_replace(
'; domain=localhost',
'; domain='.$_SERVER['HTTP_HOST'],
$data);
}
$data = preg_replace('_(\'|"|=|Location: )/webmail_', '$1/webmail_', $data); //<= This is the fix
header($data, false);
}
Hope it works for you...