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); }
function jsrsBuildFunc($validFuncs) { $F = ''; if (isset($_POST['F'])) { $F = $_POST['F']; $method = 'post'; } if (isset($_GET['F'])) { $F = $_GET['F']; $method = 'get'; } $func = ""; if ($F != "") { $func = $F; // make sure it's in the dispatch list if (strpos(strtoupper($validFuncs), strtoupper($func)) === false) { jsrsReturnError($func . " is not a valid function"); } $func .= "("; switch ($method) { case 'post': foreach ($_POST['P'] as $index => $value) { $func .= '"' . substr($value, 1, strlen($value) - 2) . '",'; } break; case 'get': foreach ($_GET['P'] as $index => $value) { $func .= '"' . substr($value, 1, strlen($value) - 2) . '",'; } break; } if (substr($func, strlen($func) - 1, 1) == ",") { $func = substr($func, 0, strlen($func) - 1); } $func .= ")"; } return $func; }