@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | $this->request->lang = $this->detectLanguage(); |
| 223 | 223 | |
| 224 | 224 | // Load our language, requested. |
| 225 | - if (! empty($this->request->lang)) |
|
| 225 | + if ( ! empty($this->request->lang)) |
|
| 226 | 226 | { |
| 227 | 227 | $file = ! empty($this->language_file) ? $this->language_file : 'application'; |
| 228 | 228 | |
@@ -241,20 +241,20 @@ discard block |
||
| 241 | 241 | $this->config->load('api'); |
| 242 | 242 | |
| 243 | 243 | // Gather config defaults when a value isn't set for this controller |
| 244 | - if ( empty($this->enable_logging) ) $this->enable_logging = config_item('api.enable_logging'); |
|
| 245 | - if ( empty($this->enable_rate_limits) ) $this->enable_rate_limits = config_item('api.enable_rate_limits'); |
|
| 246 | - if ( empty($this->rate_limits) ) $this->rate_limits = config_item('api.rate_limits'); |
|
| 244 | + if (empty($this->enable_logging)) $this->enable_logging = config_item('api.enable_logging'); |
|
| 245 | + if (empty($this->enable_rate_limits)) $this->enable_rate_limits = config_item('api.enable_rate_limits'); |
|
| 246 | + if (empty($this->rate_limits)) $this->rate_limits = config_item('api.rate_limits'); |
|
| 247 | 247 | |
| 248 | 248 | // Should we restrict to SSL requests? |
| 249 | 249 | if (config_item('api.require_ssl') === true && ! $this->request->ssl) |
| 250 | 250 | { |
| 251 | - $this->failForbidden( lang('api.ssl_required') ); |
|
| 251 | + $this->failForbidden(lang('api.ssl_required')); |
|
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | // Should we restrict to only allow AJAX requests? |
| 255 | - if (config_item('api.ajax_only') === true && ! $this->input->is_ajax_request() ) |
|
| 255 | + if (config_item('api.ajax_only') === true && ! $this->input->is_ajax_request()) |
|
| 256 | 256 | { |
| 257 | - $this->failForbidden( lang('api.ajax_required') ); |
|
| 257 | + $this->failForbidden(lang('api.ajax_required')); |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | $this->detectPage(); |
@@ -266,17 +266,17 @@ discard block |
||
| 266 | 266 | // in a single codebase. |
| 267 | 267 | get_instance()->config->set_item('api.authenticate_lib', $this->authenticate_class); |
| 268 | 268 | |
| 269 | - if (! $this->restrict(null, true) ) |
|
| 269 | + if ( ! $this->restrict(null, true)) |
|
| 270 | 270 | { |
| 271 | 271 | $this->logTime(); |
| 272 | - $this->failUnauthorized( lang('api.unauthorized') ); |
|
| 272 | + $this->failUnauthorized(lang('api.unauthorized')); |
|
| 273 | 273 | } |
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | // Has the user hit rate limits for this hour? |
| 277 | 277 | if ($this->enable_rate_limits && ! $this->isWithinLimits()) |
| 278 | 278 | { |
| 279 | - $this->failTooManyRequests( sprintf( lang('api.too_many_requests'), $this->rate_limits) ); |
|
| 279 | + $this->failTooManyRequests(sprintf(lang('api.too_many_requests'), $this->rate_limits)); |
|
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | // NEVER allow profiling via API. |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | } |
| 311 | 311 | else |
| 312 | 312 | { |
| 313 | - return $this->fail( lang('api.unknown_endpoint'), 'not_implemented'); |
|
| 313 | + return $this->fail(lang('api.unknown_endpoint'), 'not_implemented'); |
|
| 314 | 314 | } |
| 315 | 315 | } |
| 316 | 316 | |
@@ -331,7 +331,7 @@ discard block |
||
| 331 | 331 | * |
| 332 | 332 | * @return mixed |
| 333 | 333 | */ |
| 334 | - public function respond ($data = null, $status_code = 200) |
|
| 334 | + public function respond($data = null, $status_code = 200) |
|
| 335 | 335 | { |
| 336 | 336 | // If data is null and not code provide, error and bail |
| 337 | 337 | if ($data === null && $status_code === null) |
@@ -357,7 +357,7 @@ discard block |
||
| 357 | 357 | |
| 358 | 358 | set_status_header($status_code); |
| 359 | 359 | |
| 360 | - header('Content-Length: ' . strlen($output)); |
|
| 360 | + header('Content-Length: '.strlen($output)); |
|
| 361 | 361 | |
| 362 | 362 | exit($output); |
| 363 | 363 | } |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | * |
| 375 | 375 | * @return mixed |
| 376 | 376 | */ |
| 377 | - protected function fail ($description, $status_code, $error_code = 'invalid_request') |
|
| 377 | + protected function fail($description, $status_code, $error_code = 'invalid_request') |
|
| 378 | 378 | { |
| 379 | 379 | if (is_string($status_code)) |
| 380 | 380 | { |
@@ -585,26 +585,26 @@ discard block |
||
| 585 | 585 | |
| 586 | 586 | $params['page'] = ($this->page > 1 ? $this->page + 1 : 2); |
| 587 | 587 | |
| 588 | - if (! $clean_get) |
|
| 588 | + if ( ! $clean_get) |
|
| 589 | 589 | { |
| 590 | - if ( ! isset($_GET) || ! is_array($_GET) ) |
|
| 590 | + if ( ! isset($_GET) || ! is_array($_GET)) |
|
| 591 | 591 | { |
| 592 | 592 | $_GET = []; |
| 593 | 593 | } |
| 594 | 594 | |
| 595 | - foreach ( $_GET as $key => $value ) |
|
| 595 | + foreach ($_GET as $key => $value) |
|
| 596 | 596 | { |
| 597 | - $params[ $key ] = $value; |
|
| 597 | + $params[$key] = $value; |
|
| 598 | 598 | } |
| 599 | 599 | |
| 600 | 600 | // Ensure we get a correct per_page value |
| 601 | - if (! array_key_exists('per_page', $params)) |
|
| 601 | + if ( ! array_key_exists('per_page', $params)) |
|
| 602 | 602 | { |
| 603 | 603 | $params['per_page'] = $this->per_page; |
| 604 | 604 | } |
| 605 | 605 | } |
| 606 | 606 | |
| 607 | - return site_url($path) .'?'. http_build_query($params); |
|
| 607 | + return site_url($path).'?'.http_build_query($params); |
|
| 608 | 608 | } |
| 609 | 609 | |
| 610 | 610 | //-------------------------------------------------------------------- |
@@ -625,7 +625,7 @@ discard block |
||
| 625 | 625 | * |
| 626 | 626 | * @return string |
| 627 | 627 | */ |
| 628 | - public function prevURL ($path, $clean_get = false) |
|
| 628 | + public function prevURL($path, $clean_get = false) |
|
| 629 | 629 | { |
| 630 | 630 | // If paging is turned off, get out of here |
| 631 | 631 | if ($this->per_page == 0) |
@@ -637,26 +637,26 @@ discard block |
||
| 637 | 637 | |
| 638 | 638 | $params['page'] = ($this->page > 1 ? $this->page - 1 : 1); |
| 639 | 639 | |
| 640 | - if (! $clean_get) |
|
| 640 | + if ( ! $clean_get) |
|
| 641 | 641 | { |
| 642 | - if ( ! isset($_GET) || ! is_array($_GET) ) |
|
| 642 | + if ( ! isset($_GET) || ! is_array($_GET)) |
|
| 643 | 643 | { |
| 644 | 644 | $_GET = []; |
| 645 | 645 | } |
| 646 | 646 | |
| 647 | - foreach ( $_GET as $key => $value ) |
|
| 647 | + foreach ($_GET as $key => $value) |
|
| 648 | 648 | { |
| 649 | 649 | $params[$key] = $value; |
| 650 | 650 | } |
| 651 | 651 | |
| 652 | 652 | // Ensure we get a correct per_page value |
| 653 | - if (! array_key_exists('per_page', $params)) |
|
| 653 | + if ( ! array_key_exists('per_page', $params)) |
|
| 654 | 654 | { |
| 655 | 655 | $params['per_page'] = $this->per_page; |
| 656 | 656 | } |
| 657 | 657 | } |
| 658 | 658 | |
| 659 | - return site_url($path) .'?'. http_build_query($params); |
|
| 659 | + return site_url($path).'?'.http_build_query($params); |
|
| 660 | 660 | } |
| 661 | 661 | |
| 662 | 662 | //-------------------------------------------------------------------- |
@@ -675,11 +675,11 @@ discard block |
||
| 675 | 675 | protected function detectPage( ) |
| 676 | 676 | { |
| 677 | 677 | // Is a per-page limit being set? |
| 678 | - $this->per_page = isset($_GET['per_page']) ? (int)$_GET['per_page'] : $this->per_page; |
|
| 678 | + $this->per_page = isset($_GET['per_page']) ? (int) $_GET['per_page'] : $this->per_page; |
|
| 679 | 679 | |
| 680 | - $page = (int)$this->input->get('page'); |
|
| 680 | + $page = (int) $this->input->get('page'); |
|
| 681 | 681 | |
| 682 | - if (! $page || $page == 1) |
|
| 682 | + if ( ! $page || $page == 1) |
|
| 683 | 683 | { |
| 684 | 684 | $offset = 0; |
| 685 | 685 | } |
@@ -693,7 +693,7 @@ discard block |
||
| 693 | 693 | |
| 694 | 694 | // If they've specifically passed in page=0, then we need |
| 695 | 695 | // to ignore paging... |
| 696 | - if ((int)$this->input->get('page') === 0 && ! is_null($this->input->get('page')) ) |
|
| 696 | + if ((int) $this->input->get('page') === 0 && ! is_null($this->input->get('page'))) |
|
| 697 | 697 | { |
| 698 | 698 | $this->per_page = 0; |
| 699 | 699 | } |
@@ -715,7 +715,7 @@ discard block |
||
| 715 | 715 | $method = strtolower($this->input->server('REQUEST_METHOD')); |
| 716 | 716 | |
| 717 | 717 | // If it's not an allowed method, let's default to a GET |
| 718 | - if (! in_array($method, $this->allowed_http_methods)) |
|
| 718 | + if ( ! in_array($method, $this->allowed_http_methods)) |
|
| 719 | 719 | { |
| 720 | 720 | $method = 'get'; |
| 721 | 721 | } |
@@ -775,7 +775,7 @@ discard block |
||
| 775 | 775 | // We must check to see if the folder exists |
| 776 | 776 | // here since CI's lang->load will throw |
| 777 | 777 | // an error if the language doesn't exist. |
| 778 | - if (is_dir(APPPATH .'language/'. $lang)) |
|
| 778 | + if (is_dir(APPPATH.'language/'.$lang)) |
|
| 779 | 779 | { |
| 780 | 780 | $return_langs[] = $lang; |
| 781 | 781 | } |
@@ -783,7 +783,7 @@ discard block |
||
| 783 | 783 | |
| 784 | 784 | // If no languages were added, let the script |
| 785 | 785 | // send the default language back instead. |
| 786 | - if (! empty($return_langs)) |
|
| 786 | + if ( ! empty($return_langs)) |
|
| 787 | 787 | { |
| 788 | 788 | return $return_langs; |
| 789 | 789 | } |
@@ -801,14 +801,14 @@ discard block |
||
| 801 | 801 | */ |
| 802 | 802 | public function detectFields() |
| 803 | 803 | { |
| 804 | - if (! array_key_exists('fields', $_GET)) |
|
| 804 | + if ( ! array_key_exists('fields', $_GET)) |
|
| 805 | 805 | { |
| 806 | 806 | return; |
| 807 | 807 | } |
| 808 | 808 | |
| 809 | 809 | $fields = explode(',', $_GET['fields']); |
| 810 | 810 | |
| 811 | - if (! is_array($fields)) |
|
| 811 | + if ( ! is_array($fields)) |
|
| 812 | 812 | { |
| 813 | 813 | return; |
| 814 | 814 | } |
@@ -828,7 +828,7 @@ discard block |
||
| 828 | 828 | */ |
| 829 | 829 | public function logTime() |
| 830 | 830 | { |
| 831 | - if (! $this->enable_logging) |
|
| 831 | + if ( ! $this->enable_logging) |
|
| 832 | 832 | { |
| 833 | 833 | return; |
| 834 | 834 | } |
@@ -839,7 +839,7 @@ discard block |
||
| 839 | 839 | 'duration' => microtime(true) - $this->start_time, |
| 840 | 840 | 'user_id' => $this->authenticate->id(), |
| 841 | 841 | 'ip_address' => $this->input->ip_address(), |
| 842 | - 'request' => $this->uri->uri_string() .'?'. $_SERVER['QUERY_STRING'], |
|
| 842 | + 'request' => $this->uri->uri_string().'?'.$_SERVER['QUERY_STRING'], |
|
| 843 | 843 | 'method' => $this->request->method |
| 844 | 844 | ]; |
| 845 | 845 | |
@@ -860,7 +860,7 @@ discard block |
||
| 860 | 860 | { |
| 861 | 861 | $model = new LogModel(); |
| 862 | 862 | |
| 863 | - if ($model->requestsThisHourForUser( $this->authenticate->id() ) > $this->rate_limits) |
|
| 863 | + if ($model->requestsThisHourForUser($this->authenticate->id()) > $this->rate_limits) |
|
| 864 | 864 | { |
| 865 | 865 | return false; |
| 866 | 866 | } |