1.7 log EDUROAM

This commit is contained in:
Jérôme Bousquié 2019-04-09 12:13:12 +02:00
parent 2e6c628d9d
commit 4811f556da
5 changed files with 47 additions and 20 deletions

View File

@ -244,7 +244,7 @@ function Connexions_wifi() {
$db = db_connect();
$req_close = "UPDATE wifi SET close = 1 WHERE DATE(wifi_deb_conn) < CURDATE()";
$req = "SELECT wifi_id, wifi_username, wifi_ip, wifi_browser, wifi_deb_conn, prenom, nom, groupe FROM wifi, comptes WHERE close = 0 AND username = wifi_username ORDER BY wifi_deb_conn DESC";
$req = "SELECT wifi_id, wifi_username, wifi_ip, wifi_browser, wifi_deb_conn, prenom, nom, groupe FROM wifi LEFT JOIN comptes ON wifi_username = username WHERE close = 0 ORDER BY wifi_deb_conn DESC";
db_query($db, $req_close);
$res = db_query($db, $req);
@ -302,8 +302,11 @@ function Connexions_blacklist_live($delay, &$machines) {
// Ferme les connexions encore ouvertes des jours antérieurs au jour courant dans la table connexions
// Copie toutes les connexions fermées des jours antérieurs dans la table total_connexions
// Purge les connexions copiées de la table connexions
// Idem pour les connexions Wifi avec les tables wifi et total_wifi
// Retourne le nombre de connexions archivées
function ArchiveConnexions() {
$nb_archivables = 0;
$nb_archivables_wifi = 0;
$db = db_connect();
$req_marque_archivables = 'UPDATE connexions SET close = 1, archivable = 1 where DATE(fin_con) < CURDATE()';
@ -313,11 +316,22 @@ function ArchiveConnexions() {
if ($nb_archivables != 0) {
$req_archive = 'INSERT INTO total_connexions SELECT con_id, username, hote, ip, fin_con, debut_con FROM connexions WHERE archivable = 1';
$req_purge_archivees = 'DELETE FROM connexions WHERE archivable = 1';
db_query($db, $req_marque_archivables);
db_query($db, $req_archive);
db_query($db, $req_purge_archivees);
}
return $nb_archivables;
$req_marque_archivables_wifi = 'UPDATE wifi SET close = 1, archivable = 1 where DATE(wifi_deb_conn) < CURDATE()';
$res_wifi = db_query($db, $req_marque_archivables_wifi);
$nb_archivables_wifi = db_affected_rows($db);
if ($nb_archivables_wifi != 0) {
$req_archive_wifi = 'INSERT INTO total_wifi SELECT wifi_id, wifi_username, wifi_ip, wifi_browser, wifi_deb_conn FROM wifi WHERE archivable = 1';
$req_purge_archivees_wifi = 'DELETE FROM wifi WHERE archivable = 1';
db_query($db, $req_archive_wifi);
db_query($db, $req_purge_archivees_wifi);
}
return $nb_archivables + $nb_archivables_wifi;
}
// Fonction PingTimestamp() :

View File

@ -265,35 +265,43 @@ function RechercheWifi(&$db) {
$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 ?'";
$req_wifi = $req_wifi." FROM wifi, comptes WHERE wifi_username = username ";
$where = "";
$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 ?'";
$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 . " AND wifi_username LIKE \"$compte\" ";
$where = $where . " wifi_username LIKE \"$compte\" ";
$liste_const = $liste_const. "compte = <i>$compte</i><br/>";
$contrainte = true;
}
if ($nom != "") {
$where = $where ." AND nom LIKE \"{$nom}\"";
$and = ($contrainte) ? " AND " : "";
$where = $where . $and ."nom LIKE \"{$nom}\"";
$liste_const = $liste_const. "nom = <i>$nom</i><br/>";
$contrainte = true;
}
if ($prenom != "") {
$where = $where . " AND prenom LIKE \"{$prenom}\"";
$and = ($contrainte) ? " AND " : "";
$where = $where . $and . "prenom LIKE \"{$prenom}\"";
$liste_const = $liste_const. "prénom = <i>$prenom</i><br/>";
$contrainte = true;
}
if ($groupe != "") {
$where = $where . " AND groupe LIKE \"{$groupe}\"";
$and = ($contrainte) ? " AND " : "";
$where = $where . "groupe LIKE \"{$groupe}\"";
$liste_const = $liste_const. "groupe = <i>$groupe</i><br/>";
$contrainte = true;
}
if ($ip != "") {
$where = $where ." AND wifi_ip LIKE \"{$ip}\"";
$and = ($contrainte) ? " AND " : "";
$where = $where . $and . "wifi_ip LIKE \"{$ip}\"";
$liste_const = $liste_const. "adresse IP = <i>$ip</i><br/>";
$contrainte = true;
}
if ($browser != "") {
$where = $where . "AND wifi_browser LIKE \"{$browser}\"";
$and = ($contrainte) ? " AND " : "";
$where = $where . $and . "wifi_browser LIKE \"{$browser}\"";
$liste_const = $liste_const. "browser/device = <i>$browser</i><br/>";
$contrainte = true;
}
@ -306,7 +314,8 @@ function RechercheWifi(&$db) {
$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}\"";
$and = ($contrainte) ? " AND " : "";
$where = $where . $and . "wifi_deb_conn >= \"{$date_debut_00}\" AND wifi_deb_conn <= \"{$date_fin_24}\"";
$liste_const = $liste_const. "du <i>$date_debut</i> au <i>$date_fin</i><br/>";
$contrainte = true;
}
@ -318,7 +327,8 @@ function RechercheWifi(&$db) {
$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}\"";
$and = ($contrainte) ? " AND " : "";
$where = $where . $and . "wifi_deb_conn >= \"{$date_debut_00}\" AND wifi_deb_conn <= \"{$date_debut_24}\"";
$liste_const = $liste_const. "date : <i>$date_debut</i><br/>";
$contrainte = true;
}
@ -326,11 +336,9 @@ function RechercheWifi(&$db) {
if (!$contrainte) {
return false;
}
$req = "$req_wifi $where ORDER BY wifi_deb_conn DESC";
$req = "($req_wifi $where) UNION ($req_total_wifi $where) ORDER BY'Heure connexion' DESC";
$res = db_query($db, $req);
return $res;
}
// fonction AfficheResultats($tab) : formatte l'affichage d'un jeu de résultats

View File

@ -60,7 +60,7 @@ $police["A102"] = 11;
$orientation["A102"][0]="V";
$ligne_coord["A102"][0] = array(100, 100);
$ligne_machines["A102"][0] = array('A102Z1','A102A1');
$ligne_machines["A102"][0] = array('A102Z1','A102A1','A102A2','A102A3');
$shift["A102"][0] = 10;
$orientation["A102"][1]="V";

View File

@ -1,6 +1,6 @@
<?php
// Version
$version = "1.6";
$version = "1.7";
// URL administration de Winlog
$winlog_url = "https://winlog.iut-rodez.fr/admin/";
// URL serveur Winlog : URL sur laquelle les requêtes des PC clients arrivent
@ -119,7 +119,11 @@ $repertoire_scripts = "./vbs/";
// WIFI
// adresse IP du serveur émettant la requête de log Wifi
// $portal_message_ip est l'adresse du serveur présentant le message d'accueil du portail captif d'authentification Wifi
// $radius_server_ip est l'adresse du serveur radius utilisé par Eduroam
// Mettre la même valeur dans les deux variables si un seul serveur présent
$portal_message_ip = "192.168.100.64";
$radius_server_ip = "192.168.100.67";
// RPC : lancement d'une commande à distance sur un PC
// URL du serveur web traitant les requêtes RPC

View File

@ -3,14 +3,15 @@ include_once('../admin/winlog_admin_conf.php');
include_once('../admin/db_access.php');
// on n'accepte que les POST venant du portail wifi autorisé
if ($_SERVER["REQUEST_METHOD"] == "POST" && $_SERVER["REMOTE_ADDR"] == $portal_message_ip) {
$remote_addr = $_SERVER["REMOTE_ADDR"];
if ($_SERVER["REQUEST_METHOD"] == "POST" && ($remote_addr == $portal_message_ip || $remote_addr == $radius_server_ip)) {
$db = db_connect();
$wifi_username = db_escape_string($db, $_POST["username"]);
$wifi_ip = db_escape_string($db, $_POST["ip"]);
$wifi_browser = db_escape_string($db, $_POST["agent"]);
$req = "INSERT INTO wifi (wifi_username, wifi_ip, wifi_browser) VALUES (\"$wifi_username\", \"$wifi_ip\", \"$wifi_browser\")";
$req = "INSERT IGNORE INTO wifi (wifi_username, wifi_ip, wifi_browser) VALUES (\"$wifi_username\", \"$wifi_ip\", \"$wifi_browser\")";
db_query($db, $req);
}
?>