Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
moved XMLRPC server class from lib/exe to inc/Remote
- Loading branch information
1 parent
272a98e
commit 1cdd009
Showing
3 changed files
with
71 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
namespace dokuwiki\Remote; | ||
|
||
/** | ||
* Contains needed wrapper functions and registers all available XMLRPC functions. | ||
*/ | ||
class XmlRpcServer 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(); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function call($methodname, $args) | ||
{ | ||
try { | ||
$result = $this->remote->call($methodname, $args); | ||
return $result; | ||
} /** @noinspection PhpRedundantCatchClauseInspection */ 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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters