From 22c81cf3ea881e1c8bb0c6d3f95590fdfea6e906 Mon Sep 17 00:00:00 2001
From: filippo.bertilotti <filippobertilotti@gmail.com>
Date: Fri, 03 May 2024 10:24:57 +0200
Subject: [PATCH] aggiunta controllo dello spam e implementazione template annesso

---
 htdocs/contact.php |   33 +++++++++++++--------------------
 1 files changed, 13 insertions(+), 20 deletions(-)

diff --git a/htdocs/contact.php b/htdocs/contact.php
index dbfb973..0a9020e 100644
--- a/htdocs/contact.php
+++ b/htdocs/contact.php
@@ -46,32 +46,19 @@
 
 
     function controlloSpamEmail(mysqli $connection, string $email) {
-        $esitoSpamEmail = false;
+        $spam = false;
         $query = "SELECT email, dtm_richiesta FROM Contact WHERE email = '$email' AND dtm_richiesta BETWEEN DATE_SUB(NOW(), INTERVAL 1 DAY) AND NOW();";
         
         
         $result = $connection->query($query);
         
-        while ($row = $result->fetch_assoc()) {
-            echo $row['email']."<br />\n";
-            echo $row['dtm_richiesta']."<br />\n";
+        $rowcount=mysqli_num_rows($result);
+        
+        if ($rowcount > 0) {
+            $spam = true;
         }
 
-
-        while ($row = $result->fetch_assoc()) {
-            if(count($row['email']) > 0) {
-                $esitoSpamEmail = true;
-            }
-        }
-
-        if($esitoSpamEmail == true) {echo "email spammata";}
-        
-        
-        
-
-
-
-        return $esitoSpamEmail;
+        return $spam;
     }
     
 
@@ -85,8 +72,14 @@
             } catch (Exception $e) {
                 die($e->getMessage());
             }
-            controlloSpamEmail($conn, $email);
+            
+            if(controlloSpamEmail($conn, $email)) {
+                $smarty->display('avviso.tpl');
+                exit;
+            }
+            
             $esitoInserimento = insertDataOnTable($conn, $email, $number);
+            
 
             if($esitoInserimento == true) {
                 $smarty->display('conferma.tpl');

--
Gitblit v1.8.0