captcha 10 ou 20

This commit is contained in:
Fred Tempez 2020-10-11 19:29:33 +02:00
parent f0fe2c0177
commit 26841c795c
7 changed files with 124 additions and 104 deletions

View File

@ -46,13 +46,15 @@ class template {
'help' => '',
'id' => $nameId,
'name' => $nameId,
'value' => ''
'value' => '',
'limit' => false
], $attributes);
// Génère deux nombres pour le captcha
$numbers = array(0,1,2,3,4,5,6,7,8,9,10,12,13,14,15,16,17,18,19,20);
$letters = array('u','t','s','r','q','p','o','n','m','l','k','j','i','h','g','f','e','d','c','b','a');
$firstNumber = rand ( 0 , count($letters)-1 );
$secondNumber = rand ( 0 , count($letters)-1 );
$limit = $attributes['limit'] ? 9 : count($letters)-1 ;
$firstNumber = rand ( 0 , $limit );
$secondNumber = rand ( 0 , $limit );
$result = $firstNumber + $secondNumber;
$result = password_hash($result, PASSWORD_BCRYPT);
$firstLetter = uniqid();

View File

@ -39,7 +39,7 @@ class common {
const ACCESS_TIMER = 1800;
// Numéro de version
const ZWII_VERSION = '10.3.02';
const ZWII_VERSION = '10.3.03';
const ZWII_UPDATE_CHANNEL = "v10";
public static $actions = [];
@ -1421,6 +1421,12 @@ class common {
$this->setData(['config', 'connect','captcha', true]);
$this->setData(['core', 'dataVersion', 10302]);
}
// Version 10.3.03
if ($this->getData(['core', 'dataVersion']) < 10303) {
// Activation par défaut du captcha à la connexion
$this->setData(['config', 'connect','captcha10', false]);
$this->setData(['core', 'dataVersion', 10303]);
}
}
}

View File

@ -484,7 +484,8 @@ class config extends common {
'attempt' => $this->getInput('configConnectAttempt',helper::FILTER_INT),
'timeout' => $this->getInput('configConnectTimeout',helper::FILTER_INT),
'log' => $this->getInput('configConnectLog',helper::FILTER_BOOLEAN),
'captcha' => $this->getInput('configConnectCaptcha',helper::FILTER_BOOLEAN)
'captcha' => $this->getInput('configConnectCaptcha',helper::FILTER_BOOLEAN),
'captcha10' => $this->getInput('configConnectCaptcha10',helper::FILTER_BOOLEAN)
]
]
]);

View File

@ -343,6 +343,107 @@
</div>
</div>
</div>
<div class="row">
<div class="col12">
<div class="block" id="login">
<h4>Sécurité de la connexion
<div class="openClose">
<?php
echo template::ico('plus-circled','right');
echo template::ico('minus-circled','right');
?>
</div>
</h4>
<div class="blockContainer">
<div class="row">
<div class="col3">
<?php echo template::select('configConnectAttempt', $module::$connectAttempt , [
'label' => 'Connexions successives',
'selected' => $this->getData(['config', 'connect', 'attempt'])
]); ?>
</div>
<div class="col3">
<?php echo template::select('configConnectTimeout', $module::$connectTimeout , [
'label' => 'Blocage après échecs',
'selected' => $this->getData(['config', 'connect', 'timeout'])
]); ?>
</div>
<div class="col3 verticalAlignBottom">
<label id="helpBlacklist">Comptes inexistants
<?php echo template::help(
'La liste noire énumère les tentatives de connexion à partir de comptes inexistants. Sont stockés : la date, l\'heure, le nom du compte et l\'IP.
Après le nombre de tentatives autorisées, l\'IP et le compte sont bloqués.');
?>
</label>
<?php echo template::button('configConnectblacListDownload', [
'href' => helper::baseUrl() . 'config/blacklistDownload',
'value' => 'Télécharger liste noire',
'ico' => 'download'
]); ?>
</div>
<div class="col3 verticalAlignBottom">
<?php echo template::button('ConfigConnectReset', [
'class' => 'buttonRed',
'href' => helper::baseUrl() . 'config/blacklistReset',
'value' => 'Réinitialiser liste',
'ico' => 'cancel'
]); ?>
</div>
</div>
<div class="row">
<div class="col3">
<?php echo template::checkbox('configConnectCaptcha', true, 'Captcha à la connexion', [
'checked' => $this->getData(['config', 'connect','captcha'])
]); ?>
</div>
<div class="col3">
<?php echo template::checkbox('configConnectCaptcha10', true, 'Limité à 10 chiffres', [
'checked' => $this->getData(['config', 'connect','captcha10'])
]); ?>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col12">
<div class="block" id="logs">
<h4>Journalisation
<div class="openClose">
<?php
echo template::ico('plus-circled','right');
echo template::ico('minus-circled','right');
?>
</div>
</h4>
<div class="blockContainer">
<div class="row">
<div class="col4 verticalAlignBottom">
<?php echo template::checkbox('configConnectLog', true, 'Activer la journalisation', [
'checked' => $this->getData(['config', 'connect', 'log'])
]); ?>
</div>
<div class="col3 offset2">
<?php echo template::button('ConfigLogDownload', [
'href' => helper::baseUrl() . 'config/logDownload',
'value' => 'Télécharger journal',
'ico' => 'download'
]); ?>
</div>
<div class="col3">
<?php echo template::button('ConfigLogReset', [
'class' => 'buttonRed',
'href' => helper::baseUrl() . 'config/logReset',
'value' => 'Réinitialiser journal',
'ico' => 'cancel'
]); ?>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col12">
<div class="block" id="network">
@ -452,102 +553,6 @@
</div>
</div>
</div>
<div class="row">
<div class="col12">
<div class="block" id="login">
<h4>Sécurité de la connexion
<div class="openClose">
<?php
echo template::ico('plus-circled','right');
echo template::ico('minus-circled','right');
?>
</div>
</h4>
<div class="blockContainer">
<div class="row">
<div class="col3">
<?php echo template::select('configConnectAttempt', $module::$connectAttempt , [
'label' => 'Connexions successives',
'selected' => $this->getData(['config', 'connect', 'attempt'])
]); ?>
</div>
<div class="col3">
<?php echo template::select('configConnectTimeout', $module::$connectTimeout , [
'label' => 'Blocage après échecs',
'selected' => $this->getData(['config', 'connect', 'timeout'])
]); ?>
</div>
<div class="col3 verticalAlignBottom">
<label id="helpBlacklist">Comptes inexistants
<?php echo template::help(
'La liste noire énumère les tentatives de connexion à partir de comptes inexistants. Sont stockés : la date, l\'heure, le nom du compte et l\'IP.
Après le nombre de tentatives autorisées, l\'IP et le compte sont bloqués.');
?>
</label>
<?php echo template::button('configConnectblacListDownload', [
'href' => helper::baseUrl() . 'config/blacklistDownload',
'value' => 'Télécharger liste noire',
'ico' => 'download'
]); ?>
</div>
<div class="col3 verticalAlignBottom">
<?php echo template::button('ConfigConnectReset', [
'class' => 'buttonRed',
'href' => helper::baseUrl() . 'config/blacklistReset',
'value' => 'Réinitialiser liste',
'ico' => 'cancel'
]); ?>
</div>
</div>
<div class="row">
<div class="col4">
<?php echo template::checkbox('configConnectCaptcha', true, 'Captcha à la connexion', [
'checked' => $this->getData(['config', 'connect','captcha'])
]); ?>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col12">
<div class="block" id="logs">
<h4>Journalisation
<div class="openClose">
<?php
echo template::ico('plus-circled','right');
echo template::ico('minus-circled','right');
?>
</div>
</h4>
<div class="blockContainer">
<div class="row">
<div class="col4 verticalAlignBottom">
<?php echo template::checkbox('configConnectLog', true, 'Activer la journalisation', [
'checked' => $this->getData(['config', 'connect', 'log'])
]); ?>
</div>
<div class="col3 offset2">
<?php echo template::button('ConfigLogDownload', [
'href' => helper::baseUrl() . 'config/logDownload',
'value' => 'Télécharger journal',
'ico' => 'download'
]); ?>
</div>
<div class="col3">
<?php echo template::button('ConfigLogReset', [
'class' => 'buttonRed',
'href' => helper::baseUrl() . 'config/logReset',
'value' => 'Réinitialiser journal',
'ico' => 'cancel'
]); ?>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col12">
<div class="block" id="script">

View File

@ -15,7 +15,9 @@
<?php if ($this->getData(['config', 'connect','captcha'])): ?>
<div class="row">
<div class="col12 textAlignCenter">
<?php echo template::captcha('userLoginCaptcha'); ?>
<?php echo template::captcha('userLoginCaptcha', [
'limit' => $this->getData(['config','connect','captcha10'])
]); ?>
</div>
</div>
<?php endif;?>

View File

@ -79,7 +79,9 @@
<?php if($this->getUser('password') !== $this->getInput('ZWII_USER_PASSWORD')): ?>
<div class="row">
<div class="col12">
<?php echo template::captcha('blogArticleCaptcha'); ?>
<?php echo template::captcha('blogArticleCaptcha', [
'limit' => $this->getData(['config','connect','captcha10'])
]); ?>
</div>
</div>
<?php endif; ?>

View File

@ -46,7 +46,9 @@
<?php if($this->getData(['module', $this->getUrl(0), 'config', 'captcha'])): ?>
<div class="row">
<div class="col5">
<?php echo template::captcha('formCaptcha'); ?>
<?php echo template::captcha('formCaptcha', [
'limit' => $this->getData(['config','connect','captcha10'])
]); ?>
</div>
</div>
<?php endif; ?>