Changeset 6c95b3e4 in github


Ignore:
Timestamp:
Apr 19, 2012 5:42:01 AM (13 months ago)
Author:
vbenincasa <vbenincasa@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo
Children:
a2f896b
Parents:
5d66a4b
Message:
  • Update the HTTPSocket class from 2.7 to 2.8 to avoid plugin problems when used with SSL (and when DirectAdmin? uses the option "force_hostname" that requires a correct "host" header value).
File:
1 edited

Legend:

Unmodified
Added
Removed
  • plugins/password/drivers/directadmin.php

    r48e9c14 r6c95b3e4  
    66 * Driver to change passwords via DirectAdmin Control Panel 
    77 * 
    8  * @version 2.0 
     8 * @version 2.1 
    99 * @author Victor Benincasa <vbenincasa@gmail.com> 
    1010 * 
     
    6363 * Very, very basic usage: 
    6464 *   $Socket = new HTTPSocket; 
    65  *   echo $Socket->get('http://user:pass@somesite.com/somedir/some.file?query=string&this=that'); 
     65 *   echo $Socket->get('http://user:pass@somehost.com:2222/CMD_API_SOMEAPI?query=string&this=that'); 
    6666 * 
    6767 * @author Phi1 'l0rdphi1' Stier <l0rdphi1@liquenox.net> 
     68 * @updates 2.7 and 2.8 by Victor Benincasa <vbenincasa @ gmail.com> 
    6869 * @package HTTPSocket 
    69  * @version 2.7 (Updated by Victor Benincasa <vbenincasa@gmail.com>) 
     70 * @version 2.8 
    7071 */ 
    7172class HTTPSocket { 
    7273 
    73     var $version = '2.7'; 
    74  
     74    var $version = '2.8'; 
     75     
    7576    /* all vars are private except $error, $query_cache, and $doFollowLocationHeader */ 
    7677 
     
    108109        if (!is_numeric($port)) 
    109110        { 
    110             $port = 80; 
     111            $port = 2222; 
    111112        } 
    112113 
     
    167168        $this->result_status_code = NULL; 
    168169 
    169         // is our request a http:// ... ? 
    170         if (preg_match('!^http://!i',$request)) 
     170        // is our request a http(s):// ... ? 
     171        if (preg_match('/^(http|https):\/\//i',$request)) 
    171172        { 
    172173            $location = parse_url($request); 
    173174            $this->connect($location['host'],$location['port']); 
    174175            $this->set_login($location['user'],$location['pass']); 
    175  
     176             
    176177            $request = $location['path']; 
    177178            $content = $location['query']; 
     
    186187        $array_headers = array( 
    187188            'User-Agent' => "HTTPSocket/$this->version", 
    188             'Host' => ( $this->remote_port == 80 ? $this->remote_host : "$this->remote_host:$this->remote_port" ), 
     189            'Host' => ( $this->remote_port == 80 ? parse_url($this->remote_host,PHP_URL_HOST) : parse_url($this->remote_host,PHP_URL_HOST).":".$this->remote_port ), 
    189190            'Accept' => '*/*', 
    190191            'Connection' => 'Close' ); 
     
    326327 
    327328        } 
    328  
     329         
    329330        list($this->result_header,$this->result_body) = preg_split("/\r\n\r\n/",$this->result,2); 
    330331 
     
    365366            } 
    366367        } 
     368         
    367369    } 
    368370 
     
    448450    { 
    449451        $array_headers = preg_split("/\r\n/",$this->result_header); 
    450  
     452         
    451453        $array_return = array( 0 => $array_headers[0] ); 
    452454        unset($array_headers[0]); 
Note: See TracChangeset for help on using the changeset viewer.