- function set_params(array $params) : void
- {
- do_log("Set params:", $params);
- $this->body['params'] = $params;
- }
-
- function execute()
- {
- $this->content['body'] = json_encode($this->body);
- if (!$this->content['body'])
- return;
- $url = "https://".UNREALIRCD_HOST.":".UNREALIRCD_PORT."/api";
- $curl = curl_init($url);
- curl_setopt($curl, CURLOPT_URL, $url);
- curl_setopt($curl, CURLOPT_POST, true);
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
-
- $headers = array(
- "Accept: application/json",
- "Content-Type: application/json",
- "Authorization: Basic ". base64_encode(UNREALIRCD_RPC_USER.":".UNREALIRCD_RPC_PASSWORD),
- );
- curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
-
- curl_setopt($curl, CURLOPT_POSTFIELDS, $this->content['body']);
-
- //for debug only!
- curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
- curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
-
- $apiResponse = curl_exec($curl);
- curl_close($curl);
-
- $this->result = $apiResponse;
- }
-
- function fetch_assoc()
- {
- do_log("RPC::fetch_assoc()", $this->result);
- return json_decode($this->result, true);
- }
-
- static function die(array $err)
- {
- die("There was a problem processing the request: ".$err['message']." (".$err['code'].")<br>Please contact the plugin author.<br>".
- "If you are a developer, see: <a href=\"https://www.unrealircd.org/docs/JSON-RPC#Error\">https://www.unrealircd.org/docs/JSON-RPC#Error</a>");
- }
-}