diff options
author | Stig Bakken <ssb@php.net> | 2002-10-02 21:27:25 +0000 |
---|---|---|
committer | Stig Bakken <ssb@php.net> | 2002-10-02 21:27:25 +0000 |
commit | 01daca5e10cfbebc225864e56b04c15dae54367a (patch) | |
tree | e1fb8cb9022fb1cdb62444303f871ebe587e0051 /pear/PEAR | |
parent | ca0aced7c99a18e6337b3519a1a0ee7ce82605ed (diff) | |
download | php-git-01daca5e10cfbebc225864e56b04c15dae54367a.tar.gz |
* add support for http proxy authorization (thanks Arnaud)
Diffstat (limited to 'pear/PEAR')
-rw-r--r-- | pear/PEAR/Command/Remote.php | 2 | ||||
-rw-r--r-- | pear/PEAR/Common.php | 23 | ||||
-rw-r--r-- | pear/PEAR/Remote.php | 9 |
3 files changed, 24 insertions, 10 deletions
diff --git a/pear/PEAR/Command/Remote.php b/pear/PEAR/Command/Remote.php index dfb3f77707..0e6e94d11d 100644 --- a/pear/PEAR/Command/Remote.php +++ b/pear/PEAR/Command/Remote.php @@ -147,7 +147,7 @@ version of DB is 1.2, the downloaded file will be DB-1.2.tgz.', 'headline' => array('Package', 'Version'), ); foreach ($available as $name => $info) { - $data['data'][] = array($name, $info['stable']); + $data['data'][] = array($name, isset($info['stable']) ? $info['stable'] : '-n/a-'); } if (count($available)==0) { $data = '(no packages installed yet)'; diff --git a/pear/PEAR/Common.php b/pear/PEAR/Common.php index 6f82ff5c86..46d5eb34bb 100644 --- a/pear/PEAR/Common.php +++ b/pear/PEAR/Common.php @@ -1470,11 +1470,14 @@ class PEAR_Common extends PEAR } else { $config = &PEAR_Config::singleton(); } - $proxy_host = $proxy_port = null; - if ($proxy = $config->get('http_proxy')) { - $proxy = str_replace('http://', '', $proxy); - list($proxy_host, $proxy_port) = explode(':', $proxy); - if (empty($proxy_port)) { + $proxy_host = $proxy_port = $proxy_user = $proxy_pass = ''; + if ($proxy = parse_url($config->get('http_proxy'))) { + $proxy_host = @$proxy['host']; + $proxy_port = @$proxy['port']; + $proxy_user = @$proxy['user']; + $proxy_pass = @$proxy['pass']; + + if ($proxy_port == '') { $proxy_port = 8080; } if ($callback) { @@ -1484,7 +1487,7 @@ class PEAR_Common extends PEAR if (empty($port)) { $port = 80; } - if ($proxy_host) { + if ($proxy_host != '') { $fp = @fsockopen($proxy_host, $proxy_port, $errno, $errstr); if (!$fp) { if ($callback) { @@ -1506,8 +1509,12 @@ class PEAR_Common extends PEAR $request = "GET $path HTTP/1.0\r\n"; } $request .= "Host: $host:$port\r\n". - "User-Agent: PHP/".PHP_VERSION."\r\n". - "\r\n"; + "User-Agent: PHP/".PHP_VERSION."\r\n"; + if ($proxy_host != '' && $proxy_user != '') { + $request .= 'Proxy-Authorization: Basic ' . + base64_encode($proxy_user . ':' . $proxy_pass) . "\r\n"; + } + $request .= "\r\n"; fwrite($fp, $request); $headers = array(); while (trim($line = fgets($fp, 1024))) { diff --git a/pear/PEAR/Remote.php b/pear/PEAR/Remote.php index 353f94ff88..aa122c0513 100644 --- a/pear/PEAR/Remote.php +++ b/pear/PEAR/Remote.php @@ -64,6 +64,13 @@ class PEAR_Remote extends PEAR 'lastChange' => filemtime($filename), 'content' => unserialize(implode('', file($filename))), ); + $proxy_host = $proxy_port = $proxy_user = $proxy_pass = ''; + if ($proxy = parse_url($this->config->get('http_proxy'))) { + $proxy_host = @$proxy['host']; + $proxy_port = @$proxy['port']; + $proxy_user = @$proxy['user']; + $proxy_pass = @$proxy['pass']; + } return $result; } @@ -116,7 +123,7 @@ class PEAR_Remote extends PEAR } else { $maxAge = ''; }; - $c = new XML_RPC_Client('/xmlrpc.php'.$maxAge, $server_host, 80); + $c = new XML_RPC_Client('/xmlrpc.php'.$maxAge, $server_host, 80, $proxy_host, $proxy_port, $proxy_user, $proxy_pass); if ($username && $password) { $c->setCredentials($username, $password); } |