Janos Kormendi - 2007-08-04

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...