Edit File by line
/home/barbar84/www/wp-inclu.../IXR
File: class-IXR-introspectionserver.php
<?php
[0] Fix | Delete
[1] Fix | Delete
/**
[2] Fix | Delete
* IXR_IntrospectionServer
[3] Fix | Delete
*
[4] Fix | Delete
* @package IXR
[5] Fix | Delete
* @since 1.5.0
[6] Fix | Delete
*/
[7] Fix | Delete
class IXR_IntrospectionServer extends IXR_Server
[8] Fix | Delete
{
[9] Fix | Delete
var $signatures;
[10] Fix | Delete
var $help;
[11] Fix | Delete
[12] Fix | Delete
/**
[13] Fix | Delete
* PHP5 constructor.
[14] Fix | Delete
*/
[15] Fix | Delete
function __construct()
[16] Fix | Delete
{
[17] Fix | Delete
$this->setCallbacks();
[18] Fix | Delete
$this->setCapabilities();
[19] Fix | Delete
$this->capabilities['introspection'] = array(
[20] Fix | Delete
'specUrl' => 'http://xmlrpc.usefulinc.com/doc/reserved.html',
[21] Fix | Delete
'specVersion' => 1
[22] Fix | Delete
);
[23] Fix | Delete
$this->addCallback(
[24] Fix | Delete
'system.methodSignature',
[25] Fix | Delete
'this:methodSignature',
[26] Fix | Delete
array('array', 'string'),
[27] Fix | Delete
'Returns an array describing the return type and required parameters of a method'
[28] Fix | Delete
);
[29] Fix | Delete
$this->addCallback(
[30] Fix | Delete
'system.getCapabilities',
[31] Fix | Delete
'this:getCapabilities',
[32] Fix | Delete
array('struct'),
[33] Fix | Delete
'Returns a struct describing the XML-RPC specifications supported by this server'
[34] Fix | Delete
);
[35] Fix | Delete
$this->addCallback(
[36] Fix | Delete
'system.listMethods',
[37] Fix | Delete
'this:listMethods',
[38] Fix | Delete
array('array'),
[39] Fix | Delete
'Returns an array of available methods on this server'
[40] Fix | Delete
);
[41] Fix | Delete
$this->addCallback(
[42] Fix | Delete
'system.methodHelp',
[43] Fix | Delete
'this:methodHelp',
[44] Fix | Delete
array('string', 'string'),
[45] Fix | Delete
'Returns a documentation string for the specified method'
[46] Fix | Delete
);
[47] Fix | Delete
}
[48] Fix | Delete
[49] Fix | Delete
/**
[50] Fix | Delete
* PHP4 constructor.
[51] Fix | Delete
*/
[52] Fix | Delete
public function IXR_IntrospectionServer() {
[53] Fix | Delete
self::__construct();
[54] Fix | Delete
}
[55] Fix | Delete
[56] Fix | Delete
function addCallback($method, $callback, $args, $help)
[57] Fix | Delete
{
[58] Fix | Delete
$this->callbacks[$method] = $callback;
[59] Fix | Delete
$this->signatures[$method] = $args;
[60] Fix | Delete
$this->help[$method] = $help;
[61] Fix | Delete
}
[62] Fix | Delete
[63] Fix | Delete
function call($methodname, $args)
[64] Fix | Delete
{
[65] Fix | Delete
// Make sure it's in an array
[66] Fix | Delete
if ($args && !is_array($args)) {
[67] Fix | Delete
$args = array($args);
[68] Fix | Delete
}
[69] Fix | Delete
[70] Fix | Delete
// Over-rides default call method, adds signature check
[71] Fix | Delete
if (!$this->hasMethod($methodname)) {
[72] Fix | Delete
return new IXR_Error(-32601, 'server error. requested method "'.$this->message->methodName.'" not specified.');
[73] Fix | Delete
}
[74] Fix | Delete
$method = $this->callbacks[$methodname];
[75] Fix | Delete
$signature = $this->signatures[$methodname];
[76] Fix | Delete
$returnType = array_shift($signature);
[77] Fix | Delete
[78] Fix | Delete
// Check the number of arguments
[79] Fix | Delete
if (count($args) != count($signature)) {
[80] Fix | Delete
return new IXR_Error(-32602, 'server error. wrong number of method parameters');
[81] Fix | Delete
}
[82] Fix | Delete
[83] Fix | Delete
// Check the argument types
[84] Fix | Delete
$ok = true;
[85] Fix | Delete
$argsbackup = $args;
[86] Fix | Delete
for ($i = 0, $j = count($args); $i < $j; $i++) {
[87] Fix | Delete
$arg = array_shift($args);
[88] Fix | Delete
$type = array_shift($signature);
[89] Fix | Delete
switch ($type) {
[90] Fix | Delete
case 'int':
[91] Fix | Delete
case 'i4':
[92] Fix | Delete
if (is_array($arg) || !is_int($arg)) {
[93] Fix | Delete
$ok = false;
[94] Fix | Delete
}
[95] Fix | Delete
break;
[96] Fix | Delete
case 'base64':
[97] Fix | Delete
case 'string':
[98] Fix | Delete
if (!is_string($arg)) {
[99] Fix | Delete
$ok = false;
[100] Fix | Delete
}
[101] Fix | Delete
break;
[102] Fix | Delete
case 'boolean':
[103] Fix | Delete
if ($arg !== false && $arg !== true) {
[104] Fix | Delete
$ok = false;
[105] Fix | Delete
}
[106] Fix | Delete
break;
[107] Fix | Delete
case 'float':
[108] Fix | Delete
case 'double':
[109] Fix | Delete
if (!is_float($arg)) {
[110] Fix | Delete
$ok = false;
[111] Fix | Delete
}
[112] Fix | Delete
break;
[113] Fix | Delete
case 'date':
[114] Fix | Delete
case 'dateTime.iso8601':
[115] Fix | Delete
if (!is_a($arg, 'IXR_Date')) {
[116] Fix | Delete
$ok = false;
[117] Fix | Delete
}
[118] Fix | Delete
break;
[119] Fix | Delete
}
[120] Fix | Delete
if (!$ok) {
[121] Fix | Delete
return new IXR_Error(-32602, 'server error. invalid method parameters');
[122] Fix | Delete
}
[123] Fix | Delete
}
[124] Fix | Delete
// It passed the test - run the "real" method call
[125] Fix | Delete
return parent::call($methodname, $argsbackup);
[126] Fix | Delete
}
[127] Fix | Delete
[128] Fix | Delete
function methodSignature($method)
[129] Fix | Delete
{
[130] Fix | Delete
if (!$this->hasMethod($method)) {
[131] Fix | Delete
return new IXR_Error(-32601, 'server error. requested method "'.$method.'" not specified.');
[132] Fix | Delete
}
[133] Fix | Delete
// We should be returning an array of types
[134] Fix | Delete
$types = $this->signatures[$method];
[135] Fix | Delete
$return = array();
[136] Fix | Delete
foreach ($types as $type) {
[137] Fix | Delete
switch ($type) {
[138] Fix | Delete
case 'string':
[139] Fix | Delete
$return[] = 'string';
[140] Fix | Delete
break;
[141] Fix | Delete
case 'int':
[142] Fix | Delete
case 'i4':
[143] Fix | Delete
$return[] = 42;
[144] Fix | Delete
break;
[145] Fix | Delete
case 'double':
[146] Fix | Delete
$return[] = 3.1415;
[147] Fix | Delete
break;
[148] Fix | Delete
case 'dateTime.iso8601':
[149] Fix | Delete
$return[] = new IXR_Date(time());
[150] Fix | Delete
break;
[151] Fix | Delete
case 'boolean':
[152] Fix | Delete
$return[] = true;
[153] Fix | Delete
break;
[154] Fix | Delete
case 'base64':
[155] Fix | Delete
$return[] = new IXR_Base64('base64');
[156] Fix | Delete
break;
[157] Fix | Delete
case 'array':
[158] Fix | Delete
$return[] = array('array');
[159] Fix | Delete
break;
[160] Fix | Delete
case 'struct':
[161] Fix | Delete
$return[] = array('struct' => 'struct');
[162] Fix | Delete
break;
[163] Fix | Delete
}
[164] Fix | Delete
}
[165] Fix | Delete
return $return;
[166] Fix | Delete
}
[167] Fix | Delete
[168] Fix | Delete
function methodHelp($method)
[169] Fix | Delete
{
[170] Fix | Delete
return $this->help[$method];
[171] Fix | Delete
}
[172] Fix | Delete
}
[173] Fix | Delete
[174] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function