equal
deleted
inserted
replaced
656 return $this->login_compat($username, md5($password), $level); |
656 return $this->login_compat($username, md5($password), $level); |
657 } |
657 } |
658 |
658 |
659 if ( !defined('IN_ENANO_INSTALL') ) |
659 if ( !defined('IN_ENANO_INSTALL') ) |
660 { |
660 { |
661 $locked_out = $this->get_lockout_info($lockout_data); |
661 $lockout_data = $this->get_lockout_info($lockout_data); |
662 |
662 |
663 $captcha_good = false; |
663 $captcha_good = false; |
664 if ( $lockout_data['lockout_policy'] == 'captcha' && $captcha_hash && $captcha_code ) |
664 if ( $lockout_data['lockout_policy'] == 'captcha' && $captcha_hash && $captcha_code ) |
665 { |
665 { |
666 // policy is captcha -- check if it's correct, and if so, bypass lockout check |
666 // policy is captcha -- check if it's correct, and if so, bypass lockout check |
1028 if ( $policy != 'disable' ) |
1028 if ( $policy != 'disable' ) |
1029 { |
1029 { |
1030 $ipaddr = $db->escape($_SERVER['REMOTE_ADDR']); |
1030 $ipaddr = $db->escape($_SERVER['REMOTE_ADDR']); |
1031 $timestamp_cutoff = time() - $duration; |
1031 $timestamp_cutoff = time() - $duration; |
1032 $q = $this->sql('SELECT timestamp FROM ' . table_prefix . 'lockout WHERE timestamp > ' . $timestamp_cutoff . ' AND ipaddr = \'' . $ipaddr . '\' ORDER BY timestamp DESC;'); |
1032 $q = $this->sql('SELECT timestamp FROM ' . table_prefix . 'lockout WHERE timestamp > ' . $timestamp_cutoff . ' AND ipaddr = \'' . $ipaddr . '\' ORDER BY timestamp DESC;'); |
1033 $fails = $db->numrows(); |
1033 $fails = $db->numrows($q); |
1034 $row = $db->fetchrow(); |
1034 $row = $db->fetchrow($q); |
1035 $locked_out = ( $fails >= $threshold ); |
1035 $locked_out = ( $fails >= $threshold ); |
1036 $lockdata = array( |
1036 $lockdata = array( |
1037 'locked_out' => $locked_out, |
1037 'locked_out' => $locked_out, |
1038 'lockout_threshold' => $threshold, |
1038 'lockout_threshold' => $threshold, |
1039 'lockout_duration' => ( $duration / 60 ), |
1039 'lockout_duration' => ( $duration / 60 ), |
1043 'time_rem' => ( $duration / 60 ) - round( ( time() - $row['timestamp'] ) / 60 ), |
1043 'time_rem' => ( $duration / 60 ) - round( ( time() - $row['timestamp'] ) / 60 ), |
1044 'captcha' => '' |
1044 'captcha' => '' |
1045 ); |
1045 ); |
1046 $db->free_result(); |
1046 $db->free_result(); |
1047 } |
1047 } |
1048 return $locked_out; |
1048 else |
|
1049 { |
|
1050 $lockdata = array( |
|
1051 'locked_out' => false, |
|
1052 'lockout_threshold' => $threshold, |
|
1053 'lockout_duration' => ( $duration / 60 ), |
|
1054 'lockout_fails' => 0, |
|
1055 'lockout_policy' => $policy, |
|
1056 'lockout_last_time' => 0, |
|
1057 'time_rem' => 0, |
|
1058 'captcha' => '' |
|
1059 ); |
|
1060 } |
|
1061 return $lockdata; |
1049 } |
1062 } |
1050 |
1063 |
1051 /** |
1064 /** |
1052 * Creates/restores a guest session |
1065 * Creates/restores a guest session |
1053 * @todo implement real session management for guests |
1066 * @todo implement real session management for guests |