@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | * @param string $apiKey [description] |
| 96 | 96 | * @return array [description] |
| 97 | 97 | */ |
| 98 | - public function getAPIKeyData(string $apiKey):?object { |
|
| 98 | + public function getAPIKeyData(string $apiKey): ?object { |
|
| 99 | 99 | // Preliminary Check. |
| 100 | 100 | if ($this->api_key_table == null || $this->api_key_column == null) return null; |
| 101 | 101 | // Query. |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | * @param string $group [description] |
| 120 | 120 | * @return [type] [description] |
| 121 | 121 | */ |
| 122 | - public function getLimitData(string $client, string $group):?array { |
|
| 122 | + public function getLimitData(string $client, string $group): ?array { |
|
| 123 | 123 | $sql = 'SELECT count, start, (`start` + INTERVAL (1 - TIMESTAMPDIFF(HOUR, UTC_TIMESTAMP(), NOW())) HOUR) AS reset_epoch FROM rest_api_rate_limit WHERE client = ? AND _group = ?'; |
| 124 | 124 | $query = $this->db->query($sql, [$client, $group]); |
| 125 | 125 | if (!is_scalar($query) && $query->num_rows() > 0) return $query->result_array()[0]; |
@@ -117,9 +117,9 @@ discard block |
||
| 117 | 117 | * @param array|null $params Initialization parameters from the Slint system. |
| 118 | 118 | * There's no use for this arg yet. |
| 119 | 119 | */ |
| 120 | - function __construct(?array $params=null) |
|
| 120 | + function __construct(?array $params = null) |
|
| 121 | 121 | { |
| 122 | - $this->ci =& get_instance(); |
|
| 122 | + $this->ci = & get_instance(); |
|
| 123 | 123 | |
| 124 | 124 | if ($this->ci->input->is_cli_request()) return; |
| 125 | 125 | |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | |
| 138 | 138 | // Load Model. |
| 139 | 139 | $this->ci->load->splint(self::PACKAGE, '*RESTModel', 'rest_model'); |
| 140 | - $this->rest_model =& $this->ci->rest_model; |
|
| 140 | + $this->rest_model = & $this->ci->rest_model; |
|
| 141 | 141 | |
| 142 | 142 | $config = [ |
| 143 | 143 | 'users_table' => $this->ci->config->item('rest')['basic_auth']['users_table'] ?? null, |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | /** |
| 264 | 264 | * [bearer_auth description] |
| 265 | 265 | */ |
| 266 | - private function bearer_auth($auth=RESTAuth::BEARER):void { |
|
| 266 | + private function bearer_auth($auth = RESTAuth::BEARER):void { |
|
| 267 | 267 | $authorization = $this->get_authorization_header(); |
| 268 | 268 | if ($authorization == null || substr_count($authorization, " ") != 1) { |
| 269 | 269 | $this->handle_response(RESTResponse::BAD_REQUEST, $auth); // Exits. |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | } |
| 326 | 326 | // Should we acyually Limit? |
| 327 | 327 | if ($this->per_hour > 0) { |
| 328 | - $client = hash('md5', $this->ci->input->ip_address() . "%" . $apiKey->{$this->api_key_column}); |
|
| 328 | + $client = hash('md5', $this->ci->input->ip_address()."%".$apiKey->{$this->api_key_column}); |
|
| 329 | 329 | $limitData = $this->rest_model->getLimitData($client, '_api_keyed_user'); |
| 330 | 330 | if ($limitData == null) { |
| 331 | 331 | $limitData = []; |
@@ -409,7 +409,7 @@ discard block |
||
| 409 | 409 | * [get_authorization_header description] |
| 410 | 410 | * @return [type] [description] |
| 411 | 411 | */ |
| 412 | - private function get_authorization_header():?string |
|
| 412 | + private function get_authorization_header(): ?string |
|
| 413 | 413 | { |
| 414 | 414 | if (isset($_SERVER['Authorization'])) { |
| 415 | 415 | return trim($_SERVER["Authorization"]); |
@@ -432,7 +432,7 @@ discard block |
||
| 432 | 432 | * [handle_response description] |
| 433 | 433 | * @param int $code [description] |
| 434 | 434 | */ |
| 435 | - private function handle_response(int $code, $auth=null):void |
|
| 435 | + private function handle_response(int $code, $auth = null):void |
|
| 436 | 436 | { |
| 437 | 437 | http_response_code($code); |
| 438 | 438 | header("Content-Type: application/json"); |