Menu

#2 cPanel 11 bug fix

open
nobody
Bugfix (1)
5
2007-08-07
2007-08-07
No

cPanel 11 uses the Location HTTP header field for page redirection. This means that redirections to URI's containing "webmail" are not escaped, which means that the standard server redirection bypasses the proxy.

To fix this, parse the HTTP header filelds and escape "webmail"

Where the HTTP response headers are parsed, add the following:
// Fix redirect location URL
if (strpos($data, 'Location: ') === 0)
{
$data = str_replace('/webmail', '/webmail_', $data);
}

This will now parse the Location field and cPanel proxy will work for webmail with cPanel 11.

The loop to process the response header should now be:
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);
}

// Fix redirect location URL
if (strpos($data, 'Location: ') === 0)
{
$data = str_replace('/webmail', '/webmail_', $data);
}

header($data, false);
}

Discussion

  • Nobody/Anonymous

    Logged In: NO

    After composing a message in Squirrelmail and pressing send it gives me a page cannot be displayed and is referencing webmail_.domain.com instead of webmail.domain.com.

    It also does the same thing if you just try to open Horde, or purge your deleted items in Squirrelmail. I'm sure there are other things.

    Can this be resolved? The script works great otherwise.

     
  • Andre Messerschmidt

    cPanel proxy with cPanel 11 patch

     
  • Andre Messerschmidt

    Logged In: YES
    user_id=1859487
    Originator: YES

    Fixed the replacement to ignore webmail in the hostname. SquirrelMail compose message works and Horde now opens.
    File Added: cpanelproxy.php

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.