From ad352fb619ac879ed6e48ef01815448ddbee462d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Bousqui=C3=A9?= Date: Thu, 6 Dec 2018 10:56:21 +0100 Subject: [PATCH] =?UTF-8?q?log=20des=20connexions=20=C3=A0=20la=20console?= =?UTF-8?q?=20d'admin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/connexions.php | 11 ++++++++ admin/index.php | 8 ++++++ admin/login.php | 2 ++ admin/login_ldap.php | 4 ++- winlog.sql | 66 +++++++++++++++++++++++++++++++++++++++----- 5 files changed, 83 insertions(+), 8 deletions(-) diff --git a/admin/connexions.php b/admin/connexions.php index f2c751d..a4c98bb 100644 --- a/admin/connexions.php +++ b/admin/connexions.php @@ -397,4 +397,15 @@ function FormateDelta(&$delta) { return (string)$secs.$unit; } + +// Fonction LogAdminConnexion(username) +// Insère un enregistrement dans la table de log des connexions à la console d'administration de Winlog +function LogAdminConnexion($username) { + $db = db_connect(); + + $req = "INSERT INTO log_admin_connexions (username) VALUES ('".$username."')"; + db_query($db, $req); + +} + ?> diff --git a/admin/index.php b/admin/index.php index a5f38f8..5caf141 100644 --- a/admin/index.php +++ b/admin/index.php @@ -17,9 +17,17 @@ switch ($auth_mode) { break; case "CAS": + $log = false; + if (!isset($_SESSION['username'])) { + // si la session n'est pas déjà démarrée, alors il faudra logguer la première connexion + $log = true; + } // la session PHP est déjà démarrée par la lib phpCAS. include('libhome.php'); $username = phpCAS::getUser(); + if ($log) { + LogAdminConnexion($username); + } break; case "LDAP": diff --git a/admin/login.php b/admin/login.php index 7e6e8d3..71d54f9 100644 --- a/admin/login.php +++ b/admin/login.php @@ -1,6 +1,7 @@