forked from ZwiiCMS-Team/ZwiiCMS
10.2 Optimisation script protection login + journalisation IP
This commit is contained in:
parent
ff4d03c18a
commit
9579315407
@ -17,6 +17,27 @@ class helper {
|
|||||||
const FILTER_TIMESTAMP = 10;
|
const FILTER_TIMESTAMP = 10;
|
||||||
const FILTER_URL = 11;
|
const FILTER_URL = 11;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Récupérer l'adresse IP sans tenit compte du proxy
|
||||||
|
* @return string IP adress
|
||||||
|
* Cette focntion est utilisé par user
|
||||||
|
*/
|
||||||
|
|
||||||
|
public static function getIp() {
|
||||||
|
if(!empty($_SERVER['HTTP_CLIENT_IP'])){
|
||||||
|
$ip=$_SERVER['HTTP_CLIENT_IP'];
|
||||||
|
}
|
||||||
|
elseif(!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){
|
||||||
|
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$ip=$_SERVER['REMOTE_ADDR'];
|
||||||
|
}
|
||||||
|
return $ip;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fonction pour récupérer le numéro de version en ligne
|
* Fonction pour récupérer le numéro de version en ligne
|
||||||
* @param string $url à récupérer
|
* @param string $url à récupérer
|
||||||
|
@ -225,7 +225,7 @@ core.start = function() {
|
|||||||
if(document.cookie.indexOf("ZWII_COOKIE_CONSENT") === -1) {
|
if(document.cookie.indexOf("ZWII_COOKIE_CONSENT") === -1) {
|
||||||
$("body").append(
|
$("body").append(
|
||||||
$("<div>").attr("id", "cookieConsent").append(
|
$("<div>").attr("id", "cookieConsent").append(
|
||||||
$("<span>").text("En poursuivant votre navigation sur ce site, vous acceptez l'utilisation de cookies."),
|
$("<span>").text("En poursuivant votre navigation sur ce site, vous acceptez l'utilisation de cookies et de vos données de visite."),
|
||||||
$("<span>")
|
$("<span>")
|
||||||
.attr("id", "cookieConsentConfirm")
|
.attr("id", "cookieConsentConfirm")
|
||||||
.text("OK")
|
.text("OK")
|
||||||
|
@ -1331,7 +1331,7 @@ class common {
|
|||||||
unlink(self::DATA_DIR . 'theme.css');
|
unlink(self::DATA_DIR . 'theme.css');
|
||||||
}
|
}
|
||||||
// Créer les en-têtes du journal
|
// Créer les en-têtes du journal
|
||||||
$d = 'Date;Heure;Id;Action' . PHP_EOL;
|
$d = 'Date;Heure;IP;Id;Action' . PHP_EOL;
|
||||||
file_put_contents(self::DATA_DIR . 'journal.log',$d);
|
file_put_contents(self::DATA_DIR . 'journal.log',$d);
|
||||||
// Init préservation htaccess
|
// Init préservation htaccess
|
||||||
$this->setData(['config','autoUpdateHtaccess',false]);
|
$this->setData(['config','autoUpdateHtaccess',false]);
|
||||||
@ -1352,7 +1352,6 @@ class common {
|
|||||||
$this->setData(['theme','menu','memberBar',true]);
|
$this->setData(['theme','menu','memberBar',true]);
|
||||||
$this->deleteData(['theme','footer','displayMemberAccount']);
|
$this->deleteData(['theme','footer','displayMemberAccount']);
|
||||||
$this->deleteData(['theme','footer','displayMemberLogout']);
|
$this->deleteData(['theme','footer','displayMemberLogout']);
|
||||||
|
|
||||||
$this->setData(['core', 'dataVersion', 10201]);
|
$this->setData(['core', 'dataVersion', 10201]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1634,6 +1633,7 @@ class core extends common {
|
|||||||
}
|
}
|
||||||
// Journalisation
|
// Journalisation
|
||||||
$dataLog = strftime('%d/%m/%y',time()) . ';' . strftime('%R',time()) . ';' ;
|
$dataLog = strftime('%d/%m/%y',time()) . ';' . strftime('%R',time()) . ';' ;
|
||||||
|
$dataLog .= helper::getIp() . ';';
|
||||||
$dataLog .= $this->getUser('id') ? $this->getUser('id') . ';' : 'anonyme' . ';';
|
$dataLog .= $this->getUser('id') ? $this->getUser('id') . ';' : 'anonyme' . ';';
|
||||||
$dataLog .= $this->getUrl();
|
$dataLog .= $this->getUrl();
|
||||||
$dataLog .= PHP_EOL;
|
$dataLog .= PHP_EOL;
|
||||||
|
@ -612,7 +612,7 @@ class config extends common {
|
|||||||
if ( file_exists(self::DATA_DIR . 'journal.log') ) {
|
if ( file_exists(self::DATA_DIR . 'journal.log') ) {
|
||||||
unlink(self::DATA_DIR . 'journal.log');
|
unlink(self::DATA_DIR . 'journal.log');
|
||||||
// Créer les en-têtes des journaux
|
// Créer les en-têtes des journaux
|
||||||
$d = 'Date;Heure;Id;Action' . PHP_EOL;
|
$d = 'Date;Heure;IP;Id;Action' . PHP_EOL;
|
||||||
file_put_contents(self::DATA_DIR . 'journal.log',$d);
|
file_put_contents(self::DATA_DIR . 'journal.log',$d);
|
||||||
// Valeurs en sortie
|
// Valeurs en sortie
|
||||||
$this->addOutput([
|
$this->addOutput([
|
||||||
|
@ -349,18 +349,25 @@ class user extends common {
|
|||||||
[
|
[
|
||||||
'connectFail' => $this->getData(['blacklist',$userId,'connectFail']) + 1,
|
'connectFail' => $this->getData(['blacklist',$userId,'connectFail']) + 1,
|
||||||
'lastFail' => time(),
|
'lastFail' => time(),
|
||||||
'ip' => $_SERVER['REMOTE_ADDR']
|
'ip' => helper::getIp()
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
if ( $this->getData(['blacklist',$userId,'connectFail']) >= $this->getData(['config', 'connect', 'attempt']) ) {
|
// Verrouillage des IP
|
||||||
$notification = 'Trop de tentatives, compte verrouillé';
|
$ipBlackList = helper::arrayCollumn($this->getData(['blacklist']), 'ip');
|
||||||
|
if ( $this->getData(['blacklist',$userId,'connectFail']) >= $this->getData(['config', 'connect', 'attempt'])
|
||||||
|
OR in_array($this->getData(['blacklist',$userId,'ip']),$ipBlackList) ) {
|
||||||
|
// Valeurs en sortie
|
||||||
|
$this->addOutput([
|
||||||
|
'notification' => 'Trop de tentatives, compte verrouillé',
|
||||||
|
'redirect' => helper::baseUrl(),
|
||||||
|
'state' => false
|
||||||
|
]);
|
||||||
} else {
|
} else {
|
||||||
$notification = 'Identifiant ou mot de passe incorrect';
|
// Valeurs en sortie
|
||||||
|
$this->addOutput([
|
||||||
|
'notification' => 'Identifiant ou mot de passe incorrect'
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
// Valeurs en sortie
|
|
||||||
$this->addOutput([
|
|
||||||
'notification' => $notification
|
|
||||||
]);
|
|
||||||
/**
|
/**
|
||||||
* Le compte existe
|
* Le compte existe
|
||||||
*/
|
*/
|
||||||
@ -419,6 +426,7 @@ class user extends common {
|
|||||||
}
|
}
|
||||||
// Journalisation
|
// Journalisation
|
||||||
$dataLog = strftime('%d/%m/%y',time()) . ';' . strftime('%R',time()) . ';' ;
|
$dataLog = strftime('%d/%m/%y',time()) . ';' . strftime('%R',time()) . ';' ;
|
||||||
|
$dataLog .= helper::getIp() . ';';
|
||||||
$dataLog .= $userId . ';' ;
|
$dataLog .= $userId . ';' ;
|
||||||
$dataLog .= $this->getUrl() .';' ;
|
$dataLog .= $this->getUrl() .';' ;
|
||||||
$dataLog .= 'échec de connexion' ;
|
$dataLog .= 'échec de connexion' ;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user