/usr/share/php/XML/RPC2/Backend/Xmlrpcext/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 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | <?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 XMLRPCext extension-based 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_Xmlrpcext_Server extends XML_RPC2_Server
{
// {{{ properties
/**
* xmlrpcext server
*
* @var resource
*/
private $_xmlrpcextServer;
// }}}
// {{{ 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
*/
function __construct($callHandler, $options = array())
{
parent::__construct($callHandler, $options);
$this->_xmlrpcextServer = xmlrpc_server_create();
foreach ($callHandler->getMethods() as $method) {
if (xmlrpc_server_register_method($this->_xmlrpcextServer,
$method->getName(),
array($this, 'epiFunctionHandlerAdapter')) !== true) {
throw new XML_RPC2_Exception('Unable to setup XMLRPCext server. xmlrpc_server_register_method returned non-true.');
}
}
}
// }}}
// {{{ epiFunctionHandlerAdapter()
/**
* This is an adapter between XML_RPC2_CallHandler::__call and xmlrpc_server_register_method callback interface
*
* @param string Method name
* @param array Parameters
* @param array Application data (ignored)
*/
protected function epiFunctionHandlerAdapter($method_name, $params, $app_data) {
return @call_user_func_array(array($this->callHandler, $method_name), $params);
}
// }}}
// {{{ handleCall()
/**
* Respond to the XML-RPC request.
*
* handleCall reads the XML-RPC request from the raw HTTP body and decodes it. It then calls the
* corresponding method in the call handler class, returning the encoded result to the client.
*/
public function handleCall()
{
if ($this->autoDocument && $this->input->isEmpty()) {
$this->autoDocument();
} else {
$response = $this->getResponse();
header('Content-type: text/xml; charset=' . $this->encoding);
header('Content-length: ' . $this->getContentLength($response));
print $response;
}
}
// }}}
// {{{ getResponse()
/**
* get the XML response of the XMLRPC server
*
* @return string the XML response
*/
public function getResponse()
{
try {
if ($this->signatureChecking) {
$tmp = xmlrpc_parse_method_descriptions($this->input->readRequest());
$methodName = $tmp['methodName'];
$parameters = xmlrpc_decode($this->input->readRequest(), $this->encoding);
$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, $parameters))) {
return (XML_RPC2_Backend_Php_Response::encodeFault(-32602, 'server error. invalid method parameters'));
}
}
set_error_handler(array('XML_RPC2_Backend_Xmlrpcext_Server', 'errorToException'));
$response = @xmlrpc_server_call_method($this->_xmlrpcextServer,
$this->input->readRequest(),
null,
array('output_type' => 'xml', 'encoding' => $this->encoding));
restore_error_handler();
return $response;
} catch (XML_RPC2_FaultException $e) {
return (XML_RPC2_Backend_Php_Response::encodeFault($e->getFaultCode(), $e->getMessage()));
} catch (Exception $e) {
if (ini_get('display_errors') == 1) {
return (XML_RPC2_Backend_Php_Response::encodeFault(1, 'Unhandled ' . get_class($e) . ' exception:' . $e->getMessage()));
} else {
return XML_RPC2_Backend_Php_Response::encodeFault(1, 'Unhandled PHP Exception');
}
}
}
// }}}
}
?>
|