From 9dee5350d57523885e9a9f696bff418c1908e72c Mon Sep 17 00:00:00 2001 From: Valio Date: Mon, 2 Jul 2012 10:42:28 +0300 Subject: Added proxy to XML/RPC client --- system/libraries/Xmlrpc.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'system') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index eac4ac118..80648c9bd 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -174,7 +174,7 @@ class CI_Xmlrpc { * @param int port * @return void */ - public function server($url, $port = 80) + public function server($url, $port = 80, $proxy=FALSE, $proxy_port = 8080) { if (strpos($url, 'http') !== 0) { @@ -190,7 +190,7 @@ class CI_Xmlrpc { $path .= '?'.$parts['query']; } - $this->client = new XML_RPC_Client($path, $parts['host'], $port); + $this->client = new XML_RPC_Client($path, $parts['host'], $port, $proxy, $proxy_port); } // -------------------------------------------------------------------- @@ -385,6 +385,8 @@ class XML_RPC_Client extends CI_Xmlrpc public $path = ''; public $server = ''; public $port = 80; + public $proxy = FALSE; + public $proxy_port = 8080; public $errno = ''; public $errstring = ''; public $timeout = 5; @@ -398,13 +400,15 @@ class XML_RPC_Client extends CI_Xmlrpc * @param int * @return void */ - public function __construct($path, $server, $port = 80) + public function __construct($path, $server, $port = 80, $proxy = FALSE, $proxy_port = 8080) { parent::__construct(); $this->port = $port; $this->server = $server; $this->path = $path; + $this->proxy = $proxy; + $this->proxy_port = $proxy_port; } // -------------------------------------------------------------------- @@ -436,7 +440,13 @@ class XML_RPC_Client extends CI_Xmlrpc */ public function sendPayload($msg) { - $fp = @fsockopen($this->server, $this->port,$this->errno, $this->errstring, $this->timeout); + $server = $this->server; + $port = $this->port; + if ($this->proxy !== FALSE) { + $server = $this->proxy; + $port = $this->proxy_port; + } + $fp = @fsockopen($server, $port, $this->errno, $this->errstring, $this->timeout); if ( ! is_resource($fp)) { -- cgit v1.2.3-24-g4f1b