From 952121b1d24578692e5beccdaec90edfc83a5739 Mon Sep 17 00:00:00 2001 From: Daniel Tartavel Date: Sat, 30 Oct 2021 12:37:27 +0200 Subject: [PATCH] correction of some regressions --- cron.php | 18 +++++++++++++++++- gestion/gestionDB.php | 11 +++++++++-- gestion/index.php | 1 + gestion/stats.php | 40 ++++++++++++++++++++++++++++++---------- include/config.inc.php | 2 +- 5 files changed, 58 insertions(+), 14 deletions(-) diff --git a/cron.php b/cron.php index 16c1cef..638566b 100644 --- a/cron.php +++ b/cron.php @@ -16,7 +16,9 @@ peripeties(); print "Envoi des arrivées" . EOLH; arrivee(); + anonymisation(); + ################################### FONCTIONS #################################"" function peripetieDatee() { global $db; @@ -130,7 +132,7 @@ $query = "SELECT * FROM avionpoeme WHERE atteri = 0 AND TIMEDIFF(CONCAT_WS(' ',CURDATE(),CURTIME()),deliveryTimeServer) > '00:00'"; $db->query($query); $avionArrive = $db->result->fetch_all(MYSQLI_ASSOC); - var_dump($avionArrive); + //var_dump($avionArrive); foreach ($avionArrive as $avion) { print "avion poème n° " . $avion['idAvion'] . "a atterri" . EOLH; @@ -196,5 +198,19 @@ print json_last_error_msg() .EOLH; } } + + function anonymisation() + { + global $db; + $query = "SELECT idAvion FROM avionpoeme WHERE atteri = 1 AND public = 0 AND DATEDIFF(CONCAT_WS(' ',CURDATE(),CURTIME()),deliveryTimeServer) > '7'"; + $db->query($query); + $avionArrive = $db->result->fetch_all(MYSQLI_ASSOC); + //print_r($avionArrive); + foreach($avionArrive as $avion) + { + $query = "UPDATE avionpoeme SET message='', expeMail='', destMail='' WHERE idAvion='" . $avion['idAvion'] ."'"; + $db->query($query); + } + } $db->close(); ?> diff --git a/gestion/gestionDB.php b/gestion/gestionDB.php index 6f0f059..82b77cb 100644 --- a/gestion/gestionDB.php +++ b/gestion/gestionDB.php @@ -67,15 +67,22 @@ function verifPeripetieAvion() $db->query($query); $avions = $db->result->fetch_all(MYSQLI_ASSOC); $avionsId = array_column($avions, 'expeMail', 'idAvion'); - print_r($avionsId); + //print_r($avionsId); + $flag = false; foreach($peripeties as $peripetie) { - print "Péripétie " . $peripetie["idAP"] . EOLH; + //print "Péripétie " . $peripetie["idAP"] . EOLH; $idAvion = $peripetie["idAvion"]; if ( empty($avionsId[$idAvion]) ) { print "Péripétie " . $peripetie["idAP"] . " n'a pas d'avion poème idAvion=>" . $idAvion . EOLH; + $flag = true; } + + } + if ( ! $flag ) + { + print "Aucune erreur détectée"; } $db->close(); } diff --git a/gestion/index.php b/gestion/index.php index b58d888..24a4957 100644 --- a/gestion/index.php +++ b/gestion/index.php @@ -30,6 +30,7 @@ +Statistiques
Générer les fichiers de langue
Lire les logs
Vérifier la base de données
diff --git a/gestion/stats.php b/gestion/stats.php index a4ee2f3..91377fc 100644 --- a/gestion/stats.php +++ b/gestion/stats.php @@ -14,6 +14,7 @@ $result = $db->result->fetch_assoc(); return $result['Auto_increment']-1; } + function total() //nombre d'avions poèmes présents dans la base { global $db; @@ -27,26 +28,42 @@ function totalenvol() //nombre d'avions poèmes en vol { global $db; - $query = "SELECT COUNT(*) as n FROM avionpoeme WHERE public!=2"; + $query = "SELECT COUNT(*) as n FROM avionpoeme WHERE atteri!=1"; $db->query($query); $result = $db->result->fetch_assoc(); return $result["n"]; } - function alea() + function alea($nAvionEnvoye) { global $db; - $query = "SELECT COUNT(*) as nAvion FROM avionpoeme WHERE "; + $query = "SELECT DISTINCT deliveryMethod FROM avionpoeme"; $db->query($query); - $result = $db->result->fetch_assoc(); - return $result["n"]; - + $result = $db->result->fetch_all(MYSQLI_ASSOC); + //var_dump($result); + foreach ( $result as $method ) + { + $query = "SELECT COUNT(*) as nAvion FROM avionpoeme WHERE deliveryMethod='" . $method["deliveryMethod"] . "'"; + $db->query($query); + $result = $db->result->fetch_assoc(); + echo "Méthode => " . $method["deliveryMethod"] . " nombre d'avion poèmes => " . $result["nAvion"] . " => " . round($result["nAvion"]/$nAvionEnvoye*100,2) . "%" . EOLH; + } } function anonymous() //nombre d'avions poèmes envoyés anonymement { global $db; - $query = "SELECT COUNT(*) as n FROM avionpoeme WHERE expemail=''"; + $query = "SELECT COUNT(*) as n FROM avionpoeme WHERE expeknown='0'"; + $db->query($query); + $result = $db->result->fetch_assoc(); + return $result["n"]; + + } + + function deleted() + { + global $db; + $query = "SELECT COUNT(*) as n FROM avionpoeme WHERE public='2'"; $db->query($query); $result = $db->result->fetch_assoc(); return $result["n"]; @@ -63,11 +80,14 @@ echo "Nombre total d'avions-poème : " . $nAvionEnvoye . EOLH; $total = total(); $avionSupp = $nAvionEnvoye-$total; - echo "Nombre d'avion supprimés : " . $avionSupp . " => " . round($avionSupp/$nAvionEnvoye*100,3) . "%" . EOLH; + echo "Nombre d'avion supprimés : " . $avionSupp . " => " . round($avionSupp/$nAvionEnvoye*100,2) . "%" . EOLH; $nAvionenvol = totalenvol(); - echo "Nombre d'avions-poème en vol : " . $nAvionenvol . " => " . round($nAvionenvol/$nAvionEnvoye*100) . "%" . EOLH; + echo "Nombre d'avions-poème en vol : " . $nAvionenvol . " => " . round($nAvionenvol/$nAvionEnvoye*100,2) . "%" . EOLH; $anonymous = anonymous(); - echo "Nombre d'envois anonymes : " . $anonymous . " => " . round($anonymous/$nAvionEnvoye*100) . "%" . EOLH; + echo "Nombre d'envois anonymes : " . $anonymous . " => " . round($anonymous/$nAvionEnvoye*100,2) . "%" . EOLH; + $deleted = deleted(); + echo "Nombre d'avions anonymisés(effacés) : " . $deleted . " => " . round($deleted/$nAvionEnvoye*100,2) . "%" . EOLH; + alea($nAvionEnvoye); } diff --git a/include/config.inc.php b/include/config.inc.php index 126560c..a26e75c 100644 --- a/include/config.inc.php +++ b/include/config.inc.php @@ -20,7 +20,7 @@ $site = "Avion Poème"; $dossier = "/www"; $basedir = dirname( $_SERVER['DOCUMENT_ROOT'] ) . $dossier; -$base_url = "http://avion-poe.me"; +$base_url = "https://avion-poe.me"; $base_path = "/flex/storage/avion-poe.me/site/www/"; $url_admin = $base_url . "/gestion"; $accueil = $base_url . "/index.html";