$salle
"; } if ($machine != "") { $and = ($contrainte) ? " AND " : ""; $where = $where . $and . "hote LIKE \"{$machine}\""; $contrainte = true; $liste_const = $liste_const. "machine = $machine
"; } if ($compte != "") { $and = ($contrainte) ? " AND " : ""; $where = $where . $and . "username LIKE \"{$compte}\""; $contrainte = true; $liste_const = $liste_const. "compte = $compte
"; } if ($ip != "") { $and = ($contrainte) ? " AND " : ""; $where = $where . $and . " ip LIKE \"{$ip}\""; $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); if (isset($tab_deb[2]) && isset($tab_fin[2])) { $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); if (isset($tab_deb[2])) { $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"; $res = db_query($db, $req); return $res; } // fonction RechercheUtilisateurs : renvoie un tableau de résultats contenant les utilisateurs demandés function RechercheUtilisateurs(&$db) { global $_POST; global $liste_const; $compte = db_escape_string($db, $_POST["compte"]); $nom = db_escape_string($db, $_POST["nom"]); $prenom = db_escape_string($db, $_POST["prenom"]); $groupe = db_escape_string($db, $_POST["groupe"]); $req_utilisateurs = "SELECT username AS 'Compte', prenom AS 'Prénom', nom AS 'Nom', groupe AS 'Groupe', compte_id AS 'Id' FROM comptes"; $where = " WHERE "; $contrainte = false; if ($compte != "") { $where = $where . "username LIKE \"$compte\" "; $contrainte = true; $liste_const = $liste_const. "compte = $compte
"; } if ($nom != "") { $and = ($contrainte) ? " AND " : ""; $where = $where . $and . "nom LIKE \"{$nom}\""; $contrainte = true; $liste_const = $liste_const. "machine = $nom
"; } if ($prenom != "") { $and = ($contrainte) ? " AND " : ""; $where = $where . $and . "prenom LIKE \"{$prenom}\""; $contrainte = true; $liste_const = $liste_const. "prenom = $prenom
"; } if ($groupe != "") { $and = ($contrainte) ? " AND " : ""; $where = $where . $and . "groupe LIKE \"{$groupe}\""; $contrainte = true; $liste_const = $liste_const. "groupe = $groupe
"; } if (!$contrainte) { return false; } $req = "$req_utilisateurs $where ORDER BY username DESC"; $res = db_query($db, $req); return $res; } // fonction RechercheMachines : renvoie un tableau de résultats contenant les machines demandées function RechercheMachines(&$db) { global $_POST; global $liste_const; $machine = db_escape_string($db, $_POST["machine"]); $salle = db_escape_string($db, $_POST["salle"]); $os = db_escape_string($db, $_POST["os"]); $sp = db_escape_string($db, $_POST["sp"]); $os_version = db_escape_string($db, $_POST["os_version"]); $ip = db_escape_string($db, $_POST["ip"]); $marque = db_escape_string($db, $_POST["marque"]); $modele = db_escape_string($db, $_POST["modele"]); $arch = db_escape_string($db, $_POST["arch"]); $mac = db_escape_string($db, $_POST["mac"]); $iface = db_escape_string($db, $_POST["iface"]); $req_machines = "SELECT machine_id AS 'Machine', salle AS 'Salle', adresse_ip AS 'Adresse IP', os AS 'Système', os_sp AS 'Service Pack', os_version AS 'Version'"; $req_machines = $req_machines.", type_systeme AS 'archi OS', marque AS 'Marque', modele AS 'Modèle', mac_description AS 'Carte réseau', mac AS 'Adresse MAC', ROUND(ram/1000000000, 1) AS 'RAM (Go)', ROUND(procSpeed/1000, 1) AS 'Proc (GHz)', ROUND(diskSize/1000000000, 1) AS 'Disque C: (Go)', ROUND(freeSpace/1000000000, 1) AS 'Libre C: (Go)' FROM machines"; $where = " WHERE "; $contrainte = false; if ($machine != "") { $where = $where . "machine_id LIKE \"$machine\" "; $contrainte = true; $liste_const = $liste_const. "machine = $machine
"; } if ($salle != "") { $and = ($contrainte) ? " AND " : ""; $where = $where . $and . "salle LIKE \"{$salle}\""; $contrainte = true; $liste_const = $liste_const. "salle = $salle
"; } if ($os != "") { $and = ($contrainte) ? " AND " : ""; $where = $where . $and . "os LIKE \"{$os}\""; $contrainte = true; $liste_const = $liste_const. "OS = $os
"; } if ($sp != "") { $and = ($contrainte) ? " AND " : ""; $where = $where . $and . "sp LIKE \"{$sp}\""; $contrainte = true; $liste_const = $liste_const. "Service Pack = $sp
"; } if ($os_version != "") { $and = ($contrainte) ? " AND " : ""; $where = $where . $and . "os_version LIKE \"{$os_version}\""; $contrainte = true; $liste_const = $liste_const. "version OS = $os_version
"; } if ($ip != "") { $and = ($contrainte) ? " AND " : ""; $where = $where . $and . "adresse_ip LIKE \"{$ip}\""; $contrainte = true; $liste_const = $liste_const. "adresse IP = $ip
"; } if ($marque != "") { $and = ($contrainte) ? " AND " : ""; $where = $where . $and . "marque LIKE \"{$marque}\""; $contrainte = true; $liste_const = $liste_const. "marque = $marque
"; } if ($modele != "") { $and = ($contrainte) ? " AND " : ""; $where = $where . $and . "modele LIKE \"{$modele}\""; $contrainte = true; $liste_const = $liste_const. "modèle = $modele
"; } if ($arch != "") { $and = ($contrainte) ? " AND " : ""; $where = $where . $and . "type_systeme LIKE \"{$arch}\""; $contrainte = true; $liste_const = $liste_const. "architecture système = $arch
"; } if ($mac != "") { $and = ($contrainte) ? " AND " : ""; $where = $where . $and . "mac LIKE \"{$mac}\""; $contrainte = true; $liste_const = $liste_const. "adresse MAC = $mac
"; } if ($iface != "") { $and = ($contrainte) ? " AND " : ""; $where = $where . $and . "mac_description LIKE \"{$iface}\""; $contrainte = true; $liste_const = $liste_const. "carte réseau = $iface
"; } if (!$contrainte) { return false; } $req = "$req_machines $where ORDER BY machine_id, salle"; $res = db_query($db, $req); return $res; } // fonction RechercheWifi : renvoie un tableau de résultats contenant les connexions Wifi demandées function RechercheWifi(&$db) { global $_POST; global $liste_const; $compte = db_escape_string($db, $_POST["compte"]); $nom = db_escape_string($db, $_POST["nom"]); $prenom = db_escape_string($db, $_POST["prenom"]); $ip = db_escape_string($db, $_POST["ip"]); $browser = db_escape_string($db, $_POST["browser"]); $date_debut = db_escape_string($db, $_POST["date_debut"]); $date_fin = db_escape_string($db, $_POST["date_fin"]); $contrainte = false; $req_wifi = "SELECT nom AS 'Nom', prenom AS 'Prénom', wifi_username AS 'Compte', wifi_ip AS 'Adresse IP', wifi_browser AS 'Browser/Device', wifi_deb_conn AS 'Heure connexion', close AS 'Fermée ?'"; $req_wifi = $req_wifi." FROM wifi, comptes WHERE wifi_username = username "; $where = ""; if ($compte != "") { $where = $where . " AND wifi_username LIKE \"$compte\" "; $liste_const = $liste_const. "compte = $compte
"; $contrainte = true; } if ($nom != "") { $where = $where ." AND nom LIKE \"{$nom}\""; $liste_const = $liste_const. "nom = $nom
"; $contrainte = true; } if ($prenom != "") { $where = $where . " AND prenom LIKE \"{$prenom}\""; $liste_const = $liste_const. "prénom = $prenom
"; $contrainte = true; } if ($ip != "") { $where = $where ." AND wifi_ip LIKE \"{$ip}\""; $liste_const = $liste_const. "adresse IP = $ip
"; $contrainte = true; } if ($browser != "") { $where = $where . "AND wifi_browser LIKE \"{$browser}\""; $liste_const = $liste_const. "browser/device = $browser
"; $contrainte = true; } 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); if (isset($tab_deb[2]) && isset($tab_fin[2])) { $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]) ); $date_debut_00 = "$isodate_d 00:00:00"; $date_fin_24 = "$isodate_f 23:59:59"; $where = $where . " AND wifi_deb_conn >= \"{$date_debut_00}\" AND wifi_deb_conn <= \"{$date_fin_24}\""; $liste_const = $liste_const. "du $date_debut au $date_fin
"; $contrainte = true; } } elseif ($date_debut != "") { // transformation de la date JJ/MM/AAAA en date iso AAAA-MM-JJ $tab_deb = explode("/", $date_debut); if (isset($tab_deb[2])) { $isodate_d = sprintf( "%04d-%02d-%02d", (int)trim($tab_deb[2]), (int)trim($tab_deb[1]), (int)trim($tab_deb[0]) ); $date_debut_00 = "$isodate_d 00:00:00"; $date_debut_24 = "$isodate_d 23:59:59"; $where = $where . " AND wifi_deb_conn >= \"{$date_debut_00}\" AND wifi_deb_conn <= \"{$date_debut_24}\""; $liste_const = $liste_const. "date : $date_debut
"; $contrainte = true; } } if (!$contrainte) { return false; } $req = "$req_wifi $where ORDER BY wifi_deb_conn DESC"; $res = db_query($db, $req); return $res; } // fonction AfficheResultats($tab) : formatte l'affichage d'un jeu de résultats function FormatteResultats(&$db, &$res) { $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
"; } return $resultats; } // ===================== // Programme principal $db = db_connect(); $objet = $_POST["objet"]; $liste_const = ""; // variable globale switch ($objet) { case "connexions": $donnees = RechercheConnexions($db); break; case "utilisateurs": $donnees = RechercheUtilisateurs($db); break; case "machines": $donnees = RechercheMachines($db); break; case "wifi": $donnees = RechercheWifi($db); break; default: $donnees = false; break; } if (!$donnees) { $resultats = "Vous devez saisir au moins un critère."; } else { $resultats = FormatteResultats($db, $donnees); } ?> Winlog

WINLOG

Retour au menu de recherche

Rappel critères :

Résultats :

Retour au menu de recherche