From f4a4bd8fac188ebc9cda822ffc811c218fd92b45 Mon Sep 17 00:00:00 2001 From: Derek Jones Date: Thu, 20 Oct 2011 12:18:42 -0500 Subject: adding new license file (OSL 3.0) and updating readme to ReST added notice of license to all source files. OSL to all except the few files we ship inside of the application folder, those are AFL. Updated license in user guide. incrementing next dev version to 3.0 due to licensing change --- system/libraries/Xmlrpc.php | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'system/libraries/Xmlrpc.php') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index 5da6ea6ae..2f66ef09a 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -4,10 +4,22 @@ * * An open source application development framework for PHP 5.1.6 or newer * + * NOTICE OF LICENSE + * + * Licensed under the Open Software License version 3.0 + * + * This source file is subject to the Open Software License (OSL 3.0) that is + * bundled with this package in the files license.txt / license.rst. It is + * also available through the world wide web at this URL: + * http://opensource.org/licenses/OSL-3.0 + * If you did not receive a copy of the license and are unable to obtain it + * through the world wide web, please send an email to + * licensing@ellislab.com so we can send you a copy immediately. + * * @package CodeIgniter - * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. - * @license http://codeigniter.com/user_guide/license.html + * @author EllisLab Dev Team + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/) + * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com * @since Version 1.0 * @filesource @@ -27,7 +39,7 @@ if ( ! function_exists('xml_parser_create')) * @package CodeIgniter * @subpackage Libraries * @category XML-RPC - * @author ExpressionEngine Dev Team + * @author EllisLab Dev Team * @link http://codeigniter.com/user_guide/libraries/xmlrpc.html */ class CI_Xmlrpc { @@ -347,7 +359,7 @@ class CI_Xmlrpc { * XML-RPC Client class * * @category XML-RPC - * @author ExpressionEngine Dev Team + * @author EllisLab Dev Team * @link http://codeigniter.com/user_guide/libraries/xmlrpc.html */ class XML_RPC_Client extends CI_Xmlrpc @@ -425,7 +437,7 @@ class XML_RPC_Client extends CI_Xmlrpc * XML-RPC Response class * * @category XML-RPC - * @author ExpressionEngine Dev Team + * @author EllisLab Dev Team * @link http://codeigniter.com/user_guide/libraries/xmlrpc.html */ class XML_RPC_Response @@ -604,7 +616,7 @@ class XML_RPC_Response * XML-RPC Message class * * @category XML-RPC - * @author ExpressionEngine Dev Team + * @author EllisLab Dev Team * @link http://codeigniter.com/user_guide/libraries/xmlrpc.html */ class XML_RPC_Message extends CI_Xmlrpc @@ -1203,7 +1215,7 @@ class XML_RPC_Message extends CI_Xmlrpc * XML-RPC Values class * * @category XML-RPC - * @author ExpressionEngine Dev Team + * @author EllisLab Dev Team * @link http://codeigniter.com/user_guide/libraries/xmlrpc.html */ class XML_RPC_Values extends CI_Xmlrpc -- cgit v1.2.3-24-g4f1b From b1cbd712c84649a00fee5293cfcb3cc8a05db2ec Mon Sep 17 00:00:00 2001 From: Syahril Zulkefli Date: Sun, 13 Nov 2011 23:46:58 +0800 Subject: Fix invalid datetime format --- system/libraries/Xmlrpc.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'system/libraries/Xmlrpc.php') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index 2f66ef09a..7b1e3fa6e 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -1416,14 +1416,14 @@ class XML_RPC_Values extends CI_Xmlrpc { if ($utc == 1) { - $t = strftime("%Y%m%dT%H:%M:%S", $time); + $t = strftime("%Y%m%dT%H:%i:%s", $time); } else { if (function_exists('gmstrftime')) - $t = gmstrftime("%Y%m%dT%H:%M:%S", $time); + $t = gmstrftime("%Y%m%dT%H:%i:%s", $time); else - $t = strftime("%Y%m%dT%H:%M:%S", $time - date('Z')); + $t = strftime("%Y%m%dT%H:%i:%s", $time - date('Z')); } return $t; } -- cgit v1.2.3-24-g4f1b From a30faf95d1d833f716dd1e181cef5b33b02ef8b9 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 25 Dec 2011 18:15:34 +0200 Subject: Improve the Xmlrpc library --- system/libraries/Xmlrpc.php | 408 +++++++++++++++++++------------------------- 1 file changed, 180 insertions(+), 228 deletions(-) (limited to 'system/libraries/Xmlrpc.php') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index 7b1e3fa6e..ebb04601b 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -1,13 +1,13 @@ -xmlrpcName = $this->xmlrpcName; + $this->xmlrpcName = $this->xmlrpcName; $this->xmlrpc_backslash = chr(92).chr(92); // Types for info sent back and forth @@ -101,23 +101,23 @@ class CI_Xmlrpc { // Array of Valid Parents for Various XML-RPC elements $this->valid_parents = array('BOOLEAN' => array('VALUE'), - 'I4' => array('VALUE'), - 'INT' => array('VALUE'), - 'STRING' => array('VALUE'), - 'DOUBLE' => array('VALUE'), - 'DATETIME.ISO8601' => array('VALUE'), - 'BASE64' => array('VALUE'), - 'ARRAY' => array('VALUE'), - 'STRUCT' => array('VALUE'), - 'PARAM' => array('PARAMS'), - 'METHODNAME' => array('METHODCALL'), - 'PARAMS' => array('METHODCALL', 'METHODRESPONSE'), - 'MEMBER' => array('STRUCT'), - 'NAME' => array('MEMBER'), - 'DATA' => array('ARRAY'), - 'FAULT' => array('METHODRESPONSE'), - 'VALUE' => array('MEMBER', 'DATA', 'PARAM', 'FAULT') - ); + 'I4' => array('VALUE'), + 'INT' => array('VALUE'), + 'STRING' => array('VALUE'), + 'DOUBLE' => array('VALUE'), + 'DATETIME.ISO8601' => array('VALUE'), + 'BASE64' => array('VALUE'), + 'ARRAY' => array('VALUE'), + 'STRUCT' => array('VALUE'), + 'PARAM' => array('PARAMS'), + 'METHODNAME' => array('METHODCALL'), + 'PARAMS' => array('METHODCALL', 'METHODRESPONSE'), + 'MEMBER' => array('STRUCT'), + 'NAME' => array('MEMBER'), + 'DATA' => array('ARRAY'), + 'FAULT' => array('METHODRESPONSE'), + 'VALUE' => array('MEMBER', 'DATA', 'PARAM', 'FAULT') + ); // XML-RPC Responses @@ -128,7 +128,7 @@ class CI_Xmlrpc { $this->xmlrpcerr['incorrect_params'] = '3'; $this->xmlrpcstr['incorrect_params'] = 'Incorrect parameters were passed to method'; $this->xmlrpcerr['introspect_unknown'] = '4'; - $this->xmlrpcstr['introspect_unknown'] = "Cannot inspect signature for request: method unknown"; + $this->xmlrpcstr['introspect_unknown'] = 'Cannot inspect signature for request: method unknown'; $this->xmlrpcerr['http_error'] = '5'; $this->xmlrpcstr['http_error'] = "Did not receive a '200 OK' response from remote server."; $this->xmlrpcerr['no_data'] = '6'; @@ -144,7 +144,7 @@ class CI_Xmlrpc { // Initialize Prefs //------------------------------------- - function initialize($config = array()) + public function initialize($config = array()) { if (count($config) > 0) { @@ -163,9 +163,9 @@ class CI_Xmlrpc { // Take URL and parse it //------------------------------------- - function server($url, $port=80) + public function server($url, $port=80) { - if (substr($url, 0, 4) != "http") + if (strpos($url, 'http') !== 0) { $url = "http://".$url; } @@ -187,7 +187,7 @@ class CI_Xmlrpc { // Set Timeout //------------------------------------- - function timeout($seconds=5) + public function timeout($seconds = 5) { if ( ! is_null($this->client) && is_int($seconds)) { @@ -200,7 +200,7 @@ class CI_Xmlrpc { // Set Methods //------------------------------------- - function method($function) + public function method($function) { $this->method = $function; } @@ -210,7 +210,7 @@ class CI_Xmlrpc { // Take Array of Data and Create Objects //------------------------------------- - function request($incoming) + public function request($incoming) { if ( ! is_array($incoming)) { @@ -231,42 +231,34 @@ class CI_Xmlrpc { // Set Debug //------------------------------------- - function set_debug($flag = TRUE) + public function set_debug($flag = TRUE) { - $this->debug = ($flag == TRUE) ? TRUE : FALSE; + $this->debug = ($flag == TRUE); } //------------------------------------- // Values Parsing //------------------------------------- - function values_parsing($value, $return = FALSE) + public function values_parsing($value, $return = FALSE) { if (is_array($value) && array_key_exists(0, $value)) { - if ( ! isset($value['1']) OR ( ! isset($this->xmlrpcTypes[$value['1']]))) + if ( ! isset($value[1]) OR ( ! isset($this->xmlrpcTypes[$value[1]]))) { - if (is_array($value[0])) - { - $temp = new XML_RPC_Values($value['0'], 'array'); - } - else - { - $temp = new XML_RPC_Values($value['0'], 'string'); - } + $temp = new XML_RPC_Values($value[0], (is_array($value[0]) ? 'array' : 'string')); } - elseif (is_array($value['0']) && ($value['1'] == 'struct' OR $value['1'] == 'array')) + else { - while (list($k) = each($value['0'])) + if (is_array($value[0]) && ($value[1] == 'struct' OR $value[1] == 'array')) { - $value['0'][$k] = $this->values_parsing($value['0'][$k], TRUE); + while (list($k) = each($value[0])) + { + $value[0][$k] = $this->values_parsing($value[0][$k], TRUE); + } } - $temp = new XML_RPC_Values($value['0'], $value['1']); - } - else - { - $temp = new XML_RPC_Values($value['0'], $value['1']); + $temp = new XML_RPC_Values($value[0], $value[1]); } } else @@ -283,24 +275,18 @@ class CI_Xmlrpc { // Sends XML-RPC Request //------------------------------------- - function send_request() + public function send_request() { $this->message = new XML_RPC_Message($this->method,$this->data); $this->message->debug = $this->debug; - if ( ! $this->result = $this->client->send($this->message)) - { - $this->error = $this->result->errstr; - return FALSE; - } - elseif ( ! is_object($this->result->val)) + if ( ! $this->result = $this->client->send($this->message) OR ! is_object($this->result->val)) { $this->error = $this->result->errstr; return FALSE; } $this->response = $this->result->decode(); - return TRUE; } // END @@ -309,7 +295,7 @@ class CI_Xmlrpc { // Returns Error //------------------------------------- - function display_error() + public function display_error() { return $this->error; } @@ -319,7 +305,7 @@ class CI_Xmlrpc { // Returns Remote Server Response //------------------------------------- - function display_response() + public function display_response() { return $this->response; } @@ -329,9 +315,9 @@ class CI_Xmlrpc { // Sends an Error Message for Server Request //------------------------------------- - function send_error_message($number, $message) + public function send_error_message($number, $message) { - return new XML_RPC_Response('0',$number, $message); + return new XML_RPC_Response(0, $number, $message); } // END @@ -340,14 +326,11 @@ class CI_Xmlrpc { // Send Response for Server Request //------------------------------------- - function send_response($response) + public function send_response($response) { // $response should be array of values, which will be parsed // based on their data and type into a valid group of XML-RPC values - - $response = $this->values_parsing($response); - - return new XML_RPC_Response($response); + return new XML_RPC_Response($this->values_parsing($response)); } // END @@ -364,13 +347,13 @@ class CI_Xmlrpc { */ class XML_RPC_Client extends CI_Xmlrpc { - var $path = ''; - var $server = ''; - var $port = 80; - var $errno = ''; - var $errstring = ''; - var $timeout = 5; - var $no_multicall = FALSE; + public $path = ''; + public $server = ''; + public $port = 80; + public $errno = ''; + public $errstring = ''; + public $timeout = 5; + public $no_multicall = FALSE; public function __construct($path, $server, $port=80) { @@ -381,7 +364,7 @@ class XML_RPC_Client extends CI_Xmlrpc $this->path = $path; } - function send($msg) + public function send($msg) { if (is_array($msg)) { @@ -393,7 +376,7 @@ class XML_RPC_Client extends CI_Xmlrpc return $this->sendPayload($msg); } - function sendPayload($msg) + public function sendPayload($msg) { $fp = @fsockopen($this->server, $this->port,$this->errno, $this->errstr, $this->timeout); @@ -411,12 +394,12 @@ class XML_RPC_Client extends CI_Xmlrpc } $r = "\r\n"; - $op = "POST {$this->path} HTTP/1.0$r"; - $op .= "Host: {$this->server}$r"; - $op .= "Content-Type: text/xml$r"; - $op .= "User-Agent: {$this->xmlrpcName}$r"; - $op .= "Content-Length: ".strlen($msg->payload). "$r$r"; - $op .= $msg->payload; + $op = "POST {$this->path} HTTP/1.0$r" + . "Host: {$this->server}$r" + . "Content-Type: text/xml$r" + . "User-Agent: {$this->xmlrpcName}$r" + . "Content-Length: ".strlen($msg->payload)."$r$r" + . $msg->payload; if ( ! fputs($fp, $op, strlen($op))) @@ -430,8 +413,8 @@ class XML_RPC_Client extends CI_Xmlrpc return $resp; } -} // end class XML_RPC_Client - +} +// end class XML_RPC_Client /** * XML-RPC Response class @@ -442,11 +425,11 @@ class XML_RPC_Client extends CI_Xmlrpc */ class XML_RPC_Response { - var $val = 0; - var $errno = 0; - var $errstr = ''; - var $headers = array(); - var $xss_clean = TRUE; + public $val = 0; + public $errno = 0; + public $errstr = ''; + public $headers = array(); + public $xss_clean = TRUE; public function __construct($val, $code = 0, $fstr = '') { @@ -468,27 +451,26 @@ class XML_RPC_Response } } - function faultCode() + public function faultCode() { return $this->errno; } - function faultString() + public function faultString() { return $this->errstr; } - function value() + public function value() { return $this->val; } - function prepare_response() + public function prepare_response() { - $result = "\n"; - if ($this->errno) - { - $result .= ' + return "\n" + . ($this->errno + ? ' @@ -501,23 +483,16 @@ class XML_RPC_Response -'; - } - else - { - $result .= "\n\n" . - $this->val->serialize_class() . - "\n"; - } - $result .= "\n"; - return $result; +' + : "\n\n".$this->val->serialize_class()."\n") + . "\n"; } - function decode($array=FALSE) + public function decode($array = FALSE) { $CI =& get_instance(); - - if ($array !== FALSE && is_array($array)) + + if (is_array($array)) { while (list($key) = each($array)) { @@ -556,7 +531,7 @@ class XML_RPC_Response // XML-RPC Object to PHP Types //------------------------------------- - function xmlrpc_decoder($xmlrpc_val) + public function xmlrpc_decoder($xmlrpc_val) { $kind = $xmlrpc_val->kindOf(); @@ -568,11 +543,9 @@ class XML_RPC_Response { reset($xmlrpc_val->me); list($a,$b) = each($xmlrpc_val->me); - $size = count($b); - $arr = array(); - for ($i = 0; $i < $size; $i++) + for ($i = 0, $size = count($b); $i < $size; $i++) { $arr[] = $this->xmlrpc_decoder($xmlrpc_val->me['array'][$i]); } @@ -596,7 +569,7 @@ class XML_RPC_Response // ISO-8601 time to server or UTC time //------------------------------------- - function iso8601_decode($time, $utc=0) + public function iso8601_decode($time, $utc = 0) { // return a timet in the localtime, or UTC $t = 0; @@ -608,9 +581,8 @@ class XML_RPC_Response return $t; } -} // End Response Class - - +} +// End Response Class /** * XML-RPC Message class @@ -621,10 +593,10 @@ class XML_RPC_Response */ class XML_RPC_Message extends CI_Xmlrpc { - var $payload; - var $method_name; - var $params = array(); - var $xh = array(); + public $payload; + public $method_name; + public $params = array(); + public $xh = array(); public function __construct($method, $pars=0) { @@ -633,7 +605,7 @@ class XML_RPC_Message extends CI_Xmlrpc $this->method_name = $method; if (is_array($pars) && count($pars) > 0) { - for ($i=0; $iparams[] = $pars[$i]; @@ -645,13 +617,13 @@ class XML_RPC_Message extends CI_Xmlrpc // Create Payload to Send //------------------------------------- - function createPayload() + public function createPayload() { - $this->payload = "\r\n\r\n"; - $this->payload .= '' . $this->method_name . "\r\n"; - $this->payload .= "\r\n"; + $this->payload = "\r\n\r\n" + . ''.$this->method_name."\r\n" + . "\r\n"; - for ($i=0; $iparams); $i++) + for ($i = 0, $c = count($this->params); $i < $c; $i++) { // $p = XML_RPC_Values $p = $this->params[$i]; @@ -665,7 +637,7 @@ class XML_RPC_Message extends CI_Xmlrpc // Parse External XML-RPC Server's Response //------------------------------------- - function parseResponse($fp) + public function parseResponse($fp) { $data = ''; @@ -680,16 +652,14 @@ class XML_RPC_Message extends CI_Xmlrpc if ($this->debug === TRUE) { - echo "
";
-			echo "---DATA---\n" . htmlspecialchars($data) . "\n---END DATA---\n\n";
-			echo "
"; + echo "
---DATA---\n".htmlspecialchars($data)."\n---END DATA---\n\n
"; } //------------------------------------- // Check for data //------------------------------------- - if ($data == "") + if ($data === '') { error_log($this->xmlrpcstr['no_data']); $r = new XML_RPC_Response(0, $this->xmlrpcerr['no_data'], $this->xmlrpcstr['no_data']); @@ -701,7 +671,7 @@ class XML_RPC_Message extends CI_Xmlrpc // Check for HTTP 200 Response //------------------------------------- - if (strncmp($data, 'HTTP', 4) == 0 && ! preg_match('/^HTTP\/[0-9\.]+ 200 /', $data)) + if (strncmp($data, 'HTTP', 4) === 0 && ! preg_match('/^HTTP\/[0-9\.]+ 200 /', $data)) { $errstr= substr($data, 0, strpos($data, "\n")-1); $r = new XML_RPC_Response(0, $this->xmlrpcerr['http_error'], $this->xmlrpcstr['http_error']. ' (' . $errstr . ')'); @@ -714,13 +684,14 @@ class XML_RPC_Message extends CI_Xmlrpc $parser = xml_parser_create($this->xmlrpc_defencoding); - $this->xh[$parser] = array(); - $this->xh[$parser]['isf'] = 0; - $this->xh[$parser]['ac'] = ''; - $this->xh[$parser]['headers'] = array(); - $this->xh[$parser]['stack'] = array(); - $this->xh[$parser]['valuestack'] = array(); - $this->xh[$parser]['isf_reason'] = 0; + $this->xh[$parser] = array( + 'isf' => 0, + 'ac' => '', + 'headers' => array(), + 'stack' => array(), + 'valuestack' => array(), + 'isf_reason' => 0 + ); xml_set_object($parser, $this); xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true); @@ -769,9 +740,7 @@ class XML_RPC_Message extends CI_Xmlrpc { if ($this->debug === TRUE) { - echo "---Invalid Return---\n"; - echo $this->xh[$parser]['isf_reason']; - echo "---Invalid Return---\n\n"; + echo "---Invalid Return---\n".$this->xh[$parser]['isf_reason']."---Invalid Return---\n\n"; } $r = new XML_RPC_Response(0, $this->xmlrpcerr['invalid_return'],$this->xmlrpcstr['invalid_return'].' '.$this->xh[$parser]['isf_reason']); @@ -801,9 +770,7 @@ class XML_RPC_Message extends CI_Xmlrpc echo "---END HEADERS---\n\n"; } - echo "---DATA---\n" . htmlspecialchars($data) . "\n---END DATA---\n\n"; - - echo "---PARSED---\n" ; + echo "---DATA---\n".htmlspecialchars($data)."\n---END DATA---\n\n---PARSED---\n"; var_dump($this->xh[$parser]['value']); echo "\n---END PARSED---"; } @@ -813,7 +780,6 @@ class XML_RPC_Message extends CI_Xmlrpc //------------------------------------- $v = $this->xh[$parser]['value']; - if ($this->xh[$parser]['isf']) { $errno_v = $v->me['struct']['faultCode']; @@ -855,7 +821,7 @@ class XML_RPC_Message extends CI_Xmlrpc // Start Element Handler //------------------------------------- - function open_tag($the_parser, $name, $attrs) + public function open_tag($the_parser, $name, $attrs) { // If invalid nesting, then return if ($this->xh[$the_parser]['isf'] > 1) return; @@ -957,7 +923,7 @@ class XML_RPC_Message extends CI_Xmlrpc // End Element Handler //------------------------------------- - function closing_tag($the_parser, $name) + public function closing_tag($the_parser, $name) { if ($this->xh[$the_parser]['isf'] > 1) return; @@ -1101,7 +1067,7 @@ class XML_RPC_Message extends CI_Xmlrpc // Parses Character Data //------------------------------------- - function character_data($the_parser, $data) + public function character_data($the_parser, $data) { if ($this->xh[$the_parser]['isf'] > 1) return; // XML Fault found already @@ -1123,13 +1089,16 @@ class XML_RPC_Message extends CI_Xmlrpc } - function addParam($par) { $this->params[]=$par; } + public function addParam($par) + { + $this->params[] = $par; + } - function output_parameters($array=FALSE) + public function output_parameters($array = FALSE) { $CI =& get_instance(); - - if ($array !== FALSE && is_array($array)) + + if (is_array($array)) { while (list($key) = each($array)) { @@ -1151,7 +1120,7 @@ class XML_RPC_Message extends CI_Xmlrpc { $parameters = array(); - for ($i = 0; $i < count($this->params); $i++) + for ($i = 0, $c = count($this->params); $i < $c; $i++) { $a_param = $this->decode_message($this->params[$i]); @@ -1170,7 +1139,7 @@ class XML_RPC_Message extends CI_Xmlrpc } - function decode_message($param) + public function decode_message($param) { $kind = $param->kindOf(); @@ -1185,7 +1154,7 @@ class XML_RPC_Message extends CI_Xmlrpc $arr = array(); - for($i = 0; $i < count($b); $i++) + for($i = 0, $c = count($b); $i < $c; $i++) { $arr[] = $this->decode_message($param->me['array'][$i]); } @@ -1207,9 +1176,8 @@ class XML_RPC_Message extends CI_Xmlrpc } } -} // End XML_RPC_Messages class - - +} +// End XML_RPC_Messages class /** * XML-RPC Values class @@ -1220,10 +1188,10 @@ class XML_RPC_Message extends CI_Xmlrpc */ class XML_RPC_Values extends CI_Xmlrpc { - var $me = array(); - var $mytype = 0; + public $me = array(); + public $mytype = 0; - public function __construct($val=-1, $type='') + public function __construct($val = -1, $type = '') { parent::__construct(); @@ -1246,7 +1214,7 @@ class XML_RPC_Values extends CI_Xmlrpc } } - function addScalar($val, $type='string') + public function addScalar($val, $type = 'string') { $typeof = $this->xmlrpcTypes[$type]; @@ -1264,14 +1232,7 @@ class XML_RPC_Values extends CI_Xmlrpc if ($type == $this->xmlrpcBoolean) { - if (strcasecmp($val,'true')==0 OR $val==1 OR ($val==true && strcasecmp($val,'false'))) - { - $val = 1; - } - else - { - $val=0; - } + $val = (strcasecmp($val,'true') === 0 OR $val == 1 OR ($val == true && strcasecmp($val, 'false'))) ? 1 : 0; } if ($this->mytype == 2) @@ -1290,7 +1251,7 @@ class XML_RPC_Values extends CI_Xmlrpc return 1; } - function addArray($vals) + public function addArray($vals) { if ($this->mytype != 0) { @@ -1303,7 +1264,7 @@ class XML_RPC_Values extends CI_Xmlrpc return 1; } - function addStruct($vals) + public function addStruct($vals) { if ($this->mytype != 0) { @@ -1315,7 +1276,7 @@ class XML_RPC_Values extends CI_Xmlrpc return 1; } - function kindOf() + public function kindOf() { switch($this->mytype) { @@ -1333,7 +1294,7 @@ class XML_RPC_Values extends CI_Xmlrpc } } - function serializedata($typ, $val) + public function serializedata($typ, $val) { $rs = ''; @@ -1345,20 +1306,18 @@ class XML_RPC_Values extends CI_Xmlrpc reset($val); while (list($key2, $val2) = each($val)) { - $rs .= "\n{$key2}\n"; - $rs .= $this->serializeval($val2); - $rs .= "\n"; + $rs .= "\n{$key2}\n".$this->serializeval($val2)."\n"; } $rs .= ''; break; case 2: // array $rs .= "\n\n"; - for($i=0; $i < count($val); $i++) + for($i = 0, $c = count($val); $i < $c; $i++) { $rs .= $this->serializeval($val[$i]); } - $rs.="\n\n"; + $rs .= "\n\n"; break; case 1: // others @@ -1383,22 +1342,21 @@ class XML_RPC_Values extends CI_Xmlrpc return $rs; } - function serialize_class() + public function serialize_class() { return $this->serializeval($this); } - function serializeval($o) + public function serializeval($o) { $ar = $o->me; reset($ar); list($typ, $val) = each($ar); - $rs = "\n".$this->serializedata($typ, $val)."\n"; - return $rs; + return "\n".$this->serializedata($typ, $val)."\n"; } - function scalarval() + public function scalarval() { reset($this->me); list($a,$b) = each($this->me); @@ -1412,24 +1370,18 @@ class XML_RPC_Values extends CI_Xmlrpc // Useful for sending time in XML-RPC - function iso8601_encode($time, $utc=0) + public function iso8601_encode($time, $utc=0) { if ($utc == 1) { - $t = strftime("%Y%m%dT%H:%i:%s", $time); + return strftime("%Y%m%dT%H:%i:%s", $time); } - else - { - if (function_exists('gmstrftime')) - $t = gmstrftime("%Y%m%dT%H:%i:%s", $time); - else - $t = strftime("%Y%m%dT%H:%i:%s", $time - date('Z')); - } - return $t; + + return (function_exists('gmstrftime')) ? gmstrftime('%Y%m%dT%H:%i:%s', $time) : strftime('%Y%m%dT%H:%i:%s', $time - date('Z')); } } // END XML_RPC_Values Class /* End of file Xmlrpc.php */ -/* Location: ./system/libraries/Xmlrpc.php */ \ No newline at end of file +/* Location: ./system/libraries/Xmlrpc.php */ -- cgit v1.2.3-24-g4f1b From 6209015edde25e8ca82a8e8f5eb5a5eda2750e7b Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 30 Dec 2011 12:49:27 +0200 Subject: Some more optimizations --- system/libraries/Xmlrpc.php | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'system/libraries/Xmlrpc.php') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index ebb04601b..2804e6685 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -542,7 +542,7 @@ class XML_RPC_Response elseif ($kind == 'array') { reset($xmlrpc_val->me); - list($a,$b) = each($xmlrpc_val->me); + list(, $b) = each($xmlrpc_val->me); $arr = array(); for ($i = 0, $size = count($b); $i < $size; $i++) @@ -1150,7 +1150,7 @@ class XML_RPC_Message extends CI_Xmlrpc elseif ($kind == 'array') { reset($param->me); - list($a,$b) = each($param->me); + list(, $b) = each($param->me); $arr = array(); @@ -1359,7 +1359,7 @@ class XML_RPC_Values extends CI_Xmlrpc public function scalarval() { reset($this->me); - list($a,$b) = each($this->me); + list(, $b) = each($this->me); return $b; } @@ -1370,14 +1370,9 @@ class XML_RPC_Values extends CI_Xmlrpc // Useful for sending time in XML-RPC - public function iso8601_encode($time, $utc=0) + public function iso8601_encode($time, $utc = 0) { - if ($utc == 1) - { - return strftime("%Y%m%dT%H:%i:%s", $time); - } - - return (function_exists('gmstrftime')) ? gmstrftime('%Y%m%dT%H:%i:%s', $time) : strftime('%Y%m%dT%H:%i:%s', $time - date('Z')); + return ($utc) ? strftime('%Y%m%dT%H:%i:%s', $time) : gmstrftime('%Y%m%dT%H:%i:%s', $time); } } -- cgit v1.2.3-24-g4f1b From adc1175f7af1a5fa3a833f72b6f24a82b59e69c1 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 30 Dec 2011 14:46:08 +0200 Subject: Replace some list(...) = each(...) expressions with current(), where only values are needed --- system/libraries/Xmlrpc.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'system/libraries/Xmlrpc.php') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index 2804e6685..bb95ca145 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -542,7 +542,7 @@ class XML_RPC_Response elseif ($kind == 'array') { reset($xmlrpc_val->me); - list(, $b) = each($xmlrpc_val->me); + $b = current($xmlrpc_val->me); $arr = array(); for ($i = 0, $size = count($b); $i < $size; $i++) @@ -1150,8 +1150,7 @@ class XML_RPC_Message extends CI_Xmlrpc elseif ($kind == 'array') { reset($param->me); - list(, $b) = each($param->me); - + $b = current($param->me); $arr = array(); for($i = 0, $c = count($b); $i < $c; $i++) @@ -1164,7 +1163,6 @@ class XML_RPC_Message extends CI_Xmlrpc elseif ($kind == 'struct') { reset($param->me['struct']); - $arr = array(); while (list($key,$value) = each($param->me['struct'])) @@ -1359,8 +1357,7 @@ class XML_RPC_Values extends CI_Xmlrpc public function scalarval() { reset($this->me); - list(, $b) = each($this->me); - return $b; + return current($this->me); } -- cgit v1.2.3-24-g4f1b From 0defe5d33ee2633f377a109519ca818becc60f64 Mon Sep 17 00:00:00 2001 From: Greg Aker Date: Sun, 1 Jan 2012 18:46:41 -0600 Subject: Updating copyright date to 2012 --- system/libraries/Xmlrpc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries/Xmlrpc.php') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index 7b1e3fa6e..1bdc27512 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -18,7 +18,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/) + * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/) * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com * @since Version 1.0 -- cgit v1.2.3-24-g4f1b From b195637240bbbc7c3dc7ee0585f0e4cd39cb9d81 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 3 Jan 2012 11:01:48 +0200 Subject: Replace htmlentities() with htmlspecialchars() to fix issue #561 --- system/libraries/Xmlrpc.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'system/libraries/Xmlrpc.php') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index bb95ca145..a9f8d9c38 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -437,7 +437,14 @@ class XML_RPC_Response { // error $this->errno = $code; - $this->errstr = htmlentities($fstr); + if ( ! is_php('5.4')) + { + $this->errstr = htmlspecialchars($fstr, ENT_NOQUOTES, 'UTF-8'); + } + else + { + $this->errstr = htmlspecialchars($fstr, ENT_XML1 | ENT_NOQUOTES, 'UTF-8'); + } } else if ( ! is_object($val)) { -- cgit v1.2.3-24-g4f1b From 07c1ac830b4e98aa40f48baef3dd05fb68c0a836 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Fri, 9 Mar 2012 17:03:37 +0000 Subject: Bumped CodeIgniter's PHP requirement to 5.2.4. Yes I know PHP 5.4 just came out, and yes I know PHP 5.3 has lovely features, but there are plenty of corporate systems running on CodeIgniter and PHP 5.3 still is not widely supported enough. CodeIgniter is great for distributed applications, and this is the highest we can reasonably go without breaking support. PHP 5.3 will most likely happen in another year or so. Fingers crossed on that one anyway... --- system/libraries/Xmlrpc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries/Xmlrpc.php') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index 730a0fc49..32e2e523b 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * -- cgit v1.2.3-24-g4f1b From 8f50b6b36cb743be8b70809279e501c20b8e38e2 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 28 Mar 2012 14:12:09 +0300 Subject: Some minor style changes in the XMLRPC class --- system/libraries/Xmlrpc.php | 57 +++++++++++++++++++-------------------------- 1 file changed, 24 insertions(+), 33 deletions(-) (limited to 'system/libraries/Xmlrpc.php') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index 32e2e523b..b6e6c810d 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -136,10 +136,9 @@ class CI_Xmlrpc { $this->initialize($config); - log_message('debug', "XML-RPC Class Initialized"); + log_message('debug', 'XML-RPC Class Initialized'); } - //------------------------------------- // Initialize Prefs //------------------------------------- @@ -163,7 +162,7 @@ class CI_Xmlrpc { // Take URL and parse it //------------------------------------- - public function server($url, $port=80) + public function server($url, $port = 80) { if (strpos($url, 'http') !== 0) { @@ -172,9 +171,9 @@ class CI_Xmlrpc { $parts = parse_url($url); - $path = ( ! isset($parts['path'])) ? '/' : $parts['path']; + $path = isset($parts['path']) ? $parts['path'] : '/'; - if (isset($parts['query']) && $parts['query'] != '') + if ( ! empty($parts['query'])) { $path .= '?'.$parts['query']; } @@ -244,7 +243,7 @@ class CI_Xmlrpc { { if (is_array($value) && array_key_exists(0, $value)) { - if ( ! isset($value[1]) OR ( ! isset($this->xmlrpcTypes[$value[1]]))) + if ( ! isset($value[1], $this->xmlrpcTypes[$value[1]])) { $temp = new XML_RPC_Values($value[0], (is_array($value[0]) ? 'array' : 'string')); } @@ -337,7 +336,6 @@ class CI_Xmlrpc { } // END XML_RPC Class - /** * XML-RPC Client class * @@ -355,7 +353,7 @@ class XML_RPC_Client extends CI_Xmlrpc public $timeout = 5; public $no_multicall = FALSE; - public function __construct($path, $server, $port=80) + public function __construct($path, $server, $port = 80) { parent::__construct(); @@ -383,7 +381,7 @@ class XML_RPC_Client extends CI_Xmlrpc if ( ! is_resource($fp)) { error_log($this->xmlrpcstr['http_error']); - $r = new XML_RPC_Response(0, $this->xmlrpcerr['http_error'],$this->xmlrpcstr['http_error']); + $r = new XML_RPC_Response(0, $this->xmlrpcerr['http_error'], $this->xmlrpcstr['http_error']); return $r; } @@ -394,12 +392,12 @@ class XML_RPC_Client extends CI_Xmlrpc } $r = "\r\n"; - $op = "POST {$this->path} HTTP/1.0$r" - . "Host: {$this->server}$r" - . "Content-Type: text/xml$r" - . "User-Agent: {$this->xmlrpcName}$r" - . "Content-Length: ".strlen($msg->payload)."$r$r" - . $msg->payload; + $op = 'POST '.$this->path.' HTTP/1.0'.$r + .'Host: '.$this->server.$r + .'Content-Type: text/xml'.$r + .'User-Agent: '.$this->xmlrpcName.$r + .'Content-Length: '.strlen($msg->payload).$r.$r + .$msg->payload; if ( ! fputs($fp, $op, strlen($op))) @@ -446,10 +444,10 @@ class XML_RPC_Response $this->errstr = htmlspecialchars($fstr, ENT_XML1 | ENT_NOQUOTES, 'UTF-8'); } } - else if ( ! is_object($val)) + elseif ( ! is_object($val)) { // programmer error, not an object - error_log("Invalid type '" . gettype($val) . "' (value: $val) passed to XML_RPC_Response. Defaulting to empty value."); + error_log("Invalid type '".gettype($val)."' (value: ".$val.') passed to XML_RPC_Response. Defaulting to empty value.'); $this->val = new XML_RPC_Values(); } else @@ -532,8 +530,6 @@ class XML_RPC_Response return $result; } - - //------------------------------------- // XML-RPC Object to PHP Types //------------------------------------- @@ -571,7 +567,6 @@ class XML_RPC_Response } } - //------------------------------------- // ISO-8601 time to server or UTC time //------------------------------------- @@ -605,7 +600,7 @@ class XML_RPC_Message extends CI_Xmlrpc public $params = array(); public $xh = array(); - public function __construct($method, $pars=0) + public function __construct($method, $pars = 0) { parent::__construct(); @@ -681,7 +676,7 @@ class XML_RPC_Message extends CI_Xmlrpc if (strncmp($data, 'HTTP', 4) === 0 && ! preg_match('/^HTTP\/[0-9\.]+ 200 /', $data)) { $errstr= substr($data, 0, strpos($data, "\n")-1); - $r = new XML_RPC_Response(0, $this->xmlrpcerr['http_error'], $this->xmlrpcstr['http_error']. ' (' . $errstr . ')'); + $r = new XML_RPC_Response(0, $this->xmlrpcerr['http_error'], $this->xmlrpcstr['http_error'].' (' . $errstr . ')'); return $r; } @@ -706,7 +701,6 @@ class XML_RPC_Message extends CI_Xmlrpc xml_set_character_data_handler($parser, 'character_data'); //xml_set_default_handler($parser, 'default_handler'); - //------------------------------------- // GET HEADERS //------------------------------------- @@ -765,14 +759,14 @@ class XML_RPC_Message extends CI_Xmlrpc if ($this->debug === TRUE) { - echo "
";
+			echo '
';
 
 			if (count($this->xh[$parser]['headers'] > 0))
 			{
 				echo "---HEADERS---\n";
 				foreach ($this->xh[$parser]['headers'] as $header)
 				{
-					echo "$header\n";
+					echo $header."\n";
 				}
 				echo "---END HEADERS---\n\n";
 			}
@@ -850,7 +844,7 @@ class XML_RPC_Message extends CI_Xmlrpc
 			if ( ! in_array($this->xh[$the_parser]['stack'][0], $this->valid_parents[$name], TRUE))
 			{
 				$this->xh[$the_parser]['isf'] = 2;
-				$this->xh[$the_parser]['isf_reason'] = "XML-RPC element $name cannot be child of ".$this->xh[$the_parser]['stack'][0];
+				$this->xh[$the_parser]['isf_reason'] = 'XML-RPC element $name cannot be child of '.$this->xh[$the_parser]['stack'][0];
 				return;
 			}
 		}
@@ -861,8 +855,7 @@ class XML_RPC_Message extends CI_Xmlrpc
 			case 'ARRAY':
 				// Creates array for child elements
 
-				$cur_val = array('value' => array(),
-								 'type'	 => $name);
+				$cur_val = array('value' => array(), 'type' => $name);
 
 				array_unshift($this->xh[$the_parser]['valuestack'], $cur_val);
 			break;
@@ -925,7 +918,6 @@ class XML_RPC_Message extends CI_Xmlrpc
 	}
 	// END
 
-
 	//-------------------------------------
 	//  End Element Handler
 	//-------------------------------------
@@ -996,7 +988,7 @@ class XML_RPC_Message extends CI_Xmlrpc
 					}
 					else
 					{
-						$this->xh[$the_parser]['value'] = (double)$this->xh[$the_parser]['ac'];
+						$this->xh[$the_parser]['value'] = (float) $this->xh[$the_parser]['ac'];
 					}
 				}
 				else
@@ -1145,7 +1137,6 @@ class XML_RPC_Message extends CI_Xmlrpc
 		return $parameters;
 	}
 
-
 	public function decode_message($param)
 	{
 		$kind = $param->kindOf();
@@ -1237,7 +1228,7 @@ class XML_RPC_Values extends CI_Xmlrpc
 
 		if ($type == $this->xmlrpcBoolean)
 		{
-			$val = (strcasecmp($val,'true') === 0 OR $val == 1 OR ($val == true && strcasecmp($val, 'false'))) ? 1 : 0;
+			$val = (strcasecmp($val,'true') === 0 OR $val == 1 OR ($val == TRUE && strcasecmp($val, 'false'))) ? 1 : 0;
 		}
 
 		if ($this->mytype == 2)
@@ -1383,4 +1374,4 @@ class XML_RPC_Values extends CI_Xmlrpc
 // END XML_RPC_Values Class
 
 /* End of file Xmlrpc.php */
-/* Location: ./system/libraries/Xmlrpc.php */
+/* Location: ./system/libraries/Xmlrpc.php */
\ No newline at end of file
-- 
cgit v1.2.3-24-g4f1b


From c8709839a57feb991a1fef527afecd1b07f12f0f Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Wed, 4 Apr 2012 13:43:53 +0300
Subject: Replace old comments with proper docblocks in Xmlrpc.php

---
 system/libraries/Xmlrpc.php | 794 ++++++++++++++++++++++++++------------------
 1 file changed, 480 insertions(+), 314 deletions(-)

(limited to 'system/libraries/Xmlrpc.php')

diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php
index b6e6c810d..fea560c2e 100644
--- a/system/libraries/Xmlrpc.php
+++ b/system/libraries/Xmlrpc.php
@@ -25,14 +25,6 @@
  * @filesource
  */
 
-if ( ! function_exists('xml_parser_create'))
-{
-	show_error('Your PHP installation does not support XML');
-}
-
-
-// ------------------------------------------------------------------------
-
 /**
  * XML-RPC request handler class
  *
@@ -42,6 +34,14 @@ if ( ! function_exists('xml_parser_create'))
  * @author		EllisLab Dev Team
  * @link		http://codeigniter.com/user_guide/libraries/xmlrpc.html
  */
+
+if ( ! function_exists('xml_parser_create'))
+{
+	show_error('Your PHP installation does not support XML');
+}
+
+// ------------------------------------------------------------------------
+
 class CI_Xmlrpc {
 
 	public $debug		= FALSE;	// Debugging on or off
@@ -77,13 +77,17 @@ class CI_Xmlrpc {
 
 	public $xss_clean		= TRUE;
 
-	//-------------------------------------
-	//  VALUES THAT MULTIPLE CLASSES NEED
-	//-------------------------------------
 
+	/**
+	 * Constructor
+	 *
+	 * Initializes property default values
+	 *
+	 * @param	array
+	 * @return	void
+	 */
 	public function __construct($config = array())
 	{
-		$this->xmlrpcName	= $this->xmlrpcName;
 		$this->xmlrpc_backslash = chr(92).chr(92);
 
 		// Types for info sent back and forth
@@ -139,10 +143,14 @@ class CI_Xmlrpc {
 		log_message('debug', 'XML-RPC Class Initialized');
 	}
 
-	//-------------------------------------
-	//  Initialize Prefs
-	//-------------------------------------
+	// --------------------------------------------------------------------
 
+	/**
+	 * Initialize
+	 *
+	 * @param	array
+	 * @return	void
+	 */
 	public function initialize($config = array())
 	{
 		if (count($config) > 0)
@@ -156,17 +164,21 @@ class CI_Xmlrpc {
 			}
 		}
 	}
-	// END
 
-	//-------------------------------------
-	//  Take URL and parse it
-	//-------------------------------------
+	// --------------------------------------------------------------------
 
+	/**
+	 * Parse server URL
+	 *
+	 * @param	string	url
+	 * @param	int	port
+	 * @return	void
+	 */
 	public function server($url, $port = 80)
 	{
 		if (strpos($url, 'http') !== 0)
 		{
-			$url = "http://".$url;
+			$url = 'http://'.$url;
 		}
 
 		$parts = parse_url($url);
@@ -180,12 +192,15 @@ class CI_Xmlrpc {
 
 		$this->client = new XML_RPC_Client($path, $parts['host'], $port);
 	}
-	// END
 
-	//-------------------------------------
-	//  Set Timeout
-	//-------------------------------------
+	// --------------------------------------------------------------------
 
+	/**
+	 * Set Timeout
+	 *
+	 * @param	int	seconds
+	 * @return	void
+	 */
 	public function timeout($seconds = 5)
 	{
 		if ( ! is_null($this->client) && is_int($seconds))
@@ -193,27 +208,34 @@ class CI_Xmlrpc {
 			$this->client->timeout = $seconds;
 		}
 	}
-	// END
 
-	//-------------------------------------
-	//  Set Methods
-	//-------------------------------------
+	// --------------------------------------------------------------------
 
+	/**
+	 * Set Methods
+	 *
+	 * @param	string	method name
+	 * @return	void
+	 */
 	public function method($function)
 	{
 		$this->method = $function;
 	}
-	// END
 
-	//-------------------------------------
-	//  Take Array of Data and Create Objects
-	//-------------------------------------
+	// --------------------------------------------------------------------
 
+	/**
+	 * Take Array of Data and Create Objects
+	 *
+	 * @param	array
+	 * @return	void
+	 */
 	public function request($incoming)
 	{
 		if ( ! is_array($incoming))
 		{
 			// Send Error
+			return;
 		}
 
 		$this->data = array();
@@ -223,23 +245,29 @@ class CI_Xmlrpc {
 			$this->data[$key] = $this->values_parsing($value);
 		}
 	}
-	// END
-
 
-	//-------------------------------------
-	//  Set Debug
-	//-------------------------------------
+	// --------------------------------------------------------------------
 
+	/**
+	 * Set Debug
+	 *
+	 * @param	bool
+	 * @return	void
+	 */
 	public function set_debug($flag = TRUE)
 	{
 		$this->debug = ($flag == TRUE);
 	}
 
-	//-------------------------------------
-	//  Values Parsing
-	//-------------------------------------
+	// --------------------------------------------------------------------
 
-	public function values_parsing($value, $return = FALSE)
+	/**
+	 * Values Parsing
+	 *
+	 * @param	mixed
+	 * @return	object
+	 */
+	public function values_parsing($value)
 	{
 		if (is_array($value) && array_key_exists(0, $value))
 		{
@@ -267,16 +295,17 @@ class CI_Xmlrpc {
 
 		return $temp;
 	}
-	// END
-
 
-	//-------------------------------------
-	//  Sends XML-RPC Request
-	//-------------------------------------
+	// --------------------------------------------------------------------
 
+	/**
+	 * Sends XML-RPC Request
+	 *
+	 * @return	bool
+	 */
 	public function send_request()
 	{
-		$this->message = new XML_RPC_Message($this->method,$this->data);
+		$this->message = new XML_RPC_Message($this->method, $this->data);
 		$this->message->debug = $this->debug;
 
 		if ( ! $this->result = $this->client->send($this->message) OR ! is_object($this->result->val))
@@ -288,54 +317,62 @@ class CI_Xmlrpc {
 		$this->response = $this->result->decode();
 		return TRUE;
 	}
-	// END
 
-	//-------------------------------------
-	//  Returns Error
-	//-------------------------------------
+	// --------------------------------------------------------------------
 
+	/**
+	 * Returns Error
+	 *
+	 * @return	string
+	 */
 	public function display_error()
 	{
 		return $this->error;
 	}
-	// END
 
-	//-------------------------------------
-	//  Returns Remote Server Response
-	//-------------------------------------
+	// --------------------------------------------------------------------
 
+	/**
+	 * Returns Remote Server Response
+	 *
+	 * @return	string
+	 */
 	public function display_response()
 	{
 		return $this->response;
 	}
-	// END
 
-	//-------------------------------------
-	//  Sends an Error Message for Server Request
-	//-------------------------------------
+	// --------------------------------------------------------------------
 
+	/**
+	 * Sends an Error Message for Server Request
+	 *
+	 * @param	int
+	 * @param	string
+	 * @return	object
+	 */
 	public function send_error_message($number, $message)
 	{
 		return new XML_RPC_Response(0, $number, $message);
 	}
-	// END
 
+	// --------------------------------------------------------------------
 
-	//-------------------------------------
-	//  Send Response for Server Request
-	//-------------------------------------
-
+	/**
+	 * Send Response for Server Request
+	 *
+	 * @param	array
+	 * @return	object
+	 */
 	public function send_response($response)
 	{
 		// $response should be array of values, which will be parsed
 		// based on their data and type into a valid group of XML-RPC values
 		return new XML_RPC_Response($this->values_parsing($response));
 	}
-	// END
 
 } // END XML_RPC Class
 
-
 /**
  * XML-RPC Client class
  *
@@ -353,6 +390,14 @@ class XML_RPC_Client extends CI_Xmlrpc
 	public $timeout		= 5;
 	public $no_multicall	= FALSE;
 
+	/**
+	 * Constructor
+	 *
+	 * @param	string
+	 * @param	object
+	 * @param	int
+	 * @return	void
+	 */
 	public function __construct($path, $server, $port = 80)
 	{
 		parent::__construct();
@@ -362,18 +407,33 @@ class XML_RPC_Client extends CI_Xmlrpc
 		$this->path = $path;
 	}
 
+	// --------------------------------------------------------------------
+
+	/**
+	 * Send message
+	 *
+	 * @param	mixed
+	 * @return	object
+	 */
 	public function send($msg)
 	{
 		if (is_array($msg))
 		{
 			// Multi-call disabled
-			$r = new XML_RPC_Response(0, $this->xmlrpcerr['multicall_recursion'],$this->xmlrpcstr['multicall_recursion']);
-			return $r;
+			return new XML_RPC_Response(0, $this->xmlrpcerr['multicall_recursion'], $this->xmlrpcstr['multicall_recursion']);
 		}
 
 		return $this->sendPayload($msg);
 	}
 
+	// --------------------------------------------------------------------
+
+	/**
+	 * Send payload
+	 *
+	 * @param	object
+	 * @return	object
+	 */
 	public function sendPayload($msg)
 	{
 		$fp = @fsockopen($this->server, $this->port,$this->errno, $this->errstr, $this->timeout);
@@ -381,8 +441,7 @@ class XML_RPC_Client extends CI_Xmlrpc
 		if ( ! is_resource($fp))
 		{
 			error_log($this->xmlrpcstr['http_error']);
-			$r = new XML_RPC_Response(0, $this->xmlrpcerr['http_error'], $this->xmlrpcstr['http_error']);
-			return $r;
+			return new XML_RPC_Response(0, $this->xmlrpcerr['http_error'], $this->xmlrpcstr['http_error']);
 		}
 
 		if (empty($msg->payload))
@@ -399,20 +458,18 @@ class XML_RPC_Client extends CI_Xmlrpc
 			.'Content-Length: '.strlen($msg->payload).$r.$r
 			.$msg->payload;
 
-
 		if ( ! fputs($fp, $op, strlen($op)))
 		{
 			error_log($this->xmlrpcstr['http_error']);
-			$r = new XML_RPC_Response(0, $this->xmlrpcerr['http_error'], $this->xmlrpcstr['http_error']);
-			return $r;
+			return new XML_RPC_Response(0, $this->xmlrpcerr['http_error'], $this->xmlrpcstr['http_error']);
 		}
+
 		$resp = $msg->parseResponse($fp);
 		fclose($fp);
 		return $resp;
 	}
 
-}
-// end class XML_RPC_Client
+} // END XML_RPC_Client Class
 
 /**
  * XML-RPC Response class
@@ -423,26 +480,29 @@ class XML_RPC_Client extends CI_Xmlrpc
  */
 class XML_RPC_Response
 {
-	public $val = 0;
-	public $errno = 0;
-	public $errstr = '';
-	public $headers = array();
-	public $xss_clean = TRUE;
-
+	public $val		= 0;
+	public $errno		= 0;
+	public $errstr		= '';
+	public $headers		= array();
+	public $xss_clean	= TRUE;
+
+	/**
+	 * Constructor
+	 *
+	 * @param	mixed
+	 * @param	int
+	 * @param	string
+	 * @return	void
+	 */
 	public function __construct($val, $code = 0, $fstr = '')
 	{
 		if ($code != 0)
 		{
 			// error
 			$this->errno = $code;
-			if ( ! is_php('5.4'))
-			{
-				$this->errstr = htmlspecialchars($fstr, ENT_NOQUOTES, 'UTF-8');
-			}
-			else
-			{
-				$this->errstr = htmlspecialchars($fstr, ENT_XML1 | ENT_NOQUOTES, 'UTF-8');
-			}
+			$this->errstr = htmlspecialchars($fstr,
+							(is_php('5.4') ? ENT_XML1 | ENT_NOQUOTES : ENT_NOQUOTES),
+							'UTF-8');
 		}
 		elseif ( ! is_object($val))
 		{
@@ -456,43 +516,79 @@ class XML_RPC_Response
 		}
 	}
 
+	// --------------------------------------------------------------------
+
+	/**
+	 * Fault code
+	 *
+	 * @return	int
+	 */
 	public function faultCode()
 	{
 		return $this->errno;
 	}
 
+	// --------------------------------------------------------------------
+
+	/**
+	 * Fault string
+	 *
+	 * @return	string
+	 */
 	public function faultString()
 	{
 		return $this->errstr;
 	}
 
+	// --------------------------------------------------------------------
+
+	/**
+	 * Value
+	 *
+	 * @return	mixed
+	 */
 	public function value()
 	{
 		return $this->val;
 	}
 
+	// --------------------------------------------------------------------
+
+	/**
+	 * Prepare response
+	 *
+	 * @return	string	xml
+	 */
 	public function prepare_response()
 	{
 		return "\n"
-			. ($this->errno
-			? '
+			.($this->errno
+				? '
 	
 		
 			
 				faultCode
-				' . $this->errno . '
+				'.$this->errno.'
 			
 			
 				faultString
-				' . $this->errstr . '
+				'.$this->errstr.'
 			
 		
 	
 '
-			: "\n\n".$this->val->serialize_class()."\n")
-			. "\n";
+				: "\n\n".$this->val->serialize_class()."\n")
+			."\n";
 	}
 
+	// --------------------------------------------------------------------
+
+	/**
+	 * Decode
+	 *
+	 * @param	mixed
+	 * @return	array
+	 */
 	public function decode($array = FALSE)
 	{
 		$CI =& get_instance();
@@ -511,29 +607,31 @@ class XML_RPC_Response
 				}
 			}
 
-			$result = $array;
+			return $array;
+		}
+
+		$result = $this->xmlrpc_decoder($this->val);
+
+		if (is_array($result))
+		{
+			$result = $this->decode($result);
 		}
 		else
 		{
-			$result = $this->xmlrpc_decoder($this->val);
-
-			if (is_array($result))
-			{
-				$result = $this->decode($result);
-			}
-			else
-			{
-				$result = ($this->xss_clean) ? $CI->security->xss_clean($result) : $result;
-			}
+			$result = ($this->xss_clean) ? $CI->security->xss_clean($result) : $result;
 		}
 
 		return $result;
 	}
 
-	//-------------------------------------
-	//  XML-RPC Object to PHP Types
-	//-------------------------------------
+	// --------------------------------------------------------------------
 
+	/**
+	 * XML-RPC Object to PHP Types
+	 *
+	 * @param	object
+	 * @return	array
+	 */
 	public function xmlrpc_decoder($xmlrpc_val)
 	{
 		$kind = $xmlrpc_val->kindOf();
@@ -567,24 +665,28 @@ class XML_RPC_Response
 		}
 	}
 
-	//-------------------------------------
-	//  ISO-8601 time to server or UTC time
-	//-------------------------------------
+	// --------------------------------------------------------------------
 
-	public function iso8601_decode($time, $utc = 0)
+	/**
+	 * ISO-8601 time to server or UTC time
+	 *
+	 * @param	string
+	 * @param	bool
+	 * @return	int	unix timestamp
+	 */
+	public function iso8601_decode($time, $utc = FALSE)
 	{
-		// return a timet in the localtime, or UTC
+		// return a time in the localtime, or UTC
 		$t = 0;
 		if (preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})/', $time, $regs))
 		{
-			$fnc = ($utc == 1) ? 'gmmktime' : 'mktime';
+			$fnc = ($utc == TRUE) ? 'gmmktime' : 'mktime';
 			$t = $fnc($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
 		}
 		return $t;
 	}
 
-}
-// End Response Class
+} // END XML_RPC_Response Class
 
 /**
  * XML-RPC Message class
@@ -597,10 +699,17 @@ class XML_RPC_Message extends CI_Xmlrpc
 {
 	public $payload;
 	public $method_name;
-	public $params			= array();
-	public $xh				= array();
-
-	public function __construct($method, $pars = 0)
+	public $params		= array();
+	public $xh		= array();
+
+	/**
+	 * Constructor
+	 *
+	 * @param	string	method name
+	 * @param	array
+	 * @return	void
+	 */
+	public function __construct($method, $pars = FALSE)
 	{
 		parent::__construct();
 
@@ -615,15 +724,18 @@ class XML_RPC_Message extends CI_Xmlrpc
 		}
 	}
 
-	//-------------------------------------
-	//  Create Payload to Send
-	//-------------------------------------
+	// --------------------------------------------------------------------
 
+	/**
+	 * Create Payload to Send
+	 *
+	 * @return	void
+	 */
 	public function createPayload()
 	{
-		$this->payload = "\r\n\r\n"
-				. ''.$this->method_name."\r\n"
-				. "\r\n";
+		$this->payload = '\r\n\r\n"
+				.''.$this->method_name."\r\n"
+				."\r\n";
 
 		for ($i = 0, $c = count($this->params); $i < $c; $i++)
 		{
@@ -635,10 +747,14 @@ class XML_RPC_Message extends CI_Xmlrpc
 		$this->payload .= "\r\n\r\n";
 	}
 
-	//-------------------------------------
-	//  Parse External XML-RPC Server's Response
-	//-------------------------------------
+	// --------------------------------------------------------------------
 
+	/**
+	 * Parse External XML-RPC Server's Response
+	 *
+	 * @param	resource
+	 * @return	object
+	 */
 	public function parseResponse($fp)
 	{
 		$data = '';
@@ -648,36 +764,24 @@ class XML_RPC_Message extends CI_Xmlrpc
 			$data .= $datum;
 		}
 
-		//-------------------------------------
-		//  DISPLAY HTTP CONTENT for DEBUGGING
-		//-------------------------------------
-
+		// Display HTTP content for debugging
 		if ($this->debug === TRUE)
 		{
 			echo "
---DATA---\n".htmlspecialchars($data)."\n---END DATA---\n\n
"; } - //------------------------------------- - // Check for data - //------------------------------------- - + // Check for data if ($data === '') { error_log($this->xmlrpcstr['no_data']); - $r = new XML_RPC_Response(0, $this->xmlrpcerr['no_data'], $this->xmlrpcstr['no_data']); - return $r; + return new XML_RPC_Response(0, $this->xmlrpcerr['no_data'], $this->xmlrpcstr['no_data']); } - - //------------------------------------- - // Check for HTTP 200 Response - //------------------------------------- - + // Check for HTTP 200 Response if (strncmp($data, 'HTTP', 4) === 0 && ! preg_match('/^HTTP\/[0-9\.]+ 200 /', $data)) { - $errstr= substr($data, 0, strpos($data, "\n")-1); - $r = new XML_RPC_Response(0, $this->xmlrpcerr['http_error'], $this->xmlrpcstr['http_error'].' (' . $errstr . ')'); - return $r; + $errstr = substr($data, 0, strpos($data, "\n")-1); + return new XML_RPC_Response(0, $this->xmlrpcerr['http_error'], $this->xmlrpcstr['http_error'].' ('.$errstr.')'); } //------------------------------------- @@ -687,24 +791,21 @@ class XML_RPC_Message extends CI_Xmlrpc $parser = xml_parser_create($this->xmlrpc_defencoding); $this->xh[$parser] = array( - 'isf' => 0, - 'ac' => '', - 'headers' => array(), - 'stack' => array(), - 'valuestack' => array(), - 'isf_reason' => 0 + 'isf' => 0, + 'ac' => '', + 'headers' => array(), + 'stack' => array(), + 'valuestack' => array(), + 'isf_reason' => 0 ); xml_set_object($parser, $this); - xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true); + xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, TRUE); xml_set_element_handler($parser, 'open_tag', 'closing_tag'); xml_set_character_data_handler($parser, 'character_data'); //xml_set_default_handler($parser, 'default_handler'); - //------------------------------------- - // GET HEADERS - //------------------------------------- - + // Get headers $lines = explode("\r\n", $data); while (($line = array_shift($lines))) { @@ -716,16 +817,12 @@ class XML_RPC_Message extends CI_Xmlrpc } $data = implode("\r\n", $lines); - - //------------------------------------- - // PARSE XML DATA - //------------------------------------- - + // Parse XML data if ( ! xml_parse($parser, $data, count($data))) { $errstr = sprintf('XML error: %s at line %d', - xml_error_string(xml_get_error_code($parser)), - xml_get_current_line_number($parser)); + xml_error_string(xml_get_error_code($parser)), + xml_get_current_line_number($parser)); //error_log($errstr); $r = new XML_RPC_Response(0, $this->xmlrpcerr['invalid_return'], $this->xmlrpcstr['invalid_return']); xml_parser_free($parser); @@ -733,10 +830,7 @@ class XML_RPC_Message extends CI_Xmlrpc } xml_parser_free($parser); - // --------------------------------------- - // Got Ourselves Some Badness, It Seems - // --------------------------------------- - + // Got ourselves some badness, it seems if ($this->xh[$parser]['isf'] > 1) { if ($this->debug === TRUE) @@ -744,19 +838,14 @@ class XML_RPC_Message extends CI_Xmlrpc echo "---Invalid Return---\n".$this->xh[$parser]['isf_reason']."---Invalid Return---\n\n"; } - $r = new XML_RPC_Response(0, $this->xmlrpcerr['invalid_return'],$this->xmlrpcstr['invalid_return'].' '.$this->xh[$parser]['isf_reason']); - return $r; + return new XML_RPC_Response(0, $this->xmlrpcerr['invalid_return'], $this->xmlrpcstr['invalid_return'].' '.$this->xh[$parser]['isf_reason']); } elseif ( ! is_object($this->xh[$parser]['value'])) { - $r = new XML_RPC_Response(0, $this->xmlrpcerr['invalid_return'],$this->xmlrpcstr['invalid_return'].' '.$this->xh[$parser]['isf_reason']); - return $r; + return new XML_RPC_Response(0, $this->xmlrpcerr['invalid_return'], $this->xmlrpcstr['invalid_return'].' '.$this->xh[$parser]['isf_reason']); } - //------------------------------------- - // DISPLAY XML CONTENT for DEBUGGING - //------------------------------------- - + // Display XML content for debugging if ($this->debug === TRUE) { echo '
';
@@ -776,10 +865,7 @@ class XML_RPC_Message extends CI_Xmlrpc
 			echo "\n---END PARSED---
"; } - //------------------------------------- - // SEND RESPONSE - //------------------------------------- - + // Send response $v = $this->xh[$parser]['value']; if ($this->xh[$parser]['isf']) { @@ -804,6 +890,8 @@ class XML_RPC_Message extends CI_Xmlrpc return $r; } + // -------------------------------------------------------------------- + // ------------------------------------ // Begin Return Message Parsing section // ------------------------------------ @@ -818,17 +906,21 @@ class XML_RPC_Message extends CI_Xmlrpc // stack - array with parent tree of the xml element, // used to validate the nesting of elements - //------------------------------------- - // Start Element Handler - //------------------------------------- + // -------------------------------------------------------------------- - public function open_tag($the_parser, $name, $attrs) + /** + * Start Element Handler + * + * @param string + * @param string + * @return void + */ + public function open_tag($the_parser, $name) { // If invalid nesting, then return if ($this->xh[$the_parser]['isf'] > 1) return; // Evaluate and check for correct nesting of XML elements - if (count($this->xh[$the_parser]['stack']) == 0) { if ($name != 'METHODRESPONSE' && $name != 'METHODCALL') @@ -838,42 +930,37 @@ class XML_RPC_Message extends CI_Xmlrpc return; } } - else + // not top level element: see if parent is OK + elseif ( ! in_array($this->xh[$the_parser]['stack'][0], $this->valid_parents[$name], TRUE)) { - // not top level element: see if parent is OK - if ( ! in_array($this->xh[$the_parser]['stack'][0], $this->valid_parents[$name], TRUE)) - { - $this->xh[$the_parser]['isf'] = 2; - $this->xh[$the_parser]['isf_reason'] = 'XML-RPC element $name cannot be child of '.$this->xh[$the_parser]['stack'][0]; - return; - } + $this->xh[$the_parser]['isf'] = 2; + $this->xh[$the_parser]['isf_reason'] = 'XML-RPC element $name cannot be child of '.$this->xh[$the_parser]['stack'][0]; + return; } - switch($name) + switch ($name) { case 'STRUCT': case 'ARRAY': // Creates array for child elements - $cur_val = array('value' => array(), 'type' => $name); - array_unshift($this->xh[$the_parser]['valuestack'], $cur_val); - break; + break; case 'METHODNAME': case 'NAME': $this->xh[$the_parser]['ac'] = ''; - break; + break; case 'FAULT': $this->xh[$the_parser]['isf'] = 1; - break; + break; case 'PARAM': $this->xh[$the_parser]['value'] = NULL; - break; + break; case 'VALUE': $this->xh[$the_parser]['vt'] = 'value'; $this->xh[$the_parser]['ac'] = ''; $this->xh[$the_parser]['lv'] = 1; - break; + break; case 'I4': case 'INT': case 'STRING': @@ -885,65 +972,70 @@ class XML_RPC_Message extends CI_Xmlrpc { //two data elements inside a value: an error occurred! $this->xh[$the_parser]['isf'] = 2; - $this->xh[$the_parser]['isf_reason'] = "'Twas a $name element following a ".$this->xh[$the_parser]['vt']." element inside a single value"; + $this->xh[$the_parser]['isf_reason'] = "'Twas a ".$name.' element following a ' + .$this->xh[$the_parser]['vt'].' element inside a single value'; return; } $this->xh[$the_parser]['ac'] = ''; - break; + break; case 'MEMBER': // Set name of to nothing to prevent errors later if no is found $this->xh[$the_parser]['valuestack'][0]['name'] = ''; // Set NULL value to check to see if value passed for this param/member $this->xh[$the_parser]['value'] = NULL; - break; + break; case 'DATA': case 'METHODCALL': case 'METHODRESPONSE': case 'PARAMS': // valid elements that add little to processing - break; + break; default: /// An Invalid Element is Found, so we have trouble $this->xh[$the_parser]['isf'] = 2; - $this->xh[$the_parser]['isf_reason'] = "Invalid XML-RPC element found: $name"; - break; + $this->xh[$the_parser]['isf_reason'] = 'Invalid XML-RPC element found: '.$name; + break; } // Add current element name to stack, to allow validation of nesting array_unshift($this->xh[$the_parser]['stack'], $name); - if ($name != 'VALUE') $this->xh[$the_parser]['lv'] = 0; + $name == 'VALUE' OR $this->xh[$the_parser]['lv'] = 0; } - // END - //------------------------------------- - // End Element Handler - //------------------------------------- + // -------------------------------------------------------------------- + /** + * End Element Handler + * + * @param string + * @param string + * @return void + */ public function closing_tag($the_parser, $name) { if ($this->xh[$the_parser]['isf'] > 1) return; // Remove current element from stack and set variable // NOTE: If the XML validates, then we do not have to worry about - // the opening and closing of elements. Nesting is checked on the opening + // the opening and closing of elements. Nesting is checked on the opening // tag so we be safe there as well. $curr_elem = array_shift($this->xh[$the_parser]['stack']); - switch($name) + switch ($name) { case 'STRUCT': case 'ARRAY': $cur_val = array_shift($this->xh[$the_parser]['valuestack']); - $this->xh[$the_parser]['value'] = ( ! isset($cur_val['values'])) ? array() : $cur_val['values']; + $this->xh[$the_parser]['value'] = isset($cur_val['values']) ? $cur_val['values'] : array(); $this->xh[$the_parser]['vt'] = strtolower($name); - break; + break; case 'NAME': $this->xh[$the_parser]['valuestack'][0]['name'] = $this->xh[$the_parser]['ac']; - break; + break; case 'BOOLEAN': case 'I4': case 'INT': @@ -957,56 +1049,39 @@ class XML_RPC_Message extends CI_Xmlrpc { $this->xh[$the_parser]['value'] = $this->xh[$the_parser]['ac']; } - elseif ($name=='DATETIME.ISO8601') + elseif ($name == 'DATETIME.ISO8601') { $this->xh[$the_parser]['vt'] = $this->xmlrpcDateTime; $this->xh[$the_parser]['value'] = $this->xh[$the_parser]['ac']; } - elseif ($name=='BASE64') + elseif ($name == 'BASE64') { $this->xh[$the_parser]['value'] = base64_decode($this->xh[$the_parser]['ac']); } - elseif ($name=='BOOLEAN') + elseif ($name == 'BOOLEAN') { // Translated BOOLEAN values to TRUE AND FALSE - if ($this->xh[$the_parser]['ac'] == '1') - { - $this->xh[$the_parser]['value'] = TRUE; - } - else - { - $this->xh[$the_parser]['value'] = FALSE; - } + $this->xh[$the_parser]['value'] = (bool) $this->xh[$the_parser]['ac']; } elseif ($name=='DOUBLE') { // we have a DOUBLE // we must check that only 0123456789-. are characters here - if ( ! preg_match('/^[+-]?[eE0-9\t \.]+$/', $this->xh[$the_parser]['ac'])) - { - $this->xh[$the_parser]['value'] = 'ERROR_NON_NUMERIC_FOUND'; - } - else - { - $this->xh[$the_parser]['value'] = (float) $this->xh[$the_parser]['ac']; - } + $this->xh[$the_parser]['value'] = preg_match('/^[+-]?[eE0-9\t \.]+$/', $this->xh[$the_parser]['ac']) + ? (float) $this->xh[$the_parser]['ac'] + : 'ERROR_NON_NUMERIC_FOUND'; } else { // we have an I4/INT // we must check that only 0123456789- are characters here - if ( ! preg_match('/^[+-]?[0-9\t ]+$/', $this->xh[$the_parser]['ac'])) - { - $this->xh[$the_parser]['value'] = 'ERROR_NON_NUMERIC_FOUND'; - } - else - { - $this->xh[$the_parser]['value'] = (int)$this->xh[$the_parser]['ac']; - } + $this->xh[$the_parser]['value'] = preg_match('/^[+-]?[0-9\t ]+$/', $this->xh[$the_parser]['ac']) + ? (int) $this->xh[$the_parset]['ac'] + : 'ERROR_NON_NUMERIC_FOUND'; } $this->xh[$the_parser]['ac'] = ''; $this->xh[$the_parser]['lv'] = 3; // indicate we've found a value - break; + break; case 'VALUE': // This if() detects if no scalar was inside if ($this->xh[$the_parser]['vt']=='value') @@ -1028,44 +1103,49 @@ class XML_RPC_Message extends CI_Xmlrpc // Struct $this->xh[$the_parser]['value'] = $temp; } - break; + break; case 'MEMBER': - $this->xh[$the_parser]['ac']=''; + $this->xh[$the_parser]['ac'] = ''; // If value add to array in the stack for the last element built if ($this->xh[$the_parser]['value']) { $this->xh[$the_parser]['valuestack'][0]['values'][$this->xh[$the_parser]['valuestack'][0]['name']] = $this->xh[$the_parser]['value']; } - break; + break; case 'DATA': - $this->xh[$the_parser]['ac']=''; - break; + $this->xh[$the_parser]['ac'] = ''; + break; case 'PARAM': if ($this->xh[$the_parser]['value']) { $this->xh[$the_parser]['params'][] = $this->xh[$the_parser]['value']; } - break; + break; case 'METHODNAME': $this->xh[$the_parser]['method'] = ltrim($this->xh[$the_parser]['ac']); - break; + break; case 'PARAMS': case 'FAULT': case 'METHODCALL': case 'METHORESPONSE': // We're all good kids with nuthin' to do - break; + break; default: - // End of an Invalid Element. Taken care of during the opening tag though - break; + // End of an Invalid Element. Taken care of during the opening tag though + break; } } - //------------------------------------- - // Parses Character Data - //------------------------------------- + // -------------------------------------------------------------------- + /** + * Parse character data + * + * @param string + * @param string + * @return void + */ public function character_data($the_parser, $data) { if ($this->xh[$the_parser]['isf'] > 1) return; // XML Fault found already @@ -1078,7 +1158,7 @@ class XML_RPC_Message extends CI_Xmlrpc $this->xh[$the_parser]['lv'] = 2; // Found a value } - if ( ! @isset($this->xh[$the_parser]['ac'])) + if ( ! isset($this->xh[$the_parser]['ac'])) { $this->xh[$the_parser]['ac'] = ''; } @@ -1087,12 +1167,27 @@ class XML_RPC_Message extends CI_Xmlrpc } } + // -------------------------------------------------------------------- + /** + * Add parameter + * + * @param mixed + * @return void + */ public function addParam($par) { $this->params[] = $par; } + // -------------------------------------------------------------------- + + /** + * Output parameters + * + * @param array + * @return array + */ public function output_parameters($array = FALSE) { $CI =& get_instance(); @@ -1113,30 +1208,36 @@ class XML_RPC_Message extends CI_Xmlrpc } } - $parameters = $array; + return $array; } - else + + $parameters = array(); + + for ($i = 0, $c = count($this->params); $i < $c; $i++) { - $parameters = array(); + $a_param = $this->decode_message($this->params[$i]); - for ($i = 0, $c = count($this->params); $i < $c; $i++) + if (is_array($a_param)) { - $a_param = $this->decode_message($this->params[$i]); - - if (is_array($a_param)) - { - $parameters[] = $this->output_parameters($a_param); - } - else - { - $parameters[] = ($this->xss_clean) ? $CI->security->xss_clean($a_param) : $a_param; - } + $parameters[] = $this->output_parameters($a_param); + } + else + { + $parameters[] = ($this->xss_clean) ? $CI->security->xss_clean($a_param) : $a_param; } } return $parameters; } + // -------------------------------------------------------------------- + + /** + * Decode message + * + * @param object + * @return mixed + */ public function decode_message($param) { $kind = $param->kindOf(); @@ -1151,7 +1252,7 @@ class XML_RPC_Message extends CI_Xmlrpc $b = current($param->me); $arr = array(); - for($i = 0, $c = count($b); $i < $c; $i++) + for ($i = 0, $c = count($b); $i < $c; $i++) { $arr[] = $this->decode_message($param->me['array'][$i]); } @@ -1172,8 +1273,7 @@ class XML_RPC_Message extends CI_Xmlrpc } } -} -// End XML_RPC_Messages class +} // END XML_RPC_Message Class /** * XML-RPC Values class @@ -1187,6 +1287,13 @@ class XML_RPC_Values extends CI_Xmlrpc public $me = array(); public $mytype = 0; + /** + * Constructor + * + * @param mixed + * @param string + * @return void + */ public function __construct($val = -1, $type = '') { parent::__construct(); @@ -1210,11 +1317,20 @@ class XML_RPC_Values extends CI_Xmlrpc } } + // -------------------------------------------------------------------- + + /** + * Add scalar value + * + * @param scalar + * @param string + * @return int + */ public function addScalar($val, $type = 'string') { $typeof = $this->xmlrpcTypes[$type]; - if ($this->mytype==1) + if ($this->mytype == 1) { echo 'XML_RPC_Values: scalar can have only one value
'; return 0; @@ -1228,7 +1344,7 @@ class XML_RPC_Values extends CI_Xmlrpc if ($type == $this->xmlrpcBoolean) { - $val = (strcasecmp($val,'true') === 0 OR $val == 1 OR ($val == TRUE && strcasecmp($val, 'false'))) ? 1 : 0; + $val = (int) (strcasecmp($val,'true') === 0 OR $val === 1 OR ($val === TRUE && strcasecmp($val, 'false'))); } if ($this->mytype == 2) @@ -1244,9 +1360,18 @@ class XML_RPC_Values extends CI_Xmlrpc $this->me[$type] = $val; $this->mytype = $typeof; } + return 1; } + // -------------------------------------------------------------------- + + /** + * Add array value + * + * @param array + * @return int + */ public function addArray($vals) { if ($this->mytype != 0) @@ -1260,6 +1385,14 @@ class XML_RPC_Values extends CI_Xmlrpc return 1; } + // -------------------------------------------------------------------- + + /** + * Add struct value + * + * @param object + * @return int + */ public function addStruct($vals) { if ($this->mytype != 0) @@ -1272,29 +1405,37 @@ class XML_RPC_Values extends CI_Xmlrpc return 1; } + // -------------------------------------------------------------------- + + /** + * Get value type + * + * @return string + */ public function kindOf() { - switch($this->mytype) + switch ($this->mytype) { - case 3: - return 'struct'; - break; - case 2: - return 'array'; - break; - case 1: - return 'scalar'; - break; - default: - return 'undef'; + case 3: return 'struct'; + case 2: return 'array'; + case 1: return 'scalar'; + default: return 'undef'; } } + // -------------------------------------------------------------------- + + /** + * Serialize data + * + * @param string + * @param mixed + */ public function serializedata($typ, $val) { $rs = ''; - switch($this->xmlrpcTypes[$typ]) + switch ($this->xmlrpcTypes[$typ]) { case 3: // struct @@ -1305,11 +1446,11 @@ class XML_RPC_Values extends CI_Xmlrpc $rs .= "\n{$key2}\n".$this->serializeval($val2)."\n"; } $rs .= ''; - break; + break; case 2: // array $rs .= "\n\n"; - for($i = 0, $c = count($val); $i < $c; $i++) + for ($i = 0, $c = count($val); $i < $c; $i++) { $rs .= $this->serializeval($val[$i]); } @@ -1320,29 +1461,45 @@ class XML_RPC_Values extends CI_Xmlrpc switch ($typ) { case $this->xmlrpcBase64: - $rs .= "<{$typ}>" . base64_encode((string)$val) . "\n"; - break; + $rs .= '<'.$typ.'>'.base64_encode( (string) $val).'\n"; + break; case $this->xmlrpcBoolean: - $rs .= "<{$typ}>" . ((bool)$val ? '1' : '0') . "\n"; - break; + $rs .= '<'.$typ.'>'.( (bool) $val ? '1' : '0').'\n"; + break; case $this->xmlrpcString: - $rs .= "<{$typ}>" . htmlspecialchars((string)$val). "\n"; - break; + $rs .= '<'.$typ.'>'.htmlspecialchars( (string) $val).'\n"; + break; default: - $rs .= "<{$typ}>{$val}\n"; - break; + $rs .= '<'.$typ.'>'.$val.'\n"; + break; } default: - break; + break; } + return $rs; } + // -------------------------------------------------------------------- + + /** + * Serialize class + * + * @return string + */ public function serialize_class() { return $this->serializeval($this); } + // -------------------------------------------------------------------- + + /** + * Serialize value + * + * @param object + * @return string + */ public function serializeval($o) { $ar = $o->me; @@ -1352,26 +1509,35 @@ class XML_RPC_Values extends CI_Xmlrpc return "\n".$this->serializedata($typ, $val)."\n"; } + // -------------------------------------------------------------------- + + /** + * Scalar value + * + * @return mixed + */ public function scalarval() { reset($this->me); return current($this->me); } - - //------------------------------------- - // Encode time in ISO-8601 form. - //------------------------------------- - - // Useful for sending time in XML-RPC - - public function iso8601_encode($time, $utc = 0) + // -------------------------------------------------------------------- + + /** + * Encode time in ISO-8601 form. + * Useful for sending time in XML-RPC + * + * @param int unix timestamp + * @param bool + * @return string + */ + public function iso8601_encode($time, $utc = FALSE) { return ($utc) ? strftime('%Y%m%dT%H:%i:%s', $time) : gmstrftime('%Y%m%dT%H:%i:%s', $time); } -} -// END XML_RPC_Values Class +} // END XML_RPC_Values Class /* End of file Xmlrpc.php */ /* Location: ./system/libraries/Xmlrpc.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 0688ac9ad88a03f1c56cfcd9e3c475b83301344d Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Fri, 20 Apr 2012 10:25:04 -0400 Subject: Start comment cleanup of libraries --- system/libraries/Xmlrpc.php | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'system/libraries/Xmlrpc.php') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index fea560c2e..7009deacc 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -104,24 +104,24 @@ class CI_Xmlrpc { ); // Array of Valid Parents for Various XML-RPC elements - $this->valid_parents = array('BOOLEAN' => array('VALUE'), - 'I4' => array('VALUE'), - 'INT' => array('VALUE'), - 'STRING' => array('VALUE'), - 'DOUBLE' => array('VALUE'), - 'DATETIME.ISO8601' => array('VALUE'), - 'BASE64' => array('VALUE'), - 'ARRAY' => array('VALUE'), - 'STRUCT' => array('VALUE'), - 'PARAM' => array('PARAMS'), - 'METHODNAME' => array('METHODCALL'), - 'PARAMS' => array('METHODCALL', 'METHODRESPONSE'), - 'MEMBER' => array('STRUCT'), - 'NAME' => array('MEMBER'), - 'DATA' => array('ARRAY'), - 'FAULT' => array('METHODRESPONSE'), - 'VALUE' => array('MEMBER', 'DATA', 'PARAM', 'FAULT') - ); + $this->valid_parents = array('BOOLEAN' => array('VALUE'), + 'I4' => array('VALUE'), + 'INT' => array('VALUE'), + 'STRING' => array('VALUE'), + 'DOUBLE' => array('VALUE'), + 'DATETIME.ISO8601' => array('VALUE'), + 'BASE64' => array('VALUE'), + 'ARRAY' => array('VALUE'), + 'STRUCT' => array('VALUE'), + 'PARAM' => array('PARAMS'), + 'METHODNAME' => array('METHODCALL'), + 'PARAMS' => array('METHODCALL', 'METHODRESPONSE'), + 'MEMBER' => array('STRUCT'), + 'NAME' => array('MEMBER'), + 'DATA' => array('ARRAY'), + 'FAULT' => array('METHODRESPONSE'), + 'VALUE' => array('MEMBER', 'DATA', 'PARAM', 'FAULT') + ); // XML-RPC Responses -- cgit v1.2.3-24-g4f1b From 306b378525a13d9c5d1a7f0d6d50c2f263f22a04 Mon Sep 17 00:00:00 2001 From: George Petsagourakis Date: Wed, 2 May 2012 20:31:08 +0300 Subject: Fixing some typos in the xmlrpc class. Also, fputs is an alias for fwrite. --- system/libraries/Xmlrpc.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'system/libraries/Xmlrpc.php') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index 7009deacc..0d2533855 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -436,7 +436,7 @@ class XML_RPC_Client extends CI_Xmlrpc */ public function sendPayload($msg) { - $fp = @fsockopen($this->server, $this->port,$this->errno, $this->errstr, $this->timeout); + $fp = @fsockopen($this->server, $this->port,$this->errno, $this->errstring, $this->timeout); if ( ! is_resource($fp)) { @@ -458,7 +458,7 @@ class XML_RPC_Client extends CI_Xmlrpc .'Content-Length: '.strlen($msg->payload).$r.$r .$msg->payload; - if ( ! fputs($fp, $op, strlen($op))) + if ( ! fwrite($fp, $op, strlen($op))) { error_log($this->xmlrpcstr['http_error']); return new XML_RPC_Response(0, $this->xmlrpcerr['http_error'], $this->xmlrpcstr['http_error']); @@ -1076,7 +1076,7 @@ class XML_RPC_Message extends CI_Xmlrpc // we have an I4/INT // we must check that only 0123456789- are characters here $this->xh[$the_parser]['value'] = preg_match('/^[+-]?[0-9\t ]+$/', $this->xh[$the_parser]['ac']) - ? (int) $this->xh[$the_parset]['ac'] + ? (int) $this->xh[$the_parser]['ac'] : 'ERROR_NON_NUMERIC_FOUND'; } $this->xh[$the_parser]['ac'] = ''; -- cgit v1.2.3-24-g4f1b From d261b1e89c3d4d5191036d5a5660ef6764e593a0 Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Sat, 2 Jun 2012 11:12:16 +0100 Subject: Replaced `==` with `===` and `!=` with `!==` in /system/libraries --- system/libraries/Xmlrpc.php | 68 ++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 34 deletions(-) (limited to 'system/libraries/Xmlrpc.php') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index 0d2533855..6f3542333 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -256,7 +256,7 @@ class CI_Xmlrpc { */ public function set_debug($flag = TRUE) { - $this->debug = ($flag == TRUE); + $this->debug = ($flag === TRUE); } // -------------------------------------------------------------------- @@ -277,7 +277,7 @@ class CI_Xmlrpc { } else { - if (is_array($value[0]) && ($value[1] == 'struct' OR $value[1] == 'array')) + if (is_array($value[0]) && ($value[1] === 'struct' OR $value[1] === 'array')) { while (list($k) = each($value[0])) { @@ -496,7 +496,7 @@ class XML_RPC_Response */ public function __construct($val, $code = 0, $fstr = '') { - if ($code != 0) + if ($code !== 0) { // error $this->errno = $code; @@ -636,11 +636,11 @@ class XML_RPC_Response { $kind = $xmlrpc_val->kindOf(); - if ($kind == 'scalar') + if ($kind === 'scalar') { return $xmlrpc_val->scalarval(); } - elseif ($kind == 'array') + elseif ($kind === 'array') { reset($xmlrpc_val->me); $b = current($xmlrpc_val->me); @@ -652,7 +652,7 @@ class XML_RPC_Response } return $arr; } - elseif ($kind == 'struct') + elseif ($kind === 'struct') { reset($xmlrpc_val->me['struct']); $arr = array(); @@ -680,7 +680,7 @@ class XML_RPC_Response $t = 0; if (preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})/', $time, $regs)) { - $fnc = ($utc == TRUE) ? 'gmmktime' : 'mktime'; + $fnc = ($utc === TRUE) ? 'gmmktime' : 'mktime'; $t = $fnc($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]); } return $t; @@ -873,7 +873,7 @@ class XML_RPC_Message extends CI_Xmlrpc $errstr_v = $v->me['struct']['faultString']; $errno = $errno_v->scalarval(); - if ($errno == 0) + if ($errno === 0) { // FAULT returned, errno needs to reflect that $errno = -1; @@ -921,9 +921,9 @@ class XML_RPC_Message extends CI_Xmlrpc if ($this->xh[$the_parser]['isf'] > 1) return; // Evaluate and check for correct nesting of XML elements - if (count($this->xh[$the_parser]['stack']) == 0) + if (count($this->xh[$the_parser]['stack']) === 0) { - if ($name != 'METHODRESPONSE' && $name != 'METHODCALL') + if ($name !== 'METHODRESPONSE' && $name !== 'METHODCALL') { $this->xh[$the_parser]['isf'] = 2; $this->xh[$the_parser]['isf_reason'] = 'Top level XML-RPC element is missing'; @@ -968,7 +968,7 @@ class XML_RPC_Message extends CI_Xmlrpc case 'DOUBLE': case 'DATETIME.ISO8601': case 'BASE64': - if ($this->xh[$the_parser]['vt'] != 'value') + if ($this->xh[$the_parser]['vt'] !== 'value') { //two data elements inside a value: an error occurred! $this->xh[$the_parser]['isf'] = 2; @@ -1002,7 +1002,7 @@ class XML_RPC_Message extends CI_Xmlrpc // Add current element name to stack, to allow validation of nesting array_unshift($this->xh[$the_parser]['stack'], $name); - $name == 'VALUE' OR $this->xh[$the_parser]['lv'] = 0; + $name === 'VALUE' OR $this->xh[$the_parser]['lv'] = 0; } // -------------------------------------------------------------------- @@ -1045,20 +1045,20 @@ class XML_RPC_Message extends CI_Xmlrpc case 'BASE64': $this->xh[$the_parser]['vt'] = strtolower($name); - if ($name == 'STRING') + if ($name === 'STRING') { $this->xh[$the_parser]['value'] = $this->xh[$the_parser]['ac']; } - elseif ($name == 'DATETIME.ISO8601') + elseif ($name === 'DATETIME.ISO8601') { $this->xh[$the_parser]['vt'] = $this->xmlrpcDateTime; $this->xh[$the_parser]['value'] = $this->xh[$the_parser]['ac']; } - elseif ($name == 'BASE64') + elseif ($name === 'BASE64') { $this->xh[$the_parser]['value'] = base64_decode($this->xh[$the_parser]['ac']); } - elseif ($name == 'BOOLEAN') + elseif ($name === 'BOOLEAN') { // Translated BOOLEAN values to TRUE AND FALSE $this->xh[$the_parser]['value'] = (bool) $this->xh[$the_parser]['ac']; @@ -1093,7 +1093,7 @@ class XML_RPC_Message extends CI_Xmlrpc // build the XML-RPC value out of the data received, and substitute it $temp = new XML_RPC_Values($this->xh[$the_parser]['value'], $this->xh[$the_parser]['vt']); - if (count($this->xh[$the_parser]['valuestack']) && $this->xh[$the_parser]['valuestack'][0]['type'] == 'ARRAY') + if (count($this->xh[$the_parser]['valuestack']) && $this->xh[$the_parser]['valuestack'][0]['type'] === 'ARRAY') { // Array $this->xh[$the_parser]['valuestack'][0]['values'][] = $temp; @@ -1151,9 +1151,9 @@ class XML_RPC_Message extends CI_Xmlrpc if ($this->xh[$the_parser]['isf'] > 1) return; // XML Fault found already // If a value has not been found - if ($this->xh[$the_parser]['lv'] != 3) + if ($this->xh[$the_parser]['lv'] !== 3) { - if ($this->xh[$the_parser]['lv'] == 1) + if ($this->xh[$the_parser]['lv'] === 1) { $this->xh[$the_parser]['lv'] = 2; // Found a value } @@ -1204,7 +1204,7 @@ class XML_RPC_Message extends CI_Xmlrpc { // 'bits' is for the MetaWeblog API image bits // @todo - this needs to be made more general purpose - $array[$key] = ($key == 'bits' OR $this->xss_clean == FALSE) ? $array[$key] : $CI->security->xss_clean($array[$key]); + $array[$key] = ($key === 'bits' OR $this->xss_clean === FALSE) ? $array[$key] : $CI->security->xss_clean($array[$key]); } } @@ -1242,11 +1242,11 @@ class XML_RPC_Message extends CI_Xmlrpc { $kind = $param->kindOf(); - if ($kind == 'scalar') + if ($kind === 'scalar') { return $param->scalarval(); } - elseif ($kind == 'array') + elseif ($kind === 'array') { reset($param->me); $b = current($param->me); @@ -1259,7 +1259,7 @@ class XML_RPC_Message extends CI_Xmlrpc return $arr; } - elseif ($kind == 'struct') + elseif ($kind === 'struct') { reset($param->me['struct']); $arr = array(); @@ -1298,19 +1298,19 @@ class XML_RPC_Values extends CI_Xmlrpc { parent::__construct(); - if ($val != -1 OR $type != '') + if ($val !== -1 OR $type !== '') { - $type = $type == '' ? 'string' : $type; + $type = $type === '' ? 'string' : $type; - if ($this->xmlrpcTypes[$type] == 1) + if ($this->xmlrpcTypes[$type] === 1) { $this->addScalar($val,$type); } - elseif ($this->xmlrpcTypes[$type] == 2) + elseif ($this->xmlrpcTypes[$type] === 2) { $this->addArray($val); } - elseif ($this->xmlrpcTypes[$type] == 3) + elseif ($this->xmlrpcTypes[$type] === 3) { $this->addStruct($val); } @@ -1330,24 +1330,24 @@ class XML_RPC_Values extends CI_Xmlrpc { $typeof = $this->xmlrpcTypes[$type]; - if ($this->mytype == 1) + if ($this->mytype === 1) { echo 'XML_RPC_Values: scalar can have only one value
'; return 0; } - if ($typeof != 1) + if ($typeof !== 1) { echo 'XML_RPC_Values: not a scalar type (${typeof})
'; return 0; } - if ($type == $this->xmlrpcBoolean) + if ($type === $this->xmlrpcBoolean) { $val = (int) (strcasecmp($val,'true') === 0 OR $val === 1 OR ($val === TRUE && strcasecmp($val, 'false'))); } - if ($this->mytype == 2) + if ($this->mytype === 2) { // adding to an array here $ar = $this->me['array']; @@ -1374,7 +1374,7 @@ class XML_RPC_Values extends CI_Xmlrpc */ public function addArray($vals) { - if ($this->mytype != 0) + if ($this->mytype !== 0) { echo 'XML_RPC_Values: already initialized as a [' . $this->kindOf() . ']
'; return 0; @@ -1395,7 +1395,7 @@ class XML_RPC_Values extends CI_Xmlrpc */ public function addStruct($vals) { - if ($this->mytype != 0) + if ($this->mytype !== 0) { echo 'XML_RPC_Values: already initialized as a [' . $this->kindOf() . ']
'; return 0; -- cgit v1.2.3-24-g4f1b From 3dad2e714189b992248261c78d780b322b3c73da Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 14 Jun 2012 15:10:56 +0300 Subject: Replace strncmp() usage with strpos() --- system/libraries/Xmlrpc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries/Xmlrpc.php') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index 6f3542333..eac4ac118 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -778,7 +778,7 @@ class XML_RPC_Message extends CI_Xmlrpc } // Check for HTTP 200 Response - if (strncmp($data, 'HTTP', 4) === 0 && ! preg_match('/^HTTP\/[0-9\.]+ 200 /', $data)) + if (strpos($data, 'HTTP') === 0 && ! preg_match('/^HTTP\/[0-9\.]+ 200 /', $data)) { $errstr = substr($data, 0, strpos($data, "\n")-1); return new XML_RPC_Response(0, $this->xmlrpcerr['http_error'], $this->xmlrpcstr['http_error'].' ('.$errstr.')'); -- cgit v1.2.3-24-g4f1b 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/libraries/Xmlrpc.php') 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 From cfcf34e0bb9fbac5498740711552d04be3b7e63c Mon Sep 17 00:00:00 2001 From: Valentin Sheyretski Date: Mon, 2 Jul 2012 12:04:36 +0300 Subject: Update develop --- system/libraries/Xmlrpc.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'system/libraries/Xmlrpc.php') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index 80648c9bd..58389bf32 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, $proxy=FALSE, $proxy_port = 8080) + public function server($url, $port = 80, $proxy = FALSE, $proxy_port = 8080) { if (strpos($url, 'http') !== 0) { @@ -440,12 +440,15 @@ class XML_RPC_Client extends CI_Xmlrpc */ public function sendPayload($msg) { - $server = $this->server; - $port = $this->port; - if ($this->proxy !== FALSE) { + if ($this->proxy === FALSE) + { + $server = $this->server; + $port = $this->port; + } else { $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 From 09217cec2b951a13d5afe7ea8b689085165a9bd5 Mon Sep 17 00:00:00 2001 From: Valentin Sheyretski Date: Mon, 2 Jul 2012 16:27:01 +0300 Subject: Update xmlrpc coding style --- system/libraries/Xmlrpc.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'system/libraries/Xmlrpc.php') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index 58389bf32..e54030a7c 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -444,7 +444,9 @@ class XML_RPC_Client extends CI_Xmlrpc { $server = $this->server; $port = $this->port; - } else { + } + else + { $server = $this->proxy; $port = $this->proxy_port; } -- cgit v1.2.3-24-g4f1b From c02e7c5d929d17e3448b944e2279a4c6dc338614 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 2 Jul 2012 16:43:43 +0300 Subject: Add changelog entry for pull #1556 --- system/libraries/Xmlrpc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries/Xmlrpc.php') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index e54030a7c..cbb91c40a 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -440,7 +440,7 @@ class XML_RPC_Client extends CI_Xmlrpc */ public function sendPayload($msg) { - if ($this->proxy === FALSE) + if ($this->proxy === FALSE) { $server = $this->server; $port = $this->port; -- cgit v1.2.3-24-g4f1b From 3f3f135ed5b47fd87a59d31fb3d1a4c773dcc3b3 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 5 Sep 2012 16:39:28 +0300 Subject: Misc. style changes --- system/libraries/Xmlrpc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries/Xmlrpc.php') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index cbb91c40a..a8aaa2088 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -1359,7 +1359,7 @@ class XML_RPC_Values extends CI_Xmlrpc if ($type === $this->xmlrpcBoolean) { - $val = (int) (strcasecmp($val,'true') === 0 OR $val === 1 OR ($val === TRUE && strcasecmp($val, 'false'))); + $val = (int) (strcasecmp($val, 'true') === 0 OR $val === 1 OR ($val === TRUE && strcasecmp($val, 'false'))); } if ($this->mytype === 2) -- cgit v1.2.3-24-g4f1b From 740480a7513e29e201f56c6481067108a2031509 Mon Sep 17 00:00:00 2001 From: Dimitar Date: Fri, 5 Oct 2012 13:24:59 +0300 Subject: Bug-fix in XML-RPC library $type and $typeof are passed as strings in this function, therefore I took the easy way and simplified the validation. I tested with different requests (strings, numbers ..), no other issues found. --- system/libraries/Xmlrpc.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) mode change 100644 => 100755 system/libraries/Xmlrpc.php (limited to 'system/libraries/Xmlrpc.php') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php old mode 100644 new mode 100755 index a8aaa2088..dc5d27f8c --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -1317,15 +1317,15 @@ class XML_RPC_Values extends CI_Xmlrpc { $type = $type === '' ? 'string' : $type; - if ($this->xmlrpcTypes[$type] === 1) + if ($this->xmlrpcTypes[$type] == 1) { $this->addScalar($val,$type); } - elseif ($this->xmlrpcTypes[$type] === 2) + elseif ($this->xmlrpcTypes[$type] == 2) { $this->addArray($val); } - elseif ($this->xmlrpcTypes[$type] === 3) + elseif ($this->xmlrpcTypes[$type] == 3) { $this->addStruct($val); } @@ -1351,7 +1351,7 @@ class XML_RPC_Values extends CI_Xmlrpc return 0; } - if ($typeof !== 1) + if ($typeof != 1) { echo 'XML_RPC_Values: not a scalar type (${typeof})
'; return 0; -- cgit v1.2.3-24-g4f1b From 5fd3ae8d33a4f5d3159b86683b9a670e973a63f5 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 24 Oct 2012 14:55:35 +0300 Subject: [ci skip] style and phpdoc-related changes (rel #1295) --- system/libraries/Xmlrpc.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'system/libraries/Xmlrpc.php') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index dc5d27f8c..3ed050a2e 100755 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -170,8 +170,10 @@ class CI_Xmlrpc { /** * Parse server URL * - * @param string url - * @param int port + * @param string $url + * @param int $port = 80 + * @param string $proxy = FALSE + * @param int $proxy_port = 8080 * @return void */ public function server($url, $port = 80, $proxy = FALSE, $proxy_port = 8080) @@ -395,9 +397,11 @@ class XML_RPC_Client extends CI_Xmlrpc /** * Constructor * - * @param string - * @param object - * @param int + * @param string $path + * @param object $server + * @param int $port = 80 + * @param string $proxy = FALSE + * @param int $proxy_port = 8080 * @return void */ public function __construct($path, $server, $port = 80, $proxy = FALSE, $proxy_port = 8080) -- cgit v1.2.3-24-g4f1b From c5536aac5752054f7f76e448d58b86407d8f574e Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 1 Nov 2012 17:33:58 +0200 Subject: Manually apply PR #1594 (fixing phpdoc page-level generation/warnings) Also partially fixes issue #1295, fixes inconsistencies in some page-level docblocks and adds include checks in language files. --- system/libraries/Xmlrpc.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'system/libraries/Xmlrpc.php') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index 3ed050a2e..79e6c613f 100755 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -1,4 +1,4 @@ - Date: Fri, 2 Nov 2012 00:17:39 +0200 Subject: [ci skip] DocBlocks for Upload and Xmlrpc libraries Partially fixes issue #1295 --- system/libraries/Xmlrpc.php | 369 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 329 insertions(+), 40 deletions(-) (limited to 'system/libraries/Xmlrpc.php') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index 79e6c613f..3ef823e29 100755 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -26,6 +26,13 @@ */ defined('BASEPATH') OR exit('No direct script access allowed'); +if ( ! function_exists('xml_parser_create')) +{ + show_error('Your PHP installation does not support XML'); +} + +// ------------------------------------------------------------------------ + /** * XML-RPC request handler class * @@ -35,56 +42,212 @@ defined('BASEPATH') OR exit('No direct script access allowed'); * @author EllisLab Dev Team * @link http://codeigniter.com/user_guide/libraries/xmlrpc.html */ - -if ( ! function_exists('xml_parser_create')) -{ - show_error('Your PHP installation does not support XML'); -} - -// ------------------------------------------------------------------------ - class CI_Xmlrpc { - public $debug = FALSE; // Debugging on or off + /** + * Debug flag + * + * @var bool + */ + public $debug = FALSE; + + /** + * I4 data type + * + * @var string + */ public $xmlrpcI4 = 'i4'; + + /** + * Integer data type + * + * @var string + */ public $xmlrpcInt = 'int'; + + /** + * Boolean data type + * + * @var string + */ public $xmlrpcBoolean = 'boolean'; + + /** + * Double data type + * + * @var string + */ public $xmlrpcDouble = 'double'; + + /** + * String data type + * + * @var string + */ public $xmlrpcString = 'string'; + + /** + * DateTime format + * + * @var string + */ public $xmlrpcDateTime = 'dateTime.iso8601'; + + /** + * Base64 data type + * + * @var string + */ public $xmlrpcBase64 = 'base64'; + + /** + * Array data type + * + * @var string + */ public $xmlrpcArray = 'array'; + + /** + * Struct data type + * + * @var string + */ public $xmlrpcStruct = 'struct'; + /** + * Data types list + * + * @var array + */ public $xmlrpcTypes = array(); + + /** + * Valid parents list + * + * @var array + */ public $valid_parents = array(); - public $xmlrpcerr = array(); // Response numbers - public $xmlrpcstr = array(); // Response strings + /** + * Response error numbers list + * + * @var array + */ + public $xmlrpcerr = array(); + + /** + * Response error messages list + * + * @var string[] + */ + public $xmlrpcstr = array(); + + /** + * Encoding charset + * + * @var string + */ public $xmlrpc_defencoding = 'UTF-8'; + + /** + * XML-RPC client name + * + * @var string + */ public $xmlrpcName = 'XML-RPC for CodeIgniter'; + + /** + * XML-RPC version + * + * @var string + */ public $xmlrpcVersion = '1.1'; - public $xmlrpcerruser = 800; // Start of user errors - public $xmlrpcerrxml = 100; // Start of XML Parse errors - public $xmlrpc_backslash = ''; // formulate backslashes for escaping regexp + /** + * Start of user errors + * + * @var int + */ + public $xmlrpcerruser = 800; + + /** + * Start of XML parse errors + * + * @var int + */ + public $xmlrpcerrxml = 100; + + /** + * Backslash replacement value + * + * @var string + */ + public $xmlrpc_backslash = ''; + + /** + * XML-RPC Client object + * + * @var object + */ public $client; + + /** + * XML-RPC Method name + * + * @var string + */ public $method; + + /** + * XML-RPC Data + * + * @var array + */ public $data; + + /** + * XML-RPC Message + * + * @var string + */ public $message = ''; - public $error = ''; // Error string for request + + /** + * Request error message + * + * @var string + */ + public $error = ''; + + /** + * XML-RPC result object + * + * @var object + */ public $result; + + /** + * XML-RPC Reponse + * + * @var array + */ public $response = array(); // Response from remote server + /** + * XSS Filter flag + * + * @var bool + */ public $xss_clean = TRUE; + // -------------------------------------------------------------------- /** * Constructor * * Initializes property default values * - * @param array + * @param array $config * @return void */ public function __construct($config = array()) @@ -149,7 +312,7 @@ class CI_Xmlrpc { /** * Initialize * - * @param array + * @param array $config * @return void */ public function initialize($config = array()) @@ -172,9 +335,9 @@ class CI_Xmlrpc { * Parse server URL * * @param string $url - * @param int $port = 80 - * @param string $proxy = FALSE - * @param int $proxy_port = 8080 + * @param int $port + * @param string $proxy + * @param int $proxy_port * @return void */ public function server($url, $port = 80, $proxy = FALSE, $proxy_port = 8080) @@ -201,7 +364,7 @@ class CI_Xmlrpc { /** * Set Timeout * - * @param int seconds + * @param int $seconds * @return void */ public function timeout($seconds = 5) @@ -217,7 +380,7 @@ class CI_Xmlrpc { /** * Set Methods * - * @param string method name + * @param string $function Method name * @return void */ public function method($function) @@ -230,7 +393,7 @@ class CI_Xmlrpc { /** * Take Array of Data and Create Objects * - * @param array + * @param array $incoming * @return void */ public function request($incoming) @@ -254,7 +417,7 @@ class CI_Xmlrpc { /** * Set Debug * - * @param bool + * @param bool $flag * @return void */ public function set_debug($flag = TRUE) @@ -267,7 +430,7 @@ class CI_Xmlrpc { /** * Values Parsing * - * @param mixed + * @param mixed $value * @return object */ public function values_parsing($value) @@ -350,8 +513,8 @@ class CI_Xmlrpc { /** * Sends an Error Message for Server Request * - * @param int - * @param string + * @param int $number + * @param string $message * @return object */ public function send_error_message($number, $message) @@ -364,7 +527,7 @@ class CI_Xmlrpc { /** * Send Response for Server Request * - * @param array + * @param array $response * @return object */ public function send_response($response) @@ -385,24 +548,79 @@ class CI_Xmlrpc { */ class XML_RPC_Client extends CI_Xmlrpc { + /** + * Path + * + * @var string + */ public $path = ''; + + /** + * Server hostname + * + * @var string + */ public $server = ''; + + /** + * Server port + * + * @var int + */ public $port = 80; + + /** + * Proxy hostname + * + * @var string + */ public $proxy = FALSE; + + /** + * Proxy port + * + * @var int + */ public $proxy_port = 8080; + + /** + * Error number + * + * @var string + */ public $errno = ''; + + /** + * Error message + * + * @var string + */ public $errstring = ''; + + /** + * Timeout in seconds + * + * @var int + */ public $timeout = 5; + + /** + * No Multicall flag + * + * @var bool + */ public $no_multicall = FALSE; + // -------------------------------------------------------------------- + /** * Constructor * * @param string $path * @param object $server - * @param int $port = 80 - * @param string $proxy = FALSE - * @param int $proxy_port = 8080 + * @param int $port + * @param string $proxy + * @param int $proxy_port * @return void */ public function __construct($path, $server, $port = 80, $proxy = FALSE, $proxy_port = 8080) @@ -421,7 +639,7 @@ class XML_RPC_Client extends CI_Xmlrpc /** * Send message * - * @param mixed + * @param mixed $msg * @return object */ public function send($msg) @@ -440,7 +658,7 @@ class XML_RPC_Client extends CI_Xmlrpc /** * Send payload * - * @param object + * @param object $msg * @return object */ public function sendPayload($msg) @@ -500,18 +718,50 @@ class XML_RPC_Client extends CI_Xmlrpc */ class XML_RPC_Response { + + /** + * Value + * + * @var mixed + */ public $val = 0; + + /** + * Error number + * + * @var int + */ public $errno = 0; + + /** + * Error message + * + * @var string + */ public $errstr = ''; + + /** + * Headers list + * + * @var array + */ public $headers = array(); + + /** + * XSS Filter flag + * + * @var bool + */ public $xss_clean = TRUE; + // -------------------------------------------------------------------- + /** * Constructor * - * @param mixed - * @param int - * @param string + * @param mixed $val + * @param int $code + * @param string $fstr * @return void */ public function __construct($val, $code = 0, $fstr = '') @@ -717,16 +967,42 @@ class XML_RPC_Response */ class XML_RPC_Message extends CI_Xmlrpc { + + /** + * Payload + * + * @var string + */ public $payload; + + /** + * Method name + * + * @var string + */ public $method_name; + + /** + * Parameter list + * + * @var array + */ public $params = array(); + + /** + * XH? + * + * @var array + */ public $xh = array(); + // -------------------------------------------------------------------- + /** * Constructor * - * @param string method name - * @param array + * @param string $method + * @param array $pars * @return void */ public function __construct($method, $pars = FALSE) @@ -1304,14 +1580,27 @@ class XML_RPC_Message extends CI_Xmlrpc */ class XML_RPC_Values extends CI_Xmlrpc { + /** + * Value data + * + * @var array + */ public $me = array(); + + /** + * Value type + * + * @var int + */ public $mytype = 0; + // -------------------------------------------------------------------- + /** * Constructor * - * @param mixed - * @param string + * @param mixed $val + * @param string $type * @return void */ public function __construct($val = -1, $type = '') -- cgit v1.2.3-24-g4f1b From 2eaeee5aa3971932e58ffac48554e554d799249f Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 21 Nov 2012 14:31:26 +0200 Subject: Change fs permissions and add some missing index.html files (#2017) --- system/libraries/Xmlrpc.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 system/libraries/Xmlrpc.php (limited to 'system/libraries/Xmlrpc.php') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php old mode 100755 new mode 100644 -- cgit v1.2.3-24-g4f1b From b497d2b70af664caff50c54117d113e3fc692967 Mon Sep 17 00:00:00 2001 From: vkeranov Date: Fri, 23 Nov 2012 23:27:33 +0200 Subject: Minor changes to Xmlrpc.php --- system/libraries/Xmlrpc.php | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'system/libraries/Xmlrpc.php') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index 3ef823e29..529089914 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -231,7 +231,7 @@ class CI_Xmlrpc { * * @var array */ - public $response = array(); // Response from remote server + public $response = array(); // Response from remote server /** * XSS Filter flag @@ -265,7 +265,7 @@ class CI_Xmlrpc { $this->xmlrpcBase64 => '1', $this->xmlrpcArray => '2', $this->xmlrpcStruct => '3' - ); + ); // Array of Valid Parents for Various XML-RPC elements $this->valid_parents = array('BOOLEAN' => array('VALUE'), @@ -285,14 +285,13 @@ class CI_Xmlrpc { 'DATA' => array('ARRAY'), 'FAULT' => array('METHODRESPONSE'), 'VALUE' => array('MEMBER', 'DATA', 'PARAM', 'FAULT') - ); - + ); // XML-RPC Responses $this->xmlrpcerr['unknown_method'] = '1'; $this->xmlrpcstr['unknown_method'] = 'This is not a known method for this XML-RPC Server'; $this->xmlrpcerr['invalid_return'] = '2'; - $this->xmlrpcstr['invalid_return'] = 'The XML data received was either invalid or not in the correct form for XML-RPC. Turn on debugging to examine the XML data further.'; + $this->xmlrpcstr['invalid_return'] = 'The XML data received was either invalid or not in the correct form for XML-RPC. Turn on debugging to examine the XML data further.'; $this->xmlrpcerr['incorrect_params'] = '3'; $this->xmlrpcstr['incorrect_params'] = 'Incorrect parameters were passed to method'; $this->xmlrpcerr['introspect_unknown'] = '4'; @@ -300,7 +299,7 @@ class CI_Xmlrpc { $this->xmlrpcerr['http_error'] = '5'; $this->xmlrpcstr['http_error'] = "Did not receive a '200 OK' response from remote server."; $this->xmlrpcerr['no_data'] = '6'; - $this->xmlrpcstr['no_data'] ='No data received from server.'; + $this->xmlrpcstr['no_data'] = 'No data received from server.'; $this->initialize($config); @@ -946,7 +945,7 @@ class XML_RPC_Response */ public function iso8601_decode($time, $utc = FALSE) { - // return a time in the localtime, or UTC + // Return a time in the localtime, or UTC $t = 0; if (preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})/', $time, $regs)) { @@ -1081,7 +1080,7 @@ class XML_RPC_Message extends CI_Xmlrpc } //------------------------------------- - // Create and Set Up XML Parser + // Create and Set Up XML Parser //------------------------------------- $parser = xml_parser_create($this->xmlrpc_defencoding); @@ -1119,7 +1118,7 @@ class XML_RPC_Message extends CI_Xmlrpc $errstr = sprintf('XML error: %s at line %d', xml_error_string(xml_get_error_code($parser)), xml_get_current_line_number($parser)); - //error_log($errstr); + $r = new XML_RPC_Response(0, $this->xmlrpcerr['invalid_return'], $this->xmlrpcstr['invalid_return']); xml_parser_free($parser); return $r; @@ -1230,7 +1229,7 @@ class XML_RPC_Message extends CI_Xmlrpc elseif ( ! in_array($this->xh[$the_parser]['stack'][0], $this->valid_parents[$name], TRUE)) { $this->xh[$the_parser]['isf'] = 2; - $this->xh[$the_parser]['isf_reason'] = 'XML-RPC element $name cannot be child of '.$this->xh[$the_parser]['stack'][0]; + $this->xh[$the_parser]['isf_reason'] = 'XML-RPC element '.$name.' cannot be child of '.$this->xh[$the_parser]['stack'][0]; return; } @@ -1268,7 +1267,7 @@ class XML_RPC_Message extends CI_Xmlrpc { //two data elements inside a value: an error occurred! $this->xh[$the_parser]['isf'] = 2; - $this->xh[$the_parser]['isf_reason'] = "'Twas a ".$name.' element following a ' + $this->xh[$the_parser]['isf_reason'] = 'There is a '.$name.' element following a ' .$this->xh[$the_parser]['vt'].' element inside a single value'; return; } @@ -1380,7 +1379,7 @@ class XML_RPC_Message extends CI_Xmlrpc break; case 'VALUE': // This if() detects if no scalar was inside - if ($this->xh[$the_parser]['vt']=='value') + if ($this->xh[$the_parser]['vt'] == 'value') { $this->xh[$the_parser]['value'] = $this->xh[$the_parser]['ac']; $this->xh[$the_parser]['vt'] = $this->xmlrpcString; @@ -1613,7 +1612,7 @@ class XML_RPC_Values extends CI_Xmlrpc if ($this->xmlrpcTypes[$type] == 1) { - $this->addScalar($val,$type); + $this->addScalar($val, $type); } elseif ($this->xmlrpcTypes[$type] == 2) { -- cgit v1.2.3-24-g4f1b From 80500afbd188600212ca913a7bac073009feac73 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 1 Jan 2013 08:16:53 +0200 Subject: [ci skip] Happy new year --- system/libraries/Xmlrpc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries/Xmlrpc.php') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index 529089914..c3c7690f0 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -18,7 +18,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/) + * @copyright Copyright (c) 2008 - 2013, EllisLab, Inc. (http://ellislab.com/) * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com * @since Version 1.0 -- cgit v1.2.3-24-g4f1b From 1228fe27bc1f22838cd80c5fe33c37274faf0e24 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Mon, 14 Jan 2013 01:30:09 +0100 Subject: Replace is_null() with === / !== NULL Exact same behavior, but faster. I also think it's more readable. --- system/libraries/Xmlrpc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries/Xmlrpc.php') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index c3c7690f0..9e60791ae 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -368,7 +368,7 @@ class CI_Xmlrpc { */ public function timeout($seconds = 5) { - if ( ! is_null($this->client) && is_int($seconds)) + if ($this->client !== NULL && is_int($seconds)) { $this->client->timeout = $seconds; } -- cgit v1.2.3-24-g4f1b From 998607025296044cd71b7ab9da7fe3551b1e3ac7 Mon Sep 17 00:00:00 2001 From: Rasmus Lerdorf Date: Sat, 18 May 2013 10:27:12 -0400 Subject: values_parsing() only takes 1 arg Signed-off-by: Rasmus Lerdorf --- system/libraries/Xmlrpc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/libraries/Xmlrpc.php') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index 9e60791ae..2675f724e 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -446,7 +446,7 @@ class CI_Xmlrpc { { while (list($k) = each($value[0])) { - $value[0][$k] = $this->values_parsing($value[0][$k], TRUE); + $value[0][$k] = $this->values_parsing($value[0][$k]); } } @@ -1848,4 +1848,4 @@ class XML_RPC_Values extends CI_Xmlrpc } // END XML_RPC_Values Class /* End of file Xmlrpc.php */ -/* Location: ./system/libraries/Xmlrpc.php */ \ No newline at end of file +/* Location: ./system/libraries/Xmlrpc.php */ -- cgit v1.2.3-24-g4f1b From c5a7c5fd34e5446251d466c46425e129886da52b Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 17 Jul 2013 20:10:09 +0300 Subject: [ci skip] Remove some empty lines --- system/libraries/Xmlrpc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries/Xmlrpc.php') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index 2675f724e..16c5b0ed8 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -1848,4 +1848,4 @@ class XML_RPC_Values extends CI_Xmlrpc } // END XML_RPC_Values Class /* End of file Xmlrpc.php */ -/* Location: ./system/libraries/Xmlrpc.php */ +/* Location: ./system/libraries/Xmlrpc.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 3ca060a00e5039aa00d4180ded52b1af49939114 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 27 Nov 2013 16:30:31 +0200 Subject: [ci skip] Remove a few more spaces --- system/libraries/Xmlrpc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/libraries/Xmlrpc.php') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index 16c5b0ed8..fe9781b28 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -1684,7 +1684,7 @@ class XML_RPC_Values extends CI_Xmlrpc { if ($this->mytype !== 0) { - echo 'XML_RPC_Values: already initialized as a [' . $this->kindOf() . ']
'; + echo 'XML_RPC_Values: already initialized as a ['.$this->kindOf().']
'; return 0; } @@ -1705,7 +1705,7 @@ class XML_RPC_Values extends CI_Xmlrpc { if ($this->mytype !== 0) { - echo 'XML_RPC_Values: already initialized as a [' . $this->kindOf() . ']
'; + echo 'XML_RPC_Values: already initialized as a ['.$this->kindOf().']
'; return 0; } $this->mytype = $this->xmlrpcTypes['struct']; -- cgit v1.2.3-24-g4f1b From dc53d7b68adc6fdc8d0917ee2d29f5670ff82b45 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 7 Jan 2014 12:12:11 +0200 Subject: Add Basic HTTP authentication support to the XML-RPC library (based on PR #1716) --- system/libraries/Xmlrpc.php | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'system/libraries/Xmlrpc.php') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index fe9781b28..bd59c933d 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -348,6 +348,11 @@ class CI_Xmlrpc { $parts = parse_url($url); + if (isset($parts['user'], $parts['pass'])) + { + $parts['host'] = $parts['user'].':'.$parts['pass'].'@'.$parts['host']; + } + $path = isset($parts['path']) ? $parts['path'] : '/'; if ( ! empty($parts['query'])) @@ -568,6 +573,21 @@ class XML_RPC_Client extends CI_Xmlrpc */ public $port = 80; + /** + * + * Server username + * + * @var string + */ + public $username; + + /** + * Server password + * + * @var string + */ + public $password; + /** * Proxy hostname * @@ -626,8 +646,16 @@ class XML_RPC_Client extends CI_Xmlrpc { parent::__construct(); + $url = parse_url('http://'.$server); + + if (isset($url['user'], $url['pass'])) + { + $this->username = $url['user']; + $this->password = $url['pass']; + } + $this->port = $port; - $this->server = $server; + $this->server = $url['host']; $this->path = $path; $this->proxy = $proxy; $this->proxy_port = $proxy_port; @@ -691,6 +719,7 @@ class XML_RPC_Client extends CI_Xmlrpc $op = 'POST '.$this->path.' HTTP/1.0'.$r .'Host: '.$this->server.$r .'Content-Type: text/xml'.$r + .(isset($this->username, $this->password) ? 'Authorization: Basic '.base64_encode($this->username.':'.$this->password).$r : '') .'User-Agent: '.$this->xmlrpcName.$r .'Content-Length: '.strlen($msg->payload).$r.$r .$msg->payload; -- cgit v1.2.3-24-g4f1b From e417f0439440246a66e02296da701e84c6c37866 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 8 Jan 2014 14:48:01 +0200 Subject: Some small improvements to the Xmlrpc class --- system/libraries/Xmlrpc.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'system/libraries/Xmlrpc.php') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index bd59c933d..2fd12599e 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -884,10 +884,10 @@ class XML_RPC_Response /** * Decode * - * @param mixed + * @param mixed $array * @return array */ - public function decode($array = FALSE) + public function decode($array = NULL) { $CI =& get_instance(); @@ -899,9 +899,9 @@ class XML_RPC_Response { $array[$key] = $this->decode($array[$key]); } - else + elseif ($this->xss_clean) { - $array[$key] = ($this->xss_clean) ? $CI->security->xss_clean($array[$key]) : $array[$key]; + $array[$key] = $CI->security->xss_clean($array[$key]); } } @@ -914,9 +914,9 @@ class XML_RPC_Response { $result = $this->decode($result); } - else + elseif ($this->xss_clean) { - $result = ($this->xss_clean) ? $CI->security->xss_clean($result) : $result; + $result = $CI->security->xss_clean($result); } return $result; @@ -1509,14 +1509,14 @@ class XML_RPC_Message extends CI_Xmlrpc /** * Output parameters * - * @param array + * @param array $array * @return array */ - public function output_parameters($array = FALSE) + public function output_parameters(array $array = array()) { $CI =& get_instance(); - if (is_array($array)) + if ( ! empty($array)) { while (list($key) = each($array)) { @@ -1524,11 +1524,11 @@ class XML_RPC_Message extends CI_Xmlrpc { $array[$key] = $this->output_parameters($array[$key]); } - else + elseif ($key !== 'bits' && $this->xss_clean) { // 'bits' is for the MetaWeblog API image bits // @todo - this needs to be made more general purpose - $array[$key] = ($key === 'bits' OR $this->xss_clean === FALSE) ? $array[$key] : $CI->security->xss_clean($array[$key]); + $array[$key] = $CI->security->xss_clean($array[$key]); } } -- cgit v1.2.3-24-g4f1b From 3d215207ceff44193e3c1888b868fc3f691718c0 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 15 Jan 2014 11:08:47 +0200 Subject: Fix incorrect checks for the fwrite() return value ! fwrite() could trigger false-positives as it is possible for it to return 0 instead of boolean FALSE. (issue #2822) Also removed an unnecessary log level check that caused an extra space to be inserted for the INFO level. (proposed in PR #2821) --- system/libraries/Xmlrpc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries/Xmlrpc.php') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index 2fd12599e..1f93e6981 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -724,7 +724,7 @@ class XML_RPC_Client extends CI_Xmlrpc .'Content-Length: '.strlen($msg->payload).$r.$r .$msg->payload; - if ( ! fwrite($fp, $op, strlen($op))) + if (fwrite($fp, $op, strlen($op)) === FALSE) { error_log($this->xmlrpcstr['http_error']); return new XML_RPC_Response(0, $this->xmlrpcerr['http_error'], $this->xmlrpcstr['http_error']); -- cgit v1.2.3-24-g4f1b From d8b1ad31cf7ee205ddf3cf396b1d1bfa45af49fa Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 15 Jan 2014 17:42:52 +0200 Subject: Fix #2822: Incorrect usage of fwrite() We only used to check (and not always) if the return value of fwrite() is boolean FALSE, while it is possible that the otherwise returned bytecount is less than the length of data that we're trying to write. This allowed incomplete writes over network streams and possibly a few other edge cases. --- system/libraries/Xmlrpc.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'system/libraries/Xmlrpc.php') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index 1f93e6981..ab907e706 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -724,7 +724,15 @@ class XML_RPC_Client extends CI_Xmlrpc .'Content-Length: '.strlen($msg->payload).$r.$r .$msg->payload; - if (fwrite($fp, $op, strlen($op)) === FALSE) + for ($written = 0, $length = strlen($op); $written < $length; $written += $result) + { + if (($result = fwrite($fp, substr($op, $written))) === FALSE) + { + break; + } + } + + if ($result === FALSE) { error_log($this->xmlrpcstr['http_error']); return new XML_RPC_Response(0, $this->xmlrpcerr['http_error'], $this->xmlrpcstr['http_error']); -- cgit v1.2.3-24-g4f1b From 3aecedbbb017567925f76ae68b726bd22b4cc80c Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 20 Jan 2014 10:39:08 +0200 Subject: Fix #2737 --- system/libraries/Xmlrpc.php | 48 +++++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 21 deletions(-) (limited to 'system/libraries/Xmlrpc.php') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index ab907e706..d0f6d83b3 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -1121,15 +1121,15 @@ class XML_RPC_Message extends CI_Xmlrpc //------------------------------------- $parser = xml_parser_create($this->xmlrpc_defencoding); - - $this->xh[$parser] = array( - 'isf' => 0, - 'ac' => '', - 'headers' => array(), - 'stack' => array(), - 'valuestack' => array(), - 'isf_reason' => 0 - ); + $pname = (string) $parser; + $this->xh[$pname] = array( + 'isf' => 0, + 'ac' => '', + 'headers' => array(), + 'stack' => array(), + 'valuestack' => array(), + 'isf_reason' => 0 + ); xml_set_object($parser, $this); xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, TRUE); @@ -1145,7 +1145,7 @@ class XML_RPC_Message extends CI_Xmlrpc { break; } - $this->xh[$parser]['headers'][] = $line; + $this->xh[$pname]['headers'][] = $line; } $data = implode("\r\n", $lines); @@ -1163,18 +1163,18 @@ class XML_RPC_Message extends CI_Xmlrpc xml_parser_free($parser); // Got ourselves some badness, it seems - if ($this->xh[$parser]['isf'] > 1) + if ($this->xh[$pname]['isf'] > 1) { if ($this->debug === TRUE) { - echo "---Invalid Return---\n".$this->xh[$parser]['isf_reason']."---Invalid Return---\n\n"; + echo "---Invalid Return---\n".$this->xh[$pname]['isf_reason']."---Invalid Return---\n\n"; } - return new XML_RPC_Response(0, $this->xmlrpcerr['invalid_return'], $this->xmlrpcstr['invalid_return'].' '.$this->xh[$parser]['isf_reason']); + return new XML_RPC_Response(0, $this->xmlrpcerr['invalid_return'], $this->xmlrpcstr['invalid_return'].' '.$this->xh[$pname]['isf_reason']); } - elseif ( ! is_object($this->xh[$parser]['value'])) + elseif ( ! is_object($this->xh[$pname]['value'])) { - return new XML_RPC_Response(0, $this->xmlrpcerr['invalid_return'], $this->xmlrpcstr['invalid_return'].' '.$this->xh[$parser]['isf_reason']); + return new XML_RPC_Response(0, $this->xmlrpcerr['invalid_return'], $this->xmlrpcstr['invalid_return'].' '.$this->xh[$pname]['isf_reason']); } // Display XML content for debugging @@ -1182,10 +1182,10 @@ class XML_RPC_Message extends CI_Xmlrpc { echo '
';
 
-			if (count($this->xh[$parser]['headers'] > 0))
+			if (count($this->xh[$pname]['headers'] > 0))
 			{
 				echo "---HEADERS---\n";
-				foreach ($this->xh[$parser]['headers'] as $header)
+				foreach ($this->xh[$pname]['headers'] as $header)
 				{
 					echo $header."\n";
 				}
@@ -1193,13 +1193,13 @@ class XML_RPC_Message extends CI_Xmlrpc
 			}
 
 			echo "---DATA---\n".htmlspecialchars($data)."\n---END DATA---\n\n---PARSED---\n";
-			var_dump($this->xh[$parser]['value']);
+			var_dump($this->xh[$pname]['value']);
 			echo "\n---END PARSED---
"; } // Send response - $v = $this->xh[$parser]['value']; - if ($this->xh[$parser]['isf']) + $v = $this->xh[$pname]['value']; + if ($this->xh[$pname]['isf']) { $errno_v = $v->me['struct']['faultCode']; $errstr_v = $v->me['struct']['faultString']; @@ -1218,7 +1218,7 @@ class XML_RPC_Message extends CI_Xmlrpc $r = new XML_RPC_Response($v); } - $r->headers = $this->xh[$parser]['headers']; + $r->headers = $this->xh[$pname]['headers']; return $r; } @@ -1249,6 +1249,8 @@ class XML_RPC_Message extends CI_Xmlrpc */ public function open_tag($the_parser, $name) { + $the_parser = (string) $the_parser; + // If invalid nesting, then return if ($this->xh[$the_parser]['isf'] > 1) return; @@ -1348,6 +1350,8 @@ class XML_RPC_Message extends CI_Xmlrpc */ public function closing_tag($the_parser, $name) { + $the_parser = (string) $the_parser; + if ($this->xh[$the_parser]['isf'] > 1) return; // Remove current element from stack and set variable @@ -1480,6 +1484,8 @@ class XML_RPC_Message extends CI_Xmlrpc */ public function character_data($the_parser, $data) { + $the_parser = (string) $the_parser; + if ($this->xh[$the_parser]['isf'] > 1) return; // XML Fault found already // If a value has not been found -- cgit v1.2.3-24-g4f1b From 871754af60251993d640981e107d2def5f2db396 Mon Sep 17 00:00:00 2001 From: darwinel Date: Tue, 11 Feb 2014 17:34:57 +0100 Subject: 2013 > 2014 Update copyright notices from 2013 to 2014. And update one calendar example in user_guide from year 2013/2014 to 2014/2015. --- system/libraries/Xmlrpc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries/Xmlrpc.php') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index d0f6d83b3..83dc00e45 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -18,7 +18,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2008 - 2013, EllisLab, Inc. (http://ellislab.com/) + * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/) * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com * @since Version 1.0 -- cgit v1.2.3-24-g4f1b From bdb96ca1b1dbfc1791172fd169d7751cbc4d7d55 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 28 Oct 2014 00:13:31 +0200 Subject: [ci skip] Switch to MIT license; close #3293 --- system/libraries/Xmlrpc.php | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) (limited to 'system/libraries/Xmlrpc.php') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index 83dc00e45..523e861bc 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -4,24 +4,35 @@ * * An open source application development framework for PHP 5.2.4 or newer * - * NOTICE OF LICENSE + * This content is released under the MIT License (MIT) * - * Licensed under the Open Software License version 3.0 + * Copyright (c) 2014, British Columbia Institute of Technology * - * This source file is subject to the Open Software License (OSL 3.0) that is - * bundled with this package in the files license.txt / license.rst. It is - * also available through the world wide web at this URL: - * http://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to obtain it - * through the world wide web, please send an email to - * licensing@ellislab.com so we can send you a copy immediately. + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * @package CodeIgniter - * @author EllisLab Dev Team + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * @package CodeIgniter + * @author EllisLab Dev Team * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/) - * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - * @link http://codeigniter.com - * @since Version 1.0 + * @copyright Copyright (c) 2014, British Columbia Institute of Technology (http://bcit.ca/) + * @license http://opensource.org/licenses/MIT MIT License + * @link http://codeigniter.com + * @since Version 1.0.0 * @filesource */ defined('BASEPATH') OR exit('No direct script access allowed'); -- cgit v1.2.3-24-g4f1b From fe9309d22c1b088f5363954d6dac013c8c955894 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 9 Jan 2015 17:48:58 +0200 Subject: Bulk (mostly documentation) update - Remove PHP version from license notices - Bump year number in copyright notices - Recommend PHP 5.4 or newer to be used - Tell Travis-CI to test on PHP 5.3.0 instead of the latest 5.3 version Related: #3450 --- system/libraries/Xmlrpc.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'system/libraries/Xmlrpc.php') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index 523e861bc..5ecebaf6d 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.2.4 or newer + * An open source application development framework for PHP * * This content is released under the MIT License (MIT) * - * Copyright (c) 2014, British Columbia Institute of Technology + * Copyright (c) 2014 - 2015, British Columbia Institute of Technology * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * @package CodeIgniter * @author EllisLab Dev Team * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/) - * @copyright Copyright (c) 2014, British Columbia Institute of Technology (http://bcit.ca/) + * @copyright Copyright (c) 2014 - 2015, British Columbia Institute of Technology (http://bcit.ca/) * @license http://opensource.org/licenses/MIT MIT License * @link http://codeigniter.com * @since Version 1.0.0 -- cgit v1.2.3-24-g4f1b From 90726b8c769ea75aec34814ddfa91655d488e6c3 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 20 Jan 2015 12:39:22 +0200 Subject: [ci skip] Change some log messages' level 'Class Loaded' type of messages flood log files when log_threshold is set to 2 (debug). They're now logged as 'info' level. This is manually applying PR #1528, which was created to do the same thing, but became outdated. --- system/libraries/Xmlrpc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries/Xmlrpc.php') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index 5ecebaf6d..9f5e20468 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -314,7 +314,7 @@ class CI_Xmlrpc { $this->initialize($config); - log_message('debug', 'XML-RPC Class Initialized'); + log_message('info', 'XML-RPC Class Initialized'); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 4cbe463b4c442e0e2dae2f43565e77f7ac5ecb86 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Wed, 21 Jan 2015 22:56:22 +0100 Subject: Remove closing blocks at end of PHP files --- system/libraries/Xmlrpc.php | 3 --- 1 file changed, 3 deletions(-) (limited to 'system/libraries/Xmlrpc.php') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index 9f5e20468..9d7cbffa2 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -1900,6 +1900,3 @@ class XML_RPC_Values extends CI_Xmlrpc } } // END XML_RPC_Values Class - -/* End of file Xmlrpc.php */ -/* Location: ./system/libraries/Xmlrpc.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From e8a2792de5ff21d0b89304da0b94e5ea24b94fa7 Mon Sep 17 00:00:00 2001 From: Gabriel Potkány Date: Wed, 4 Feb 2015 09:52:50 +0100 Subject: Add missing return type --- system/libraries/Xmlrpc.php | 1 + 1 file changed, 1 insertion(+) (limited to 'system/libraries/Xmlrpc.php') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index 9d7cbffa2..8fbc18f04 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -1792,6 +1792,7 @@ class XML_RPC_Values extends CI_Xmlrpc * * @param string * @param mixed + * @return string */ public function serializedata($typ, $val) { -- cgit v1.2.3-24-g4f1b From 4e0496e2d6d0bcf654235854d88f71b031e63cb0 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 22 Jun 2015 12:34:38 +0300 Subject: Work-around for https://bugs.php.net/bug.php?id=39598 Fixes #3922 --- system/libraries/Xmlrpc.php | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'system/libraries/Xmlrpc.php') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index 8fbc18f04..55555f56f 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -735,12 +735,32 @@ class XML_RPC_Client extends CI_Xmlrpc .'Content-Length: '.strlen($msg->payload).$r.$r .$msg->payload; - for ($written = 0, $length = strlen($op); $written < $length; $written += $result) + for ($written = $timestamp = 0, $length = strlen($op); $written < $length; $written += $result) { if (($result = fwrite($fp, substr($op, $written))) === FALSE) { break; } + // See https://bugs.php.net/bug.php?id=39598 and http://php.net/manual/en/function.fwrite.php#96951 + elseif ($result === 0) + { + if ($timestamp === 0) + { + $timestamp = time(); + } + elseif ($timestamp < (time() - $this->timeout)) + { + $result = FALSE; + break; + } + + usleep(250000); + continue; + } + else + { + $timestamp = 0; + } } if ($result === FALSE) -- cgit v1.2.3-24-g4f1b From 125ef4751080a2118cb203357d77687699e3eb25 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 11 Jan 2016 12:33:00 +0200 Subject: [ci skip] Bump year to 2016 --- system/libraries/Xmlrpc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/libraries/Xmlrpc.php') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index 55555f56f..cc1b65eb1 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -6,7 +6,7 @@ * * This content is released under the MIT License (MIT) * - * Copyright (c) 2014 - 2015, British Columbia Institute of Technology + * Copyright (c) 2014 - 2016, British Columbia Institute of Technology * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * @package CodeIgniter * @author EllisLab Dev Team * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/) - * @copyright Copyright (c) 2014 - 2015, British Columbia Institute of Technology (http://bcit.ca/) + * @copyright Copyright (c) 2014 - 2016, British Columbia Institute of Technology (http://bcit.ca/) * @license http://opensource.org/licenses/MIT MIT License * @link http://codeigniter.com * @since Version 1.0.0 -- cgit v1.2.3-24-g4f1b From bd202c91b0e9cf0a8c93bcaa71df9574f5909346 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 11 Jan 2016 12:50:18 +0200 Subject: [ci skip] Update codeigniter.com links to https --- system/libraries/Xmlrpc.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'system/libraries/Xmlrpc.php') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index cc1b65eb1..d4bcbd019 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -31,7 +31,7 @@ * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/) * @copyright Copyright (c) 2014 - 2016, British Columbia Institute of Technology (http://bcit.ca/) * @license http://opensource.org/licenses/MIT MIT License - * @link http://codeigniter.com + * @link https://codeigniter.com * @since Version 1.0.0 * @filesource */ @@ -51,7 +51,7 @@ if ( ! function_exists('xml_parser_create')) * @subpackage Libraries * @category XML-RPC * @author EllisLab Dev Team - * @link http://codeigniter.com/user_guide/libraries/xmlrpc.html + * @link https://codeigniter.com/user_guide/libraries/xmlrpc.html */ class CI_Xmlrpc { @@ -559,7 +559,7 @@ class CI_Xmlrpc { * * @category XML-RPC * @author EllisLab Dev Team - * @link http://codeigniter.com/user_guide/libraries/xmlrpc.html + * @link https://codeigniter.com/user_guide/libraries/xmlrpc.html */ class XML_RPC_Client extends CI_Xmlrpc { @@ -781,7 +781,7 @@ class XML_RPC_Client extends CI_Xmlrpc * * @category XML-RPC * @author EllisLab Dev Team - * @link http://codeigniter.com/user_guide/libraries/xmlrpc.html + * @link https://codeigniter.com/user_guide/libraries/xmlrpc.html */ class XML_RPC_Response { @@ -1030,7 +1030,7 @@ class XML_RPC_Response * * @category XML-RPC * @author EllisLab Dev Team - * @link http://codeigniter.com/user_guide/libraries/xmlrpc.html + * @link https://codeigniter.com/user_guide/libraries/xmlrpc.html */ class XML_RPC_Message extends CI_Xmlrpc { @@ -1649,7 +1649,7 @@ class XML_RPC_Message extends CI_Xmlrpc * * @category XML-RPC * @author EllisLab Dev Team - * @link http://codeigniter.com/user_guide/libraries/xmlrpc.html + * @link https://codeigniter.com/user_guide/libraries/xmlrpc.html */ class XML_RPC_Values extends CI_Xmlrpc { -- cgit v1.2.3-24-g4f1b From 1924e879b165fb119847a49a7a5eab2f28295fa2 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 11 Jan 2016 12:55:34 +0200 Subject: [ci skip] Update ellislab.com links to https too --- system/libraries/Xmlrpc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries/Xmlrpc.php') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index d4bcbd019..f965858e2 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -28,7 +28,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/) + * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/) * @copyright Copyright (c) 2014 - 2016, British Columbia Institute of Technology (http://bcit.ca/) * @license http://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com -- cgit v1.2.3-24-g4f1b From e33c82d62e5a56b2fe46096420de838eb74553e8 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 10 Aug 2016 15:18:31 +0300 Subject: Merge pull request #4758 from butane/uri_scheme_case URI schemes are not case-sensitive --- system/libraries/Xmlrpc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries/Xmlrpc.php') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index f965858e2..181a104d0 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -352,7 +352,7 @@ class CI_Xmlrpc { */ public function server($url, $port = 80, $proxy = FALSE, $proxy_port = 8080) { - if (strpos($url, 'http') !== 0) + if (stripos($url, 'http') !== 0) { $url = 'http://'.$url; } -- cgit v1.2.3-24-g4f1b From a09ffbc3bc91acd60735c6f1289b97125dae5ed6 Mon Sep 17 00:00:00 2001 From: "Instructor, Computer Systems Technology" Date: Tue, 18 Oct 2016 15:28:05 -0700 Subject: Merge pull request #4855 from jim-parry/fix/xmlrpc-timeout Fix xmlrpc timeout, #4843 --- system/libraries/Xmlrpc.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'system/libraries/Xmlrpc.php') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index 181a104d0..4be926f0e 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -734,6 +734,8 @@ class XML_RPC_Client extends CI_Xmlrpc .'User-Agent: '.$this->xmlrpcName.$r .'Content-Length: '.strlen($msg->payload).$r.$r .$msg->payload; + + stream_set_timeout($fp,$this->timeout); // set timeout for subsequent operations for ($written = $timestamp = 0, $length = strlen($op); $written < $length; $written += $result) { @@ -753,9 +755,6 @@ class XML_RPC_Client extends CI_Xmlrpc $result = FALSE; break; } - - usleep(250000); - continue; } else { -- cgit v1.2.3-24-g4f1b From dc44b922dfda28d72879f6e5d2ef509e8bb51275 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 20 Oct 2016 11:56:20 +0300 Subject: [ci skip] Polish changes and add a changelog entry for PR #4855 --- system/libraries/Xmlrpc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/libraries/Xmlrpc.php') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index 4be926f0e..7186646da 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -734,8 +734,8 @@ class XML_RPC_Client extends CI_Xmlrpc .'User-Agent: '.$this->xmlrpcName.$r .'Content-Length: '.strlen($msg->payload).$r.$r .$msg->payload; - - stream_set_timeout($fp,$this->timeout); // set timeout for subsequent operations + + stream_set_timeout($fp, $this->timeout); // set timeout for subsequent operations for ($written = $timestamp = 0, $length = strlen($op); $written < $length; $written += $result) { -- cgit v1.2.3-24-g4f1b From da60e9bc66ec90970fbd2dfd08b0a6e66b9f5f5f Mon Sep 17 00:00:00 2001 From: Master Yoda Date: Sat, 31 Dec 2016 08:46:18 -0800 Subject: Update copyright data to 2017 --- system/libraries/Xmlrpc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/libraries/Xmlrpc.php') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index 7186646da..f043e0f90 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -6,7 +6,7 @@ * * This content is released under the MIT License (MIT) * - * Copyright (c) 2014 - 2016, British Columbia Institute of Technology + * Copyright (c) 2014 - 2017, British Columbia Institute of Technology * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * @package CodeIgniter * @author EllisLab Dev Team * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/) - * @copyright Copyright (c) 2014 - 2016, British Columbia Institute of Technology (http://bcit.ca/) + * @copyright Copyright (c) 2014 - 2017, British Columbia Institute of Technology (http://bcit.ca/) * @license http://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 1.0.0 -- cgit v1.2.3-24-g4f1b From 71d8f72ffc48a7f46747b3b6b1a554533cc1cbc5 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 17 Jan 2017 12:01:00 +0200 Subject: [ci skip] Merge pull request #4986 from ka7/feature/spelling Spelling fixes in comment blocks and docs --- system/libraries/Xmlrpc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries/Xmlrpc.php') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index f043e0f90..fc5abe5c4 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -238,7 +238,7 @@ class CI_Xmlrpc { public $result; /** - * XML-RPC Reponse + * XML-RPC Response * * @var array */ -- cgit v1.2.3-24-g4f1b From 4316a157c27a3721dbfd8a817bf8cbffb1fe371f Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 20 Jan 2017 15:46:17 +0200 Subject: Don't use each() Will be deprecated in PHP 7.2 --- system/libraries/Xmlrpc.php | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) (limited to 'system/libraries/Xmlrpc.php') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index fc5abe5c4..c766a89c8 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -460,7 +460,7 @@ class CI_Xmlrpc { { if (is_array($value[0]) && ($value[1] === 'struct' OR $value[1] === 'array')) { - while (list($k) = each($value[0])) + foreach (array_keys($value[0]) as $k) { $value[0][$k] = $this->values_parsing($value[0][$k]); } @@ -931,15 +931,15 @@ class XML_RPC_Response if (is_array($array)) { - while (list($key) = each($array)) + foreach ($array as $key => &$value) { - if (is_array($array[$key])) + if (is_array($value)) { - $array[$key] = $this->decode($array[$key]); + $array[$key] = $this->decode($value); } elseif ($this->xss_clean) { - $array[$key] = $CI->security->xss_clean($array[$key]); + $array[$key] = $CI->security->xss_clean($value); } } @@ -993,10 +993,11 @@ class XML_RPC_Response reset($xmlrpc_val->me['struct']); $arr = array(); - while (list($key,$value) = each($xmlrpc_val->me['struct'])) + foreach ($xmlrpc_val->me['struct'] as $key => &$value) { $arr[$key] = $this->xmlrpc_decoder($value); } + return $arr; } } @@ -1562,17 +1563,17 @@ class XML_RPC_Message extends CI_Xmlrpc if ( ! empty($array)) { - while (list($key) = each($array)) + foreach ($array as $key => &$value) { - if (is_array($array[$key])) + if (is_array($value)) { - $array[$key] = $this->output_parameters($array[$key]); + $array[$key] = $this->output_parameters($value); } elseif ($key !== 'bits' && $this->xss_clean) { // 'bits' is for the MetaWeblog API image bits // @todo - this needs to be made more general purpose - $array[$key] = $CI->security->xss_clean($array[$key]); + $array[$key] = $CI->security->xss_clean($value); } } @@ -1632,7 +1633,7 @@ class XML_RPC_Message extends CI_Xmlrpc reset($param->me['struct']); $arr = array(); - while (list($key,$value) = each($param->me['struct'])) + foreach ($param->me['struct'] as $key => &$value) { $arr[$key] = $this->decode_message($value); } @@ -1823,7 +1824,7 @@ class XML_RPC_Values extends CI_Xmlrpc // struct $rs .= "\n"; reset($val); - while (list($key2, $val2) = each($val)) + foreach ($val as $key2 => &$val2) { $rs .= "\n{$key2}\n".$this->serializeval($val2)."\n"; } @@ -1884,11 +1885,9 @@ class XML_RPC_Values extends CI_Xmlrpc */ public function serializeval($o) { - $ar = $o->me; - reset($ar); - - list($typ, $val) = each($ar); - return "\n".$this->serializedata($typ, $val)."\n"; + $array = $o->me; + list($value, $type) = array(reset($ar), key($array)); + return "\n".$this->serializedata($type, $value)."\n"; } // -------------------------------------------------------------------- @@ -1900,8 +1899,7 @@ class XML_RPC_Values extends CI_Xmlrpc */ public function scalarval() { - reset($this->me); - return current($this->me); + return reset($this->me); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 11d59d7097ce35ab3b9845de2e021f9db1e25863 Mon Sep 17 00:00:00 2001 From: "Instructor, Computer Systems Technology" Date: Sat, 15 Apr 2017 13:35:10 -0700 Subject: Merge pull request #5085 from jim-parry/fix/xmlrpc Fix typo in serializeval() --- system/libraries/Xmlrpc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries/Xmlrpc.php') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index c766a89c8..6fa791864 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -1886,7 +1886,7 @@ class XML_RPC_Values extends CI_Xmlrpc public function serializeval($o) { $array = $o->me; - list($value, $type) = array(reset($ar), key($array)); + list($value, $type) = array(reset($array), key($array)); return "\n".$this->serializedata($type, $value)."\n"; } -- cgit v1.2.3-24-g4f1b