Lines Matching +full:php +full:- +full:version
1 <?php
12 /** @var float The XML-RPC Version. 0 is our own simplified variant */
13 protected $version = 0; variable in dokuwiki\\Remote\\JsonRpcServer
20 $this->remote = new Api();
26 …am string $body Should only be set for testing, otherwise the request body is read from php://input
37 throw new RemoteException("JSON-RPC server not enabled.", -32605);
40 header('Access-Control-Allow-Origin: ' . $conf['remotecors']);
42 if ($INPUT->server->str('REQUEST_METHOD') !== 'POST') {
45 throw new RemoteException("JSON-RPC server only accepts POST requests.", -32606);
47 [$contentType] = explode(';', $INPUT->server->str('CONTENT_TYPE'), 2); // ignore charset
48 $contentType = strtolower($contentType); // mime types are case-insensitive
51 … throw new RemoteException("JSON-RPC server only accepts application/json requests.", -32606);
56 $body = file_get_contents('php://input');
65 throw new RemoteException("JSON-RPC server only accepts valid JSON.", -32700);
68 return $this->createResponse($data);
74 * This should handle all JSON-RPC versions and our simplified version
76 * @link https://en.wikipedia.org/wiki/JSON-RPC
88 // this is a standard conform request (at least version 1.0)
91 $this->version = 1;
96 // version 2.0 request
99 $this->version = (float)$data['jsonrpc'];
102 // version 1.1 request
103 if (isset($data['version'])) {
104 $return['version'] = $data['version'];
105 $this->version = (float)$data['version'];
109 $method = $INPUT->server->str('PATH_INFO');
112 $this->version = 0;
116 $return['result'] = $this->call($method, $params);
117 $this->addErrorData($return); // handles non-error info
130 $this->addErrorData($return, $exception);
135 * Depending on the requested version, add error data to the response
146 'code' => $e->getCode() ?: 1, // 0 is success, so we use 1 as default
147 'message' => $e->getMessage()
150 // no error, act according to version
151 if ($this->version > 0 && $this->version < 2) {
152 // version 1.* wants null
154 } elseif ($this->version < 1) {
155 // simplified version wants success
161 // version 2 wants no error at all
176 return $this->remote->call($methodname, $args);
180 … throw new RemoteException("server error. not authorized to call method $methodname", -32603);
183 … throw new RemoteException("server error. forbidden to call the method $methodname", -32604);