seul le premier admin peut accéder aux utilisateurs
This commit is contained in:
parent
10806e5aec
commit
adabbf47ab
10
admin.php
10
admin.php
@ -99,6 +99,15 @@ function showAdminInterface() {
|
||||
</div>
|
||||
</a>
|
||||
|
||||
<?php
|
||||
// Vérifier si c'est le premier administrateur
|
||||
$db = getDB();
|
||||
$stmt = $db->prepare('SELECT MIN(id) as first_id FROM admins');
|
||||
$result = $stmt->execute();
|
||||
$firstId = $result->fetchArray()['first_id'];
|
||||
|
||||
if ($_SESSION['admin_id'] == $firstId):
|
||||
?>
|
||||
<a href="utilisateurs.php" class="admin-menu-item">
|
||||
<div class="menu-icon">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
@ -111,6 +120,7 @@ function showAdminInterface() {
|
||||
<p>Gérez les comptes administrateurs de la galerie photo.</p>
|
||||
</div>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
@ -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)) {
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
Loading…
x
Reference in New Issue
Block a user