@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | //-------------------------------------------------------------------- |
| 50 | 50 | |
| 51 | - public function __construct($ci=null) |
|
| 51 | + public function __construct($ci = null) |
|
| 52 | 52 | { |
| 53 | 53 | parent::__construct($ci); |
| 54 | 54 | |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | // so request authorization by the client. |
| 115 | 115 | if (empty($username) || empty($password)) |
| 116 | 116 | { |
| 117 | - $this->ci->output->set_header('WWW-Authenticate: Basic realm="'. config_item('api.realm') .'"'); |
|
| 117 | + $this->ci->output->set_header('WWW-Authenticate: Basic realm="'.config_item('api.realm').'"'); |
|
| 118 | 118 | return false; |
| 119 | 119 | } |
| 120 | 120 | |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | // No digest string? Then you're done. Go home. |
| 171 | 171 | if (empty($digest_string)) |
| 172 | 172 | { |
| 173 | - $this->ci->output->set_header( sprintf('WWW-Authenticate: Digest realm="%s", nonce="%s", opaque="%s"', config_item('api.realm'), $nonce, $opaque) ); |
|
| 173 | + $this->ci->output->set_header(sprintf('WWW-Authenticate: Digest realm="%s", nonce="%s", opaque="%s"', config_item('api.realm'), $nonce, $opaque)); |
|
| 174 | 174 | return false; |
| 175 | 175 | } |
| 176 | 176 | |
@@ -180,9 +180,9 @@ discard block |
||
| 180 | 180 | preg_match_all('@(username|nonce|uri|nc|cnonce|qop|response)=[\'"]?([^\'",]+)@', $digest_string, $matches); |
| 181 | 181 | $digest = (empty($matches[1]) || empty($matches[2])) ? array() : array_combine($matches[1], $matches[2]); |
| 182 | 182 | |
| 183 | - if (! array_key_exists('username', $digest)) |
|
| 183 | + if ( ! array_key_exists('username', $digest)) |
|
| 184 | 184 | { |
| 185 | - $this->ci->output->set_header( sprintf('WWW-Authenticate: Digest realm="%s", nonce="%s", opaque="%s"', config_item('api.realm'), $nonce, $opaque) ); |
|
| 185 | + $this->ci->output->set_header(sprintf('WWW-Authenticate: Digest realm="%s", nonce="%s", opaque="%s"', config_item('api.realm'), $nonce, $opaque)); |
|
| 186 | 186 | return false; |
| 187 | 187 | } |
| 188 | 188 | |
@@ -194,10 +194,10 @@ discard block |
||
| 194 | 194 | |
| 195 | 195 | // Grab the user that corresponds to that "username" |
| 196 | 196 | // exact field determined in the api config file - api.auth_field setting. |
| 197 | - $user = $this->user_model->as_array()->find_by( config_item('api.auth_field'), $digest['username'] ); |
|
| 198 | - if (! $user) |
|
| 197 | + $user = $this->user_model->as_array()->find_by(config_item('api.auth_field'), $digest['username']); |
|
| 198 | + if ( ! $user) |
|
| 199 | 199 | { |
| 200 | - $this->ci->output->set_header( sprintf('WWW-Authenticate: Digest realm="%s", nonce="%s", opaque="%s"', config_item('api.realm'), $nonce, $opaque) ); |
|
| 200 | + $this->ci->output->set_header(sprintf('WWW-Authenticate: Digest realm="%s", nonce="%s", opaque="%s"', config_item('api.realm'), $nonce, $opaque)); |
|
| 201 | 201 | return false; |
| 202 | 202 | } |
| 203 | 203 | |
@@ -206,16 +206,16 @@ discard block |
||
| 206 | 206 | |
| 207 | 207 | if ($digest['qop'] == 'auth') |
| 208 | 208 | { |
| 209 | - $A2 = md5( strtoupper( $_SERVER['REQUEST_METHOD'] ) .':'. $digest['uri'] ); |
|
| 209 | + $A2 = md5(strtoupper($_SERVER['REQUEST_METHOD']).':'.$digest['uri']); |
|
| 210 | 210 | } else { |
| 211 | 211 | $body = file_get_contents('php://input'); |
| 212 | - $A2 = md5( strtoupper( $_SERVER['REQUEST_METHOD'] ) .':'. $digest['uri'] .':'. md5($body) ); |
|
| 212 | + $A2 = md5(strtoupper($_SERVER['REQUEST_METHOD']).':'.$digest['uri'].':'.md5($body)); |
|
| 213 | 213 | } |
| 214 | - $valid_response = md5($A1 .':'. $digest['nonce'].':'. $digest['nc'] .':'. $digest['cnonce'] .':'. $digest['qop'] .':'. $A2); |
|
| 214 | + $valid_response = md5($A1.':'.$digest['nonce'].':'.$digest['nc'].':'.$digest['cnonce'].':'.$digest['qop'].':'.$A2); |
|
| 215 | 215 | |
| 216 | 216 | if ($digest['response'] != $valid_response) |
| 217 | 217 | { |
| 218 | - $this->ci->output->set_header( sprintf('WWW-Authenticate: Digest realm="%s", nonce="%s", opaque="%s"', config_item('api.realm'), $nonce, $opaque) ); |
|
| 218 | + $this->ci->output->set_header(sprintf('WWW-Authenticate: Digest realm="%s", nonce="%s", opaque="%s"', config_item('api.realm'), $nonce, $opaque)); |
|
| 219 | 219 | return false; |
| 220 | 220 | } |
| 221 | 221 | |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | { |
| 262 | 262 | // If throttling time is above zero, we can't allow |
| 263 | 263 | // logins now. |
| 264 | - if ($time = (int)$this->isThrottled($this->email) > 0) |
|
| 264 | + if ($time = (int) $this->isThrottled($this->email) > 0) |
|
| 265 | 265 | { |
| 266 | 266 | $this->error = sprintf(lang('api.throttled'), $time); |
| 267 | 267 | return false; |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | $this->email = null; |
| 271 | 271 | } |
| 272 | 272 | |
| 273 | - if (! $user) |
|
| 273 | + if ( ! $user) |
|
| 274 | 274 | { |
| 275 | 275 | $this->user = null; |
| 276 | 276 | return $user; |
@@ -298,13 +298,13 @@ discard block |
||
| 298 | 298 | { |
| 299 | 299 | $blacklist = explode(',', config_item('api.ip_blacklist')); |
| 300 | 300 | |
| 301 | - array_walk($blacklist, function (&$item, $key) { |
|
| 301 | + array_walk($blacklist, function(&$item, $key) { |
|
| 302 | 302 | $item = trim($item); |
| 303 | 303 | }); |
| 304 | 304 | |
| 305 | 305 | if (in_array($this->ci->input->ip_address(), $blacklist)) |
| 306 | 306 | { |
| 307 | - throw new \Exception( lang('api.ip_denied'), 401); |
|
| 307 | + throw new \Exception(lang('api.ip_denied'), 401); |
|
| 308 | 308 | } |
| 309 | 309 | |
| 310 | 310 | return true; |
@@ -323,13 +323,13 @@ discard block |
||
| 323 | 323 | |
| 324 | 324 | array_push($whitelist, '127.0.0.1', '0.0.0.0'); |
| 325 | 325 | |
| 326 | - array_walk($whitelist, function (&$item, $key) { |
|
| 326 | + array_walk($whitelist, function(&$item, $key) { |
|
| 327 | 327 | $item = trim($item); |
| 328 | 328 | }); |
| 329 | 329 | |
| 330 | - if (! in_array($this->ci->input->ip_address(), $whitelist)) |
|
| 330 | + if ( ! in_array($this->ci->input->ip_address(), $whitelist)) |
|
| 331 | 331 | { |
| 332 | - throw new \Exception( lang('api.ip_denied'), 401); |
|
| 332 | + throw new \Exception(lang('api.ip_denied'), 401); |
|
| 333 | 333 | } |
| 334 | 334 | |
| 335 | 335 | return true; |
@@ -386,9 +386,9 @@ discard block |
||
| 386 | 386 | * |
| 387 | 387 | * @return bool|mixed|void |
| 388 | 388 | */ |
| 389 | - public function login($credentials, $remember=false) |
|
| 389 | + public function login($credentials, $remember = false) |
|
| 390 | 390 | { |
| 391 | - throw new \BadMethodCallException( lang('api.unused_method') ); |
|
| 391 | + throw new \BadMethodCallException(lang('api.unused_method')); |
|
| 392 | 392 | } |
| 393 | 393 | |
| 394 | 394 | //-------------------------------------------------------------------- |
@@ -403,7 +403,7 @@ discard block |
||
| 403 | 403 | */ |
| 404 | 404 | public function logout() |
| 405 | 405 | { |
| 406 | - throw new \BadMethodCallException( lang('api.unused_method') ); |
|
| 406 | + throw new \BadMethodCallException(lang('api.unused_method')); |
|
| 407 | 407 | } |
| 408 | 408 | |
| 409 | 409 | //-------------------------------------------------------------------- |