@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | |
| 47 | 47 | //-------------------------------------------------------------------- |
| 48 | 48 | |
| 49 | - public function __construct($ci=null) |
|
| 49 | + public function __construct($ci = null) |
|
| 50 | 50 | { |
| 51 | 51 | parent::__construct($ci); |
| 52 | 52 | |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | // so request authorization by the client. |
| 113 | 113 | if (empty($username) || empty($password)) |
| 114 | 114 | { |
| 115 | - $this->ci->output->set_header('WWW-Authenticate: Basic realm="'. config_item('api.realm') .'"'); |
|
| 115 | + $this->ci->output->set_header('WWW-Authenticate: Basic realm="'.config_item('api.realm').'"'); |
|
| 116 | 116 | return false; |
| 117 | 117 | } |
| 118 | 118 | |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | // No digest string? Then you're done. Go home. |
| 163 | 163 | if (empty($digest_string)) |
| 164 | 164 | { |
| 165 | - $this->ci->output->set_header( sprintf('WWW-Authenticate: Digest realm="%s", nonce="%s", opaque="%s"', config_item('api.realm'), $nonce, $opaque) ); |
|
| 165 | + $this->ci->output->set_header(sprintf('WWW-Authenticate: Digest realm="%s", nonce="%s", opaque="%s"', config_item('api.realm'), $nonce, $opaque)); |
|
| 166 | 166 | return false; |
| 167 | 167 | } |
| 168 | 168 | |
@@ -172,18 +172,18 @@ discard block |
||
| 172 | 172 | preg_match_all('@(username|nonce|uri|nc|cnonce|qop|response)=[\'"]?([^\'",]+)@', $digest_string, $matches); |
| 173 | 173 | $digest = (empty($matches[1]) || empty($matches[2])) ? array() : array_combine($matches[1], $matches[2]); |
| 174 | 174 | |
| 175 | - if (! array_key_exists('username', $digest)) |
|
| 175 | + if ( ! array_key_exists('username', $digest)) |
|
| 176 | 176 | { |
| 177 | - $this->ci->output->set_header( sprintf('WWW-Authenticate: Digest realm="%s", nonce="%s", opaque="%s"', config_item('api.realm'), $nonce, $opaque) ); |
|
| 177 | + $this->ci->output->set_header(sprintf('WWW-Authenticate: Digest realm="%s", nonce="%s", opaque="%s"', config_item('api.realm'), $nonce, $opaque)); |
|
| 178 | 178 | return false; |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | // Grab the user that corresponds to that "username" |
| 182 | 182 | // exact field determined in the api config file - api.auth_field setting. |
| 183 | - $user = $this->user_model->as_array()->find_by( config_item('api.auth_field'), $digest['username'] ); |
|
| 184 | - if (! $user) |
|
| 183 | + $user = $this->user_model->as_array()->find_by(config_item('api.auth_field'), $digest['username']); |
|
| 184 | + if ( ! $user) |
|
| 185 | 185 | { |
| 186 | - $this->ci->output->set_header( sprintf('WWW-Authenticate: Digest realm="%s", nonce="%s", opaque="%s"', config_item('api.realm'), $nonce, $opaque) ); |
|
| 186 | + $this->ci->output->set_header(sprintf('WWW-Authenticate: Digest realm="%s", nonce="%s", opaque="%s"', config_item('api.realm'), $nonce, $opaque)); |
|
| 187 | 187 | $this->ci->login_model->recordLoginAttempt($_SERVER['REMOTE_ADDR']); |
| 188 | 188 | return false; |
| 189 | 189 | } |
@@ -193,16 +193,16 @@ discard block |
||
| 193 | 193 | |
| 194 | 194 | if ($digest['qop'] == 'auth') |
| 195 | 195 | { |
| 196 | - $A2 = md5( strtoupper( $_SERVER['REQUEST_METHOD'] ) .':'. $digest['uri'] ); |
|
| 196 | + $A2 = md5(strtoupper($_SERVER['REQUEST_METHOD']).':'.$digest['uri']); |
|
| 197 | 197 | } else { |
| 198 | 198 | $body = file_get_contents('php://input'); |
| 199 | - $A2 = md5( strtoupper( $_SERVER['REQUEST_METHOD'] ) .':'. $digest['uri'] .':'. md5($body) ); |
|
| 199 | + $A2 = md5(strtoupper($_SERVER['REQUEST_METHOD']).':'.$digest['uri'].':'.md5($body)); |
|
| 200 | 200 | } |
| 201 | - $valid_response = md5($A1 .':'. $digest['nonce'].':'. $digest['nc'] .':'. $digest['cnonce'] .':'. $digest['qop'] .':'. $A2); |
|
| 201 | + $valid_response = md5($A1.':'.$digest['nonce'].':'.$digest['nc'].':'.$digest['cnonce'].':'.$digest['qop'].':'.$A2); |
|
| 202 | 202 | |
| 203 | 203 | if ($digest['response'] != $valid_response) |
| 204 | 204 | { |
| 205 | - $this->ci->output->set_header( sprintf('WWW-Authenticate: Digest realm="%s", nonce="%s", opaque="%s"', config_item('api.realm'), $nonce, $opaque) ); |
|
| 205 | + $this->ci->output->set_header(sprintf('WWW-Authenticate: Digest realm="%s", nonce="%s", opaque="%s"', config_item('api.realm'), $nonce, $opaque)); |
|
| 206 | 206 | $this->ci->login_model->recordLoginAttempt($_SERVER['REMOTE_ADDR'], $user['id']); |
| 207 | 207 | return false; |
| 208 | 208 | } |
@@ -247,13 +247,13 @@ discard block |
||
| 247 | 247 | |
| 248 | 248 | // If throttling time is above zero, we can't allow |
| 249 | 249 | // logins now. |
| 250 | - if ($time = (int)$this->isThrottled($user) > 0) |
|
| 250 | + if ($time = (int) $this->isThrottled($user) > 0) |
|
| 251 | 251 | { |
| 252 | 252 | $this->error = sprintf(lang('api.throttled'), $time); |
| 253 | 253 | return false; |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | - if (! $user) |
|
| 256 | + if ( ! $user) |
|
| 257 | 257 | { |
| 258 | 258 | $this->user = null; |
| 259 | 259 | return $user; |
@@ -281,13 +281,13 @@ discard block |
||
| 281 | 281 | { |
| 282 | 282 | $blacklist = explode(',', config_item('api.ip_blacklist')); |
| 283 | 283 | |
| 284 | - array_walk($blacklist, function (&$item, $key) { |
|
| 284 | + array_walk($blacklist, function(&$item, $key) { |
|
| 285 | 285 | $item = trim($item); |
| 286 | 286 | }); |
| 287 | 287 | |
| 288 | 288 | if (in_array($this->ci->input->ip_address(), $blacklist)) |
| 289 | 289 | { |
| 290 | - throw new \Exception( lang('api.ip_denied'), 401); |
|
| 290 | + throw new \Exception(lang('api.ip_denied'), 401); |
|
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | return true; |
@@ -306,13 +306,13 @@ discard block |
||
| 306 | 306 | |
| 307 | 307 | array_push($whitelist, '127.0.0.1', '0.0.0.0'); |
| 308 | 308 | |
| 309 | - array_walk($whitelist, function (&$item, $key) { |
|
| 309 | + array_walk($whitelist, function(&$item, $key) { |
|
| 310 | 310 | $item = trim($item); |
| 311 | 311 | }); |
| 312 | 312 | |
| 313 | - if (! in_array($this->ci->input->ip_address(), $whitelist)) |
|
| 313 | + if ( ! in_array($this->ci->input->ip_address(), $whitelist)) |
|
| 314 | 314 | { |
| 315 | - throw new \Exception( lang('api.ip_denied'), 401); |
|
| 315 | + throw new \Exception(lang('api.ip_denied'), 401); |
|
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | return true; |
@@ -369,9 +369,9 @@ discard block |
||
| 369 | 369 | * |
| 370 | 370 | * @return bool|mixed|void |
| 371 | 371 | */ |
| 372 | - public function login($credentials, $remember=false) |
|
| 372 | + public function login($credentials, $remember = false) |
|
| 373 | 373 | { |
| 374 | - throw new \BadMethodCallException( lang('api.unused_method') ); |
|
| 374 | + throw new \BadMethodCallException(lang('api.unused_method')); |
|
| 375 | 375 | } |
| 376 | 376 | |
| 377 | 377 | //-------------------------------------------------------------------- |
@@ -386,7 +386,7 @@ discard block |
||
| 386 | 386 | */ |
| 387 | 387 | public function logout() |
| 388 | 388 | { |
| 389 | - throw new \BadMethodCallException( lang('api.unused_method') ); |
|
| 389 | + throw new \BadMethodCallException(lang('api.unused_method')); |
|
| 390 | 390 | } |
| 391 | 391 | |
| 392 | 392 | //-------------------------------------------------------------------- |
@@ -62,21 +62,21 @@ discard block |
||
| 62 | 62 | |
| 63 | 63 | //-------------------------------------------------------------------- |
| 64 | 64 | |
| 65 | - public function __construct( $ci=null ) |
|
| 65 | + public function __construct($ci = null) |
|
| 66 | 66 | { |
| 67 | 67 | if ($ci) |
| 68 | 68 | { |
| 69 | - $this->ci= $ci; |
|
| 69 | + $this->ci = $ci; |
|
| 70 | 70 | } |
| 71 | 71 | else |
| 72 | 72 | { |
| 73 | - $this->ci =& get_instance(); |
|
| 73 | + $this->ci = & get_instance(); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | // Get our compatibility password file loaded up. |
| 77 | - if (! function_exists('password_hash')) |
|
| 77 | + if ( ! function_exists('password_hash')) |
|
| 78 | 78 | { |
| 79 | - require_once dirname(__FILE__) .'password.php'; |
|
| 79 | + require_once dirname(__FILE__).'password.php'; |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | if (empty($this->ci->session)) |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | * @param bool $remember |
| 102 | 102 | * @return bool|mixed |
| 103 | 103 | */ |
| 104 | - public function login($credentials, $remember=false) |
|
| 104 | + public function login($credentials, $remember = false) |
|
| 105 | 105 | { |
| 106 | 106 | $user = $this->validate($credentials, true); |
| 107 | 107 | |
@@ -112,14 +112,14 @@ discard block |
||
| 112 | 112 | |
| 113 | 113 | // If throttling time is above zero, we can't allow |
| 114 | 114 | // logins now. |
| 115 | - $time = (int)$this->isThrottled($user); |
|
| 115 | + $time = (int) $this->isThrottled($user); |
|
| 116 | 116 | if ($time > 0) |
| 117 | 117 | { |
| 118 | 118 | $this->error = sprintf(lang('auth.throttled'), $time); |
| 119 | 119 | return false; |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - if (! $user) |
|
| 122 | + if ( ! $user) |
|
| 123 | 123 | { |
| 124 | 124 | if (empty($this->error)) |
| 125 | 125 | { |
@@ -154,14 +154,14 @@ discard block |
||
| 154 | 154 | * @param bool $return_user |
| 155 | 155 | * @return mixed |
| 156 | 156 | */ |
| 157 | - public function validate($credentials, $return_user=false) |
|
| 157 | + public function validate($credentials, $return_user = false) |
|
| 158 | 158 | { |
| 159 | 159 | // Get ip address |
| 160 | 160 | $ip_address = $this->ci->input->server('REMOTE_ADDR'); |
| 161 | 161 | |
| 162 | 162 | // We do not want to force case-sensitivity on things |
| 163 | 163 | // like username and email for usability sake. |
| 164 | - if (! empty($credentials['email'])) |
|
| 164 | + if ( ! empty($credentials['email'])) |
|
| 165 | 165 | { |
| 166 | 166 | $credentials['email'] = strtolower($credentials['email']); |
| 167 | 167 | } |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | // Ensure that the fields are allowed validation fields |
| 189 | - if (! in_array(key($credentials), config_item('auth.valid_fields')) ) |
|
| 189 | + if ( ! in_array(key($credentials), config_item('auth.valid_fields'))) |
|
| 190 | 190 | { |
| 191 | 191 | $this->error = lang('auth.invalid_credentials'); |
| 192 | 192 | $this->ci->login_model->recordLoginAttempt($ip_address); |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | ->where($credentials) |
| 199 | 199 | ->first(); |
| 200 | 200 | |
| 201 | - if (! $user) |
|
| 201 | + if ( ! $user) |
|
| 202 | 202 | { |
| 203 | 203 | $this->error = lang('auth.invalid_user'); |
| 204 | 204 | $this->ci->login_model->recordLoginAttempt($ip_address); |
@@ -206,9 +206,9 @@ discard block |
||
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | // Now, try matching the passwords. |
| 209 | - $result = password_verify($password, $user['password_hash']); |
|
| 209 | + $result = password_verify($password, $user['password_hash']); |
|
| 210 | 210 | |
| 211 | - if (! $result) |
|
| 211 | + if ( ! $result) |
|
| 212 | 212 | { |
| 213 | 213 | $this->error = lang('auth.invalid_password'); |
| 214 | 214 | $this->ci->login_model->recordLoginAttempt($ip_address, $user['id']); |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | // This would be due to the hash algorithm or hash |
| 220 | 220 | // cost changing since the last time that a user |
| 221 | 221 | // logged in. |
| 222 | - if (password_needs_rehash($user['password_hash'], PASSWORD_DEFAULT, ['cost' => config_item('auth.hash_cost')] )) |
|
| 222 | + if (password_needs_rehash($user['password_hash'], PASSWORD_DEFAULT, ['cost' => config_item('auth.hash_cost')])) |
|
| 223 | 223 | { |
| 224 | 224 | $new_hash = Password::hashPassword($password); |
| 225 | 225 | $this->user_model->skip_validation() |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | // Is the user active? |
| 231 | - if (! $user['active']) |
|
| 231 | + if ( ! $user['active']) |
|
| 232 | 232 | { |
| 233 | 233 | $this->error = lang('auth.inactive_account'); |
| 234 | 234 | return false; |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | { |
| 249 | 249 | $this->ci->load->helper('cookie'); |
| 250 | 250 | |
| 251 | - if (! Events::trigger('beforeLogout', [$this->user])) |
|
| 251 | + if ( ! Events::trigger('beforeLogout', [$this->user])) |
|
| 252 | 252 | { |
| 253 | 253 | return false; |
| 254 | 254 | } |
@@ -257,10 +257,10 @@ discard block |
||
| 257 | 257 | // available for flash messages, etc. |
| 258 | 258 | if (isset($_SESSION)) |
| 259 | 259 | { |
| 260 | - foreach ( $_SESSION as $key => $value ) |
|
| 260 | + foreach ($_SESSION as $key => $value) |
|
| 261 | 261 | { |
| 262 | - $_SESSION[ $key ] = NULL; |
|
| 263 | - unset( $_SESSION[ $key ] ); |
|
| 262 | + $_SESSION[$key] = NULL; |
|
| 263 | + unset($_SESSION[$key]); |
|
| 264 | 264 | } |
| 265 | 265 | } |
| 266 | 266 | // Also, regenerate the session ID for a touch of added safety. |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | { |
| 287 | 287 | $id = $this->ci->session->userdata('logged_in'); |
| 288 | 288 | |
| 289 | - if (! $id) |
|
| 289 | + if ( ! $id) |
|
| 290 | 290 | { |
| 291 | 291 | return false; |
| 292 | 292 | } |
@@ -294,10 +294,10 @@ discard block |
||
| 294 | 294 | // If the user var hasn't been filled in, we need to fill it in, |
| 295 | 295 | // since this method will typically be used as the only method |
| 296 | 296 | // to determine whether a user is logged in or not. |
| 297 | - if (! $this->user) |
|
| 297 | + if ( ! $this->user) |
|
| 298 | 298 | { |
| 299 | 299 | $this->user = $this->user_model->as_array() |
| 300 | - ->find_by('id', (int)$id); |
|
| 300 | + ->find_by('id', (int) $id); |
|
| 301 | 301 | |
| 302 | 302 | if (empty($this->user)) |
| 303 | 303 | { |
@@ -321,14 +321,14 @@ discard block |
||
| 321 | 321 | */ |
| 322 | 322 | public function viaRemember() |
| 323 | 323 | { |
| 324 | - if (! config_item('auth.allow_remembering')) |
|
| 324 | + if ( ! config_item('auth.allow_remembering')) |
|
| 325 | 325 | { |
| 326 | 326 | return false; |
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | $this->ci->load->helper('cookie'); |
| 330 | 330 | |
| 331 | - if (! $token = get_cookie('remember')) |
|
| 331 | + if ( ! $token = get_cookie('remember')) |
|
| 332 | 332 | { |
| 333 | 333 | return false; |
| 334 | 334 | } |
@@ -337,7 +337,7 @@ discard block |
||
| 337 | 337 | $query = $this->ci->db->where('hash', $this->ci->login_model->hashRememberToken($token)) |
| 338 | 338 | ->get('auth_tokens'); |
| 339 | 339 | |
| 340 | - if (! $query->num_rows()) |
|
| 340 | + if ( ! $query->num_rows()) |
|
| 341 | 341 | { |
| 342 | 342 | return false; |
| 343 | 343 | } |
@@ -375,16 +375,16 @@ discard block |
||
| 375 | 375 | // If via email, we need to generate a hash |
| 376 | 376 | $this->ci->load->helper('string'); |
| 377 | 377 | $token = random_string('alnum', 24); |
| 378 | - $user_data['activate_hash'] = hash('sha1', config_item('auth.salt') . $token); |
|
| 378 | + $user_data['activate_hash'] = hash('sha1', config_item('auth.salt').$token); |
|
| 379 | 379 | |
| 380 | 380 | // Email should NOT be case sensitive. |
| 381 | - if (! empty($user_data['email'])) |
|
| 381 | + if ( ! empty($user_data['email'])) |
|
| 382 | 382 | { |
| 383 | 383 | $user_data['email'] = strtolower($user_data['email']); |
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | // Save the user |
| 387 | - if (! $id = $this->user_model->insert($user_data)) |
|
| 387 | + if ( ! $id = $this->user_model->insert($user_data)) |
|
| 388 | 388 | { |
| 389 | 389 | $this->error = $this->user_model->error(); |
| 390 | 390 | return false; |
@@ -415,25 +415,25 @@ discard block |
||
| 415 | 415 | { |
| 416 | 416 | $post = [ |
| 417 | 417 | 'email' => $data['email'], |
| 418 | - 'activate_hash' => hash('sha1', config_item('auth.salt') . $data['code']) |
|
| 418 | + 'activate_hash' => hash('sha1', config_item('auth.salt').$data['code']) |
|
| 419 | 419 | ]; |
| 420 | 420 | |
| 421 | 421 | $user = $this->user_model->where($post) |
| 422 | 422 | ->first(); |
| 423 | 423 | |
| 424 | - if (! $user) { |
|
| 424 | + if ( ! $user) { |
|
| 425 | 425 | $this->error = $this->user_model->error() ? $this->user_model->error() : lang('auth.activate_no_user'); |
| 426 | 426 | |
| 427 | 427 | return false; |
| 428 | 428 | } |
| 429 | 429 | |
| 430 | - if (! $this->user_model->update($user->id, ['active' => 1, 'activate_hash' => null])) |
|
| 430 | + if ( ! $this->user_model->update($user->id, ['active' => 1, 'activate_hash' => null])) |
|
| 431 | 431 | { |
| 432 | 432 | $this->error = $this->user_model->error(); |
| 433 | 433 | return false; |
| 434 | 434 | } |
| 435 | 435 | |
| 436 | - Events::trigger('didActivate', [(array)$user]); |
|
| 436 | + Events::trigger('didActivate', [(array) $user]); |
|
| 437 | 437 | |
| 438 | 438 | return true; |
| 439 | 439 | } |
@@ -448,7 +448,7 @@ discard block |
||
| 448 | 448 | */ |
| 449 | 449 | public function activateUserById($id) |
| 450 | 450 | { |
| 451 | - if (! $this->user_model->update($id, ['active' => 1, 'activate_hash' => null])) |
|
| 451 | + if ( ! $this->user_model->update($id, ['active' => 1, 'activate_hash' => null])) |
|
| 452 | 452 | { |
| 453 | 453 | $this->error = $this->user_model->error(); |
| 454 | 454 | return false; |
@@ -480,12 +480,12 @@ discard block |
||
| 480 | 480 | */ |
| 481 | 481 | public function id() |
| 482 | 482 | { |
| 483 | - if (! is_array($this->user) || empty($this->user['id'])) |
|
| 483 | + if ( ! is_array($this->user) || empty($this->user['id'])) |
|
| 484 | 484 | { |
| 485 | 485 | return null; |
| 486 | 486 | } |
| 487 | 487 | |
| 488 | - return (int)$this->user['id']; |
|
| 488 | + return (int) $this->user['id']; |
|
| 489 | 489 | } |
| 490 | 490 | |
| 491 | 491 | //-------------------------------------------------------------------- |
@@ -502,7 +502,7 @@ discard block |
||
| 502 | 502 | public function isThrottled($user) |
| 503 | 503 | { |
| 504 | 504 | // Not throttling? Get outta here! |
| 505 | - if (! config_item('auth.allow_throttling')) |
|
| 505 | + if ( ! config_item('auth.allow_throttling')) |
|
| 506 | 506 | { |
| 507 | 507 | return false; |
| 508 | 508 | } |
@@ -570,7 +570,7 @@ discard block |
||
| 570 | 570 | { |
| 571 | 571 | $this->error = lang('auth.bruteBan_notice'); |
| 572 | 572 | |
| 573 | - $ban_time = 60 * 15; // 15 minutes |
|
| 573 | + $ban_time = 60 * 15; // 15 minutes |
|
| 574 | 574 | $_SESSION['bruteBan'] = time() + $ban_time; |
| 575 | 575 | return $ban_time; |
| 576 | 576 | } |
@@ -618,7 +618,7 @@ discard block |
||
| 618 | 618 | // Is it a valid user? |
| 619 | 619 | $user = $this->user_model->find_by('email', $email); |
| 620 | 620 | |
| 621 | - if (! $user) |
|
| 621 | + if ( ! $user) |
|
| 622 | 622 | { |
| 623 | 623 | $this->error = lang('auth.invalid_email'); |
| 624 | 624 | return false; |
@@ -627,17 +627,17 @@ discard block |
||
| 627 | 627 | // Generate/store our codes |
| 628 | 628 | $this->ci->load->helper('string'); |
| 629 | 629 | $token = random_string('alnum', 24); |
| 630 | - $hash = hash('sha1', config_item('auth.salt') .$token); |
|
| 630 | + $hash = hash('sha1', config_item('auth.salt').$token); |
|
| 631 | 631 | |
| 632 | 632 | $result = $this->user_model->update($user->id, ['reset_hash' => $hash]); |
| 633 | 633 | |
| 634 | - if (! $result) |
|
| 634 | + if ( ! $result) |
|
| 635 | 635 | { |
| 636 | 636 | $this->error = $this->user_model->error(); |
| 637 | 637 | return false; |
| 638 | 638 | } |
| 639 | 639 | |
| 640 | - Events::trigger('didRemindUser', [(array)$user, $token]); |
|
| 640 | + Events::trigger('didRemindUser', [(array) $user, $token]); |
|
| 641 | 641 | |
| 642 | 642 | return true; |
| 643 | 643 | } |
@@ -664,10 +664,10 @@ discard block |
||
| 664 | 664 | } |
| 665 | 665 | |
| 666 | 666 | // Generate a hash to match against the table. |
| 667 | - $credentials['reset_hash'] = hash('sha1', config_item('auth.salt') .$credentials['code']); |
|
| 667 | + $credentials['reset_hash'] = hash('sha1', config_item('auth.salt').$credentials['code']); |
|
| 668 | 668 | unset($credentials['code']); |
| 669 | 669 | |
| 670 | - if (! empty($credentials['email'])) |
|
| 670 | + if ( ! empty($credentials['email'])) |
|
| 671 | 671 | { |
| 672 | 672 | $credentials['email'] = strtolower($credentials['email']); |
| 673 | 673 | } |
@@ -675,7 +675,7 @@ discard block |
||
| 675 | 675 | // Is there a matching user? |
| 676 | 676 | $user = $this->user_model->find_by($credentials); |
| 677 | 677 | |
| 678 | - if (! $user) |
|
| 678 | + if ( ! $user) |
|
| 679 | 679 | { |
| 680 | 680 | $this->error = lang('auth.reset_no_user'); |
| 681 | 681 | return false; |
@@ -688,13 +688,13 @@ discard block |
||
| 688 | 688 | 'reset_hash' => null |
| 689 | 689 | ]; |
| 690 | 690 | |
| 691 | - if (! $this->user_model->update($user->id, $data)) |
|
| 691 | + if ( ! $this->user_model->update($user->id, $data)) |
|
| 692 | 692 | { |
| 693 | 693 | $this->error = $this->user_model->error(); |
| 694 | 694 | return false; |
| 695 | 695 | } |
| 696 | 696 | |
| 697 | - Events::trigger('didResetPassword', [(array)$user]); |
|
| 697 | + Events::trigger('didResetPassword', [(array) $user]); |
|
| 698 | 698 | |
| 699 | 699 | return true; |
| 700 | 700 | } |
@@ -710,7 +710,7 @@ discard block |
||
| 710 | 710 | * @param null $message |
| 711 | 711 | * @return mixed |
| 712 | 712 | */ |
| 713 | - public function changeStatus($newStatus, $message=null) |
|
| 713 | + public function changeStatus($newStatus, $message = null) |
|
| 714 | 714 | { |
| 715 | 715 | // todo actually record new users status! |
| 716 | 716 | } |
@@ -727,14 +727,14 @@ discard block |
||
| 727 | 727 | * @param bool $allow_any_parent |
| 728 | 728 | * @return mixed |
| 729 | 729 | */ |
| 730 | - public function useModel($model, $allow_any_parent=false) |
|
| 730 | + public function useModel($model, $allow_any_parent = false) |
|
| 731 | 731 | { |
| 732 | - if (! $allow_any_parent && get_parent_class($model) != 'Myth\Models\CIDbModel') |
|
| 732 | + if ( ! $allow_any_parent && get_parent_class($model) != 'Myth\Models\CIDbModel') |
|
| 733 | 733 | { |
| 734 | 734 | throw new \RuntimeException('Models passed into LocalAuthenticate MUST extend Myth\Models\CIDbModel'); |
| 735 | 735 | } |
| 736 | 736 | |
| 737 | - $this->user_model =& $model; |
|
| 737 | + $this->user_model = & $model; |
|
| 738 | 738 | |
| 739 | 739 | return $this; |
| 740 | 740 | } |
@@ -806,7 +806,7 @@ discard block |
||
| 806 | 806 | */ |
| 807 | 807 | protected function rememberUser($user) |
| 808 | 808 | { |
| 809 | - if (! config_item('auth.allow_remembering')) |
|
| 809 | + if ( ! config_item('auth.allow_remembering')) |
|
| 810 | 810 | { |
| 811 | 811 | log_message('debug', 'Auth library set to refuse "Remember Me" functionality.'); |
| 812 | 812 | return false; |
@@ -825,13 +825,13 @@ discard block |
||
| 825 | 825 | * @param null $token |
| 826 | 826 | * @return mixed |
| 827 | 827 | */ |
| 828 | - protected function refreshRememberCookie($user, $token=null) |
|
| 828 | + protected function refreshRememberCookie($user, $token = null) |
|
| 829 | 829 | { |
| 830 | 830 | $this->ci->load->helper('cookie'); |
| 831 | 831 | |
| 832 | 832 | // If a token is passed in, we know we're removing the |
| 833 | 833 | // old one. |
| 834 | - if (! empty($token)) |
|
| 834 | + if ( ! empty($token)) |
|
| 835 | 835 | { |
| 836 | 836 | $this->invalidateRememberCookie($user['email'], $token); |
| 837 | 837 | } |
@@ -841,7 +841,7 @@ discard block |
||
| 841 | 841 | // Save the token to the database. |
| 842 | 842 | $data = [ |
| 843 | 843 | 'email' => $user['email'], |
| 844 | - 'hash' => sha1(config_item('auth.salt') . $new_token), |
|
| 844 | + 'hash' => sha1(config_item('auth.salt').$new_token), |
|
| 845 | 845 | 'created' => date('Y-m-d H:i:s') |
| 846 | 846 | ]; |
| 847 | 847 | |
@@ -849,13 +849,13 @@ discard block |
||
| 849 | 849 | |
| 850 | 850 | // Create the cookie |
| 851 | 851 | set_cookie( |
| 852 | - 'remember', // Cookie Name |
|
| 853 | - $new_token, // Value |
|
| 854 | - config_item('auth.remember_length'), // # Seconds until it expires |
|
| 852 | + 'remember', // Cookie Name |
|
| 853 | + $new_token, // Value |
|
| 854 | + config_item('auth.remember_length'), // # Seconds until it expires |
|
| 855 | 855 | config_item('cookie_domain'), |
| 856 | 856 | config_item('cookie_path'), |
| 857 | 857 | config_item('cookie_prefix'), |
| 858 | - false, // Only send over HTTPS? |
|
| 858 | + false, // Only send over HTTPS? |
|
| 859 | 859 | true // Hide from Javascript? |
| 860 | 860 | ); |
| 861 | 861 | |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | $this->db->insert('auth_login_attempts', $data); |
| 74 | 74 | |
| 75 | 75 | // log attempt for ip address |
| 76 | - if (! empty($ip_address)) |
|
| 76 | + if ( ! empty($ip_address)) |
|
| 77 | 77 | { |
| 78 | 78 | $data = [ |
| 79 | 79 | 'type' => 'ip', |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | ->where('datetime >=', $start_time) |
| 134 | 134 | ->count_all_results('auth_login_attempts'); |
| 135 | 135 | |
| 136 | - if (! $user_id) |
|
| 136 | + if ( ! $user_id) |
|
| 137 | 137 | { |
| 138 | 138 | return $attempts_ip > 100; |
| 139 | 139 | } |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | */ |
| 172 | 172 | public function distributedBruteForceTime() |
| 173 | 173 | { |
| 174 | - if (! $time = $this->cache->get('dbrutetime')) |
|
| 174 | + if ( ! $time = $this->cache->get('dbrutetime')) |
|
| 175 | 175 | { |
| 176 | 176 | $time = 0; |
| 177 | 177 | |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | |
| 181 | 181 | $query = $this->db->query("SELECT COUNT(*) / COUNT(DISTINCT DATE(`datetime`)) as num_rows FROM `auth_login_attempts` WHERE `type` = 'app' AND `datetime` >= ?", $avg_start_time); |
| 182 | 182 | |
| 183 | - if (! $query->num_rows()) |
|
| 183 | + if ( ! $query->num_rows()) |
|
| 184 | 184 | { |
| 185 | 185 | $average = 0; |
| 186 | 186 | } |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | // Cache it for 3 hours. |
| 205 | - $this->cache->save('dbrutetime', $time, 60*60*3); |
|
| 205 | + $this->cache->save('dbrutetime', $time, 60 * 60 * 3); |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | return $time; |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | public function recordLogin($user) |
| 224 | 224 | { |
| 225 | 225 | $data = [ |
| 226 | - 'user_id' => (int)$user['id'], |
|
| 226 | + 'user_id' => (int) $user['id'], |
|
| 227 | 227 | 'datetime' => date('Y-m-d H:i:s'), |
| 228 | 228 | 'ip_address' => $this->input->ip_address() |
| 229 | 229 | ]; |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | { |
| 252 | 252 | $this->load->helper('string'); |
| 253 | 253 | |
| 254 | - return str_replace('@', '.', $user['email']) .'|' . random_string('alnum', 128); |
|
| 254 | + return str_replace('@', '.', $user['email']).'|'.random_string('alnum', 128); |
|
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | //-------------------------------------------------------------------- |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | */ |
| 265 | 265 | public function hashRememberToken($token) |
| 266 | 266 | { |
| 267 | - return sha1(config_item('auth.salt') . $token); |
|
| 267 | + return sha1(config_item('auth.salt').$token); |
|
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | //-------------------------------------------------------------------- |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | */ |
| 311 | 311 | public function purgeOldRememberTokens() |
| 312 | 312 | { |
| 313 | - if (! config_item('auth.allow_remembering')) |
|
| 313 | + if ( ! config_item('auth.allow_remembering')) |
|
| 314 | 314 | { |
| 315 | 315 | return; |
| 316 | 316 | } |
@@ -341,7 +341,7 @@ discard block |
||
| 341 | 341 | |
| 342 | 342 | $last_ip = ! $query->num_rows() ? 0 : strtotime($query->row()->datetime); |
| 343 | 343 | |
| 344 | - if (! $user_id) |
|
| 344 | + if ( ! $user_id) |
|
| 345 | 345 | { |
| 346 | 346 | return $last_ip; |
| 347 | 347 | } |
@@ -372,7 +372,7 @@ discard block |
||
| 372 | 372 | ->where('ip_address', $ip_address) |
| 373 | 373 | ->count_all_results('auth_login_attempts'); |
| 374 | 374 | |
| 375 | - if (! $user_id) |
|
| 375 | + if ( ! $user_id) |
|
| 376 | 376 | { |
| 377 | 377 | return $count_ip; |
| 378 | 378 | } |