';
echo '
'.$theme['name'].'
';
echo '
'.$theme['description'].'
';
diff --git a/admin/views/users.php b/admin/views/users.php
index 6f9a4ac9..da6f4634 100644
--- a/admin/views/users.php
+++ b/admin/views/users.php
@@ -22,7 +22,7 @@
echo '
'.$username.' | ';
echo '
'.$field['firstName'].' | ';
echo '
'.$field['lastName'].' | ';
- echo '
'.$field['role'].' | ';
+ echo '
a'.$field['role'].' | ';
echo '
'.$field['email'].' | ';
echo '
'.Date::format($field['registered'], '%d %B').' | ';
echo '';
diff --git a/kernel/security.class.php b/kernel/security.class.php
index 90a7e38c..c4ac5a34 100644
--- a/kernel/security.class.php
+++ b/kernel/security.class.php
@@ -4,7 +4,8 @@ class Security extends dbJSON
{
private $dbFields = array(
'minutesBlocked'=>5,
- 'numberFailures'=>10
+ 'numberFailuresAllowed'=>10,
+ 'blackList'=>array('numberFailures', 'lastFailure')
);
function __construct()
@@ -12,14 +13,47 @@ class Security extends dbJSON
parent::__construct(PATH_DATABASES.'security.php');
}
+ public function isBlocked()
+ {
+ $ip = $this->getUserIp();
+ if(!isset($this->db['blackList'][$ip])) {
+ return false;
+ }
+
+ $currentTime = time();
+ $userBlack = $this->db['blackList'][$ip];
+ $numberFailures = $userBlack['numberFailures'];
+ $lastFailure = $userBlack['lastFailure'];
+
+ // Check if the IP is expired, then is not blocked.
+ if($currentTime > $lastFailure + $this->db['minutesBlocked']) {
+ return false;
+ }
+
+ // The IP has more failures than number of failures, then the IP is blocked.
+ if($numberFailures >= $this->db['numberFailuresAllowed']) {
+ return true;
+ }
+
+ // Otherwise the IP is not blocked.
+ return false;
+ }
public function addLoginFail()
{
$ip = $this->getUserIp();
+ $currentTime = time();
+ $numberFailures = 1;
+
+ if(isset($this->db['blackList'][$ip])) {
+ $numberFailures = $userBlack['numberFailures'];
+ $numberFailures = $numberFailures + 1;
+ }
+
+ $this->db['blackList'][$ip] = array('lastFailure'=>$currentTime, 'numberFailures'=>$numberFailures);
// Save the database
- $this->db[$ip] = (int)$this->db[$ip] + 1;
if( $this->save() === false ) {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to save the database file.');
return false;