Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function authenticate_user( $username, $password )
- {
- $CI = &get_instance();
- $accounts_table = $CI->config->item('accounts_table');
- $salt = $CI->db->select('salt')->from($accounts_table)->where('username', $username)->limit(1)->get()->result->row(0)->salt;
- if ( !$salt OR empty($salt) )
- {
- return false;
- }
- $password = apply_salt($password, $salt);
- $where = array(
- 'username' => $username,
- 'password' => $password
- );
- $results = $CI->db->get_where( $accounts_table, $where, 1 );
- if ( $results )
- {
- $user = $results->row(0);
- if ( $user->lockout_time != 0 )
- {
- $lockout_expire = $CI->config->item('login_lockout_expire');
- if ( time() - strtotime($user->lockout_time) >= $lockout_expire )
- {
- return array( 'user_id' => $user->user_id, 'activated' => $user->activated, 'locked' => !unlock_account($user->user_id) );
- }
- else
- {
- return array( 'user_id' => $user->user_id, 'locked', 'locked' => true );
- }
- }
- if ( $user->activated != 1 )
- {
- return array( 'user_id' => $user->user_id, 'activated' => $user->activated );
- }
- return $user->user_id;
- }
- return false;
- }
Add Comment
Please, Sign In to add comment