equal
deleted
inserted
replaced
575 { |
575 { |
576 $ipaddr = $db->escape($_SERVER['REMOTE_ADDR']); |
576 $ipaddr = $db->escape($_SERVER['REMOTE_ADDR']); |
577 $timestamp_cutoff = time() - $duration; |
577 $timestamp_cutoff = time() - $duration; |
578 $q = $this->sql('SELECT timestamp FROM '.table_prefix.'lockout WHERE timestamp > ' . $timestamp_cutoff . ' AND ipaddr = \'' . $ipaddr . '\' ORDER BY timestamp DESC;'); |
578 $q = $this->sql('SELECT timestamp FROM '.table_prefix.'lockout WHERE timestamp > ' . $timestamp_cutoff . ' AND ipaddr = \'' . $ipaddr . '\' ORDER BY timestamp DESC;'); |
579 $fails = $db->numrows(); |
579 $fails = $db->numrows(); |
580 if ( $fails > $threshold ) |
580 if ( $fails >= $threshold ) |
581 { |
581 { |
582 // ooh boy, somebody's in trouble ;-) |
582 // ooh boy, somebody's in trouble ;-) |
583 $row = $db->fetchrow(); |
583 $row = $db->fetchrow(); |
584 $db->free_result(); |
584 $db->free_result(); |
585 return array( |
585 return array( |
587 'error' => 'locked_out', |
587 'error' => 'locked_out', |
588 'lockout_threshold' => $threshold, |
588 'lockout_threshold' => $threshold, |
589 'lockout_duration' => ( $duration / 60 ), |
589 'lockout_duration' => ( $duration / 60 ), |
590 'lockout_fails' => $fails, |
590 'lockout_fails' => $fails, |
591 'lockout_policy' => $policy, |
591 'lockout_policy' => $policy, |
|
592 'time_rem' => ( $duration / 60 ) - round( ( time() - $row['timestamp'] ) / 60 ), |
592 'lockout_last_time' => $row['timestamp'] |
593 'lockout_last_time' => $row['timestamp'] |
593 ); |
594 ); |
594 } |
595 } |
595 $db->free_result(); |
596 $db->free_result(); |
596 } |
597 } |
648 'success' => false, |
649 'success' => false, |
649 'error' => ( $fails >= $threshold ) ? 'locked_out' : 'invalid_credentials', |
650 'error' => ( $fails >= $threshold ) ? 'locked_out' : 'invalid_credentials', |
650 'lockout_threshold' => $threshold, |
651 'lockout_threshold' => $threshold, |
651 'lockout_duration' => ( $duration / 60 ), |
652 'lockout_duration' => ( $duration / 60 ), |
652 'lockout_fails' => $fails, |
653 'lockout_fails' => $fails, |
|
654 'time_rem' => ( $duration / 60 ), |
653 'lockout_policy' => $policy |
655 'lockout_policy' => $policy |
654 ); |
656 ); |
655 } |
657 } |
656 |
658 |
657 return array( |
659 return array( |
759 'success' => false, |
761 'success' => false, |
760 'error' => ( $fails >= $threshold ) ? 'locked_out' : 'invalid_credentials', |
762 'error' => ( $fails >= $threshold ) ? 'locked_out' : 'invalid_credentials', |
761 'lockout_threshold' => $threshold, |
763 'lockout_threshold' => $threshold, |
762 'lockout_duration' => ( $duration / 60 ), |
764 'lockout_duration' => ( $duration / 60 ), |
763 'lockout_fails' => $fails, |
765 'lockout_fails' => $fails, |
|
766 'time_rem' => ( $duration / 60 ), |
764 'lockout_policy' => $policy |
767 'lockout_policy' => $policy |
765 ); |
768 ); |
766 } |
769 } |
767 |
770 |
768 return array( |
771 return array( |
823 'error' => 'locked_out', |
826 'error' => 'locked_out', |
824 'lockout_threshold' => $threshold, |
827 'lockout_threshold' => $threshold, |
825 'lockout_duration' => ( $duration / 60 ), |
828 'lockout_duration' => ( $duration / 60 ), |
826 'lockout_fails' => $fails, |
829 'lockout_fails' => $fails, |
827 'lockout_policy' => $policy, |
830 'lockout_policy' => $policy, |
|
831 'time_rem' => $duration - round( ( time() - $row['timestamp'] ) / 60 ), |
828 'lockout_last_time' => $row['timestamp'] |
832 'lockout_last_time' => $row['timestamp'] |
829 ); |
833 ); |
830 } |
834 } |
831 $db->free_result(); |
835 $db->free_result(); |
832 } |
836 } |