Changes in trunk/wp-includes/class-IXR.php [16809:14677]
- File:
-
- 1 edited
-
trunk/wp-includes/class-IXR.php (modified) (51 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/class-IXR.php
r16809 r14677 1 1 <?php 2 2 /** 3 * IXR - The Incutio XML-RPC Library 4 * 5 * Copyright (c) 2010, Incutio Ltd. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions are met: 10 * 11 * - Redistributions of source code must retain the above copyright notice, 12 * this list of conditions and the following disclaimer. 13 * - Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * - Neither the name of Incutio Ltd. nor the names of its contributors 17 * may be used to endorse or promote products derived from this software 18 * without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 21 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 27 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 28 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 30 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 * 32 * @package IXR 33 * @since 1.5 34 * 35 * @copyright Incutio Ltd 2010 (http://www.incutio.com) 36 * @version 1.7.4 7th September 2010 37 * @author Simon Willison 38 * @link http://scripts.incutio.com/xmlrpc/ Site/manual 39 * @license http://www.opensource.org/licenses/bsd-license.php BSD 3 * IXR - The Inutio XML-RPC Library 4 * 5 * @package IXR 6 * @since 1.5 7 * 8 * @copyright Incutio Ltd 2002-2005 9 * @version 1.7 (beta) 23rd May 2005 10 * @author Simon Willison 11 * @link http://scripts.incutio.com/xmlrpc/ Site 12 * @link http://scripts.incutio.com/xmlrpc/manual.php Manual 13 * @license BSD License http://www.opensource.org/licenses/bsd-license.php 40 14 */ 41 15 … … 50 24 var $type; 51 25 52 function IXR_Value($data, $type = false) 53 { 26 function IXR_Value ($data, $type = false) { 54 27 $this->data = $data; 55 28 if (!$type) { … … 58 31 $this->type = $type; 59 32 if ($type == 'struct') { 60 / / Turn all the values in the array in to new IXR_Value objects33 /* Turn all the values in the array in to new IXR_Value objects */ 61 34 foreach ($this->data as $key => $value) { 62 35 $this->data[$key] = new IXR_Value($value); … … 70 43 } 71 44 72 function calculateType() 73 { 45 function calculateType() { 74 46 if ($this->data === true || $this->data === false) { 75 47 return 'boolean'; … … 81 53 return 'double'; 82 54 } 83 84 55 // Deal with IXR object types base64 and date 85 56 if (is_object($this->data) && is_a($this->data, 'IXR_Date')) { … … 89 60 return 'base64'; 90 61 } 91 92 62 // If it is a normal PHP object convert it in to a struct 93 63 if (is_object($this->data)) { 64 94 65 $this->data = get_object_vars($this->data); 95 66 return 'struct'; … … 98 69 return 'string'; 99 70 } 100 101 // We have an array - is it an array or a struct? 71 /* We have an array - is it an array or a struct ? */ 102 72 if ($this->isStruct($this->data)) { 103 73 return 'struct'; … … 107 77 } 108 78 109 function getXml() 110 { 111 // Return XML for this value 79 function getXml() { 80 /* Return XML for this value */ 112 81 switch ($this->type) { 113 82 case 'boolean': … … 149 118 } 150 119 151 /** 152 * Checks whether or not the supplied array is a struct or not 153 * 154 * @param unknown_type $array 155 * @return boolean 156 */ 157 function isStruct($array) 158 { 120 function isStruct($array) { 121 /* Nasty function to check if an array is a struct or not */ 159 122 $expected = 0; 160 123 foreach ($array as $key => $value) { … … 169 132 170 133 /** 171 * IXR_MESSAGE 172 * 173 * @package IXR 174 * @since 1.5 175 * 176 */ 177 class IXR_Message 178 { 134 * IXR_Message 135 * 136 * @package IXR 137 * @since 1.5 138 */ 139 class IXR_Message { 179 140 var $message; 180 141 var $messageType; // methodCall / methodResponse / fault … … 183 144 var $methodName; 184 145 var $params; 185 186 146 // Current variable stacks 187 147 var $_arraystructs = array(); // The stack used to keep track of the current array/struct … … 194 154 // The XML parser 195 155 var $_parser; 196 197 function IXR_Message($message) 198 { 199 $this->message =& $message; 200 } 201 202 function parse() 203 { 204 // first remove the XML declaration 205 // merged from WP #10698 - this method avoids the RAM usage of preg_replace on very large messages 206 $header = preg_replace( '/<\?xml.*?\?'.'>/', '', substr($this->message, 0, 100), 1); 207 $this->message = substr_replace($this->message, $header, 0, 100); 156 function IXR_Message (&$message) { 157 $this->message = &$message; 158 } 159 function parse() { 160 // first remove the XML declaration 161 // this method avoids the RAM usage of preg_replace on very large messages 162 $header = preg_replace( '/<\?xml.*?\?'.'>/', '', substr( $this->message, 0, 100 ), 1 ); 163 $this->message = substr_replace($this->message, $header, 0, 100); 208 164 if (trim($this->message) == '') { 209 165 return false; 210 }166 } 211 167 $this->_parser = xml_parser_create(); 212 168 // Set XML parser to take the case of tags in to account … … 215 171 xml_set_object($this->_parser, $this); 216 172 xml_set_element_handler($this->_parser, 'tag_open', 'tag_close'); 217 xml_set_character_data_handler($this->_parser, 'cdata'); 218 $chunk_size = 262144; // 256Kb, parse in chunks to avoid the RAM usage on very large messages 219 $final = false; 220 do { 221 if (strlen($this->message) <= $chunk_size) { 222 $final = true; 223 } 224 $part = substr($this->message, 0, $chunk_size); 225 $this->message = substr($this->message, $chunk_size); 226 if (!xml_parse($this->_parser, $part, $final)) { 227 return false; 228 } 229 if ($final) { 230 break; 231 } 232 } while (true); 233 xml_parser_free($this->_parser); 234 173 xml_set_character_data_handler($this->_parser, 'cdata'); 174 $chunk_size = 262144; // 256Kb, parse in chunks to avoid the RAM usage on very large messages 175 do { 176 if ( strlen($this->message) <= $chunk_size ) 177 $final=true; 178 $part = substr( $this->message, 0, $chunk_size ); 179 $this->message = substr( $this->message, $chunk_size ); 180 if ( !xml_parse( $this->_parser, $part, $final ) ) 181 return false; 182 if ( $final ) 183 break; 184 } while ( true ); 185 xml_parser_free($this->_parser); 235 186 // Grab the error messages, if any 236 187 if ($this->messageType == 'fault') { 237 188 $this->faultCode = $this->params[0]['faultCode']; 238 189 $this->faultString = $this->params[0]['faultString']; 239 }190 } 240 191 return true; 241 192 } 242 243 function tag_open($parser, $tag, $attr) 244 { 193 function tag_open($parser, $tag, $attr) { 245 194 $this->_currentTagContents = ''; 246 195 $this->currentTag = $tag; … … 251 200 $this->messageType = $tag; 252 201 break; 253 /* Deal with stacks of arrays and structs */202 /* Deal with stacks of arrays and structs */ 254 203 case 'data': // data is to all intents and puposes more interesting than array 255 204 $this->_arraystructstypes[] = 'array'; … … 262 211 } 263 212 } 264 265 function cdata($parser, $cdata) 266 { 213 function cdata($parser, $cdata) { 267 214 $this->_currentTagContents .= $cdata; 268 215 } 269 270 function tag_close($parser, $tag) 271 { 216 function tag_close($parser, $tag) { 272 217 $valueFlag = false; 273 218 switch($tag) { 274 219 case 'int': 275 220 case 'i4': 276 $value = (int) trim($this->_currentTagContents);221 $value = (int) trim($this->_currentTagContents); 277 222 $valueFlag = true; 278 223 break; 279 224 case 'double': 280 $value = (double) trim($this->_currentTagContents);225 $value = (double) trim($this->_currentTagContents); 281 226 $valueFlag = true; 282 227 break; 283 228 case 'string': 284 $value = (string)trim($this->_currentTagContents);229 $value = $this->_currentTagContents; 285 230 $valueFlag = true; 286 231 break; 287 232 case 'dateTime.iso8601': 288 233 $value = new IXR_Date(trim($this->_currentTagContents)); 234 // $value = $iso->getTimestamp(); 289 235 $valueFlag = true; 290 236 break; … … 297 243 break; 298 244 case 'boolean': 299 $value = (boolean) trim($this->_currentTagContents);245 $value = (boolean) trim($this->_currentTagContents); 300 246 $valueFlag = true; 301 247 break; 302 248 case 'base64': 303 $value = base64_decode( $this->_currentTagContents);249 $value = base64_decode( trim( $this->_currentTagContents ) ); 304 250 $valueFlag = true; 305 251 break; 306 /* Deal with stacks of arrays and structs */252 /* Deal with stacks of arrays and structs */ 307 253 case 'data': 308 254 case 'struct': … … 321 267 break; 322 268 } 323 324 269 if ($valueFlag) { 325 270 if (count($this->_arraystructs) > 0) { … … 347 292 * @since 1.5 348 293 */ 349 class IXR_Server 350 { 294 class IXR_Server { 351 295 var $data; 352 296 var $callbacks = array(); 353 297 var $message; 354 298 var $capabilities; 355 356 function IXR_Server($callbacks = false, $data = false, $wait = false) 357 { 299 function IXR_Server($callbacks = false, $data = false) { 358 300 $this->setCapabilities(); 359 301 if ($callbacks) { … … 361 303 } 362 304 $this->setCallbacks(); 363 if (!$wait) { 364 $this->serve($data); 365 } 366 } 367 368 function serve($data = false) 369 { 305 $this->serve($data); 306 } 307 function serve($data = false) { 370 308 if (!$data) { 371 if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] !== 'POST') {372 header('Content-Type: text/plain'); // merged from WP #9093373 die('XML-RPC server accepts POST requests only.');374 }375 376 309 global $HTTP_RAW_POST_DATA; 377 if (empty($HTTP_RAW_POST_DATA)) { 378 // workaround for a bug in PHP 5.2.2 - http://bugs.php.net/bug.php?id=41293 379 $data = file_get_contents('php://input'); 380 } else { 381 $data =& $HTTP_RAW_POST_DATA; 382 } 310 if (!$HTTP_RAW_POST_DATA) { 311 header( 'Content-Type: text/plain' ); 312 die('XML-RPC server accepts POST requests only.'); 313 } 314 $data = &$HTTP_RAW_POST_DATA; 383 315 } 384 316 $this->message = new IXR_Message($data); … … 390 322 } 391 323 $result = $this->call($this->message->methodName, $this->message->params); 392 393 324 // Is the result an error? 394 325 if (is_a($result, 'IXR_Error')) { 395 326 $this->error($result); 396 327 } 397 398 328 // Encode the result 399 329 $r = new IXR_Value($result); 400 330 $resultxml = $r->getXml(); 401 402 331 // Create the XML 403 332 $xml = <<<EOD … … 406 335 <param> 407 336 <value> 408 $resultxml337 $resultxml 409 338 </value> 410 339 </param> … … 413 342 414 343 EOD; 415 // Send it 416 $this->output($xml); 417 } 418 419 function call($methodname, $args) 420 { 344 // Send it 345 $this->output($xml); 346 } 347 function call($methodname, $args) { 421 348 if (!$this->hasMethod($methodname)) { 422 return new IXR_Error(-32601, 'server error. requested method '.$methodname.' does not exist.'); 349 return new IXR_Error(-32601, 'server error. requested method '. 350 $methodname.' does not exist.'); 423 351 } 424 352 $method = $this->callbacks[$methodname]; 425 426 353 // Perform the callback and send the response 427 354 if (count($args) == 1) { … … 429 356 $args = $args[0]; 430 357 } 431 432 358 // Are we dealing with a function or a method? 433 if ( is_string($method) && substr($method, 0, 5) == 'this:') {359 if ( is_string( $method ) && substr($method, 0, 5) == 'this:' ) { 434 360 // It's a class method - check it exists 435 361 $method = substr($method, 5); 436 362 if (!method_exists($this, $method)) { 437 return new IXR_Error(-32601, 'server error. requested class method "'. $method.'" does not exist.');438 }439 440 // Call the method363 return new IXR_Error(-32601, 'server error. requested class method "'. 364 $method.'" does not exist.'); 365 } 366 // Call the method 441 367 $result = $this->$method($args); 442 368 } else { 443 369 // It's a function - does it exist? 444 370 if (is_array($method)) { 445 if (!is_callable(array($method[0], $method[1]))) { 446 return new IXR_Error(-32601, 'server error. requested object method "'.$method[1].'" does not exist.'); 371 if (!method_exists($method[0], $method[1])) { 372 return new IXR_Error(-32601, 'server error. requested object method "'. 373 $method[1].'" does not exist.'); 447 374 } 448 375 } else if (!function_exists($method)) { 449 return new IXR_Error(-32601, 'server error. requested function "'. $method.'" does not exist.');450 }451 376 return new IXR_Error(-32601, 'server error. requested function "'. 377 $method.'" does not exist.'); 378 } 452 379 // Call the function 453 380 $result = call_user_func($method, $args); … … 456 383 } 457 384 458 function error($error, $message = false) 459 { 385 function error($error, $message = false) { 460 386 // Accepts either an error object or an error code and message 461 387 if ($message && !is_object($error)) { … … 464 390 $this->output($error->getXml()); 465 391 } 466 467 function output($xml) 468 { 392 function output($xml) { 469 393 $xml = '<?xml version="1.0"?>'."\n".$xml; 470 394 $length = strlen($xml); … … 476 400 exit; 477 401 } 478 479 function hasMethod($method) 480 { 402 function hasMethod($method) { 481 403 return in_array($method, array_keys($this->callbacks)); 482 404 } 483 484 function setCapabilities() 485 { 405 function setCapabilities() { 486 406 // Initialises capabilities array 487 407 $this->capabilities = array( … … 489 409 'specUrl' => 'http://www.xmlrpc.com/spec', 490 410 'specVersion' => 1 491 ),411 ), 492 412 'faults_interop' => array( 493 413 'specUrl' => 'http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php', 494 414 'specVersion' => 20010516 495 ),415 ), 496 416 'system.multicall' => array( 497 417 'specUrl' => 'http://www.xmlrpc.com/discuss/msgReader$1208', 498 418 'specVersion' => 1 499 ),419 ), 500 420 ); 501 421 } 502 503 function getCapabilities($args) 504 { 422 function getCapabilities($args) { 505 423 return $this->capabilities; 506 424 } 507 508 function setCallbacks() 509 { 425 function setCallbacks() { 510 426 $this->callbacks['system.getCapabilities'] = 'this:getCapabilities'; 511 427 $this->callbacks['system.listMethods'] = 'this:listMethods'; 512 428 $this->callbacks['system.multicall'] = 'this:multiCall'; 513 429 } 514 515 function listMethods($args) 516 { 430 function listMethods($args) { 517 431 // Returns a list of methods - uses array_reverse to ensure user defined 518 432 // methods are listed before server defined methods 519 433 return array_reverse(array_keys($this->callbacks)); 520 434 } 521 522 function multiCall($methodcalls) 523 { 435 function multiCall($methodcalls) { 524 436 // See http://www.xmlrpc.com/discuss/msgReader$1208 525 437 $return = array(); … … 551 463 * @since 1.5 552 464 */ 553 class IXR_Request 554 { 465 class IXR_Request { 555 466 var $method; 556 467 var $args; 557 468 var $xml; 558 559 function IXR_Request($method, $args) 560 { 469 function IXR_Request($method, $args) { 561 470 $this->method = $method; 562 471 $this->args = $args; … … 576 485 $this->xml .= '</params></methodCall>'; 577 486 } 578 579 function getLength() 580 { 487 function getLength() { 581 488 return strlen($this->xml); 582 489 } 583 584 function getXml() 585 { 490 function getXml() { 586 491 return $this->xml; 587 492 } … … 593 498 * @package IXR 594 499 * @since 1.5 595 * 596 */ 597 class IXR_Client 598 { 500 */ 501 class IXR_Client { 599 502 var $server; 600 503 var $port; 601 504 var $path; 602 505 var $useragent; 506 var $headers; 603 507 var $response; 604 508 var $message = false; 605 509 var $debug = false; 606 510 var $timeout; 607 var $headers = array();608 609 511 // Storage place for an error message 610 512 var $error = false; 611 612 function IXR_Client($server, $path = false, $port = 80, $timeout = 15) 613 { 513 function IXR_Client($server, $path = false, $port = 80, $timeout = false) { 614 514 if (!$path) { 615 515 // Assume we have been given a URL instead … … 618 518 $this->port = isset($bits['port']) ? $bits['port'] : 80; 619 519 $this->path = isset($bits['path']) ? $bits['path'] : '/'; 620 621 520 // Make absolutely sure we have a path 622 521 if (!$this->path) { … … 631 530 $this->timeout = $timeout; 632 531 } 633 634 function query() 635 { 532 function query() { 636 533 $args = func_get_args(); 637 534 $method = array_shift($args); … … 642 539 $request = "POST {$this->path} HTTP/1.0$r"; 643 540 644 // Merged from WP #8145 - allow custom headers 645 $this->headers['Host'] = $this->server; 646 $this->headers['Content-Type'] = 'text/xml'; 647 $this->headers['User-Agent'] = $this->useragent; 648 $this->headers['Content-Length']= $length; 649 650 foreach( $this->headers as $header => $value ) { 651 $request .= "{$header}: {$value}{$r}"; 652 } 653 $request .= $r; 541 $this->headers['Host'] = $this->server; 542 $this->headers['Content-Type'] = 'text/xml'; 543 $this->headers['User-Agent'] = $this->useragent; 544 $this->headers['Content-Length']= $length; 545 546 foreach( $this->headers as $header => $value ) { 547 $request .= "{$header}: {$value}{$r}"; 548 } 549 $request .= $r; 654 550 655 551 $request .= $xml; 656 657 552 // Now send the request 658 553 if ($this->debug) { 659 554 echo '<pre class="ixr_request">'.htmlspecialchars($request)."\n</pre>\n\n"; 660 555 } 661 662 556 if ($this->timeout) { 663 557 $fp = @fsockopen($this->server, $this->port, $errno, $errstr, $this->timeout); … … 666 560 } 667 561 if (!$fp) { 668 $this->error = new IXR_Error(-32300, 'transport error - could not open socket');562 $this->error = new IXR_Error(-32300, "transport error - could not open socket: $errno $errstr"); 669 563 return false; 670 564 } 671 565 fputs($fp, $request); 672 566 $contents = ''; 673 $debug Contents = '';567 $debug_contents = ''; 674 568 $gotFirstLine = false; 675 569 $gettingHeaders = true; … … 679 573 // Check line for '200' 680 574 if (strstr($line, '200') === false) { 681 $this->error = new IXR_Error(-3230 0, 'transport error - HTTP status code was not 200');575 $this->error = new IXR_Error(-32301, 'transport error - HTTP status code was not 200'); 682 576 return false; 683 577 } … … 688 582 } 689 583 if (!$gettingHeaders) { 690 // merged from WP #12559 - remove trim584 // WP#12559 remove trim so as to not strip newlines from received response. 691 585 $contents .= $line; 692 586 } 693 587 if ($this->debug) { 694 $debugContents .= $line;588 $debug_contents .= $line; 695 589 } 696 590 } 697 591 if ($this->debug) { 698 echo '<pre class="ixr_response">'.htmlspecialchars($debugContents)."\n</pre>\n\n"; 699 } 700 592 echo '<pre class="ixr_response">'.htmlspecialchars($debug_contents)."\n</pre>\n\n"; 593 } 701 594 // Now parse what we've got back 702 595 $this->message = new IXR_Message($contents); … … 706 599 return false; 707 600 } 708 709 601 // Is the message a fault? 710 602 if ($this->message->messageType == 'fault') { … … 712 604 return false; 713 605 } 714 715 606 // Message must be OK 716 607 return true; 717 608 } 718 719 function getResponse() 720 { 609 function getResponse() { 721 610 // methodResponses can only have one param - return that 722 611 return $this->message->params[0]; 723 612 } 724 725 function isError() 726 { 613 function isError() { 727 614 return (is_object($this->error)); 728 615 } 729 730 function getErrorCode() 731 { 616 function getErrorCode() { 732 617 return $this->error->code; 733 618 } 734 735 function getErrorMessage() 736 { 619 function getErrorMessage() { 737 620 return $this->error->message; 738 621 } 739 622 } 740 623 741 742 624 /** 743 625 * IXR_Error … … 746 628 * @since 1.5 747 629 */ 748 class IXR_Error 749 { 630 class IXR_Error { 750 631 var $code; 751 632 var $message; 752 753 function IXR_Error($code, $message) 754 { 633 function IXR_Error($code, $message) { 755 634 $this->code = $code; 635 // WP adds htmlspecialchars(). See #5666 756 636 $this->message = htmlspecialchars($message); 757 637 } 758 759 function getXml() 760 { 638 function getXml() { 761 639 $xml = <<<EOD 762 640 <methodResponse> … … 796 674 var $second; 797 675 var $timezone; 798 799 function IXR_Date($time) 800 { 676 function IXR_Date($time) { 801 677 // $time can be a PHP timestamp or an ISO one 802 678 if (is_numeric($time)) { … … 806 682 } 807 683 } 808 809 function parseTimestamp($timestamp) 810 { 684 function parseTimestamp($timestamp) { 811 685 $this->year = date('Y', $timestamp); 812 686 $this->month = date('m', $timestamp); … … 815 689 $this->minute = date('i', $timestamp); 816 690 $this->second = date('s', $timestamp); 691 // WP adds timezone. See #2036 817 692 $this->timezone = ''; 818 693 } 819 820 function parseIso($iso) 821 { 694 function parseIso($iso) { 822 695 $this->year = substr($iso, 0, 4); 823 696 $this->month = substr($iso, 4, 2); … … 826 699 $this->minute = substr($iso, 12, 2); 827 700 $this->second = substr($iso, 15, 2); 701 // WP adds timezone. See #2036 828 702 $this->timezone = substr($iso, 17); 829 703 } 830 831 function getIso() 832 { 704 function getIso() { 705 // WP adds timezone. See #2036 833 706 return $this->year.$this->month.$this->day.'T'.$this->hour.':'.$this->minute.':'.$this->second.$this->timezone; 834 707 } 835 836 function getXml() 837 { 708 function getXml() { 838 709 return '<dateTime.iso8601>'.$this->getIso().'</dateTime.iso8601>'; 839 710 } 840 841 function getTimestamp() 842 { 711 function getTimestamp() { 843 712 return mktime($this->hour, $this->minute, $this->second, $this->month, $this->day, $this->year); 844 713 } … … 851 720 * @since 1.5 852 721 */ 853 class IXR_Base64 854 { 722 class IXR_Base64 { 855 723 var $data; 856 857 function IXR_Base64($data) 858 { 724 function IXR_Base64($data) { 859 725 $this->data = $data; 860 726 } 861 862 function getXml() 863 { 727 function getXml() { 864 728 return '<base64>'.base64_encode($this->data).'</base64>'; 865 729 } … … 872 736 * @since 1.5 873 737 */ 874 class IXR_IntrospectionServer extends IXR_Server 875 { 738 class IXR_IntrospectionServer extends IXR_Server { 876 739 var $signatures; 877 740 var $help; 878 879 function IXR_IntrospectionServer() 880 { 741 function IXR_IntrospectionServer() { 881 742 $this->setCallbacks(); 882 743 $this->setCapabilities(); … … 910 771 ); 911 772 } 912 913 function addCallback($method, $callback, $args, $help) 914 { 773 function addCallback($method, $callback, $args, $help) { 915 774 $this->callbacks[$method] = $callback; 916 775 $this->signatures[$method] = $args; 917 776 $this->help[$method] = $help; 918 777 } 919 920 function call($methodname, $args) 921 { 778 function call($methodname, $args) { 922 779 // Make sure it's in an array 923 780 if ($args && !is_array($args)) { 924 781 $args = array($args); 925 782 } 926 927 783 // Over-rides default call method, adds signature check 928 784 if (!$this->hasMethod($methodname)) { … … 932 788 $signature = $this->signatures[$methodname]; 933 789 $returnType = array_shift($signature); 934 935 790 // Check the number of arguments 936 791 if (count($args) != count($signature)) { 937 792 return new IXR_Error(-32602, 'server error. wrong number of method parameters'); 938 793 } 939 940 794 // Check the argument types 941 795 $ok = true; … … 982 836 return parent::call($methodname, $argsbackup); 983 837 } 984 985 function methodSignature($method) 986 { 838 function methodSignature($method) { 987 839 if (!$this->hasMethod($method)) { 988 840 return new IXR_Error(-32601, 'server error. requested method "'.$method.'" not specified.'); … … 1022 874 return $return; 1023 875 } 1024 1025 function methodHelp($method) 1026 { 876 function methodHelp($method) { 1027 877 return $this->help[$method]; 1028 878 } … … 1035 885 * @since 1.5 1036 886 */ 1037 class IXR_ClientMulticall extends IXR_Client 1038 { 887 class IXR_ClientMulticall extends IXR_Client { 1039 888 var $calls = array(); 1040 1041 function IXR_ClientMulticall($server, $path = false, $port = 80) 1042 { 889 function IXR_ClientMulticall($server, $path = false, $port = 80) { 1043 890 parent::IXR_Client($server, $path, $port); 1044 891 $this->useragent = 'The Incutio XML-RPC PHP Library (multicall client)'; 1045 892 } 1046 1047 function addCall() 1048 { 893 function addCall() { 1049 894 $args = func_get_args(); 1050 895 $methodName = array_shift($args); … … 1055 900 $this->calls[] = $struct; 1056 901 } 1057 1058 function query() 1059 { 902 function query() { 1060 903 // Prepare multicall, then call the parent::query() method 1061 904 return parent::query('system.multicall', $this->calls);
Note: See TracChangeset
for help on using the changeset viewer.