Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change library count_rows() #3

Open
heyder777 opened this issue Dec 27, 2022 · 0 comments
Open

change library count_rows() #3

heyder777 opened this issue Dec 27, 2022 · 0 comments

Comments

@heyder777
Copy link

public function throttle($type = 0, $limit = 10, $timeout = 30)
{
    //clean up login attempts older than specified time
    $this->throttle_cleanup($timeout, $type, $timeout);

    $data = new stdClass();
    $data->ip = $this->CI->input->ip_address();
    $data->type = $type;

    $this->CI->throttle_model->insert($data);
    $attempts = $this->CI->throttle_model->where(['ip' => $this->CI->input->ip_address(), 'type' => $type])->count_rows();

    if ($attempts > $limit) {
        show_error('Too many attempts. Try back after ' . $timeout . ' minutes.', 503, 'Attempt failed');
    }

    return $attempts; // return current number of attempted logins
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant