class.bruteForceMapper.php

Gesponsorde koppelingen

PHP script bestanden

  1. index.php
  2. class.user.php
  3. login.php
  4. phphulp.sql
  5. class.userMapper.php
  6. class.bruteForce.php
  7. class.bruteForceMapper.php
  8. class.database.php
  9. class.dataMapper.php
  10. class.hash.php

« Lees de omschrijving en reacties

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php

/**
 *
 * @date 15 Aug 2012,
 * @package Login System
 *
 */

Class BruteForceMapper extends DataMapper {

    /**
     * @param object $bruteforce,
     * @return mixed                    -> bool when failing, otherwishe array
     */

    public function getByUsername(BruteForce $bruteforce, $fields = '*') {
        $this->pdo->query("SELECT ".$fields." FROM brute_force WHERE insert_datetime >= NOW() - INTERVAL :attempts_time MINUTE AND username = :username GROUP BY username, ip HAVING (COUNT(username) >= :max_attempts)", array(':username' => $bruteforce->getUsername(), ':attempts_time' => $bruteforce->getTimeout(), ':max_attempts' => $bruteforce->getMaxAttempts()));
        return $this->pdo->fetchAll();
    }

    
    /**
     * @param object $bruteforce,
     * @return mixed
     */

    public function getByIp(Bruteforce $bruteforce, $fields = '*') {
        $this->pdo->query("SELECT ".$fields." FROM brute_force WHERE insert_datetime >= NOW() - INTERVAL :attempts_time MINUTE AND ip = :ip GROUP BY username, ip HAVING (COUNT(username) >= :max_attempts)", array(':ip' => $bruteforce->getIp(), ':attempts_time' => $bruteforce->getTimeout(), ':max_attempts' => $bruteforce->getMaxAttempts()));
        return $this->pdo->fetchAll();
    }


    /**
     * @param object $bruteforce,
     * @return bool true/false
     */

    public function insert(BruteForce $bruteforce) {
        return $this->pdo->query("INSERT INTO brute_force SET username = :username, ip = :ip, insert_datetime = NOW()", array(':username' => $bruteforce->getUsername(), ':ip' => $bruteforce->getIp()));
    }

    
    /**
     * @param object $bruteforce,
     * @return bool true/false
     */

    public function deleteByTime(BruteForce $bruteforce) {
        return $this->pdo->query("DELETE FROM brute_force WHERE insert_datetime < :insert_datetime", array(':insert_datetime' => date('Y-m-d H:i:s', time() - $bruteforce->getTimeout() * 60)));
    }
    
}


?>

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.