| | |
| | | * |
| | | * Driver to change passwords via DirectAdmin Control Panel |
| | | * |
| | | * @version 2.0 |
| | | * @version 2.1 |
| | | * @author Victor Benincasa <vbenincasa@gmail.com> |
| | | * |
| | | */ |
| | |
| | | * |
| | | * Very, very basic usage: |
| | | * $Socket = new HTTPSocket; |
| | | * echo $Socket->get('http://user:pass@somesite.com/somedir/some.file?query=string&this=that'); |
| | | * echo $Socket->get('http://user:pass@somehost.com:2222/CMD_API_SOMEAPI?query=string&this=that'); |
| | | * |
| | | * @author Phi1 'l0rdphi1' Stier <l0rdphi1@liquenox.net> |
| | | * @updates 2.7 and 2.8 by Victor Benincasa <vbenincasa @ gmail.com> |
| | | * @package HTTPSocket |
| | | * @version 2.7 (Updated by Victor Benincasa <vbenincasa@gmail.com>) |
| | | * @version 2.8 |
| | | */ |
| | | class HTTPSocket { |
| | | |
| | | var $version = '2.7'; |
| | | var $version = '2.8'; |
| | | |
| | | /* all vars are private except $error, $query_cache, and $doFollowLocationHeader */ |
| | | |
| | |
| | | { |
| | | if (!is_numeric($port)) |
| | | { |
| | | $port = 80; |
| | | $port = 2222; |
| | | } |
| | | |
| | | $this->remote_host = $host; |
| | |
| | | $this->error = $this->warn = array(); |
| | | $this->result_status_code = NULL; |
| | | |
| | | // is our request a http:// ... ? |
| | | if (preg_match('!^http://!i',$request)) |
| | | // is our request a http(s):// ... ? |
| | | if (preg_match('/^(http|https):\/\//i',$request)) |
| | | { |
| | | $location = parse_url($request); |
| | | $this->connect($location['host'],$location['port']); |
| | |
| | | |
| | | $array_headers = array( |
| | | 'User-Agent' => "HTTPSocket/$this->version", |
| | | 'Host' => ( $this->remote_port == 80 ? $this->remote_host : "$this->remote_host:$this->remote_port" ), |
| | | 'Host' => ( $this->remote_port == 80 ? parse_url($this->remote_host,PHP_URL_HOST) : parse_url($this->remote_host,PHP_URL_HOST).":".$this->remote_port ), |
| | | 'Accept' => '*/*', |
| | | 'Connection' => 'Close' ); |
| | | |
| | |
| | | $this->query($headers['location']); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | function getTransferSpeed() |