<?php 


/** 
***************************************************
*欢迎使用免费版SiteTeam企业建站软件！
*这是一个专业为搜索引擎营销而设计的，极稳定、极易维护的建站软件！
*官方客服：help@php.net.cn
*官方下载网址：http://www.SiteTeam.cn 
***************************************************
**/




 $GLOBALS['xmlrpcs_capabilities'] = array( 'xmlrpc' => new xmlrpcval(array( 'specUrl' => new xmlrpcval('http://www.xmlrpc.com/spec', 'string'), 'specVersion' => new xmlrpcval(1, 'int') ), 'struct'), 'system.multicall' => new xmlrpcval(array( 'specUrl' => new xmlrpcval('http://www.xmlrpc.com/discuss/msgReader$1208', 'string'), 'specVersion' => new xmlrpcval(1, 'int') ), 'struct'), 'introspection' => new xmlrpcval(array( 'specUrl' => new xmlrpcval('http://phpxmlrpc.sourceforge.net/doc-2/ch10.html', 'string'), 'specVersion' => new xmlrpcval(2, 'int') ), 'struct') ); $_xmlrpcs_getCapabilities_sig=array(array($GLOBALS['xmlrpcStruct'])); $_xmlrpcs_getCapabilities_doc='This method lists all the capabilites that the XML-RPC server has: the (more or less standard) extensions to the xmlrpc spec that it adheres to'; $_xmlrpcs_getCapabilities_sdoc=array(array('list of capabilities, described as structs with a version number and url for the spec')); function _xmlrpcs_getCapabilities($server, $m=null) { $outAr = $GLOBALS['xmlrpcs_capabilities']; if ($GLOBALS['xmlrpc_null_extension']) { $outAr['nil'] = new xmlrpcval(array( 'specUrl' => new xmlrpcval('http://www.ontosys.com/xml-rpc/extensions.php', 'string'), 'specVersion' => new xmlrpcval(1, 'int') ), 'struct'); } return new xmlrpcresp(new xmlrpcval($outAr, 'struct')); } $_xmlrpcs_listMethods_sig=array(array($GLOBALS['xmlrpcArray'])); $_xmlrpcs_listMethods_doc='This method lists all the methods that the XML-RPC server knows how to dispatch'; $_xmlrpcs_listMethods_sdoc=array(array('list of method names')); function _xmlrpcs_listMethods($server, $m=null) { $outAr=array(); foreach($server->dmap as $key => $val) { $outAr[]=&new xmlrpcval($key, 'string'); } if($server->allow_system_funcs) { foreach($GLOBALS['_xmlrpcs_dmap'] as $key => $val) { $outAr[]=&new xmlrpcval($key, 'string'); } } return new xmlrpcresp(new xmlrpcval($outAr, 'array')); } $_xmlrpcs_methodSignature_sig=array(array($GLOBALS['xmlrpcArray'], $GLOBALS['xmlrpcString'])); $_xmlrpcs_methodSignature_doc='Returns an array of known signatures (an array of arrays) for the method name passed. If no signatures are known, returns a none-array (test for type != array to detect missing signature)'; $_xmlrpcs_methodSignature_sdoc=array(array('list of known signatures, each sig being an array of xmlrpc type names', 'name of method to be described')); function _xmlrpcs_methodSignature($server, $m) { if (is_object($m)) { $methName=$m->getParam(0); $methName=$methName->scalarval(); } else { $methName=$m; } if(strpos($methName, "system.") === 0) { $dmap=$GLOBALS['_xmlrpcs_dmap']; $sysCall=1; } else { $dmap=$server->dmap; $sysCall=0; } if(isset($dmap[$methName])) { if(isset($dmap[$methName]['signature'])) { $sigs=array(); foreach($dmap[$methName]['signature'] as $inSig) { $cursig=array(); foreach($inSig as $sig) { $cursig[]=&new xmlrpcval($sig, 'string'); } $sigs[]=&new xmlrpcval($cursig, 'array'); } $r=&new xmlrpcresp(new xmlrpcval($sigs, 'array')); } else { $r=&new xmlrpcresp(new xmlrpcval('undef', 'string')); } } else { $r=&new xmlrpcresp(0,$GLOBALS['xmlrpcerr']['introspect_unknown'], $GLOBALS['xmlrpcstr']['introspect_unknown']); } return $r; } $_xmlrpcs_methodHelp_sig=array(array($GLOBALS['xmlrpcString'], $GLOBALS['xmlrpcString'])); $_xmlrpcs_methodHelp_doc='Returns help text if defined for the method passed, otherwise returns an empty string'; $_xmlrpcs_methodHelp_sdoc=array(array('method description', 'name of the method to be described')); function _xmlrpcs_methodHelp($server, $m) { if (is_object($m)) { $methName=$m->getParam(0); $methName=$methName->scalarval(); } else { $methName=$m; } if(strpos($methName, "system.") === 0) { $dmap=$GLOBALS['_xmlrpcs_dmap']; $sysCall=1; } else { $dmap=$server->dmap; $sysCall=0; } if(isset($dmap[$methName])) { if(isset($dmap[$methName]['docstring'])) { $r=&new xmlrpcresp(new xmlrpcval($dmap[$methName]['docstring']), 'string'); } else { $r=&new xmlrpcresp(new xmlrpcval('', 'string')); } } else { $r=&new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['introspect_unknown'], $GLOBALS['xmlrpcstr']['introspect_unknown']); } return $r; } $_xmlrpcs_multicall_sig = array(array($GLOBALS['xmlrpcArray'], $GLOBALS['xmlrpcArray'])); $_xmlrpcs_multicall_doc = 'Boxcar multiple RPC calls in one request. See http://www.xmlrpc.com/discuss/msgReader$1208 for details'; $_xmlrpcs_multicall_sdoc = array(array('list of response structs, where each struct has the usual members', 'list of calls, with each call being represented as a struct, with members "methodname" and "params"')); function _xmlrpcs_multicall_error($err) { if(is_string($err)) { $str = $GLOBALS['xmlrpcstr']["multicall_${err}"]; $code = $GLOBALS['xmlrpcerr']["multicall_${err}"]; } else { $code = $err->faultCode(); $str = $err->faultString(); } $struct = array(); $struct['faultCode'] =& new xmlrpcval($code, 'int'); $struct['faultString'] =& new xmlrpcval($str, 'string'); return new xmlrpcval($struct, 'struct'); } function _xmlrpcs_multicall_do_call($server, $call) { if($call->kindOf() != 'struct') { return _xmlrpcs_multicall_error('notstruct'); } $methName = @$call->structmem('methodName'); if(!$methName) { return _xmlrpcs_multicall_error('nomethod'); } if($methName->kindOf() != 'scalar' || $methName->scalartyp() != 'string') { return _xmlrpcs_multicall_error('notstring'); } if($methName->scalarval() == 'system.multicall') { return _xmlrpcs_multicall_error('recursion'); } $params = @$call->structmem('params'); if(!$params) { return _xmlrpcs_multicall_error('noparams'); } if($params->kindOf() != 'array') { return _xmlrpcs_multicall_error('notarray'); } $numParams = $params->arraysize(); $msg =& new xmlrpcmsg($methName->scalarval()); for($i = 0; $i < $numParams; $i++) { if(!$msg->addParam($params->arraymem($i))) { $i++; return _xmlrpcs_multicall_error(new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['incorrect_params'], $GLOBALS['xmlrpcstr']['incorrect_params'] . ": probable xml error in param " . $i)); } } $result = $server->execute($msg); if($result->faultCode() != 0) { return _xmlrpcs_multicall_error($result); } return new xmlrpcval(array($result->value()), 'array'); } function _xmlrpcs_multicall_do_call_phpvals($server, $call) { if(!is_array($call)) { return _xmlrpcs_multicall_error('notstruct'); } if(!array_key_exists('methodName', $call)) { return _xmlrpcs_multicall_error('nomethod'); } if (!is_string($call['methodName'])) { return _xmlrpcs_multicall_error('notstring'); } if($call['methodName'] == 'system.multicall') { return _xmlrpcs_multicall_error('recursion'); } if(!array_key_exists('params', $call)) { return _xmlrpcs_multicall_error('noparams'); } if(!is_array($call['params'])) { return _xmlrpcs_multicall_error('notarray'); } $numParams = count($call['params']); $pt = array(); foreach($call['params'] as $val) $pt[] = php_2_xmlrpc_type(gettype($val)); $result = $server->execute($call['methodName'], $call['params'], $pt); if($result->faultCode() != 0) { return _xmlrpcs_multicall_error($result); } return new xmlrpcval(array($result->value()), 'array'); } function _xmlrpcs_multicall($server, $m) { $result = array(); if (is_object($m)) { $calls = $m->getParam(0); $numCalls = $calls->arraysize(); for($i = 0; $i < $numCalls; $i++) { $call = $calls->arraymem($i); $result[$i] = _xmlrpcs_multicall_do_call($server, $call); } } else { $numCalls=count($m); for($i = 0; $i < $numCalls; $i++) { $result[$i] = _xmlrpcs_multicall_do_call_phpvals($server, $m[$i]); } } return new xmlrpcresp(new xmlrpcval($result, 'array')); } $GLOBALS['_xmlrpcs_dmap']=array( 'system.listMethods' => array( 'function' => '_xmlrpcs_listMethods', 'signature' => $_xmlrpcs_listMethods_sig, 'docstring' => $_xmlrpcs_listMethods_doc, 'signature_docs' => $_xmlrpcs_listMethods_sdoc), 'system.methodHelp' => array( 'function' => '_xmlrpcs_methodHelp', 'signature' => $_xmlrpcs_methodHelp_sig, 'docstring' => $_xmlrpcs_methodHelp_doc, 'signature_docs' => $_xmlrpcs_methodHelp_sdoc), 'system.methodSignature' => array( 'function' => '_xmlrpcs_methodSignature', 'signature' => $_xmlrpcs_methodSignature_sig, 'docstring' => $_xmlrpcs_methodSignature_doc, 'signature_docs' => $_xmlrpcs_methodSignature_sdoc), 'system.multicall' => array( 'function' => '_xmlrpcs_multicall', 'signature' => $_xmlrpcs_multicall_sig, 'docstring' => $_xmlrpcs_multicall_doc, 'signature_docs' => $_xmlrpcs_multicall_sdoc), 'system.getCapabilities' => array( 'function' => '_xmlrpcs_getCapabilities', 'signature' => $_xmlrpcs_getCapabilities_sig, 'docstring' => $_xmlrpcs_getCapabilities_doc, 'signature_docs' => $_xmlrpcs_getCapabilities_sdoc) ); $GLOBALS['_xmlrpcs_occurred_errors'] = ''; $GLOBALS['_xmlrpcs_prev_ehandler'] = ''; function _xmlrpcs_errorHandler($errcode, $errstring, $filename=null, $lineno=null, $context=null) { if (error_reporting() == 0) return; if($errcode != 2048) { $GLOBALS['_xmlrpcs_occurred_errors'] = $GLOBALS['_xmlrpcs_occurred_errors'] . $errstring . "\n"; } if($GLOBALS['_xmlrpcs_prev_ehandler'] == '') { if(ini_get('log_errors') && (intval(ini_get('error_reporting')) & $errcode)) { error_log($errstring); } } else { if($GLOBALS['_xmlrpcs_prev_ehandler'] != '_xmlrpcs_errorHandler') { if(is_array($GLOBALS['_xmlrpcs_prev_ehandler'])) { call_user_func_array($GLOBALS['_xmlrpcs_prev_ehandler'], array($errcode, $errstring, $filename, $lineno, $context)); } else { $GLOBALS['_xmlrpcs_prev_ehandler']($errcode, $errstring, $filename, $lineno, $context); } } } } $GLOBALS['_xmlrpc_debuginfo']=''; function xmlrpc_debugmsg($m) { $GLOBALS['_xmlrpc_debuginfo'] .= $m . "\n"; } class xmlrpc_server { var $dmap=array(); var $functions_parameters_type='xmlrpcvals'; var $debug = 1; var $compress_response = false; var $accepted_compression = array(); var $allow_system_funcs = true; var $accepted_charset_encodings = array(); var $response_charset_encoding = ''; var $debug_info = ''; var $user_data = null; function xmlrpc_server($dispMap=null, $serviceNow=true) { if(function_exists('gzinflate')) { $this->accepted_compression = array('gzip', 'deflate'); $this->compress_response = true; } $this->accepted_charset_encodings = array('UTF-8', 'ISO-8859-1', 'US-ASCII'); if($dispMap) { $this->dmap = $dispMap; if($serviceNow) { $this->service(); } } } function setDebug($in) { $this->debug=$in; } function serializeDebug($charset_encoding='') { $out = ''; if ($this->debug_info != '') { $out .= "<!-- SERVER DEBUG INFO (BASE64 ENCODED):\n".base64_encode($this->debug_info)."\n-->\n"; } if($GLOBALS['_xmlrpc_debuginfo']!='') { $out .= "<!-- DEBUG INFO:\n" . xmlrpc_encode_entitites(str_replace('--', '_-', $GLOBALS['_xmlrpc_debuginfo']), $GLOBALS['xmlrpc_internalencoding'], $charset_encoding) . "\n-->\n"; } return $out; } function service($data=null, $return_payload=false) { if ($data === null) { $ver = phpversion(); if ($ver[0] >= 5) { $data = file_get_contents('php://input'); } else { $data = isset($GLOBALS['HTTP_RAW_POST_DATA']) ? $GLOBALS['HTTP_RAW_POST_DATA'] : ''; } } $raw_data = $data; $this->debug_info = ''; if($this->debug > 1) { $this->debugmsg("+++GOT+++\n" . $data . "\n+++END+++"); } $r = $this->parseRequestHeaders($data, $req_charset, $resp_charset, $resp_encoding); if (!$r) { $r=$this->parseRequest($data, $req_charset); } $r->raw_data = $raw_data; if($this->debug > 2 && $GLOBALS['_xmlrpcs_occurred_errors']) { $this->debugmsg("+++PROCESSING ERRORS AND WARNINGS+++\n" . $GLOBALS['_xmlrpcs_occurred_errors'] . "+++END+++"); } $payload=$this->xml_header($resp_charset); if($this->debug > 0) { $payload = $payload . $this->serializeDebug($resp_charset); } if (empty($r->payload)) { $r->serialize($resp_charset); } $payload = $payload . $r->payload; if ($return_payload) { return $payload; } if(!headers_sent()) { header('Content-Type: '.$r->content_type); header("Vary: Accept-Charset"); $php_no_self_compress = !ini_get('zlib.output_compression') && (ini_get('output_handler') != 'ob_gzhandler'); if($this->compress_response && function_exists('gzencode') && $resp_encoding != '' && $php_no_self_compress) { if(strpos($resp_encoding, 'gzip') !== false) { $payload = gzencode($payload); header("Content-Encoding: gzip"); header("Vary: Accept-Encoding"); } elseif (strpos($resp_encoding, 'deflate') !== false) { $payload = gzcompress($payload); header("Content-Encoding: deflate"); header("Vary: Accept-Encoding"); } } if($php_no_self_compress) { header('Content-Length: ' . (int)strlen($payload)); } } else { error_log('XML-RPC: xmlrpc_server::service: http headers already sent before response is fully generated. Check for php warning or error messages'); } print $payload; return $r; } function add_to_map($methodname,$function,$sig=null,$doc=false,$sigdoc=false) { $this->dmap[$methodname] = array( 'function' => $function, 'docstring' => $doc ); if ($sig) { $this->dmap[$methodname]['signature'] = $sig; } if ($sigdoc) { $this->dmap[$methodname]['signature_docs'] = $sigdoc; } } function verifySignature($in, $sig) { if (is_object($in)) { $numParams = $in->getNumParams(); } else { $numParams = count($in); } foreach($sig as $cursig) { if(count($cursig)==$numParams+1) { $itsOK=1; for($n=0; $n<$numParams; $n++) { if (is_object($in)) { $p=$in->getParam($n); if($p->kindOf() == 'scalar') { $pt=$p->scalartyp(); } else { $pt=$p->kindOf(); } } else { $pt= $in[$n] == 'i4' ? 'int' : $in[$n]; } if($pt != $cursig[$n+1] && $cursig[$n+1] != $GLOBALS['xmlrpcValue']) { $itsOK=0; $pno=$n+1; $wanted=$cursig[$n+1]; $got=$pt; break; } } if($itsOK) { return array(1,''); } } } if(isset($wanted)) { return array(0, "Wanted ${wanted}, got ${got} at param ${pno}"); } else { return array(0, "No method signature matches number of parameters"); } } function parseRequestHeaders(&$data, &$req_encoding, &$resp_encoding, &$resp_compression) { if(!isset($_SERVER)) { $_SERVER = $GLOBALS['HTTP_SERVER_VARS']; } if($this->debug > 1) { if(function_exists('getallheaders')) { $this->debugmsg(''); foreach(getallheaders() as $name => $val) { $this->debugmsg("HEADER: $name: $val"); } } } if(isset($_SERVER['HTTP_CONTENT_ENCODING'])) { $content_encoding = str_replace('x-', '', $_SERVER['HTTP_CONTENT_ENCODING']); } else { $content_encoding = ''; } if($content_encoding != '' && strlen($data)) { if($content_encoding == 'deflate' || $content_encoding == 'gzip') { if(function_exists('gzinflate') && in_array($content_encoding, $this->accepted_compression)) { if($content_encoding == 'deflate' && $degzdata = @gzuncompress($data)) { $data = $degzdata; if($this->debug > 1) { $this->debugmsg("\n+++INFLATED REQUEST+++[".strlen($data)." chars]+++\n" . $data . "\n+++END+++"); } } elseif($content_encoding == 'gzip' && $degzdata = @gzinflate(substr($data, 10))) { $data = $degzdata; if($this->debug > 1) $this->debugmsg("+++INFLATED REQUEST+++[".strlen($data)." chars]+++\n" . $data . "\n+++END+++"); } else { $r =& new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['server_decompress_fail'], $GLOBALS['xmlrpcstr']['server_decompress_fail']); return $r; } } else { $r =& new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['server_cannot_decompress'], $GLOBALS['xmlrpcstr']['server_cannot_decompress']); return $r; } } } if ($this->response_charset_encoding == 'auto') { $resp_encoding = ''; if (isset($_SERVER['HTTP_ACCEPT_CHARSET'])) { $client_accepted_charsets = explode(',', strtoupper($_SERVER['HTTP_ACCEPT_CHARSET'])); $known_charsets = array($GLOBALS['xmlrpc_internalencoding'], 'UTF-8', 'ISO-8859-1', 'US-ASCII'); foreach ($known_charsets as $charset) { foreach ($client_accepted_charsets as $accepted) if (strpos($accepted, $charset) === 0) { $resp_encoding = $charset; break; } if ($resp_encoding) break; } } } else { $resp_encoding = $this->response_charset_encoding; } if (isset($_SERVER['HTTP_ACCEPT_ENCODING'])) { $resp_compression = $_SERVER['HTTP_ACCEPT_ENCODING']; } else { $resp_compression = ''; } $req_encoding = guess_encoding(isset($_SERVER['CONTENT_TYPE']) ? $_SERVER['CONTENT_TYPE'] : '', $data); return null; } function parseRequest($data, $req_encoding='') { $GLOBALS['_xh']=array(); $GLOBALS['_xh']['ac']=''; $GLOBALS['_xh']['stack']=array(); $GLOBALS['_xh']['valuestack'] = array(); $GLOBALS['_xh']['params']=array(); $GLOBALS['_xh']['pt']=array(); $GLOBALS['_xh']['isf']=0; $GLOBALS['_xh']['isf_reason']=''; $GLOBALS['_xh']['method']=false; $GLOBALS['_xh']['rt']=''; if ($req_encoding != '') { if (!in_array($req_encoding, array('UTF-8', 'ISO-8859-1', 'US-ASCII'))) { error_log('XML-RPC: xmlrpc_server::parseRequest: invalid charset encoding of received request: '.$req_encoding); $req_encoding = $GLOBALS['xmlrpc_defencoding']; } $parser = xml_parser_create($req_encoding); } else { $parser = xml_parser_create(); } xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true); if (!in_array($GLOBALS['xmlrpc_internalencoding'], array('UTF-8', 'ISO-8859-1', 'US-ASCII'))) { xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, 'UTF-8'); } else { xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, $GLOBALS['xmlrpc_internalencoding']); } if ($this->functions_parameters_type != 'xmlrpcvals') xml_set_element_handler($parser, 'xmlrpc_se', 'xmlrpc_ee_fast'); else xml_set_element_handler($parser, 'xmlrpc_se', 'xmlrpc_ee'); xml_set_character_data_handler($parser, 'xmlrpc_cd'); xml_set_default_handler($parser, 'xmlrpc_dh'); if(!xml_parse($parser, $data, 1)) { $r=&new xmlrpcresp(0, $GLOBALS['xmlrpcerrxml']+xml_get_error_code($parser), sprintf('XML error: %s at line %d, column %d', xml_error_string(xml_get_error_code($parser)), xml_get_current_line_number($parser), xml_get_current_column_number($parser))); xml_parser_free($parser); } elseif ($GLOBALS['_xh']['isf']) { xml_parser_free($parser); $r=&new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['invalid_request'], $GLOBALS['xmlrpcstr']['invalid_request'] . ' ' . $GLOBALS['_xh']['isf_reason']); } else { xml_parser_free($parser); if ($this->functions_parameters_type != 'xmlrpcvals') { if($this->debug > 1) { $this->debugmsg("\n+++PARSED+++\n".var_export($GLOBALS['_xh']['params'], true)."\n+++END+++"); } $r = $this->execute($GLOBALS['_xh']['method'], $GLOBALS['_xh']['params'], $GLOBALS['_xh']['pt']); } else { $m=&new xmlrpcmsg($GLOBALS['_xh']['method']); for($i=0; $i<count($GLOBALS['_xh']['params']); $i++) { $m->addParam($GLOBALS['_xh']['params'][$i]); } if($this->debug > 1) { $this->debugmsg("\n+++PARSED+++\n".var_export($m, true)."\n+++END+++"); } $r = $this->execute($m); } } return $r; } function execute($m, $params=null, $paramtypes=null) { if (is_object($m)) { $methName = $m->method(); } else { $methName = $m; } $sysCall = $this->allow_system_funcs && (strpos($methName, "system.") === 0); $dmap = $sysCall ? $GLOBALS['_xmlrpcs_dmap'] : $this->dmap; if(!isset($dmap[$methName]['function'])) { return new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['unknown_method'], $GLOBALS['xmlrpcstr']['unknown_method']); } if(isset($dmap[$methName]['signature'])) { $sig = $dmap[$methName]['signature']; if (is_object($m)) { list($ok, $errstr) = $this->verifySignature($m, $sig); } else { list($ok, $errstr) = $this->verifySignature($paramtypes, $sig); } if(!$ok) { return new xmlrpcresp( 0, $GLOBALS['xmlrpcerr']['incorrect_params'], $GLOBALS['xmlrpcstr']['incorrect_params'] . ": ${errstr}" ); } } $func = $dmap[$methName]['function']; if(is_string($func) && strpos($func, '::')) { $func = explode('::', $func); } if(!is_callable($func)) { error_log("XML-RPC: xmlrpc_server::execute: function $func registered as method handler is not callable"); return new xmlrpcresp( 0, $GLOBALS['xmlrpcerr']['server_error'], $GLOBALS['xmlrpcstr']['server_error'] . ": no function matches method" ); } if($this->debug > 2) { $GLOBALS['_xmlrpcs_prev_ehandler'] = set_error_handler('_xmlrpcs_errorHandler'); } if (is_object($m)) { if($sysCall) { $r = call_user_func($func, $this, $m); } else { $r = call_user_func($func, $m); } if (!is_a($r, 'xmlrpcresp')) { error_log("XML-RPC: xmlrpc_server::execute: function $func registered as method handler does not return an xmlrpcresp object"); if (is_a($r, 'xmlrpcval')) { $r =& new xmlrpcresp($r); } else { $r =& new xmlrpcresp( 0, $GLOBALS['xmlrpcerr']['server_error'], $GLOBALS['xmlrpcstr']['server_error'] . ": function does not return xmlrpcresp object" ); } } } else { if($sysCall) { array_unshift($params, $this); $r = call_user_func_array($func, $params); } else { if ($this->functions_parameters_type == 'epivals') { $r = call_user_func_array($func, array($methName, $params, $this->user_data)); if (is_array($r) && array_key_exists('faultCode', $r) && array_key_exists('faultString', $r)) { $r =& new xmlrpcresp(0, (integer)$r['faultCode'], (string)$r['faultString']); } else { $r =& new xmlrpcresp(php_xmlrpc_encode($r, array('extension_api'))); } } else { $r = call_user_func_array($func, $params); } } if (!is_a($r, 'xmlrpcresp')) { $r =& new xmlrpcresp(php_xmlrpc_encode($r, array('auto_dates'))); } } if($this->debug > 2) { if($GLOBALS['_xmlrpcs_prev_ehandler']) { set_error_handler($GLOBALS['_xmlrpcs_prev_ehandler']); } else { restore_error_handler(); } } return $r; } function debugmsg($string) { $this->debug_info .= $string."\n"; } function xml_header($charset_encoding='') { if ($charset_encoding != '') { return "<?xml version=\"1.0\" encoding=\"$charset_encoding\"?" . ">\n"; } else { return "<?xml version=\"1.0\"?" . ">\n"; } } function echoInput() { $r=&new xmlrpcresp(new xmlrpcval( "'Aha said I: '" . $GLOBALS['HTTP_RAW_POST_DATA'], 'string')); print $r->serialize(); } } ?>