Bug fixes
This commit is contained in:
parent
a82243939f
commit
1f0e439b3d
@ -24,7 +24,7 @@
|
||||
}
|
||||
|
||||
echo '<tr>';
|
||||
echo '<td>'.($Page->parentKey()?NO_PARENT_CHAR:'').'<a href="'.HTML_PATH_ADMIN_ROOT.'edit-page/'.$Page->key().'">'.($Page->published()?'':'['.$Language->g('Draft').'] ').($Page->title()?$Page->title():'['.$Language->g('Empty title').'] ').'</a></td>';
|
||||
echo '<td>'.($Page->parentKey()?NO_PARENT_CHAR:'').'<a href="'.HTML_PATH_ADMIN_ROOT.'edit-page/'.$Page->key().'">'.($Page->published()?'':'<span class="label label-outline label-red smaller">'.$Language->g('Draft').'</span> ').($Page->title()?$Page->title():'<span class="label label-outline label-blue smaller">'.$Language->g('Empty title').'</span> ').'</a></td>';
|
||||
echo '<td>'.$parentTitle.'</td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
|
@ -16,7 +16,7 @@
|
||||
foreach($posts as $Post)
|
||||
{
|
||||
echo '<tr>';
|
||||
echo '<td><a href="'.HTML_PATH_ADMIN_ROOT.'edit-post/'.$Post->key().'">'.($Post->published()?'':'<span class="label label-outline label-red smaller">'.$Language->g('Draft').'</span> ').($Post->title()?$Post->title():'['.$Language->g('Empty title').'] ').'</a></td>';
|
||||
echo '<td><a href="'.HTML_PATH_ADMIN_ROOT.'edit-post/'.$Post->key().'">'.($Post->published()?'':'<span class="label label-outline label-red smaller">'.$Language->g('Draft').'</span> ').($Post->title()?$Post->title():'<span class="label label-outline label-blue smaller">'.$Language->g('Empty title').'</span> ').'</a></td>';
|
||||
echo '<td>'.$Post->dateCreated().'</td>';
|
||||
echo '<td>'.$Post->timeago().'</td>';
|
||||
echo '</tr>';
|
||||
|
@ -3,12 +3,12 @@
|
||||
<?php
|
||||
foreach($themes as $theme)
|
||||
{
|
||||
$installed = '';
|
||||
$installedCSS = '';
|
||||
if($theme['dirname']==$Site->theme()) {
|
||||
$installed = 'themeBoxInstalled';
|
||||
$installedCSS = 'themeBoxInstalled';
|
||||
}
|
||||
|
||||
echo '<div class="themeBox '.$installed.'">';
|
||||
echo '<div class="themeBox '.$installedCSS.'">';
|
||||
|
||||
echo '<p class="name">'.$theme['name'].'</p>';
|
||||
echo '<p>'.$theme['description'].'</p>';
|
||||
|
@ -22,7 +22,7 @@
|
||||
echo '<td><a href="'.HTML_PATH_ADMIN_ROOT.'edit-user/'.$username.'">'.$username.'</a></td>';
|
||||
echo '<td>'.$field['firstName'].'</td>';
|
||||
echo '<td>'.$field['lastName'].'</td>';
|
||||
echo '<td>'.$field['role'].'</td>';
|
||||
echo '<td>a'.$field['role'].'</td>';
|
||||
echo '<td>'.$field['email'].'</td>';
|
||||
echo '<td>'.Date::format($field['registered'], '%d %B').'</td>';
|
||||
echo '</tr>';
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user