From adabbf47ab3a39415f375d39e395f01547b4cd9f Mon Sep 17 00:00:00 2001 From: Esenjin Date: Mon, 30 Dec 2024 23:01:28 +0100 Subject: [PATCH] =?UTF-8?q?seul=20le=20premier=20admin=20peut=20acc=C3=A9d?= =?UTF-8?q?er=20aux=20utilisateurs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin.php | 10 ++++++++++ utilisateurs.php | 14 +++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/admin.php b/admin.php index 53c541a..f3f6b23 100644 --- a/admin.php +++ b/admin.php @@ -99,6 +99,15 @@ function showAdminInterface() { + prepare('SELECT MIN(id) as first_id FROM admins'); + $result = $stmt->execute(); + $firstId = $result->fetchArray()['first_id']; + + if ($_SESSION['admin_id'] == $firstId): + ?> + diff --git a/utilisateurs.php b/utilisateurs.php index 9adaac8..524e7d9 100644 --- a/utilisateurs.php +++ b/utilisateurs.php @@ -7,6 +7,18 @@ if (!isset($_SESSION['admin_id'])) { exit; } +// Vérifier que c'est bien le premier administrateur +$db = new SQLite3('database.sqlite'); +$stmt = $db->prepare('SELECT MIN(id) as first_id FROM admins'); +$result = $stmt->execute(); +$firstId = $result->fetchArray()['first_id']; + +if ($_SESSION['admin_id'] != $firstId) { + $_SESSION['error_message'] = "Accès non autorisé. Seul le premier administrateur peut gérer les comptes."; + header('Location: admin.php'); + exit; +} + // Se connecter à la base de données function getDB() { return new SQLite3('database.sqlite'); @@ -301,4 +313,4 @@ while ($row = $result->fetchArray(SQLITE3_ASSOC)) { } - + \ No newline at end of file