]> SAFE projects GIT repository - jmp/mailleur/commitdiff
cookies management seems to be working
authorJean-Marc Pigeon <jmp@safe.c>
Thu, 4 Sep 2025 11:05:11 +0000 (07:05 -0400)
committerJean-Marc Pigeon <jmp@safe.c>
Thu, 4 Sep 2025 11:05:11 +0000 (07:05 -0400)
www/gessql.php
www/home.php

index 9dbd47ba94d5a21920d8bf5fe69bdb801ff02137..107498b2f1e8fb06564915fabafc2c2bcf128480 100644 (file)
@@ -74,7 +74,9 @@ function sql_getlogname($dbsql)
 $OPEP="gessql.php:sql_getlogname";
 
 $logname=NULL;
-$cookie=$_COOKIE['mailleur']; 
+$expire=NULL;
+$cookie=$_COOKIE[getenv("APPNAME")];
+$cookie=htmlspecialchars($cookie);
 $phase=0;
 $proceed=true;
 while ($proceed==true) {
@@ -85,15 +87,23 @@ while ($proceed==true) {
         $phase=999;
       break;
     case 1      :       //is the cookie within database
-      $cookie=htmlspecialchars($cookie);
       $stmt=$dbsql->Select("Select * from cookies where cookuuid='$cookie'");
       $expire=$stmt->fetch(PDO::FETCH_ASSOC)['expire'];
-      rou_alert(0,"$OPEP, cookie expire=<$expire>");
+      if ($expire==null) {
+        rou_alert(0,"$OPEP, cookie <$cookie> expire not found in DB!");
+        $phase=999;
+        }
+      break;
+    case 2      :       //checking if cookie expired
+      $texpire=strtotime($expire);
+      if (time()>$texpire) {
+        rou_alert(0,"$OPEP, cookie <$cookie> time limite");
+        $phase=999;
+        }
       break;
-    case 2      :       //extracting logname
+    case 3      :       //extracting logname
       $stmt=$dbsql->Select("Select * from cookies where cookuuid='$cookie'");
       $logname=$stmt->fetch(PDO::FETCH_ASSOC)['email'];
-      rou_alert(0,"$OPEP, cookie logname=<$logname>");
       if ($logname==NULL) { //is user known?
         rou_alert(0,"$OPEP, cookie <$cookie> not found in DB");
         $phase=999;
index 8a65e606a46089c130f9ff0057f5981d50a5acb7..dff36485caa5564909fee706be132fa47d1cfffb 100644 (file)
@@ -7,8 +7,7 @@ include_once "gessql.php";
 
 //section to generate the main screen body
 //
-//define('JMPDBG','1');
-function body($action,$user,$pass)
+function body()
 
 {
 //including screen function
@@ -30,7 +29,6 @@ $STR  = <<<EOT
 Mailleur
 </FONT></STRONG></CENTER>
 $login
-USERNAME=$user
 $footer
 </BODY>
 </HTML>
@@ -39,8 +37,6 @@ EOT;
 return $STR;
 }
 
-$logname="U1";
-$pass="P1";
 if ($_SERVER["REQUEST_METHOD"] == "POST") {
   $pass=$_POST["passwd"];
   $logname=$_POST["email"];
@@ -60,7 +56,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
   }
 
 //display main screen
-echo body($action,$logname,$pass);
+echo body();
 ?>