本文整理汇总了PHP中xmlrpc_decode_request函数的典型用法代码示例。如果您正苦于以下问题:PHP xmlrpc_decode_request函数的具体用法?PHP xmlrpc_decode_request怎么用?PHP xmlrpc_decode_request使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xmlrpc_decode_request函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: xmlrpc_request
function xmlrpc_request($host, $port, $location, $function, &$request_data)
{
/*
* This method sends a very basic XML-RPC request. $host, $port, $location,
* and $function are pretty simple. $request_data can be any PHP type,
* and this function returns the PHP type of whatever the xmlrpc function
* returns.
*
* WARNING: This function dies upon failure.
*/
// Send request
$request_xml = xmlrpc_encode_request($function, $request_data);
// Split out response into headers, and xml
$response = urlpost($host, $port, $location, $request_xml);
$response_array = split("\r\n\r\n", $response, 2);
$response_headers = split("\r\n", $response_array[0]);
$response_xml = $response_array[1];
$http_array = split(" ", $response_headers[0], 3);
if ($http_array[1] != "200") {
trigger_error("xmlrpc request failed: ({$http_array[1]}, {$http_array[2]}) at {$host}:{$port} using {$location}");
} else {
// Get native PHP types and return them for data.
$response_data = xmlrpc_decode_request($response_xml, $function);
return $response_data;
}
}
开发者ID:BGCX261,项目名称:zoto-server-svn-to-git,代码行数:26,代码来源:upload.php
示例2: registerObjects
public function registerObjects()
{
$postRequest = $this->getRequest();
//Utils::debug($postRequest, 'rpc.log', false);
//extract method
$methodRequest = '';
$classname = '';
$method = '';
$result = xmlrpc_decode_request($postRequest, $methodRequest);
if ($methodRequest) {
list($classname, $method) = explode('.', $methodRequest);
}
//Utils::debug("class = $classname, method = $method");
try {
$this->director->pluginManager->loadPlugin($classname);
} catch (Exception $e) {
// normal plugin failed, try to load admin plugin
try {
$this->director->adminManager->loadPlugin($classname);
} catch (Exception $err) {
$this->log->error("error loading coreplugin : {$err}");
}
//throw new Exception($e->getMessage());
}
}
开发者ID:rverbrugge,项目名称:dif,代码行数:25,代码来源:RpcServer.php
示例3: __call
public function __call($method, $params)
{
if (!function_exists('xmlrpc_encode_request')) {
throw new \Exception("The php5-xmlrpc extension is not installed. Please install this to use this functionality");
}
$xml = xmlrpc_encode_request($method, $params);
//\GO::debug($xml);
if ($this->curl_hdl === null) {
// Create cURL resource
$this->curl_hdl = curl_init();
// Configure options
curl_setopt($this->curl_hdl, CURLOPT_URL, $this->uri);
curl_setopt($this->curl_hdl, CURLOPT_HEADER, 0);
curl_setopt($this->curl_hdl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($this->curl_hdl, CURLOPT_POST, true);
curl_setopt($this->curl_hdl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($this->curl_hdl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($this->curl_hdl, CURLOPT_TIMEOUT, 10);
if (isset($this->_user)) {
curl_setopt($this->curl_hdl, CURLOPT_USERPWD, $this->_user . ":" . $this->_pass);
}
}
curl_setopt($this->curl_hdl, CURLOPT_POSTFIELDS, $xml);
// Invoke RPC command
$response = curl_exec($this->curl_hdl);
$errorNo = curl_errno($this->curl_hdl);
if ($errorNo) {
throw new \Exception($this->_curlErrorCodes[$errorNo]);
}
//\GO::debug($response);
$result = xmlrpc_decode_request($response, $method);
return $result;
}
开发者ID:ajaboa,项目名称:crmpuan,代码行数:33,代码来源:XMLRPCClient.php
示例4: parse_request
/**
* This method parses the request input, it needs to get:
* 1/ user authentication - username+password or token
* 2/ function name
* 3/ function parameters
*/
protected function parse_request()
{
// Retrieve and clean the POST/GET parameters from the parameters specific to the server.
parent::set_web_service_call_settings();
// Get GET and POST parameters.
$methodvariables = array_merge($_GET, $_POST);
if ($this->authmethod == WEBSERVICE_AUTHMETHOD_USERNAME) {
$this->username = isset($methodvariables['wsusername']) ? $methodvariables['wsusername'] : null;
unset($methodvariables['wsusername']);
$this->password = isset($methodvariables['wspassword']) ? $methodvariables['wspassword'] : null;
unset($methodvariables['wspassword']);
} else {
$this->token = isset($methodvariables['wstoken']) ? $methodvariables['wstoken'] : null;
unset($methodvariables['wstoken']);
}
// Get the XML-RPC request data.
$rawpostdata = file_get_contents("php://input");
$methodname = null;
// Decode the request to get the decoded parameters and the name of the method to be called.
$decodedparams = xmlrpc_decode_request($rawpostdata, $methodname);
$methodinfo = external_api::external_function_info($methodname);
$methodparams = array_keys($methodinfo->parameters_desc->keys);
// Add the decoded parameters to the methodvariables array.
if (is_array($decodedparams)) {
foreach ($decodedparams as $index => $param) {
// See MDL-53962 - XML-RPC requests will usually be sent as an array (as in, one with indicies).
// We need to use a bit of "magic" to add the correct index back. Zend used to do this for us.
$methodvariables[$methodparams[$index]] = $param;
}
}
$this->functionname = $methodname;
$this->parameters = $methodvariables;
}
开发者ID:IFPBMoodle,项目名称:moodle,代码行数:39,代码来源:locallib.php
示例5: parse_request
/**
* This method parses the request input, it needs to get:
* 1/ user authentication - username+password or token
* 2/ function name
* 3/ function parameters
*/
protected function parse_request()
{
// Retrieve and clean the POST/GET parameters from the parameters specific to the server.
parent::set_web_service_call_settings();
// Get GET and POST parameters.
$methodvariables = array_merge($_GET, $_POST);
if ($this->authmethod == WEBSERVICE_AUTHMETHOD_USERNAME) {
$this->username = isset($methodvariables['wsusername']) ? $methodvariables['wsusername'] : null;
unset($methodvariables['wsusername']);
$this->password = isset($methodvariables['wspassword']) ? $methodvariables['wspassword'] : null;
unset($methodvariables['wspassword']);
} else {
$this->token = isset($methodvariables['wstoken']) ? $methodvariables['wstoken'] : null;
unset($methodvariables['wstoken']);
}
// Get the XML-RPC request data.
$rawpostdata = file_get_contents("php://input");
$methodname = null;
// Decode the request to get the decoded parameters and the name of the method to be called.
$decodedparams = xmlrpc_decode_request($rawpostdata, $methodname);
// Add the decoded parameters to the methodvariables array.
if (is_array($decodedparams)) {
foreach ($decodedparams as $param) {
// Check if decoded param is an associative array.
if (is_array($param) && array_keys($param) !== range(0, count($param) - 1)) {
$methodvariables = array_merge($methodvariables, $param);
} else {
$methodvariables[] = $param;
}
}
}
$this->functionname = $methodname;
$this->parameters = $methodvariables;
}
开发者ID:GaganJotSingh,项目名称:moodle,代码行数:40,代码来源:locallib.php
示例6: __construct
function __construct($payload, $payload_signed, $payload_encrypted)
{
$this->payload = $payload;
// xmlrpc_decode_request is defined such that the '$method' string is
// passed in by reference.
$this->params = xmlrpc_decode_request($this->payload, $this->method, 'UTF-8');
// The method name is not allowed to have a dot, except for a single dot
// which preceeds the php extension. It can have slashes but it cannot
// begin with a slash. We specifically don't want .. to be possible.
if (0 == preg_match("@^[A-Za-z0-9]+/[A-Za-z0-9/_-]+(\\.php/)?[A-Za-z0-9_-]+\$@", $this->method)) {
throw new XmlrpcServerException('The function does not exist', 6010);
}
if ($payload_signed && $payload_encrypted || $this->method == 'system/keyswap') {
// The remote server's credentials checked out.
// You might want to enable some methods for unsigned/unencrypted
// transport
} else {
// For now, we throw an exception
throw new XmlrpcServerException('The signature on your message was not valid', 6005);
}
// The system methods are treated differently.
if (array_key_exists($this->method, $this->system_methods)) {
$xmlrpcserver = xmlrpc_server_create();
xmlrpc_server_register_method($xmlrpcserver, $this->method, array(&$this, $this->system_methods[$this->method]));
} else {
// Security: I'm thinking that we should not return separate errors for
// the file not existing, the file not being readable, etc. as
// it might provide an opportunity for outsiders to scan the
// server for random files. So just a single message/code for
// all failures here kthxbye.
if (strpos($this->method, '/') !== false) {
$this->callstack = explode('/', $this->method);
} else {
throw new XmlrpcServerException('The function does not exist', 6011);
}
// Read custom xmlrpc functions from local
if (function_exists('local_xmlrpc_services')) {
foreach (local_xmlrpc_services() as $name => $localservices) {
$this->services[$name] = array_merge($this->services[$name], $localservices);
}
}
foreach ($this->services as $container) {
if (array_key_exists($this->method, $container)) {
$xmlrpcserver = xmlrpc_server_create();
$bool = xmlrpc_server_register_method($xmlrpcserver, $this->method, 'api_dummy_method');
$this->response = xmlrpc_server_call_method($xmlrpcserver, $payload, $container[$this->method], array("encoding" => "utf-8"));
$bool = xmlrpc_server_destroy($xmlrpcserver);
return $this->response;
}
}
throw new XmlrpcServerException('No such method: ' . $this->method);
}
$temp = '';
$this->response = xmlrpc_server_call_method($xmlrpcserver, $payload, $temp, array("encoding" => "utf-8"));
return $this->response;
}
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:56,代码来源:dispatcher.php
示例7: readRequest
/**
* Reads the HTTP request from client and decodes the XML data
*
* @return void
*/
public function readRequest()
{
$this->_debug("-----> " . __CLASS__ . '::' . __FUNCTION__ . "()", 9);
// Parent will do the request reading
parent::readRequest();
// Assign and decode the request
$this->requestRawXml =& $this->requestRawBody;
$this->params = xmlrpc_decode_request($this->requestRawXml, $this->method);
// Set the response header
$this->setResponseHeader('Content-type', 'text/xml');
}
开发者ID:bostjanskufca,项目名称:PHP-application-server,代码行数:16,代码来源:XmlRpc.php
示例8: decodeStream
function decodeStream($rawResponse)
{
/// @todo test if this automatically groks encoding from xml or not...
$meth = '';
$resp = xmlrpc_decode_request($rawResponse, $meth);
if (!is_array($resp)) {
return false;
}
$this->Name = $meth;
$this->Parameters = $resp;
return true;
}
开发者ID:gggeek,项目名称:ggwebservices,代码行数:12,代码来源:ggxmlrpcrequest.php
示例9: handle
/**
* Handle RPC request(s).
* Fluent interface.
*
* @param boolean|string $request RPC request (string), FALSE read from php://input once or TRUE to keep listing on php://input for multiple requests
* @return RPC_Server_XMLRPC
*
* @todo implement keep alive
*/
public function handle($request = false)
{
$keep_alive = (int) $request === 1;
if ($keep_alive || empty($request)) {
$request = "";
while ($line = fread(STDIN, 1024)) {
$request .= $line;
if (substr($request, -1) == "") {
break;
}
}
$request = substr($request, 0, strlen($request) - 1);
}
try {
$method = null;
$args = xmlrpc_decode_request($request, $method);
if (empty($method)) {
throw new Exception("Invalid XMLRPC request.");
}
if (!is_callable(array($this->object, $method))) {
throw new Exception("RPC call failed: Unable to call method '{$method}'.");
}
$result = call_user_func_array(array($this->object, $method), $args);
$output = xmlrpc_encode_request(null, $result);
} catch (ExpectedException $e) {
$output = xmlrpc_encode(array("faultCode" => $e->getCode(), "faultString" => $e->getMessage()));
} catch (\Exception $e) {
$output = xmlrpc_encode(array("faultCode" => -1, "faultString" => "Unexpected exception."));
$this->putExtraInfo('X-Exception', $e->getMessage());
if (class_exists(__NAMESPACE__ . '::ErrorHandler', false) && ErrorHandler::isInit()) {
ErrorHandler::i()->handleException($e);
}
}
$content_type = HTTP::header_getValue('Content-Type');
if (empty($content_type) || $content_type == 'text/xml') {
fwrite($this->stream, $output);
} else {
if (HTTP::headers_sendable()) {
if ($keep_alive) {
trigger_error("Using keep-alive together with sending non-XMLRPC is not allowed. Found header 'Content-Type: {$content_type}'.", E_USER_WARNING);
fwrite($this->stream, xmlrpc_encode(array("faultCode" => 0, "faultString" => "Could not send non-XMLRPC output because of keep-alive.")));
}
} else {
$this->putExtraInfo('Content-Type', $content_type);
}
}
return $this;
}
开发者ID:jasny,项目名称:Q,代码行数:57,代码来源:XMLRPC.php
示例10: findRoute
public function findRoute($path)
{
global $HTTP_RAW_POST_DATA;
$result = parent::findRoute($path);
//$rawdata = xmlrpc_encode_request("authorize", array( "cons", "cons" ));
//if ((!$result["action"] || !$result["params"]) && ($rawdata))
if ((!$result["action"] || !$result["params"]) && ($rawdata = $HTTP_RAW_POST_DATA)) {
$params = xmlrpc_decode_request($rawdata, &$action);
if (!$result["action"]) {
$result["action"] = $action;
}
if (!$result["params"]) {
$result["params"] = $params;
}
}
return $result;
}
开发者ID:kstep,项目名称:pnut,代码行数:17,代码来源:XmlRpc.php
示例11: fromXmlString
public function fromXmlString($xmlString)
{
$this->parameters = xmlrpc_decode_request($xmlString, $this->methodName);
$this->fixupParameter($this->parameters);
if ($this->methodName === null) {
throw new UnexpectedValueException("Invalid XML-RPC structure (/methodCall/methodName not found)");
}
if ($this->parameters === null) {
if (($simpleXml = @simplexml_load_string($xmlString)) === false) {
$errors = array();
foreach (libxml_get_errors() as $error) {
$errors[] = $error->message;
}
throw new UnexpectedValueException("Invalid XML-RPC message:" . implode("\n", $errors));
}
}
}
开发者ID:bdunogier,项目名称:xmlrpcbundle,代码行数:17,代码来源:RequestParser.php
示例12: executeRPC2
/**
* This is the main handle for the xmlrpc calls
*/
public function executeRPC2($request)
{
// get all the defined RPC
$rpc_functions = $this->getRPCFunctions();
// http POST method is required for modifying the database
$this->forward404Unless($request->isMethod('post'), "HTTP POST is required");
// log to debug
ezDbg::err("enter xmlrpc");
// get xmlrpc request string posted as a raw
$xmlrpc_reqstr = file_get_contents("php://input");
// parse the xmlrpc_reqstr
$method_name = null;
$xmlrpc_params = xmlrpc_decode_request($xmlrpc_reqstr, &$method_name);
ezDbg::err("enter method_name={$method_name} xmlrpc param=" . print_r($xmlrpc_params, true));
if (!isset($rpc_functions[$method_name])) {
$xmlrpc_resp = array("faultCode" => 1, "faultString" => "unknown method name (" . $method_name . ")");
} else {
$rpc_function = $rpc_functions[$method_name];
$nparam = $rpc_function['nparam'];
if (count($xmlrpc_params) < $nparam) {
$xmlrpc_resp = array("faultCode" => 1, "faultString" => $method_name . " require " . $nparam . " parameters.");
} else {
try {
ezDbg::err('trying to call (' . $rpc_function['function'] . ')', $xmlrpc_params);
$xmlrpc_resp = call_user_func_array($rpc_function['function'], $xmlrpc_params);
//$xmlrpc_resp = sfWebRPCPluginDemo::superAddFct(2,3);
} catch (Exception $e) {
$xmlrpc_resp = array("faultCode" => 1, "faultString" => "" . $e->getMessage());
}
}
}
// encode the xmlrpc_resp
$xmlrpc_respstr = xmlrpc_encode($xmlrpc_resp);
// KLUDGE: xmlrpc_encode is unable to add the methodResponse required
$arr = split("\n", $xmlrpc_respstr);
$arr[0] .= "\n<methodResponse>";
$arr[count($arr) - 1] = "</methodResponse>";
$xmlrpc_respstr = implode("\n", $arr);
ezDbg::err("enter xmlrpc resp=" . print_r($xmlrpc_respstr, true));
// disable the web_debug bar
sfConfig::set('sf_web_debug', false);
// return the $value in xml
$this->getResponse()->setHttpHeader('Content-Type', 'text/xml');
return $this->renderText($xmlrpc_respstr);
}
开发者ID:Esleelkartea,项目名称:legedia-ESLE,代码行数:48,代码来源:BaseWebRPCActions.class.php
示例13: parse
/**
* Parse request
*
* @param \Zend\Http\Request $request
* @param \Zend\Http\Response $request
* @return string|null $error
*/
public function parse(Request $request, Response $response)
{
$error = parent::parse($request, $response);
if ($error) {
return $error;
}
$method = null;
$params = xmlrpc_decode_request($request->getContent(), $method, 'utf-8');
if (!$params) {
return self::PARSE;
}
if (empty($method) || empty($params)) {
return self::INVALID_REQUEST;
}
$this->method = $method;
$this->params = $params;
return null;
}
开发者ID:gridguyz,项目名称:core,代码行数:25,代码来源:Xml.php
示例14: inputFilter
public function inputFilter($data, stdClass $context)
{
if ($data !== "" && $data[0] === '<') {
$context->userdata->format = "xmlrpc";
$method = null;
$params = xmlrpc_decode_request($data, $method, "UTF-8");
$stream = new BytesIO();
$writer = new Writer($stream, true);
if (isset($method)) {
$stream->write(Tags::TagCall);
$writer->writeString($method);
if (isset($params)) {
$writer->writeArray($params);
}
}
$stream->write(Tags::TagEnd);
$data = $stream->toString();
}
return $data;
}
开发者ID:wanggeopens,项目名称:own-libs,代码行数:20,代码来源:ServiceFilter.php
示例15: createRequest
/**
* @param Request $request
* @return XmlRpcRequest
* @throws RpcException
*/
public function createRequest(Request $request)
{
if (!$request->isMethod('POST')) {
throw new InvalidRequestException(self::MESSAGE_INVALID_HTTP_METHOD);
}
if ($request->getContentType() != 'xml') {
throw new InvalidRequestException(self::MESSAGE_INVALID_CONTENT_TYPE);
}
$params = xmlrpc_decode_request($request->getContent(), $method, 'UTF-8');
if (is_null($method)) {
throw new RequestParseException(self::MESSAGE_INVALID_BODY);
}
if (empty($method)) {
throw new InvalidRequestException(self::MESSAGE_METHOD_REQUIRED);
}
if (!is_array($params)) {
throw new InvalidRequestException(self::MESSAGE_METHOD_PARAMS_TYPE);
}
return new XmlRpcRequest($request, $method, $params);
}
开发者ID:moriony,项目名称:rpc-server,代码行数:25,代码来源:XmlRpcProtocol.php
示例16: index
public function index()
{
$request_xml = file_get_contents("php://input");
$method = null;
$params = xmlrpc_decode_request($request_xml, &$method);
if (strpos($method, '.')) {
$action = explode('.', $method);
if (file_exists(BASE_DIR . 'controllers/' . $action[0] . '.php')) {
include $action[0] . '.php';
$classname = ucwords($action[0] . 'Controller');
$obj = new $classname();
if (method_exists($obj, $action[1])) {
$results = $obj->{$action[1]}($params[0]);
header("Content-type:text/xml");
echo xmlrpc_encode_request(NULL, $results);
exit;
}
}
}
}
开发者ID:rajanvenkataguru,项目名称:kurry,代码行数:20,代码来源:xmlrpc.php
示例17: handle
/**
* handle incoming XML RPC requests
*
* @return null
*/
public function handle()
{
try {
// Get the XMLRPC request (raw POST data)
$rawHTTPContents = file_get_contents("php://input");
// some debugging
// file_put_contents("xmlrpc_messages.txt",
// "Request at XML-RPC server = " . $rawHTTPContents ."\n",
// FILE_APPEND);
// decode xmlrpc request
$params = xmlrpc_decode_request($rawHTTPContents, $method);
SCA::$logger->log("Request {$rawHTTPContents}");
SCA::$logger->log("handle request {$method}");
if ($method == null || strlen($method) == 0) {
$error["faultCode"] = 32600;
$error["faultString"] = "Invalid XML-RPC request : {$rawHTTPContents}";
$response = xmlrpc_encode_request(null, $error);
} else {
if (strpos($method, "system.") === 0) {
$response = $this->service_wrapper->callSystemMethod($rawHTTPContents);
// some debugging
// file_put_contents("xmlrpc_messages.txt",
// "Response at XML-RPC server = " . $response . "\n",
// FILE_APPEND);
} else {
$response = $this->service_wrapper->__call($method, $params);
}
}
} catch (Exception $ex) {
$error["faultCode"] = $ex instanceof SCA_RuntimeException ? 32000 : 32500;
$error["faultString"] = $ex->__toString();
$response = xmlrpc_encode_request(null, $error);
}
// some debugging
// file_put_contents("xmlrpc_messages.txt",
// "Response at XML-RPC server = " . $response . "\n",
// FILE_APPEND);
header('Content-type: text/xml');
echo $response;
return;
}
开发者ID:psagi,项目名称:sdo,代码行数:46,代码来源:Server.php
示例18: initialize
/**
* Initialize this Request.
*
* @param AgaviContext An AgaviContext instance.
* @param array An associative array of initialization parameters.
*
* @throws <b>AgaviInitializationException</b> If an error occurs while
* initializing this Request.
*
* @author David Zülke <[email protected]>
* @since 0.11.0
*/
public function initialize(AgaviContext $context, array $parameters = array())
{
parent::initialize($context, $parameters);
$decoded = (array) xmlrpc_decode_request($this->input, $this->invokedMethod, isset($parameters['encoding']) ? $parameters['encoding'] : 'utf-8');
$akeys = array_keys($decoded);
if (count($decoded) == 1 && is_int($key = array_pop($akeys)) && is_array($decoded[$key])) {
$decoded = $decoded[$key];
}
$rdhc = $this->getParameter('request_data_holder_class');
$rd = new $rdhc(array(constant("{$rdhc}::SOURCE_PARAMETERS") => (array) $decoded));
if ($this->getParameter('use_module_action_parameters')) {
$split = explode(':', $this->invokedMethod);
if (count($split) == 2) {
$rd->setParameter($this->getParameter('module_accessor'), $split[0]);
$rd->setParameter($this->getParameter('action_accessor'), $split[1]);
} else {
$rd->setParameter($this->getParameter('action_accessor'), $this->invokedMethod);
}
}
$this->setRequestData($rd);
}
开发者ID:philippjenni,项目名称:icinga-web,代码行数:33,代码来源:AgaviXmlrpcepiphpRequest.class.php
示例19: mnet_server_dispatch
/**
* If security checks are passed, dispatch the request to the function/method
*
* The config variable 'mnet_dispatcher_mode' can be:
* strict: Only execute functions that are in specific files
* off: The default - don't execute anything
*
* @param string $payload The XML-RPC request
*
* @throws mnet_server_exception
*
* @return No return val - just echo the response
*/
function mnet_server_dispatch($payload) {
global $CFG, $DB;
$remoteclient = get_mnet_remote_client();
// xmlrpc_decode_request returns an array of parameters, and the $method
// variable (which is passed by reference) is instantiated with the value from
// the methodName tag in the xml payload
// xmlrpc_decode_request($xml, &$method)
$params = xmlrpc_decode_request($payload, $method);
// $method is something like: "mod/forum/lib.php/forum_add_instance"
// $params is an array of parameters. A parameter might itself be an array.
// Whitelist characters that are permitted in a method name
// The method name must not begin with a / - avoid absolute paths
// A dot character . is only allowed in the filename, i.e. something.php
if (0 == preg_match("@^[A-Za-z0-9]+/[A-Za-z0-9/_\.-]+(\.php/)?[A-Za-z0-9_-]+$@",$method)) {
throw new mnet_server_exception(713, 'nosuchfunction');
}
if(preg_match("/^system\./", $method)) {
$callstack = explode('.', $method);
} else {
$callstack = explode('/', $method);
// callstack will look like array('mod', 'forum', 'lib.php', 'forum_add_instance');
}
/**
* What has the site administrator chosen as his dispatcher setting?
* strict: Only execute functions that are in specific files
* off: The default - don't execute anything
*/
////////////////////////////////////// OFF
if (!isset($CFG->mnet_dispatcher_mode) ) {
set_config('mnet_dispatcher_mode', 'off');
throw new mnet_server_exception(704, 'nosuchservice');
} elseif ('off' == $CFG->mnet_dispatcher_mode) {
throw new mnet_server_exception(704, 'nosuchservice');
////////////////////////////////////// SYSTEM METHODS
} elseif ($callstack[0] == 'system') {
$functionname = $callstack[1];
$xmlrpcserver = xmlrpc_server_create();
// register all the system methods
$systemmethods = array('listMethods', 'methodSignature', 'methodHelp', 'listServices', 'listFiles', 'retrieveFile', 'keyswap');
foreach ($systemmethods as $m) {
// I'm adding the canonical xmlrpc references here, however we've
// already forbidden that the period (.) should be allowed in the call
// stack, so if someone tries to access our XMLRPC in the normal way,
// they'll already have received a RPC server fault message.
// Maybe we should allow an easement so that regular XMLRPC clients can
// call our system methods, and find out what we have to offer?
$handler = 'mnet_system';
if ($m == 'keyswap') {
$handler = 'mnet_keyswap';
}
if ($method == 'system.' . $m || $method == 'system/' . $m) {
xmlrpc_server_register_method($xmlrpcserver, $method, $handler);
$response = xmlrpc_server_call_method($xmlrpcserver, $payload, $remoteclient, array("encoding" => "utf-8"));
$response = mnet_server_prepare_response($response);
echo $response;
xmlrpc_server_destroy($xmlrpcserver);
return;
}
}
throw new mnet_server_exception(7018, 'nosuchfunction');
//////////////////////////////////// NORMAL PLUGIN DISPATCHER
} else {
// anything else comes from some sort of plugin
if ($rpcrecord = $DB->get_record('mnet_rpc', array('xmlrpcpath' => $method))) {
$response = mnet_server_invoke_plugin_method($method, $callstack, $rpcrecord, $payload);
$response = mnet_server_prepare_response($response);
echo $response;
return;
// if the rpc record isn't found, check to see if dangerous mode is on
////////////////////////////////////// DANGEROUS
} else if ('dangerous' == $CFG->mnet_dispatcher_mode && $remoteclient->plaintext_is_ok()) {
$functionname = array_pop($callstack);
$filename = clean_param(implode('/',$callstack), PARAM_PATH);
if (0 == preg_match("/php$/", $filename)) {
// Filename doesn't end in 'php'; possible attack?
// Generate error response - unable to locate function
throw new mnet_server_exception(7012, 'nosuchfunction');
}
//.........这里部分代码省略.........
开发者ID:JP-Git,项目名称:moodle,代码行数:101,代码来源:serverlib.php
示例20: call
/**
* Call a method on the server. The result is returned decoded as
* native PHP data.
*
* @param string $method The method to call
* @param any $data The data
* @return any The result data
*/
function call($method, $args = null)
{
logger::debug("Sending XmlrpcRequest to %s ...", $method);
$req = xmlrpc_encode_request($method, $args);
logger::debug('%s', $req);
$opts = array('method' => 'post', 'parameters' => $req, 'content-type' => 'text/xml');
if ($this->username) {
$opts['username'] = $this->username;
$opts['password'] = $this->password;
}
$opts = array_merge($opts, $this->httpopts);
$ret = new HttpRequest($this->url, $opts);
logger::debug('Response: %s', $ret->responseText());
$mtd = null;
$dec = xmlrpc_decode_request($ret->responseText(), $mtd);
/*
if ($dec && arr::hasKey($dec,'faultCode')) {
printf("Fault\n");
}
*/
return $dec;
/*
// Encode the request
$xml = xmlrpc_encode_request( $method, $args );
// Send it to the server
$sparams = array('http' => array(
'method' => 'POST',
'content' => $xml,
'header' => array(
'content-type' => 'text/xml'
)
));
$ctx = stream_context_create($params);
$fp = @fopen($this->url, 'rb', false, $ctx);
if (!$fp) {
throw new Exception("Problem with $this->url, $php_errormsg");
}
$response = @stream_get_contents($fp);
if ($response === false) {
throw new Exception("Problem reading data from $url, $php_errormsg");
}
// Parse the output
$ret = xmlrpc_decode_request($response,$mtd);
return $ret;
*/
}
开发者ID:noccy80,项目名称:lepton-ng,代码行数:56,代码来源:xmlrpc.php
注:本文中的xmlrpc_decode_request函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论