From: Stig Bakken Date: Fri, 26 Oct 2001 11:45:21 +0000 (+0000) Subject: * implemented "pear list-packages", the first sub-command using xmlrpc X-Git-Tag: POST_PARAMETER_PARSING_API~10 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c278bfc448d9a81bf2b0c85c5e3a50fe51f20bd3;p=php * implemented "pear list-packages", the first sub-command using xmlrpc --- diff --git a/pear/Makefile.in b/pear/Makefile.in index 9d8cf36208..c0dc8999ca 100644 --- a/pear/Makefile.in +++ b/pear/Makefile.in @@ -103,6 +103,7 @@ PEAR_FILES = \ PEAR/Config.php \ PEAR/Installer.php \ PEAR/Packager.php \ + PEAR/Remote.php \ PEAR/Uploader.php \ Payment/Verisign.php \ Schedule/At.php \ diff --git a/pear/PEAR/Remote.php b/pear/PEAR/Remote.php index b813215176..5c66b8e941 100644 --- a/pear/PEAR/Remote.php +++ b/pear/PEAR/Remote.php @@ -52,24 +52,26 @@ class PEAR_Remote extends PEAR } $params = array_slice(func_get_args(), 1); $request = xmlrpc_encode_request($method, $params); - print "

Request:

\n"; - print "

";
-        print htmlspecialchars($request);
-        print "
"; - $fp = @fsockopen($config->get("master_server"), 80); + $server_host = $this->config_object->get("master_server"); + $server_port = 80; + flush(); + $fp = @fsockopen($server_host, $server_port); if (!$fp) { return $this->raiseError("PEAR_Remote::call: connect failed"); } $len = strlen($request); fwrite($fp, ("POST /xmlrpc.php HTTP/1.0\r\n". + "Host: $server_host:$server_port\r\n". "Content-type: text/xml\r\n". "Content-length: $len\r\n". "\r\n$request")); - print "Response:\n"; - while ($line = fgets($fp, 2048)) { - print $line; + $response = ''; + while (trim(fgets($fp, 2048)) != ''); // skip headers + while ($chunk = fread($fp, 10240)) { + $response .= $chunk; } - // XXX UNFINISHED + fclose($fp); + return xmlrpc_decode($response); } // }}} diff --git a/pear/scripts/pear.in b/pear/scripts/pear.in index c5f7ec642b..ecdfa88102 100644 --- a/pear/scripts/pear.in +++ b/pear/scripts/pear.in @@ -137,6 +137,23 @@ switch ($command) { case 'list-packages': { include_once 'PEAR/Remote.php'; $remote = new PEAR_Remote($config); + $result = $remote->call('package.listAll'); + $i = $j = 0; + foreach ($result as $package) { + if ($i++ % 20 == 0) { + if ($j++ > 0) { + print "\n"; + } + printf("%-20s %-10s %-15s %s\n", + "Package", "Stable", "Lead", "Category"); + print str_repeat("=", 75)."\n"; + } + $stable = $package['stable']; + printf("%-20s %-10s %-15s %s\n", $package['name'], + $stable ? $stable : "???", + $package['lead'], $package['category']); + } + break; } // }}}