@@ -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 | |
| 4 | 6 | class Bcrypt { |
@@ -49,34 +51,26 @@ discard block |
||
| 49 | 51 | * @param string $user_string |
| 50 | 52 | * @return bool |
| 51 | 53 | */ |
| 52 | - private function hashEquals($known_string, $user_string) |
|
| 53 | - { |
|
| 54 | + private function hashEquals($known_string, $user_string) { |
|
| 54 | 55 | // For CI3 or PHP >= 5.6 |
| 55 | - if (function_exists('hash_equals')) |
|
| 56 | - { |
|
| 56 | + if (function_exists('hash_equals')) { |
|
| 57 | 57 | return hash_equals($known_string, $user_string); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | // For CI2 with PHP < 5.6 |
| 61 | 61 | // Code from CI3 https://github.com/bcit-ci/CodeIgniter/blob/develop/system/core/compat/hash.php |
| 62 | - if ( ! is_string($known_string)) |
|
| 63 | - { |
|
| 62 | + if ( ! is_string($known_string)) { |
|
| 64 | 63 | trigger_error('hash_equals(): Expected known_string to be a string, '.strtolower(gettype($known_string)).' given', E_USER_WARNING); |
| 65 | 64 | return FALSE; |
| 66 | - } |
|
| 67 | - elseif ( ! is_string($user_string)) |
|
| 68 | - { |
|
| 65 | + } elseif ( ! is_string($user_string)) { |
|
| 69 | 66 | trigger_error('hash_equals(): Expected user_string to be a string, '.strtolower(gettype($user_string)).' given', E_USER_WARNING); |
| 70 | 67 | return FALSE; |
| 71 | - } |
|
| 72 | - elseif (($length = strlen($known_string)) !== strlen($user_string)) |
|
| 73 | - { |
|
| 68 | + } elseif (($length = strlen($known_string)) !== strlen($user_string)) { |
|
| 74 | 69 | return FALSE; |
| 75 | 70 | } |
| 76 | 71 | |
| 77 | 72 | $diff = 0; |
| 78 | - for ($i = 0; $i < $length; $i++) |
|
| 79 | - { |
|
| 73 | + for ($i = 0; $i < $length; $i++) { |
|
| 80 | 74 | $diff |= ord($known_string[$i]) ^ ord($user_string[$i]); |
| 81 | 75 | } |
| 82 | 76 | |
@@ -104,7 +98,8 @@ discard block |
||
| 104 | 98 | $bytes = ''; |
| 105 | 99 | |
| 106 | 100 | if(function_exists('openssl_random_pseudo_bytes') && |
| 107 | - (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN')) { // OpenSSL slow on Win |
|
| 101 | + (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN')) { |
|
| 102 | +// OpenSSL slow on Win |
|
| 108 | 103 | $bytes = openssl_random_pseudo_bytes($count); |
| 109 | 104 | } |
| 110 | 105 | |
@@ -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 |
@@ -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 | /** |
| 4 | 6 | * Sekati CodeIgniter Asset Helper |
@@ -52,8 +54,7 @@ discard block |
||
| 52 | 54 | */ |
| 53 | 55 | |
| 54 | 56 | if (!function_exists('asset_url')) { |
| 55 | - function asset_url() |
|
| 56 | - { |
|
| 57 | + function asset_url() { |
|
| 57 | 58 | //get an instance of CI so we can access our configuration |
| 58 | 59 | $CI =& get_instance(); |
| 59 | 60 | |
@@ -69,8 +70,7 @@ discard block |
||
| 69 | 70 | * @return string |
| 70 | 71 | */ |
| 71 | 72 | if (!function_exists('css_url')) { |
| 72 | - function css_url() |
|
| 73 | - { |
|
| 73 | + function css_url() { |
|
| 74 | 74 | $CI =& get_instance(); |
| 75 | 75 | |
| 76 | 76 | return $CI->config->slash_item('static_url') . $CI->config->item('css_path'); |
@@ -84,8 +84,7 @@ discard block |
||
| 84 | 84 | * @return string |
| 85 | 85 | */ |
| 86 | 86 | if (!function_exists('less_url')) { |
| 87 | - function less_url() |
|
| 88 | - { |
|
| 87 | + function less_url() { |
|
| 89 | 88 | $CI =& get_instance(); |
| 90 | 89 | |
| 91 | 90 | return $CI->config->slash_item('static_url') . $CI->config->item('less_path'); |
@@ -99,8 +98,7 @@ discard block |
||
| 99 | 98 | * @return string |
| 100 | 99 | */ |
| 101 | 100 | if (!function_exists('js_url')) { |
| 102 | - function js_url() |
|
| 103 | - { |
|
| 101 | + function js_url() { |
|
| 104 | 102 | $CI =& get_instance(); |
| 105 | 103 | |
| 106 | 104 | return $CI->config->slash_item('static_url') . $CI->config->item('js_path'); |
@@ -114,8 +112,7 @@ discard block |
||
| 114 | 112 | * @return string |
| 115 | 113 | */ |
| 116 | 114 | if (!function_exists('img_url')) { |
| 117 | - function img_url() |
|
| 118 | - { |
|
| 115 | + function img_url() { |
|
| 119 | 116 | $CI =& get_instance(); |
| 120 | 117 | |
| 121 | 118 | return $CI->config->slash_item('static_url') . $CI->config->item('img_path'); |
@@ -129,8 +126,7 @@ discard block |
||
| 129 | 126 | * @return string |
| 130 | 127 | */ |
| 131 | 128 | if (!function_exists('swf_url')) { |
| 132 | - function swf_url() |
|
| 133 | - { |
|
| 129 | + function swf_url() { |
|
| 134 | 130 | $CI =& get_instance(); |
| 135 | 131 | |
| 136 | 132 | return $CI->config->slash_item('static_url') . $CI->config->item('swf_path'); |
@@ -144,8 +140,7 @@ discard block |
||
| 144 | 140 | * @return string |
| 145 | 141 | */ |
| 146 | 142 | if (!function_exists('upload_url')) { |
| 147 | - function upload_url() |
|
| 148 | - { |
|
| 143 | + function upload_url() { |
|
| 149 | 144 | $CI =& get_instance(); |
| 150 | 145 | |
| 151 | 146 | return base_url() . $CI->config->item('upload_path'); |
@@ -159,8 +154,7 @@ discard block |
||
| 159 | 154 | * @return string |
| 160 | 155 | */ |
| 161 | 156 | if (!function_exists('download_url')) { |
| 162 | - function download_url() |
|
| 163 | - { |
|
| 157 | + function download_url() { |
|
| 164 | 158 | $CI =& get_instance(); |
| 165 | 159 | |
| 166 | 160 | return base_url() . $CI->config->item('download_path'); |
@@ -174,8 +168,7 @@ discard block |
||
| 174 | 168 | * @return string |
| 175 | 169 | */ |
| 176 | 170 | if (!function_exists('xml_url')) { |
| 177 | - function xml_url() |
|
| 178 | - { |
|
| 171 | + function xml_url() { |
|
| 179 | 172 | $CI =& get_instance(); |
| 180 | 173 | |
| 181 | 174 | return base_url() . $CI->config->item('xml_path'); |
@@ -193,8 +186,7 @@ discard block |
||
| 193 | 186 | * @return string |
| 194 | 187 | */ |
| 195 | 188 | if (!function_exists('asset_path')) { |
| 196 | - function asset_path() |
|
| 197 | - { |
|
| 189 | + function asset_path() { |
|
| 198 | 190 | //get an instance of CI so we can access our configuration |
| 199 | 191 | $CI =& get_instance(); |
| 200 | 192 | |
@@ -209,8 +201,7 @@ discard block |
||
| 209 | 201 | * @return string |
| 210 | 202 | */ |
| 211 | 203 | if (!function_exists('css_path')) { |
| 212 | - function css_path() |
|
| 213 | - { |
|
| 204 | + function css_path() { |
|
| 214 | 205 | //get an instance of CI so we can access our configuration |
| 215 | 206 | $CI =& get_instance(); |
| 216 | 207 | |
@@ -225,8 +216,7 @@ discard block |
||
| 225 | 216 | * @return string |
| 226 | 217 | */ |
| 227 | 218 | if (!function_exists('less_path')) { |
| 228 | - function less_path() |
|
| 229 | - { |
|
| 219 | + function less_path() { |
|
| 230 | 220 | //get an instance of CI so we can access our configuration |
| 231 | 221 | $CI =& get_instance(); |
| 232 | 222 | |
@@ -241,8 +231,7 @@ discard block |
||
| 241 | 231 | * @return string |
| 242 | 232 | */ |
| 243 | 233 | if (!function_exists('js_path')) { |
| 244 | - function js_path() |
|
| 245 | - { |
|
| 234 | + function js_path() { |
|
| 246 | 235 | //get an instance of CI so we can access our configuration |
| 247 | 236 | $CI =& get_instance(); |
| 248 | 237 | |
@@ -257,8 +246,7 @@ discard block |
||
| 257 | 246 | * @return string |
| 258 | 247 | */ |
| 259 | 248 | if (!function_exists('img_path')) { |
| 260 | - function img_path() |
|
| 261 | - { |
|
| 249 | + function img_path() { |
|
| 262 | 250 | //get an instance of CI so we can access our configuration |
| 263 | 251 | $CI =& get_instance(); |
| 264 | 252 | |
@@ -273,8 +261,7 @@ discard block |
||
| 273 | 261 | * @return string |
| 274 | 262 | */ |
| 275 | 263 | if (!function_exists('swf_path')) { |
| 276 | - function swf_path() |
|
| 277 | - { |
|
| 264 | + function swf_path() { |
|
| 278 | 265 | $CI =& get_instance(); |
| 279 | 266 | |
| 280 | 267 | return FCPATH . $CI->config->item('swf_path'); |
@@ -288,8 +275,7 @@ discard block |
||
| 288 | 275 | * @return string |
| 289 | 276 | */ |
| 290 | 277 | if (!function_exists('xml_path')) { |
| 291 | - function xml_path() |
|
| 292 | - { |
|
| 278 | + function xml_path() { |
|
| 293 | 279 | $CI =& get_instance(); |
| 294 | 280 | |
| 295 | 281 | return FCPATH . $CI->config->item('xml_path'); |
@@ -303,8 +289,7 @@ discard block |
||
| 303 | 289 | * @return string |
| 304 | 290 | */ |
| 305 | 291 | if (!function_exists('upload_path')) { |
| 306 | - function upload_path() |
|
| 307 | - { |
|
| 292 | + function upload_path() { |
|
| 308 | 293 | $CI =& get_instance(); |
| 309 | 294 | |
| 310 | 295 | return FCPATH . $CI->config->item('upload_path'); |
@@ -318,8 +303,7 @@ discard block |
||
| 318 | 303 | * @return string |
| 319 | 304 | */ |
| 320 | 305 | if (!function_exists('upload_path_relative')) { |
| 321 | - function upload_path_relative() |
|
| 322 | - { |
|
| 306 | + function upload_path_relative() { |
|
| 323 | 307 | $CI =& get_instance(); |
| 324 | 308 | |
| 325 | 309 | return './' . $CI->config->item('upload_path'); |
@@ -333,8 +317,7 @@ discard block |
||
| 333 | 317 | * @return string |
| 334 | 318 | */ |
| 335 | 319 | if (!function_exists('download_path')) { |
| 336 | - function download_path() |
|
| 337 | - { |
|
| 320 | + function download_path() { |
|
| 338 | 321 | $CI =& get_instance(); |
| 339 | 322 | |
| 340 | 323 | return FCPATH . $CI->config->item('download_path'); |
@@ -348,8 +331,7 @@ discard block |
||
| 348 | 331 | * @return string |
| 349 | 332 | */ |
| 350 | 333 | if (!function_exists('download_path_relative')) { |
| 351 | - function download_path_relative() |
|
| 352 | - { |
|
| 334 | + function download_path_relative() { |
|
| 353 | 335 | $CI =& get_instance(); |
| 354 | 336 | |
| 355 | 337 | return './' . $CI->config->item('download_path'); |
@@ -370,8 +352,7 @@ discard block |
||
| 370 | 352 | * @return string |
| 371 | 353 | */ |
| 372 | 354 | if (!function_exists('css')) { |
| 373 | - function css($file, $media = 'all') |
|
| 374 | - { |
|
| 355 | + function css($file, $media = 'all') { |
|
| 375 | 356 | return '<link rel="stylesheet" type="text/css" href="' . css_url() . $file . '" media="' . $media . '">' . "\n"; |
| 376 | 357 | } |
| 377 | 358 | } |
@@ -386,8 +367,7 @@ discard block |
||
| 386 | 367 | * @return string |
| 387 | 368 | */ |
| 388 | 369 | if (!function_exists('less')) { |
| 389 | - function less($file) |
|
| 390 | - { |
|
| 370 | + function less($file) { |
|
| 391 | 371 | return '<link rel="stylesheet/less" type="text/css" href="' . less_url() . $file . '">' . "\n"; |
| 392 | 372 | } |
| 393 | 373 | } |
@@ -403,12 +383,12 @@ discard block |
||
| 403 | 383 | * @return string |
| 404 | 384 | */ |
| 405 | 385 | if (!function_exists('js')) { |
| 406 | - function js($file, $atts = array()) |
|
| 407 | - { |
|
| 386 | + function js($file, $atts = array()) { |
|
| 408 | 387 | $element = '<script type="text/javascript" src="' . js_url() . $file . '"'; |
| 409 | 388 | |
| 410 | - foreach ($atts as $key => $val) |
|
| 411 | - $element .= ' ' . $key . '="' . $val . '"'; |
|
| 389 | + foreach ($atts as $key => $val) { |
|
| 390 | + $element .= ' ' . $key . '="' . $val . '"'; |
|
| 391 | + } |
|
| 412 | 392 | $element .= '></script>' . "\n"; |
| 413 | 393 | |
| 414 | 394 | return $element; |
@@ -426,11 +406,11 @@ discard block |
||
| 426 | 406 | * @return string |
| 427 | 407 | */ |
| 428 | 408 | if (!function_exists('img')) { |
| 429 | - function img($file, $atts = array()) |
|
| 430 | - { |
|
| 409 | + function img($file, $atts = array()) { |
|
| 431 | 410 | $url = '<img src="' . img_url() . $file . '"'; |
| 432 | - foreach ($atts as $key => $val) |
|
| 433 | - $url .= ' ' . $key . '="' . $val . '"'; |
|
| 411 | + foreach ($atts as $key => $val) { |
|
| 412 | + $url .= ' ' . $key . '="' . $val . '"'; |
|
| 413 | + } |
|
| 434 | 414 | $url .= " />\n"; |
| 435 | 415 | |
| 436 | 416 | return $url; |
@@ -447,8 +427,7 @@ discard block |
||
| 447 | 427 | * @return string |
| 448 | 428 | */ |
| 449 | 429 | if (!function_exists('jquery')) { |
| 450 | - function jquery($version = '') |
|
| 451 | - { |
|
| 430 | + function jquery($version = '') { |
|
| 452 | 431 | // Grab Google CDN's jQuery, with a protocol relative URL; fall back to local if offline |
| 453 | 432 | $out = '<script src="//ajax.googleapis.com/ajax/libs/jquery/' . $version . '/jquery.min.js"></script>' . "\n"; |
| 454 | 433 | $out .= '<script>window.jQuery || document.write(\'<script src="' . js_url() . 'jquery-' . $version . '.min.js"><\/script>\')</script>' . "\n"; |
@@ -467,8 +446,7 @@ discard block |
||
| 467 | 446 | * @return string |
| 468 | 447 | */ |
| 469 | 448 | if (!function_exists('google_analytics')) { |
| 470 | - function google_analytics($ua = '') |
|
| 471 | - { |
|
| 449 | + function google_analytics($ua = '') { |
|
| 472 | 450 | // Change UA-XXXXX-X to be your site's ID |
| 473 | 451 | $out = "<!-- Google Webmaster Tools & Analytics -->\n"; |
| 474 | 452 | $out .= '<script type="text/javascript">'; |
@@ -367,12 +367,10 @@ discard block |
||
| 367 | 367 | * |
| 368 | 368 | * @deprecated |
| 369 | 369 | */ |
| 370 | - public function set_email($email) |
|
| 371 | - { |
|
| 370 | + public function set_email($email) { |
|
| 372 | 371 | $email = trim(strtolower($email)); |
| 373 | 372 | |
| 374 | - if ( ! filter_var($email, FILTER_VALIDATE_EMAIL) === FALSE) |
|
| 375 | - { |
|
| 373 | + if ( ! filter_var($email, FILTER_VALIDATE_EMAIL) === FALSE) { |
|
| 376 | 374 | return md5($email); |
| 377 | 375 | } |
| 378 | 376 | |
@@ -393,12 +391,10 @@ discard block |
||
| 393 | 391 | * |
| 394 | 392 | * @deprecated |
| 395 | 393 | */ |
| 396 | - public function get_gravatar($email, $rating = NULL, $size = NULL, $default_image = NULL, $secure = NULL) |
|
| 397 | - { |
|
| 394 | + public function get_gravatar($email, $rating = NULL, $size = NULL, $default_image = NULL, $secure = NULL) { |
|
| 398 | 395 | $hash = $this->set_email($email); |
| 399 | 396 | |
| 400 | - if ($hash === NULL) |
|
| 401 | - { |
|
| 397 | + if ($hash === NULL) { |
|
| 402 | 398 | // $hash has to be set to a value so the gravatar site can return a default image |
| 403 | 399 | $hash = 'invalid_email'; |
| 404 | 400 | } |
@@ -406,32 +402,25 @@ discard block |
||
| 406 | 402 | $query_string = NULL; |
| 407 | 403 | $options = array(); |
| 408 | 404 | |
| 409 | - if ($rating !== NULL) |
|
| 410 | - { |
|
| 405 | + if ($rating !== NULL) { |
|
| 411 | 406 | $options['r'] = $rating; |
| 412 | 407 | } |
| 413 | 408 | |
| 414 | - if ($size !== NULL) |
|
| 415 | - { |
|
| 409 | + if ($size !== NULL) { |
|
| 416 | 410 | $options['s'] = $size; |
| 417 | 411 | } |
| 418 | 412 | |
| 419 | - if ($default_image !== NULL) |
|
| 420 | - { |
|
| 413 | + if ($default_image !== NULL) { |
|
| 421 | 414 | $options['d'] = urlencode($default_image); |
| 422 | 415 | } |
| 423 | 416 | |
| 424 | - if (count($options) > 0) |
|
| 425 | - { |
|
| 417 | + if (count($options) > 0) { |
|
| 426 | 418 | $query_string = '?'. http_build_query($options); |
| 427 | 419 | } |
| 428 | 420 | |
| 429 | - if ($secure !== NULL) |
|
| 430 | - { |
|
| 421 | + if ($secure !== NULL) { |
|
| 431 | 422 | $base = $this->gravatar_secure_base_url; |
| 432 | - } |
|
| 433 | - else |
|
| 434 | - { |
|
| 423 | + } else { |
|
| 435 | 424 | $base = $this->gravatar_base_url; |
| 436 | 425 | } |
| 437 | 426 | |
@@ -448,32 +437,26 @@ discard block |
||
| 448 | 437 | * |
| 449 | 438 | * @deprecated |
| 450 | 439 | */ |
| 451 | - public function get_profile($email, $fetch_method = 'file') |
|
| 452 | - { |
|
| 440 | + public function get_profile($email, $fetch_method = 'file') { |
|
| 453 | 441 | $hash = $this->set_email($email); |
| 454 | 442 | |
| 455 | - if ($hash === NULL) |
|
| 456 | - { |
|
| 443 | + if ($hash === NULL) { |
|
| 457 | 444 | // A hash value of NULL will return no xml so the method returns NULL |
| 458 | 445 | return NULL; |
| 459 | 446 | } |
| 460 | 447 | |
| 461 | 448 | libxml_use_internal_errors(TRUE); |
| 462 | 449 | |
| 463 | - if ($fetch_method === 'file') |
|
| 464 | - { |
|
| 465 | - if (ini_get('allow_url_fopen') == FALSE) |
|
| 466 | - { |
|
| 450 | + if ($fetch_method === 'file') { |
|
| 451 | + if (ini_get('allow_url_fopen') == FALSE) { |
|
| 467 | 452 | return NULL; |
| 468 | 453 | } |
| 469 | 454 | |
| 470 | 455 | $str = file_get_contents($this->gravatar_base_url . $hash .'.xml'); |
| 471 | 456 | } |
| 472 | 457 | |
| 473 | - if ($fetch_method === 'curl') |
|
| 474 | - { |
|
| 475 | - if ( ! function_exists('curl_init')) |
|
| 476 | - { |
|
| 458 | + if ($fetch_method === 'curl') { |
|
| 459 | + if ( ! function_exists('curl_init')) { |
|
| 477 | 460 | return NULL; |
| 478 | 461 | } |
| 479 | 462 | |
@@ -490,18 +473,14 @@ discard block |
||
| 490 | 473 | |
| 491 | 474 | $xml = simplexml_load_string($str); |
| 492 | 475 | |
| 493 | - if ($xml === FALSE) |
|
| 494 | - { |
|
| 476 | + if ($xml === FALSE) { |
|
| 495 | 477 | $errors = array(); |
| 496 | - foreach(libxml_get_errors() as $error) |
|
| 497 | - { |
|
| 478 | + foreach(libxml_get_errors() as $error) { |
|
| 498 | 479 | $errors[] = $error->message.'\n'; |
| 499 | 480 | } |
| 500 | 481 | $error_string = implode('\n', $errors); |
| 501 | 482 | throw new Exception('Failed loading XML\n'. $error_string); |
| 502 | - } |
|
| 503 | - else |
|
| 504 | - { |
|
| 483 | + } else { |
|
| 505 | 484 | return $xml->entry; |
| 506 | 485 | } |
| 507 | 486 | } |
@@ -1,4 +1,6 @@ |
||
| 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: Auth Lang - English |
| 4 | 6 | * |
@@ -1,4 +1,6 @@ |
||
| 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: Auth Lang - English |
| 4 | 6 | * |
@@ -1,4 +1,6 @@ |
||
| 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: Auth Lang - English |
| 4 | 6 | * |
@@ -1,4 +1,6 @@ |
||
| 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: Auth Lang - Slovenian |
| 4 | 6 | * |
@@ -1,4 +1,6 @@ |
||
| 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: Auth Lang - English |
| 4 | 6 | * |