reindentation et nettoyage
This commit is contained in:
parent
cbdb690d34
commit
466ba6aaeb
@ -14,10 +14,10 @@ function Connexions_par_salle($salle) {
|
||||
foreach($machines_de_ma_salle as $machine) {
|
||||
$connexions_par_salle[$i] = array();
|
||||
$connexions_par_salle[$i]["machine"] = $machine;
|
||||
$connexions_par_salle[$i]["username"] = $machines_connectees[$machine]["username"];
|
||||
$connexions_par_salle[$i]["stamp"] = $machines_connectees[$machine]["stamp"];
|
||||
$connexions_par_salle[$i]["ip"] = $machines_connectees[$machine]["ip"];
|
||||
$i++;
|
||||
$connexions_par_salle[$i]["username"] = $machines_connectees[$machine]["username"];
|
||||
$connexions_par_salle[$i]["stamp"] = $machines_connectees[$machine]["stamp"];
|
||||
$connexions_par_salle[$i]["ip"] = $machines_connectees[$machine]["ip"];
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
return $connexions_par_salle;
|
||||
@ -27,60 +27,60 @@ function Connexions_par_salle($salle) {
|
||||
// Renvoie toutes les machines existantes
|
||||
// Retourne un tableau associatif : machines[$machine_id] = ($salle, $os, $os_sp, $os_version, $ip_fixe)
|
||||
function Machines() {
|
||||
//$machines = array() ;
|
||||
$db = db_connect();
|
||||
//$machines = array() ;
|
||||
$db = db_connect();
|
||||
|
||||
$req = 'select machine_id, salle, os, os_sp, os_version, ip_fixe from machines order by salle, machine_id';
|
||||
$res = db_query($db, $req);
|
||||
while ($mac = db_fetch_row($res)) {
|
||||
$machines[$mac[0]] = array($mac[1], $mac[2], $mac[3], $mac[4], $mac[5]);
|
||||
}
|
||||
db_free($res);
|
||||
return $machines;
|
||||
$req = 'select machine_id, salle, os, os_sp, os_version, ip_fixe from machines order by salle, machine_id';
|
||||
$res = db_query($db, $req);
|
||||
while ($mac = db_fetch_row($res)) {
|
||||
$machines[$mac[0]] = array($mac[1], $mac[2], $mac[3], $mac[4], $mac[5]);
|
||||
}
|
||||
db_free($res);
|
||||
return $machines;
|
||||
}
|
||||
// Fonction : Machines_de_salle($machines)
|
||||
// Renvoie les machines existantes des salles du tableau $machine (si le tableau est vide, alors appel à Machines()
|
||||
// Retourne un tableau associatif machines_de_salle[$salle_id]=($machine_id1, $machine_id2, ...)
|
||||
// En fait, cette fonction inverse le tableau associatif de la fonction machine sur la clé $salle
|
||||
function Machines_de_salle($machines) {
|
||||
$machines_de_salle = array() ;
|
||||
if (!$machines ) { $machines = Machines(); }
|
||||
while ($mac = current($machines)) {
|
||||
$machines_de_salle[$mac[0]][] = key($machines);
|
||||
next($machines);
|
||||
}
|
||||
return $machines_de_salle;
|
||||
$machines_de_salle = array() ;
|
||||
if (!$machines ) { $machines = Machines(); }
|
||||
while ($mac = current($machines)) {
|
||||
$machines_de_salle[$mac[0]][] = key($machines);
|
||||
next($machines);
|
||||
}
|
||||
return $machines_de_salle;
|
||||
}
|
||||
|
||||
// Fonction Connexion_machine()
|
||||
// Renvoie un tableau associatif des machines connectées:
|
||||
// connexion_machines[$machine_id]["username"] = $username
|
||||
// connexion_machines[$machine_id]["ip"] = $ip
|
||||
// connexion_machines[$machine_id]["stamp"] = $stamp
|
||||
// connexion_machines[$machine_id]["ip"] = $ip
|
||||
// connexion_machines[$machine_id]["stamp"] = $stamp
|
||||
function Connexion_machine() {
|
||||
$connexion_machine = array();
|
||||
$connexions = Connexions();
|
||||
$connexion_machine = array();
|
||||
$connexions = Connexions();
|
||||
if (!empty($connexions)) {
|
||||
foreach($connexions as $con) {
|
||||
foreach($connexions as $con) {
|
||||
$connexion_machine[$con["hote"]] = array();
|
||||
$connexion_machine[$con["hote"]]["username"] = $con["username"];
|
||||
$connexion_machine[$con["hote"]]["ip"] = $con["ip"];
|
||||
$connexion_machine[$con["hote"]]["stamp"] = $con["stamp"];
|
||||
}
|
||||
$connexion_machine[$con["hote"]]["username"] = $con["username"];
|
||||
$connexion_machine[$con["hote"]]["ip"] = $con["ip"];
|
||||
$connexion_machine[$con["hote"]]["stamp"] = $con["stamp"];
|
||||
}
|
||||
}
|
||||
return $connexion_machine;
|
||||
return $connexion_machine;
|
||||
}
|
||||
|
||||
// Fonction Compte($username)
|
||||
// Renvoie les informations sur l'utilisateur du compte
|
||||
// Retourne un array (nom, prenom, groupe)
|
||||
function Compte($username) {
|
||||
$db = db_connect();
|
||||
$req = "SELECT nom, prenom, groupe FROM comptes WHERE username=\"{$username}\"";
|
||||
$res = db_query($db, $req);
|
||||
$compte = db_fetch_row($res);
|
||||
db_free($res);
|
||||
return $compte;
|
||||
$db = db_connect();
|
||||
$req = "SELECT nom, prenom, groupe FROM comptes WHERE username=\"{$username}\"";
|
||||
$res = db_query($db, $req);
|
||||
$compte = db_fetch_row($res);
|
||||
db_free($res);
|
||||
return $compte;
|
||||
}
|
||||
|
||||
// Fonction : Con_ip($ip)
|
||||
@ -88,19 +88,19 @@ function Compte($username) {
|
||||
// Retourne un array (con_id, username, hote, stamp, nom, prenom, groupe)
|
||||
|
||||
function Con_ip($ip) {
|
||||
$con = Connexions();
|
||||
$con_ip = array();
|
||||
$i = 0;
|
||||
$con = Connexions();
|
||||
$con_ip = array();
|
||||
$i = 0;
|
||||
$count = count($con);
|
||||
while($i < $count) {
|
||||
if ($con[$i]["ip"] == $ip ) {
|
||||
$cpt = Compte($con[$i]["username"]);
|
||||
$con_ip = array($con[$i]["con_id"], $con[$i]["username"], $con[$i]["hote"], $con[$i]["stamp"], $cpt[0], $cpt[1], $cpt[2]);
|
||||
break;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
return $con_ip;
|
||||
while($i < $count) {
|
||||
if ($con[$i]["ip"] == $ip ) {
|
||||
$cpt = Compte($con[$i]["username"]);
|
||||
$con_ip = array($con[$i]["con_id"], $con[$i]["username"], $con[$i]["hote"], $con[$i]["stamp"], $cpt[0], $cpt[1], $cpt[2]);
|
||||
break;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
return $con_ip;
|
||||
}
|
||||
|
||||
|
||||
@ -108,28 +108,28 @@ function Con_ip($ip) {
|
||||
// Renvoie les connexions windows en cours du jour
|
||||
// Retourne un array indexé de connexions :
|
||||
// con[i]["con_id"] : id de connexion dans la table connexions
|
||||
// con[i]["username"] : login windows
|
||||
// con[i]["hote"] : nom de la machine
|
||||
// con[i]["stamp"] : timestamp unix de la connexion
|
||||
// con[i]["ip"] : adresse IP de la machine
|
||||
// con[i]["username"] : login windows
|
||||
// con[i]["hote"] : nom de la machine
|
||||
// con[i]["stamp"] : timestamp unix de la connexion
|
||||
// con[i]["ip"] : adresse IP de la machine
|
||||
function Connexions() {
|
||||
$connexions = array();
|
||||
$db = db_connect();
|
||||
$connexions = array();
|
||||
$db = db_connect();
|
||||
|
||||
$req = 'select con_id, username, hote, unix_timestamp(debut_con), ip from connexions where close=0 and (to_days(now())-to_days(debut_con)<1) order by username';
|
||||
$res = db_query($db, $req);
|
||||
$i = 0;
|
||||
while ($con = db_fetch_row($res)) {
|
||||
$req = 'select con_id, username, hote, unix_timestamp(debut_con), ip from connexions where close=0 and (to_days(now())-to_days(debut_con)<1) order by username';
|
||||
$res = db_query($db, $req);
|
||||
$i = 0;
|
||||
while ($con = db_fetch_row($res)) {
|
||||
$connexions[$i] = array();
|
||||
$connexions[$i]["con_id"] = $con[0];
|
||||
$connexions[$i]["username"] = $con[1];
|
||||
$connexions[$i]["hote"] = $con[2];
|
||||
$connexions[$i]["stamp"] = $con[3];
|
||||
$connexions[$i]["ip"] = $con[4];
|
||||
$i++;
|
||||
}
|
||||
db_free($res);
|
||||
return $connexions;
|
||||
$connexions[$i]["con_id"] = $con[0];
|
||||
$connexions[$i]["username"] = $con[1];
|
||||
$connexions[$i]["hote"] = $con[2];
|
||||
$connexions[$i]["stamp"] = $con[3];
|
||||
$connexions[$i]["ip"] = $con[4];
|
||||
$i++;
|
||||
}
|
||||
db_free($res);
|
||||
return $connexions;
|
||||
}
|
||||
|
||||
|
||||
@ -142,17 +142,17 @@ function Connexions() {
|
||||
// last_conn["close"] : 0 | 1 booléen indiquant si la connexion est terminée (1=close)
|
||||
function Derniere_connexion_machine($hote) {
|
||||
$last_conn = array();
|
||||
$db = db_connect();
|
||||
$db = db_connect();
|
||||
|
||||
$req = 'SELECT username, debut_con, fin_con, close FROM `connexions` WHERE hote="'.$hote.'" order by con_id desc limit 1';
|
||||
$res = db_query($db, $req);
|
||||
$req = 'SELECT username, debut_con, fin_con, close FROM `connexions` WHERE hote="'.$hote.'" order by con_id desc limit 1';
|
||||
$res = db_query($db, $req);
|
||||
while ($con = db_fetch_row($res)) {
|
||||
$last_conn["username"] = $con[0];
|
||||
$last_conn["debut"] = $con[1];
|
||||
$last_conn["fin"] = $con[2];
|
||||
$last_conn["close"] = $con[3];
|
||||
}
|
||||
db_free($res);
|
||||
db_free($res);
|
||||
return $last_conn;
|
||||
}
|
||||
|
||||
@ -186,22 +186,22 @@ function Connexion_doyenne_salle($machines_de_la_salle) {
|
||||
|
||||
function Connexions_wifi() {
|
||||
$connexions_wifi = array();
|
||||
$db = db_connect();
|
||||
$db = db_connect();
|
||||
|
||||
$req = 'select wifi_id, wifi_username, wifi_ip, wifi_browser, unix_timestamp(wifi_deb_conn) from wifi where close=0 and (to_days(now())-to_days(wifi_deb_conn)<1) order by wifi_deb_conn';
|
||||
$res = db_query($db, $req);
|
||||
$i = 0;
|
||||
while ($con = db_fetch_row($res)) {
|
||||
$connexions_wifi[$i]["id"] = $con[0];
|
||||
$connexions_wifi[$i]["username"] = $con[1];
|
||||
$connexions_wifi[$i]["ip"] = $con[2];
|
||||
$connexions_wifi[$i]["browser"] = $con[3];
|
||||
$connexions_wifi[$i]["debut"] = $con[4];
|
||||
$i++;
|
||||
}
|
||||
$req = 'select wifi_id, wifi_username, wifi_ip, wifi_browser, unix_timestamp(wifi_deb_conn) from wifi where close=0 and (to_days(now())-to_days(wifi_deb_conn)<1) order by wifi_deb_conn';
|
||||
$res = db_query($db, $req);
|
||||
$i = 0;
|
||||
while ($con = db_fetch_row($res)) {
|
||||
$connexions_wifi[$i]["id"] = $con[0];
|
||||
$connexions_wifi[$i]["username"] = $con[1];
|
||||
$connexions_wifi[$i]["ip"] = $con[2];
|
||||
$connexions_wifi[$i]["browser"] = $con[3];
|
||||
$connexions_wifi[$i]["debut"] = $con[4];
|
||||
$i++;
|
||||
}
|
||||
|
||||
db_free($res);
|
||||
return $connexions_wifi;
|
||||
db_free($res);
|
||||
return $connexions_wifi;
|
||||
}
|
||||
|
||||
// function connexions_blacklist_live()
|
||||
@ -212,20 +212,20 @@ function Connexions_wifi() {
|
||||
// $connexion_bl_live[$i]["target"] : thème de la blacklist concerné - adult, warez, games, etc
|
||||
function Connexions_blacklist_live() {
|
||||
$connexions_bl_live = array();
|
||||
$db = db_connect();
|
||||
$db = db_connect();
|
||||
|
||||
$req = 'select ip, username, target from proxy where timestampdiff(SECOND, timestamp(logts), timestamp(now())) < 15'; // on récupère les logs non checkés datant moins de 15s
|
||||
$res = db_query($db, $req);
|
||||
$i = 0;
|
||||
while ($log = db_fetch_row($res)) {
|
||||
$connexions_bl_live[$i]["ip"] = $log[0];
|
||||
$connexions_bl_live[$i]["username"] = $log[1];
|
||||
$connexions_bl_live[$i]["target"] = $log[2];
|
||||
$i++;
|
||||
}
|
||||
$req = 'select ip, username, target from proxy where timestampdiff(SECOND, timestamp(logts), timestamp(now())) < 15'; // on récupère les logs non checkés datant moins de 15s
|
||||
$res = db_query($db, $req);
|
||||
$i = 0;
|
||||
while ($log = db_fetch_row($res)) {
|
||||
$connexions_bl_live[$i]["ip"] = $log[0];
|
||||
$connexions_bl_live[$i]["username"] = $log[1];
|
||||
$connexions_bl_live[$i]["target"] = $log[2];
|
||||
$i++;
|
||||
}
|
||||
|
||||
db_free($res);
|
||||
return $connexions_bl_live;
|
||||
db_free($res);
|
||||
return $connexions_bl_live;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user