Andrey Andreev | 56e3214 | 2011-12-25 18:36:31 +0200 | [diff] [blame] | 1 | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 2 | /** |
| 3 | * CodeIgniter |
| 4 | * |
Greg Aker | 741de1c | 2010-11-10 14:52:57 -0600 | [diff] [blame] | 5 | * An open source application development framework for PHP 5.1.6 or newer |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 6 | * |
Derek Jones | f4a4bd8 | 2011-10-20 12:18:42 -0500 | [diff] [blame] | 7 | * NOTICE OF LICENSE |
Andrey Andreev | 56e3214 | 2011-12-25 18:36:31 +0200 | [diff] [blame] | 8 | * |
Derek Jones | f4a4bd8 | 2011-10-20 12:18:42 -0500 | [diff] [blame] | 9 | * Licensed under the Open Software License version 3.0 |
Andrey Andreev | 56e3214 | 2011-12-25 18:36:31 +0200 | [diff] [blame] | 10 | * |
Derek Jones | f4a4bd8 | 2011-10-20 12:18:42 -0500 | [diff] [blame] | 11 | * This source file is subject to the Open Software License (OSL 3.0) that is |
| 12 | * bundled with this package in the files license.txt / license.rst. It is |
| 13 | * also available through the world wide web at this URL: |
| 14 | * http://opensource.org/licenses/OSL-3.0 |
| 15 | * If you did not receive a copy of the license and are unable to obtain it |
| 16 | * through the world wide web, please send an email to |
| 17 | * licensing@ellislab.com so we can send you a copy immediately. |
| 18 | * |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 19 | * @package CodeIgniter |
Derek Jones | f4a4bd8 | 2011-10-20 12:18:42 -0500 | [diff] [blame] | 20 | * @author EllisLab Dev Team |
Greg Aker | 0defe5d | 2012-01-01 18:46:41 -0600 | [diff] [blame] | 21 | * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/) |
Derek Jones | f4a4bd8 | 2011-10-20 12:18:42 -0500 | [diff] [blame] | 22 | * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 23 | * @link http://codeigniter.com |
| 24 | * @since Version 1.0 |
| 25 | * @filesource |
| 26 | */ |
| 27 | |
| 28 | if ( ! function_exists('xml_parser_create')) |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 29 | { |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 30 | show_error('Your PHP installation does not support XML'); |
| 31 | } |
| 32 | |
| 33 | if ( ! class_exists('CI_Xmlrpc')) |
| 34 | { |
| 35 | show_error('You must load the Xmlrpc class before loading the Xmlrpcs class in order to create a server.'); |
| 36 | } |
| 37 | |
| 38 | // ------------------------------------------------------------------------ |
| 39 | |
| 40 | /** |
| 41 | * XML-RPC server class |
| 42 | * |
| 43 | * @package CodeIgniter |
| 44 | * @subpackage Libraries |
| 45 | * @category XML-RPC |
Derek Jones | f4a4bd8 | 2011-10-20 12:18:42 -0500 | [diff] [blame] | 46 | * @author EllisLab Dev Team |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 47 | * @link http://codeigniter.com/user_guide/libraries/xmlrpc.html |
| 48 | */ |
| 49 | class CI_Xmlrpcs extends CI_Xmlrpc |
| 50 | { |
Andrey Andreev | 56e3214 | 2011-12-25 18:36:31 +0200 | [diff] [blame] | 51 | public $methods = array(); //array of methods mapped to function names and signatures |
| 52 | public $debug_msg = ''; // Debug Message |
| 53 | public $system_methods = array(); // XML RPC Server methods |
| 54 | public $controller_obj; |
| 55 | public $object = FALSE; |
Derek Jones | c4c34ee | 2010-03-02 23:00:28 -0600 | [diff] [blame] | 56 | |
Greg Aker | a926328 | 2010-11-10 15:26:43 -0600 | [diff] [blame] | 57 | /** |
| 58 | * Constructor |
| 59 | */ |
| 60 | public function __construct($config=array()) |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 61 | { |
Greg Aker | a926328 | 2010-11-10 15:26:43 -0600 | [diff] [blame] | 62 | parent::__construct(); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 63 | $this->set_system_methods(); |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 64 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 65 | if (isset($config['functions']) && is_array($config['functions'])) |
| 66 | { |
| 67 | $this->methods = array_merge($this->methods, $config['functions']); |
| 68 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 69 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 70 | log_message('debug', "XML-RPC Server Class Initialized"); |
| 71 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 72 | |
Pascal Kriete | 68d2987 | 2011-02-14 13:39:06 -0500 | [diff] [blame] | 73 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 74 | |
Pascal Kriete | 68d2987 | 2011-02-14 13:39:06 -0500 | [diff] [blame] | 75 | /** |
| 76 | * Initialize Prefs and Serve |
| 77 | * |
| 78 | * @access public |
| 79 | * @param mixed |
| 80 | * @return void |
| 81 | */ |
Andrey Andreev | 56e3214 | 2011-12-25 18:36:31 +0200 | [diff] [blame] | 82 | public function initialize($config = array()) |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 83 | { |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 84 | if (isset($config['functions']) && is_array($config['functions'])) |
| 85 | { |
| 86 | $this->methods = array_merge($this->methods, $config['functions']); |
| 87 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 88 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 89 | if (isset($config['debug'])) |
| 90 | { |
| 91 | $this->debug = $config['debug']; |
| 92 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 93 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 94 | if (isset($config['object']) && is_object($config['object'])) |
| 95 | { |
| 96 | $this->object = $config['object']; |
| 97 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 98 | |
Robin Sowell | 66a3fc0 | 2010-03-18 09:44:55 -0400 | [diff] [blame] | 99 | if (isset($config['xss_clean'])) |
| 100 | { |
| 101 | $this->xss_clean = $config['xss_clean']; |
| 102 | } |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 103 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 104 | |
Pascal Kriete | 68d2987 | 2011-02-14 13:39:06 -0500 | [diff] [blame] | 105 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 106 | |
Pascal Kriete | 68d2987 | 2011-02-14 13:39:06 -0500 | [diff] [blame] | 107 | /** |
| 108 | * Setting of System Methods |
| 109 | * |
| 110 | * @access public |
| 111 | * @return void |
| 112 | */ |
Andrey Andreev | 56e3214 | 2011-12-25 18:36:31 +0200 | [diff] [blame] | 113 | public function set_system_methods() |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 114 | { |
| 115 | $this->methods = array( |
| 116 | 'system.listMethods' => array( |
Andrey Andreev | 56e3214 | 2011-12-25 18:36:31 +0200 | [diff] [blame] | 117 | 'function' => 'this.listMethods', |
| 118 | 'signature' => array(array($this->xmlrpcArray, $this->xmlrpcString), array($this->xmlrpcArray)), |
| 119 | 'docstring' => 'Returns an array of available methods on this server'), |
| 120 | 'system.methodHelp' => array( |
| 121 | 'function' => 'this.methodHelp', |
| 122 | 'signature' => array(array($this->xmlrpcString, $this->xmlrpcString)), |
| 123 | 'docstring' => 'Returns a documentation string for the specified method'), |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 124 | 'system.methodSignature' => array( |
Andrey Andreev | 56e3214 | 2011-12-25 18:36:31 +0200 | [diff] [blame] | 125 | 'function' => 'this.methodSignature', |
| 126 | 'signature' => array(array($this->xmlrpcArray, $this->xmlrpcString)), |
| 127 | 'docstring' => 'Returns an array describing the return type and required parameters of a method'), |
| 128 | 'system.multicall' => array( |
| 129 | 'function' => 'this.multicall', |
| 130 | 'signature' => array(array($this->xmlrpcArray, $this->xmlrpcArray)), |
| 131 | 'docstring' => 'Combine multiple RPC calls in one request. See http://www.xmlrpc.com/discuss/msgReader$1208 for details') |
| 132 | ); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 133 | } |
| 134 | |
Pascal Kriete | 68d2987 | 2011-02-14 13:39:06 -0500 | [diff] [blame] | 135 | // -------------------------------------------------------------------- |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 136 | |
Pascal Kriete | 68d2987 | 2011-02-14 13:39:06 -0500 | [diff] [blame] | 137 | /** |
| 138 | * Main Server Function |
| 139 | * |
| 140 | * @access public |
| 141 | * @return void |
| 142 | */ |
Andrey Andreev | 56e3214 | 2011-12-25 18:36:31 +0200 | [diff] [blame] | 143 | public function serve() |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 144 | { |
| 145 | $r = $this->parseRequest(); |
Andrey Andreev | 56e3214 | 2011-12-25 18:36:31 +0200 | [diff] [blame] | 146 | $payload = '<?xml version="1.0" encoding="'.$this->xmlrpc_defencoding.'"?'.'>'."\n".$this->debug_msg.$r->prepare_response(); |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 147 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 148 | header("Content-Type: text/xml"); |
| 149 | header("Content-Length: ".strlen($payload)); |
Derek Jones | b8d3c3d | 2009-06-24 15:27:01 +0000 | [diff] [blame] | 150 | exit($payload); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 151 | } |
| 152 | |
Pascal Kriete | 68d2987 | 2011-02-14 13:39:06 -0500 | [diff] [blame] | 153 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 154 | |
Pascal Kriete | 68d2987 | 2011-02-14 13:39:06 -0500 | [diff] [blame] | 155 | /** |
| 156 | * Add Method to Class |
| 157 | * |
| 158 | * @access public |
| 159 | * @param string method name |
| 160 | * @param string function |
| 161 | * @param string signature |
| 162 | * @param string docstring |
| 163 | * @return void |
| 164 | */ |
Andrey Andreev | 56e3214 | 2011-12-25 18:36:31 +0200 | [diff] [blame] | 165 | public function add_to_map($methodname, $function, $sig, $doc) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 166 | { |
| 167 | $this->methods[$methodname] = array( |
Derek Jones | 37f4b9c | 2011-07-01 17:56:50 -0500 | [diff] [blame] | 168 | 'function' => $function, |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 169 | 'signature' => $sig, |
| 170 | 'docstring' => $doc |
| 171 | ); |
| 172 | } |
| 173 | |
Pascal Kriete | 68d2987 | 2011-02-14 13:39:06 -0500 | [diff] [blame] | 174 | // -------------------------------------------------------------------- |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 175 | |
Pascal Kriete | 68d2987 | 2011-02-14 13:39:06 -0500 | [diff] [blame] | 176 | /** |
| 177 | * Parse Server Request |
| 178 | * |
| 179 | * @access public |
| 180 | * @param string data |
| 181 | * @return object xmlrpc response |
| 182 | */ |
Andrey Andreev | 56e3214 | 2011-12-25 18:36:31 +0200 | [diff] [blame] | 183 | public function parseRequest($data = '') |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 184 | { |
| 185 | global $HTTP_RAW_POST_DATA; |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 186 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 187 | //------------------------------------- |
Derek Jones | 37f4b9c | 2011-07-01 17:56:50 -0500 | [diff] [blame] | 188 | // Get Data |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 189 | //------------------------------------- |
| 190 | |
| 191 | if ($data == '') |
| 192 | { |
| 193 | $data = $HTTP_RAW_POST_DATA; |
| 194 | } |
| 195 | |
| 196 | //------------------------------------- |
Derek Jones | 37f4b9c | 2011-07-01 17:56:50 -0500 | [diff] [blame] | 197 | // Set up XML Parser |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 198 | //------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 199 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 200 | $parser = xml_parser_create($this->xmlrpc_defencoding); |
| 201 | $parser_object = new XML_RPC_Message("filler"); |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 202 | |
Andrey Andreev | 56e3214 | 2011-12-25 18:36:31 +0200 | [diff] [blame] | 203 | $parser_object->xh[$parser] = array( |
| 204 | 'isf' => 0, |
| 205 | 'isf_reason' => '', |
| 206 | 'params' => array(), |
| 207 | 'stack' => array(), |
| 208 | 'valuestack' => array(), |
| 209 | 'method' => '' |
| 210 | ); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 211 | |
| 212 | xml_set_object($parser, $parser_object); |
| 213 | xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true); |
| 214 | xml_set_element_handler($parser, 'open_tag', 'closing_tag'); |
| 215 | xml_set_character_data_handler($parser, 'character_data'); |
| 216 | //xml_set_default_handler($parser, 'default_handler'); |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 217 | |
| 218 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 219 | //------------------------------------- |
Derek Jones | 37f4b9c | 2011-07-01 17:56:50 -0500 | [diff] [blame] | 220 | // PARSE + PROCESS XML DATA |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 221 | //------------------------------------- |
| 222 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 223 | if ( ! xml_parse($parser, $data, 1)) |
| 224 | { |
| 225 | // return XML error as a faultCode |
| 226 | $r = new XML_RPC_Response(0, |
| 227 | $this->xmlrpcerrxml + xml_get_error_code($parser), |
| 228 | sprintf('XML error: %s at line %d', |
| 229 | xml_error_string(xml_get_error_code($parser)), |
| 230 | xml_get_current_line_number($parser))); |
| 231 | xml_parser_free($parser); |
| 232 | } |
Pascal Kriete | 68d2987 | 2011-02-14 13:39:06 -0500 | [diff] [blame] | 233 | elseif ($parser_object->xh[$parser]['isf']) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 234 | { |
| 235 | return new XML_RPC_Response(0, $this->xmlrpcerr['invalid_return'], $this->xmlrpcstr['invalid_return']); |
| 236 | } |
| 237 | else |
| 238 | { |
| 239 | xml_parser_free($parser); |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 240 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 241 | $m = new XML_RPC_Message($parser_object->xh[$parser]['method']); |
| 242 | $plist=''; |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 243 | |
Andrey Andreev | 56e3214 | 2011-12-25 18:36:31 +0200 | [diff] [blame] | 244 | for ($i = 0, $c = count($parser_object->xh[$parser]['params']); $i < $c; $i++) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 245 | { |
| 246 | if ($this->debug === TRUE) |
| 247 | { |
Derek Jones | 37f4b9c | 2011-07-01 17:56:50 -0500 | [diff] [blame] | 248 | $plist .= "$i - " . print_r(get_object_vars($parser_object->xh[$parser]['params'][$i]), TRUE). ";\n"; |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 249 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 250 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 251 | $m->addParam($parser_object->xh[$parser]['params'][$i]); |
| 252 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 253 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 254 | if ($this->debug === TRUE) |
| 255 | { |
Andrey Andreev | 56e3214 | 2011-12-25 18:36:31 +0200 | [diff] [blame] | 256 | echo "<pre>---PLIST---\n".$plist."\n---PLIST END---\n\n</pre>"; |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 257 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 258 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 259 | $r = $this->_execute($m); |
| 260 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 261 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 262 | //------------------------------------- |
Derek Jones | 37f4b9c | 2011-07-01 17:56:50 -0500 | [diff] [blame] | 263 | // SET DEBUGGING MESSAGE |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 264 | //------------------------------------- |
| 265 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 266 | if ($this->debug === TRUE) |
| 267 | { |
| 268 | $this->debug_msg = "<!-- DEBUG INFO:\n\n".$plist."\n END DEBUG-->\n"; |
| 269 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 270 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 271 | return $r; |
| 272 | } |
| 273 | |
Pascal Kriete | 68d2987 | 2011-02-14 13:39:06 -0500 | [diff] [blame] | 274 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 275 | |
Pascal Kriete | 68d2987 | 2011-02-14 13:39:06 -0500 | [diff] [blame] | 276 | /** |
| 277 | * Executes the Method |
| 278 | * |
| 279 | * @access protected |
| 280 | * @param object |
| 281 | * @return mixed |
| 282 | */ |
Andrey Andreev | 56e3214 | 2011-12-25 18:36:31 +0200 | [diff] [blame] | 283 | protected function _execute($m) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 284 | { |
| 285 | $methName = $m->method_name; |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 286 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 287 | // Check to see if it is a system call |
Andrey Andreev | 56e3214 | 2011-12-25 18:36:31 +0200 | [diff] [blame] | 288 | $system_call = (strncmp($methName, 'system', 5) === 0); |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 289 | |
Robin Sowell | 66a3fc0 | 2010-03-18 09:44:55 -0400 | [diff] [blame] | 290 | if ($this->xss_clean == FALSE) |
| 291 | { |
| 292 | $m->xss_clean = FALSE; |
| 293 | } |
| 294 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 295 | //------------------------------------- |
Derek Jones | 37f4b9c | 2011-07-01 17:56:50 -0500 | [diff] [blame] | 296 | // Valid Method |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 297 | //------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 298 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 299 | if ( ! isset($this->methods[$methName]['function'])) |
| 300 | { |
| 301 | return new XML_RPC_Response(0, $this->xmlrpcerr['unknown_method'], $this->xmlrpcstr['unknown_method']); |
| 302 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 303 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 304 | //------------------------------------- |
Derek Jones | 37f4b9c | 2011-07-01 17:56:50 -0500 | [diff] [blame] | 305 | // Check for Method (and Object) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 306 | //------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 307 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 308 | $method_parts = explode(".", $this->methods[$methName]['function']); |
Andrey Andreev | 56e3214 | 2011-12-25 18:36:31 +0200 | [diff] [blame] | 309 | $objectCall = (isset($method_parts[1]) && $method_parts[1] != ''); |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 310 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 311 | if ($system_call === TRUE) |
| 312 | { |
Andrey Andreev | 56e3214 | 2011-12-25 18:36:31 +0200 | [diff] [blame] | 313 | if ( ! is_callable(array($this,$method_parts[1]))) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 314 | { |
| 315 | return new XML_RPC_Response(0, $this->xmlrpcerr['unknown_method'], $this->xmlrpcstr['unknown_method']); |
| 316 | } |
| 317 | } |
| 318 | else |
| 319 | { |
Andrey Andreev | 56e3214 | 2011-12-25 18:36:31 +0200 | [diff] [blame] | 320 | if (($objectCall AND ! is_callable(array($method_parts[0], $method_parts[1]))) |
| 321 | OR ( ! $objectCall AND ! is_callable($this->methods[$methName]['function'])) |
| 322 | ) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 323 | { |
| 324 | return new XML_RPC_Response(0, $this->xmlrpcerr['unknown_method'], $this->xmlrpcstr['unknown_method']); |
| 325 | } |
| 326 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 327 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 328 | //------------------------------------- |
Derek Jones | 37f4b9c | 2011-07-01 17:56:50 -0500 | [diff] [blame] | 329 | // Checking Methods Signature |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 330 | //------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 331 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 332 | if (isset($this->methods[$methName]['signature'])) |
| 333 | { |
| 334 | $sig = $this->methods[$methName]['signature']; |
Andrey Andreev | 56e3214 | 2011-12-25 18:36:31 +0200 | [diff] [blame] | 335 | for ($i = 0, $c = count($sig); $i < $c; $i++) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 336 | { |
| 337 | $current_sig = $sig[$i]; |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 338 | |
Andrey Andreev | 56e3214 | 2011-12-25 18:36:31 +0200 | [diff] [blame] | 339 | if (count($current_sig) === count($m->params)+1) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 340 | { |
Andrey Andreev | 56e3214 | 2011-12-25 18:36:31 +0200 | [diff] [blame] | 341 | for ($n = 0, $mc = count($m->params); $n < $mc; $n++) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 342 | { |
| 343 | $p = $m->params[$n]; |
| 344 | $pt = ($p->kindOf() == 'scalar') ? $p->scalarval() : $p->kindOf(); |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 345 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 346 | if ($pt != $current_sig[$n+1]) |
| 347 | { |
| 348 | $pno = $n+1; |
| 349 | $wanted = $current_sig[$n+1]; |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 350 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 351 | return new XML_RPC_Response(0, |
| 352 | $this->xmlrpcerr['incorrect_params'], |
| 353 | $this->xmlrpcstr['incorrect_params'] . |
| 354 | ": Wanted {$wanted}, got {$pt} at param {$pno})"); |
| 355 | } |
| 356 | } |
| 357 | } |
| 358 | } |
| 359 | } |
| 360 | |
| 361 | //------------------------------------- |
Derek Jones | 37f4b9c | 2011-07-01 17:56:50 -0500 | [diff] [blame] | 362 | // Calls the Function |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 363 | //------------------------------------- |
| 364 | |
| 365 | if ($objectCall === TRUE) |
| 366 | { |
Andrey Andreev | 56e3214 | 2011-12-25 18:36:31 +0200 | [diff] [blame] | 367 | if ($method_parts[0] === 'this' && $system_call === TRUE) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 368 | { |
| 369 | return call_user_func(array($this, $method_parts[1]), $m); |
| 370 | } |
| 371 | else |
| 372 | { |
| 373 | if ($this->object === FALSE) |
| 374 | { |
| 375 | $CI =& get_instance(); |
Andrey Andreev | 56e3214 | 2011-12-25 18:36:31 +0200 | [diff] [blame] | 376 | return $CI->$method_parts[1]($m); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 377 | } |
| 378 | else |
| 379 | { |
Andrey Andreev | 56e3214 | 2011-12-25 18:36:31 +0200 | [diff] [blame] | 380 | return $this->object->$method_parts[1]($m); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 381 | //return call_user_func(array(&$method_parts['0'],$method_parts['1']), $m); |
| 382 | } |
| 383 | } |
| 384 | } |
| 385 | else |
| 386 | { |
| 387 | return call_user_func($this->methods[$methName]['function'], $m); |
| 388 | } |
| 389 | } |
Andrey Andreev | 56e3214 | 2011-12-25 18:36:31 +0200 | [diff] [blame] | 390 | |
Pascal Kriete | 68d2987 | 2011-02-14 13:39:06 -0500 | [diff] [blame] | 391 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 392 | |
Pascal Kriete | 68d2987 | 2011-02-14 13:39:06 -0500 | [diff] [blame] | 393 | /** |
Derek Jones | 37f4b9c | 2011-07-01 17:56:50 -0500 | [diff] [blame] | 394 | * Server Function: List Methods |
Pascal Kriete | 68d2987 | 2011-02-14 13:39:06 -0500 | [diff] [blame] | 395 | * |
| 396 | * @access public |
| 397 | * @param mixed |
| 398 | * @return object |
| 399 | */ |
Andrey Andreev | 56e3214 | 2011-12-25 18:36:31 +0200 | [diff] [blame] | 400 | public function listMethods($m) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 401 | { |
| 402 | $v = new XML_RPC_Values(); |
| 403 | $output = array(); |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 404 | |
Pascal Kriete | 68d2987 | 2011-02-14 13:39:06 -0500 | [diff] [blame] | 405 | foreach ($this->methods as $key => $value) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 406 | { |
| 407 | $output[] = new XML_RPC_Values($key, 'string'); |
| 408 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 409 | |
Pascal Kriete | 68d2987 | 2011-02-14 13:39:06 -0500 | [diff] [blame] | 410 | foreach ($this->system_methods as $key => $value) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 411 | { |
| 412 | $output[]= new XML_RPC_Values($key, 'string'); |
| 413 | } |
| 414 | |
| 415 | $v->addArray($output); |
| 416 | return new XML_RPC_Response($v); |
| 417 | } |
Andrey Andreev | 56e3214 | 2011-12-25 18:36:31 +0200 | [diff] [blame] | 418 | |
Pascal Kriete | 68d2987 | 2011-02-14 13:39:06 -0500 | [diff] [blame] | 419 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 420 | |
Pascal Kriete | 68d2987 | 2011-02-14 13:39:06 -0500 | [diff] [blame] | 421 | /** |
Derek Jones | 37f4b9c | 2011-07-01 17:56:50 -0500 | [diff] [blame] | 422 | * Server Function: Return Signature for Method |
Pascal Kriete | 68d2987 | 2011-02-14 13:39:06 -0500 | [diff] [blame] | 423 | * |
| 424 | * @access public |
| 425 | * @param mixed |
| 426 | * @return object |
| 427 | */ |
Andrey Andreev | 56e3214 | 2011-12-25 18:36:31 +0200 | [diff] [blame] | 428 | public function methodSignature($m) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 429 | { |
| 430 | $parameters = $m->output_parameters(); |
| 431 | $method_name = $parameters[0]; |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 432 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 433 | if (isset($this->methods[$method_name])) |
| 434 | { |
| 435 | if ($this->methods[$method_name]['signature']) |
| 436 | { |
| 437 | $sigs = array(); |
| 438 | $signature = $this->methods[$method_name]['signature']; |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 439 | |
Andrey Andreev | 56e3214 | 2011-12-25 18:36:31 +0200 | [diff] [blame] | 440 | for ($i = 0, $c = count($signature); $i < $c; $i++) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 441 | { |
| 442 | $cursig = array(); |
| 443 | $inSig = $signature[$i]; |
Andrey Andreev | 56e3214 | 2011-12-25 18:36:31 +0200 | [diff] [blame] | 444 | for ($j = 0, $jc = count($inSig); $j < $jc; $j++) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 445 | { |
| 446 | $cursig[]= new XML_RPC_Values($inSig[$j], 'string'); |
| 447 | } |
Andrey Andreev | 56e3214 | 2011-12-25 18:36:31 +0200 | [diff] [blame] | 448 | $sigs[] = new XML_RPC_Values($cursig, 'array'); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 449 | } |
| 450 | $r = new XML_RPC_Response(new XML_RPC_Values($sigs, 'array')); |
| 451 | } |
| 452 | else |
| 453 | { |
| 454 | $r = new XML_RPC_Response(new XML_RPC_Values('undef', 'string')); |
| 455 | } |
| 456 | } |
| 457 | else |
| 458 | { |
| 459 | $r = new XML_RPC_Response(0,$this->xmlrpcerr['introspect_unknown'], $this->xmlrpcstr['introspect_unknown']); |
| 460 | } |
| 461 | return $r; |
| 462 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 463 | |
Pascal Kriete | 68d2987 | 2011-02-14 13:39:06 -0500 | [diff] [blame] | 464 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 465 | |
Pascal Kriete | 68d2987 | 2011-02-14 13:39:06 -0500 | [diff] [blame] | 466 | /** |
Derek Jones | 37f4b9c | 2011-07-01 17:56:50 -0500 | [diff] [blame] | 467 | * Server Function: Doc String for Method |
Pascal Kriete | 68d2987 | 2011-02-14 13:39:06 -0500 | [diff] [blame] | 468 | * |
| 469 | * @access public |
| 470 | * @param mixed |
| 471 | * @return object |
| 472 | */ |
Andrey Andreev | 56e3214 | 2011-12-25 18:36:31 +0200 | [diff] [blame] | 473 | public function methodHelp($m) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 474 | { |
| 475 | $parameters = $m->output_parameters(); |
| 476 | $method_name = $parameters[0]; |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 477 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 478 | if (isset($this->methods[$method_name])) |
| 479 | { |
| 480 | $docstring = isset($this->methods[$method_name]['docstring']) ? $this->methods[$method_name]['docstring'] : ''; |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 481 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 482 | return new XML_RPC_Response(new XML_RPC_Values($docstring, 'string')); |
| 483 | } |
| 484 | else |
| 485 | { |
| 486 | return new XML_RPC_Response(0, $this->xmlrpcerr['introspect_unknown'], $this->xmlrpcstr['introspect_unknown']); |
| 487 | } |
| 488 | } |
Andrey Andreev | 56e3214 | 2011-12-25 18:36:31 +0200 | [diff] [blame] | 489 | |
Pascal Kriete | 68d2987 | 2011-02-14 13:39:06 -0500 | [diff] [blame] | 490 | // -------------------------------------------------------------------- |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 491 | |
Pascal Kriete | 68d2987 | 2011-02-14 13:39:06 -0500 | [diff] [blame] | 492 | /** |
Derek Jones | 37f4b9c | 2011-07-01 17:56:50 -0500 | [diff] [blame] | 493 | * Server Function: Multi-call |
Pascal Kriete | 68d2987 | 2011-02-14 13:39:06 -0500 | [diff] [blame] | 494 | * |
| 495 | * @access public |
| 496 | * @param mixed |
| 497 | * @return object |
| 498 | */ |
Andrey Andreev | 56e3214 | 2011-12-25 18:36:31 +0200 | [diff] [blame] | 499 | public function multicall($m) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 500 | { |
| 501 | // Disabled |
| 502 | return new XML_RPC_Response(0, $this->xmlrpcerr['unknown_method'], $this->xmlrpcstr['unknown_method']); |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 503 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 504 | $parameters = $m->output_parameters(); |
| 505 | $calls = $parameters[0]; |
| 506 | |
| 507 | $result = array(); |
| 508 | |
| 509 | foreach ($calls as $value) |
| 510 | { |
| 511 | //$attempt = $this->_execute(new XML_RPC_Message($value[0], $value[1])); |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 512 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 513 | $m = new XML_RPC_Message($value[0]); |
| 514 | $plist=''; |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 515 | |
Andrey Andreev | 56e3214 | 2011-12-25 18:36:31 +0200 | [diff] [blame] | 516 | for ($i = 0, $c = count($value[1]); $i < $c; $i++) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 517 | { |
| 518 | $m->addParam(new XML_RPC_Values($value[1][$i], 'string')); |
| 519 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 520 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 521 | $attempt = $this->_execute($m); |
| 522 | |
| 523 | if ($attempt->faultCode() != 0) |
| 524 | { |
| 525 | return $attempt; |
| 526 | } |
| 527 | |
| 528 | $result[] = new XML_RPC_Values(array($attempt->value()), 'array'); |
| 529 | } |
| 530 | |
| 531 | return new XML_RPC_Response(new XML_RPC_Values($result, 'array')); |
| 532 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 533 | |
Pascal Kriete | 68d2987 | 2011-02-14 13:39:06 -0500 | [diff] [blame] | 534 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 535 | |
Pascal Kriete | 68d2987 | 2011-02-14 13:39:06 -0500 | [diff] [blame] | 536 | /** |
Derek Jones | 37f4b9c | 2011-07-01 17:56:50 -0500 | [diff] [blame] | 537 | * Multi-call Function: Error Handling |
Pascal Kriete | 68d2987 | 2011-02-14 13:39:06 -0500 | [diff] [blame] | 538 | * |
| 539 | * @access public |
| 540 | * @param mixed |
| 541 | * @return object |
| 542 | */ |
Andrey Andreev | 56e3214 | 2011-12-25 18:36:31 +0200 | [diff] [blame] | 543 | public function multicall_error($err) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 544 | { |
Derek Jones | 37f4b9c | 2011-07-01 17:56:50 -0500 | [diff] [blame] | 545 | $str = is_string($err) ? $this->xmlrpcstr["multicall_${err}"] : $err->faultString(); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 546 | $code = is_string($err) ? $this->xmlrpcerr["multicall_${err}"] : $err->faultCode(); |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 547 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 548 | $struct['faultCode'] = new XML_RPC_Values($code, 'int'); |
| 549 | $struct['faultString'] = new XML_RPC_Values($str, 'string'); |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 550 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 551 | return new XML_RPC_Values($struct, 'struct'); |
| 552 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 553 | |
Pascal Kriete | 68d2987 | 2011-02-14 13:39:06 -0500 | [diff] [blame] | 554 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 555 | |
Pascal Kriete | 68d2987 | 2011-02-14 13:39:06 -0500 | [diff] [blame] | 556 | /** |
Derek Jones | 37f4b9c | 2011-07-01 17:56:50 -0500 | [diff] [blame] | 557 | * Multi-call Function: Processes method |
Pascal Kriete | 68d2987 | 2011-02-14 13:39:06 -0500 | [diff] [blame] | 558 | * |
| 559 | * @access public |
| 560 | * @param mixed |
| 561 | * @return object |
| 562 | */ |
Andrey Andreev | 56e3214 | 2011-12-25 18:36:31 +0200 | [diff] [blame] | 563 | public function do_multicall($call) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 564 | { |
| 565 | if ($call->kindOf() != 'struct') |
Pascal Kriete | 68d2987 | 2011-02-14 13:39:06 -0500 | [diff] [blame] | 566 | { |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 567 | return $this->multicall_error('notstruct'); |
Pascal Kriete | 68d2987 | 2011-02-14 13:39:06 -0500 | [diff] [blame] | 568 | } |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 569 | elseif ( ! $methName = $call->me['struct']['methodName']) |
Pascal Kriete | 68d2987 | 2011-02-14 13:39:06 -0500 | [diff] [blame] | 570 | { |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 571 | return $this->multicall_error('nomethod'); |
Pascal Kriete | 68d2987 | 2011-02-14 13:39:06 -0500 | [diff] [blame] | 572 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 573 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 574 | list($scalar_type,$scalar_value)=each($methName->me); |
| 575 | $scalar_type = $scalar_type == $this->xmlrpcI4 ? $this->xmlrpcInt : $scalar_type; |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 576 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 577 | if ($methName->kindOf() != 'scalar' OR $scalar_type != 'string') |
Pascal Kriete | 68d2987 | 2011-02-14 13:39:06 -0500 | [diff] [blame] | 578 | { |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 579 | return $this->multicall_error('notstring'); |
Pascal Kriete | 68d2987 | 2011-02-14 13:39:06 -0500 | [diff] [blame] | 580 | } |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 581 | elseif ($scalar_value == 'system.multicall') |
Pascal Kriete | 68d2987 | 2011-02-14 13:39:06 -0500 | [diff] [blame] | 582 | { |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 583 | return $this->multicall_error('recursion'); |
Pascal Kriete | 68d2987 | 2011-02-14 13:39:06 -0500 | [diff] [blame] | 584 | } |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 585 | elseif ( ! $params = $call->me['struct']['params']) |
Pascal Kriete | 68d2987 | 2011-02-14 13:39:06 -0500 | [diff] [blame] | 586 | { |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 587 | return $this->multicall_error('noparams'); |
Pascal Kriete | 68d2987 | 2011-02-14 13:39:06 -0500 | [diff] [blame] | 588 | } |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 589 | elseif ($params->kindOf() != 'array') |
Pascal Kriete | 68d2987 | 2011-02-14 13:39:06 -0500 | [diff] [blame] | 590 | { |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 591 | return $this->multicall_error('notarray'); |
Pascal Kriete | 68d2987 | 2011-02-14 13:39:06 -0500 | [diff] [blame] | 592 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 593 | |
Andrey Andreev | 56e3214 | 2011-12-25 18:36:31 +0200 | [diff] [blame] | 594 | list($a,$b) = each($params->me); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 595 | |
| 596 | $msg = new XML_RPC_Message($scalar_value); |
Andrey Andreev | 56e3214 | 2011-12-25 18:36:31 +0200 | [diff] [blame] | 597 | for ($i = 0, $numParams = count($b); $i < $numParams; $i++) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 598 | { |
| 599 | $msg->params[] = $params->me['array'][$i]; |
| 600 | } |
| 601 | |
| 602 | $result = $this->_execute($msg); |
| 603 | |
| 604 | if ($result->faultCode() != 0) |
| 605 | { |
| 606 | return $this->multicall_error($result); |
| 607 | } |
| 608 | |
| 609 | return new XML_RPC_Values(array($result->value()), 'array'); |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 610 | } |
| 611 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 612 | } |
| 613 | // END XML_RPC_Server class |
| 614 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 615 | /* End of file Xmlrpcs.php */ |
Andrey Andreev | 56e3214 | 2011-12-25 18:36:31 +0200 | [diff] [blame] | 616 | /* Location: ./system/libraries/Xmlrpcs.php */ |