Phpauth\Auth::deleteAttempts PHP Method

deleteAttempts() protected method

Deletes all attempts for a given IP from database
protected deleteAttempts ( string $ip, boolean $all = false ) : boolean
$ip string
$all boolean = false
return boolean
    protected function deleteAttempts($ip, $all = false)
    {
        if ($all == true) {
            $query = $this->dbh->prepare("DELETE FROM {$this->config->table_attempts} WHERE ip = ?");
            return $query->execute(array($ip));
        }
        $query = $this->dbh->prepare("SELECT id, expiredate FROM {$this->config->table_attempts} WHERE ip = ?");
        $query->execute(array($ip));
        while ($row = $query->fetch(\PDO::FETCH_ASSOC)) {
            $expiredate = strtotime($row['expiredate']);
            $currentdate = strtotime(date("Y-m-d H:i:s"));
            if ($currentdate > $expiredate) {
                $queryDel = $this->dbh->prepare("DELETE FROM {$this->config->table_attempts} WHERE id = ?");
                $queryDel->execute(array($row['id']));
            }
        }
    }