From: x2000habouzit Date: Thu, 9 Sep 2004 23:21:42 +0000 (+0000) Subject: some improvements X-Git-Tag: xorg/old~1541 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=41c597be7507e4b14cf4e2fa8f97879da918cc66;p=platal.git some improvements --- diff --git a/include/xml-rpc-client.inc.php b/include/xml-rpc-client.inc.php index 6978218..fe32419 100644 --- a/include/xml-rpc-client.inc.php +++ b/include/xml-rpc-client.inc.php @@ -18,7 +18,7 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: xml-rpc-client.inc.php,v 1.1 2004-09-07 20:05:17 x2000habouzit Exp $ + $Id: xml-rpc-client.inc.php,v 1.2 2004-09-09 23:21:42 x2000habouzit Exp $ ***************************************************************************/ require_once('xml-rpc.inc.php'); @@ -57,8 +57,8 @@ class xmlrpc_client $requestprms['args'] = $arguments; $requestprms['debug'] = 0; $requestprms['timeout'] = 0; - $requestprms['user'] = NULL; - $requestprms['pass'] = NULL; + $requestprms['user'] = $this->urlparts['user']; + $requestprms['pass'] = $this->urlparts['pass']; $requestprms['secure'] = 0; $result = xu_rpc_http_concise($requestprms); diff --git a/include/xml-rpc.inc.php b/include/xml-rpc.inc.php index b95b820..ad80073 100644 --- a/include/xml-rpc.inc.php +++ b/include/xml-rpc.inc.php @@ -8,7 +8,7 @@ * The Polytechnique.org TEAM * * * ****************************************************************************** - $Id: xml-rpc.inc.php,v 1.3 2004-09-07 20:07:13 x2000habouzit Exp $ + $Id: xml-rpc.inc.php,v 1.4 2004-09-09 23:21:42 x2000habouzit Exp $ ******************************************************************************/ /* @@ -51,68 +51,67 @@ /* generic function to call an http server with post method */ function xu_query_http_post($request, $host, $uri, $port, $debug, $timeout, $user, $pass, $secure=false) { - $response_buf = ""; - if ($host && $uri && $port) { - $content_len = strlen($request); - - $fsockopen = $secure ? "fsockopen_ssl" : "fsockopen"; - - dbg1("opening socket to host: $host, port: $port, uri: $uri", $debug); - $query_fd = $fsockopen($host, $port, $errno, $errstr, 10); - - if ($query_fd) { - - $auth = ""; - if ($user) { - $auth = "Authorization: Basic " . - base64_encode($user . ":" . $pass) . "\r\n"; - } - - $http_request = - "POST $uri HTTP/1.0\r\n" . - "User-Agent: xmlrpc-epi-php/0.2 (PHP)\r\n" . - "Host: $host:$port\r\n" . - $auth . - "Content-Type: text/xml\r\n" . - "Content-Length: $content_len\r\n" . - "\r\n" . - $request; - - dbg1("sending http request: \n$http_request\n", $debug); - - fputs($query_fd, $http_request, strlen($http_request)); - - dbg1("receiving response...", $debug); - - $header_parsed = false; - - $line = fgets($query_fd, 4096); - while ($line) { - if (!$header_parsed) { - if ($line === "\r\n" || $line === "\n") { - $header_parsed = 1; - } - dbg2("got header - $line", $debug); - } - else { - $response_buf .= $line; - } - $line = fgets($query_fd, 4096); - } - - fclose($query_fd); - } - else { - dbg1("socket open failed", $debug); - } - } - else { - dbg1("missing param(s)", $debug); - } + $response_buf = ""; + if ($host && $uri && $port) { + $content_len = strlen($request); + + $fsockopen = $secure ? "fsockopen_ssl" : "fsockopen"; + + dbg1("opening socket to host: $host, port: $port, uri: $uri", $debug); + $query_fd = $fsockopen($host, $port, $errno, $errstr, 10); + + if ($query_fd) { + + $auth = ""; + if ($user) { + $auth = "Authorization: Basic " . base64_encode($user . ":" . $pass) . "\r\n"; + } + + $http_request = + "POST $uri HTTP/1.0\r\n" . + "Host: $host:$port\r\n" . + $auth . + "User-Agent: xmlrpc-epi-php/0.2 (PHP)\r\n" . + "Content-Type: text/xml\r\n" . + "Content-Length: $content_len\r\n" . + "Connection: Close\r\n" . + "\r\n" . + $request; + + dbg1("sending http request: \n$http_request\n", $debug); + + fputs($query_fd, $http_request, strlen($http_request)); + + dbg1("receiving response...", $debug); + + $header_parsed = false; + + while (!feof($query_fd)) { + $line = fgets($query_fd, 4096); + if (!$header_parsed) { + if ($line === "\r\n" || $line === "\n") { + $header_parsed = 1; + } + dbg2("got header - $line", $debug); + } + else { + $response_buf .= $line; + } + } + + fclose($query_fd); + } + else { + dbg1("socket open failed", $debug); + } + } + else { + dbg1("missing param(s)", $debug); + } - dbg1("got response:. \n$response_buf\n\n", $debug); + dbg1("got response:. \n$response_buf\n\n", $debug); - return $response_buf; + return $response_buf; } function xu_fault_code($code, $string) {