3 namespace dokuwiki\Remote
;
5 use IXR\DataType\Base64
;
7 use IXR\Exception\ServerException
;
12 * Contains needed wrapper functions and registers all available XMLRPC functions.
14 class XmlRpcServer
extends Server
19 * Constructor. Register methods and run Server
21 public function __construct($wait = false)
23 $this->remote
= new Api();
24 parent
::__construct(false, false, $wait);
28 public function serve($data = false)
32 if (!$conf['remote']) {
33 throw new ServerException("XML-RPC server not enabled.", -32605);
35 if (!empty($conf['remotecors'])) {
36 header('Access-Control-Allow-Origin: ' . $conf['remotecors']);
38 [$contentType] = explode(';', $INPUT->server
->str('CONTENT_TYPE'), 2); // ignore charset
39 $contentType = strtolower($contentType); // mime types are case-insensitive
40 if ($contentType !== 'text/xml' && $contentType !== 'application/xml') {
41 throw new ServerException('XML-RPC server accepts XML requests only.', -32606);
50 protected function call($methodname, $args)
53 $result = $this->remote
->call($methodname, $args);
55 } catch (AccessDeniedException
$e) {
56 if (!isset($_SERVER['REMOTE_USER'])) {
58 return new Error(-32603, "server error. not authorized to call method $methodname");
61 return new Error(-32604, "server error. forbidden to call the method $methodname");
63 } catch (RemoteException
$e) {
64 return new Error($e->getCode(), $e->getMessage());