generated from francesco/deploy-dinamico
154 lines
4.8 KiB
PHP
154 lines
4.8 KiB
PHP
<?php
|
|
|
|
if (isset($_GET['s'])) {
|
|
highlight_file("index.php");
|
|
return;
|
|
}
|
|
|
|
// Ricerca film dal DB
|
|
|
|
// Questi valori vengono letti automaticamente
|
|
$host = getenv('DB_HOST'); // Sarà "local_db"
|
|
$db = getenv('DB_NAME'); // Sarà "nomerepository-nomeutente"
|
|
$user = getenv('DB_USER'); // Uguale al nome DB
|
|
$pass = getenv('DB_PASS'); // Password generata casualmente ad ogni deploy
|
|
$charset = 'utf8mb4';
|
|
|
|
$dsn = "mysql:host=$host;dbname=$db;charset=$charset";
|
|
|
|
try {
|
|
$pdo = new PDO($dsn, $user, $pass);
|
|
} catch (\PDOException $e) {
|
|
throw new \PDOException($e->getMessage(), (int) $e->getCode());
|
|
}
|
|
|
|
// Collegamento al DB effettuato
|
|
|
|
// Leggo ID
|
|
if (!isset($_GET['id'])) {
|
|
// Codice HTTP 404: Not found
|
|
http_response_code(404);
|
|
echo "<code>Film non trovato!</code>";
|
|
return;
|
|
}
|
|
|
|
if (!is_numeric($_GET['id']) || $_GET['id'] === "" || $_GET['id'] === null) {
|
|
// Codice HTTP 404: Not found
|
|
http_response_code(404);
|
|
echo "<code>Film non trovato!</code>";
|
|
return;
|
|
}
|
|
|
|
$idFilm = intval($_GET['id']);
|
|
$query = "SELECT film.id_film, film.nome, film.trama, film.durata, film.data_uscita, generi.nome as genere FROM film, generi WHERE film.id_genere = generi.id_genere AND film.id_film = :id ORDER BY film.data_uscita";
|
|
|
|
// Leggo i dati del film e faccio il JOIN per avere il nome del genere
|
|
$stmt = $pdo->prepare($query);
|
|
$stmt->execute([
|
|
':id' => $idFilm
|
|
]);
|
|
|
|
$row = $stmt->fetch();
|
|
|
|
if (!$row) {
|
|
// Codice HTTP 404: Not found
|
|
http_response_code(404);
|
|
echo "<code>Film non trovato!</code>";
|
|
return;
|
|
}
|
|
|
|
// Ottengo gli attori
|
|
$queryAttori = "SELECT attori.nome, attori.cognome, attori.data_nascita, recitare.ruolo FROM attori, recitare WHERE attori.id_attore = recitare.id_attore AND recitare.id_film = :id ORDER BY recitare.ruolo DESC ";
|
|
|
|
$stmt = $pdo->prepare($queryAttori);
|
|
$stmt->execute([
|
|
':id' => $idFilm
|
|
]);
|
|
|
|
?>
|
|
|
|
<!DOCTYPE html>
|
|
<html lang="it">
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title><?php echo $row["nome"]; ?> - Film - The NoSpace Cinema</title>
|
|
<!--- www.francescomancuso.it -->
|
|
<link rel="stylesheet" href="../style.css">
|
|
<link rel="icon" href="../favicon.png">
|
|
</head>
|
|
|
|
<body>
|
|
<header>
|
|
<div class="container">
|
|
<a href="../" style="text-decoration: none;">
|
|
<div>
|
|
<img src="../logo.png">
|
|
<h4>The NoSpace Cinema</h4>
|
|
</div>
|
|
</a>
|
|
<div>
|
|
<a href=".?s" style="font-size:16px">Vedi sorgente pagina</a>
|
|
<a href="../search/" class="button">Tutti i film</a>
|
|
</div>
|
|
</div>
|
|
</header>
|
|
<div class="container">
|
|
<div class="hero film" style="background-image: url('<?php echo "../api/v1/img/?n=" . urlencode($row['nome'] . ' ' . date('Y', strtotime($row['data_uscita']))); ?>')">
|
|
<div>
|
|
<h1><?php echo $row["nome"]; ?></h1>
|
|
<div class="genere">
|
|
<?php echo $row["genere"]; ?>
|
|
</div>
|
|
<div class="meta">
|
|
<span><?php echo date("d M Y", strtotime($row["data_uscita"])); ?></span>
|
|
<span>|</span>
|
|
<span><?php echo $row["durata"]; ?></span>
|
|
</div>
|
|
</div>
|
|
<img src="<?php echo "../api/v1/img/?n=" . urlencode($row['nome'] . ' ' . date('Y', strtotime($row['data_uscita']))); ?>">
|
|
</div>
|
|
</div>
|
|
<div class="page film">
|
|
<div class="container">
|
|
<h2>Trama</h2>
|
|
<div class="trama">
|
|
<?php echo $row['trama']; ?>
|
|
</div>
|
|
|
|
<h2>Attori</h2>
|
|
<div class="grid films">
|
|
<?php
|
|
$test = true;
|
|
while ($rowAttori = $stmt->fetch()) {
|
|
$test = false;
|
|
?>
|
|
<div class="attore">
|
|
<img src="../attore-list.png">
|
|
<h5><?php echo $rowAttori['nome']; ?> <?php echo $rowAttori['cognome']; ?></h5>
|
|
<span>Nato/a il <?php echo date("d M Y", strtotime($rowAttori['data_nascita'])); ?></span>
|
|
<div class="ruolo">
|
|
<?php echo $rowAttori['ruolo']; ?>
|
|
</div>
|
|
</div>
|
|
<?php
|
|
}
|
|
?>
|
|
</div>
|
|
<?php
|
|
// Nessun risultato...
|
|
if ($test) {
|
|
echo "<div class=\"container\">Nessun attore trovato!</div>";
|
|
}
|
|
?>
|
|
</div>
|
|
</div>
|
|
<footer>
|
|
<div class="container">
|
|
<span>Realizzato da Francesco Giuseppe Mancuso - classe 5E - www.francescomancuso.it</span>
|
|
</div>
|
|
</footer>
|
|
</body>
|
|
|
|
</html>
|