-1

I changed my default time zone in my php.ini from Europe/Berlin to another time zone and suddenly my login throttling lockout count down got mixed up it is showing the remaining 15 minutes in seconds but it is counting up instead of counting down , please help me fix it.

Code for throttling:

<?php
$throttle = array(1 => 1, 10 => 2, 1000 => 'captcha');
$getfailedq = 'SELECT MAX(attempted) AS attempted FROM failed_logins';
$getfailed = $muc->prepare($getfailedq);
$getfailed->bindParam(1, $attempted);
$getfailed->execute();
if ($getfailed->rowCount() > 0) {
    $row = $getfailed->fetch(PDO::FETCH_ASSOC);
    $latest_attempt = (int) date('U', strtotime($row['attempted']));
    $getfailedq = 'SELECT Count(*) AS failed FROM failed_logins WHERE attempted > Date_sub(Now(), INTERVAL 15 minute)';
    $getfailed = $muc->prepare($getfailedq);
    $getfailed->bindParam(1, $attempted);
    $getfailed->execute();
    if ($getfailed->rowCount() > 0) {
        $row = $getfailed->fetch(PDO::FETCH_ASSOC);
        $failed_attempts = (int) $row['failed'];
        krsort($throttle);
        foreach ($throttle as $attempts => $delay) {
            if ($failed_attempts > $attempts) {
                if (is_numeric($delay)) {
                    $remaining_delay = time() - $latest_attempt + $delay;
                    echo 'You must wait ' . $remaining_delay . ' seconds before your next login attempt';
                } else {
                    echo "captcha";
                }
                break;
            }
        }        
    }
}
?>
Serjio
  • 209
  • 2
  • 10
  • -1 for "show me teh codez". Please read [How do I ask a good question?](http://stackoverflow.com/help/how-to-ask) and provide a [Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve) – Matt Johnson-Pint Apr 27 '16 at 17:41
  • You could just give a heads up and not a down vote I am new here and not an expert, what do you expect? – Serjio Apr 27 '16 at 17:42
  • 1
    It's a legitimate reason for downvoting. If you edit your question to fit the site guidelines, I'll be happy to reverse my vote. As far as expectations, please visit the [help center](http://stackoverflow.com/help). Take the tour, and read more about how the site works before asking. Thanks. – Matt Johnson-Pint Apr 27 '16 at 17:45
  • What exactly do you mean by "some seemingly random numbers"? Please describe what you expect to see (and why) and what you actually see. – Jon Skeet Apr 28 '16 at 06:00
  • @JonSkeet, I will edit the code now. – Serjio Apr 28 '16 at 07:08

1 Answers1

0

Maybe your database is still in Europe/Berlin.

Try editing you my.cnf, add this

default_time_zone=TIMEZONE

William Perron
  • 485
  • 7
  • 16
  • I dont have a file called my.cnf, and no my timezone is not on Europe at all and I restarted xampp but no difference – Serjio Apr 27 '16 at 16:08
  • my.cnf is mysql configuration. Can you check what is your database timezone?: `SELECT @@global.time_zone, @@session.time_zone;` You should see **SYSTEM**. – William Perron Apr 27 '16 at 17:17