@@ -1,4 +1,4 @@ |
||
1 | -<?php defined('BASEPATH') OR exit('No direct script access allowed'); |
|
1 | +<?php defined('BASEPATH') or exit('No direct script access allowed'); |
|
2 | 2 | |
3 | 3 | class MY_Config extends CI_Config { |
4 | 4 | public function __construct() { |
@@ -1,4 +1,4 @@ |
||
1 | -<?php declare(strict_types=1); defined('BASEPATH') OR exit('No direct script access allowed'); |
|
1 | +<?php declare(strict_types = 1); defined('BASEPATH') OR exit('No direct script access allowed'); |
|
2 | 2 | |
3 | 3 | class WorldThree extends Base_FoolSlide_Site_Model { |
4 | 4 | public $baseURL = 'http://www.slide.world-three.org'; |
@@ -1,4 +1,4 @@ |
||
1 | -<?php declare(strict_types=1); defined('BASEPATH') OR exit('No direct script access allowed'); |
|
1 | +<?php declare(strict_types=1); defined('BASEPATH') or exit('No direct script access allowed'); |
|
2 | 2 | |
3 | 3 | class WorldThree extends Base_FoolSlide_Site_Model { |
4 | 4 | public $baseURL = 'http://www.slide.world-three.org'; |
@@ -1,4 +1,4 @@ |
||
1 | -<?php declare(strict_types=1); defined('BASEPATH') OR exit('No direct script access allowed'); |
|
1 | +<?php declare(strict_types = 1); defined('BASEPATH') OR exit('No direct script access allowed'); |
|
2 | 2 | |
3 | 3 | class WhiteCloudPavillion extends Base_FoolSlide_Site_Model { |
4 | 4 | public $baseURL = 'https://archangelscans.com/free'; |
@@ -1,4 +1,4 @@ |
||
1 | -<?php declare(strict_types=1); defined('BASEPATH') OR exit('No direct script access allowed'); |
|
1 | +<?php declare(strict_types=1); defined('BASEPATH') or exit('No direct script access allowed'); |
|
2 | 2 | |
3 | 3 | class WhiteCloudPavillion extends Base_FoolSlide_Site_Model { |
4 | 4 | public $baseURL = 'https://archangelscans.com/free'; |
@@ -1,4 +1,4 @@ |
||
1 | -<?php declare(strict_types=1); defined('BASEPATH') OR exit('No direct script access allowed'); |
|
1 | +<?php declare(strict_types = 1); defined('BASEPATH') OR exit('No direct script access allowed'); |
|
2 | 2 | |
3 | 3 | class HotChocolateScans extends Base_FoolSlide_Site_Model { |
4 | 4 | public $baseURL = 'http://hotchocolatescans.com/fs'; |
@@ -1,4 +1,4 @@ |
||
1 | -<?php declare(strict_types=1); defined('BASEPATH') OR exit('No direct script access allowed'); |
|
1 | +<?php declare(strict_types=1); defined('BASEPATH') or exit('No direct script access allowed'); |
|
2 | 2 | |
3 | 3 | class HotChocolateScans extends Base_FoolSlide_Site_Model { |
4 | 4 | public $baseURL = 'http://hotchocolatescans.com/fs'; |
@@ -136,7 +136,7 @@ |
||
136 | 136 | | |
137 | 137 | <a href="#" class="set-mal-id" data-mal-id="<?=$row['mal_id']?>" data-mal-type="<?=$row['mal_type']?>">Set MAL ID</a> <?php if(!is_null($row['mal_id']) && $row['mal_type'] == 'chapter') { ?><span>(<small><?=($row['mal_id'] !== '0' ? $row['mal_id'] : 'none')?></small>)</span><?php } ?> |
138 | 138 | | |
139 | - Tags (<a href="#" class="edit-tags small">Edit</a>): <span class="text-lowercase tag-list"><?=($row['has_tags'] ? implode("", array_map(function ($str) { return "<i class='tag'>{$str}</i>"; }, explode(",", $row['tag_list']))) : "none")?></span> |
|
139 | + Tags (<a href="#" class="edit-tags small">Edit</a>): <span class="text-lowercase tag-list"><?=($row['has_tags'] ? implode("", array_map(function($str) { return "<i class='tag'>{$str}</i>"; }, explode(",", $row['tag_list']))) : "none")?></span> |
|
140 | 140 | <div class="input-group hidden tag-edit"> |
141 | 141 | <input type="text" class="form-control" placeholder="tag1,tag2,tag3" maxlength="255" pattern='[a-z0-9-_,]{0,255}' value="<?=$row['tag_list']?>"> |
142 | 142 | <span class="input-group-btn"> |
@@ -1,4 +1,4 @@ |
||
1 | -<?php declare(strict_types=1); defined('BASEPATH') OR exit('No direct script access allowed'); |
|
1 | +<?php declare(strict_types = 1); defined('BASEPATH') OR exit('No direct script access allowed'); |
|
2 | 2 | |
3 | 3 | class YummyGummyScans extends Base_FoolSlide_Site_Model { |
4 | 4 | public $baseURL = 'http://reader.ygscans.com'; |
@@ -1,4 +1,4 @@ |
||
1 | -<?php declare(strict_types=1); defined('BASEPATH') OR exit('No direct script access allowed'); |
|
1 | +<?php declare(strict_types=1); defined('BASEPATH') or exit('No direct script access allowed'); |
|
2 | 2 | |
3 | 3 | class YummyGummyScans extends Base_FoolSlide_Site_Model { |
4 | 4 | public $baseURL = 'http://reader.ygscans.com'; |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare(strict_types=1); defined('BASEPATH') OR exit('No direct script access allowed'); |
|
1 | +<?php declare(strict_types = 1); defined('BASEPATH') OR exit('No direct script access allowed'); |
|
2 | 2 | |
3 | 3 | class MerakiScans extends Base_Site_Model { |
4 | 4 | public $titleFormat = '/^[a-zA-Z0-9_-]+$/'; |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | ]; |
16 | 16 | } |
17 | 17 | |
18 | - public function getTitleData(string $title_url, bool $firstGet = FALSE) : ?array { |
|
18 | + public function getTitleData(string $title_url, bool $firstGet = FALSE) : ? array { |
|
19 | 19 | $titleData = []; |
20 | 20 | |
21 | 21 | $fullURL = $this->getFullTitleURL($title_url); |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | |
37 | 37 | $titleData['latest_chapter'] = preg_replace('/^.*\/([0-9\.]+)\/$/', '$1', (string) $data['nodes_chapter']->getAttribute('href')); |
38 | 38 | |
39 | - $titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) substr($data['nodes_latest']->getAttribute('title'), 13))); |
|
39 | + $titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) substr($data['nodes_latest']->getAttribute('title'), 13))); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | return (!empty($titleData) ? $titleData : NULL); |
@@ -1,4 +1,4 @@ |
||
1 | -<?php declare(strict_types=1); defined('BASEPATH') OR exit('No direct script access allowed'); |
|
1 | +<?php declare(strict_types=1); defined('BASEPATH') or exit('No direct script access allowed'); |
|
2 | 2 | |
3 | 3 | class MerakiScans extends Base_Site_Model { |
4 | 4 | public $titleFormat = '/^[a-zA-Z0-9_-]+$/'; |
@@ -379,7 +379,7 @@ |
||
379 | 379 | /** |
380 | 380 | * logout |
381 | 381 | * |
382 | - * @return void |
|
382 | + * @return boolean |
|
383 | 383 | * @author Mathew |
384 | 384 | **/ |
385 | 385 | public function logout() |
@@ -133,8 +133,8 @@ discard block |
||
133 | 133 | if ( $this->ion_auth_model->forgotten_password($identity) ) //changed |
134 | 134 | { |
135 | 135 | // Get user information |
136 | - $identifier = $this->ion_auth_model->identity_column; // use model identity column, so it can be overridden in a controller |
|
137 | - $user = $this->where($identifier, $identity)->where('active', 1)->users()->row(); // changed to get_user_by_identity from email |
|
136 | + $identifier = $this->ion_auth_model->identity_column; // use model identity column, so it can be overridden in a controller |
|
137 | + $user = $this->where($identifier, $identity)->where('active', 1)->users()->row(); // changed to get_user_by_identity from email |
|
138 | 138 | |
139 | 139 | if ($user) |
140 | 140 | { |
@@ -388,14 +388,14 @@ discard block |
||
388 | 388 | |
389 | 389 | $identity = $this->config->item('identity', 'ion_auth'); |
390 | 390 | |
391 | - if (substr(CI_VERSION, 0, 1) == '2') |
|
391 | + if (substr(CI_VERSION, 0, 1) == '2') |
|
392 | 392 | { |
393 | 393 | $this->session->unset_userdata( array($identity => '', 'id' => '', 'user_id' => '') ); |
394 | - } |
|
395 | - else |
|
396 | - { |
|
397 | - $this->session->unset_userdata( array($identity, 'id', 'user_id') ); |
|
398 | - } |
|
394 | + } |
|
395 | + else |
|
396 | + { |
|
397 | + $this->session->unset_userdata( array($identity, 'id', 'user_id') ); |
|
398 | + } |
|
399 | 399 | |
400 | 400 | // delete the remember me cookies if they exist |
401 | 401 | if (get_cookie($this->config->item('identity_cookie_name', 'ion_auth'))) |
@@ -437,15 +437,15 @@ discard block |
||
437 | 437 | { |
438 | 438 | $this->ion_auth_model->trigger_events('logged_in'); |
439 | 439 | |
440 | - $recheck= $this->ion_auth_model->recheck_session(); |
|
440 | + $recheck= $this->ion_auth_model->recheck_session(); |
|
441 | 441 | |
442 | - //auto-login the user if they are remembered |
|
443 | - if ( ! $recheck && get_cookie($this->config->item('identity_cookie_name', 'ion_auth')) && get_cookie($this->config->item('remember_cookie_name', 'ion_auth'))) |
|
442 | + //auto-login the user if they are remembered |
|
443 | + if ( ! $recheck && get_cookie($this->config->item('identity_cookie_name', 'ion_auth')) && get_cookie($this->config->item('remember_cookie_name', 'ion_auth'))) |
|
444 | 444 | { |
445 | 445 | $recheck = $this->ion_auth_model->login_remembered_user(); |
446 | 446 | } |
447 | 447 | |
448 | - return $recheck; |
|
448 | + return $recheck; |
|
449 | 449 | } |
450 | 450 | |
451 | 451 | /** |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); |
|
1 | +<?php if(!defined('BASEPATH')) exit('No direct script access allowed'); |
|
2 | 2 | /** |
3 | 3 | * Name: Ion Auth |
4 | 4 | * |
@@ -59,17 +59,17 @@ discard block |
||
59 | 59 | $this->config->load('ion_auth', TRUE); |
60 | 60 | $this->load->library(array('email')); |
61 | 61 | $this->lang->load('ion_auth'); |
62 | - $this->load->helper(array('cookie', 'language','url')); |
|
62 | + $this->load->helper(array('cookie', 'language', 'url')); |
|
63 | 63 | |
64 | 64 | $this->load->library('session'); |
65 | 65 | |
66 | 66 | $this->load->model('ion_auth_model'); |
67 | 67 | |
68 | - $this->_cache_user_in_group =& $this->ion_auth_model->_cache_user_in_group; |
|
68 | + $this->_cache_user_in_group = & $this->ion_auth_model->_cache_user_in_group; |
|
69 | 69 | |
70 | 70 | $email_config = $this->config->item('email_config', 'ion_auth'); |
71 | 71 | |
72 | - if ($this->config->item('use_ci_email', 'ion_auth') && isset($email_config) && is_array($email_config)) |
|
72 | + if($this->config->item('use_ci_email', 'ion_auth') && isset($email_config) && is_array($email_config)) |
|
73 | 73 | { |
74 | 74 | $this->email->initialize($email_config); |
75 | 75 | } |
@@ -89,19 +89,19 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public function __call($method, $arguments) |
91 | 91 | { |
92 | - if (!method_exists( $this->ion_auth_model, $method) ) |
|
92 | + if(!method_exists($this->ion_auth_model, $method)) |
|
93 | 93 | { |
94 | - throw new Exception('Undefined method Ion_auth::' . $method . '() called'); |
|
94 | + throw new Exception('Undefined method Ion_auth::'.$method.'() called'); |
|
95 | 95 | } |
96 | 96 | if($method == 'create_user') |
97 | 97 | { |
98 | 98 | return call_user_func_array(array($this, 'register'), $arguments); |
99 | 99 | } |
100 | - if($method=='update_user') |
|
100 | + if($method == 'update_user') |
|
101 | 101 | { |
102 | 102 | return call_user_func_array(array($this, 'update'), $arguments); |
103 | 103 | } |
104 | - return call_user_func_array( array($this->ion_auth_model, $method), $arguments); |
|
104 | + return call_user_func_array(array($this->ion_auth_model, $method), $arguments); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | /** |
@@ -130,13 +130,13 @@ discard block |
||
130 | 130 | */ |
131 | 131 | public function forgotten_password($identity) //changed $email to $identity |
132 | 132 | { |
133 | - if ( $this->ion_auth_model->forgotten_password($identity) ) //changed |
|
133 | + if($this->ion_auth_model->forgotten_password($identity)) //changed |
|
134 | 134 | { |
135 | 135 | // Get user information |
136 | 136 | $identifier = $this->ion_auth_model->identity_column; // use model identity column, so it can be overridden in a controller |
137 | - $user = $this->where($identifier, $identity)->where('active', 1)->users()->row(); // changed to get_user_by_identity from email |
|
137 | + $user = $this->where($identifier, $identity)->where('active', 1)->users()->row(); // changed to get_user_by_identity from email |
|
138 | 138 | |
139 | - if ($user) |
|
139 | + if($user) |
|
140 | 140 | { |
141 | 141 | $data = array( |
142 | 142 | 'identity' => $user->{$this->config->item('identity', 'ion_auth')}, |
@@ -154,10 +154,10 @@ discard block |
||
154 | 154 | $this->email->clear(); |
155 | 155 | $this->email->from($this->config->item('admin_email', 'ion_auth'), $this->config->item('site_title', 'ion_auth')); |
156 | 156 | $this->email->to($user->email); |
157 | - $this->email->subject($this->config->item('site_title', 'ion_auth') . ' - ' . $this->lang->line('email_forgotten_password_subject')); |
|
157 | + $this->email->subject($this->config->item('site_title', 'ion_auth').' - '.$this->lang->line('email_forgotten_password_subject')); |
|
158 | 158 | $this->email->message($message); |
159 | 159 | |
160 | - if ($this->email->send()) |
|
160 | + if($this->email->send()) |
|
161 | 161 | { |
162 | 162 | $this->set_message('forgot_password_successful'); |
163 | 163 | return TRUE; |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | $identity = $this->config->item('identity', 'ion_auth'); |
197 | 197 | $profile = $this->where('forgotten_password_code', $code)->users()->row(); //pass the code to profile |
198 | 198 | |
199 | - if (!$profile) |
|
199 | + if(!$profile) |
|
200 | 200 | { |
201 | 201 | $this->ion_auth_model->trigger_events(array('post_password_change', 'password_change_unsuccessful')); |
202 | 202 | $this->set_error('password_change_unsuccessful'); |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | |
206 | 206 | $new_password = $this->ion_auth_model->forgotten_password_complete($code, $profile->salt); |
207 | 207 | |
208 | - if ($new_password) |
|
208 | + if($new_password) |
|
209 | 209 | { |
210 | 210 | $data = array( |
211 | 211 | 'identity' => $profile->{$identity}, |
@@ -224,10 +224,10 @@ discard block |
||
224 | 224 | $this->email->clear(); |
225 | 225 | $this->email->from($this->config->item('admin_email', 'ion_auth'), $this->config->item('site_title', 'ion_auth')); |
226 | 226 | $this->email->to($profile->email); |
227 | - $this->email->subject($this->config->item('site_title', 'ion_auth') . ' - ' . $this->lang->line('email_new_password_subject')); |
|
227 | + $this->email->subject($this->config->item('site_title', 'ion_auth').' - '.$this->lang->line('email_new_password_subject')); |
|
228 | 228 | $this->email->message($message); |
229 | 229 | |
230 | - if ($this->email->send()) |
|
230 | + if($this->email->send()) |
|
231 | 231 | { |
232 | 232 | $this->set_message('password_change_successful'); |
233 | 233 | $this->ion_auth_model->trigger_events(array('post_password_change', 'password_change_successful')); |
@@ -258,17 +258,17 @@ discard block |
||
258 | 258 | { |
259 | 259 | $profile = $this->where('forgotten_password_code', $code)->users()->row(); //pass the code to profile |
260 | 260 | |
261 | - if (!is_object($profile)) |
|
261 | + if(!is_object($profile)) |
|
262 | 262 | { |
263 | 263 | $this->set_error('password_change_unsuccessful'); |
264 | 264 | return FALSE; |
265 | 265 | } |
266 | 266 | else |
267 | 267 | { |
268 | - if ($this->config->item('forgot_password_expiration', 'ion_auth') > 0) { |
|
268 | + if($this->config->item('forgot_password_expiration', 'ion_auth') > 0) { |
|
269 | 269 | //Make sure it isn't expired |
270 | 270 | $expiration = $this->config->item('forgot_password_expiration', 'ion_auth'); |
271 | - if (time() - $profile->forgotten_password_time > $expiration) { |
|
271 | + if(time() - $profile->forgotten_password_time > $expiration) { |
|
272 | 272 | //it has expired |
273 | 273 | $this->clear_forgotten_password_code($code); |
274 | 274 | $this->set_error('password_change_unsuccessful'); |
@@ -298,9 +298,9 @@ discard block |
||
298 | 298 | |
299 | 299 | $id = $this->ion_auth_model->register($identity, $password, $email, $additional_data, $group_ids); |
300 | 300 | |
301 | - if (!$email_activation) |
|
301 | + if(!$email_activation) |
|
302 | 302 | { |
303 | - if ($id !== FALSE) |
|
303 | + if($id !== FALSE) |
|
304 | 304 | { |
305 | 305 | $this->set_message('account_creation_successful'); |
306 | 306 | $this->ion_auth_model->trigger_events(array('post_account_creation', 'post_account_creation_successful')); |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | } |
316 | 316 | else |
317 | 317 | { |
318 | - if (!$id) |
|
318 | + if(!$id) |
|
319 | 319 | { |
320 | 320 | $this->set_error('account_creation_unsuccessful'); |
321 | 321 | return FALSE; |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | $this->ion_auth_model->clear_messages(); |
329 | 329 | |
330 | 330 | |
331 | - if (!$deactivate) |
|
331 | + if(!$deactivate) |
|
332 | 332 | { |
333 | 333 | $this->set_error('deactivate_unsuccessful'); |
334 | 334 | $this->ion_auth_model->trigger_events(array('post_account_creation', 'post_account_creation_unsuccessful')); |
@@ -358,10 +358,10 @@ discard block |
||
358 | 358 | $this->email->clear(); |
359 | 359 | $this->email->from($this->config->item('admin_email', 'ion_auth'), $this->config->item('site_title', 'ion_auth')); |
360 | 360 | $this->email->to($email); |
361 | - $this->email->subject($this->config->item('site_title', 'ion_auth') . ' - ' . $this->lang->line('email_activation_subject')); |
|
361 | + $this->email->subject($this->config->item('site_title', 'ion_auth').' - '.$this->lang->line('email_activation_subject')); |
|
362 | 362 | $this->email->message($message); |
363 | 363 | |
364 | - if ($this->email->send() == TRUE) |
|
364 | + if($this->email->send() == TRUE) |
|
365 | 365 | { |
366 | 366 | $this->ion_auth_model->trigger_events(array('post_account_creation', 'post_account_creation_successful', 'activation_email_successful')); |
367 | 367 | $this->set_message('activation_email_successful'); |
@@ -388,21 +388,21 @@ discard block |
||
388 | 388 | |
389 | 389 | $identity = $this->config->item('identity', 'ion_auth'); |
390 | 390 | |
391 | - if (substr(CI_VERSION, 0, 1) == '2') |
|
391 | + if(substr(CI_VERSION, 0, 1) == '2') |
|
392 | 392 | { |
393 | - $this->session->unset_userdata( array($identity => '', 'id' => '', 'user_id' => '') ); |
|
393 | + $this->session->unset_userdata(array($identity => '', 'id' => '', 'user_id' => '')); |
|
394 | 394 | } |
395 | 395 | else |
396 | 396 | { |
397 | - $this->session->unset_userdata( array($identity, 'id', 'user_id') ); |
|
397 | + $this->session->unset_userdata(array($identity, 'id', 'user_id')); |
|
398 | 398 | } |
399 | 399 | |
400 | 400 | // delete the remember me cookies if they exist |
401 | - if (get_cookie($this->config->item('identity_cookie_name', 'ion_auth'))) |
|
401 | + if(get_cookie($this->config->item('identity_cookie_name', 'ion_auth'))) |
|
402 | 402 | { |
403 | 403 | delete_cookie($this->config->item('identity_cookie_name', 'ion_auth')); |
404 | 404 | } |
405 | - if (get_cookie($this->config->item('remember_cookie_name', 'ion_auth'))) |
|
405 | + if(get_cookie($this->config->item('remember_cookie_name', 'ion_auth'))) |
|
406 | 406 | { |
407 | 407 | delete_cookie($this->config->item('remember_cookie_name', 'ion_auth')); |
408 | 408 | } |
@@ -411,13 +411,13 @@ discard block |
||
411 | 411 | $this->session->sess_destroy(); |
412 | 412 | |
413 | 413 | //Recreate the session |
414 | - if (substr(CI_VERSION, 0, 1) == '2') |
|
414 | + if(substr(CI_VERSION, 0, 1) == '2') |
|
415 | 415 | { |
416 | 416 | $this->session->sess_create(); |
417 | 417 | } |
418 | 418 | else |
419 | 419 | { |
420 | - if (version_compare(PHP_VERSION, '7.0.0') >= 0) { |
|
420 | + if(version_compare(PHP_VERSION, '7.0.0') >= 0) { |
|
421 | 421 | session_start(); |
422 | 422 | } |
423 | 423 | $this->session->sess_regenerate(TRUE); |
@@ -437,10 +437,10 @@ discard block |
||
437 | 437 | { |
438 | 438 | $this->ion_auth_model->trigger_events('logged_in'); |
439 | 439 | |
440 | - $recheck= $this->ion_auth_model->recheck_session(); |
|
440 | + $recheck = $this->ion_auth_model->recheck_session(); |
|
441 | 441 | |
442 | 442 | //auto-login the user if they are remembered |
443 | - if ( ! $recheck && get_cookie($this->config->item('identity_cookie_name', 'ion_auth')) && get_cookie($this->config->item('remember_cookie_name', 'ion_auth'))) |
|
443 | + if(!$recheck && get_cookie($this->config->item('identity_cookie_name', 'ion_auth')) && get_cookie($this->config->item('remember_cookie_name', 'ion_auth'))) |
|
444 | 444 | { |
445 | 445 | $recheck = $this->ion_auth_model->login_remembered_user(); |
446 | 446 | } |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | public function get_user_id() |
458 | 458 | { |
459 | 459 | $user_id = $this->session->userdata('user_id'); |
460 | - if (!empty($user_id)) |
|
460 | + if(!empty($user_id)) |
|
461 | 461 | { |
462 | 462 | return $user_id; |
463 | 463 | } |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | * @return bool |
472 | 472 | * @author Ben Edmunds |
473 | 473 | **/ |
474 | - public function is_admin($id=false) |
|
474 | + public function is_admin($id = false) |
|
475 | 475 | { |
476 | 476 | $this->ion_auth_model->trigger_events('is_admin'); |
477 | 477 | |
@@ -490,18 +490,18 @@ discard block |
||
490 | 490 | * @return bool |
491 | 491 | * @author Phil Sturgeon |
492 | 492 | **/ |
493 | - public function in_group($check_group, $id=false, $check_all = false) |
|
493 | + public function in_group($check_group, $id = false, $check_all = false) |
|
494 | 494 | { |
495 | 495 | $this->ion_auth_model->trigger_events('in_group'); |
496 | 496 | |
497 | 497 | $id || $id = $this->session->userdata('user_id'); |
498 | 498 | |
499 | - if (!is_array($check_group)) |
|
499 | + if(!is_array($check_group)) |
|
500 | 500 | { |
501 | 501 | $check_group = array($check_group); |
502 | 502 | } |
503 | 503 | |
504 | - if (isset($this->_cache_user_in_group[$id])) |
|
504 | + if(isset($this->_cache_user_in_group[$id])) |
|
505 | 505 | { |
506 | 506 | $groups_array = $this->_cache_user_in_group[$id]; |
507 | 507 | } |
@@ -509,13 +509,13 @@ discard block |
||
509 | 509 | { |
510 | 510 | $users_groups = $this->ion_auth_model->get_users_groups($id)->result(); |
511 | 511 | $groups_array = array(); |
512 | - foreach ($users_groups as $group) |
|
512 | + foreach($users_groups as $group) |
|
513 | 513 | { |
514 | 514 | $groups_array[$group->id] = $group->name; |
515 | 515 | } |
516 | 516 | $this->_cache_user_in_group[$id] = $groups_array; |
517 | 517 | } |
518 | - foreach ($check_group as $key => $value) |
|
518 | + foreach($check_group as $key => $value) |
|
519 | 519 | { |
520 | 520 | $groups = (is_string($value)) ? $groups_array : array_keys($groups_array); |
521 | 521 | |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | * if !all (default), in_array |
524 | 524 | * if all, !in_array |
525 | 525 | */ |
526 | - if (in_array($value, $groups) xor $check_all) |
|
526 | + if(in_array($value, $groups) xor $check_all) |
|
527 | 527 | { |
528 | 528 | /** |
529 | 529 | * if !all (default), true |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('BASEPATH')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Name: Ion Auth |
4 | 6 | * |
@@ -19,8 +21,7 @@ discard block |
||
19 | 21 | * |
20 | 22 | */ |
21 | 23 | |
22 | -class Ion_auth |
|
23 | -{ |
|
24 | +class Ion_auth { |
|
24 | 25 | /** |
25 | 26 | * account status ('not_activated', etc ...) |
26 | 27 | * |
@@ -54,8 +55,7 @@ discard block |
||
54 | 55 | * |
55 | 56 | * @author Ben |
56 | 57 | */ |
57 | - public function __construct() |
|
58 | - { |
|
58 | + public function __construct() { |
|
59 | 59 | $this->config->load('ion_auth', TRUE); |
60 | 60 | $this->load->library(array('email')); |
61 | 61 | $this->lang->load('ion_auth'); |
@@ -69,8 +69,7 @@ discard block |
||
69 | 69 | |
70 | 70 | $email_config = $this->config->item('email_config', 'ion_auth'); |
71 | 71 | |
72 | - if ($this->config->item('use_ci_email', 'ion_auth') && isset($email_config) && is_array($email_config)) |
|
73 | - { |
|
72 | + if ($this->config->item('use_ci_email', 'ion_auth') && isset($email_config) && is_array($email_config)) { |
|
74 | 73 | $this->email->initialize($email_config); |
75 | 74 | } |
76 | 75 | |
@@ -87,18 +86,14 @@ discard block |
||
87 | 86 | * @return mixed |
88 | 87 | * @throws Exception |
89 | 88 | */ |
90 | - public function __call($method, $arguments) |
|
91 | - { |
|
92 | - if (!method_exists( $this->ion_auth_model, $method) ) |
|
93 | - { |
|
89 | + public function __call($method, $arguments) { |
|
90 | + if (!method_exists( $this->ion_auth_model, $method) ) { |
|
94 | 91 | throw new Exception('Undefined method Ion_auth::' . $method . '() called'); |
95 | 92 | } |
96 | - if($method == 'create_user') |
|
97 | - { |
|
93 | + if($method == 'create_user') { |
|
98 | 94 | return call_user_func_array(array($this, 'register'), $arguments); |
99 | 95 | } |
100 | - if($method=='update_user') |
|
101 | - { |
|
96 | + if($method=='update_user') { |
|
102 | 97 | return call_user_func_array(array($this, 'update'), $arguments); |
103 | 98 | } |
104 | 99 | return call_user_func_array( array($this->ion_auth_model, $method), $arguments); |
@@ -115,8 +110,7 @@ discard block |
||
115 | 110 | * @param $var |
116 | 111 | * @return mixed |
117 | 112 | */ |
118 | - public function __get($var) |
|
119 | - { |
|
113 | + public function __get($var) { |
|
120 | 114 | return get_instance()->$var; |
121 | 115 | } |
122 | 116 | |
@@ -130,26 +124,25 @@ discard block |
||
130 | 124 | */ |
131 | 125 | public function forgotten_password($identity) //changed $email to $identity |
132 | 126 | { |
133 | - if ( $this->ion_auth_model->forgotten_password($identity) ) //changed |
|
127 | + if ( $this->ion_auth_model->forgotten_password($identity) ) { |
|
128 | + //changed |
|
134 | 129 | { |
135 | 130 | // Get user information |
136 | - $identifier = $this->ion_auth_model->identity_column; // use model identity column, so it can be overridden in a controller |
|
131 | + $identifier = $this->ion_auth_model->identity_column; |
|
132 | + } |
|
133 | + // use model identity column, so it can be overridden in a controller |
|
137 | 134 | $user = $this->where($identifier, $identity)->where('active', 1)->users()->row(); // changed to get_user_by_identity from email |
138 | 135 | |
139 | - if ($user) |
|
140 | - { |
|
136 | + if ($user) { |
|
141 | 137 | $data = array( |
142 | 138 | 'identity' => $user->{$this->config->item('identity', 'ion_auth')}, |
143 | 139 | 'forgotten_password_code' => $user->forgotten_password_code |
144 | 140 | ); |
145 | 141 | |
146 | - if(!$this->config->item('use_ci_email', 'ion_auth')) |
|
147 | - { |
|
142 | + if(!$this->config->item('use_ci_email', 'ion_auth')) { |
|
148 | 143 | $this->set_message('forgot_password_successful'); |
149 | 144 | return $data; |
150 | - } |
|
151 | - else |
|
152 | - { |
|
145 | + } else { |
|
153 | 146 | $message = $this->load->view($this->config->item('email_templates', 'ion_auth').$this->config->item('email_forgot_password', 'ion_auth'), $data, true); |
154 | 147 | $this->email->clear(); |
155 | 148 | $this->email->from($this->config->item('admin_email', 'ion_auth'), $this->config->item('site_title', 'ion_auth')); |
@@ -157,26 +150,19 @@ discard block |
||
157 | 150 | $this->email->subject($this->config->item('site_title', 'ion_auth') . ' - ' . $this->lang->line('email_forgotten_password_subject')); |
158 | 151 | $this->email->message($message); |
159 | 152 | |
160 | - if ($this->email->send()) |
|
161 | - { |
|
153 | + if ($this->email->send()) { |
|
162 | 154 | $this->set_message('forgot_password_successful'); |
163 | 155 | return TRUE; |
164 | - } |
|
165 | - else |
|
166 | - { |
|
156 | + } else { |
|
167 | 157 | $this->set_error('forgot_password_unsuccessful'); |
168 | 158 | return FALSE; |
169 | 159 | } |
170 | 160 | } |
171 | - } |
|
172 | - else |
|
173 | - { |
|
161 | + } else { |
|
174 | 162 | $this->set_error('forgot_password_unsuccessful'); |
175 | 163 | return FALSE; |
176 | 164 | } |
177 | - } |
|
178 | - else |
|
179 | - { |
|
165 | + } else { |
|
180 | 166 | $this->set_error('forgot_password_unsuccessful'); |
181 | 167 | return FALSE; |
182 | 168 | } |
@@ -189,15 +175,13 @@ discard block |
||
189 | 175 | * @author Mathew |
190 | 176 | * @return bool |
191 | 177 | */ |
192 | - public function forgotten_password_complete($code) |
|
193 | - { |
|
178 | + public function forgotten_password_complete($code) { |
|
194 | 179 | $this->ion_auth_model->trigger_events('pre_password_change'); |
195 | 180 | |
196 | 181 | $identity = $this->config->item('identity', 'ion_auth'); |
197 | 182 | $profile = $this->where('forgotten_password_code', $code)->users()->row(); //pass the code to profile |
198 | 183 | |
199 | - if (!$profile) |
|
200 | - { |
|
184 | + if (!$profile) { |
|
201 | 185 | $this->ion_auth_model->trigger_events(array('post_password_change', 'password_change_unsuccessful')); |
202 | 186 | $this->set_error('password_change_unsuccessful'); |
203 | 187 | return FALSE; |
@@ -205,20 +189,16 @@ discard block |
||
205 | 189 | |
206 | 190 | $new_password = $this->ion_auth_model->forgotten_password_complete($code, $profile->salt); |
207 | 191 | |
208 | - if ($new_password) |
|
209 | - { |
|
192 | + if ($new_password) { |
|
210 | 193 | $data = array( |
211 | 194 | 'identity' => $profile->{$identity}, |
212 | 195 | 'new_password' => $new_password |
213 | 196 | ); |
214 | - if(!$this->config->item('use_ci_email', 'ion_auth')) |
|
215 | - { |
|
197 | + if(!$this->config->item('use_ci_email', 'ion_auth')) { |
|
216 | 198 | $this->set_message('password_change_successful'); |
217 | 199 | $this->ion_auth_model->trigger_events(array('post_password_change', 'password_change_successful')); |
218 | 200 | return $data; |
219 | - } |
|
220 | - else |
|
221 | - { |
|
201 | + } else { |
|
222 | 202 | $message = $this->load->view($this->config->item('email_templates', 'ion_auth').$this->config->item('email_forgot_password_complete', 'ion_auth'), $data, true); |
223 | 203 | |
224 | 204 | $this->email->clear(); |
@@ -227,14 +207,11 @@ discard block |
||
227 | 207 | $this->email->subject($this->config->item('site_title', 'ion_auth') . ' - ' . $this->lang->line('email_new_password_subject')); |
228 | 208 | $this->email->message($message); |
229 | 209 | |
230 | - if ($this->email->send()) |
|
231 | - { |
|
210 | + if ($this->email->send()) { |
|
232 | 211 | $this->set_message('password_change_successful'); |
233 | 212 | $this->ion_auth_model->trigger_events(array('post_password_change', 'password_change_successful')); |
234 | 213 | return TRUE; |
235 | - } |
|
236 | - else |
|
237 | - { |
|
214 | + } else { |
|
238 | 215 | $this->set_error('password_change_unsuccessful'); |
239 | 216 | $this->ion_auth_model->trigger_events(array('post_password_change', 'password_change_unsuccessful')); |
240 | 217 | return FALSE; |
@@ -254,17 +231,13 @@ discard block |
||
254 | 231 | * @author Michael |
255 | 232 | * @return bool |
256 | 233 | */ |
257 | - public function forgotten_password_check($code) |
|
258 | - { |
|
234 | + public function forgotten_password_check($code) { |
|
259 | 235 | $profile = $this->where('forgotten_password_code', $code)->users()->row(); //pass the code to profile |
260 | 236 | |
261 | - if (!is_object($profile)) |
|
262 | - { |
|
237 | + if (!is_object($profile)) { |
|
263 | 238 | $this->set_error('password_change_unsuccessful'); |
264 | 239 | return FALSE; |
265 | - } |
|
266 | - else |
|
267 | - { |
|
240 | + } else { |
|
268 | 241 | if ($this->config->item('forgot_password_expiration', 'ion_auth') > 0) { |
269 | 242 | //Make sure it isn't expired |
270 | 243 | $expiration = $this->config->item('forgot_password_expiration', 'ion_auth'); |
@@ -298,25 +271,18 @@ discard block |
||
298 | 271 | |
299 | 272 | $id = $this->ion_auth_model->register($identity, $password, $email, $additional_data, $group_ids); |
300 | 273 | |
301 | - if (!$email_activation) |
|
302 | - { |
|
303 | - if ($id !== FALSE) |
|
304 | - { |
|
274 | + if (!$email_activation) { |
|
275 | + if ($id !== FALSE) { |
|
305 | 276 | $this->set_message('account_creation_successful'); |
306 | 277 | $this->ion_auth_model->trigger_events(array('post_account_creation', 'post_account_creation_successful')); |
307 | 278 | return $id; |
308 | - } |
|
309 | - else |
|
310 | - { |
|
279 | + } else { |
|
311 | 280 | $this->set_error('account_creation_unsuccessful'); |
312 | 281 | $this->ion_auth_model->trigger_events(array('post_account_creation', 'post_account_creation_unsuccessful')); |
313 | 282 | return FALSE; |
314 | 283 | } |
315 | - } |
|
316 | - else |
|
317 | - { |
|
318 | - if (!$id) |
|
319 | - { |
|
284 | + } else { |
|
285 | + if (!$id) { |
|
320 | 286 | $this->set_error('account_creation_unsuccessful'); |
321 | 287 | return FALSE; |
322 | 288 | } |
@@ -328,8 +294,7 @@ discard block |
||
328 | 294 | $this->ion_auth_model->clear_messages(); |
329 | 295 | |
330 | 296 | |
331 | - if (!$deactivate) |
|
332 | - { |
|
297 | + if (!$deactivate) { |
|
333 | 298 | $this->set_error('deactivate_unsuccessful'); |
334 | 299 | $this->ion_auth_model->trigger_events(array('post_account_creation', 'post_account_creation_unsuccessful')); |
335 | 300 | return FALSE; |
@@ -345,14 +310,11 @@ discard block |
||
345 | 310 | 'email' => $email, |
346 | 311 | 'activation' => $activation_code, |
347 | 312 | ); |
348 | - if(!$this->config->item('use_ci_email', 'ion_auth')) |
|
349 | - { |
|
313 | + if(!$this->config->item('use_ci_email', 'ion_auth')) { |
|
350 | 314 | $this->ion_auth_model->trigger_events(array('post_account_creation', 'post_account_creation_successful', 'activation_email_successful')); |
351 | 315 | $this->set_message('activation_email_successful'); |
352 | 316 | return $data; |
353 | - } |
|
354 | - else |
|
355 | - { |
|
317 | + } else { |
|
356 | 318 | $message = $this->load->view($this->config->item('email_templates', 'ion_auth').$this->config->item('email_activate', 'ion_auth'), $data, true); |
357 | 319 | |
358 | 320 | $this->email->clear(); |
@@ -361,8 +323,7 @@ discard block |
||
361 | 323 | $this->email->subject($this->config->item('site_title', 'ion_auth') . ' - ' . $this->lang->line('email_activation_subject')); |
362 | 324 | $this->email->message($message); |
363 | 325 | |
364 | - if ($this->email->send() == TRUE) |
|
365 | - { |
|
326 | + if ($this->email->send() == TRUE) { |
|
366 | 327 | $this->ion_auth_model->trigger_events(array('post_account_creation', 'post_account_creation_successful', 'activation_email_successful')); |
367 | 328 | $this->set_message('activation_email_successful'); |
368 | 329 | return $id; |
@@ -382,28 +343,22 @@ discard block |
||
382 | 343 | * @return void |
383 | 344 | * @author Mathew |
384 | 345 | **/ |
385 | - public function logout() |
|
386 | - { |
|
346 | + public function logout() { |
|
387 | 347 | $this->ion_auth_model->trigger_events('logout'); |
388 | 348 | |
389 | 349 | $identity = $this->config->item('identity', 'ion_auth'); |
390 | 350 | |
391 | - if (substr(CI_VERSION, 0, 1) == '2') |
|
392 | - { |
|
351 | + if (substr(CI_VERSION, 0, 1) == '2') { |
|
393 | 352 | $this->session->unset_userdata( array($identity => '', 'id' => '', 'user_id' => '') ); |
394 | - } |
|
395 | - else |
|
396 | - { |
|
353 | + } else { |
|
397 | 354 | $this->session->unset_userdata( array($identity, 'id', 'user_id') ); |
398 | 355 | } |
399 | 356 | |
400 | 357 | // delete the remember me cookies if they exist |
401 | - if (get_cookie($this->config->item('identity_cookie_name', 'ion_auth'))) |
|
402 | - { |
|
358 | + if (get_cookie($this->config->item('identity_cookie_name', 'ion_auth'))) { |
|
403 | 359 | delete_cookie($this->config->item('identity_cookie_name', 'ion_auth')); |
404 | 360 | } |
405 | - if (get_cookie($this->config->item('remember_cookie_name', 'ion_auth'))) |
|
406 | - { |
|
361 | + if (get_cookie($this->config->item('remember_cookie_name', 'ion_auth'))) { |
|
407 | 362 | delete_cookie($this->config->item('remember_cookie_name', 'ion_auth')); |
408 | 363 | } |
409 | 364 | |
@@ -411,12 +366,9 @@ discard block |
||
411 | 366 | $this->session->sess_destroy(); |
412 | 367 | |
413 | 368 | //Recreate the session |
414 | - if (substr(CI_VERSION, 0, 1) == '2') |
|
415 | - { |
|
369 | + if (substr(CI_VERSION, 0, 1) == '2') { |
|
416 | 370 | $this->session->sess_create(); |
417 | - } |
|
418 | - else |
|
419 | - { |
|
371 | + } else { |
|
420 | 372 | if (version_compare(PHP_VERSION, '7.0.0') >= 0) { |
421 | 373 | session_start(); |
422 | 374 | } |
@@ -433,15 +385,13 @@ discard block |
||
433 | 385 | * @return bool |
434 | 386 | * @author Mathew |
435 | 387 | **/ |
436 | - public function logged_in() |
|
437 | - { |
|
388 | + public function logged_in() { |
|
438 | 389 | $this->ion_auth_model->trigger_events('logged_in'); |
439 | 390 | |
440 | 391 | $recheck= $this->ion_auth_model->recheck_session(); |
441 | 392 | |
442 | 393 | //auto-login the user if they are remembered |
443 | - if ( ! $recheck && get_cookie($this->config->item('identity_cookie_name', 'ion_auth')) && get_cookie($this->config->item('remember_cookie_name', 'ion_auth'))) |
|
444 | - { |
|
394 | + if ( ! $recheck && get_cookie($this->config->item('identity_cookie_name', 'ion_auth')) && get_cookie($this->config->item('remember_cookie_name', 'ion_auth'))) { |
|
445 | 395 | $recheck = $this->ion_auth_model->login_remembered_user(); |
446 | 396 | } |
447 | 397 | |
@@ -454,11 +404,9 @@ discard block |
||
454 | 404 | * @return integer |
455 | 405 | * @author jrmadsen67 |
456 | 406 | **/ |
457 | - public function get_user_id() |
|
458 | - { |
|
407 | + public function get_user_id() { |
|
459 | 408 | $user_id = $this->session->userdata('user_id'); |
460 | - if (!empty($user_id)) |
|
461 | - { |
|
409 | + if (!empty($user_id)) { |
|
462 | 410 | return $user_id; |
463 | 411 | } |
464 | 412 | return null; |
@@ -471,8 +419,7 @@ discard block |
||
471 | 419 | * @return bool |
472 | 420 | * @author Ben Edmunds |
473 | 421 | **/ |
474 | - public function is_admin($id=false) |
|
475 | - { |
|
422 | + public function is_admin($id=false) { |
|
476 | 423 | $this->ion_auth_model->trigger_events('is_admin'); |
477 | 424 | |
478 | 425 | $admin_group = $this->config->item('admin_group', 'ion_auth'); |
@@ -490,41 +437,33 @@ discard block |
||
490 | 437 | * @return bool |
491 | 438 | * @author Phil Sturgeon |
492 | 439 | **/ |
493 | - public function in_group($check_group, $id=false, $check_all = false) |
|
494 | - { |
|
440 | + public function in_group($check_group, $id=false, $check_all = false) { |
|
495 | 441 | $this->ion_auth_model->trigger_events('in_group'); |
496 | 442 | |
497 | 443 | $id || $id = $this->session->userdata('user_id'); |
498 | 444 | |
499 | - if (!is_array($check_group)) |
|
500 | - { |
|
445 | + if (!is_array($check_group)) { |
|
501 | 446 | $check_group = array($check_group); |
502 | 447 | } |
503 | 448 | |
504 | - if (isset($this->_cache_user_in_group[$id])) |
|
505 | - { |
|
449 | + if (isset($this->_cache_user_in_group[$id])) { |
|
506 | 450 | $groups_array = $this->_cache_user_in_group[$id]; |
507 | - } |
|
508 | - else |
|
509 | - { |
|
451 | + } else { |
|
510 | 452 | $users_groups = $this->ion_auth_model->get_users_groups($id)->result(); |
511 | 453 | $groups_array = array(); |
512 | - foreach ($users_groups as $group) |
|
513 | - { |
|
454 | + foreach ($users_groups as $group) { |
|
514 | 455 | $groups_array[$group->id] = $group->name; |
515 | 456 | } |
516 | 457 | $this->_cache_user_in_group[$id] = $groups_array; |
517 | 458 | } |
518 | - foreach ($check_group as $key => $value) |
|
519 | - { |
|
459 | + foreach ($check_group as $key => $value) { |
|
520 | 460 | $groups = (is_string($value)) ? $groups_array : array_keys($groups_array); |
521 | 461 | |
522 | 462 | /** |
523 | 463 | * if !all (default), in_array |
524 | 464 | * if all, !in_array |
525 | 465 | */ |
526 | - if (in_array($value, $groups) xor $check_all) |
|
527 | - { |
|
466 | + if (in_array($value, $groups) xor $check_all) { |
|
528 | 467 | /** |
529 | 468 | * if !all (default), true |
530 | 469 | * if all, false |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | } |
151 | 151 | else |
152 | 152 | { |
153 | - $message = $this->load->view($this->config->item('email_templates', 'ion_auth').$this->config->item('email_forgot_password', 'ion_auth'), $data, true); |
|
153 | + $message = $this->load->view($this->config->item('email_templates', 'ion_auth').$this->config->item('email_forgot_password', 'ion_auth'), $data, TRUE); |
|
154 | 154 | $this->email->clear(); |
155 | 155 | $this->email->from($this->config->item('admin_email', 'ion_auth'), $this->config->item('site_title', 'ion_auth')); |
156 | 156 | $this->email->to($user->email); |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | } |
220 | 220 | else |
221 | 221 | { |
222 | - $message = $this->load->view($this->config->item('email_templates', 'ion_auth').$this->config->item('email_forgot_password_complete', 'ion_auth'), $data, true); |
|
222 | + $message = $this->load->view($this->config->item('email_templates', 'ion_auth').$this->config->item('email_forgot_password_complete', 'ion_auth'), $data, TRUE); |
|
223 | 223 | |
224 | 224 | $this->email->clear(); |
225 | 225 | $this->email->from($this->config->item('admin_email', 'ion_auth'), $this->config->item('site_title', 'ion_auth')); |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | } |
354 | 354 | else |
355 | 355 | { |
356 | - $message = $this->load->view($this->config->item('email_templates', 'ion_auth').$this->config->item('email_activate', 'ion_auth'), $data, true); |
|
356 | + $message = $this->load->view($this->config->item('email_templates', 'ion_auth').$this->config->item('email_activate', 'ion_auth'), $data, TRUE); |
|
357 | 357 | |
358 | 358 | $this->email->clear(); |
359 | 359 | $this->email->from($this->config->item('admin_email', 'ion_auth'), $this->config->item('site_title', 'ion_auth')); |
@@ -461,7 +461,7 @@ discard block |
||
461 | 461 | { |
462 | 462 | return $user_id; |
463 | 463 | } |
464 | - return null; |
|
464 | + return NULL; |
|
465 | 465 | } |
466 | 466 | |
467 | 467 | |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | * @return bool |
472 | 472 | * @author Ben Edmunds |
473 | 473 | **/ |
474 | - public function is_admin($id=false) |
|
474 | + public function is_admin($id=FALSE) |
|
475 | 475 | { |
476 | 476 | $this->ion_auth_model->trigger_events('is_admin'); |
477 | 477 | |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | * @return bool |
491 | 491 | * @author Phil Sturgeon |
492 | 492 | **/ |
493 | - public function in_group($check_group, $id=false, $check_all = false) |
|
493 | + public function in_group($check_group, $id=FALSE, $check_all = FALSE) |
|
494 | 494 | { |
495 | 495 | $this->ion_auth_model->trigger_events('in_group'); |
496 | 496 |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | /** |
258 | 258 | * Hashes the password to be stored in the database. |
259 | 259 | * |
260 | - * @return void |
|
260 | + * @return false|string |
|
261 | 261 | * @author Mathew |
262 | 262 | **/ |
263 | 263 | public function hash_password($password, $salt=false, $use_sha1_override=FALSE) |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | * This function takes a password and validates it |
290 | 290 | * against an entry in the users table. |
291 | 291 | * |
292 | - * @return void |
|
292 | + * @return boolean |
|
293 | 293 | * @author Mathew |
294 | 294 | **/ |
295 | 295 | public function hash_password_db($id, $password, $use_sha1_override=FALSE) |
@@ -350,7 +350,8 @@ discard block |
||
350 | 350 | /** |
351 | 351 | * Generates a random salt value for forgotten passwords or any other keys. Uses SHA1. |
352 | 352 | * |
353 | - * @return void |
|
353 | + * @param string $password |
|
354 | + * @return false|string |
|
354 | 355 | * @author Mathew |
355 | 356 | **/ |
356 | 357 | public function hash_code($password) |
@@ -363,7 +364,7 @@ discard block |
||
363 | 364 | * |
364 | 365 | * Salt generation code taken from https://github.com/ircmaxell/password_compat/blob/master/lib/password.php |
365 | 366 | * |
366 | - * @return void |
|
367 | + * @return string |
|
367 | 368 | * @author Anthony Ferrera |
368 | 369 | **/ |
369 | 370 | public function salt() |
@@ -446,7 +447,7 @@ discard block |
||
446 | 447 | /** |
447 | 448 | * activate |
448 | 449 | * |
449 | - * @return void |
|
450 | + * @return boolean |
|
450 | 451 | * @author Mathew |
451 | 452 | **/ |
452 | 453 | public function activate($id, $code = false) |
@@ -512,7 +513,7 @@ discard block |
||
512 | 513 | /** |
513 | 514 | * Deactivate |
514 | 515 | * |
515 | - * @return void |
|
516 | + * @return boolean |
|
516 | 517 | * @author Mathew |
517 | 518 | **/ |
518 | 519 | public function deactivate($id = NULL) |
@@ -1257,6 +1258,9 @@ discard block |
||
1257 | 1258 | return FALSE; |
1258 | 1259 | } |
1259 | 1260 | |
1261 | + /** |
|
1262 | + * @param integer $limit |
|
1263 | + */ |
|
1260 | 1264 | public function limit($limit) |
1261 | 1265 | { |
1262 | 1266 | $this->trigger_events('limit'); |
@@ -1273,6 +1277,9 @@ discard block |
||
1273 | 1277 | return $this; |
1274 | 1278 | } |
1275 | 1279 | |
1280 | + /** |
|
1281 | + * @param string $where |
|
1282 | + */ |
|
1276 | 1283 | public function where($where, $value = NULL) |
1277 | 1284 | { |
1278 | 1285 | $this->trigger_events('where'); |
@@ -1309,6 +1316,9 @@ discard block |
||
1309 | 1316 | return $this; |
1310 | 1317 | } |
1311 | 1318 | |
1319 | + /** |
|
1320 | + * @param string $by |
|
1321 | + */ |
|
1312 | 1322 | public function order_by($by, $order='desc') |
1313 | 1323 | { |
1314 | 1324 | $this->trigger_events('order_by'); |
@@ -1367,7 +1377,7 @@ discard block |
||
1367 | 1377 | /** |
1368 | 1378 | * users |
1369 | 1379 | * |
1370 | - * @return object Users |
|
1380 | + * @return Ion_auth_model Users |
|
1371 | 1381 | * @author Ben Edmunds |
1372 | 1382 | **/ |
1373 | 1383 | public function users($groups = NULL) |
@@ -1488,7 +1498,7 @@ discard block |
||
1488 | 1498 | /** |
1489 | 1499 | * user |
1490 | 1500 | * |
1491 | - * @return object |
|
1501 | + * @return Ion_auth_model |
|
1492 | 1502 | * @author Ben Edmunds |
1493 | 1503 | **/ |
1494 | 1504 | public function user($id = NULL) |
@@ -1510,7 +1520,7 @@ discard block |
||
1510 | 1520 | /** |
1511 | 1521 | * get_users_groups |
1512 | 1522 | * |
1513 | - * @return array |
|
1523 | + * @return CI_DB_result |
|
1514 | 1524 | * @author Ben Edmunds |
1515 | 1525 | **/ |
1516 | 1526 | public function get_users_groups($id=FALSE) |
@@ -1529,7 +1539,7 @@ discard block |
||
1529 | 1539 | /** |
1530 | 1540 | * add_to_group |
1531 | 1541 | * |
1532 | - * @return bool |
|
1542 | + * @return integer |
|
1533 | 1543 | * @author Ben Edmunds |
1534 | 1544 | **/ |
1535 | 1545 | public function add_to_group($group_ids, $user_id=false) |
@@ -1617,7 +1627,7 @@ discard block |
||
1617 | 1627 | /** |
1618 | 1628 | * groups |
1619 | 1629 | * |
1620 | - * @return object |
|
1630 | + * @return Ion_auth_model |
|
1621 | 1631 | * @author Ben Edmunds |
1622 | 1632 | **/ |
1623 | 1633 | public function groups() |
@@ -1662,7 +1672,7 @@ discard block |
||
1662 | 1672 | /** |
1663 | 1673 | * group |
1664 | 1674 | * |
1665 | - * @return object |
|
1675 | + * @return Ion_auth_model |
|
1666 | 1676 | * @author Ben Edmunds |
1667 | 1677 | **/ |
1668 | 1678 | public function group($id = NULL) |
@@ -2160,7 +2170,7 @@ discard block |
||
2160 | 2170 | * |
2161 | 2171 | * Set the message delimiters |
2162 | 2172 | * |
2163 | - * @return void |
|
2173 | + * @return boolean |
|
2164 | 2174 | * @author Ben Edmunds |
2165 | 2175 | **/ |
2166 | 2176 | public function set_message_delimiters($start_delimiter, $end_delimiter) |
@@ -2176,7 +2186,7 @@ discard block |
||
2176 | 2186 | * |
2177 | 2187 | * Set the error delimiters |
2178 | 2188 | * |
2179 | - * @return void |
|
2189 | + * @return boolean |
|
2180 | 2190 | * @author Ben Edmunds |
2181 | 2191 | **/ |
2182 | 2192 | public function set_error_delimiters($start_delimiter, $end_delimiter) |
@@ -2192,6 +2202,7 @@ discard block |
||
2192 | 2202 | * |
2193 | 2203 | * Set a message |
2194 | 2204 | * |
2205 | + * @param string $message |
|
2195 | 2206 | * @return void |
2196 | 2207 | * @author Ben Edmunds |
2197 | 2208 | **/ |
@@ -2209,7 +2220,7 @@ discard block |
||
2209 | 2220 | * |
2210 | 2221 | * Get the messages |
2211 | 2222 | * |
2212 | - * @return void |
|
2223 | + * @return string |
|
2213 | 2224 | * @author Ben Edmunds |
2214 | 2225 | **/ |
2215 | 2226 | public function messages() |
@@ -2256,7 +2267,7 @@ discard block |
||
2256 | 2267 | * |
2257 | 2268 | * Clear messages |
2258 | 2269 | * |
2259 | - * @return void |
|
2270 | + * @return boolean |
|
2260 | 2271 | * @author Ben Edmunds |
2261 | 2272 | **/ |
2262 | 2273 | public function clear_messages() |
@@ -2272,6 +2283,7 @@ discard block |
||
2272 | 2283 | * |
2273 | 2284 | * Set an error message |
2274 | 2285 | * |
2286 | + * @param string $error |
|
2275 | 2287 | * @return void |
2276 | 2288 | * @author Ben Edmunds |
2277 | 2289 | **/ |
@@ -2287,7 +2299,7 @@ discard block |
||
2287 | 2299 | * |
2288 | 2300 | * Get the error message |
2289 | 2301 | * |
2290 | - * @return void |
|
2302 | + * @return string |
|
2291 | 2303 | * @author Ben Edmunds |
2292 | 2304 | **/ |
2293 | 2305 | public function errors() |
@@ -2334,7 +2346,7 @@ discard block |
||
2334 | 2346 | * |
2335 | 2347 | * Clear Errors |
2336 | 2348 | * |
2337 | - * @return void |
|
2349 | + * @return boolean |
|
2338 | 2350 | * @author Ben Edmunds |
2339 | 2351 | **/ |
2340 | 2352 | public function clear_errors() |
@@ -2363,6 +2375,9 @@ discard block |
||
2363 | 2375 | return $filtered_data; |
2364 | 2376 | } |
2365 | 2377 | |
2378 | + /** |
|
2379 | + * @param string $ip_address |
|
2380 | + */ |
|
2366 | 2381 | protected function _prepare_ip($ip_address) { |
2367 | 2382 | // just return the string IP address now for better compatibility |
2368 | 2383 | return $ip_address; |
@@ -302,10 +302,10 @@ discard block |
||
302 | 302 | $this->trigger_events('extra_where'); |
303 | 303 | |
304 | 304 | $query = $this->db->select('password, salt') |
305 | - ->where('id', $id) |
|
306 | - ->limit(1) |
|
307 | - ->order_by('id', 'desc') |
|
308 | - ->get($this->tables['users']); |
|
305 | + ->where('id', $id) |
|
306 | + ->limit(1) |
|
307 | + ->order_by('id', 'desc') |
|
308 | + ->get($this->tables['users']); |
|
309 | 309 | |
310 | 310 | $hash_password_db = $query->row(); |
311 | 311 | |
@@ -372,62 +372,62 @@ discard block |
||
372 | 372 | $raw_salt_len = 16; |
373 | 373 | |
374 | 374 | $buffer = ''; |
375 | - $buffer_valid = false; |
|
375 | + $buffer_valid = false; |
|
376 | 376 | |
377 | - if (function_exists('random_bytes')) { |
|
377 | + if (function_exists('random_bytes')) { |
|
378 | 378 | $buffer = random_bytes($raw_salt_len); |
379 | 379 | if ($buffer) { |
380 | - $buffer_valid = true; |
|
380 | + $buffer_valid = true; |
|
381 | 381 | } |
382 | 382 | } |
383 | 383 | |
384 | 384 | if (!$buffer_valid && function_exists('mcrypt_create_iv') && !defined('PHALANGER')) { |
385 | - $buffer = mcrypt_create_iv($raw_salt_len, MCRYPT_DEV_URANDOM); |
|
386 | - if ($buffer) { |
|
387 | - $buffer_valid = true; |
|
388 | - } |
|
389 | - } |
|
390 | - |
|
391 | - if (!$buffer_valid && function_exists('openssl_random_pseudo_bytes')) { |
|
392 | - $buffer = openssl_random_pseudo_bytes($raw_salt_len); |
|
393 | - if ($buffer) { |
|
394 | - $buffer_valid = true; |
|
395 | - } |
|
396 | - } |
|
397 | - |
|
398 | - if (!$buffer_valid && @is_readable('/dev/urandom')) { |
|
399 | - $f = fopen('/dev/urandom', 'r'); |
|
400 | - $read = strlen($buffer); |
|
401 | - while ($read < $raw_salt_len) { |
|
402 | - $buffer .= fread($f, $raw_salt_len - $read); |
|
403 | - $read = strlen($buffer); |
|
404 | - } |
|
405 | - fclose($f); |
|
406 | - if ($read >= $raw_salt_len) { |
|
407 | - $buffer_valid = true; |
|
408 | - } |
|
409 | - } |
|
410 | - |
|
411 | - if (!$buffer_valid || strlen($buffer) < $raw_salt_len) { |
|
412 | - $bl = strlen($buffer); |
|
413 | - for ($i = 0; $i < $raw_salt_len; $i++) { |
|
414 | - if ($i < $bl) { |
|
415 | - $buffer[$i] = $buffer[$i] ^ chr(mt_rand(0, 255)); |
|
416 | - } else { |
|
417 | - $buffer .= chr(mt_rand(0, 255)); |
|
418 | - } |
|
419 | - } |
|
420 | - } |
|
421 | - |
|
422 | - $salt = $buffer; |
|
423 | - |
|
424 | - // encode string with the Base64 variant used by crypt |
|
425 | - $base64_digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; |
|
426 | - $bcrypt64_digits = './ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; |
|
427 | - $base64_string = base64_encode($salt); |
|
428 | - $salt = strtr(rtrim($base64_string, '='), $base64_digits, $bcrypt64_digits); |
|
429 | - |
|
430 | - $salt = substr($salt, 0, $this->salt_length); |
|
385 | + $buffer = mcrypt_create_iv($raw_salt_len, MCRYPT_DEV_URANDOM); |
|
386 | + if ($buffer) { |
|
387 | + $buffer_valid = true; |
|
388 | + } |
|
389 | + } |
|
390 | + |
|
391 | + if (!$buffer_valid && function_exists('openssl_random_pseudo_bytes')) { |
|
392 | + $buffer = openssl_random_pseudo_bytes($raw_salt_len); |
|
393 | + if ($buffer) { |
|
394 | + $buffer_valid = true; |
|
395 | + } |
|
396 | + } |
|
397 | + |
|
398 | + if (!$buffer_valid && @is_readable('/dev/urandom')) { |
|
399 | + $f = fopen('/dev/urandom', 'r'); |
|
400 | + $read = strlen($buffer); |
|
401 | + while ($read < $raw_salt_len) { |
|
402 | + $buffer .= fread($f, $raw_salt_len - $read); |
|
403 | + $read = strlen($buffer); |
|
404 | + } |
|
405 | + fclose($f); |
|
406 | + if ($read >= $raw_salt_len) { |
|
407 | + $buffer_valid = true; |
|
408 | + } |
|
409 | + } |
|
410 | + |
|
411 | + if (!$buffer_valid || strlen($buffer) < $raw_salt_len) { |
|
412 | + $bl = strlen($buffer); |
|
413 | + for ($i = 0; $i < $raw_salt_len; $i++) { |
|
414 | + if ($i < $bl) { |
|
415 | + $buffer[$i] = $buffer[$i] ^ chr(mt_rand(0, 255)); |
|
416 | + } else { |
|
417 | + $buffer .= chr(mt_rand(0, 255)); |
|
418 | + } |
|
419 | + } |
|
420 | + } |
|
421 | + |
|
422 | + $salt = $buffer; |
|
423 | + |
|
424 | + // encode string with the Base64 variant used by crypt |
|
425 | + $base64_digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; |
|
426 | + $bcrypt64_digits = './ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; |
|
427 | + $base64_string = base64_encode($salt); |
|
428 | + $salt = strtr(rtrim($base64_string, '='), $base64_digits, $bcrypt64_digits); |
|
429 | + |
|
430 | + $salt = substr($salt, 0, $this->salt_length); |
|
431 | 431 | |
432 | 432 | |
433 | 433 | return $salt; |
@@ -456,11 +456,11 @@ discard block |
||
456 | 456 | if ($code !== FALSE) |
457 | 457 | { |
458 | 458 | $query = $this->db->select($this->identity_column) |
459 | - ->where('activation_code', $code) |
|
460 | - ->where('id', $id) |
|
461 | - ->limit(1) |
|
462 | - ->order_by('id', 'desc') |
|
463 | - ->get($this->tables['users']); |
|
459 | + ->where('activation_code', $code) |
|
460 | + ->where('id', $id) |
|
461 | + ->limit(1) |
|
462 | + ->order_by('id', 'desc') |
|
463 | + ->get($this->tables['users']); |
|
464 | 464 | |
465 | 465 | $result = $query->row(); |
466 | 466 | |
@@ -472,8 +472,8 @@ discard block |
||
472 | 472 | } |
473 | 473 | |
474 | 474 | $data = array( |
475 | - 'activation_code' => NULL, |
|
476 | - 'active' => 1 |
|
475 | + 'activation_code' => NULL, |
|
476 | + 'active' => 1 |
|
477 | 477 | ); |
478 | 478 | |
479 | 479 | $this->trigger_events('extra_where'); |
@@ -482,8 +482,8 @@ discard block |
||
482 | 482 | else |
483 | 483 | { |
484 | 484 | $data = array( |
485 | - 'activation_code' => NULL, |
|
486 | - 'active' => 1 |
|
485 | + 'activation_code' => NULL, |
|
486 | + 'active' => 1 |
|
487 | 487 | ); |
488 | 488 | |
489 | 489 | |
@@ -524,18 +524,18 @@ discard block |
||
524 | 524 | $this->set_error('deactivate_unsuccessful'); |
525 | 525 | return FALSE; |
526 | 526 | } |
527 | - elseif($this->ion_auth->logged_in() && $this->user()->row()->id == $id) |
|
528 | - { |
|
529 | - $this->set_error('deactivate_current_user_unsuccessful'); |
|
530 | - return FALSE; |
|
531 | - } |
|
527 | + elseif($this->ion_auth->logged_in() && $this->user()->row()->id == $id) |
|
528 | + { |
|
529 | + $this->set_error('deactivate_current_user_unsuccessful'); |
|
530 | + return FALSE; |
|
531 | + } |
|
532 | 532 | |
533 | 533 | $activation_code = sha1(md5(microtime())); |
534 | 534 | $this->activation_code = $activation_code; |
535 | 535 | |
536 | 536 | $data = array( |
537 | - 'activation_code' => $activation_code, |
|
538 | - 'active' => 0 |
|
537 | + 'activation_code' => $activation_code, |
|
538 | + 'active' => 0 |
|
539 | 539 | ); |
540 | 540 | |
541 | 541 | $this->trigger_events('extra_where'); |
@@ -562,8 +562,8 @@ discard block |
||
562 | 562 | if ($this->db->count_all_results($this->tables['users']) > 0) |
563 | 563 | { |
564 | 564 | $data = array( |
565 | - 'forgotten_password_code' => NULL, |
|
566 | - 'forgotten_password_time' => NULL |
|
565 | + 'forgotten_password_code' => NULL, |
|
566 | + 'forgotten_password_time' => NULL |
|
567 | 567 | ); |
568 | 568 | |
569 | 569 | $this->db->update($this->tables['users'], $data, array('forgotten_password_code' => $code)); |
@@ -591,10 +591,10 @@ discard block |
||
591 | 591 | $this->trigger_events('extra_where'); |
592 | 592 | |
593 | 593 | $query = $this->db->select('id, password, salt') |
594 | - ->where($this->identity_column, $identity) |
|
595 | - ->limit(1) |
|
596 | - ->order_by('id', 'desc') |
|
597 | - ->get($this->tables['users']); |
|
594 | + ->where($this->identity_column, $identity) |
|
595 | + ->limit(1) |
|
596 | + ->order_by('id', 'desc') |
|
597 | + ->get($this->tables['users']); |
|
598 | 598 | |
599 | 599 | if ($query->num_rows() !== 1) |
600 | 600 | { |
@@ -610,10 +610,10 @@ discard block |
||
610 | 610 | // store the new password and reset the remember code so all remembered instances have to re-login |
611 | 611 | // also clear the forgotten password code |
612 | 612 | $data = array( |
613 | - 'password' => $new, |
|
614 | - 'remember_code' => NULL, |
|
615 | - 'forgotten_password_code' => NULL, |
|
616 | - 'forgotten_password_time' => NULL, |
|
613 | + 'password' => $new, |
|
614 | + 'remember_code' => NULL, |
|
615 | + 'forgotten_password_code' => NULL, |
|
616 | + 'forgotten_password_time' => NULL, |
|
617 | 617 | ); |
618 | 618 | |
619 | 619 | $this->trigger_events('extra_where'); |
@@ -647,10 +647,10 @@ discard block |
||
647 | 647 | $this->trigger_events('extra_where'); |
648 | 648 | |
649 | 649 | $query = $this->db->select('id, password, salt') |
650 | - ->where($this->identity_column, $identity) |
|
651 | - ->limit(1) |
|
652 | - ->order_by('id', 'desc') |
|
653 | - ->get($this->tables['users']); |
|
650 | + ->where($this->identity_column, $identity) |
|
651 | + ->limit(1) |
|
652 | + ->order_by('id', 'desc') |
|
653 | + ->get($this->tables['users']); |
|
654 | 654 | |
655 | 655 | if ($query->num_rows() !== 1) |
656 | 656 | { |
@@ -668,8 +668,8 @@ discard block |
||
668 | 668 | // store the new password and reset the remember code so all remembered instances have to re-login |
669 | 669 | $hashed_new_password = $this->hash_password($new, $user->salt); |
670 | 670 | $data = array( |
671 | - 'password' => $hashed_new_password, |
|
672 | - 'remember_code' => NULL, |
|
671 | + 'password' => $hashed_new_password, |
|
672 | + 'remember_code' => NULL, |
|
673 | 673 | ); |
674 | 674 | |
675 | 675 | $this->trigger_events('extra_where'); |
@@ -714,7 +714,7 @@ discard block |
||
714 | 714 | ->group_by("id") |
715 | 715 | ->order_by("id", "ASC") |
716 | 716 | ->limit(1) |
717 | - ->count_all_results($this->tables['users']) > 0; |
|
717 | + ->count_all_results($this->tables['users']) > 0; |
|
718 | 718 | } |
719 | 719 | |
720 | 720 | /** |
@@ -738,7 +738,7 @@ discard block |
||
738 | 738 | ->group_by("id") |
739 | 739 | ->order_by("id", "ASC") |
740 | 740 | ->limit(1) |
741 | - ->count_all_results($this->tables['users']) > 0; |
|
741 | + ->count_all_results($this->tables['users']) > 0; |
|
742 | 742 | } |
743 | 743 | |
744 | 744 | /** |
@@ -757,7 +757,7 @@ discard block |
||
757 | 757 | } |
758 | 758 | |
759 | 759 | return $this->db->where($this->identity_column, $identity) |
760 | - ->count_all_results($this->tables['users']) > 0; |
|
760 | + ->count_all_results($this->tables['users']) > 0; |
|
761 | 761 | } |
762 | 762 | |
763 | 763 | /** |
@@ -805,8 +805,8 @@ discard block |
||
805 | 805 | $this->trigger_events('extra_where'); |
806 | 806 | |
807 | 807 | $update = array( |
808 | - 'forgotten_password_code' => $key, |
|
809 | - 'forgotten_password_time' => time() |
|
808 | + 'forgotten_password_code' => $key, |
|
809 | + 'forgotten_password_time' => time() |
|
810 | 810 | ); |
811 | 811 | |
812 | 812 | $this->db->update($this->tables['users'], $update, array($this->identity_column => $identity)); |
@@ -855,9 +855,9 @@ discard block |
||
855 | 855 | $password = $this->salt(); |
856 | 856 | |
857 | 857 | $data = array( |
858 | - 'password' => $this->hash_password($password, $salt), |
|
859 | - 'forgotten_password_code' => NULL, |
|
860 | - 'active' => 1, |
|
858 | + 'password' => $this->hash_password($password, $salt), |
|
859 | + 'forgotten_password_code' => NULL, |
|
860 | + 'active' => 1, |
|
861 | 861 | ); |
862 | 862 | |
863 | 863 | $this->db->update($this->tables['users'], $data, array('forgotten_password_code' => $code)); |
@@ -911,13 +911,13 @@ discard block |
||
911 | 911 | |
912 | 912 | // Users table. |
913 | 913 | $data = array( |
914 | - $this->identity_column => $identity, |
|
915 | - 'username' => $identity, |
|
916 | - 'password' => $password, |
|
917 | - 'email' => $email, |
|
918 | - 'ip_address' => $ip_address, |
|
919 | - 'created_on' => time(), |
|
920 | - 'active' => ($manual_activation === false ? 1 : 0) |
|
914 | + $this->identity_column => $identity, |
|
915 | + 'username' => $identity, |
|
916 | + 'password' => $password, |
|
917 | + 'email' => $email, |
|
918 | + 'ip_address' => $ip_address, |
|
919 | + 'created_on' => time(), |
|
920 | + 'active' => ($manual_activation === false ? 1 : 0) |
|
921 | 921 | ); |
922 | 922 | |
923 | 923 | if ($this->store_salt) |
@@ -974,10 +974,10 @@ discard block |
||
974 | 974 | $this->trigger_events('extra_where'); |
975 | 975 | |
976 | 976 | $query = $this->db->select($this->identity_column . ', email, id, password, active, last_login') |
977 | - ->where($this->identity_column, $identity) |
|
978 | - ->limit(1) |
|
979 | - ->order_by('id', 'desc') |
|
980 | - ->get($this->tables['users']); |
|
977 | + ->where($this->identity_column, $identity) |
|
978 | + ->limit(1) |
|
979 | + ->order_by('id', 'desc') |
|
980 | + ->get($this->tables['users']); |
|
981 | 981 | |
982 | 982 | if($this->is_max_login_attempts_exceeded($identity)) |
983 | 983 | { |
@@ -1035,50 +1035,50 @@ discard block |
||
1035 | 1035 | return FALSE; |
1036 | 1036 | } |
1037 | 1037 | |
1038 | - /** |
|
1039 | - * recheck_session verifies if the session should be rechecked according to |
|
1040 | - * the configuration item recheck_timer. If it does, then it will check if the user is still active |
|
1041 | - * @return bool |
|
1042 | - */ |
|
1038 | + /** |
|
1039 | + * recheck_session verifies if the session should be rechecked according to |
|
1040 | + * the configuration item recheck_timer. If it does, then it will check if the user is still active |
|
1041 | + * @return bool |
|
1042 | + */ |
|
1043 | 1043 | public function recheck_session() |
1044 | - { |
|
1045 | - $recheck = (null !== $this->config->item('recheck_timer', 'ion_auth')) ? $this->config->item('recheck_timer', 'ion_auth') : 0; |
|
1046 | - |
|
1047 | - if($recheck!==0) |
|
1048 | - { |
|
1049 | - $last_login = $this->session->userdata('last_check'); |
|
1050 | - if($last_login+$recheck < time()) |
|
1051 | - { |
|
1052 | - $query = $this->db->select('id') |
|
1053 | - ->where(array($this->identity_column=>$this->session->userdata('identity'),'active'=>'1')) |
|
1054 | - ->limit(1) |
|
1055 | - ->order_by('id', 'desc') |
|
1056 | - ->get($this->tables['users']); |
|
1057 | - if ($query->num_rows() === 1) |
|
1058 | - { |
|
1059 | - $this->session->set_userdata('last_check',time()); |
|
1060 | - } |
|
1061 | - else |
|
1062 | - { |
|
1063 | - $this->trigger_events('logout'); |
|
1064 | - |
|
1065 | - $identity = $this->config->item('identity', 'ion_auth'); |
|
1066 | - |
|
1067 | - if (substr(CI_VERSION, 0, 1) == '2') |
|
1068 | - { |
|
1069 | - $this->session->unset_userdata( array($identity => '', 'id' => '', 'user_id' => '') ); |
|
1070 | - } |
|
1071 | - else |
|
1072 | - { |
|
1073 | - $this->session->unset_userdata( array($identity, 'id', 'user_id') ); |
|
1074 | - } |
|
1075 | - return false; |
|
1076 | - } |
|
1077 | - } |
|
1078 | - } |
|
1079 | - |
|
1080 | - return (bool) $this->session->userdata('identity'); |
|
1081 | - } |
|
1044 | + { |
|
1045 | + $recheck = (null !== $this->config->item('recheck_timer', 'ion_auth')) ? $this->config->item('recheck_timer', 'ion_auth') : 0; |
|
1046 | + |
|
1047 | + if($recheck!==0) |
|
1048 | + { |
|
1049 | + $last_login = $this->session->userdata('last_check'); |
|
1050 | + if($last_login+$recheck < time()) |
|
1051 | + { |
|
1052 | + $query = $this->db->select('id') |
|
1053 | + ->where(array($this->identity_column=>$this->session->userdata('identity'),'active'=>'1')) |
|
1054 | + ->limit(1) |
|
1055 | + ->order_by('id', 'desc') |
|
1056 | + ->get($this->tables['users']); |
|
1057 | + if ($query->num_rows() === 1) |
|
1058 | + { |
|
1059 | + $this->session->set_userdata('last_check',time()); |
|
1060 | + } |
|
1061 | + else |
|
1062 | + { |
|
1063 | + $this->trigger_events('logout'); |
|
1064 | + |
|
1065 | + $identity = $this->config->item('identity', 'ion_auth'); |
|
1066 | + |
|
1067 | + if (substr(CI_VERSION, 0, 1) == '2') |
|
1068 | + { |
|
1069 | + $this->session->unset_userdata( array($identity => '', 'id' => '', 'user_id' => '') ); |
|
1070 | + } |
|
1071 | + else |
|
1072 | + { |
|
1073 | + $this->session->unset_userdata( array($identity, 'id', 'user_id') ); |
|
1074 | + } |
|
1075 | + return false; |
|
1076 | + } |
|
1077 | + } |
|
1078 | + } |
|
1079 | + |
|
1080 | + return (bool) $this->session->userdata('identity'); |
|
1081 | + } |
|
1082 | 1082 | |
1083 | 1083 | /** |
1084 | 1084 | * is_max_login_attempts_exceeded |
@@ -1115,20 +1115,20 @@ discard block |
||
1115 | 1115 | */ |
1116 | 1116 | public function get_attempts_num($identity, $ip_address = NULL) |
1117 | 1117 | { |
1118 | - if ($this->config->item('track_login_attempts', 'ion_auth')) { |
|
1119 | - $this->db->select('1', FALSE); |
|
1120 | - $this->db->where('login', $identity); |
|
1121 | - if ($this->config->item('track_login_ip_address', 'ion_auth')) { |
|
1122 | - if (!isset($ip_address)) { |
|
1123 | - $ip_address = $this->_prepare_ip($this->input->ip_address()); |
|
1124 | - } |
|
1125 | - $this->db->where('ip_address', $ip_address); |
|
1126 | - } |
|
1127 | - $this->db->where('time >', time() - $this->config->item('lockout_time', 'ion_auth'), FALSE); |
|
1128 | - $qres = $this->db->get($this->tables['login_attempts']); |
|
1129 | - return $qres->num_rows(); |
|
1130 | - } |
|
1131 | - return 0; |
|
1118 | + if ($this->config->item('track_login_attempts', 'ion_auth')) { |
|
1119 | + $this->db->select('1', FALSE); |
|
1120 | + $this->db->where('login', $identity); |
|
1121 | + if ($this->config->item('track_login_ip_address', 'ion_auth')) { |
|
1122 | + if (!isset($ip_address)) { |
|
1123 | + $ip_address = $this->_prepare_ip($this->input->ip_address()); |
|
1124 | + } |
|
1125 | + $this->db->where('ip_address', $ip_address); |
|
1126 | + } |
|
1127 | + $this->db->where('time >', time() - $this->config->item('lockout_time', 'ion_auth'), FALSE); |
|
1128 | + $qres = $this->db->get($this->tables['login_attempts']); |
|
1129 | + return $qres->num_rows(); |
|
1130 | + } |
|
1131 | + return 0; |
|
1132 | 1132 | } |
1133 | 1133 | |
1134 | 1134 | /** |
@@ -1185,11 +1185,11 @@ discard block |
||
1185 | 1185 | } |
1186 | 1186 | |
1187 | 1187 | /** |
1188 | - * Get the IP address of the last time a login attempt occured from given identity |
|
1189 | - * |
|
1188 | + * Get the IP address of the last time a login attempt occured from given identity |
|
1189 | + * |
|
1190 | 1190 | * @param string $identity: user's identity |
1191 | - * @return string |
|
1192 | - */ |
|
1191 | + * @return string |
|
1192 | + */ |
|
1193 | 1193 | public function get_last_attempt_ip($identity) { |
1194 | 1194 | if ($this->config->item('track_login_attempts', 'ion_auth') && $this->config->item('track_login_ip_address', 'ion_auth')) { |
1195 | 1195 | $this->db->select('ip_address'); |
@@ -1387,9 +1387,9 @@ discard block |
||
1387 | 1387 | { |
1388 | 1388 | //default selects |
1389 | 1389 | $this->db->select(array( |
1390 | - $this->tables['users'].'.*', |
|
1391 | - $this->tables['users'].'.id as id', |
|
1392 | - $this->tables['users'].'.id as user_id' |
|
1390 | + $this->tables['users'].'.*', |
|
1391 | + $this->tables['users'].'.id as id', |
|
1392 | + $this->tables['users'].'.id as user_id' |
|
1393 | 1393 | )); |
1394 | 1394 | } |
1395 | 1395 | |
@@ -1407,9 +1407,9 @@ discard block |
||
1407 | 1407 | { |
1408 | 1408 | $this->db->distinct(); |
1409 | 1409 | $this->db->join( |
1410 | - $this->tables['users_groups'], |
|
1411 | - $this->tables['users_groups'].'.'.$this->join['users'].'='.$this->tables['users'].'.id', |
|
1412 | - 'inner' |
|
1410 | + $this->tables['users_groups'], |
|
1411 | + $this->tables['users_groups'].'.'.$this->join['users'].'='.$this->tables['users'].'.id', |
|
1412 | + 'inner' |
|
1413 | 1413 | ); |
1414 | 1414 | } |
1415 | 1415 | |
@@ -1521,9 +1521,9 @@ discard block |
||
1521 | 1521 | $id || $id = $this->session->userdata('user_id'); |
1522 | 1522 | |
1523 | 1523 | return $this->db->select($this->tables['users_groups'].'.'.$this->join['groups'].' as id, '.$this->tables['groups'].'.name, '.$this->tables['groups'].'.description') |
1524 | - ->where($this->tables['users_groups'].'.'.$this->join['users'], $id) |
|
1525 | - ->join($this->tables['groups'], $this->tables['users_groups'].'.'.$this->join['groups'].'='.$this->tables['groups'].'.id') |
|
1526 | - ->get($this->tables['users_groups']); |
|
1524 | + ->where($this->tables['users_groups'].'.'.$this->join['users'], $id) |
|
1525 | + ->join($this->tables['groups'], $this->tables['users_groups'].'.'.$this->join['groups'].'='.$this->tables['groups'].'.id') |
|
1526 | + ->get($this->tables['users_groups']); |
|
1527 | 1527 | } |
1528 | 1528 | |
1529 | 1529 | /** |
@@ -1744,11 +1744,11 @@ discard block |
||
1744 | 1744 | } |
1745 | 1745 | |
1746 | 1746 | /** |
1747 | - * delete_user |
|
1748 | - * |
|
1749 | - * @return bool |
|
1750 | - * @author Phil Sturgeon |
|
1751 | - **/ |
|
1747 | + * delete_user |
|
1748 | + * |
|
1749 | + * @return bool |
|
1750 | + * @author Phil Sturgeon |
|
1751 | + **/ |
|
1752 | 1752 | public function delete_user($id) |
1753 | 1753 | { |
1754 | 1754 | $this->trigger_events('pre_delete_user'); |
@@ -1838,12 +1838,12 @@ discard block |
||
1838 | 1838 | $this->trigger_events('pre_set_session'); |
1839 | 1839 | |
1840 | 1840 | $session_data = array( |
1841 | - 'identity' => $user->{$this->identity_column}, |
|
1842 | - $this->identity_column => $user->{$this->identity_column}, |
|
1843 | - 'email' => $user->email, |
|
1844 | - 'user_id' => $user->id, //everyone likes to overwrite id so we'll use user_id |
|
1845 | - 'old_last_login' => $user->last_login, |
|
1846 | - 'last_check' => time(), |
|
1841 | + 'identity' => $user->{$this->identity_column}, |
|
1842 | + $this->identity_column => $user->{$this->identity_column}, |
|
1843 | + 'email' => $user->email, |
|
1844 | + 'user_id' => $user->id, //everyone likes to overwrite id so we'll use user_id |
|
1845 | + 'old_last_login' => $user->last_login, |
|
1846 | + 'last_check' => time(), |
|
1847 | 1847 | ); |
1848 | 1848 | |
1849 | 1849 | $this->session->set_userdata($session_data); |
@@ -1888,15 +1888,15 @@ discard block |
||
1888 | 1888 | } |
1889 | 1889 | |
1890 | 1890 | set_cookie(array( |
1891 | - 'name' => $this->config->item('identity_cookie_name', 'ion_auth'), |
|
1892 | - 'value' => $user->{$this->identity_column}, |
|
1893 | - 'expire' => $expire |
|
1891 | + 'name' => $this->config->item('identity_cookie_name', 'ion_auth'), |
|
1892 | + 'value' => $user->{$this->identity_column}, |
|
1893 | + 'expire' => $expire |
|
1894 | 1894 | )); |
1895 | 1895 | |
1896 | 1896 | set_cookie(array( |
1897 | - 'name' => $this->config->item('remember_cookie_name', 'ion_auth'), |
|
1898 | - 'value' => $salt, |
|
1899 | - 'expire' => $expire |
|
1897 | + 'name' => $this->config->item('remember_cookie_name', 'ion_auth'), |
|
1898 | + 'value' => $salt, |
|
1899 | + 'expire' => $expire |
|
1900 | 1900 | )); |
1901 | 1901 | |
1902 | 1902 | $this->trigger_events(array('post_remember_user', 'remember_user_successful')); |
@@ -1929,12 +1929,12 @@ discard block |
||
1929 | 1929 | // get the user |
1930 | 1930 | $this->trigger_events('extra_where'); |
1931 | 1931 | $query = $this->db->select($this->identity_column.', id, email, last_login') |
1932 | - ->where($this->identity_column, urldecode(get_cookie($this->config->item('identity_cookie_name', 'ion_auth')))) |
|
1933 | - ->where('remember_code', get_cookie($this->config->item('remember_cookie_name', 'ion_auth'))) |
|
1932 | + ->where($this->identity_column, urldecode(get_cookie($this->config->item('identity_cookie_name', 'ion_auth')))) |
|
1933 | + ->where('remember_code', get_cookie($this->config->item('remember_cookie_name', 'ion_auth'))) |
|
1934 | 1934 | ->where('active',1) |
1935 | - ->limit(1) |
|
1936 | - ->order_by('id', 'desc') |
|
1937 | - ->get($this->tables['users']); |
|
1935 | + ->limit(1) |
|
1936 | + ->order_by('id', 'desc') |
|
1937 | + ->get($this->tables['users']); |
|
1938 | 1938 | |
1939 | 1939 | // if the user was found, sign them in |
1940 | 1940 | if ($query->num_rows() == 1) |
@@ -1964,7 +1964,7 @@ discard block |
||
1964 | 1964 | * create_group |
1965 | 1965 | * |
1966 | 1966 | * @author aditya menon |
1967 | - */ |
|
1967 | + */ |
|
1968 | 1968 | public function create_group($group_name = FALSE, $group_description = '', $additional_data = array()) |
1969 | 1969 | { |
1970 | 1970 | // bail if the group name was not passed |
@@ -2028,12 +2028,12 @@ discard block |
||
2028 | 2028 | } |
2029 | 2029 | |
2030 | 2030 | // restrict change of name of the admin group |
2031 | - $group = $this->db->get_where($this->tables['groups'], array('id' => $group_id))->row(); |
|
2032 | - if($this->config->item('admin_group', 'ion_auth') === $group->name && $group_name !== $group->name) |
|
2033 | - { |
|
2034 | - $this->set_error('group_name_admin_not_alter'); |
|
2035 | - return FALSE; |
|
2036 | - } |
|
2031 | + $group = $this->db->get_where($this->tables['groups'], array('id' => $group_id))->row(); |
|
2032 | + if($this->config->item('admin_group', 'ion_auth') === $group->name && $group_name !== $group->name) |
|
2033 | + { |
|
2034 | + $this->set_error('group_name_admin_not_alter'); |
|
2035 | + return FALSE; |
|
2036 | + } |
|
2037 | 2037 | |
2038 | 2038 | |
2039 | 2039 | // IMPORTANT!! Third parameter was string type $description; this following code is to maintain backward compatibility |
@@ -2054,11 +2054,11 @@ discard block |
||
2054 | 2054 | } |
2055 | 2055 | |
2056 | 2056 | /** |
2057 | - * delete_group |
|
2058 | - * |
|
2059 | - * @return bool |
|
2060 | - * @author aditya menon |
|
2061 | - **/ |
|
2057 | + * delete_group |
|
2058 | + * |
|
2059 | + * @return bool |
|
2060 | + * @author aditya menon |
|
2061 | + **/ |
|
2062 | 2062 | public function delete_group($group_id = FALSE) |
2063 | 2063 | { |
2064 | 2064 | // bail if mandatory param not set |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); |
|
1 | +<?php if(!defined('BASEPATH')) exit('No direct script access allowed'); |
|
2 | 2 | /** |
3 | 3 | * Name: Ion Auth Model |
4 | 4 | * |
@@ -171,13 +171,13 @@ discard block |
||
171 | 171 | $this->lang->load('ion_auth'); |
172 | 172 | |
173 | 173 | // initialize db tables data |
174 | - $this->tables = $this->config->item('tables', 'ion_auth'); |
|
174 | + $this->tables = $this->config->item('tables', 'ion_auth'); |
|
175 | 175 | |
176 | 176 | //initialize data |
177 | 177 | $this->identity_column = $this->config->item('identity', 'ion_auth'); |
178 | 178 | $this->store_salt = $this->config->item('store_salt', 'ion_auth'); |
179 | 179 | $this->salt_length = $this->config->item('salt_length', 'ion_auth'); |
180 | - $this->join = $this->config->item('join', 'ion_auth'); |
|
180 | + $this->join = $this->config->item('join', 'ion_auth'); |
|
181 | 181 | |
182 | 182 | |
183 | 183 | // initialize hash method options (Bcrypt) |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | $delimiters_source = $this->config->item('delimiters_source', 'ion_auth'); |
195 | 195 | |
196 | 196 | // load the error delimeters either from the config file or use what's been supplied to form validation |
197 | - if ($delimiters_source === 'form_validation') |
|
197 | + if($delimiters_source === 'form_validation') |
|
198 | 198 | { |
199 | 199 | // load in delimiters from form_validation |
200 | 200 | // to keep this simple we'll load the value using reflection since these properties are protected |
@@ -225,10 +225,10 @@ discard block |
||
225 | 225 | $this->_ion_hooks = new stdClass; |
226 | 226 | |
227 | 227 | // load the bcrypt class if needed |
228 | - if ($this->hash_method == 'bcrypt') { |
|
229 | - if ($this->random_rounds) |
|
228 | + if($this->hash_method == 'bcrypt') { |
|
229 | + if($this->random_rounds) |
|
230 | 230 | { |
231 | - $rand = rand($this->min_rounds,$this->max_rounds); |
|
231 | + $rand = rand($this->min_rounds, $this->max_rounds); |
|
232 | 232 | $params = array('rounds' => $rand); |
233 | 233 | } |
234 | 234 | else |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | } |
238 | 238 | |
239 | 239 | $params['salt_prefix'] = $this->config->item('salt_prefix', 'ion_auth'); |
240 | - $this->load->library('bcrypt',$params); |
|
240 | + $this->load->library('bcrypt', $params); |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | $this->trigger_events('model_constructor'); |
@@ -260,28 +260,28 @@ discard block |
||
260 | 260 | * @return void |
261 | 261 | * @author Mathew |
262 | 262 | **/ |
263 | - public function hash_password($password, $salt=false, $use_sha1_override=FALSE) |
|
263 | + public function hash_password($password, $salt = false, $use_sha1_override = FALSE) |
|
264 | 264 | { |
265 | - if (empty($password)) |
|
265 | + if(empty($password)) |
|
266 | 266 | { |
267 | 267 | return FALSE; |
268 | 268 | } |
269 | 269 | |
270 | 270 | // bcrypt |
271 | - if ($use_sha1_override === FALSE && $this->hash_method == 'bcrypt') |
|
271 | + if($use_sha1_override === FALSE && $this->hash_method == 'bcrypt') |
|
272 | 272 | { |
273 | 273 | return $this->bcrypt->hash($password); |
274 | 274 | } |
275 | 275 | |
276 | 276 | |
277 | - if ($this->store_salt && $salt) |
|
277 | + if($this->store_salt && $salt) |
|
278 | 278 | { |
279 | - return sha1($password . $salt); |
|
279 | + return sha1($password.$salt); |
|
280 | 280 | } |
281 | 281 | else |
282 | 282 | { |
283 | 283 | $salt = $this->salt(); |
284 | - return $salt . substr(sha1($salt . $password), 0, -$this->salt_length); |
|
284 | + return $salt.substr(sha1($salt.$password), 0, -$this->salt_length); |
|
285 | 285 | } |
286 | 286 | } |
287 | 287 | |
@@ -292,9 +292,9 @@ discard block |
||
292 | 292 | * @return void |
293 | 293 | * @author Mathew |
294 | 294 | **/ |
295 | - public function hash_password_db($id, $password, $use_sha1_override=FALSE) |
|
295 | + public function hash_password_db($id, $password, $use_sha1_override = FALSE) |
|
296 | 296 | { |
297 | - if (empty($id) || empty($password)) |
|
297 | + if(empty($id) || empty($password)) |
|
298 | 298 | { |
299 | 299 | return FALSE; |
300 | 300 | } |
@@ -309,15 +309,15 @@ discard block |
||
309 | 309 | |
310 | 310 | $hash_password_db = $query->row(); |
311 | 311 | |
312 | - if ($query->num_rows() !== 1) |
|
312 | + if($query->num_rows() !== 1) |
|
313 | 313 | { |
314 | 314 | return FALSE; |
315 | 315 | } |
316 | 316 | |
317 | 317 | // bcrypt |
318 | - if ($use_sha1_override === FALSE && $this->hash_method == 'bcrypt') |
|
318 | + if($use_sha1_override === FALSE && $this->hash_method == 'bcrypt') |
|
319 | 319 | { |
320 | - if ($this->bcrypt->verify($password,$hash_password_db->password)) |
|
320 | + if($this->bcrypt->verify($password, $hash_password_db->password)) |
|
321 | 321 | { |
322 | 322 | return TRUE; |
323 | 323 | } |
@@ -326,15 +326,15 @@ discard block |
||
326 | 326 | } |
327 | 327 | |
328 | 328 | // sha1 |
329 | - if ($this->store_salt) |
|
329 | + if($this->store_salt) |
|
330 | 330 | { |
331 | - $db_password = sha1($password . $hash_password_db->salt); |
|
331 | + $db_password = sha1($password.$hash_password_db->salt); |
|
332 | 332 | } |
333 | 333 | else |
334 | 334 | { |
335 | 335 | $salt = substr($hash_password_db->password, 0, $this->salt_length); |
336 | 336 | |
337 | - $db_password = $salt . substr(sha1($salt . $password), 0, -$this->salt_length); |
|
337 | + $db_password = $salt.substr(sha1($salt.$password), 0, -$this->salt_length); |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | if($db_password == $hash_password_db->password) |
@@ -374,44 +374,44 @@ discard block |
||
374 | 374 | $buffer = ''; |
375 | 375 | $buffer_valid = false; |
376 | 376 | |
377 | - if (function_exists('random_bytes')) { |
|
377 | + if(function_exists('random_bytes')) { |
|
378 | 378 | $buffer = random_bytes($raw_salt_len); |
379 | - if ($buffer) { |
|
379 | + if($buffer) { |
|
380 | 380 | $buffer_valid = true; |
381 | 381 | } |
382 | 382 | } |
383 | 383 | |
384 | - if (!$buffer_valid && function_exists('mcrypt_create_iv') && !defined('PHALANGER')) { |
|
384 | + if(!$buffer_valid && function_exists('mcrypt_create_iv') && !defined('PHALANGER')) { |
|
385 | 385 | $buffer = mcrypt_create_iv($raw_salt_len, MCRYPT_DEV_URANDOM); |
386 | - if ($buffer) { |
|
386 | + if($buffer) { |
|
387 | 387 | $buffer_valid = true; |
388 | 388 | } |
389 | 389 | } |
390 | 390 | |
391 | - if (!$buffer_valid && function_exists('openssl_random_pseudo_bytes')) { |
|
391 | + if(!$buffer_valid && function_exists('openssl_random_pseudo_bytes')) { |
|
392 | 392 | $buffer = openssl_random_pseudo_bytes($raw_salt_len); |
393 | - if ($buffer) { |
|
393 | + if($buffer) { |
|
394 | 394 | $buffer_valid = true; |
395 | 395 | } |
396 | 396 | } |
397 | 397 | |
398 | - if (!$buffer_valid && @is_readable('/dev/urandom')) { |
|
398 | + if(!$buffer_valid && @is_readable('/dev/urandom')) { |
|
399 | 399 | $f = fopen('/dev/urandom', 'r'); |
400 | 400 | $read = strlen($buffer); |
401 | - while ($read < $raw_salt_len) { |
|
401 | + while($read < $raw_salt_len) { |
|
402 | 402 | $buffer .= fread($f, $raw_salt_len - $read); |
403 | 403 | $read = strlen($buffer); |
404 | 404 | } |
405 | 405 | fclose($f); |
406 | - if ($read >= $raw_salt_len) { |
|
406 | + if($read >= $raw_salt_len) { |
|
407 | 407 | $buffer_valid = true; |
408 | 408 | } |
409 | 409 | } |
410 | 410 | |
411 | - if (!$buffer_valid || strlen($buffer) < $raw_salt_len) { |
|
411 | + if(!$buffer_valid || strlen($buffer) < $raw_salt_len) { |
|
412 | 412 | $bl = strlen($buffer); |
413 | - for ($i = 0; $i < $raw_salt_len; $i++) { |
|
414 | - if ($i < $bl) { |
|
413 | + for($i = 0; $i < $raw_salt_len; $i++) { |
|
414 | + if($i < $bl) { |
|
415 | 415 | $buffer[$i] = $buffer[$i] ^ chr(mt_rand(0, 255)); |
416 | 416 | } else { |
417 | 417 | $buffer .= chr(mt_rand(0, 255)); |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | { |
454 | 454 | $this->trigger_events('pre_activate'); |
455 | 455 | |
456 | - if ($code !== FALSE) |
|
456 | + if($code !== FALSE) |
|
457 | 457 | { |
458 | 458 | $query = $this->db->select($this->identity_column) |
459 | 459 | ->where('activation_code', $code) |
@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | |
465 | 465 | $result = $query->row(); |
466 | 466 | |
467 | - if ($query->num_rows() !== 1) |
|
467 | + if($query->num_rows() !== 1) |
|
468 | 468 | { |
469 | 469 | $this->trigger_events(array('post_activate', 'post_activate_unsuccessful')); |
470 | 470 | $this->set_error('activate_unsuccessful'); |
@@ -493,7 +493,7 @@ discard block |
||
493 | 493 | |
494 | 494 | |
495 | 495 | $return = $this->db->affected_rows() == 1; |
496 | - if ($return) |
|
496 | + if($return) |
|
497 | 497 | { |
498 | 498 | $this->trigger_events(array('post_activate', 'post_activate_successful')); |
499 | 499 | $this->set_message('activate_successful'); |
@@ -519,7 +519,7 @@ discard block |
||
519 | 519 | { |
520 | 520 | $this->trigger_events('deactivate'); |
521 | 521 | |
522 | - if (!isset($id)) |
|
522 | + if(!isset($id)) |
|
523 | 523 | { |
524 | 524 | $this->set_error('deactivate_unsuccessful'); |
525 | 525 | return FALSE; |
@@ -542,7 +542,7 @@ discard block |
||
542 | 542 | $this->db->update($this->tables['users'], $data, array('id' => $id)); |
543 | 543 | |
544 | 544 | $return = $this->db->affected_rows() == 1; |
545 | - if ($return) |
|
545 | + if($return) |
|
546 | 546 | $this->set_message('deactivate_successful'); |
547 | 547 | else |
548 | 548 | $this->set_error('deactivate_unsuccessful'); |
@@ -552,14 +552,14 @@ discard block |
||
552 | 552 | |
553 | 553 | public function clear_forgotten_password_code($code) { |
554 | 554 | |
555 | - if (empty($code)) |
|
555 | + if(empty($code)) |
|
556 | 556 | { |
557 | 557 | return FALSE; |
558 | 558 | } |
559 | 559 | |
560 | 560 | $this->db->where('forgotten_password_code', $code); |
561 | 561 | |
562 | - if ($this->db->count_all_results($this->tables['users']) > 0) |
|
562 | + if($this->db->count_all_results($this->tables['users']) > 0) |
|
563 | 563 | { |
564 | 564 | $data = array( |
565 | 565 | 'forgotten_password_code' => NULL, |
@@ -583,7 +583,7 @@ discard block |
||
583 | 583 | public function reset_password($identity, $new) { |
584 | 584 | $this->trigger_events('pre_change_password'); |
585 | 585 | |
586 | - if (!$this->identity_check($identity)) { |
|
586 | + if(!$this->identity_check($identity)) { |
|
587 | 587 | $this->trigger_events(array('post_change_password', 'post_change_password_unsuccessful')); |
588 | 588 | return FALSE; |
589 | 589 | } |
@@ -596,7 +596,7 @@ discard block |
||
596 | 596 | ->order_by('id', 'desc') |
597 | 597 | ->get($this->tables['users']); |
598 | 598 | |
599 | - if ($query->num_rows() !== 1) |
|
599 | + if($query->num_rows() !== 1) |
|
600 | 600 | { |
601 | 601 | $this->trigger_events(array('post_change_password', 'post_change_password_unsuccessful')); |
602 | 602 | $this->set_error('password_change_unsuccessful'); |
@@ -620,7 +620,7 @@ discard block |
||
620 | 620 | $this->db->update($this->tables['users'], $data, array($this->identity_column => $identity)); |
621 | 621 | |
622 | 622 | $return = $this->db->affected_rows() == 1; |
623 | - if ($return) |
|
623 | + if($return) |
|
624 | 624 | { |
625 | 625 | $this->trigger_events(array('post_change_password', 'post_change_password_successful')); |
626 | 626 | $this->set_message('password_change_successful'); |
@@ -652,7 +652,7 @@ discard block |
||
652 | 652 | ->order_by('id', 'desc') |
653 | 653 | ->get($this->tables['users']); |
654 | 654 | |
655 | - if ($query->num_rows() !== 1) |
|
655 | + if($query->num_rows() !== 1) |
|
656 | 656 | { |
657 | 657 | $this->trigger_events(array('post_change_password', 'post_change_password_unsuccessful')); |
658 | 658 | $this->set_error('password_change_unsuccessful'); |
@@ -663,10 +663,10 @@ discard block |
||
663 | 663 | |
664 | 664 | $old_password_matches = $this->hash_password_db($user->id, $old); |
665 | 665 | |
666 | - if ($old_password_matches === TRUE) |
|
666 | + if($old_password_matches === TRUE) |
|
667 | 667 | { |
668 | 668 | // store the new password and reset the remember code so all remembered instances have to re-login |
669 | - $hashed_new_password = $this->hash_password($new, $user->salt); |
|
669 | + $hashed_new_password = $this->hash_password($new, $user->salt); |
|
670 | 670 | $data = array( |
671 | 671 | 'password' => $hashed_new_password, |
672 | 672 | 'remember_code' => NULL, |
@@ -675,7 +675,7 @@ discard block |
||
675 | 675 | $this->trigger_events('extra_where'); |
676 | 676 | |
677 | 677 | $successfully_changed_password_in_db = $this->db->update($this->tables['users'], $data, array($this->identity_column => $identity)); |
678 | - if ($successfully_changed_password_in_db) |
|
678 | + if($successfully_changed_password_in_db) |
|
679 | 679 | { |
680 | 680 | $this->trigger_events(array('post_change_password', 'post_change_password_successful')); |
681 | 681 | $this->set_message('password_change_successful'); |
@@ -703,7 +703,7 @@ discard block |
||
703 | 703 | { |
704 | 704 | $this->trigger_events('username_check'); |
705 | 705 | |
706 | - if (empty($username)) |
|
706 | + if(empty($username)) |
|
707 | 707 | { |
708 | 708 | return FALSE; |
709 | 709 | } |
@@ -727,7 +727,7 @@ discard block |
||
727 | 727 | { |
728 | 728 | $this->trigger_events('email_check'); |
729 | 729 | |
730 | - if (empty($email)) |
|
730 | + if(empty($email)) |
|
731 | 731 | { |
732 | 732 | return FALSE; |
733 | 733 | } |
@@ -751,7 +751,7 @@ discard block |
||
751 | 751 | { |
752 | 752 | $this->trigger_events('identity_check'); |
753 | 753 | |
754 | - if (empty($identity)) |
|
754 | + if(empty($identity)) |
|
755 | 755 | { |
756 | 756 | return FALSE; |
757 | 757 | } |
@@ -770,7 +770,7 @@ discard block |
||
770 | 770 | **/ |
771 | 771 | public function forgotten_password($identity) |
772 | 772 | { |
773 | - if (empty($identity)) |
|
773 | + if(empty($identity)) |
|
774 | 774 | { |
775 | 775 | $this->trigger_events(array('post_forgotten_password', 'post_forgotten_password_unsuccessful')); |
776 | 776 | return FALSE; |
@@ -782,18 +782,18 @@ discard block |
||
782 | 782 | $activation_code_part = openssl_random_pseudo_bytes(128); |
783 | 783 | } |
784 | 784 | |
785 | - for($i=0;$i<1024;$i++) { |
|
786 | - $activation_code_part = sha1($activation_code_part . mt_rand() . microtime()); |
|
785 | + for($i = 0; $i < 1024; $i++) { |
|
786 | + $activation_code_part = sha1($activation_code_part.mt_rand().microtime()); |
|
787 | 787 | } |
788 | 788 | |
789 | 789 | $key = $this->hash_code($activation_code_part.$identity); |
790 | 790 | |
791 | 791 | // If enable query strings is set, then we need to replace any unsafe characters so that the code can still work |
792 | - if ($key != '' && $this->config->item('permitted_uri_chars') != '' && $this->config->item('enable_query_strings') == FALSE) |
|
792 | + if($key != '' && $this->config->item('permitted_uri_chars') != '' && $this->config->item('enable_query_strings') == FALSE) |
|
793 | 793 | { |
794 | 794 | // preg_quote() in PHP 5.3 escapes -, so the str_replace() and addition of - to preg_quote() is to maintain backwards |
795 | 795 | // compatibility as many are unaware of how characters in the permitted_uri_chars will be parsed as a regex pattern |
796 | - if ( ! preg_match("|^[".str_replace(array('\\-', '\-'), '-', preg_quote($this->config->item('permitted_uri_chars'), '-'))."]+$|i", $key)) |
|
796 | + if(!preg_match("|^[".str_replace(array('\\-', '\-'), '-', preg_quote($this->config->item('permitted_uri_chars'), '-'))."]+$|i", $key)) |
|
797 | 797 | { |
798 | 798 | $key = preg_replace("/[^".$this->config->item('permitted_uri_chars')."]+/i", "-", $key); |
799 | 799 | } |
@@ -813,7 +813,7 @@ discard block |
||
813 | 813 | |
814 | 814 | $return = $this->db->affected_rows() == 1; |
815 | 815 | |
816 | - if ($return) |
|
816 | + if($return) |
|
817 | 817 | $this->trigger_events(array('post_forgotten_password', 'post_forgotten_password_successful')); |
818 | 818 | else |
819 | 819 | $this->trigger_events(array('post_forgotten_password', 'post_forgotten_password_unsuccessful')); |
@@ -827,11 +827,11 @@ discard block |
||
827 | 827 | * @return string |
828 | 828 | * @author Mathew |
829 | 829 | **/ |
830 | - public function forgotten_password_complete($code, $salt=FALSE) |
|
830 | + public function forgotten_password_complete($code, $salt = FALSE) |
|
831 | 831 | { |
832 | 832 | $this->trigger_events('pre_forgotten_password_complete'); |
833 | 833 | |
834 | - if (empty($code)) |
|
834 | + if(empty($code)) |
|
835 | 835 | { |
836 | 836 | $this->trigger_events(array('post_forgotten_password_complete', 'post_forgotten_password_complete_unsuccessful')); |
837 | 837 | return FALSE; |
@@ -839,12 +839,12 @@ discard block |
||
839 | 839 | |
840 | 840 | $profile = $this->where('forgotten_password_code', $code)->users()->row(); //pass the code to profile |
841 | 841 | |
842 | - if ($profile) { |
|
842 | + if($profile) { |
|
843 | 843 | |
844 | - if ($this->config->item('forgot_password_expiration', 'ion_auth') > 0) { |
|
844 | + if($this->config->item('forgot_password_expiration', 'ion_auth') > 0) { |
|
845 | 845 | //Make sure it isn't expired |
846 | 846 | $expiration = $this->config->item('forgot_password_expiration', 'ion_auth'); |
847 | - if (time() - $profile->forgotten_password_time > $expiration) { |
|
847 | + if(time() - $profile->forgotten_password_time > $expiration) { |
|
848 | 848 | //it has expired |
849 | 849 | $this->set_error('forgot_password_expired'); |
850 | 850 | $this->trigger_events(array('post_forgotten_password_complete', 'post_forgotten_password_complete_unsuccessful')); |
@@ -882,20 +882,20 @@ discard block |
||
882 | 882 | |
883 | 883 | $manual_activation = $this->config->item('manual_activation', 'ion_auth'); |
884 | 884 | |
885 | - if ($this->identity_check($identity)) |
|
885 | + if($this->identity_check($identity)) |
|
886 | 886 | { |
887 | 887 | $this->set_error('account_creation_duplicate_identity'); |
888 | 888 | return FALSE; |
889 | 889 | } |
890 | - elseif ( !$this->config->item('default_group', 'ion_auth') && empty($groups) ) |
|
890 | + elseif(!$this->config->item('default_group', 'ion_auth') && empty($groups)) |
|
891 | 891 | { |
892 | 892 | $this->set_error('account_creation_missing_default_group'); |
893 | 893 | return FALSE; |
894 | 894 | } |
895 | 895 | |
896 | 896 | // check if the default set in config exists in database |
897 | - $query = $this->db->get_where($this->tables['groups'],array('name' => $this->config->item('default_group', 'ion_auth')),1)->row(); |
|
898 | - if( !isset($query->id) && empty($groups) ) |
|
897 | + $query = $this->db->get_where($this->tables['groups'], array('name' => $this->config->item('default_group', 'ion_auth')), 1)->row(); |
|
898 | + if(!isset($query->id) && empty($groups)) |
|
899 | 899 | { |
900 | 900 | $this->set_error('account_creation_invalid_default_group'); |
901 | 901 | return FALSE; |
@@ -920,7 +920,7 @@ discard block |
||
920 | 920 | 'active' => ($manual_activation === false ? 1 : 0) |
921 | 921 | ); |
922 | 922 | |
923 | - if ($this->store_salt) |
|
923 | + if($this->store_salt) |
|
924 | 924 | { |
925 | 925 | $data['salt'] = $salt; |
926 | 926 | } |
@@ -933,18 +933,18 @@ discard block |
||
933 | 933 | |
934 | 934 | $this->db->insert($this->tables['users'], $user_data); |
935 | 935 | |
936 | - $id = $this->db->insert_id($this->tables['users'] . '_id_seq'); |
|
936 | + $id = $this->db->insert_id($this->tables['users'].'_id_seq'); |
|
937 | 937 | |
938 | 938 | // add in groups array if it doesn't exists and stop adding into default group if default group ids are set |
939 | - if( isset($default_group->id) && empty($groups) ) |
|
939 | + if(isset($default_group->id) && empty($groups)) |
|
940 | 940 | { |
941 | 941 | $groups[] = $default_group->id; |
942 | 942 | } |
943 | 943 | |
944 | - if (!empty($groups)) |
|
944 | + if(!empty($groups)) |
|
945 | 945 | { |
946 | 946 | // add to groups |
947 | - foreach ($groups as $group) |
|
947 | + foreach($groups as $group) |
|
948 | 948 | { |
949 | 949 | $this->add_to_group($group, $id); |
950 | 950 | } |
@@ -961,11 +961,11 @@ discard block |
||
961 | 961 | * @return bool |
962 | 962 | * @author Mathew |
963 | 963 | **/ |
964 | - public function login($identity, $password, $remember=FALSE) |
|
964 | + public function login($identity, $password, $remember = FALSE) |
|
965 | 965 | { |
966 | 966 | $this->trigger_events('pre_login'); |
967 | 967 | |
968 | - if (empty($identity) || empty($password)) |
|
968 | + if(empty($identity) || empty($password)) |
|
969 | 969 | { |
970 | 970 | $this->set_error('login_unsuccessful'); |
971 | 971 | return FALSE; |
@@ -973,7 +973,7 @@ discard block |
||
973 | 973 | |
974 | 974 | $this->trigger_events('extra_where'); |
975 | 975 | |
976 | - $query = $this->db->select($this->identity_column . ', email, id, password, active, last_login') |
|
976 | + $query = $this->db->select($this->identity_column.', email, id, password, active, last_login') |
|
977 | 977 | ->where($this->identity_column, $identity) |
978 | 978 | ->limit(1) |
979 | 979 | ->order_by('id', 'desc') |
@@ -990,15 +990,15 @@ discard block |
||
990 | 990 | return FALSE; |
991 | 991 | } |
992 | 992 | |
993 | - if ($query->num_rows() === 1) |
|
993 | + if($query->num_rows() === 1) |
|
994 | 994 | { |
995 | 995 | $user = $query->row(); |
996 | 996 | |
997 | 997 | $password = $this->hash_password_db($user->id, $password); |
998 | 998 | |
999 | - if ($password === TRUE) |
|
999 | + if($password === TRUE) |
|
1000 | 1000 | { |
1001 | - if ($user->active == 0) |
|
1001 | + if($user->active == 0) |
|
1002 | 1002 | { |
1003 | 1003 | $this->trigger_events('post_login_unsuccessful'); |
1004 | 1004 | $this->set_error('login_unsuccessful_not_active'); |
@@ -1012,7 +1012,7 @@ discard block |
||
1012 | 1012 | |
1013 | 1013 | $this->clear_login_attempts($identity); |
1014 | 1014 | |
1015 | - if ($remember && $this->config->item('remember_users', 'ion_auth')) |
|
1015 | + if($remember && $this->config->item('remember_users', 'ion_auth')) |
|
1016 | 1016 | { |
1017 | 1017 | $this->remember_user($user->id); |
1018 | 1018 | } |
@@ -1044,19 +1044,19 @@ discard block |
||
1044 | 1044 | { |
1045 | 1045 | $recheck = (null !== $this->config->item('recheck_timer', 'ion_auth')) ? $this->config->item('recheck_timer', 'ion_auth') : 0; |
1046 | 1046 | |
1047 | - if($recheck!==0) |
|
1047 | + if($recheck !== 0) |
|
1048 | 1048 | { |
1049 | 1049 | $last_login = $this->session->userdata('last_check'); |
1050 | - if($last_login+$recheck < time()) |
|
1050 | + if($last_login + $recheck < time()) |
|
1051 | 1051 | { |
1052 | 1052 | $query = $this->db->select('id') |
1053 | - ->where(array($this->identity_column=>$this->session->userdata('identity'),'active'=>'1')) |
|
1053 | + ->where(array($this->identity_column=>$this->session->userdata('identity'), 'active'=>'1')) |
|
1054 | 1054 | ->limit(1) |
1055 | 1055 | ->order_by('id', 'desc') |
1056 | 1056 | ->get($this->tables['users']); |
1057 | - if ($query->num_rows() === 1) |
|
1057 | + if($query->num_rows() === 1) |
|
1058 | 1058 | { |
1059 | - $this->session->set_userdata('last_check',time()); |
|
1059 | + $this->session->set_userdata('last_check', time()); |
|
1060 | 1060 | } |
1061 | 1061 | else |
1062 | 1062 | { |
@@ -1064,13 +1064,13 @@ discard block |
||
1064 | 1064 | |
1065 | 1065 | $identity = $this->config->item('identity', 'ion_auth'); |
1066 | 1066 | |
1067 | - if (substr(CI_VERSION, 0, 1) == '2') |
|
1067 | + if(substr(CI_VERSION, 0, 1) == '2') |
|
1068 | 1068 | { |
1069 | - $this->session->unset_userdata( array($identity => '', 'id' => '', 'user_id' => '') ); |
|
1069 | + $this->session->unset_userdata(array($identity => '', 'id' => '', 'user_id' => '')); |
|
1070 | 1070 | } |
1071 | 1071 | else |
1072 | 1072 | { |
1073 | - $this->session->unset_userdata( array($identity, 'id', 'user_id') ); |
|
1073 | + $this->session->unset_userdata(array($identity, 'id', 'user_id')); |
|
1074 | 1074 | } |
1075 | 1075 | return false; |
1076 | 1076 | } |
@@ -1092,9 +1092,9 @@ discard block |
||
1092 | 1092 | * @return boolean |
1093 | 1093 | **/ |
1094 | 1094 | public function is_max_login_attempts_exceeded($identity, $ip_address = NULL) { |
1095 | - if ($this->config->item('track_login_attempts', 'ion_auth')) { |
|
1095 | + if($this->config->item('track_login_attempts', 'ion_auth')) { |
|
1096 | 1096 | $max_attempts = $this->config->item('maximum_login_attempts', 'ion_auth'); |
1097 | - if ($max_attempts > 0) { |
|
1097 | + if($max_attempts > 0) { |
|
1098 | 1098 | $attempts = $this->get_attempts_num($identity, $ip_address); |
1099 | 1099 | return $attempts >= $max_attempts; |
1100 | 1100 | } |
@@ -1115,11 +1115,11 @@ discard block |
||
1115 | 1115 | */ |
1116 | 1116 | public function get_attempts_num($identity, $ip_address = NULL) |
1117 | 1117 | { |
1118 | - if ($this->config->item('track_login_attempts', 'ion_auth')) { |
|
1118 | + if($this->config->item('track_login_attempts', 'ion_auth')) { |
|
1119 | 1119 | $this->db->select('1', FALSE); |
1120 | 1120 | $this->db->where('login', $identity); |
1121 | - if ($this->config->item('track_login_ip_address', 'ion_auth')) { |
|
1122 | - if (!isset($ip_address)) { |
|
1121 | + if($this->config->item('track_login_ip_address', 'ion_auth')) { |
|
1122 | + if(!isset($ip_address)) { |
|
1123 | 1123 | $ip_address = $this->_prepare_ip($this->input->ip_address()); |
1124 | 1124 | } |
1125 | 1125 | $this->db->where('ip_address', $ip_address); |
@@ -1164,11 +1164,11 @@ discard block |
||
1164 | 1164 | * @return int |
1165 | 1165 | */ |
1166 | 1166 | public function get_last_attempt_time($identity, $ip_address = NULL) { |
1167 | - if ($this->config->item('track_login_attempts', 'ion_auth')) { |
|
1167 | + if($this->config->item('track_login_attempts', 'ion_auth')) { |
|
1168 | 1168 | $this->db->select('time'); |
1169 | 1169 | $this->db->where('login', $identity); |
1170 | - if ($this->config->item('track_login_ip_address', 'ion_auth')) { |
|
1171 | - if (!isset($ip_address)) { |
|
1170 | + if($this->config->item('track_login_ip_address', 'ion_auth')) { |
|
1171 | + if(!isset($ip_address)) { |
|
1172 | 1172 | $ip_address = $this->_prepare_ip($this->input->ip_address()); |
1173 | 1173 | } |
1174 | 1174 | $this->db->where('ip_address', $ip_address); |
@@ -1191,7 +1191,7 @@ discard block |
||
1191 | 1191 | * @return string |
1192 | 1192 | */ |
1193 | 1193 | public function get_last_attempt_ip($identity) { |
1194 | - if ($this->config->item('track_login_attempts', 'ion_auth') && $this->config->item('track_login_ip_address', 'ion_auth')) { |
|
1194 | + if($this->config->item('track_login_attempts', 'ion_auth') && $this->config->item('track_login_ip_address', 'ion_auth')) { |
|
1195 | 1195 | $this->db->select('ip_address'); |
1196 | 1196 | $this->db->where('login', $identity); |
1197 | 1197 | $this->db->order_by('id', 'desc'); |
@@ -1214,9 +1214,9 @@ discard block |
||
1214 | 1214 | * @param string $identity: user's identity |
1215 | 1215 | **/ |
1216 | 1216 | public function increase_login_attempts($identity) { |
1217 | - if ($this->config->item('track_login_attempts', 'ion_auth')) { |
|
1217 | + if($this->config->item('track_login_attempts', 'ion_auth')) { |
|
1218 | 1218 | $data = array('ip_address' => '', 'login' => $identity, 'time' => time()); |
1219 | - if ($this->config->item('track_login_ip_address', 'ion_auth')) { |
|
1219 | + if($this->config->item('track_login_ip_address', 'ion_auth')) { |
|
1220 | 1220 | $data['ip_address'] = $this->_prepare_ip($this->input->ip_address()); |
1221 | 1221 | } |
1222 | 1222 | return $this->db->insert($this->tables['login_attempts'], $data); |
@@ -1238,13 +1238,13 @@ discard block |
||
1238 | 1238 | * Use get_last_attempt_ip($identity) to retrieve user's last IP |
1239 | 1239 | **/ |
1240 | 1240 | public function clear_login_attempts($identity, $old_attempts_expire_period = 86400, $ip_address = NULL) { |
1241 | - if ($this->config->item('track_login_attempts', 'ion_auth')) { |
|
1241 | + if($this->config->item('track_login_attempts', 'ion_auth')) { |
|
1242 | 1242 | // Make sure $old_attempts_expire_period is at least equals to lockout_time |
1243 | 1243 | $old_attempts_expire_period = max($old_attempts_expire_period, $this->config->item('lockout_time', 'ion_auth')); |
1244 | 1244 | |
1245 | 1245 | $this->db->where('login', $identity); |
1246 | - if ($this->config->item('track_login_ip_address', 'ion_auth')) { |
|
1247 | - if (!isset($ip_address)) { |
|
1246 | + if($this->config->item('track_login_ip_address', 'ion_auth')) { |
|
1247 | + if(!isset($ip_address)) { |
|
1248 | 1248 | $ip_address = $this->_prepare_ip($this->input->ip_address()); |
1249 | 1249 | } |
1250 | 1250 | $this->db->where('ip_address', $ip_address); |
@@ -1277,7 +1277,7 @@ discard block |
||
1277 | 1277 | { |
1278 | 1278 | $this->trigger_events('where'); |
1279 | 1279 | |
1280 | - if (!is_array($where)) |
|
1280 | + if(!is_array($where)) |
|
1281 | 1281 | { |
1282 | 1282 | $where = array($where => $value); |
1283 | 1283 | } |
@@ -1309,7 +1309,7 @@ discard block |
||
1309 | 1309 | return $this; |
1310 | 1310 | } |
1311 | 1311 | |
1312 | - public function order_by($by, $order='desc') |
|
1312 | + public function order_by($by, $order = 'desc') |
|
1313 | 1313 | { |
1314 | 1314 | $this->trigger_events('order_by'); |
1315 | 1315 | |
@@ -1374,9 +1374,9 @@ discard block |
||
1374 | 1374 | { |
1375 | 1375 | $this->trigger_events('users'); |
1376 | 1376 | |
1377 | - if (isset($this->_ion_select) && !empty($this->_ion_select)) |
|
1377 | + if(isset($this->_ion_select) && !empty($this->_ion_select)) |
|
1378 | 1378 | { |
1379 | - foreach ($this->_ion_select as $select) |
|
1379 | + foreach($this->_ion_select as $select) |
|
1380 | 1380 | { |
1381 | 1381 | $this->db->select($select); |
1382 | 1382 | } |
@@ -1394,16 +1394,16 @@ discard block |
||
1394 | 1394 | } |
1395 | 1395 | |
1396 | 1396 | // filter by group id(s) if passed |
1397 | - if (isset($groups)) |
|
1397 | + if(isset($groups)) |
|
1398 | 1398 | { |
1399 | 1399 | // build an array if only one group was passed |
1400 | - if (!is_array($groups)) |
|
1400 | + if(!is_array($groups)) |
|
1401 | 1401 | { |
1402 | 1402 | $groups = Array($groups); |
1403 | 1403 | } |
1404 | 1404 | |
1405 | 1405 | // join and then run a where_in against the group ids |
1406 | - if (isset($groups) && !empty($groups)) |
|
1406 | + if(isset($groups) && !empty($groups)) |
|
1407 | 1407 | { |
1408 | 1408 | $this->db->distinct(); |
1409 | 1409 | $this->db->join( |
@@ -1425,8 +1425,8 @@ discard block |
||
1425 | 1425 | // if group name was used we do one more join with groups |
1426 | 1426 | if(!empty($group_names)) |
1427 | 1427 | { |
1428 | - $this->db->join($this->tables['groups'], $this->tables['users_groups'] . '.' . $this->join['groups'] . ' = ' . $this->tables['groups'] . '.id', 'inner'); |
|
1429 | - $this->db->where_in($this->tables['groups'] . '.name', $group_names); |
|
1428 | + $this->db->join($this->tables['groups'], $this->tables['users_groups'].'.'.$this->join['groups'].' = '.$this->tables['groups'].'.id', 'inner'); |
|
1429 | + $this->db->where_in($this->tables['groups'].'.name', $group_names); |
|
1430 | 1430 | } |
1431 | 1431 | if(!empty($group_ids)) |
1432 | 1432 | { |
@@ -1437,9 +1437,9 @@ discard block |
||
1437 | 1437 | $this->trigger_events('extra_where'); |
1438 | 1438 | |
1439 | 1439 | // run each where that was passed |
1440 | - if (isset($this->_ion_where) && !empty($this->_ion_where)) |
|
1440 | + if(isset($this->_ion_where) && !empty($this->_ion_where)) |
|
1441 | 1441 | { |
1442 | - foreach ($this->_ion_where as $where) |
|
1442 | + foreach($this->_ion_where as $where) |
|
1443 | 1443 | { |
1444 | 1444 | $this->db->where($where); |
1445 | 1445 | } |
@@ -1447,9 +1447,9 @@ discard block |
||
1447 | 1447 | $this->_ion_where = array(); |
1448 | 1448 | } |
1449 | 1449 | |
1450 | - if (isset($this->_ion_like) && !empty($this->_ion_like)) |
|
1450 | + if(isset($this->_ion_like) && !empty($this->_ion_like)) |
|
1451 | 1451 | { |
1452 | - foreach ($this->_ion_like as $like) |
|
1452 | + foreach($this->_ion_like as $like) |
|
1453 | 1453 | { |
1454 | 1454 | $this->db->or_like($like['like'], $like['value'], $like['position']); |
1455 | 1455 | } |
@@ -1457,22 +1457,22 @@ discard block |
||
1457 | 1457 | $this->_ion_like = array(); |
1458 | 1458 | } |
1459 | 1459 | |
1460 | - if (isset($this->_ion_limit) && isset($this->_ion_offset)) |
|
1460 | + if(isset($this->_ion_limit) && isset($this->_ion_offset)) |
|
1461 | 1461 | { |
1462 | 1462 | $this->db->limit($this->_ion_limit, $this->_ion_offset); |
1463 | 1463 | |
1464 | 1464 | $this->_ion_limit = NULL; |
1465 | 1465 | $this->_ion_offset = NULL; |
1466 | 1466 | } |
1467 | - else if (isset($this->_ion_limit)) |
|
1467 | + else if(isset($this->_ion_limit)) |
|
1468 | 1468 | { |
1469 | 1469 | $this->db->limit($this->_ion_limit); |
1470 | 1470 | |
1471 | - $this->_ion_limit = NULL; |
|
1471 | + $this->_ion_limit = NULL; |
|
1472 | 1472 | } |
1473 | 1473 | |
1474 | 1474 | // set the order |
1475 | - if (isset($this->_ion_order_by) && isset($this->_ion_order)) |
|
1475 | + if(isset($this->_ion_order_by) && isset($this->_ion_order)) |
|
1476 | 1476 | { |
1477 | 1477 | $this->db->order_by($this->_ion_order_by, $this->_ion_order); |
1478 | 1478 | |
@@ -1513,7 +1513,7 @@ discard block |
||
1513 | 1513 | * @return array |
1514 | 1514 | * @author Ben Edmunds |
1515 | 1515 | **/ |
1516 | - public function get_users_groups($id=FALSE) |
|
1516 | + public function get_users_groups($id = FALSE) |
|
1517 | 1517 | { |
1518 | 1518 | $this->trigger_events('get_users_group'); |
1519 | 1519 | |
@@ -1532,7 +1532,7 @@ discard block |
||
1532 | 1532 | * @return bool |
1533 | 1533 | * @author Ben Edmunds |
1534 | 1534 | **/ |
1535 | - public function add_to_group($group_ids, $user_id=false) |
|
1535 | + public function add_to_group($group_ids, $user_id = false) |
|
1536 | 1536 | { |
1537 | 1537 | $this->trigger_events('add_to_group'); |
1538 | 1538 | |
@@ -1547,11 +1547,11 @@ discard block |
||
1547 | 1547 | $return = 0; |
1548 | 1548 | |
1549 | 1549 | // Then insert each into the database |
1550 | - foreach ($group_ids as $group_id) |
|
1550 | + foreach($group_ids as $group_id) |
|
1551 | 1551 | { |
1552 | - if ($this->db->insert($this->tables['users_groups'], array( $this->join['groups'] => (float)$group_id, $this->join['users'] => (float)$user_id))) |
|
1552 | + if($this->db->insert($this->tables['users_groups'], array($this->join['groups'] => (float) $group_id, $this->join['users'] => (float) $user_id))) |
|
1553 | 1553 | { |
1554 | - if (isset($this->_cache_groups[$group_id])) { |
|
1554 | + if(isset($this->_cache_groups[$group_id])) { |
|
1555 | 1555 | $group_name = $this->_cache_groups[$group_id]; |
1556 | 1556 | } |
1557 | 1557 | else { |
@@ -1575,7 +1575,7 @@ discard block |
||
1575 | 1575 | * @return bool |
1576 | 1576 | * @author Ben Edmunds |
1577 | 1577 | **/ |
1578 | - public function remove_from_group($group_ids=false, $user_id=false) |
|
1578 | + public function remove_from_group($group_ids = false, $user_id = false) |
|
1579 | 1579 | { |
1580 | 1580 | $this->trigger_events('remove_from_group'); |
1581 | 1581 | |
@@ -1586,7 +1586,7 @@ discard block |
||
1586 | 1586 | } |
1587 | 1587 | |
1588 | 1588 | // if group id(s) are passed remove user from the group(s) |
1589 | - if( ! empty($group_ids)) |
|
1589 | + if(!empty($group_ids)) |
|
1590 | 1590 | { |
1591 | 1591 | if(!is_array($group_ids)) |
1592 | 1592 | { |
@@ -1595,8 +1595,8 @@ discard block |
||
1595 | 1595 | |
1596 | 1596 | foreach($group_ids as $group_id) |
1597 | 1597 | { |
1598 | - $this->db->delete($this->tables['users_groups'], array($this->join['groups'] => (float)$group_id, $this->join['users'] => (float)$user_id)); |
|
1599 | - if (isset($this->_cache_user_in_group[$user_id]) && isset($this->_cache_user_in_group[$user_id][$group_id])) |
|
1598 | + $this->db->delete($this->tables['users_groups'], array($this->join['groups'] => (float) $group_id, $this->join['users'] => (float) $user_id)); |
|
1599 | + if(isset($this->_cache_user_in_group[$user_id]) && isset($this->_cache_user_in_group[$user_id][$group_id])) |
|
1600 | 1600 | { |
1601 | 1601 | unset($this->_cache_user_in_group[$user_id][$group_id]); |
1602 | 1602 | } |
@@ -1607,7 +1607,7 @@ discard block |
||
1607 | 1607 | // otherwise remove user from all groups |
1608 | 1608 | else |
1609 | 1609 | { |
1610 | - if ($return = $this->db->delete($this->tables['users_groups'], array($this->join['users'] => (float)$user_id))) { |
|
1610 | + if($return = $this->db->delete($this->tables['users_groups'], array($this->join['users'] => (float) $user_id))) { |
|
1611 | 1611 | $this->_cache_user_in_group[$user_id] = array(); |
1612 | 1612 | } |
1613 | 1613 | } |
@@ -1625,31 +1625,31 @@ discard block |
||
1625 | 1625 | $this->trigger_events('groups'); |
1626 | 1626 | |
1627 | 1627 | // run each where that was passed |
1628 | - if (isset($this->_ion_where) && !empty($this->_ion_where)) |
|
1628 | + if(isset($this->_ion_where) && !empty($this->_ion_where)) |
|
1629 | 1629 | { |
1630 | - foreach ($this->_ion_where as $where) |
|
1630 | + foreach($this->_ion_where as $where) |
|
1631 | 1631 | { |
1632 | 1632 | $this->db->where($where); |
1633 | 1633 | } |
1634 | 1634 | $this->_ion_where = array(); |
1635 | 1635 | } |
1636 | 1636 | |
1637 | - if (isset($this->_ion_limit) && isset($this->_ion_offset)) |
|
1637 | + if(isset($this->_ion_limit) && isset($this->_ion_offset)) |
|
1638 | 1638 | { |
1639 | 1639 | $this->db->limit($this->_ion_limit, $this->_ion_offset); |
1640 | 1640 | |
1641 | 1641 | $this->_ion_limit = NULL; |
1642 | 1642 | $this->_ion_offset = NULL; |
1643 | 1643 | } |
1644 | - else if (isset($this->_ion_limit)) |
|
1644 | + else if(isset($this->_ion_limit)) |
|
1645 | 1645 | { |
1646 | 1646 | $this->db->limit($this->_ion_limit); |
1647 | 1647 | |
1648 | - $this->_ion_limit = NULL; |
|
1648 | + $this->_ion_limit = NULL; |
|
1649 | 1649 | } |
1650 | 1650 | |
1651 | 1651 | // set the order |
1652 | - if (isset($this->_ion_order_by) && isset($this->_ion_order)) |
|
1652 | + if(isset($this->_ion_order_by) && isset($this->_ion_order)) |
|
1653 | 1653 | { |
1654 | 1654 | $this->db->order_by($this->_ion_order_by, $this->_ion_order); |
1655 | 1655 | } |
@@ -1669,7 +1669,7 @@ discard block |
||
1669 | 1669 | { |
1670 | 1670 | $this->trigger_events('group'); |
1671 | 1671 | |
1672 | - if (isset($id)) |
|
1672 | + if(isset($id)) |
|
1673 | 1673 | { |
1674 | 1674 | $this->where($this->tables['groups'].'.id', $id); |
1675 | 1675 | } |
@@ -1694,7 +1694,7 @@ discard block |
||
1694 | 1694 | |
1695 | 1695 | $this->db->trans_begin(); |
1696 | 1696 | |
1697 | - if (array_key_exists($this->identity_column, $data) && $this->identity_check($data[$this->identity_column]) && $user->{$this->identity_column} !== $data[$this->identity_column]) |
|
1697 | + if(array_key_exists($this->identity_column, $data) && $this->identity_check($data[$this->identity_column]) && $user->{$this->identity_column} !== $data[$this->identity_column]) |
|
1698 | 1698 | { |
1699 | 1699 | $this->db->trans_rollback(); |
1700 | 1700 | $this->set_error('account_creation_duplicate_identity'); |
@@ -1708,11 +1708,11 @@ discard block |
||
1708 | 1708 | // Filter the data passed |
1709 | 1709 | $data = $this->_filter_data($this->tables['users'], $data); |
1710 | 1710 | |
1711 | - if (array_key_exists($this->identity_column, $data) || array_key_exists('password', $data) || array_key_exists('email', $data)) |
|
1711 | + if(array_key_exists($this->identity_column, $data) || array_key_exists('password', $data) || array_key_exists('email', $data)) |
|
1712 | 1712 | { |
1713 | - if (array_key_exists('password', $data)) |
|
1713 | + if(array_key_exists('password', $data)) |
|
1714 | 1714 | { |
1715 | - if( ! empty($data['password'])) |
|
1715 | + if(!empty($data['password'])) |
|
1716 | 1716 | { |
1717 | 1717 | $data['password'] = $this->hash_password($data['password'], $user->salt); |
1718 | 1718 | } |
@@ -1727,7 +1727,7 @@ discard block |
||
1727 | 1727 | $this->trigger_events('extra_where'); |
1728 | 1728 | $this->db->update($this->tables['users'], $data, array('id' => $user->id)); |
1729 | 1729 | |
1730 | - if ($this->db->trans_status() === FALSE) |
|
1730 | + if($this->db->trans_status() === FALSE) |
|
1731 | 1731 | { |
1732 | 1732 | $this->db->trans_rollback(); |
1733 | 1733 | |
@@ -1762,7 +1762,7 @@ discard block |
||
1762 | 1762 | $this->db->delete($this->tables['users'], array('id' => $id)); |
1763 | 1763 | |
1764 | 1764 | |
1765 | - if ($this->db->trans_status() === FALSE) |
|
1765 | + if($this->db->trans_status() === FALSE) |
|
1766 | 1766 | { |
1767 | 1767 | $this->db->trans_rollback(); |
1768 | 1768 | $this->trigger_events(array('post_delete_user', 'post_delete_user_unsuccessful')); |
@@ -1809,7 +1809,7 @@ discard block |
||
1809 | 1809 | // if the user_expire is set to zero we'll set the expiration two years from now. |
1810 | 1810 | if($this->config->item('user_expire', 'ion_auth') === 0) |
1811 | 1811 | { |
1812 | - $expire = (60*60*24*365*2); |
|
1812 | + $expire = (60 * 60 * 24 * 365 * 2); |
|
1813 | 1813 | } |
1814 | 1814 | // otherwise use what is set |
1815 | 1815 | else |
@@ -1863,7 +1863,7 @@ discard block |
||
1863 | 1863 | { |
1864 | 1864 | $this->trigger_events('pre_remember_user'); |
1865 | 1865 | |
1866 | - if (!$id) |
|
1866 | + if(!$id) |
|
1867 | 1867 | { |
1868 | 1868 | return FALSE; |
1869 | 1869 | } |
@@ -1874,12 +1874,12 @@ discard block |
||
1874 | 1874 | |
1875 | 1875 | $this->db->update($this->tables['users'], array('remember_code' => $salt), array('id' => $id)); |
1876 | 1876 | |
1877 | - if ($this->db->affected_rows() > -1) |
|
1877 | + if($this->db->affected_rows() > -1) |
|
1878 | 1878 | { |
1879 | 1879 | // if the user_expire is set to zero we'll set the expiration two years from now. |
1880 | 1880 | if($this->config->item('user_expire', 'ion_auth') === 0) |
1881 | 1881 | { |
1882 | - $expire = (60*60*24*365*2); |
|
1882 | + $expire = (60 * 60 * 24 * 365 * 2); |
|
1883 | 1883 | } |
1884 | 1884 | // otherwise use what is set |
1885 | 1885 | else |
@@ -1918,7 +1918,7 @@ discard block |
||
1918 | 1918 | $this->trigger_events('pre_login_remembered_user'); |
1919 | 1919 | |
1920 | 1920 | // check for valid data |
1921 | - if (!get_cookie($this->config->item('identity_cookie_name', 'ion_auth')) |
|
1921 | + if(!get_cookie($this->config->item('identity_cookie_name', 'ion_auth')) |
|
1922 | 1922 | || !get_cookie($this->config->item('remember_cookie_name', 'ion_auth')) |
1923 | 1923 | || !$this->identity_check(get_cookie($this->config->item('identity_cookie_name', 'ion_auth')))) |
1924 | 1924 | { |
@@ -1931,13 +1931,13 @@ discard block |
||
1931 | 1931 | $query = $this->db->select($this->identity_column.', id, email, last_login') |
1932 | 1932 | ->where($this->identity_column, urldecode(get_cookie($this->config->item('identity_cookie_name', 'ion_auth')))) |
1933 | 1933 | ->where('remember_code', get_cookie($this->config->item('remember_cookie_name', 'ion_auth'))) |
1934 | - ->where('active',1) |
|
1934 | + ->where('active', 1) |
|
1935 | 1935 | ->limit(1) |
1936 | 1936 | ->order_by('id', 'desc') |
1937 | 1937 | ->get($this->tables['users']); |
1938 | 1938 | |
1939 | 1939 | // if the user was found, sign them in |
1940 | - if ($query->num_rows() == 1) |
|
1940 | + if($query->num_rows() == 1) |
|
1941 | 1941 | { |
1942 | 1942 | $user = $query->row(); |
1943 | 1943 | |
@@ -1946,7 +1946,7 @@ discard block |
||
1946 | 1946 | $this->set_session($user); |
1947 | 1947 | |
1948 | 1948 | // extend the users cookies if the option is enabled |
1949 | - if ($this->config->item('user_extend_on_login', 'ion_auth')) |
|
1949 | + if($this->config->item('user_extend_on_login', 'ion_auth')) |
|
1950 | 1950 | { |
1951 | 1951 | $this->remember_user($user->id); |
1952 | 1952 | } |
@@ -1982,17 +1982,17 @@ discard block |
||
1982 | 1982 | return FALSE; |
1983 | 1983 | } |
1984 | 1984 | |
1985 | - $data = array('name'=>$group_name,'description'=>$group_description); |
|
1985 | + $data = array('name'=>$group_name, 'description'=>$group_description); |
|
1986 | 1986 | |
1987 | 1987 | // filter out any data passed that doesnt have a matching column in the groups table |
1988 | 1988 | // and merge the set group data and the additional data |
1989 | - if (!empty($additional_data)) $data = array_merge($this->_filter_data($this->tables['groups'], $additional_data), $data); |
|
1989 | + if(!empty($additional_data)) $data = array_merge($this->_filter_data($this->tables['groups'], $additional_data), $data); |
|
1990 | 1990 | |
1991 | 1991 | $this->trigger_events('extra_group_set'); |
1992 | 1992 | |
1993 | 1993 | // insert the new group |
1994 | 1994 | $this->db->insert($this->tables['groups'], $data); |
1995 | - $group_id = $this->db->insert_id($this->tables['groups'] . '_id_seq'); |
|
1995 | + $group_id = $this->db->insert_id($this->tables['groups'].'_id_seq'); |
|
1996 | 1996 | |
1997 | 1997 | // report success |
1998 | 1998 | $this->set_message('group_creation_successful'); |
@@ -2008,11 +2008,11 @@ discard block |
||
2008 | 2008 | **/ |
2009 | 2009 | public function update_group($group_id = FALSE, $group_name = FALSE, $additional_data = array()) |
2010 | 2010 | { |
2011 | - if (empty($group_id)) return FALSE; |
|
2011 | + if(empty($group_id)) return FALSE; |
|
2012 | 2012 | |
2013 | 2013 | $data = array(); |
2014 | 2014 | |
2015 | - if (!empty($group_name)) |
|
2015 | + if(!empty($group_name)) |
|
2016 | 2016 | { |
2017 | 2017 | // we are changing the name, so do some checks |
2018 | 2018 | |
@@ -2038,12 +2038,12 @@ discard block |
||
2038 | 2038 | |
2039 | 2039 | // IMPORTANT!! Third parameter was string type $description; this following code is to maintain backward compatibility |
2040 | 2040 | // New projects should work with 3rd param as array |
2041 | - if (is_string($additional_data)) $additional_data = array('description' => $additional_data); |
|
2041 | + if(is_string($additional_data)) $additional_data = array('description' => $additional_data); |
|
2042 | 2042 | |
2043 | 2043 | |
2044 | 2044 | // filter out any data passed that doesnt have a matching column in the groups table |
2045 | 2045 | // and merge the set group data and the additional data |
2046 | - if (!empty($additional_data)) $data = array_merge($this->_filter_data($this->tables['groups'], $additional_data), $data); |
|
2046 | + if(!empty($additional_data)) $data = array_merge($this->_filter_data($this->tables['groups'], $additional_data), $data); |
|
2047 | 2047 | |
2048 | 2048 | |
2049 | 2049 | $this->db->update($this->tables['groups'], $data, array('id' => $group_id)); |
@@ -2083,7 +2083,7 @@ discard block |
||
2083 | 2083 | // remove the group itself |
2084 | 2084 | $this->db->delete($this->tables['groups'], array('id' => $group_id)); |
2085 | 2085 | |
2086 | - if ($this->db->trans_status() === FALSE) |
|
2086 | + if($this->db->trans_status() === FALSE) |
|
2087 | 2087 | { |
2088 | 2088 | $this->db->trans_rollback(); |
2089 | 2089 | $this->trigger_events(array('post_delete_group', 'post_delete_group_unsuccessful')); |
@@ -2108,7 +2108,7 @@ discard block |
||
2108 | 2108 | |
2109 | 2109 | public function remove_hook($event, $name) |
2110 | 2110 | { |
2111 | - if (isset($this->_ion_hooks->{$event}[$name])) |
|
2111 | + if(isset($this->_ion_hooks->{$event}[$name])) |
|
2112 | 2112 | { |
2113 | 2113 | unset($this->_ion_hooks->{$event}[$name]); |
2114 | 2114 | } |
@@ -2116,7 +2116,7 @@ discard block |
||
2116 | 2116 | |
2117 | 2117 | public function remove_hooks($event) |
2118 | 2118 | { |
2119 | - if (isset($this->_ion_hooks->$event)) |
|
2119 | + if(isset($this->_ion_hooks->$event)) |
|
2120 | 2120 | { |
2121 | 2121 | unset($this->_ion_hooks->$event); |
2122 | 2122 | } |
@@ -2124,7 +2124,7 @@ discard block |
||
2124 | 2124 | |
2125 | 2125 | protected function _call_hook($event, $name) |
2126 | 2126 | { |
2127 | - if (isset($this->_ion_hooks->{$event}[$name]) && method_exists($this->_ion_hooks->{$event}[$name]->class, $this->_ion_hooks->{$event}[$name]->method)) |
|
2127 | + if(isset($this->_ion_hooks->{$event}[$name]) && method_exists($this->_ion_hooks->{$event}[$name]->class, $this->_ion_hooks->{$event}[$name]->method)) |
|
2128 | 2128 | { |
2129 | 2129 | $hook = $this->_ion_hooks->{$event}[$name]; |
2130 | 2130 | |
@@ -2136,18 +2136,18 @@ discard block |
||
2136 | 2136 | |
2137 | 2137 | public function trigger_events($events) |
2138 | 2138 | { |
2139 | - if (is_array($events) && !empty($events)) |
|
2139 | + if(is_array($events) && !empty($events)) |
|
2140 | 2140 | { |
2141 | - foreach ($events as $event) |
|
2141 | + foreach($events as $event) |
|
2142 | 2142 | { |
2143 | 2143 | $this->trigger_events($event); |
2144 | 2144 | } |
2145 | 2145 | } |
2146 | 2146 | else |
2147 | 2147 | { |
2148 | - if (isset($this->_ion_hooks->$events) && !empty($this->_ion_hooks->$events)) |
|
2148 | + if(isset($this->_ion_hooks->$events) && !empty($this->_ion_hooks->$events)) |
|
2149 | 2149 | { |
2150 | - foreach ($this->_ion_hooks->$events as $name => $hook) |
|
2150 | + foreach($this->_ion_hooks->$events as $name => $hook) |
|
2151 | 2151 | { |
2152 | 2152 | $this->_call_hook($events, $name); |
2153 | 2153 | } |
@@ -2215,10 +2215,10 @@ discard block |
||
2215 | 2215 | public function messages() |
2216 | 2216 | { |
2217 | 2217 | $_output = ''; |
2218 | - foreach ($this->messages as $message) |
|
2218 | + foreach($this->messages as $message) |
|
2219 | 2219 | { |
2220 | - $messageLang = $this->lang->line($message) ? $this->lang->line($message) : '##' . $message . '##'; |
|
2221 | - $_output .= $this->message_start_delimiter . $messageLang . $this->message_end_delimiter; |
|
2220 | + $messageLang = $this->lang->line($message) ? $this->lang->line($message) : '##'.$message.'##'; |
|
2221 | + $_output .= $this->message_start_delimiter.$messageLang.$this->message_end_delimiter; |
|
2222 | 2222 | } |
2223 | 2223 | |
2224 | 2224 | return $_output; |
@@ -2234,13 +2234,13 @@ discard block |
||
2234 | 2234 | **/ |
2235 | 2235 | public function messages_array($langify = TRUE) |
2236 | 2236 | { |
2237 | - if ($langify) |
|
2237 | + if($langify) |
|
2238 | 2238 | { |
2239 | 2239 | $_output = array(); |
2240 | - foreach ($this->messages as $message) |
|
2240 | + foreach($this->messages as $message) |
|
2241 | 2241 | { |
2242 | - $messageLang = $this->lang->line($message) ? $this->lang->line($message) : '##' . $message . '##'; |
|
2243 | - $_output[] = $this->message_start_delimiter . $messageLang . $this->message_end_delimiter; |
|
2242 | + $messageLang = $this->lang->line($message) ? $this->lang->line($message) : '##'.$message.'##'; |
|
2243 | + $_output[] = $this->message_start_delimiter.$messageLang.$this->message_end_delimiter; |
|
2244 | 2244 | } |
2245 | 2245 | return $_output; |
2246 | 2246 | } |
@@ -2293,10 +2293,10 @@ discard block |
||
2293 | 2293 | public function errors() |
2294 | 2294 | { |
2295 | 2295 | $_output = ''; |
2296 | - foreach ($this->errors as $error) |
|
2296 | + foreach($this->errors as $error) |
|
2297 | 2297 | { |
2298 | - $errorLang = $this->lang->line($error) ? $this->lang->line($error) : '##' . $error . '##'; |
|
2299 | - $_output .= $this->error_start_delimiter . $errorLang . $this->error_end_delimiter; |
|
2298 | + $errorLang = $this->lang->line($error) ? $this->lang->line($error) : '##'.$error.'##'; |
|
2299 | + $_output .= $this->error_start_delimiter.$errorLang.$this->error_end_delimiter; |
|
2300 | 2300 | } |
2301 | 2301 | |
2302 | 2302 | return $_output; |
@@ -2312,13 +2312,13 @@ discard block |
||
2312 | 2312 | **/ |
2313 | 2313 | public function errors_array($langify = TRUE) |
2314 | 2314 | { |
2315 | - if ($langify) |
|
2315 | + if($langify) |
|
2316 | 2316 | { |
2317 | 2317 | $_output = array(); |
2318 | - foreach ($this->errors as $error) |
|
2318 | + foreach($this->errors as $error) |
|
2319 | 2319 | { |
2320 | - $errorLang = $this->lang->line($error) ? $this->lang->line($error) : '##' . $error . '##'; |
|
2321 | - $_output[] = $this->error_start_delimiter . $errorLang . $this->error_end_delimiter; |
|
2320 | + $errorLang = $this->lang->line($error) ? $this->lang->line($error) : '##'.$error.'##'; |
|
2321 | + $_output[] = $this->error_start_delimiter.$errorLang.$this->error_end_delimiter; |
|
2322 | 2322 | } |
2323 | 2323 | return $_output; |
2324 | 2324 | } |
@@ -2351,11 +2351,11 @@ discard block |
||
2351 | 2351 | $filtered_data = array(); |
2352 | 2352 | $columns = $this->db->list_fields($table); |
2353 | 2353 | |
2354 | - if (is_array($data)) |
|
2354 | + if(is_array($data)) |
|
2355 | 2355 | { |
2356 | - foreach ($columns as $column) |
|
2356 | + foreach($columns as $column) |
|
2357 | 2357 | { |
2358 | - if (array_key_exists($column, $data)) |
|
2358 | + if(array_key_exists($column, $data)) |
|
2359 | 2359 | $filtered_data[$column] = $data[$column]; |
2360 | 2360 | } |
2361 | 2361 | } |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('BASEPATH')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Name: Ion Auth Model |
4 | 6 | * |
@@ -19,8 +21,7 @@ discard block |
||
19 | 21 | * |
20 | 22 | */ |
21 | 23 | |
22 | -class Ion_auth_model extends CI_Model |
|
23 | -{ |
|
24 | +class Ion_auth_model extends CI_Model { |
|
24 | 25 | /** |
25 | 26 | * Holds an array of tables used |
26 | 27 | * |
@@ -161,8 +162,7 @@ discard block |
||
161 | 162 | **/ |
162 | 163 | protected $_cache_groups = array(); |
163 | 164 | |
164 | - public function __construct() |
|
165 | - { |
|
165 | + public function __construct() { |
|
166 | 166 | parent::__construct(); |
167 | 167 | $this->load->database(); |
168 | 168 | $this->config->load('ion_auth', TRUE); |
@@ -194,8 +194,7 @@ discard block |
||
194 | 194 | $delimiters_source = $this->config->item('delimiters_source', 'ion_auth'); |
195 | 195 | |
196 | 196 | // load the error delimeters either from the config file or use what's been supplied to form validation |
197 | - if ($delimiters_source === 'form_validation') |
|
198 | - { |
|
197 | + if ($delimiters_source === 'form_validation') { |
|
199 | 198 | // load in delimiters from form_validation |
200 | 199 | // to keep this simple we'll load the value using reflection since these properties are protected |
201 | 200 | $this->load->library('form_validation'); |
@@ -210,9 +209,7 @@ discard block |
||
210 | 209 | $error_suffix->setAccessible(TRUE); |
211 | 210 | $this->error_end_delimiter = $error_suffix->getValue($this->form_validation); |
212 | 211 | $this->message_end_delimiter = $this->error_end_delimiter; |
213 | - } |
|
214 | - else |
|
215 | - { |
|
212 | + } else { |
|
216 | 213 | // use delimiters from config |
217 | 214 | $this->message_start_delimiter = $this->config->item('message_start_delimiter', 'ion_auth'); |
218 | 215 | $this->message_end_delimiter = $this->config->item('message_end_delimiter', 'ion_auth'); |
@@ -226,13 +223,10 @@ discard block |
||
226 | 223 | |
227 | 224 | // load the bcrypt class if needed |
228 | 225 | if ($this->hash_method == 'bcrypt') { |
229 | - if ($this->random_rounds) |
|
230 | - { |
|
226 | + if ($this->random_rounds) { |
|
231 | 227 | $rand = rand($this->min_rounds,$this->max_rounds); |
232 | 228 | $params = array('rounds' => $rand); |
233 | - } |
|
234 | - else |
|
235 | - { |
|
229 | + } else { |
|
236 | 230 | $params = array('rounds' => $this->default_rounds); |
237 | 231 | } |
238 | 232 | |
@@ -260,26 +254,20 @@ discard block |
||
260 | 254 | * @return void |
261 | 255 | * @author Mathew |
262 | 256 | **/ |
263 | - public function hash_password($password, $salt=false, $use_sha1_override=FALSE) |
|
264 | - { |
|
265 | - if (empty($password)) |
|
266 | - { |
|
257 | + public function hash_password($password, $salt=false, $use_sha1_override=FALSE) { |
|
258 | + if (empty($password)) { |
|
267 | 259 | return FALSE; |
268 | 260 | } |
269 | 261 | |
270 | 262 | // bcrypt |
271 | - if ($use_sha1_override === FALSE && $this->hash_method == 'bcrypt') |
|
272 | - { |
|
263 | + if ($use_sha1_override === FALSE && $this->hash_method == 'bcrypt') { |
|
273 | 264 | return $this->bcrypt->hash($password); |
274 | 265 | } |
275 | 266 | |
276 | 267 | |
277 | - if ($this->store_salt && $salt) |
|
278 | - { |
|
268 | + if ($this->store_salt && $salt) { |
|
279 | 269 | return sha1($password . $salt); |
280 | - } |
|
281 | - else |
|
282 | - { |
|
270 | + } else { |
|
283 | 271 | $salt = $this->salt(); |
284 | 272 | return $salt . substr(sha1($salt . $password), 0, -$this->salt_length); |
285 | 273 | } |
@@ -292,10 +280,8 @@ discard block |
||
292 | 280 | * @return void |
293 | 281 | * @author Mathew |
294 | 282 | **/ |
295 | - public function hash_password_db($id, $password, $use_sha1_override=FALSE) |
|
296 | - { |
|
297 | - if (empty($id) || empty($password)) |
|
298 | - { |
|
283 | + public function hash_password_db($id, $password, $use_sha1_override=FALSE) { |
|
284 | + if (empty($id) || empty($password)) { |
|
299 | 285 | return FALSE; |
300 | 286 | } |
301 | 287 | |
@@ -309,16 +295,13 @@ discard block |
||
309 | 295 | |
310 | 296 | $hash_password_db = $query->row(); |
311 | 297 | |
312 | - if ($query->num_rows() !== 1) |
|
313 | - { |
|
298 | + if ($query->num_rows() !== 1) { |
|
314 | 299 | return FALSE; |
315 | 300 | } |
316 | 301 | |
317 | 302 | // bcrypt |
318 | - if ($use_sha1_override === FALSE && $this->hash_method == 'bcrypt') |
|
319 | - { |
|
320 | - if ($this->bcrypt->verify($password,$hash_password_db->password)) |
|
321 | - { |
|
303 | + if ($use_sha1_override === FALSE && $this->hash_method == 'bcrypt') { |
|
304 | + if ($this->bcrypt->verify($password,$hash_password_db->password)) { |
|
322 | 305 | return TRUE; |
323 | 306 | } |
324 | 307 | |
@@ -326,23 +309,17 @@ discard block |
||
326 | 309 | } |
327 | 310 | |
328 | 311 | // sha1 |
329 | - if ($this->store_salt) |
|
330 | - { |
|
312 | + if ($this->store_salt) { |
|
331 | 313 | $db_password = sha1($password . $hash_password_db->salt); |
332 | - } |
|
333 | - else |
|
334 | - { |
|
314 | + } else { |
|
335 | 315 | $salt = substr($hash_password_db->password, 0, $this->salt_length); |
336 | 316 | |
337 | 317 | $db_password = $salt . substr(sha1($salt . $password), 0, -$this->salt_length); |
338 | 318 | } |
339 | 319 | |
340 | - if($db_password == $hash_password_db->password) |
|
341 | - { |
|
320 | + if($db_password == $hash_password_db->password) { |
|
342 | 321 | return TRUE; |
343 | - } |
|
344 | - else |
|
345 | - { |
|
322 | + } else { |
|
346 | 323 | return FALSE; |
347 | 324 | } |
348 | 325 | } |
@@ -353,8 +330,7 @@ discard block |
||
353 | 330 | * @return void |
354 | 331 | * @author Mathew |
355 | 332 | **/ |
356 | - public function hash_code($password) |
|
357 | - { |
|
333 | + public function hash_code($password) { |
|
358 | 334 | return $this->hash_password($password, FALSE, TRUE); |
359 | 335 | } |
360 | 336 | |
@@ -366,8 +342,7 @@ discard block |
||
366 | 342 | * @return void |
367 | 343 | * @author Anthony Ferrera |
368 | 344 | **/ |
369 | - public function salt() |
|
370 | - { |
|
345 | + public function salt() { |
|
371 | 346 | |
372 | 347 | $raw_salt_len = 16; |
373 | 348 | |
@@ -449,12 +424,10 @@ discard block |
||
449 | 424 | * @return void |
450 | 425 | * @author Mathew |
451 | 426 | **/ |
452 | - public function activate($id, $code = false) |
|
453 | - { |
|
427 | + public function activate($id, $code = false) { |
|
454 | 428 | $this->trigger_events('pre_activate'); |
455 | 429 | |
456 | - if ($code !== FALSE) |
|
457 | - { |
|
430 | + if ($code !== FALSE) { |
|
458 | 431 | $query = $this->db->select($this->identity_column) |
459 | 432 | ->where('activation_code', $code) |
460 | 433 | ->where('id', $id) |
@@ -464,8 +437,7 @@ discard block |
||
464 | 437 | |
465 | 438 | $result = $query->row(); |
466 | 439 | |
467 | - if ($query->num_rows() !== 1) |
|
468 | - { |
|
440 | + if ($query->num_rows() !== 1) { |
|
469 | 441 | $this->trigger_events(array('post_activate', 'post_activate_unsuccessful')); |
470 | 442 | $this->set_error('activate_unsuccessful'); |
471 | 443 | return FALSE; |
@@ -478,9 +450,7 @@ discard block |
||
478 | 450 | |
479 | 451 | $this->trigger_events('extra_where'); |
480 | 452 | $this->db->update($this->tables['users'], $data, array('id' => $id)); |
481 | - } |
|
482 | - else |
|
483 | - { |
|
453 | + } else { |
|
484 | 454 | $data = array( |
485 | 455 | 'activation_code' => NULL, |
486 | 456 | 'active' => 1 |
@@ -493,13 +463,10 @@ discard block |
||
493 | 463 | |
494 | 464 | |
495 | 465 | $return = $this->db->affected_rows() == 1; |
496 | - if ($return) |
|
497 | - { |
|
466 | + if ($return) { |
|
498 | 467 | $this->trigger_events(array('post_activate', 'post_activate_successful')); |
499 | 468 | $this->set_message('activate_successful'); |
500 | - } |
|
501 | - else |
|
502 | - { |
|
469 | + } else { |
|
503 | 470 | $this->trigger_events(array('post_activate', 'post_activate_unsuccessful')); |
504 | 471 | $this->set_error('activate_unsuccessful'); |
505 | 472 | } |
@@ -515,17 +482,13 @@ discard block |
||
515 | 482 | * @return void |
516 | 483 | * @author Mathew |
517 | 484 | **/ |
518 | - public function deactivate($id = NULL) |
|
519 | - { |
|
485 | + public function deactivate($id = NULL) { |
|
520 | 486 | $this->trigger_events('deactivate'); |
521 | 487 | |
522 | - if (!isset($id)) |
|
523 | - { |
|
488 | + if (!isset($id)) { |
|
524 | 489 | $this->set_error('deactivate_unsuccessful'); |
525 | 490 | return FALSE; |
526 | - } |
|
527 | - elseif($this->ion_auth->logged_in() && $this->user()->row()->id == $id) |
|
528 | - { |
|
491 | + } elseif($this->ion_auth->logged_in() && $this->user()->row()->id == $id) { |
|
529 | 492 | $this->set_error('deactivate_current_user_unsuccessful'); |
530 | 493 | return FALSE; |
531 | 494 | } |
@@ -542,25 +505,24 @@ discard block |
||
542 | 505 | $this->db->update($this->tables['users'], $data, array('id' => $id)); |
543 | 506 | |
544 | 507 | $return = $this->db->affected_rows() == 1; |
545 | - if ($return) |
|
546 | - $this->set_message('deactivate_successful'); |
|
547 | - else |
|
548 | - $this->set_error('deactivate_unsuccessful'); |
|
508 | + if ($return) { |
|
509 | + $this->set_message('deactivate_successful'); |
|
510 | + } else { |
|
511 | + $this->set_error('deactivate_unsuccessful'); |
|
512 | + } |
|
549 | 513 | |
550 | 514 | return $return; |
551 | 515 | } |
552 | 516 | |
553 | 517 | public function clear_forgotten_password_code($code) { |
554 | 518 | |
555 | - if (empty($code)) |
|
556 | - { |
|
519 | + if (empty($code)) { |
|
557 | 520 | return FALSE; |
558 | 521 | } |
559 | 522 | |
560 | 523 | $this->db->where('forgotten_password_code', $code); |
561 | 524 | |
562 | - if ($this->db->count_all_results($this->tables['users']) > 0) |
|
563 | - { |
|
525 | + if ($this->db->count_all_results($this->tables['users']) > 0) { |
|
564 | 526 | $data = array( |
565 | 527 | 'forgotten_password_code' => NULL, |
566 | 528 | 'forgotten_password_time' => NULL |
@@ -596,8 +558,7 @@ discard block |
||
596 | 558 | ->order_by('id', 'desc') |
597 | 559 | ->get($this->tables['users']); |
598 | 560 | |
599 | - if ($query->num_rows() !== 1) |
|
600 | - { |
|
561 | + if ($query->num_rows() !== 1) { |
|
601 | 562 | $this->trigger_events(array('post_change_password', 'post_change_password_unsuccessful')); |
602 | 563 | $this->set_error('password_change_unsuccessful'); |
603 | 564 | return FALSE; |
@@ -620,13 +581,10 @@ discard block |
||
620 | 581 | $this->db->update($this->tables['users'], $data, array($this->identity_column => $identity)); |
621 | 582 | |
622 | 583 | $return = $this->db->affected_rows() == 1; |
623 | - if ($return) |
|
624 | - { |
|
584 | + if ($return) { |
|
625 | 585 | $this->trigger_events(array('post_change_password', 'post_change_password_successful')); |
626 | 586 | $this->set_message('password_change_successful'); |
627 | - } |
|
628 | - else |
|
629 | - { |
|
587 | + } else { |
|
630 | 588 | $this->trigger_events(array('post_change_password', 'post_change_password_unsuccessful')); |
631 | 589 | $this->set_error('password_change_unsuccessful'); |
632 | 590 | } |
@@ -640,8 +598,7 @@ discard block |
||
640 | 598 | * @return bool |
641 | 599 | * @author Mathew |
642 | 600 | **/ |
643 | - public function change_password($identity, $old, $new) |
|
644 | - { |
|
601 | + public function change_password($identity, $old, $new) { |
|
645 | 602 | $this->trigger_events('pre_change_password'); |
646 | 603 | |
647 | 604 | $this->trigger_events('extra_where'); |
@@ -652,8 +609,7 @@ discard block |
||
652 | 609 | ->order_by('id', 'desc') |
653 | 610 | ->get($this->tables['users']); |
654 | 611 | |
655 | - if ($query->num_rows() !== 1) |
|
656 | - { |
|
612 | + if ($query->num_rows() !== 1) { |
|
657 | 613 | $this->trigger_events(array('post_change_password', 'post_change_password_unsuccessful')); |
658 | 614 | $this->set_error('password_change_unsuccessful'); |
659 | 615 | return FALSE; |
@@ -663,8 +619,7 @@ discard block |
||
663 | 619 | |
664 | 620 | $old_password_matches = $this->hash_password_db($user->id, $old); |
665 | 621 | |
666 | - if ($old_password_matches === TRUE) |
|
667 | - { |
|
622 | + if ($old_password_matches === TRUE) { |
|
668 | 623 | // store the new password and reset the remember code so all remembered instances have to re-login |
669 | 624 | $hashed_new_password = $this->hash_password($new, $user->salt); |
670 | 625 | $data = array( |
@@ -675,13 +630,10 @@ discard block |
||
675 | 630 | $this->trigger_events('extra_where'); |
676 | 631 | |
677 | 632 | $successfully_changed_password_in_db = $this->db->update($this->tables['users'], $data, array($this->identity_column => $identity)); |
678 | - if ($successfully_changed_password_in_db) |
|
679 | - { |
|
633 | + if ($successfully_changed_password_in_db) { |
|
680 | 634 | $this->trigger_events(array('post_change_password', 'post_change_password_successful')); |
681 | 635 | $this->set_message('password_change_successful'); |
682 | - } |
|
683 | - else |
|
684 | - { |
|
636 | + } else { |
|
685 | 637 | $this->trigger_events(array('post_change_password', 'post_change_password_unsuccessful')); |
686 | 638 | $this->set_error('password_change_unsuccessful'); |
687 | 639 | } |
@@ -699,12 +651,10 @@ discard block |
||
699 | 651 | * @return bool |
700 | 652 | * @author Mathew |
701 | 653 | **/ |
702 | - public function username_check($username = '') |
|
703 | - { |
|
654 | + public function username_check($username = '') { |
|
704 | 655 | $this->trigger_events('username_check'); |
705 | 656 | |
706 | - if (empty($username)) |
|
707 | - { |
|
657 | + if (empty($username)) { |
|
708 | 658 | return FALSE; |
709 | 659 | } |
710 | 660 | |
@@ -723,12 +673,10 @@ discard block |
||
723 | 673 | * @return bool |
724 | 674 | * @author Mathew |
725 | 675 | **/ |
726 | - public function email_check($email = '') |
|
727 | - { |
|
676 | + public function email_check($email = '') { |
|
728 | 677 | $this->trigger_events('email_check'); |
729 | 678 | |
730 | - if (empty($email)) |
|
731 | - { |
|
679 | + if (empty($email)) { |
|
732 | 680 | return FALSE; |
733 | 681 | } |
734 | 682 | |
@@ -747,12 +695,10 @@ discard block |
||
747 | 695 | * @return bool |
748 | 696 | * @author Mathew |
749 | 697 | **/ |
750 | - public function identity_check($identity = '') |
|
751 | - { |
|
698 | + public function identity_check($identity = '') { |
|
752 | 699 | $this->trigger_events('identity_check'); |
753 | 700 | |
754 | - if (empty($identity)) |
|
755 | - { |
|
701 | + if (empty($identity)) { |
|
756 | 702 | return FALSE; |
757 | 703 | } |
758 | 704 | |
@@ -768,10 +714,8 @@ discard block |
||
768 | 714 | * @updated Ryan |
769 | 715 | * @updated 52aa456eef8b60ad6754b31fbdcc77bb |
770 | 716 | **/ |
771 | - public function forgotten_password($identity) |
|
772 | - { |
|
773 | - if (empty($identity)) |
|
774 | - { |
|
717 | + public function forgotten_password($identity) { |
|
718 | + if (empty($identity)) { |
|
775 | 719 | $this->trigger_events(array('post_forgotten_password', 'post_forgotten_password_unsuccessful')); |
776 | 720 | return FALSE; |
777 | 721 | } |
@@ -789,12 +733,10 @@ discard block |
||
789 | 733 | $key = $this->hash_code($activation_code_part.$identity); |
790 | 734 | |
791 | 735 | // If enable query strings is set, then we need to replace any unsafe characters so that the code can still work |
792 | - if ($key != '' && $this->config->item('permitted_uri_chars') != '' && $this->config->item('enable_query_strings') == FALSE) |
|
793 | - { |
|
736 | + if ($key != '' && $this->config->item('permitted_uri_chars') != '' && $this->config->item('enable_query_strings') == FALSE) { |
|
794 | 737 | // preg_quote() in PHP 5.3 escapes -, so the str_replace() and addition of - to preg_quote() is to maintain backwards |
795 | 738 | // compatibility as many are unaware of how characters in the permitted_uri_chars will be parsed as a regex pattern |
796 | - if ( ! preg_match("|^[".str_replace(array('\\-', '\-'), '-', preg_quote($this->config->item('permitted_uri_chars'), '-'))."]+$|i", $key)) |
|
797 | - { |
|
739 | + if ( ! preg_match("|^[".str_replace(array('\\-', '\-'), '-', preg_quote($this->config->item('permitted_uri_chars'), '-'))."]+$|i", $key)) { |
|
798 | 740 | $key = preg_replace("/[^".$this->config->item('permitted_uri_chars')."]+/i", "-", $key); |
799 | 741 | } |
800 | 742 | } |
@@ -813,10 +755,11 @@ discard block |
||
813 | 755 | |
814 | 756 | $return = $this->db->affected_rows() == 1; |
815 | 757 | |
816 | - if ($return) |
|
817 | - $this->trigger_events(array('post_forgotten_password', 'post_forgotten_password_successful')); |
|
818 | - else |
|
819 | - $this->trigger_events(array('post_forgotten_password', 'post_forgotten_password_unsuccessful')); |
|
758 | + if ($return) { |
|
759 | + $this->trigger_events(array('post_forgotten_password', 'post_forgotten_password_successful')); |
|
760 | + } else { |
|
761 | + $this->trigger_events(array('post_forgotten_password', 'post_forgotten_password_unsuccessful')); |
|
762 | + } |
|
820 | 763 | |
821 | 764 | return $return; |
822 | 765 | } |
@@ -827,12 +770,10 @@ discard block |
||
827 | 770 | * @return string |
828 | 771 | * @author Mathew |
829 | 772 | **/ |
830 | - public function forgotten_password_complete($code, $salt=FALSE) |
|
831 | - { |
|
773 | + public function forgotten_password_complete($code, $salt=FALSE) { |
|
832 | 774 | $this->trigger_events('pre_forgotten_password_complete'); |
833 | 775 | |
834 | - if (empty($code)) |
|
835 | - { |
|
776 | + if (empty($code)) { |
|
836 | 777 | $this->trigger_events(array('post_forgotten_password_complete', 'post_forgotten_password_complete_unsuccessful')); |
837 | 778 | return FALSE; |
838 | 779 | } |
@@ -876,27 +817,22 @@ discard block |
||
876 | 817 | * @return bool |
877 | 818 | * @author Mathew |
878 | 819 | **/ |
879 | - public function register($identity, $password, $email, $additional_data = array(), $groups = array()) |
|
880 | - { |
|
820 | + public function register($identity, $password, $email, $additional_data = array(), $groups = array()) { |
|
881 | 821 | $this->trigger_events('pre_register'); |
882 | 822 | |
883 | 823 | $manual_activation = $this->config->item('manual_activation', 'ion_auth'); |
884 | 824 | |
885 | - if ($this->identity_check($identity)) |
|
886 | - { |
|
825 | + if ($this->identity_check($identity)) { |
|
887 | 826 | $this->set_error('account_creation_duplicate_identity'); |
888 | 827 | return FALSE; |
889 | - } |
|
890 | - elseif ( !$this->config->item('default_group', 'ion_auth') && empty($groups) ) |
|
891 | - { |
|
828 | + } elseif ( !$this->config->item('default_group', 'ion_auth') && empty($groups) ) { |
|
892 | 829 | $this->set_error('account_creation_missing_default_group'); |
893 | 830 | return FALSE; |
894 | 831 | } |
895 | 832 | |
896 | 833 | // check if the default set in config exists in database |
897 | 834 | $query = $this->db->get_where($this->tables['groups'],array('name' => $this->config->item('default_group', 'ion_auth')),1)->row(); |
898 | - if( !isset($query->id) && empty($groups) ) |
|
899 | - { |
|
835 | + if( !isset($query->id) && empty($groups) ) { |
|
900 | 836 | $this->set_error('account_creation_invalid_default_group'); |
901 | 837 | return FALSE; |
902 | 838 | } |
@@ -920,8 +856,7 @@ discard block |
||
920 | 856 | 'active' => ($manual_activation === false ? 1 : 0) |
921 | 857 | ); |
922 | 858 | |
923 | - if ($this->store_salt) |
|
924 | - { |
|
859 | + if ($this->store_salt) { |
|
925 | 860 | $data['salt'] = $salt; |
926 | 861 | } |
927 | 862 | |
@@ -936,16 +871,13 @@ discard block |
||
936 | 871 | $id = $this->db->insert_id($this->tables['users'] . '_id_seq'); |
937 | 872 | |
938 | 873 | // add in groups array if it doesn't exists and stop adding into default group if default group ids are set |
939 | - if( isset($default_group->id) && empty($groups) ) |
|
940 | - { |
|
874 | + if( isset($default_group->id) && empty($groups) ) { |
|
941 | 875 | $groups[] = $default_group->id; |
942 | 876 | } |
943 | 877 | |
944 | - if (!empty($groups)) |
|
945 | - { |
|
878 | + if (!empty($groups)) { |
|
946 | 879 | // add to groups |
947 | - foreach ($groups as $group) |
|
948 | - { |
|
880 | + foreach ($groups as $group) { |
|
949 | 881 | $this->add_to_group($group, $id); |
950 | 882 | } |
951 | 883 | } |
@@ -961,12 +893,10 @@ discard block |
||
961 | 893 | * @return bool |
962 | 894 | * @author Mathew |
963 | 895 | **/ |
964 | - public function login($identity, $password, $remember=FALSE) |
|
965 | - { |
|
896 | + public function login($identity, $password, $remember=FALSE) { |
|
966 | 897 | $this->trigger_events('pre_login'); |
967 | 898 | |
968 | - if (empty($identity) || empty($password)) |
|
969 | - { |
|
899 | + if (empty($identity) || empty($password)) { |
|
970 | 900 | $this->set_error('login_unsuccessful'); |
971 | 901 | return FALSE; |
972 | 902 | } |
@@ -979,8 +909,7 @@ discard block |
||
979 | 909 | ->order_by('id', 'desc') |
980 | 910 | ->get($this->tables['users']); |
981 | 911 | |
982 | - if($this->is_max_login_attempts_exceeded($identity)) |
|
983 | - { |
|
912 | + if($this->is_max_login_attempts_exceeded($identity)) { |
|
984 | 913 | // Hash something anyway, just to take up time |
985 | 914 | $this->hash_password($password); |
986 | 915 | |
@@ -990,16 +919,13 @@ discard block |
||
990 | 919 | return FALSE; |
991 | 920 | } |
992 | 921 | |
993 | - if ($query->num_rows() === 1) |
|
994 | - { |
|
922 | + if ($query->num_rows() === 1) { |
|
995 | 923 | $user = $query->row(); |
996 | 924 | |
997 | 925 | $password = $this->hash_password_db($user->id, $password); |
998 | 926 | |
999 | - if ($password === TRUE) |
|
1000 | - { |
|
1001 | - if ($user->active == 0) |
|
1002 | - { |
|
927 | + if ($password === TRUE) { |
|
928 | + if ($user->active == 0) { |
|
1003 | 929 | $this->trigger_events('post_login_unsuccessful'); |
1004 | 930 | $this->set_error('login_unsuccessful_not_active'); |
1005 | 931 | |
@@ -1012,8 +938,7 @@ discard block |
||
1012 | 938 | |
1013 | 939 | $this->clear_login_attempts($identity); |
1014 | 940 | |
1015 | - if ($remember && $this->config->item('remember_users', 'ion_auth')) |
|
1016 | - { |
|
941 | + if ($remember && $this->config->item('remember_users', 'ion_auth')) { |
|
1017 | 942 | $this->remember_user($user->id); |
1018 | 943 | } |
1019 | 944 | |
@@ -1040,36 +965,27 @@ discard block |
||
1040 | 965 | * the configuration item recheck_timer. If it does, then it will check if the user is still active |
1041 | 966 | * @return bool |
1042 | 967 | */ |
1043 | - public function recheck_session() |
|
1044 | - { |
|
968 | + public function recheck_session() { |
|
1045 | 969 | $recheck = (null !== $this->config->item('recheck_timer', 'ion_auth')) ? $this->config->item('recheck_timer', 'ion_auth') : 0; |
1046 | 970 | |
1047 | - if($recheck!==0) |
|
1048 | - { |
|
971 | + if($recheck!==0) { |
|
1049 | 972 | $last_login = $this->session->userdata('last_check'); |
1050 | - if($last_login+$recheck < time()) |
|
1051 | - { |
|
973 | + if($last_login+$recheck < time()) { |
|
1052 | 974 | $query = $this->db->select('id') |
1053 | 975 | ->where(array($this->identity_column=>$this->session->userdata('identity'),'active'=>'1')) |
1054 | 976 | ->limit(1) |
1055 | 977 | ->order_by('id', 'desc') |
1056 | 978 | ->get($this->tables['users']); |
1057 | - if ($query->num_rows() === 1) |
|
1058 | - { |
|
979 | + if ($query->num_rows() === 1) { |
|
1059 | 980 | $this->session->set_userdata('last_check',time()); |
1060 | - } |
|
1061 | - else |
|
1062 | - { |
|
981 | + } else { |
|
1063 | 982 | $this->trigger_events('logout'); |
1064 | 983 | |
1065 | 984 | $identity = $this->config->item('identity', 'ion_auth'); |
1066 | 985 | |
1067 | - if (substr(CI_VERSION, 0, 1) == '2') |
|
1068 | - { |
|
986 | + if (substr(CI_VERSION, 0, 1) == '2') { |
|
1069 | 987 | $this->session->unset_userdata( array($identity => '', 'id' => '', 'user_id' => '') ); |
1070 | - } |
|
1071 | - else |
|
1072 | - { |
|
988 | + } else { |
|
1073 | 989 | $this->session->unset_userdata( array($identity, 'id', 'user_id') ); |
1074 | 990 | } |
1075 | 991 | return false; |
@@ -1113,8 +1029,7 @@ discard block |
||
1113 | 1029 | * Use get_last_attempt_ip($identity) to retrieve user's last IP |
1114 | 1030 | * @return int |
1115 | 1031 | */ |
1116 | - public function get_attempts_num($identity, $ip_address = NULL) |
|
1117 | - { |
|
1032 | + public function get_attempts_num($identity, $ip_address = NULL) { |
|
1118 | 1033 | if ($this->config->item('track_login_attempts', 'ion_auth')) { |
1119 | 1034 | $this->db->select('1', FALSE); |
1120 | 1035 | $this->db->where('login', $identity); |
@@ -1257,28 +1172,24 @@ discard block |
||
1257 | 1172 | return FALSE; |
1258 | 1173 | } |
1259 | 1174 | |
1260 | - public function limit($limit) |
|
1261 | - { |
|
1175 | + public function limit($limit) { |
|
1262 | 1176 | $this->trigger_events('limit'); |
1263 | 1177 | $this->_ion_limit = $limit; |
1264 | 1178 | |
1265 | 1179 | return $this; |
1266 | 1180 | } |
1267 | 1181 | |
1268 | - public function offset($offset) |
|
1269 | - { |
|
1182 | + public function offset($offset) { |
|
1270 | 1183 | $this->trigger_events('offset'); |
1271 | 1184 | $this->_ion_offset = $offset; |
1272 | 1185 | |
1273 | 1186 | return $this; |
1274 | 1187 | } |
1275 | 1188 | |
1276 | - public function where($where, $value = NULL) |
|
1277 | - { |
|
1189 | + public function where($where, $value = NULL) { |
|
1278 | 1190 | $this->trigger_events('where'); |
1279 | 1191 | |
1280 | - if (!is_array($where)) |
|
1281 | - { |
|
1192 | + if (!is_array($where)) { |
|
1282 | 1193 | $where = array($where => $value); |
1283 | 1194 | } |
1284 | 1195 | |
@@ -1287,8 +1198,7 @@ discard block |
||
1287 | 1198 | return $this; |
1288 | 1199 | } |
1289 | 1200 | |
1290 | - public function like($like, $value = NULL, $position = 'both') |
|
1291 | - { |
|
1201 | + public function like($like, $value = NULL, $position = 'both') { |
|
1292 | 1202 | $this->trigger_events('like'); |
1293 | 1203 | |
1294 | 1204 | array_push($this->_ion_like, array( |
@@ -1300,8 +1210,7 @@ discard block |
||
1300 | 1210 | return $this; |
1301 | 1211 | } |
1302 | 1212 | |
1303 | - public function select($select) |
|
1304 | - { |
|
1213 | + public function select($select) { |
|
1305 | 1214 | $this->trigger_events('select'); |
1306 | 1215 | |
1307 | 1216 | $this->_ion_select[] = $select; |
@@ -1309,8 +1218,7 @@ discard block |
||
1309 | 1218 | return $this; |
1310 | 1219 | } |
1311 | 1220 | |
1312 | - public function order_by($by, $order='desc') |
|
1313 | - { |
|
1221 | + public function order_by($by, $order='desc') { |
|
1314 | 1222 | $this->trigger_events('order_by'); |
1315 | 1223 | |
1316 | 1224 | $this->_ion_order_by = $by; |
@@ -1319,8 +1227,7 @@ discard block |
||
1319 | 1227 | return $this; |
1320 | 1228 | } |
1321 | 1229 | |
1322 | - public function row() |
|
1323 | - { |
|
1230 | + public function row() { |
|
1324 | 1231 | $this->trigger_events('row'); |
1325 | 1232 | |
1326 | 1233 | $row = $this->response->row(); |
@@ -1328,8 +1235,7 @@ discard block |
||
1328 | 1235 | return $row; |
1329 | 1236 | } |
1330 | 1237 | |
1331 | - public function row_array() |
|
1332 | - { |
|
1238 | + public function row_array() { |
|
1333 | 1239 | $this->trigger_events(array('row', 'row_array')); |
1334 | 1240 | |
1335 | 1241 | $row = $this->response->row_array(); |
@@ -1337,8 +1243,7 @@ discard block |
||
1337 | 1243 | return $row; |
1338 | 1244 | } |
1339 | 1245 | |
1340 | - public function result() |
|
1341 | - { |
|
1246 | + public function result() { |
|
1342 | 1247 | $this->trigger_events('result'); |
1343 | 1248 | |
1344 | 1249 | $result = $this->response->result(); |
@@ -1346,8 +1251,7 @@ discard block |
||
1346 | 1251 | return $result; |
1347 | 1252 | } |
1348 | 1253 | |
1349 | - public function result_array() |
|
1350 | - { |
|
1254 | + public function result_array() { |
|
1351 | 1255 | $this->trigger_events(array('result', 'result_array')); |
1352 | 1256 | |
1353 | 1257 | $result = $this->response->result_array(); |
@@ -1355,8 +1259,7 @@ discard block |
||
1355 | 1259 | return $result; |
1356 | 1260 | } |
1357 | 1261 | |
1358 | - public function num_rows() |
|
1359 | - { |
|
1262 | + public function num_rows() { |
|
1360 | 1263 | $this->trigger_events(array('num_rows')); |
1361 | 1264 | |
1362 | 1265 | $result = $this->response->num_rows(); |
@@ -1370,21 +1273,16 @@ discard block |
||
1370 | 1273 | * @return object Users |
1371 | 1274 | * @author Ben Edmunds |
1372 | 1275 | **/ |
1373 | - public function users($groups = NULL) |
|
1374 | - { |
|
1276 | + public function users($groups = NULL) { |
|
1375 | 1277 | $this->trigger_events('users'); |
1376 | 1278 | |
1377 | - if (isset($this->_ion_select) && !empty($this->_ion_select)) |
|
1378 | - { |
|
1379 | - foreach ($this->_ion_select as $select) |
|
1380 | - { |
|
1279 | + if (isset($this->_ion_select) && !empty($this->_ion_select)) { |
|
1280 | + foreach ($this->_ion_select as $select) { |
|
1381 | 1281 | $this->db->select($select); |
1382 | 1282 | } |
1383 | 1283 | |
1384 | 1284 | $this->_ion_select = array(); |
1385 | - } |
|
1386 | - else |
|
1387 | - { |
|
1285 | + } else { |
|
1388 | 1286 | //default selects |
1389 | 1287 | $this->db->select(array( |
1390 | 1288 | $this->tables['users'].'.*', |
@@ -1394,17 +1292,14 @@ discard block |
||
1394 | 1292 | } |
1395 | 1293 | |
1396 | 1294 | // filter by group id(s) if passed |
1397 | - if (isset($groups)) |
|
1398 | - { |
|
1295 | + if (isset($groups)) { |
|
1399 | 1296 | // build an array if only one group was passed |
1400 | - if (!is_array($groups)) |
|
1401 | - { |
|
1297 | + if (!is_array($groups)) { |
|
1402 | 1298 | $groups = Array($groups); |
1403 | 1299 | } |
1404 | 1300 | |
1405 | 1301 | // join and then run a where_in against the group ids |
1406 | - if (isset($groups) && !empty($groups)) |
|
1407 | - { |
|
1302 | + if (isset($groups) && !empty($groups)) { |
|
1408 | 1303 | $this->db->distinct(); |
1409 | 1304 | $this->db->join( |
1410 | 1305 | $this->tables['users_groups'], |
@@ -1416,20 +1311,20 @@ discard block |
||
1416 | 1311 | // verify if group name or group id was used and create and put elements in different arrays |
1417 | 1312 | $group_ids = array(); |
1418 | 1313 | $group_names = array(); |
1419 | - foreach($groups as $group) |
|
1420 | - { |
|
1421 | - if(is_numeric($group)) $group_ids[] = $group; |
|
1422 | - else $group_names[] = $group; |
|
1314 | + foreach($groups as $group) { |
|
1315 | + if(is_numeric($group)) { |
|
1316 | + $group_ids[] = $group; |
|
1317 | + } else { |
|
1318 | + $group_names[] = $group; |
|
1319 | + } |
|
1423 | 1320 | } |
1424 | 1321 | $or_where_in = (!empty($group_ids) && !empty($group_names)) ? 'or_where_in' : 'where_in'; |
1425 | 1322 | // if group name was used we do one more join with groups |
1426 | - if(!empty($group_names)) |
|
1427 | - { |
|
1323 | + if(!empty($group_names)) { |
|
1428 | 1324 | $this->db->join($this->tables['groups'], $this->tables['users_groups'] . '.' . $this->join['groups'] . ' = ' . $this->tables['groups'] . '.id', 'inner'); |
1429 | 1325 | $this->db->where_in($this->tables['groups'] . '.name', $group_names); |
1430 | 1326 | } |
1431 | - if(!empty($group_ids)) |
|
1432 | - { |
|
1327 | + if(!empty($group_ids)) { |
|
1433 | 1328 | $this->db->{$or_where_in}($this->tables['users_groups'].'.'.$this->join['groups'], $group_ids); |
1434 | 1329 | } |
1435 | 1330 | } |
@@ -1437,43 +1332,35 @@ discard block |
||
1437 | 1332 | $this->trigger_events('extra_where'); |
1438 | 1333 | |
1439 | 1334 | // run each where that was passed |
1440 | - if (isset($this->_ion_where) && !empty($this->_ion_where)) |
|
1441 | - { |
|
1442 | - foreach ($this->_ion_where as $where) |
|
1443 | - { |
|
1335 | + if (isset($this->_ion_where) && !empty($this->_ion_where)) { |
|
1336 | + foreach ($this->_ion_where as $where) { |
|
1444 | 1337 | $this->db->where($where); |
1445 | 1338 | } |
1446 | 1339 | |
1447 | 1340 | $this->_ion_where = array(); |
1448 | 1341 | } |
1449 | 1342 | |
1450 | - if (isset($this->_ion_like) && !empty($this->_ion_like)) |
|
1451 | - { |
|
1452 | - foreach ($this->_ion_like as $like) |
|
1453 | - { |
|
1343 | + if (isset($this->_ion_like) && !empty($this->_ion_like)) { |
|
1344 | + foreach ($this->_ion_like as $like) { |
|
1454 | 1345 | $this->db->or_like($like['like'], $like['value'], $like['position']); |
1455 | 1346 | } |
1456 | 1347 | |
1457 | 1348 | $this->_ion_like = array(); |
1458 | 1349 | } |
1459 | 1350 | |
1460 | - if (isset($this->_ion_limit) && isset($this->_ion_offset)) |
|
1461 | - { |
|
1351 | + if (isset($this->_ion_limit) && isset($this->_ion_offset)) { |
|
1462 | 1352 | $this->db->limit($this->_ion_limit, $this->_ion_offset); |
1463 | 1353 | |
1464 | 1354 | $this->_ion_limit = NULL; |
1465 | 1355 | $this->_ion_offset = NULL; |
1466 | - } |
|
1467 | - else if (isset($this->_ion_limit)) |
|
1468 | - { |
|
1356 | + } else if (isset($this->_ion_limit)) { |
|
1469 | 1357 | $this->db->limit($this->_ion_limit); |
1470 | 1358 | |
1471 | 1359 | $this->_ion_limit = NULL; |
1472 | 1360 | } |
1473 | 1361 | |
1474 | 1362 | // set the order |
1475 | - if (isset($this->_ion_order_by) && isset($this->_ion_order)) |
|
1476 | - { |
|
1363 | + if (isset($this->_ion_order_by) && isset($this->_ion_order)) { |
|
1477 | 1364 | $this->db->order_by($this->_ion_order_by, $this->_ion_order); |
1478 | 1365 | |
1479 | 1366 | $this->_ion_order = NULL; |
@@ -1491,8 +1378,7 @@ discard block |
||
1491 | 1378 | * @return object |
1492 | 1379 | * @author Ben Edmunds |
1493 | 1380 | **/ |
1494 | - public function user($id = NULL) |
|
1495 | - { |
|
1381 | + public function user($id = NULL) { |
|
1496 | 1382 | $this->trigger_events('user'); |
1497 | 1383 | |
1498 | 1384 | // if no id was passed use the current users id |
@@ -1513,8 +1399,7 @@ discard block |
||
1513 | 1399 | * @return array |
1514 | 1400 | * @author Ben Edmunds |
1515 | 1401 | **/ |
1516 | - public function get_users_groups($id=FALSE) |
|
1517 | - { |
|
1402 | + public function get_users_groups($id=FALSE) { |
|
1518 | 1403 | $this->trigger_events('get_users_group'); |
1519 | 1404 | |
1520 | 1405 | // if no id was passed use the current users id |
@@ -1532,29 +1417,24 @@ discard block |
||
1532 | 1417 | * @return bool |
1533 | 1418 | * @author Ben Edmunds |
1534 | 1419 | **/ |
1535 | - public function add_to_group($group_ids, $user_id=false) |
|
1536 | - { |
|
1420 | + public function add_to_group($group_ids, $user_id=false) { |
|
1537 | 1421 | $this->trigger_events('add_to_group'); |
1538 | 1422 | |
1539 | 1423 | // if no id was passed use the current users id |
1540 | 1424 | $user_id || $user_id = $this->session->userdata('user_id'); |
1541 | 1425 | |
1542 | - if(!is_array($group_ids)) |
|
1543 | - { |
|
1426 | + if(!is_array($group_ids)) { |
|
1544 | 1427 | $group_ids = array($group_ids); |
1545 | 1428 | } |
1546 | 1429 | |
1547 | 1430 | $return = 0; |
1548 | 1431 | |
1549 | 1432 | // Then insert each into the database |
1550 | - foreach ($group_ids as $group_id) |
|
1551 | - { |
|
1552 | - if ($this->db->insert($this->tables['users_groups'], array( $this->join['groups'] => (float)$group_id, $this->join['users'] => (float)$user_id))) |
|
1553 | - { |
|
1433 | + foreach ($group_ids as $group_id) { |
|
1434 | + if ($this->db->insert($this->tables['users_groups'], array( $this->join['groups'] => (float)$group_id, $this->join['users'] => (float)$user_id))) { |
|
1554 | 1435 | if (isset($this->_cache_groups[$group_id])) { |
1555 | 1436 | $group_name = $this->_cache_groups[$group_id]; |
1556 | - } |
|
1557 | - else { |
|
1437 | + } else { |
|
1558 | 1438 | $group = $this->group($group_id)->result(); |
1559 | 1439 | $group_name = $group[0]->name; |
1560 | 1440 | $this->_cache_groups[$group_id] = $group_name; |
@@ -1575,29 +1455,23 @@ discard block |
||
1575 | 1455 | * @return bool |
1576 | 1456 | * @author Ben Edmunds |
1577 | 1457 | **/ |
1578 | - public function remove_from_group($group_ids=false, $user_id=false) |
|
1579 | - { |
|
1458 | + public function remove_from_group($group_ids=false, $user_id=false) { |
|
1580 | 1459 | $this->trigger_events('remove_from_group'); |
1581 | 1460 | |
1582 | 1461 | // user id is required |
1583 | - if(empty($user_id)) |
|
1584 | - { |
|
1462 | + if(empty($user_id)) { |
|
1585 | 1463 | return FALSE; |
1586 | 1464 | } |
1587 | 1465 | |
1588 | 1466 | // if group id(s) are passed remove user from the group(s) |
1589 | - if( ! empty($group_ids)) |
|
1590 | - { |
|
1591 | - if(!is_array($group_ids)) |
|
1592 | - { |
|
1467 | + if( ! empty($group_ids)) { |
|
1468 | + if(!is_array($group_ids)) { |
|
1593 | 1469 | $group_ids = array($group_ids); |
1594 | 1470 | } |
1595 | 1471 | |
1596 | - foreach($group_ids as $group_id) |
|
1597 | - { |
|
1472 | + foreach($group_ids as $group_id) { |
|
1598 | 1473 | $this->db->delete($this->tables['users_groups'], array($this->join['groups'] => (float)$group_id, $this->join['users'] => (float)$user_id)); |
1599 | - if (isset($this->_cache_user_in_group[$user_id]) && isset($this->_cache_user_in_group[$user_id][$group_id])) |
|
1600 | - { |
|
1474 | + if (isset($this->_cache_user_in_group[$user_id]) && isset($this->_cache_user_in_group[$user_id][$group_id])) { |
|
1601 | 1475 | unset($this->_cache_user_in_group[$user_id][$group_id]); |
1602 | 1476 | } |
1603 | 1477 | } |
@@ -1605,8 +1479,7 @@ discard block |
||
1605 | 1479 | $return = TRUE; |
1606 | 1480 | } |
1607 | 1481 | // otherwise remove user from all groups |
1608 | - else |
|
1609 | - { |
|
1482 | + else { |
|
1610 | 1483 | if ($return = $this->db->delete($this->tables['users_groups'], array($this->join['users'] => (float)$user_id))) { |
1611 | 1484 | $this->_cache_user_in_group[$user_id] = array(); |
1612 | 1485 | } |
@@ -1620,37 +1493,30 @@ discard block |
||
1620 | 1493 | * @return object |
1621 | 1494 | * @author Ben Edmunds |
1622 | 1495 | **/ |
1623 | - public function groups() |
|
1624 | - { |
|
1496 | + public function groups() { |
|
1625 | 1497 | $this->trigger_events('groups'); |
1626 | 1498 | |
1627 | 1499 | // run each where that was passed |
1628 | - if (isset($this->_ion_where) && !empty($this->_ion_where)) |
|
1629 | - { |
|
1630 | - foreach ($this->_ion_where as $where) |
|
1631 | - { |
|
1500 | + if (isset($this->_ion_where) && !empty($this->_ion_where)) { |
|
1501 | + foreach ($this->_ion_where as $where) { |
|
1632 | 1502 | $this->db->where($where); |
1633 | 1503 | } |
1634 | 1504 | $this->_ion_where = array(); |
1635 | 1505 | } |
1636 | 1506 | |
1637 | - if (isset($this->_ion_limit) && isset($this->_ion_offset)) |
|
1638 | - { |
|
1507 | + if (isset($this->_ion_limit) && isset($this->_ion_offset)) { |
|
1639 | 1508 | $this->db->limit($this->_ion_limit, $this->_ion_offset); |
1640 | 1509 | |
1641 | 1510 | $this->_ion_limit = NULL; |
1642 | 1511 | $this->_ion_offset = NULL; |
1643 | - } |
|
1644 | - else if (isset($this->_ion_limit)) |
|
1645 | - { |
|
1512 | + } else if (isset($this->_ion_limit)) { |
|
1646 | 1513 | $this->db->limit($this->_ion_limit); |
1647 | 1514 | |
1648 | 1515 | $this->_ion_limit = NULL; |
1649 | 1516 | } |
1650 | 1517 | |
1651 | 1518 | // set the order |
1652 | - if (isset($this->_ion_order_by) && isset($this->_ion_order)) |
|
1653 | - { |
|
1519 | + if (isset($this->_ion_order_by) && isset($this->_ion_order)) { |
|
1654 | 1520 | $this->db->order_by($this->_ion_order_by, $this->_ion_order); |
1655 | 1521 | } |
1656 | 1522 | |
@@ -1665,12 +1531,10 @@ discard block |
||
1665 | 1531 | * @return object |
1666 | 1532 | * @author Ben Edmunds |
1667 | 1533 | **/ |
1668 | - public function group($id = NULL) |
|
1669 | - { |
|
1534 | + public function group($id = NULL) { |
|
1670 | 1535 | $this->trigger_events('group'); |
1671 | 1536 | |
1672 | - if (isset($id)) |
|
1673 | - { |
|
1537 | + if (isset($id)) { |
|
1674 | 1538 | $this->where($this->tables['groups'].'.id', $id); |
1675 | 1539 | } |
1676 | 1540 | |
@@ -1686,16 +1550,14 @@ discard block |
||
1686 | 1550 | * @return bool |
1687 | 1551 | * @author Phil Sturgeon |
1688 | 1552 | **/ |
1689 | - public function update($id, array $data) |
|
1690 | - { |
|
1553 | + public function update($id, array $data) { |
|
1691 | 1554 | $this->trigger_events('pre_update_user'); |
1692 | 1555 | |
1693 | 1556 | $user = $this->user($id)->row(); |
1694 | 1557 | |
1695 | 1558 | $this->db->trans_begin(); |
1696 | 1559 | |
1697 | - if (array_key_exists($this->identity_column, $data) && $this->identity_check($data[$this->identity_column]) && $user->{$this->identity_column} !== $data[$this->identity_column]) |
|
1698 | - { |
|
1560 | + if (array_key_exists($this->identity_column, $data) && $this->identity_check($data[$this->identity_column]) && $user->{$this->identity_column} !== $data[$this->identity_column]) { |
|
1699 | 1561 | $this->db->trans_rollback(); |
1700 | 1562 | $this->set_error('account_creation_duplicate_identity'); |
1701 | 1563 | |
@@ -1708,16 +1570,11 @@ discard block |
||
1708 | 1570 | // Filter the data passed |
1709 | 1571 | $data = $this->_filter_data($this->tables['users'], $data); |
1710 | 1572 | |
1711 | - if (array_key_exists($this->identity_column, $data) || array_key_exists('password', $data) || array_key_exists('email', $data)) |
|
1712 | - { |
|
1713 | - if (array_key_exists('password', $data)) |
|
1714 | - { |
|
1715 | - if( ! empty($data['password'])) |
|
1716 | - { |
|
1573 | + if (array_key_exists($this->identity_column, $data) || array_key_exists('password', $data) || array_key_exists('email', $data)) { |
|
1574 | + if (array_key_exists('password', $data)) { |
|
1575 | + if( ! empty($data['password'])) { |
|
1717 | 1576 | $data['password'] = $this->hash_password($data['password'], $user->salt); |
1718 | - } |
|
1719 | - else |
|
1720 | - { |
|
1577 | + } else { |
|
1721 | 1578 | // unset password so it doesn't effect database entry if no password passed |
1722 | 1579 | unset($data['password']); |
1723 | 1580 | } |
@@ -1727,8 +1584,7 @@ discard block |
||
1727 | 1584 | $this->trigger_events('extra_where'); |
1728 | 1585 | $this->db->update($this->tables['users'], $data, array('id' => $user->id)); |
1729 | 1586 | |
1730 | - if ($this->db->trans_status() === FALSE) |
|
1731 | - { |
|
1587 | + if ($this->db->trans_status() === FALSE) { |
|
1732 | 1588 | $this->db->trans_rollback(); |
1733 | 1589 | |
1734 | 1590 | $this->trigger_events(array('post_update_user', 'post_update_user_unsuccessful')); |
@@ -1749,8 +1605,7 @@ discard block |
||
1749 | 1605 | * @return bool |
1750 | 1606 | * @author Phil Sturgeon |
1751 | 1607 | **/ |
1752 | - public function delete_user($id) |
|
1753 | - { |
|
1608 | + public function delete_user($id) { |
|
1754 | 1609 | $this->trigger_events('pre_delete_user'); |
1755 | 1610 | |
1756 | 1611 | $this->db->trans_begin(); |
@@ -1762,8 +1617,7 @@ discard block |
||
1762 | 1617 | $this->db->delete($this->tables['users'], array('id' => $id)); |
1763 | 1618 | |
1764 | 1619 | |
1765 | - if ($this->db->trans_status() === FALSE) |
|
1766 | - { |
|
1620 | + if ($this->db->trans_status() === FALSE) { |
|
1767 | 1621 | $this->db->trans_rollback(); |
1768 | 1622 | $this->trigger_events(array('post_delete_user', 'post_delete_user_unsuccessful')); |
1769 | 1623 | $this->set_error('delete_unsuccessful'); |
@@ -1783,8 +1637,7 @@ discard block |
||
1783 | 1637 | * @return bool |
1784 | 1638 | * @author Ben Edmunds |
1785 | 1639 | **/ |
1786 | - public function update_last_login($id) |
|
1787 | - { |
|
1640 | + public function update_last_login($id) { |
|
1788 | 1641 | $this->trigger_events('update_last_login'); |
1789 | 1642 | |
1790 | 1643 | $this->load->helper('date'); |
@@ -1802,18 +1655,15 @@ discard block |
||
1802 | 1655 | * @return bool |
1803 | 1656 | * @author Ben Edmunds |
1804 | 1657 | **/ |
1805 | - public function set_lang($lang = 'en') |
|
1806 | - { |
|
1658 | + public function set_lang($lang = 'en') { |
|
1807 | 1659 | $this->trigger_events('set_lang'); |
1808 | 1660 | |
1809 | 1661 | // if the user_expire is set to zero we'll set the expiration two years from now. |
1810 | - if($this->config->item('user_expire', 'ion_auth') === 0) |
|
1811 | - { |
|
1662 | + if($this->config->item('user_expire', 'ion_auth') === 0) { |
|
1812 | 1663 | $expire = (60*60*24*365*2); |
1813 | 1664 | } |
1814 | 1665 | // otherwise use what is set |
1815 | - else |
|
1816 | - { |
|
1666 | + else { |
|
1817 | 1667 | $expire = $this->config->item('user_expire', 'ion_auth'); |
1818 | 1668 | } |
1819 | 1669 | |
@@ -1832,8 +1682,7 @@ discard block |
||
1832 | 1682 | * @return bool |
1833 | 1683 | * @author jrmadsen67 |
1834 | 1684 | **/ |
1835 | - public function set_session($user) |
|
1836 | - { |
|
1685 | + public function set_session($user) { |
|
1837 | 1686 | |
1838 | 1687 | $this->trigger_events('pre_set_session'); |
1839 | 1688 | |
@@ -1859,12 +1708,10 @@ discard block |
||
1859 | 1708 | * @return bool |
1860 | 1709 | * @author Ben Edmunds |
1861 | 1710 | **/ |
1862 | - public function remember_user($id) |
|
1863 | - { |
|
1711 | + public function remember_user($id) { |
|
1864 | 1712 | $this->trigger_events('pre_remember_user'); |
1865 | 1713 | |
1866 | - if (!$id) |
|
1867 | - { |
|
1714 | + if (!$id) { |
|
1868 | 1715 | return FALSE; |
1869 | 1716 | } |
1870 | 1717 | |
@@ -1874,16 +1721,13 @@ discard block |
||
1874 | 1721 | |
1875 | 1722 | $this->db->update($this->tables['users'], array('remember_code' => $salt), array('id' => $id)); |
1876 | 1723 | |
1877 | - if ($this->db->affected_rows() > -1) |
|
1878 | - { |
|
1724 | + if ($this->db->affected_rows() > -1) { |
|
1879 | 1725 | // if the user_expire is set to zero we'll set the expiration two years from now. |
1880 | - if($this->config->item('user_expire', 'ion_auth') === 0) |
|
1881 | - { |
|
1726 | + if($this->config->item('user_expire', 'ion_auth') === 0) { |
|
1882 | 1727 | $expire = (60*60*24*365*2); |
1883 | 1728 | } |
1884 | 1729 | // otherwise use what is set |
1885 | - else |
|
1886 | - { |
|
1730 | + else { |
|
1887 | 1731 | $expire = $this->config->item('user_expire', 'ion_auth'); |
1888 | 1732 | } |
1889 | 1733 | |
@@ -1913,15 +1757,13 @@ discard block |
||
1913 | 1757 | * @return bool |
1914 | 1758 | * @author Ben Edmunds |
1915 | 1759 | **/ |
1916 | - public function login_remembered_user() |
|
1917 | - { |
|
1760 | + public function login_remembered_user() { |
|
1918 | 1761 | $this->trigger_events('pre_login_remembered_user'); |
1919 | 1762 | |
1920 | 1763 | // check for valid data |
1921 | 1764 | if (!get_cookie($this->config->item('identity_cookie_name', 'ion_auth')) |
1922 | 1765 | || !get_cookie($this->config->item('remember_cookie_name', 'ion_auth')) |
1923 | - || !$this->identity_check(get_cookie($this->config->item('identity_cookie_name', 'ion_auth')))) |
|
1924 | - { |
|
1766 | + || !$this->identity_check(get_cookie($this->config->item('identity_cookie_name', 'ion_auth')))) { |
|
1925 | 1767 | $this->trigger_events(array('post_login_remembered_user', 'post_login_remembered_user_unsuccessful')); |
1926 | 1768 | return FALSE; |
1927 | 1769 | } |
@@ -1937,8 +1779,7 @@ discard block |
||
1937 | 1779 | ->get($this->tables['users']); |
1938 | 1780 | |
1939 | 1781 | // if the user was found, sign them in |
1940 | - if ($query->num_rows() == 1) |
|
1941 | - { |
|
1782 | + if ($query->num_rows() == 1) { |
|
1942 | 1783 | $user = $query->row(); |
1943 | 1784 | |
1944 | 1785 | $this->update_last_login($user->id); |
@@ -1946,8 +1787,7 @@ discard block |
||
1946 | 1787 | $this->set_session($user); |
1947 | 1788 | |
1948 | 1789 | // extend the users cookies if the option is enabled |
1949 | - if ($this->config->item('user_extend_on_login', 'ion_auth')) |
|
1950 | - { |
|
1790 | + if ($this->config->item('user_extend_on_login', 'ion_auth')) { |
|
1951 | 1791 | $this->remember_user($user->id); |
1952 | 1792 | } |
1953 | 1793 | |
@@ -1965,19 +1805,16 @@ discard block |
||
1965 | 1805 | * |
1966 | 1806 | * @author aditya menon |
1967 | 1807 | */ |
1968 | - public function create_group($group_name = FALSE, $group_description = '', $additional_data = array()) |
|
1969 | - { |
|
1808 | + public function create_group($group_name = FALSE, $group_description = '', $additional_data = array()) { |
|
1970 | 1809 | // bail if the group name was not passed |
1971 | - if(!$group_name) |
|
1972 | - { |
|
1810 | + if(!$group_name) { |
|
1973 | 1811 | $this->set_error('group_name_required'); |
1974 | 1812 | return FALSE; |
1975 | 1813 | } |
1976 | 1814 | |
1977 | 1815 | // bail if the group name already exists |
1978 | 1816 | $existing_group = $this->db->get_where($this->tables['groups'], array('name' => $group_name))->num_rows(); |
1979 | - if($existing_group !== 0) |
|
1980 | - { |
|
1817 | + if($existing_group !== 0) { |
|
1981 | 1818 | $this->set_error('group_already_exists'); |
1982 | 1819 | return FALSE; |
1983 | 1820 | } |
@@ -1986,7 +1823,9 @@ discard block |
||
1986 | 1823 | |
1987 | 1824 | // filter out any data passed that doesnt have a matching column in the groups table |
1988 | 1825 | // and merge the set group data and the additional data |
1989 | - if (!empty($additional_data)) $data = array_merge($this->_filter_data($this->tables['groups'], $additional_data), $data); |
|
1826 | + if (!empty($additional_data)) { |
|
1827 | + $data = array_merge($this->_filter_data($this->tables['groups'], $additional_data), $data); |
|
1828 | + } |
|
1990 | 1829 | |
1991 | 1830 | $this->trigger_events('extra_group_set'); |
1992 | 1831 | |
@@ -2006,20 +1845,19 @@ discard block |
||
2006 | 1845 | * @return bool |
2007 | 1846 | * @author aditya menon |
2008 | 1847 | **/ |
2009 | - public function update_group($group_id = FALSE, $group_name = FALSE, $additional_data = array()) |
|
2010 | - { |
|
2011 | - if (empty($group_id)) return FALSE; |
|
1848 | + public function update_group($group_id = FALSE, $group_name = FALSE, $additional_data = array()) { |
|
1849 | + if (empty($group_id)) { |
|
1850 | + return FALSE; |
|
1851 | + } |
|
2012 | 1852 | |
2013 | 1853 | $data = array(); |
2014 | 1854 | |
2015 | - if (!empty($group_name)) |
|
2016 | - { |
|
1855 | + if (!empty($group_name)) { |
|
2017 | 1856 | // we are changing the name, so do some checks |
2018 | 1857 | |
2019 | 1858 | // bail if the group name already exists |
2020 | 1859 | $existing_group = $this->db->get_where($this->tables['groups'], array('name' => $group_name))->row(); |
2021 | - if(isset($existing_group->id) && $existing_group->id != $group_id) |
|
2022 | - { |
|
1860 | + if(isset($existing_group->id) && $existing_group->id != $group_id) { |
|
2023 | 1861 | $this->set_error('group_already_exists'); |
2024 | 1862 | return FALSE; |
2025 | 1863 | } |
@@ -2029,8 +1867,7 @@ discard block |
||
2029 | 1867 | |
2030 | 1868 | // restrict change of name of the admin group |
2031 | 1869 | $group = $this->db->get_where($this->tables['groups'], array('id' => $group_id))->row(); |
2032 | - if($this->config->item('admin_group', 'ion_auth') === $group->name && $group_name !== $group->name) |
|
2033 | - { |
|
1870 | + if($this->config->item('admin_group', 'ion_auth') === $group->name && $group_name !== $group->name) { |
|
2034 | 1871 | $this->set_error('group_name_admin_not_alter'); |
2035 | 1872 | return FALSE; |
2036 | 1873 | } |
@@ -2038,12 +1875,16 @@ discard block |
||
2038 | 1875 | |
2039 | 1876 | // IMPORTANT!! Third parameter was string type $description; this following code is to maintain backward compatibility |
2040 | 1877 | // New projects should work with 3rd param as array |
2041 | - if (is_string($additional_data)) $additional_data = array('description' => $additional_data); |
|
1878 | + if (is_string($additional_data)) { |
|
1879 | + $additional_data = array('description' => $additional_data); |
|
1880 | + } |
|
2042 | 1881 | |
2043 | 1882 | |
2044 | 1883 | // filter out any data passed that doesnt have a matching column in the groups table |
2045 | 1884 | // and merge the set group data and the additional data |
2046 | - if (!empty($additional_data)) $data = array_merge($this->_filter_data($this->tables['groups'], $additional_data), $data); |
|
1885 | + if (!empty($additional_data)) { |
|
1886 | + $data = array_merge($this->_filter_data($this->tables['groups'], $additional_data), $data); |
|
1887 | + } |
|
2047 | 1888 | |
2048 | 1889 | |
2049 | 1890 | $this->db->update($this->tables['groups'], $data, array('id' => $group_id)); |
@@ -2059,16 +1900,13 @@ discard block |
||
2059 | 1900 | * @return bool |
2060 | 1901 | * @author aditya menon |
2061 | 1902 | **/ |
2062 | - public function delete_group($group_id = FALSE) |
|
2063 | - { |
|
1903 | + public function delete_group($group_id = FALSE) { |
|
2064 | 1904 | // bail if mandatory param not set |
2065 | - if(!$group_id || empty($group_id)) |
|
2066 | - { |
|
1905 | + if(!$group_id || empty($group_id)) { |
|
2067 | 1906 | return FALSE; |
2068 | 1907 | } |
2069 | 1908 | $group = $this->group($group_id)->row(); |
2070 | - if($group->name == $this->config->item('admin_group', 'ion_auth')) |
|
2071 | - { |
|
1909 | + if($group->name == $this->config->item('admin_group', 'ion_auth')) { |
|
2072 | 1910 | $this->trigger_events(array('post_delete_group', 'post_delete_group_notallowed')); |
2073 | 1911 | $this->set_error('group_delete_notallowed'); |
2074 | 1912 | return FALSE; |
@@ -2083,8 +1921,7 @@ discard block |
||
2083 | 1921 | // remove the group itself |
2084 | 1922 | $this->db->delete($this->tables['groups'], array('id' => $group_id)); |
2085 | 1923 | |
2086 | - if ($this->db->trans_status() === FALSE) |
|
2087 | - { |
|
1924 | + if ($this->db->trans_status() === FALSE) { |
|
2088 | 1925 | $this->db->trans_rollback(); |
2089 | 1926 | $this->trigger_events(array('post_delete_group', 'post_delete_group_unsuccessful')); |
2090 | 1927 | $this->set_error('group_delete_unsuccessful'); |
@@ -2098,34 +1935,27 @@ discard block |
||
2098 | 1935 | return TRUE; |
2099 | 1936 | } |
2100 | 1937 | |
2101 | - public function set_hook($event, $name, $class, $method, $arguments) |
|
2102 | - { |
|
1938 | + public function set_hook($event, $name, $class, $method, $arguments) { |
|
2103 | 1939 | $this->_ion_hooks->{$event}[$name] = new stdClass; |
2104 | 1940 | $this->_ion_hooks->{$event}[$name]->class = $class; |
2105 | 1941 | $this->_ion_hooks->{$event}[$name]->method = $method; |
2106 | 1942 | $this->_ion_hooks->{$event}[$name]->arguments = $arguments; |
2107 | 1943 | } |
2108 | 1944 | |
2109 | - public function remove_hook($event, $name) |
|
2110 | - { |
|
2111 | - if (isset($this->_ion_hooks->{$event}[$name])) |
|
2112 | - { |
|
1945 | + public function remove_hook($event, $name) { |
|
1946 | + if (isset($this->_ion_hooks->{$event}[$name])) { |
|
2113 | 1947 | unset($this->_ion_hooks->{$event}[$name]); |
2114 | 1948 | } |
2115 | 1949 | } |
2116 | 1950 | |
2117 | - public function remove_hooks($event) |
|
2118 | - { |
|
2119 | - if (isset($this->_ion_hooks->$event)) |
|
2120 | - { |
|
1951 | + public function remove_hooks($event) { |
|
1952 | + if (isset($this->_ion_hooks->$event)) { |
|
2121 | 1953 | unset($this->_ion_hooks->$event); |
2122 | 1954 | } |
2123 | 1955 | } |
2124 | 1956 | |
2125 | - protected function _call_hook($event, $name) |
|
2126 | - { |
|
2127 | - if (isset($this->_ion_hooks->{$event}[$name]) && method_exists($this->_ion_hooks->{$event}[$name]->class, $this->_ion_hooks->{$event}[$name]->method)) |
|
2128 | - { |
|
1957 | + protected function _call_hook($event, $name) { |
|
1958 | + if (isset($this->_ion_hooks->{$event}[$name]) && method_exists($this->_ion_hooks->{$event}[$name]->class, $this->_ion_hooks->{$event}[$name]->method)) { |
|
2129 | 1959 | $hook = $this->_ion_hooks->{$event}[$name]; |
2130 | 1960 | |
2131 | 1961 | return call_user_func_array(array($hook->class, $hook->method), $hook->arguments); |
@@ -2134,21 +1964,14 @@ discard block |
||
2134 | 1964 | return FALSE; |
2135 | 1965 | } |
2136 | 1966 | |
2137 | - public function trigger_events($events) |
|
2138 | - { |
|
2139 | - if (is_array($events) && !empty($events)) |
|
2140 | - { |
|
2141 | - foreach ($events as $event) |
|
2142 | - { |
|
1967 | + public function trigger_events($events) { |
|
1968 | + if (is_array($events) && !empty($events)) { |
|
1969 | + foreach ($events as $event) { |
|
2143 | 1970 | $this->trigger_events($event); |
2144 | 1971 | } |
2145 | - } |
|
2146 | - else |
|
2147 | - { |
|
2148 | - if (isset($this->_ion_hooks->$events) && !empty($this->_ion_hooks->$events)) |
|
2149 | - { |
|
2150 | - foreach ($this->_ion_hooks->$events as $name => $hook) |
|
2151 | - { |
|
1972 | + } else { |
|
1973 | + if (isset($this->_ion_hooks->$events) && !empty($this->_ion_hooks->$events)) { |
|
1974 | + foreach ($this->_ion_hooks->$events as $name => $hook) { |
|
2152 | 1975 | $this->_call_hook($events, $name); |
2153 | 1976 | } |
2154 | 1977 | } |
@@ -2163,8 +1986,7 @@ discard block |
||
2163 | 1986 | * @return void |
2164 | 1987 | * @author Ben Edmunds |
2165 | 1988 | **/ |
2166 | - public function set_message_delimiters($start_delimiter, $end_delimiter) |
|
2167 | - { |
|
1989 | + public function set_message_delimiters($start_delimiter, $end_delimiter) { |
|
2168 | 1990 | $this->message_start_delimiter = $start_delimiter; |
2169 | 1991 | $this->message_end_delimiter = $end_delimiter; |
2170 | 1992 | |
@@ -2179,8 +2001,7 @@ discard block |
||
2179 | 2001 | * @return void |
2180 | 2002 | * @author Ben Edmunds |
2181 | 2003 | **/ |
2182 | - public function set_error_delimiters($start_delimiter, $end_delimiter) |
|
2183 | - { |
|
2004 | + public function set_error_delimiters($start_delimiter, $end_delimiter) { |
|
2184 | 2005 | $this->error_start_delimiter = $start_delimiter; |
2185 | 2006 | $this->error_end_delimiter = $end_delimiter; |
2186 | 2007 | |
@@ -2195,8 +2016,7 @@ discard block |
||
2195 | 2016 | * @return void |
2196 | 2017 | * @author Ben Edmunds |
2197 | 2018 | **/ |
2198 | - public function set_message($message) |
|
2199 | - { |
|
2019 | + public function set_message($message) { |
|
2200 | 2020 | $this->messages[] = $message; |
2201 | 2021 | |
2202 | 2022 | return $message; |
@@ -2212,11 +2032,9 @@ discard block |
||
2212 | 2032 | * @return void |
2213 | 2033 | * @author Ben Edmunds |
2214 | 2034 | **/ |
2215 | - public function messages() |
|
2216 | - { |
|
2035 | + public function messages() { |
|
2217 | 2036 | $_output = ''; |
2218 | - foreach ($this->messages as $message) |
|
2219 | - { |
|
2037 | + foreach ($this->messages as $message) { |
|
2220 | 2038 | $messageLang = $this->lang->line($message) ? $this->lang->line($message) : '##' . $message . '##'; |
2221 | 2039 | $_output .= $this->message_start_delimiter . $messageLang . $this->message_end_delimiter; |
2222 | 2040 | } |
@@ -2232,20 +2050,15 @@ discard block |
||
2232 | 2050 | * @return array |
2233 | 2051 | * @author Raul Baldner Junior |
2234 | 2052 | **/ |
2235 | - public function messages_array($langify = TRUE) |
|
2236 | - { |
|
2237 | - if ($langify) |
|
2238 | - { |
|
2053 | + public function messages_array($langify = TRUE) { |
|
2054 | + if ($langify) { |
|
2239 | 2055 | $_output = array(); |
2240 | - foreach ($this->messages as $message) |
|
2241 | - { |
|
2056 | + foreach ($this->messages as $message) { |
|
2242 | 2057 | $messageLang = $this->lang->line($message) ? $this->lang->line($message) : '##' . $message . '##'; |
2243 | 2058 | $_output[] = $this->message_start_delimiter . $messageLang . $this->message_end_delimiter; |
2244 | 2059 | } |
2245 | 2060 | return $_output; |
2246 | - } |
|
2247 | - else |
|
2248 | - { |
|
2061 | + } else { |
|
2249 | 2062 | return $this->messages; |
2250 | 2063 | } |
2251 | 2064 | } |
@@ -2259,8 +2072,7 @@ discard block |
||
2259 | 2072 | * @return void |
2260 | 2073 | * @author Ben Edmunds |
2261 | 2074 | **/ |
2262 | - public function clear_messages() |
|
2263 | - { |
|
2075 | + public function clear_messages() { |
|
2264 | 2076 | $this->messages = array(); |
2265 | 2077 | |
2266 | 2078 | return TRUE; |
@@ -2275,8 +2087,7 @@ discard block |
||
2275 | 2087 | * @return void |
2276 | 2088 | * @author Ben Edmunds |
2277 | 2089 | **/ |
2278 | - public function set_error($error) |
|
2279 | - { |
|
2090 | + public function set_error($error) { |
|
2280 | 2091 | $this->errors[] = $error; |
2281 | 2092 | |
2282 | 2093 | return $error; |
@@ -2290,11 +2101,9 @@ discard block |
||
2290 | 2101 | * @return void |
2291 | 2102 | * @author Ben Edmunds |
2292 | 2103 | **/ |
2293 | - public function errors() |
|
2294 | - { |
|
2104 | + public function errors() { |
|
2295 | 2105 | $_output = ''; |
2296 | - foreach ($this->errors as $error) |
|
2297 | - { |
|
2106 | + foreach ($this->errors as $error) { |
|
2298 | 2107 | $errorLang = $this->lang->line($error) ? $this->lang->line($error) : '##' . $error . '##'; |
2299 | 2108 | $_output .= $this->error_start_delimiter . $errorLang . $this->error_end_delimiter; |
2300 | 2109 | } |
@@ -2310,20 +2119,15 @@ discard block |
||
2310 | 2119 | * @return array |
2311 | 2120 | * @author Raul Baldner Junior |
2312 | 2121 | **/ |
2313 | - public function errors_array($langify = TRUE) |
|
2314 | - { |
|
2315 | - if ($langify) |
|
2316 | - { |
|
2122 | + public function errors_array($langify = TRUE) { |
|
2123 | + if ($langify) { |
|
2317 | 2124 | $_output = array(); |
2318 | - foreach ($this->errors as $error) |
|
2319 | - { |
|
2125 | + foreach ($this->errors as $error) { |
|
2320 | 2126 | $errorLang = $this->lang->line($error) ? $this->lang->line($error) : '##' . $error . '##'; |
2321 | 2127 | $_output[] = $this->error_start_delimiter . $errorLang . $this->error_end_delimiter; |
2322 | 2128 | } |
2323 | 2129 | return $_output; |
2324 | - } |
|
2325 | - else |
|
2326 | - { |
|
2130 | + } else { |
|
2327 | 2131 | return $this->errors; |
2328 | 2132 | } |
2329 | 2133 | } |
@@ -2337,8 +2141,7 @@ discard block |
||
2337 | 2141 | * @return void |
2338 | 2142 | * @author Ben Edmunds |
2339 | 2143 | **/ |
2340 | - public function clear_errors() |
|
2341 | - { |
|
2144 | + public function clear_errors() { |
|
2342 | 2145 | $this->errors = array(); |
2343 | 2146 | |
2344 | 2147 | return TRUE; |
@@ -2346,17 +2149,15 @@ discard block |
||
2346 | 2149 | |
2347 | 2150 | |
2348 | 2151 | |
2349 | - protected function _filter_data($table, $data) |
|
2350 | - { |
|
2152 | + protected function _filter_data($table, $data) { |
|
2351 | 2153 | $filtered_data = array(); |
2352 | 2154 | $columns = $this->db->list_fields($table); |
2353 | 2155 | |
2354 | - if (is_array($data)) |
|
2355 | - { |
|
2356 | - foreach ($columns as $column) |
|
2357 | - { |
|
2358 | - if (array_key_exists($column, $data)) |
|
2359 | - $filtered_data[$column] = $data[$column]; |
|
2156 | + if (is_array($data)) { |
|
2157 | + foreach ($columns as $column) { |
|
2158 | + if (array_key_exists($column, $data)) { |
|
2159 | + $filtered_data[$column] = $data[$column]; |
|
2160 | + } |
|
2360 | 2161 | } |
2361 | 2162 | } |
2362 | 2163 |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | * @return void |
261 | 261 | * @author Mathew |
262 | 262 | **/ |
263 | - public function hash_password($password, $salt=false, $use_sha1_override=FALSE) |
|
263 | + public function hash_password($password, $salt=FALSE, $use_sha1_override=FALSE) |
|
264 | 264 | { |
265 | 265 | if (empty($password)) |
266 | 266 | { |
@@ -372,26 +372,26 @@ discard block |
||
372 | 372 | $raw_salt_len = 16; |
373 | 373 | |
374 | 374 | $buffer = ''; |
375 | - $buffer_valid = false; |
|
375 | + $buffer_valid = FALSE; |
|
376 | 376 | |
377 | 377 | if (function_exists('random_bytes')) { |
378 | 378 | $buffer = random_bytes($raw_salt_len); |
379 | 379 | if ($buffer) { |
380 | - $buffer_valid = true; |
|
380 | + $buffer_valid = TRUE; |
|
381 | 381 | } |
382 | 382 | } |
383 | 383 | |
384 | 384 | if (!$buffer_valid && function_exists('mcrypt_create_iv') && !defined('PHALANGER')) { |
385 | 385 | $buffer = mcrypt_create_iv($raw_salt_len, MCRYPT_DEV_URANDOM); |
386 | 386 | if ($buffer) { |
387 | - $buffer_valid = true; |
|
387 | + $buffer_valid = TRUE; |
|
388 | 388 | } |
389 | 389 | } |
390 | 390 | |
391 | 391 | if (!$buffer_valid && function_exists('openssl_random_pseudo_bytes')) { |
392 | 392 | $buffer = openssl_random_pseudo_bytes($raw_salt_len); |
393 | 393 | if ($buffer) { |
394 | - $buffer_valid = true; |
|
394 | + $buffer_valid = TRUE; |
|
395 | 395 | } |
396 | 396 | } |
397 | 397 | |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | } |
405 | 405 | fclose($f); |
406 | 406 | if ($read >= $raw_salt_len) { |
407 | - $buffer_valid = true; |
|
407 | + $buffer_valid = TRUE; |
|
408 | 408 | } |
409 | 409 | } |
410 | 410 | |
@@ -449,7 +449,7 @@ discard block |
||
449 | 449 | * @return void |
450 | 450 | * @author Mathew |
451 | 451 | **/ |
452 | - public function activate($id, $code = false) |
|
452 | + public function activate($id, $code = FALSE) |
|
453 | 453 | { |
454 | 454 | $this->trigger_events('pre_activate'); |
455 | 455 | |
@@ -917,7 +917,7 @@ discard block |
||
917 | 917 | 'email' => $email, |
918 | 918 | 'ip_address' => $ip_address, |
919 | 919 | 'created_on' => time(), |
920 | - 'active' => ($manual_activation === false ? 1 : 0) |
|
920 | + 'active' => ($manual_activation === FALSE ? 1 : 0) |
|
921 | 921 | ); |
922 | 922 | |
923 | 923 | if ($this->store_salt) |
@@ -1042,7 +1042,7 @@ discard block |
||
1042 | 1042 | */ |
1043 | 1043 | public function recheck_session() |
1044 | 1044 | { |
1045 | - $recheck = (null !== $this->config->item('recheck_timer', 'ion_auth')) ? $this->config->item('recheck_timer', 'ion_auth') : 0; |
|
1045 | + $recheck = (NULL !== $this->config->item('recheck_timer', 'ion_auth')) ? $this->config->item('recheck_timer', 'ion_auth') : 0; |
|
1046 | 1046 | |
1047 | 1047 | if($recheck!==0) |
1048 | 1048 | { |
@@ -1072,7 +1072,7 @@ discard block |
||
1072 | 1072 | { |
1073 | 1073 | $this->session->unset_userdata( array($identity, 'id', 'user_id') ); |
1074 | 1074 | } |
1075 | - return false; |
|
1075 | + return FALSE; |
|
1076 | 1076 | } |
1077 | 1077 | } |
1078 | 1078 | } |
@@ -1399,7 +1399,7 @@ discard block |
||
1399 | 1399 | // build an array if only one group was passed |
1400 | 1400 | if (!is_array($groups)) |
1401 | 1401 | { |
1402 | - $groups = Array($groups); |
|
1402 | + $groups = array($groups); |
|
1403 | 1403 | } |
1404 | 1404 | |
1405 | 1405 | // join and then run a where_in against the group ids |
@@ -1532,7 +1532,7 @@ discard block |
||
1532 | 1532 | * @return bool |
1533 | 1533 | * @author Ben Edmunds |
1534 | 1534 | **/ |
1535 | - public function add_to_group($group_ids, $user_id=false) |
|
1535 | + public function add_to_group($group_ids, $user_id=FALSE) |
|
1536 | 1536 | { |
1537 | 1537 | $this->trigger_events('add_to_group'); |
1538 | 1538 | |
@@ -1575,7 +1575,7 @@ discard block |
||
1575 | 1575 | * @return bool |
1576 | 1576 | * @author Ben Edmunds |
1577 | 1577 | **/ |
1578 | - public function remove_from_group($group_ids=false, $user_id=false) |
|
1578 | + public function remove_from_group($group_ids=FALSE, $user_id=FALSE) |
|
1579 | 1579 | { |
1580 | 1580 | $this->trigger_events('remove_from_group'); |
1581 | 1581 |