From 728fb21dd8786140716280e88e989968c4d21f3c Mon Sep 17 00:00:00 2001 From: jbousquie Date: Thu, 1 Dec 2016 14:03:10 +0100 Subject: [PATCH] translation date JJ/MM/AAAA en AAAA-MM-JJ --- admin/recherche.php | 65 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 49 insertions(+), 16 deletions(-) diff --git a/admin/recherche.php b/admin/recherche.php index d5f3023..3e8bb37 100644 --- a/admin/recherche.php +++ b/admin/recherche.php @@ -43,8 +43,8 @@ function RechercheConnexions(&$db) { $date_debut = db_escape_string($db, $_POST["date_debut"]); $date_fin = db_escape_string($db, $_POST["date_fin"]); - $req_connexions = "SELECT con_id, username, hote, ip, fin_con, debut_con, close FROM connexions"; - $req_total_connexions = "SELECT con_id, username, hote, ip, fin_con, debut_con, 1 FROM total_connexions"; + $req_connexions = "SELECT username AS 'Compte', hote AS 'Machine', debut_con AS 'Début connexion', fin_con AS 'Fin connexion', close AS 'fermée ?', ip AS 'Adresse IP', con_id AS 'Id connexion' FROM connexions"; + $req_total_connexions = "SELECT username AS 'Compte', hote AS 'Machine', debut_con AS 'Début connexion', fin_con AS 'Fin connexion', 1 AS 'fermée ?', ip AS 'Adresse IP', con_id AS 'Id connexion' FROM total_connexions"; $where = " WHERE "; $contrainte = false; if ($salle != "") { @@ -72,11 +72,35 @@ function RechercheConnexions(&$db) { $contrainte = true; $liste_const = $liste_const. "ip = $ip
"; } + if ($date_debut != "" && $date_fin != "") { + // transformation de la date JJ/MM/AAAA en date iso AAAA-MM-JJ + $tab_deb = explode("/", $date_debut); + $tab_fin = explode("/", $date_fin); + $isodate_d = sprintf( "%04d-%02d-%02d", (int)trim($tab_deb[2]), (int)trim($tab_deb[1]), (int)trim($tab_deb[0]) ); + $isodate_f = sprintf( "%04d-%02d-%02d", (int)trim($tab_fin[2]), (int)trim($tab_fin[1]), (int)trim($tab_fin[0]) ); + $and = ($contrainte) ? " AND " : ""; + $date_debut_00 = "$isodate_d 00:00:00"; + $date_fin_24 = "$isodate_f 23:59:59"; + $where = $where . $and . " debut_con >= \"{$date_debut_00}\" AND fin_con <= \"{$date_fin_24}\""; + $contrainte = true; + $liste_const = $liste_const. "du $date_debut au $date_fin
"; + } + elseif ($date_debut != "") { + // transformation de la date JJ/MM/AAAA en date iso AAAA-MM-JJ + $tab_deb = explode("/", $date_debut); + $isodate_d = sprintf( "%04d-%02d-%02d", (int)trim($tab_deb[2]), (int)trim($tab_deb[1]), (int)trim($tab_deb[0]) ); + $and = ($contrainte) ? " AND " : ""; + $date_debut_00 = "$isodate_d 00:00:00"; + $date_debut_24 = "$isodate_d 23:59:59"; + $where = $where . $and . " debut_con >= \"{$date_debut_00}\" AND fin_con <= \"{$date_debut_24}\""; + $contrainte = true; + $liste_const = $liste_const. "date : $date_debut
"; + } if (!$contrainte) { return false; } - $req = "($req_connexions $where) UNION ($req_total_connexions $where) ORDER BY con_id DESC"; + $req = "($req_connexions $where) UNION ($req_total_connexions $where) ORDER BY 'Id connexion' DESC"; $res = db_query($db, $req); return $res; @@ -84,20 +108,27 @@ function RechercheConnexions(&$db) { // fonction AfficheResultats($tab) : formatte l'affichage d'un jeu de résultats function FormatteResultats(&$db, &$res) { - $r = ""; - $cols = db_fetch_column_names($res); - foreach($cols as $name) { - $r = $r . "$name"; + $r = "n°"; + $resultats = "La recherche n'a abouti à aucun résultat."; + $nb = db_num_rows($res); + if ($nb != 0) { + $cols = db_fetch_column_names($res); + foreach($cols as $name) { + $r = $r . "$name"; + } + $cpt = 1; + while ($li = db_fetch_row($res)) { + $li_coul = ($cpt % 2 == 0) ? "odd" : "even"; + $r = $r . "$cpt"; + foreach($li as $col) { + $r = $r . "$col"; + } + $r = $r . "\n"; + $cpt = $cpt + 1; + } + db_free($res); + $resultats = "$nb résultats trouvés
\n\n$r
"; } - while ($li = db_fetch_row($res)) { - $r = $r . ""; - foreach($li as $col) { - $r = $r . "$col"; - } - $r = $r . "\n"; - } - db_free($res); - $resultats = "\n$r
"; return $resultats; } ?> @@ -110,6 +141,7 @@ function FormatteResultats(&$db, &$res) {

WINLOG

+

Retour au menu de recherche

Rappel critères :

@@ -117,6 +149,7 @@ function FormatteResultats(&$db, &$res) { +

Retour au menu de recherche