function jsrsDispatch($validFuncs) { $func = jsrsBuildFunc($validFuncs); if ($func != "") { $retval = ""; eval("\$retval = " . $func . ";"); if (strlen($retval) > 0) { jsrsReturn($retval . ""); } else { jsrsReturn(""); } } else { jsrsReturnError("function builds as empty string"); } }
function doRPC($rpcserver, $rpctext) { if (!isset($rpcserver)) { jsrsReturnError("No rpcserver specified."); die; } if (!isset($rpctext)) { jsrsReturnError("No rpctext specified."); die; } $rpctext = urldecode($rpctext); $rpctext = str_replace("\n", "", $rpctext); $rpctext = str_replace("\r", "", $rpctext); $a = new http_post(); $a->set_action($rpcserver); $a->set_enctype("text/xml"); $a->set_useragent("JavaScript/PHP XMLRPC Client/1.0"); $a->set_body($rpctext); $response = $a->send(); $startXML = strpos($response, "<?"); $methodResponse = substr($response, $startXML); jsrsReturn($methodResponse); }