$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;
global $mode_ping;
$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"]);
$ping_join = "";
$ping_col = "";
if ($mode_ping) {
$ping_join = " LEFT OUTER JOIN ping ON machines.machine_id = ping.machine_id ";
$ping_col = ", ping_timestamp AS 'Dernier ping' ";
}
$req_machines = "SELECT machines.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)' $ping_col FROM machines".$ping_join;
$where = " WHERE ";
$contrainte = false;
if ($machine != "") {
$where = $where . "machines.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 machines.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;
global $res_bool;
$res_bool = true;
$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"]);
$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 wifi_username AS 'Compte', nom AS 'Nom', prenom AS 'Prénom', groupe AS 'Groupe', wifi_ip AS 'Adresse IP', wifi_browser AS 'Browser/Device', wifi_deb_conn AS 'Heure connexion', close AS 'Fermée ?', wifi_id";
$req_wifi = $req_wifi." FROM wifi LEFT OUTER JOIN comptes ON wifi.wifi_username = comptes.username ";
$req_total_wifi = "SELECT wifi_username AS 'Compte', nom AS 'Nom', prenom AS 'Prénom', groupe AS 'Groupe', wifi_ip AS 'Adresse IP', wifi_browser AS 'Browser/Device', wifi_deb_conn AS 'Heure connexion', 1 AS 'Fermée ?', wifi_id";
$req_total_wifi = $req_total_wifi." FROM total_wifi LEFT OUTER JOIN comptes ON total_wifi.wifi_username = comptes.username ";
$where = " WHERE ";
$contrainte = false;
if ($compte != "") {
$where = $where . " wifi_username LIKE \"$compte\" ";
$liste_const = $liste_const. "compte = $compte
";
$contrainte = true;
}
if ($nom != "") {
$and = ($contrainte) ? " AND " : "";
$where = $where . $and ."nom LIKE \"{$nom}\"";
$liste_const = $liste_const. "nom = $nom
";
$contrainte = true;
}
if ($prenom != "") {
$and = ($contrainte) ? " AND " : "";
$where = $where . $and . "prenom LIKE \"{$prenom}\"";
$liste_const = $liste_const. "prénom = $prenom
";
$contrainte = true;
}
if ($groupe != "") {
$and = ($contrainte) ? " AND " : "";
$where = $where . "groupe LIKE \"{$groupe}\"";
$liste_const = $liste_const. "groupe = $groupe
";
$contrainte = true;
}
if ($ip != "") {
$and = ($contrainte) ? " AND " : "";
$where = $where . $and . "wifi_ip LIKE \"{$ip}\"";
$liste_const = $liste_const. "adresse IP = $ip
";
$contrainte = true;
}
if ($browser != "") {
$and = ($contrainte) ? " AND " : "";
$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";
$and = ($contrainte) ? " AND " : "";
$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";
$and = ($contrainte) ? " AND " : "";
$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) UNION ($req_total_wifi $where) ORDER BY wifi_id 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 = "
Les résultats booléens sont exprimés en chiffre : 0 = faux, 1 = vrai.
"; } ?>WINLOG-R
Rappel critères :
Résultats :