cvs: php4 /pear/XML RPC.php

From: Date: Wed, 11 Jul 2001 05:29:12 +0000
Subject: cvs: php4 /pear/XML RPC.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-256@lists.php.net to get a copy of this message
mj Wed Jul 11 01:29:12 2001 EDT Modified files: /php4/pear/XML RPC.php Log: * Patch for RPC.php (Submited by: yavor shahpasov <yavo@itena.com.cy>) Index: php4/pear/XML/RPC.php diff -u php4/pear/XML/RPC.php:1.6 php4/pear/XML/RPC.php:1.7 --- php4/pear/XML/RPC.php:1.6 Tue Jul 3 15:00:07 2001 +++ php4/pear/XML/RPC.php Wed Jul 11 01:29:12 2001 @@ -1,7 +1,7 @@ <?php // by Edd Dumbill (C) 1999-2000 // <edd@usefulinc.com> -// $Id: RPC.php,v 1.6 2001/07/03 19:00:07 jon Exp $ +// $Id: RPC.php,v 1.7 2001/07/11 05:29:12 mj Exp $ // License is granted to use or modify this software ("XML-RPC for PHP") // for commercial or non-commercial use provided the copyright of the author @@ -20,6 +20,8 @@ // Adapted to PEAR standards by Stig Sæther Bakken <stig@php.net> +require_once "PEAR.php"; + if (!function_exists('xml_parser_create')) { // Win 32 fix. From: "Leo West" <lwest@imaginet.fr> if($WINDIR) { @@ -448,11 +450,13 @@ var $username=""; var $password=""; - function XML_RPC_Client($path, $server, $port=80) + function XML_RPC_Client($path, $server, $port=80, $proxy="", $proxy_port=8080) { $this->port=$port; $this->server=$server; $this->path=$path; + $this->proxy = $proxy; + $this->proxy_port = $proxy_port ; } function setDebug($in) @@ -482,15 +486,31 @@ function sendPayloadHTTP10($msg, $server, $port, $timeout=0, $username="", $password="") { - if($timeout>0) - $fp=fsockopen($server, $port, - &$this->errno, &$this->errstr, $timeout); - else - $fp=fsockopen($server, $port, - &$this->errno, &$this->errstr); - if (!$fp) { - return 0; - } + // If we're using a proxy open a socket to the proxy server instead to the xml-rpc server + if($this->proxy){ + if($timeout > 0){ + $fp=fsockopen($this->proxy, $this->proxy_port, $this->errno, $this->errstr, $timeout); + } + else{ + $fp=fsockopen($this->proxy, $this->proxy_port, $this->errno, $this->errstr); + } + } + else{ + if($timeout > 0){ + $fp=fsockopen($server, $port, $this->errno, $this->errstr, $timeout); + } + else{ + $fp=fsockopen($server, $port, $this->errno, $this->errstr); + } + } + + if(!$fp && $this->proxy){ + PEAR::raiseError("Connection to proxy server ".$this->proxy.":".$this->proxy_port." failed"); + } + else if(!$fp){ + PEAR::raiseError("Connection to RPC server ".$this->server." failed"); + } + // Only create the payload if it was not created previously if(empty($msg->payload)) $msg->createPayload(); @@ -502,13 +522,26 @@ base64_encode($username . ":" . $password) . "\r\n"; } - $op= "POST " . $this->path. " HTTP/1.0\r\nUser-Agent: PHP XMLRPC 1.0\r\n" . - "Host: ". $this->server . "\r\n" . - $credentials . - "Content-Type: text/xml\r\nContent-Length: " . - strlen($msg->payload) . "\r\n\r\n" . - $msg->payload; - + + if($this->proxy){ + $op = "POST http://" . $this->server; + if($this->proxy_port){ + $op .= ":" . $this->port; + } + } + else{ + $op = "POST "; + } + + $op .= $this->path. " HTTP/1.0\r\nUser-Agent: PHP XMLRPC 1.0\r\n" . + "Host: ". $this->server . "\r\n" . + $credentials . + "Content-Type: text/xml\r\nContent-Length: " . + strlen($msg->payload) . "\r\n\r\n" . + $msg->payload; + + print($op); + if (!fputs($fp, $op, strlen($op))) { $this->errstr="Write error"; return 0;

« previous php.pear.cvs (#256) next »