cvs: php4 /pear/PEAR Common.php Remote.php /pear/PEAR/Command Remote.php
| From: | Stig Bakken | Date: | Wed, 02 Oct 2002 21:27:25 +0000 |
| Subject: | cvs: php4 /pear/PEAR Common.php Remote.php /pear/PEAR/Command Remote.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-6817@lists.php.net to get a copy of this message | ||
ssb Wed Oct 2 17:27:25 2002 EDT
Modified files:
/php4/pear/PEAR Common.php Remote.php
/php4/pear/PEAR/Command Remote.php
Log:
* add support for http proxy authorization (thanks Arnaud)
Index: php4/pear/PEAR/Common.php
diff -u php4/pear/PEAR/Common.php:1.77 php4/pear/PEAR/Common.php:1.78
--- php4/pear/PEAR/Common.php:1.77 Thu Aug 15 13:07:12 2002
+++ php4/pear/PEAR/Common.php Wed Oct 2 17:27:24 2002
@@ -17,7 +17,7 @@
// | Tomas V.V.Cox <cox@idecnet.com> |
// +----------------------------------------------------------------------+
//
-// $Id: Common.php,v 1.77 2002/08/15 17:07:12 mj Exp $
+// $Id: Common.php,v 1.78 2002/10/02 21:27:24 ssb Exp $
require_once 'PEAR.php';
require_once 'Archive/Tar.php';
@@ -1470,11 +1470,14 @@
} 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 @@
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 @@
$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))) {
Index: php4/pear/PEAR/Remote.php
diff -u php4/pear/PEAR/Remote.php:1.30 php4/pear/PEAR/Remote.php:1.31
--- php4/pear/PEAR/Remote.php:1.30 Tue Jul 9 06:52:04 2002
+++ php4/pear/PEAR/Remote.php Wed Oct 2 17:27:24 2002
@@ -16,7 +16,7 @@
// | Author: Stig Bakken <ssb@fast.no> |
// +----------------------------------------------------------------------+
//
-// $Id: Remote.php,v 1.30 2002/07/09 10:52:04 ssb Exp $
+// $Id: Remote.php,v 1.31 2002/10/02 21:27:24 ssb Exp $
require_once 'PEAR.php';
require_once 'PEAR/Config.php';
@@ -64,6 +64,13 @@
'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 @@
} 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);
}
Index: php4/pear/PEAR/Command/Remote.php
diff -u php4/pear/PEAR/Command/Remote.php:1.21 php4/pear/PEAR/Command/Remote.php:1.22
--- php4/pear/PEAR/Command/Remote.php:1.21 Tue Jul 2 09:04:01 2002
+++ php4/pear/PEAR/Command/Remote.php Wed Oct 2 17:27:25 2002
@@ -17,7 +17,7 @@
// | |
// +----------------------------------------------------------------------+
//
-// $Id: Remote.php,v 1.21 2002/07/02 13:04:01 dickmann Exp $
+// $Id: Remote.php,v 1.22 2002/10/02 21:27:25 ssb Exp $
require_once 'PEAR/Command/Common.php';
require_once 'PEAR/Common.php';
@@ -147,7 +147,7 @@
'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)';