-
Notifications
You must be signed in to change notification settings - Fork 0
/
security.php
142 lines (116 loc) · 6.78 KB
/
security.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
<?php
session_start();
if(empty($_SESSION['user'])) {
echo "<script language=javascript>alert( 'Acesso Bloqueado!' );</script>";
echo "<script language=javascript>window.location.replace('index.html');</script>";
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Rock in Rio</title>
<meta name="theme-color" content="#8257E5">
<link rel="stylesheet" href="styles/main.css">
<link rel="stylesheet" href="styles/security.css">
<link href="https://fonts.googleapis.com/css2?family=Archivo:wght@400;700&family=Poppins:wght@400;600&display=swap" rel="stylesheet">
<script>
function NotPermission(){
alert( 'Você não pode realizar essa operação em ocorrências de outros seguranças!');
}
</script>
</head>
<body id="painel">
<div id="container">
<header>
<img class="logo" src="images/logo.png" alt="Rock In Rio">
<div class="user">
<p>Segurança: <span> <?php echo $_SESSION['user']; ?> </span> </p>
<a href="php/exit.php" id="button"> Sair </a>
</div>
</header>
<div class="main">
<div class="busca">
<form action="#" method="GET">
<input type="text" name="cod" id="cod" placeholder="Código">
<input type="date" name="lineup" id="lineup" placeholder="LineUp" >
<input type="text" name="credencial" id="credencial" maxlength=11 placeholder="CPF Segurança">
<input type="submit" class="button" value="Filtrar">
<a href="php/ocorrencia/cadastroocorrencia.php" id="button"> Nova </a>
</form>
</div>
<div class="resultados">
<table border="1px">
<tr style='text-align: center; font-weight: bolder; font-family: Arial'>
<td>Código</td>
<td>LineUp</td>
<td>Descrição</td>
<td>Segurança</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<?php
include ('bd/database.php');
$conn = BD_connect();
$numero = isset($_GET['cod'])?$_GET['cod']:"";
$lineup = isset( $_GET['lineup'])? $_GET['lineup']:"";
$credencial = isset($_GET['credencial'])?$_GET['credencial']:"";
if($conn != null){
$stmt = "SELECT numero, data, descricao, cpfprofissionalseg FROM OCORRENCIA";
if($numero != "" || $lineup != "" || $credencial != ""){
$stmt = $stmt." WHERE";
$prox = false;
if($numero != ""){
$stmt = $stmt." numero = $numero";
$prox = true;
}
if($lineup != ""){
$stmt = $prox ? $stmt." and":$stmt."";
$stmt = $stmt." data = TO_DATE('".$lineup."', 'YYYY-MM-DD')";
$prox = true;
}
if($credencial != ""){
$stmt = $prox ? $stmt." and":$stmt."";
$stmt = $stmt." cpfprofissionalseg = $credencial";
}
}
$stmt = $stmt . " ORDER BY NUMERO";
//echo $stmt; // Descomente para exibir a consulta SQL.
$stid = oci_parse($conn, $stmt);
if( !oci_execute($stid) ) {
$e = oci_error();
echo htmlentities($e['message'], ENT_QUOTES);
oci_close($conn);
}
else{
while ($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) {
echo "<tr>\n";
foreach ($row as $item) {
echo " <td>" . ($item !== null ? htmlentities($item, ENT_QUOTES) : " ") . "</td>\n";
}
echo "<td><form method='POST' action='php/ocorrencia/view.php'><button type='submit' name='cod' value=".$row["NUMERO"]." >Visualizar</button></form></td>";
if($row["CPFPROFISSIONALSEG"] == $_SESSION["user"]){
echo "<td><form method='POST' action='php/ocorrencia/atualizarocorrencia.php'><button type='submit' name='cod' value=".$row["NUMERO"]." >Atualizar</button></form></td>";
echo "<td><form method='POST' action='php/ocorrencia/delete.php'><button type='submit' name='cod' value=".$row["NUMERO"]." >Excluir</button></form></td>";
}else{
echo "<td><button type='submit' name='cod' onclick='NotPermission()' >Atualizar</button></form></td>";
echo "<td><button type='submit' name='cod' onclick='NotPermission()' >Excluir</button></form></td>";
}
echo "</tr>\n";
}
oci_close($conn);
}
}
else{
echo "<p>Erro na conexão com banco de dados!</p>";
}
?>
</table>
</div>
</div>
<footer style="margin-top: 3rem; margin-bottom: 3rem; text-align: center;" > RockInRio © Todos os direitos reservados.</footer>
</div>
</body>
</html>