Results 1 to 6 of 6

Thread: Port Free Web Mail

  1. #1
    Senior Member
    Join Date
    Sep 2003
    Location
    London
    Posts
    255
    Thanks
    1
    Thanked
    0 times in 0 posts

    Port Free Web Mail

    Due to firewall setup at work I cannot access my web host provided webmail squirrel mail etc or cpanel. I use to use a script from hasweb.com but due to problems I have lost the script. I have tried to find a copy of it but cannot find it anywhere. I have found a program for accessing cpanel but not the webmail. Can anyone assist
    Specs:

    Q6600 G0, Thermalright Ultra 120, ABIT IP35 PRO, 4GB Corsair DDR2, Trusty old Tagan 480u, BFG 8800 GTS 512, Samsung F1 750 GB.

    "Only two things are infinite, the universe and human stupidity, and I'm not sure about the former."

    Albert Einstein

  2. #2
    Ex-MSFT Paul Adams's Avatar
    Join Date
    Jul 2003
    Location
    %systemroot%
    Posts
    1,926
    Thanks
    29
    Thanked
    77 times in 59 posts
    • Paul Adams's system
      • Motherboard:
      • Asus Maximus VIII
      • CPU:
      • Intel Core i7-6700K
      • Memory:
      • 16GB
      • Storage:
      • 2x250GB SSD / 500GB SSD / 2TB HDD
      • Graphics card(s):
      • nVidia GeForce GTX1080
      • Operating System:
      • Windows 10 x64 Pro
      • Monitor(s):
      • Philips 40" 4K
      • Internet:
      • 500Mbps fiber
    Is there a company policy against accessing all webmail?

    If there isn't then I'd recommend contacting your network admin, and if there is then you shouldn't be trying to circumvent the policy!
    ~ I have CDO. It's like OCD except the letters are in alphabetical order, as they should be. ~
    PC: Win10 x64 | Asus Maximus VIII | Core i7-6700K | 16GB DDR3 | 2x250GB SSD | 500GB SSD | 2TB SATA-300 | GeForce GTX1080
    Camera: Canon 60D | Sigma 10-20/4.0-5.6 | Canon 100/2.8 | Tamron 18-270/3.5-6.3

  3. #3
    Senior Member
    Join Date
    Sep 2003
    Location
    London
    Posts
    255
    Thanks
    1
    Thanked
    0 times in 0 posts
    I think its because port that the webmail uses is blocked. I have spoken to networks and it will remain blocked although there is no policy against webmail. This is why I have to find an alternative.
    Specs:

    Q6600 G0, Thermalright Ultra 120, ABIT IP35 PRO, 4GB Corsair DDR2, Trusty old Tagan 480u, BFG 8800 GTS 512, Samsung F1 750 GB.

    "Only two things are infinite, the universe and human stupidity, and I'm not sure about the former."

    Albert Einstein

  4. #4
    Ex-MSFT Paul Adams's Avatar
    Join Date
    Jul 2003
    Location
    %systemroot%
    Posts
    1,926
    Thanks
    29
    Thanked
    77 times in 59 posts
    • Paul Adams's system
      • Motherboard:
      • Asus Maximus VIII
      • CPU:
      • Intel Core i7-6700K
      • Memory:
      • 16GB
      • Storage:
      • 2x250GB SSD / 500GB SSD / 2TB HDD
      • Graphics card(s):
      • nVidia GeForce GTX1080
      • Operating System:
      • Windows 10 x64 Pro
      • Monitor(s):
      • Philips 40" 4K
      • Internet:
      • 500Mbps fiber
    Weird, I thought all webmail just used regular HTTPS on port 443.
    You live & learn.

    Do the webmail hosting company not have a FAQ on connectivity problems?
    If they are using a nonstandard port then I would have thought they'd have had quite a few users potentially having problems.
    ~ I have CDO. It's like OCD except the letters are in alphabetical order, as they should be. ~
    PC: Win10 x64 | Asus Maximus VIII | Core i7-6700K | 16GB DDR3 | 2x250GB SSD | 500GB SSD | 2TB SATA-300 | GeForce GTX1080
    Camera: Canon 60D | Sigma 10-20/4.0-5.6 | Canon 100/2.8 | Tamron 18-270/3.5-6.3

  5. #5
    You're god damn right Barry's Avatar
    Join Date
    Jul 2003
    Posts
    1,484
    Thanks
    70
    Thanked
    75 times in 59 posts
    • Barry's system
      • Motherboard:
      • Gigabyte Z270M-D3H
      • CPU:
      • Intel i7 7700
      • Memory:
      • 16GB (2x8GB) Avexir 2400
      • Storage:
      • Samsung 860 256GB SSD, Sandisk Ultra 3D 500GB, LG BR Writer
      • Graphics card(s):
      • Evga GeForce GTX Titan X 12GB
      • PSU:
      • Corsair RM750I
      • Case:
      • Fractal Design Focus G
      • Operating System:
      • Windows 10 Professional
      • Monitor(s):
      • 28" Acer UHD 4K2K
      • Internet:
      • Sky Fibre
    Couple ways to do this.

    1. This should be added to your apache.conf and ips changed..

    Code:
     <VirtualHost 192.168.0.2:80>
    ServerName cpanel.servername.co.uk
    ProxyPass / http://192.168.0.1:1234
    ProxyPassReverse / http://10.0.0.1:1234/
    </VirtualHost>
    2. alot easyer (can do it without asking for the apache.conf to be changed)

    This goes in a .htaccess file

    Code:
     RewriteEngine on
    RewriteCond %{REQUEST_URI} !^/proxy.php
    RewriteRule .* /proxy.php [last]
    and call this proxy.php

    Code:
    <?php
    
    //// Config
    
    // Last part of hostnames
    $hostpostfix = preg_replace('/^.*?\./', '', $_SERVER['HTTP_HOST']);
    
    // First parts of hostnames
    $webmailhost = 'webmail.'.$hostpostfix;
    $cpanelhost = 'cpanel.'.$hostpostfix;
    $whmhost = 'whm.'.$hostpostfix;
    
    // The host where cPanel is running. I strongly suggest having this script on 
    // the same server as cPanel, and leaving this setting at default "localhost".
    $host = 'localhost';
    
    // I'm honestly not sure if \r\n or \n is most correct, but in this case it 
    // just needs to work.
    $nl = "\r\n";
    
    function error($header, $string) {
      echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html>
    <head>
    <title>Error</title>
    </head>
    <body>
    <h1>Error: '.$header.'</h1>
    '.$string.'
    <hr />
    <div style="font-size: 0.8em;"><a href="http://www.hosting-unlimited.net/">'
    .'cPanel Proxy 0.2</a></div>
    </body>
    </html>
    ';
    }
    
    switch($_SERVER['HTTP_HOST']) {
     case $webmailhost:
       $port = 2095;
       break;
     case $cpanelhost:
       $port = 2082;
       break;
     case $whmhost:
       $port = 2086;
       break;
     default:
       error(
    	 'Hostname not recognised','<p>Server is misconfigured or you have '
    .'entered a wrong address. You can try these instead:</p>
    
    <table>
    <tr><td>Webmail: </td><td><a href="http://'.$webmailhost.'/">http://'
    .$webmailhost.'/</a></td></tr>
    <tr><td>cPanel: </td><td><a href="http://'.$cpanelhost.'/">http://'
    .$cpanelhost.'/</a></td></tr>
    <tr><td>WHM: </td><td><a href="http://'.$whmhost.'/">http://'.$whmhost
    .'/</a></td></tr>
    </table>
    ');
       exit;
    }
    
    
    //// Get headers from browser
    
    // "/webmail" is replaced with "/webmail_" in the url, so the server won't
    // redirect browsers using this proxy for webmail.
    // The protocol is hardcoded to HTTP 1.0. Then we don't have to worry about
    // chunked transfers, as 1.1 forces you to.
    $frombrowser = $_SERVER['REQUEST_METHOD']." "
    .str_replace('/webmail_', '/webmail',$_SERVER['REQUEST_URI'])." "
    .'HTTP/1.0'.$nl;
    
    
    foreach($_SERVER as $a=>$b) {
      if ($a == 'HTTP_HOST') $b = "$host:$port";
      if ($a == 'HTTP_CONNECTION') $b = "Close"; // FIXME: Maybe a persitent socket could be good for performance. Do we need to make sure only the same browser reuses a socket, or is persistent sockets as stateless as usual?
      if (substr($a,0,5)=='HTTP_') {
        $frombrowser .= substr($a,5)
          .': '. $b.$nl;
      }
    }
    
    // That was the regular headers. Now we need to re-generate the headers that 
    // was parsed and thrown away before this scripts gets a chance to see them.
    
    // First authentication.
    if (isset($_SERVER['PHP_AUTH_USER']) 
        && !isset($_SERVER['HTTP_AUTHORIZATION'])) {
      $frombrowser .= "Authorization: Basic "
    .base64_encode($_SERVER['PHP_AUTH_USER'].':'.$_SERVER['PHP_AUTH_PW']).$nl;
    }
    
    // End of browsers headers (for now).
    
    switch($_SERVER['REQUEST_METHOD']) {
    
     case 'HEAD':
     case 'GET':
       // We're done, signalling this with an extra newline.
       $frombrowser .= $nl;
       break;
    
     case 'POST':
       // We probably have a body, we need to include this.
       
       $input = fopen('php://input','r');
       $frombrowser_body = '';
    
       if (strpos(@$_SERVER['CONTENT_TYPE'], 'multipart/form-data')===false) {
    
         // Not multipart/form-data, sending body directly from browser
         
         // First we get the entire post body.
         while (true) {
           $data = fread($input, 10240); // FIXME: Can we optimize here with another buffer-size?
           if (strlen($data)===0) break;
           $frombrowser_body .= $data;
         }
         
         if (strlen(@$_SERVER['CONTENT_TYPE'])) {
           $frombrowser .= "Content-Type: ".$_SERVER['CONTENT_TYPE'].$nl;
         }
    
       } else {
    
         // multipart/form-data
         
         $boundary = '--------'.md5(time()); // FIXME: Do we need a better algorithm to generate boundary string?
         $frombrowser .= "Content-Type: multipart/form-data; boundary="
           .$boundary.$nl;
         foreach($_POST as $name=>$data) {
           $frombrowser_body .= '--'.$boundary.$nl
    	 .'Content-Disposition: form-data; name="'.$name.'"'.$nl
    	 .$nl.$data.$nl; // FIXME: If $data is an array, handle that correctly.
         }
    
         foreach($_FILES as $name=>$data) {
           if (!is_uploaded_file($data['tmp_name'])) continue;
    
           $frombrowser_body .= '--'.$boundary.$nl
    	 .'Content-Disposition: form-data; name="'.$name.'";'
    	 .' filename="'.$data['name'].'"'.$nl; // FIXME: Do we need some kind of encoding here? What if the filename (or the name) has characters like double-quote, colon, semicolon, \n or \r?
           // (Uploading a file with double-quote in filename with Mozilla thru this script fails, I have not done any further testing yet.)
           $frombrowser_body .= 'Content-Type: '.$data['type'].$nl
    	 .$nl
    	 .file_get_contents($data['tmp_name'])
    	 .$nl;
         }
         $frombrowser_body .= '--'.$boundary.$nl;
        }
       
       // Okay, now we can finish the headers and attach the body.
       $frombrowser .= "Content-Length: ".strlen($frombrowser_body).$nl
         .$nl
         .$frombrowser_body;
    
       break;
    
     default:
       error(
    	 'Method not implemented',
    	 '<p>Method '.$_SERVER['REQUEST_METHOD'].' not supported in cPanel '
    .'Proxy, sorry.</p>'
    	 );
       exit;
    }
    
    // Time to contact server and send request
    $server = fsockopen($host, $port);
    fputs($server, $frombrowser);
    
    
    // Get server headers
    while (true) {
      $data = fgets($server, 10240); // FIXME: Can we optimize here with another buffer-size?
      if (strlen(trim($data))==0) break;
    
      // Fix redirects, so browser keeps using proxy for webmail
      // I'm not sure if there's any redirects other than in webmail
      $data = str_replace(
    		      'Location: http://localhost:2095',
    		      'Location: http://'.$_SERVER['HTTP_HOST'],
    		      $data);
      header($data);
    }
    
    if($_SERVER['REQUEST_METHOD']=='HEAD') {
      exit;
    }
    
    // Get server body
    $data = '';
    while (true) {
      $line = fgets($server, 10240); // FIXME: Can we optimize here with another buffer-size?
      if (strlen($line)===0) break;
      $data .= preg_replace('_("|=)/webmail_', '$1/webmail_', $line);
      // This has heavy influence on chunk-size (for HTTP/1.1 to browser)
      if (strlen($data)>10240) { // FIXME: Can we optimize here with another buffer-size?
        echo $data;
        flush();
        $data = '';
      }
    }
    // $data is probably not empty.
    echo $data;
    ?>
    Someone left a note on a piece of cake in the fridge that said, "Do not eat!". I ate the cake and left a note saying, "Yuck, who the hell eats paper ?

  6. #6
    Registered User
    Join Date
    Jun 2004
    Posts
    1
    Thanks
    0
    Thanked
    0 times in 0 posts
    That version of the script is old and has lots of bugs.
    Go here to get the latest version: http://cpanelproxy.net/

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Fleetwood Computers free shipping - reduced cathodes
    By Lexeus in forum Retail Therapy and Bargains
    Replies: 5
    Last Post: 14-03-2004, 03:01 AM
  2. game port on a7n8x deluxe, but not a7n8x-e deluxe
    By cm_uk in forum PC Hardware and Components
    Replies: 0
    Last Post: 11-02-2004, 02:43 PM
  3. Free Clothes ! With Vouchers
    By Scooby in forum Retail Therapy and Bargains
    Replies: 132
    Last Post: 16-01-2004, 11:26 AM
  4. NTL: free install and 1 month free
    By Jayson in forum Retail Therapy and Bargains
    Replies: 29
    Last Post: 02-10-2003, 02:19 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •