示例#1
0
文件: json_rpc.php 项目: rair/yacs
    // not a valid request
} elseif (!$parameters || empty($parameters['method'])) {
    $response['error'] = array('code' => -32700, 'message' => 'Parse error');
    // dispatch the request
} else {
    // remember parameters if debug mode
    if (isset($context['debug_rpc']) && $context['debug_rpc'] == 'Y') {
        Logger::remember('services/json_rpc.php: json_rpc ' . $parameters['method'], $parameters['params'], 'debug');
    }
    // sanitize parameters
    if (!isset($parameters['params'])) {
        $parameters['params'] = array();
    }
    // depending on method name
    if (is_callable(array('Hooks', 'serve_scripts'))) {
        $response['result'] = Hooks::serve_scripts($parameters['method'], $parameters['params']);
    }
    // unknown method
    if ($response['result'] === NULL) {
        $response['error'] = array('code' => -32601, 'message' => 'Method not found "' . $parameters['method'] . '"');
        if (isset($context['debug_rpc']) && $context['debug_rpc'] == 'Y') {
            Logger::remember('services/json_rpc.php: json_rpc unsupported method ' . $parameters['method'], NULL, 'debug');
        }
        // error passed in result
    } elseif (is_array($response['result']) && !empty($response['result']['code']) && !empty($response['result']['message'])) {
        $response['error'] = $response['result'];
        $response['result'] = NULL;
    }
}
// copy request id in response, if any
if (empty($parameters['id'])) {
示例#2
0
文件: xml_rpc.php 项目: rair/yacs
$parameters = @$result[1];
// nothing to parse
if (!$raw_data) {
    $response = array('faultCode' => 1, 'faultString' => 'Empty request, please retry');
    // parse has failed
} elseif (!$status) {
    $response = array('faultCode' => 1, 'faultString' => 'Impossible to parse parameters');
    // dispatch the request
} else {
    // remember parameters if debug mode
    if (isset($context['debug_rpc']) && $context['debug_rpc'] == 'Y') {
        Logger::remember('services/xml_rpc.php: xml_rpc ' . $parameters['methodName'], $parameters['params'], 'debug');
    }
    // depending on method name
    if (is_callable(array('Hooks', 'serve_scripts'))) {
        $response = Hooks::serve_scripts($parameters['methodName'], $parameters['params']);
    }
}
// unknown method
if (!isset($response)) {
    $response = array('faultCode' => 1, 'faultString' => 'Do not know how to process ' . $parameters['methodName']);
    if (isset($context['debug_rpc']) && $context['debug_rpc'] == 'Y') {
        Logger::remember('services/xml_rpc.php: xml_rpc unsupported methodName ' . $parameters['methodName'], $parameters, 'debug');
    }
}
// encode the response as an XML snippet
if (!is_string($response) || !preg_match('/^<\\?xml/', $response)) {
    $result = $codec->export_response($response);
    $status = @$result[0];
    $response = @$result[1];
}