diff options
author | Andreas Gohr <andi@splitbrain.org> | 2018-05-07 23:13:22 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2018-05-07 23:13:22 +0200 |
commit | 1cdd0090d7e8ffd0f99da73d0911bcd46d97a9ee (patch) | |
tree | dafc87b8979838963b0284530759a2f42d50df2b /lib/exe/xmlrpc.php | |
parent | 272a98e22f41465d58354ae15a7885070287f376 (diff) | |
download | dokuwiki-1cdd0090d7e8ffd0f99da73d0911bcd46d97a9ee.tar.gz dokuwiki-1cdd0090d7e8ffd0f99da73d0911bcd46d97a9ee.zip |
moved XMLRPC server class from lib/exe to inc/Remote
Diffstat (limited to 'lib/exe/xmlrpc.php')
-rw-r--r-- | lib/exe/xmlrpc.php | 67 |
1 files changed, 5 insertions, 62 deletions
diff --git a/lib/exe/xmlrpc.php b/lib/exe/xmlrpc.php index 49ba1f5fe..dc0438ee1 100644 --- a/lib/exe/xmlrpc.php +++ b/lib/exe/xmlrpc.php @@ -1,8 +1,9 @@ <?php +/** + * XMLRPC API backend + */ -use dokuwiki\Remote\AccessDeniedException; -use dokuwiki\Remote\Api; -use dokuwiki\Remote\RemoteException; +use dokuwiki\Remote\XmlRpcServer; if(!defined('DOKU_INC')) define('DOKU_INC', dirname(__FILE__).'/../../'); @@ -11,62 +12,4 @@ session_write_close(); //close session if(!$conf['remote']) die((new IXR_Error(-32605, "XML-RPC server not enabled."))->getXml()); -/** - * Contains needed wrapper functions and registers all available - * XMLRPC functions. - */ -class dokuwiki_xmlrpc_server extends IXR_Server { - protected $remote; - - /** - * Constructor. Register methods and run Server - */ - public function __construct(){ - $this->remote = new Api(); - $this->remote->setDateTransformation(array($this, 'toDate')); - $this->remote->setFileTransformation(array($this, 'toFile')); - parent::__construct(); - } - - /** - * @param string $methodname - * @param array $args - * @return IXR_Error|mixed - */ - public function call($methodname, $args){ - try { - $result = $this->remote->call($methodname, $args); - return $result; - } catch (AccessDeniedException $e) { - if (!isset($_SERVER['REMOTE_USER'])) { - http_status(401); - return new IXR_Error(-32603, "server error. not authorized to call method $methodname"); - } else { - http_status(403); - return new IXR_Error(-32604, "server error. forbidden to call the method $methodname"); - } - } catch (RemoteException $e) { - return new IXR_Error($e->getCode(), $e->getMessage()); - } - } - - /** - * @param string|int $data iso date(yyyy[-]mm[-]dd[ hh:mm[:ss]]) or timestamp - * @return IXR_Date - */ - public function toDate($data) { - return new IXR_Date($data); - } - - /** - * @param string $data - * @return IXR_Base64 - */ - public function toFile($data) { - return new IXR_Base64($data); - } -} - -$server = new dokuwiki_xmlrpc_server(); - -// vim:ts=4:sw=4:et: +$server = new XmlRpcServer(); |