Welcome Guest, Not a member yet? Register   Sign In
Checking lock date
#1

[eluser]xtremer360[/eluser]
For some reason the test to see if if the current_time variable is bigger or smaller than the time to login is not right for some reason. I'm not sure what I'm missing. The lock_date property of the $user_data object stands for the exact datetime that the user made its last failed login attempt. So its always continuing on with the code and by passing with the rest of the submit function.

I thought about switching the great than sign in the if statement when comparing the two times but with those two I didn't think it would make sense.

Code:
$current_time = now();
$current_gmt_human_format = unix_to_human($current_time, TRUE, 'us');

/* Get user data from post username value */
$user_data = $this->users_model->get_by('username', $post_username);

if (count($user_data) > 0)
{
    /* User was found in database */

    if ($user_data->lock_date !== '0000-00-00 00:00:00')
    {
        /* User is locked out */

        /* How long the user must wait to login */
        $wait_time = 60 * 15;

        /* Time user is able to login */
        $time_to_login = human_to_unix($user_data->lock_date) + $wait_time;

        //echo 'current time is...' . $current_time;
        //echo '<br>';
        //echo 'time to login is...' . $time_to_login;
        //die();

        if ($current_time < $time_to_login)
        {
        }
    }
}

As per the request here is the data I have.

Code:
current readable format is...2013-05-23 08:03:44 PM
current time is...1369353824
user lock out...1369310405
wait time is...900
time to login is...1369311305

#2

[eluser]TheFuzzy0ne[/eluser]
I don't understand your application flow, but I do suggest you consider either storing your lockout date in the database as an integer, or converting it to an integer before doing any comparisons on it. It just makes things easier.

I'm not quite sure what the problem is, and I didn't really understand your explanation. However, I'm quite sure that this can be debugged quite easily. You can either use a debugger, or you can just add some die() lines or echoes to compare values to ensure they are what you're expecting them to be.




Theme © iAndrew 2016 - Forum software by © MyBB