Captcha en lettres + correction du nom : capcha en captcha
This commit is contained in:
parent
bf1819fc74
commit
e94cb81b24
@ -33,12 +33,12 @@ class template {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Crée un champ capcha
|
* Crée un champ captcha
|
||||||
* @param string $nameId Nom et id du champ
|
* @param string $nameId Nom et id du champ
|
||||||
* @param array $attributes Attributs ($key => $value)
|
* @param array $attributes Attributs ($key => $value)
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function capcha($nameId, array $attributes = []) {
|
public static function captcha($nameId, array $attributes = []) {
|
||||||
// Attributs par défaut
|
// Attributs par défaut
|
||||||
$attributes = array_merge([
|
$attributes = array_merge([
|
||||||
'class' => '',
|
'class' => '',
|
||||||
@ -48,13 +48,15 @@ class template {
|
|||||||
'name' => $nameId,
|
'name' => $nameId,
|
||||||
'value' => ''
|
'value' => ''
|
||||||
], $attributes);
|
], $attributes);
|
||||||
// Génère deux nombres pour le capcha
|
// Génère deux nombres pour le captcha
|
||||||
$firstNumber = mt_rand(1, 15);
|
$numbers=array(0,1,2,3,4,5,6,7,8,9,10,12,13,14,15,16,17,18,19,20);
|
||||||
$secondNumber = mt_rand(1, 15);
|
$letters=array('zéro','un','deux','trois','quatre','cinq','six','sept','huit','neuf','dix','onze','douze','treize','quatorze','quinze','seize','dix-sept','dix-huit','dix-neuf','vingt');
|
||||||
|
$firstNumber=rand ( 0 , count($letters)-1 );
|
||||||
|
$secondNumber=rand ( 0 , count($letters)-1 );
|
||||||
// Début du wrapper
|
// Début du wrapper
|
||||||
$html = '<div id="' . $attributes['id'] . 'Wrapper" class="inputWrapper ' . $attributes['classWrapper'] . '">';
|
$html = '<div id="' . $attributes['id'] . 'Wrapper" class="inputWrapper ' . $attributes['classWrapper'] . '">';
|
||||||
// Label
|
// Label
|
||||||
$html .= self::label($attributes['id'], $firstNumber . ' + ' . $secondNumber . ' = ?', [
|
$html .= self::label($attributes['id'], $letters[$firstNumber] . ' + ' . $letters[$secondNumber] . ' = ? (réponse en chiffres)', [
|
||||||
'help' => $attributes['help']
|
'help' => $attributes['help']
|
||||||
]);
|
]);
|
||||||
// Notice
|
// Notice
|
||||||
@ -64,7 +66,7 @@ class template {
|
|||||||
$attributes['class'] .= ' notice';
|
$attributes['class'] .= ' notice';
|
||||||
}
|
}
|
||||||
$html .= self::notice($attributes['id'], $notice);
|
$html .= self::notice($attributes['id'], $notice);
|
||||||
// Capcha
|
// captcha
|
||||||
$html .= sprintf(
|
$html .= sprintf(
|
||||||
'<input type="text" %s>',
|
'<input type="text" %s>',
|
||||||
helper::sprintAttributes($attributes)
|
helper::sprintAttributes($attributes)
|
||||||
|
@ -632,7 +632,7 @@ class init extends common {
|
|||||||
'contact' => [
|
'contact' => [
|
||||||
'config' => [
|
'config' => [
|
||||||
'button' => '',
|
'button' => '',
|
||||||
'capcha' => true,
|
'captcha' => true,
|
||||||
'group' => self::GROUP_ADMIN,
|
'group' => self::GROUP_ADMIN,
|
||||||
'pageId' => '',
|
'pageId' => '',
|
||||||
'subject' => ''
|
'subject' => ''
|
||||||
|
@ -339,12 +339,12 @@ class blog extends common {
|
|||||||
else {
|
else {
|
||||||
// Soumission du formulaire
|
// Soumission du formulaire
|
||||||
if($this->isPost()) {
|
if($this->isPost()) {
|
||||||
// Check la capcha
|
// Check la captcha
|
||||||
if(
|
if(
|
||||||
$this->getUser('password') !== $this->getInput('ZWII_USER_PASSWORD')
|
$this->getUser('password') !== $this->getInput('ZWII_USER_PASSWORD')
|
||||||
AND $this->getInput('blogArticleCapcha', helper::FILTER_INT) !== $this->getInput('blogArticleCapchaFirstNumber', helper::FILTER_INT) + $this->getInput('blogArticleCapchaSecondNumber', helper::FILTER_INT))
|
AND $this->getInput('blogArticlecaptcha', helper::FILTER_INT) !== $this->getInput('blogArticlecaptchaFirstNumber', helper::FILTER_INT) + $this->getInput('blogArticlecaptchaSecondNumber', helper::FILTER_INT))
|
||||||
{
|
{
|
||||||
self::$inputNotices['blogArticleCapcha'] = 'Incorrect';
|
self::$inputNotices['blogArticlecaptcha'] = 'Incorrect';
|
||||||
}
|
}
|
||||||
// Crée le commentaire
|
// Crée le commentaire
|
||||||
$commentId = helper::increment(uniqid(), $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'comment']));
|
$commentId = helper::increment(uniqid(), $this->getData(['module', $this->getUrl(0), $this->getUrl(1), 'comment']));
|
||||||
|
@ -75,7 +75,7 @@
|
|||||||
<?php if($this->getUser('password') !== $this->getInput('ZWII_USER_PASSWORD')): ?>
|
<?php if($this->getUser('password') !== $this->getInput('ZWII_USER_PASSWORD')): ?>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col4">
|
<div class="col4">
|
||||||
<?php echo template::capcha('blogArticleCapcha'); ?>
|
<?php echo template::captcha('blogArticlecaptcha'); ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
@ -77,7 +77,7 @@ class form extends common {
|
|||||||
'config',
|
'config',
|
||||||
[
|
[
|
||||||
'button' => $this->getInput('formConfigButton'),
|
'button' => $this->getInput('formConfigButton'),
|
||||||
'capcha' => $this->getInput('formConfigCapcha', helper::FILTER_BOOLEAN),
|
'captcha' => $this->getInput('formConfigcaptcha', helper::FILTER_BOOLEAN),
|
||||||
'group' => $this->getInput('formConfigGroup', helper::FILTER_INT),
|
'group' => $this->getInput('formConfigGroup', helper::FILTER_INT),
|
||||||
'user' => self::$listUsers [$this->getInput('formConfigUser', helper::FILTER_INT)],
|
'user' => self::$listUsers [$this->getInput('formConfigUser', helper::FILTER_INT)],
|
||||||
'mail' => $this->getInput('formConfigMail') ,
|
'mail' => $this->getInput('formConfigMail') ,
|
||||||
@ -279,12 +279,12 @@ class form extends common {
|
|||||||
public function index() {
|
public function index() {
|
||||||
// Soumission du formulaire
|
// Soumission du formulaire
|
||||||
if($this->isPost()) {
|
if($this->isPost()) {
|
||||||
// Check la capcha
|
// Check la captcha
|
||||||
if(
|
if(
|
||||||
$this->getData(['module', $this->getUrl(0), 'config', 'capcha'])
|
$this->getData(['module', $this->getUrl(0), 'config', 'captcha'])
|
||||||
AND $this->getInput('formCapcha', helper::FILTER_INT) !== $this->getInput('formCapchaFirstNumber', helper::FILTER_INT) + $this->getInput('formCapchaSecondNumber', helper::FILTER_INT))
|
AND $this->getInput('formcaptcha', helper::FILTER_INT) !== $this->getInput('formcaptchaFirstNumber', helper::FILTER_INT) + $this->getInput('formcaptchaSecondNumber', helper::FILTER_INT))
|
||||||
{
|
{
|
||||||
self::$inputNotices['formCapcha'] = 'Incorrect';
|
self::$inputNotices['formcaptcha'] = 'Incorrect';
|
||||||
|
|
||||||
}
|
}
|
||||||
// Préparation le contenu du mail
|
// Préparation le contenu du mail
|
||||||
|
@ -142,8 +142,8 @@
|
|||||||
]); ?>
|
]); ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<?php echo template::checkbox('formConfigCapcha', true, 'Valider un capcha afin de soumettre le formulaire.', [
|
<?php echo template::checkbox('formConfigcaptcha', true, 'Valider un captcha afin de soumettre le formulaire.', [
|
||||||
'checked' => $this->getData(['module', $this->getUrl(0), 'config', 'capcha'])
|
'checked' => $this->getData(['module', $this->getUrl(0), 'config', 'captcha'])
|
||||||
]); ?>
|
]); ?>
|
||||||
</div>
|
</div>
|
||||||
<div class="block">
|
<div class="block">
|
||||||
|
@ -43,10 +43,10 @@
|
|||||||
</h3>
|
</h3>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
<?php if($this->getData(['module', $this->getUrl(0), 'config', 'capcha'])): ?>
|
<?php if($this->getData(['module', $this->getUrl(0), 'config', 'captcha'])): ?>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col4">
|
<div class="col4">
|
||||||
<?php echo template::capcha('formCapcha'); ?>
|
<?php echo template::captcha('formcaptcha'); ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
Loading…
Reference in New Issue
Block a user