2 namespace wcf\data\user\authentication\failure
;
3 use wcf\data\DatabaseObject
;
8 * Represents a user authentication failure.
11 * @copyright 2001-2014 WoltLab GmbH
12 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
13 * @package com.woltlab.wcf
14 * @subpackage data.user.authentication.failure
15 * @category Community Framework
17 class UserAuthenticationFailure
extends DatabaseObject
{
19 * @see \wcf\data\DatabaseObject::$databaseTableName
21 protected static $databaseTableName = 'user_authentication_failure';
24 * @see \wcf\data\DatabaseObject::$databaseTableIndexName
26 protected static $databaseTableIndexName = 'failureID';
29 * Returns the ip address and attempts to convert into IPv4.
33 public function getIpAddress() {
34 return UserUtil
::convertIPv6To4($this->ipAddress
);
38 * Returns the number of authentication failures caused by given ip address.
40 * @param string $ipAddress
43 public static function countIPFailures($ipAddress) {
44 $sql = "SELECT COUNT(*) AS count
45 FROM wcf".WCF_N
."_user_authentication_failure
48 $statement = WCF
::getDB()->prepareStatement($sql);
49 $statement->execute(array($ipAddress, TIME_NOW
- USER_AUTHENTICATION_FAILURE_TIMEOUT
));
50 return $statement->fetchColumn();
54 * Returns the number of authentication failures for given user account.
56 * @param integer $userID
59 public static function countUserFailures($userID) {
60 $sql = "SELECT COUNT(*) AS count
61 FROM wcf".WCF_N
."_user_authentication_failure
64 $statement = WCF
::getDB()->prepareStatement($sql);
65 $statement->execute(array($userID, TIME_NOW
- USER_AUTHENTICATION_FAILURE_TIMEOUT
));
66 return $statement->fetchColumn();