forked from gdgpescara/app-mod-workshop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
33 lines (27 loc) · 900 Bytes
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
include 'config.php';
if (!isset($_SESSION['user_id'])) {
header("Location: login.php");
exit;
}
// Se l'utente è amministratore, può vedere tutte le immagini
$is_admin = ($_SESSION['role'] == 'admin');
if ($is_admin) {
$stmt = $pdo->query("SELECT * FROM images");
} else {
$stmt = $pdo->query("SELECT * FROM images WHERE inappropriate = 0");
}
$images = $stmt->fetchAll();
?>
<h1>Catalogo Immagini</h1>
<?php foreach ($images as $image): ?>
<div>
<img src="<?php echo $image['filename']; ?>" alt="Immagine" width="200" />
<?php if ($is_admin): ?>
<form method="post" action="inappropriate.php">
<input type="hidden" name="image_id" value="<?php echo $image['id']; ?>" />
<button type="submit">Segnala come Inappropriata</button>
</form>
<?php endif; ?>
</div>
<?php endforeach; ?>