-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharticle.php
More file actions
116 lines (111 loc) · 5.15 KB
/
article.php
File metadata and controls
116 lines (111 loc) · 5.15 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<?php
$estaPagina = 'Noticia';
include_once 'inc/navbar.php';
include_once 'utils/functions.php';
?>
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Noticia | NASCAR</title>
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/styles.php">
<link rel="icon" href="img/favicon.ico">
<style>
body {
visibility: hidden;
}
</style>
</head>
<body class="sitio">
<?php
if (isset($_GET['id_noticia'])) {
$id_noticia = $_GET['id_noticia'];
$noticia = get_noticia($id_noticia);
} else {
header('location:index.php');
exit();
}
?>
<main class="holder noticia">
<?php if (!is_null($noticia['id_noticia'])) { ?>
<div class="cuerpoNoticia">
<h1><?php display($noticia['title']); ?></h1>
<p><?php display($noticia['description']); ?></p>
</div>
<?php if (!is_null($noticia['image_article'])) { ?>
<img class="imgPrincipal" src="<?php echo $noticia['image_article']; ?>">
<?php } elseif (!is_null($noticia['image_main'])) { ?>
<img class="imgPrincipal" src="<?php echo $noticia['image_main']; ?>">
<?php } ?>
<div class="cuerpoNoticia">
<p><?php display($noticia['body']); ?></p>
</div>
<?php if (!is_null($noticia['video_embed_url'])) { ?>
<div class="videoNoticia">
<iframe width="560" height="315" src="<?php echo $noticia['video_embed_url']; ?>" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div>
<?php } ?>
<div class="comentarios">
<div class="titulo"><h1 class="titulo" style="margin-top: 4px;">Comentarios</h1></div>
<?php
$comentarios = mysqli_query(
$conexion,
"SELECT id_usuario, comentario, fecha FROM comentarios WHERE id_noticia = $id_noticia ORDER BY fecha ASC LIMIT 10"
);
if ($comentarios && mysqli_num_rows($comentarios) > 0) { ?>
<div class="comentarios-list">
<?php while ($comentario = mysqli_fetch_array($comentarios)) { ?>
<div class="comentario">
<div class="comentario-header">
<img src="<?php echo get_profile_pic($comentario['id_usuario']); ?>">
<span class="comentario-usuario"><?php display(nombre_usuario($comentario['id_usuario'])); ?></span>
<span class="comentario-fecha"><?php echo $comentario['fecha']; ?></span>
</div>
<div class="comentario-body">
<p><?php display($comentario['comentario']); ?></p>
</div>
</div>
<?php } ?>
</div>
<?php } else { ?>
<p>Aún no hay comentarios, ¡sé el primero!</p>
<?php } ?>
<?php if (isset($_SESSION['id_usuario'])) { ?>
<form action="utils/comment-create.php" method="POST">
<input type="hidden" name="id_noticia" value="<?php echo $noticia['id_noticia']; ?>">
<input type="hidden" name="id_usuario" value="<?php echo $_SESSION['id_usuario']; ?>">
<div class="comentario-form">
<div class="comentario-form-header">
<img src="<?php echo get_profile_pic($_SESSION['id_usuario']); ?>">
<span><?php display(nombre_usuario($_SESSION['id_usuario'])); ?></span>
</div>
<div class="comentario-form-body">
<textarea name="comentario" placeholder="¿Cuál es tu opinión? ¡Únete a la conversación dejando un comentario!" rows="5" cols="77"></textarea>
</div>
<div class="comentario-form-footer">
<input type="submit" value="Enviar">
</div>
</div>
</form>
<?php } else { ?>
<p>¿Cuál es tu opinión? <a href="log-in.php">Inicia Sesión</a> o <a href="register.php">Regístrate</a> para comentar.</p>
<?php } ?>
</div>
<?php } else { ?>
<div class="cuerpoNoticia">
<h1>Noticia no encontrada</h1>
<p>La noticia solicitada no está disponible.</p>
</div>
<?php } ?>
</main>
<?php include_once 'inc/footer.php'; ?>
<script>
// Delay the display of the body content to prevent Flash of Unstyled Content (FOUC)
setTimeout(function() {
document.body.style.visibility = "visible";
}, 10);
</script>
</body>
</html>