noalyss-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Noalyss-commit] [noalyss] 36/73: improve captcha, replace the global va


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 36/73: improve captcha, replace the global variable by a "DEFINE" constant
Date: Fri, 28 May 2021 05:26:32 -0400 (EDT)

sparkyx pushed a commit to branch master
in repository noalyss.

commit 5b30467fad80dae476319899c9dc10409e35a71c
Author: sparkyx <danydb@noalyss.eu>
AuthorDate: Sat Apr 24 10:49:28 2021 +0200

    improve captcha, replace the global variable by a "DEFINE" constant
---
 html/index.php              | 9 +++++----
 html/js/scripts.js          | 2 ++
 html/login.php              | 2 +-
 include/constant.php        | 7 +++++--
 include/lib/config_file.php | 2 ++
 include/verif_bilan.inc.php | 2 +-
 6 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/html/index.php b/html/index.php
index 09521f8..3547a4c 100644
--- a/html/index.php
+++ b/html/index.php
@@ -150,6 +150,7 @@ echo '<!doctype html><HTML>
 <link rel="stylesheet" type="text/css" href="css/bootstrap-grid.min.css" 
media="screen">
 <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" 
media="screen">
 <link rel="stylesheet" type="text/css" href="css/index.css" media="screen">
+<script src="js/prototype.js" type="text/javascript"></script>
 <script src="js/scripts.js" type="text/javascript"></script>
 </head>
 <BODY>';
@@ -235,19 +236,19 @@ if 
(isset($_REQUEST['reconnect'])&&isset($_REQUEST['backurl']))
 
                 <?php
 // if captcha is used
-                if ($g_captcha==true) :
+                if (defined('NOALYSS_CAPTCHA') && NOALYSS_CAPTCHA==true) :
                     ?>
                     Indiquer le code que vous lisez dans l'image
-                    <img id="captcha" src="securimage/securimage_show.php" 
alt="CAPTCHA Image" border=1/>';
+                    <img id="captcha" src="securimage/securimage_show.php" 
alt="CAPTCHA Image" border=1/>
 
                     <input type="text" class="input_text" name="captcha_code" 
size="10" maxlength="6" autocomplete="off"/>
-                    <a href="#" 
onclick="document.getElementById('captcha').src = 
'securimage/securimage_show.php?\' + Math.random(); return false">Reload 
Image</a>
+                    <a href="#" 
onclick="document.getElementById('captcha').src = 
'securimage/securimage_show.php?' + Math.random(); return false">Reload 
Image</a>
 
                     <?php
                 endif;
                 ?>  
                 <div class="form-group  row  justify-content-center">
-                    <INPUT TYPE="SUBMIT"  class="button" 
style="background-image: url('image/bg-submit2.gif'); width: 100%; height: 
42px; border-radius: 11px; color: white;" NAME="login" value="se connecter">
+                    <INPUT TYPE="SUBMIT"  class="button" style="width:91%" 
NAME="login" value="se connecter">
                 </div>
 
             </form>
diff --git a/html/js/scripts.js b/html/js/scripts.js
index 401ce3e..60d67fd 100644
--- a/html/js/scripts.js
+++ b/html/js/scripts.js
@@ -27,6 +27,8 @@ var ask_reload = 0;
 // tag_choose Element  which contains all the selected tags 
 var tag_choose = ''; 
 var aDraggableElement = new Array();
+
+// document.viewport depends of prototype.js
 var viewport = document.viewport.getDimensions(); // Gets the viewport as an 
object literal
 var width = viewport.width; // Usable window width
 var height = viewport.height;
diff --git a/html/login.php b/html/login.php
index 7131420..3e4ab0b 100644
--- a/html/login.php
+++ b/html/login.php
@@ -60,7 +60,7 @@ if (  isset ($_POST["p_user"] ) )
     require_once NOALYSS_INCLUDE."/class/user.class.php";
     $User=new User($rep);
     $User->Check(false,'LOGIN');
-    if ($g_captcha == true)
+    if (defined('NOALYSS_CAPTCHA') && NOALYSS_CAPTCHA==true) 
     {
           include("securimage/securimage.php");
           $img = new Securimage();
diff --git a/include/constant.php b/include/constant.php
index 58197ae..c1189ac 100644
--- a/include/constant.php
+++ b/include/constant.php
@@ -79,9 +79,12 @@ if ( ! defined('OVERRIDE_PARAM')) {
  * Ini session
  */
 
+if (! defined('NOALYSS_CAPTCHA') ) 
+{
+    define ("NOALYSS_CAPTCHA",false);
+}
 
-global $g_captcha,$g_failed,$g_succeed;
-$g_captcha=false;
+global $g_failed,$g_succeed;
 $g_failed="<span style=\"font-size:18px;color:red\">&#x2716;</span>";
 $g_succeed="<span style=\"font-size:18px;color:green\">&#x2713;</span>";
 define ('SMALLX','#xe816;');
diff --git a/include/lib/config_file.php b/include/lib/config_file.php
index b780658..8a94e53 100644
--- a/include/lib/config_file.php
+++ b/include/lib/config_file.php
@@ -252,6 +252,8 @@ function display_file_config($p_array,$from_setup=1,$p_os=1)
     print ("// for exporting document in PDF\r\n");
     print ("// \$pdftk = /usr/bin/pdftk \r\n");
     print ("// \$pdftk = /snap/bin/pdftk \r\n");
+    print ("// uncomment to activate the captcha on login page\r\n");
+    print ("// define('NOALYSS_CAPTCHA',true);\r\n");
 
 }
 /*!\brief create the config file
diff --git a/include/verif_bilan.inc.php b/include/verif_bilan.inc.php
index 0dff014..622eebd 100644
--- a/include/verif_bilan.inc.php
+++ b/include/verif_bilan.inc.php
@@ -27,7 +27,7 @@ if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas 
permis');
 require_once  NOALYSS_INCLUDE.'/class/user.class.php';
 require_once NOALYSS_INCLUDE.'/class/acc_bilan.class.php';
 
-global $g_captcha,$g_failed,$g_succeed;
+global $g_failed,$g_succeed;
 $cn=Dossier::connect();
 $exercice=$g_user->get_exercice();
 echo '<div class="content">';



reply via email to

[Prev in Thread] Current Thread [Next in Thread]