-
Notifications
You must be signed in to change notification settings - Fork 0
/
generosInicio.php
153 lines (112 loc) · 4.72 KB
/
generosInicio.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
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<?php
include_once "conexao.php";
include_once "Usuario.php";
include_once "dadosSistema.php";
include_once "verificaTempoSessao.php";
if(!isset($_SESSION)) session_start();
$conexao = conexao::getConexao();
if(!isset($_SESSION["usuario"])){
header("location: index.php");
}
try{
$codigo = null;
if(isset($_GET["cod_genero"])){
$codigo = trim(addslashes($_GET["cod_genero"]));
}else{
header("location: Inicio.php");
}
$comando = $conexao->prepare("SELECT nome_genero FROM genero AS g LEFT JOIN genero_livro AS gl ON g.id_genero = gl.id_genero_tombo WHERE g.id_genero = :cod LIMIT 1");
$comando->bindParam(":cod", $codigo);
$comando->execute();
$dados = $comando->fetchAll();
$html = null;
if(count($dados) > 0){
$tituloGenero = $dados[0][0];
//Verificando se o código passado está associado há algum livro no sistema
$comando = $conexao->prepare("SELECT l.cod_livro, l.titulo, l.idioma, l.img_livro, (SELECT AVG(avaliacao_estrelas) FROM avaliacao WHERE livro_tombo_avaliacao = l.cod_livro) FROM livro AS l INNER JOIN genero_livro AS g ON g.id_livro_tombo = l.cod_livro WHERE g.id_genero_tombo = :cod LIMIT 10");
$comando->bindParam(":cod", $codigo);
$comando->execute();
$dadosLivro = $comando->fetchAll();
if(count($dadosLivro) > 0){
foreach($dadosLivro as $value){
$codigoL = htmlspecialchars($value[0]);
$titulo = htmlspecialchars($value[1]);
$idioma = htmlspecialchars($value[2]);
$img = base64_encode($value[3]);
$avaliacao = (strlen(htmlspecialchars($value[4])) > 0) ? htmlspecialchars($value[4]) : 0;
$avaliacao = number_format($avaliacao, 1);
$tituloCompleto = htmlspecialchars($value[1]);
if(strlen($titulo) > 20){
$titulo = substr($titulo, 0, 40) . "...";
}
$html .= "<a href='telaLivro.php?cod_livro=$codigoL'>
<main>
<img src='data:image/jpg;base64,$img'>
<div>
<div>
<h4 title='$tituloCompleto'>$titulo</h4><br>
<p>$avaliacao <i class='fas fa-star'></i> | $idioma <i class='fas fa-language'></i></p>
</div>
</div>
</main>
</a>";
}
if(count($dadosLivro) >= 10){
$html .= "<div id='loadingCont'>
<div class='carregarMais' title='Carregar Mais Livros' onclick='carregaMaisLivrosGen($codigo, this)'><i class='fas fa-plus'></i></div>
</div>";
}
}else{
$html = "<h4 style='color: white'>Não há livros cadastrados a este genêro</h4>";
}
}else{
header("location: Inicio.php");
}
}catch(PDOException $ex){
header("location: Inicio.php");
}
?>
<!DOCTYPE html>
<html lang="pt-br">
<head>
<title><?php echo Info::$nomeSistema ?> - <?php echo $tituloGenero; ?></title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<script src="./scripts/jquery.min.js"></script>
<script src="./scripts/MaskaraJquery/jquery.mask.js"></script>
<script src="./scripts/generosInicio.js"></script>
<link rel="stylesheet" type="text/css" href="./css/fontawesome-free-5.12.1-web/css/all.min.css">
<link rel="stylesheet" type="text/css" href="./css/fontawesome-free-5.12.1-web/css/brands.min.css">
<link rel="stylesheet" type="text/css" href="./css/fontawesome-free-5.12.1-web/css/solid.min.css">
<link rel="stylesheet" type="text/css" href="./css/fontawesome-free-5.12.1-web/css/svg-with-js.min.css">
<link rel="stylesheet" type="text/css" href="./css/fontawesome-free-5.12.1-web/css/regular.min.css">
<link rel="stylesheet" type="text/css" href="./css/fontawesome-free-5.12.1-web/css/v4-shims.min.css">
<link rel="shortcut icon" type="image/jpg" <?php echo "href='".Info::$logoSistema."'" ?> sizes="50x50">
<link rel="stylesheet" type="text/css" href="./css/config.css">
<link rel="stylesheet" type="text/css" href="./css/generosInicio.css">
</head>
<body>
<nav id="menu">
<ul>
<li id="mn"><a href="javascript: history.go(-1)"><span><i class="fas fa-arrow-left"></i></span></a> <h5>Voltar</h5></li>
<li id="imgInicial">
<?php
echo "<a href='". Info::$siteEtec ."' target='_blank'><img title='". Info::$nomeEtec ."' src='". Info::$logoEtec ."'></a>
<a href='Inicio.php'><img title='". Info::$nomeSistema ."' src='". Info::$logoSistema ."'></a>
<a href='". Info::$siteCentro ."' target='_blank'><img title='". Info::$nomeCentro ."' src='". Info::$logoCentro ."'></a>";
?>
</li>
</ul>
</nav>
<section id="livrosGenero">
<?php
echo "<h2>$tituloGenero</h2>";
echo "<section class='livrosG'>";
echo $html;
echo "</section>";
?>
</section>
<!--Botão para ajuda-->
<a href="ajuda.php#Inicio"><div id="btnhelp" title="Ajuda" style="bottom: 40px"><i class="fas fa-question"></i></div></a>
</body>
</html>