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>
|
</div>
|
||||||
</a>
|
</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">
|
<a href="utilisateurs.php" class="admin-menu-item">
|
||||||
<div class="menu-icon">
|
<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">
|
<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>
|
<p>Gérez les comptes administrateurs de la galerie photo.</p>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
@ -7,6 +7,18 @@ if (!isset($_SESSION['admin_id'])) {
|
|||||||
exit;
|
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
|
// Se connecter à la base de données
|
||||||
function getDB() {
|
function getDB() {
|
||||||
return new SQLite3('database.sqlite');
|
return new SQLite3('database.sqlite');
|
||||||
@ -301,4 +313,4 @@ while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
Loading…
x
Reference in New Issue
Block a user