From 1915f554b7e21d42811f06a670bc16ca4076273e Mon Sep 17 00:00:00 2001
From: Fred <23246457+fredtempez@users.noreply.github.com>
Date: Thu, 29 Oct 2020 13:50:10 +0100
Subject: [PATCH 1/3] Update template.class.php
---
core/class/template.class.php | 63 +++++++++++++++++++----------------
1 file changed, 34 insertions(+), 29 deletions(-)
diff --git a/core/class/template.class.php b/core/class/template.class.php
index cbcde427..141ccc7c 100644
--- a/core/class/template.class.php
+++ b/core/class/template.class.php
@@ -49,26 +49,30 @@ class template {
'value' => '',
'limit' => false
], $attributes);
+
// Tirage de l'opération et des nombres
+ // Correspondance tableau des images
$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');
+
+ // Détermination de la limitation
$limit = $attributes['limit'] ? count($letters)-1 : 10;
mt_srand((float) microtime()*1000000);
$operator = mt_rand (0, 3);
- if ($operator > 1) {
- $limit = 10;
- }
+
+ // Limiter les valuers si pas une addition
+ if ($operator > 1) $limit = 10;
$firstNumber = mt_rand (1, $limit);
$secondNumber = mt_rand (1, $limit);
-
- if ( ($operator < 2)
- AND ($firstNumber < $secondNumber) )
- {
+
+ // Ordre des valeurs selon type d'opération
+ if (($operator < 2) AND ($firstNumber < $secondNumber)) {
$temp = $firstNumber;
$firstNumber = $secondNumber;
$secondNumber = $temp;
- }
-
+ }
+
+ // Calcul du résultat et icône de l'opérateur
switch ($operator) {
case 0:
$operator = template::ico('plus');
@@ -84,40 +88,37 @@ class template {
break;
case 3:
$operator = template::ico('divide');
- switch ($firstNumber) {
- case 3:
- $limit = 6;
- break;
- case 4:
- $limit = 5;
- break;
- case 5:
- $limit = 4;
- break;
- case 6:
- $limit = 3;
- break;
+ $limit2 = [10, 10, 6, 5, 4, 3, 2, 2, 2, 2];
+ for ($i = 1; $i <= $firstNumber; $i++) {
+ $limit = $limit2[$i-1];
}
- if ($firstNumber > 6) $limit = 2;
-
- $secondNumber = mt_rand(1, $limit);
- $firstNumber = $firstNumber * $secondNumber;
- $result = $firstNumber / $secondNumber;
+ mt_srand((float) microtime()*1000000);
+ $secondNumber = mt_rand(1, $limit);
+ $firstNumber = $firstNumber * $secondNumber;
+ $result = $firstNumber / $secondNumber;
break;
- }
+ }
+
+ // Hashage du résultat
$result = password_hash($result, PASSWORD_BCRYPT);
+
+ // Codage des valeurs de l'opération
$firstLetter = uniqid();
$secondLetter = uniqid();
- // Masquage image source
+
+ // Masquage image source pour éviter un décodage
copy ('core/vendor/zwiico/png/'.$letters[$firstNumber] . '.png', 'site/tmp/' . $firstLetter . '.png');
copy ('core/vendor/zwiico/png/'.$letters[$secondNumber] . '.png', 'site/tmp/' . $secondLetter . '.png');
+
// Début du wrapper
$html = '
';
+
// Label
$html .= self::label($attributes['id'],
'
' . $operator . ' en chiffres ?', [
'help' => $attributes['help']
]);
+
// Notice
$notice = '';
if(array_key_exists($attributes['id'], common::$inputNotices)) {
@@ -125,18 +126,22 @@ class template {
$attributes['class'] .= ' notice';
}
$html .= self::notice($attributes['id'], $notice);
+
// captcha
$html .= sprintf(
'
',
helper::sprintAttributes($attributes)
);
+
// Champ résultat codé
$html .= self::hidden($attributes['id'] . 'Result', [
'value' => $result,
'before' => false
]);
+
// Fin du wrapper
$html .= '
';
+
// Retourne le html
return $html;
}
From 3fefff219da54bb66958827cbb709674d1dede22 Mon Sep 17 00:00:00 2001
From: Fred <23246457+fredtempez@users.noreply.github.com>
Date: Thu, 29 Oct 2020 15:44:03 +0100
Subject: [PATCH 2/3] Update init.js
---
core/vendor/tinymce/init.js | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/core/vendor/tinymce/init.js b/core/vendor/tinymce/init.js
index a1db9365..809ad9f2 100755
--- a/core/vendor/tinymce/init.js
+++ b/core/vendor/tinymce/init.js
@@ -27,7 +27,7 @@ tinymce.init({
// Plugins
plugins: "advlist anchor autolink autoresize autosave codemirror colorpicker contextmenu fullscreen hr image imagetools link lists media paste searchreplace stickytoolbar tabfocus table template textcolor emoticons nonbreaking",
// Contenu de la barre d'outils
- toolbar: "restoredraft | undo redo | bold italic underline forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist emoticons | table template | image media link | code fullscreen",
+ toolbar: "restoredraft | undo redo | formatselect bold italic underline forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist emoticons | table template | image media link | code fullscreen",
// Emoticons
emoticons_append: {
custom_mind_explode: {
@@ -265,7 +265,7 @@ tinymce.init({
// Plugins
plugins: "advlist anchor autolink autoresize autosave colorpicker contextmenu fullscreen hr lists paste searchreplace stickytoolbar tabfocus template textcolor visualblocks emoticons",
// Contenu de la barre d'outils
- toolbar: "restoredraft | undo redo | styleselect | bold italic forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist emoticons | visualblocks fullscreen",
+ toolbar: "restoredraft | undo redo | formatselect bold italic forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist emoticons | visualblocks fullscreen",
// Emoticons
emoticons_append: {
custom_mind_explode: {
@@ -436,4 +436,4 @@ tinymce.PluginManager.add('stickytoolbar', function(editor, url) {
return false;
}
- });
\ No newline at end of file
+ });
From 567a70d909d84f06ee0df18b057dc33033f1a9dc Mon Sep 17 00:00:00 2001
From: fredtempez
Date: Thu, 29 Oct 2020 19:14:19 +0100
Subject: [PATCH 3/3] espaces
---
core/class/template.class.php | 34 +++++++++++++++++-----------------
1 file changed, 17 insertions(+), 17 deletions(-)
diff --git a/core/class/template.class.php b/core/class/template.class.php
index 141ccc7c..ee13f502 100644
--- a/core/class/template.class.php
+++ b/core/class/template.class.php
@@ -49,29 +49,29 @@ class template {
'value' => '',
'limit' => false
], $attributes);
-
+
// Tirage de l'opération et des nombres
// Correspondance tableau des images
$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');
-
+
// Détermination de la limitation
$limit = $attributes['limit'] ? count($letters)-1 : 10;
mt_srand((float) microtime()*1000000);
$operator = mt_rand (0, 3);
-
+
// Limiter les valuers si pas une addition
if ($operator > 1) $limit = 10;
$firstNumber = mt_rand (1, $limit);
$secondNumber = mt_rand (1, $limit);
-
+
// Ordre des valeurs selon type d'opération
if (($operator < 2) AND ($firstNumber < $secondNumber)) {
$temp = $firstNumber;
$firstNumber = $secondNumber;
$secondNumber = $temp;
- }
-
+ }
+
// Calcul du résultat et icône de l'opérateur
switch ($operator) {
case 0:
@@ -98,27 +98,27 @@ class template {
$result = $firstNumber / $secondNumber;
break;
}
-
+
// Hashage du résultat
$result = password_hash($result, PASSWORD_BCRYPT);
-
+
// Codage des valeurs de l'opération
$firstLetter = uniqid();
$secondLetter = uniqid();
-
- // Masquage image source pour éviter un décodage
+
+ // Masquage image source pour éviter un décodage
copy ('core/vendor/zwiico/png/'.$letters[$firstNumber] . '.png', 'site/tmp/' . $firstLetter . '.png');
copy ('core/vendor/zwiico/png/'.$letters[$secondNumber] . '.png', 'site/tmp/' . $secondLetter . '.png');
-
+
// Début du wrapper
$html = '';
-
+
// Label
$html .= self::label($attributes['id'],
'
' . $operator . ' en chiffres ?', [
'help' => $attributes['help']
]);
-
+
// Notice
$notice = '';
if(array_key_exists($attributes['id'], common::$inputNotices)) {
@@ -126,22 +126,22 @@ class template {
$attributes['class'] .= ' notice';
}
$html .= self::notice($attributes['id'], $notice);
-
+
// captcha
$html .= sprintf(
'
',
helper::sprintAttributes($attributes)
);
-
+
// Champ résultat codé
$html .= self::hidden($attributes['id'] . 'Result', [
'value' => $result,
'before' => false
]);
-
+
// Fin du wrapper
$html .= '
';
-
+
// Retourne le html
return $html;
}