/usr/share/php/XML/RPC2/Backend/Php/Server.php is in php-xml-rpc2 1.1.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | <?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */
// LICENSE AGREEMENT. If folded, press za here to unfold and read license {{{
/**
* +-----------------------------------------------------------------------------+
* | Copyright (c) 2004-2006 Sergio Gonalves Carvalho |
* +-----------------------------------------------------------------------------+
* | This file is part of XML_RPC2. |
* | |
* | XML_RPC2 is free software; you can redistribute it and/or modify |
* | it under the terms of the GNU Lesser General Public License as published by |
* | the Free Software Foundation; either version 2.1 of the License, or |
* | (at your option) any later version. |
* | |
* | XML_RPC2 is distributed in the hope that it will be useful, |
* | but WITHOUT ANY WARRANTY; without even the implied warranty of |
* | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
* | GNU Lesser General Public License for more details. |
* | |
* | You should have received a copy of the GNU Lesser General Public License |
* | along with XML_RPC2; if not, write to the Free Software |
* | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
* | 02111-1307 USA |
* +-----------------------------------------------------------------------------+
* | Author: Sergio Carvalho <sergio.carvalho@portugalmail.com> |
* +-----------------------------------------------------------------------------+
*
* @category XML
* @package XML_RPC2
* @author Sergio Carvalho <sergio.carvalho@portugalmail.com>
* @copyright 2004-2006 Sergio Carvalho
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id$
* @link http://pear.php.net/package/XML_RPC2
*/
// }}}
// dependencies {{{
require_once 'XML/RPC2/Backend/Php/Request.php';
require_once 'XML/RPC2/Backend/Php/Response.php';
require_once 'XML/RPC2/Exception.php';
// }}}
/**
* XML_RPC server class PHP-only backend.
*
* The XML_RPC2_Server does the work of decoding and encoding xml-rpc request and response. The actual
* method execution is delegated to the call handler instance.
*
* The XML_RPC server is responsible for decoding the request and calling the appropriate method in the
* call handler class. It then encodes the result into an XML-RPC response and returns it to the client.
*
* @category XML
* @package XML_RPC2
* @author Sergio Carvalho <sergio.carvalho@portugalmail.com>
* @copyright 2004-2006 Sergio Carvalho
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @link http://pear.php.net/package/XML_RPC2
*/
class XML_RPC2_Backend_Php_Server extends XML_RPC2_Server
{
// {{{ constructor
/**
* Create a new XML-RPC Server.
*
* The constructor receives a mandatory parameter: the Call Handler. The call handler executes the actual
* method call. XML_RPC2 server acts as a protocol decoder/encoder between the call handler and the client
*
* @param object $callHandler
* @param array $options associative array of options
* @access public
*/
function __construct($callHandler, $options = array())
{
parent::__construct($callHandler, $options);
if (strtolower($this->encoding) != 'utf-8') {
throw new XML_RPC2_Exception('XML_RPC2_Backend_Php does not support any encoding other than utf-8, due to a simplexml limitation');
}
}
// }}}
// {{{ handleCall()
/**
* Receive the XML-RPC request, decode the HTTP payload, delegate execution to the call handler, and output the encoded call handler response.
*
*/
public function handleCall()
{
if ($this->autoDocument && $this->input->isEmpty()) {
$this->autoDocument();
} else {
$response = $this->getResponse();
header('Content-type: text/xml; charset=' . strtolower($this->encoding));
header('Content-length: ' . $this->getContentLength($response));
print $response;
}
}
// }}}
// {{{ getResponse()
/**
* Get the XML response of the XMLRPC server
*
* @return string XML response
*/
public function getResponse()
{
try {
set_error_handler(array('XML_RPC2_Backend_Php_Server', 'errorToException'));
$request = @simplexml_load_string($this->input->readRequest());
// TODO : do not use exception but a XMLRPC error !
if (!is_object($request)) throw new XML_RPC2_FaultException('Unable to parse request XML', 0);
$request = XML_RPC2_Backend_Php_Request::createFromDecode($request);
$methodName = $request->getMethodName();
$arguments = $request->getParameters();
if ($this->signatureChecking) {
$method = $this->callHandler->getMethod($methodName);
if (!($method)) {
// see http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php for standard error codes
return (XML_RPC2_Backend_Php_Response::encodeFault(-32601, 'server error. requested method not found'));
}
if (!($method->matchesSignature($methodName, $arguments))) {
return (XML_RPC2_Backend_Php_Response::encodeFault(-32602, 'server error. invalid method parameters'));
}
}
restore_error_handler();
return (XML_RPC2_Backend_Php_Response::encode(call_user_func_array(array($this->callHandler, $methodName), $arguments), $this->encoding));
} catch (XML_RPC2_FaultException $e) {
return (XML_RPC2_Backend_Php_Response::encodeFault($e->getFaultCode(), $e->getMessage(), $this->encoding));
} catch (Exception $e) {
if (ini_get('display_errors') == 1) {
return (XML_RPC2_Backend_Php_Response::encodeFault(1, 'Unhandled ' . get_class($e) . ' exception:' . $e->getMessage() . $e->getTraceAsString(), $this->encoding));
} else {
return XML_RPC2_Backend_Php_Response::encodeFault(1, 'Unhandled PHP Exception', $this->encoding);
}
}
}
}
?>
|