-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathammDashboard.php
More file actions
270 lines (252 loc) · 13.1 KB
/
Copy pathammDashboard.php
File metadata and controls
270 lines (252 loc) · 13.1 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
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
<?php
error_reporting(E_ERROR | E_WARNING | E_PARSE);
session_start();
if (!$_SESSION['utente']){
header("location: LoginRegister.php");
}
$connessione=@mysqli_connect("localhost","root","","covid19");
if (mysqli_connect_errno()){
echo "Errore nella Connessione al Database.".die (mysqli_connect_error());
}
//Ultimo accesso registrato {data ip ora}
$lasthourdateip="select ora, data, ip from accessi where token=\"".$_SESSION['utente']."\"";
$lasth=mysqli_query($connessione,$lasthourdateip);
$fetchlast=mysqli_fetch_array($lasth);
//Per aggiungere utenti
function calctoken() {
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$randomstring="";
for ($i = 0; $i < 20; $i++) {
$index = rand(0, strlen($characters) - 1);
$randomString .= $characters[$index];
}
return $randomString;
}
?>
<html>
<head>
<?php include "include/header.php";?>
</head>
<body>
<div class="container-fluid">
<nav class="navbar navbar-light bg-light justify-content-center border rounded-lg">
<a class="navbar-brand align-left" href="Homepage.php">Home</a>
<a class="navbar-brand">Benvenuto => <?php echo $_SESSION['utente'];?> <= Amministratore</a> </nav> </div>
<div class="container-fluid">
<div class="alert alert-danger text-center" role="alert">
Ultimo accesso Il <?php echo $fetchlast[1];?> Ore <?php echo $fetchlast[0];?> IP:
<?php echo $fetchlast[2]; ?>
</div>
</div>
<!--Navbar fatta di container con "Accettazione" e "Log" solo scritte-->
<div class="container-fluid">
<div class="container-fluid col-4 float-right border rounded-lg">
<h1 style="font-family: 'Open Sans', sans-serif;" class="text-center py-2">Log</h1>
</div>
<div class="container-fluid col-8 float-left border rounded-lg">
<h1 style="font-family: 'Open Sans', sans-serif;" class="text-center py-2">Accettazione</h1>
</div>
</div>
<!--Dati e tabella Accettazione-->
<div class="container-fluid">
<div class="col-8 float-left border rounded-lg" style="overflow-y:scroll; height:50%;">
<table class="table table-striped table-hover ">
<thead>
<tr>
<th scope="col">Token</th>
<th scope="col">Regione</th>
<th scope="col">Struttura</th>
<th scope="col">Citta</th>
<th scope="col">Nome</th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
<?php
$connessione=@mysqli_connect("localhost","root","","covid19");
if (mysqli_connect_errno()){
echo "Errore nella Connessione al Database.".die (mysqli_connect_error());
}
$query="select account.token, regione,struttura,citta,nome from istituzioni,account where istituzioni.token=account.token and account.attivo=0";
$result=mysqli_query($connessione,$query);
while ($res=mysqli_fetch_array($result)){
$token=$res[0];
$regione=$res[1];
$struttura=$res[2];
$citta=$res[3];
$nome=$res[4];
echo
"
<tr>
<th>".$token."</th>
<td>".$regione."</td>
<td>".$struttura."</td>
<td>".$citta."</td>
<td>".$nome."</td>
<td>
<form action=\"backend/ammDashboardlogic.php\" method=\"POST\">
<input type=\"hidden\" name=\"accept\">
<input type=\"submit\" class=\"btn btn-outline-success\" value=\"Accetta\" name=\"accetta\"><input type=\"hidden\" name=\"token\" value=\"".$token."\">
</form>
<form action=\"backend/ammDashboardlogic.php\" method=\"POST\"><input type=\"submit\" class=\"btn btn-outline-danger\" value=\"Rifiuta\" name=\"rifiuta\">
<input type=\"hidden\" name=\"deny\">
<input type=\"hidden\" name=\"token\" value=\"".$token."\">
</form>
</td>
</tr>
";
}
?>
</tbody>
</table>
</div>
</div>
<!--Log-->
<div class="container-fluid">
<div class="col-4 float-right border rounded-lg" style="overflow-y:scroll; height:50%;">
<!--Inserisci Log-->
<?php
$var=file("C:\\xampp\\apache\\logs\\access.log");
$rev=array_reverse($var);
for ($i=0;$i<1000;$i++){
echo $rev[$i]."<br><br>";
}
?>
</div>
<div class="container-fluid">
<div class="col-4 float-right border rounded-lg" style="overflow-y:scroll; height:50%;">
<div class="container-fluid col-4">
<h1 style="font-family: 'Open Sans', sans-serif;" class="text-center py-2">Accessi</h1>
</div>
<table class="table table-striped table-hover">
<thead>
<tr>
<th scope="col">Identificativo</th>
<th scope="col">Data</th>
<th scope="col">Ora</th>
<th scope="col">Ip</th>
</tr>
</thead>
<tbody>
<?php
$connessione=@mysqli_connect("localhost","root","","covid19");
if (mysqli_connect_errno()){
echo "Errore nella Connessione al Database.".die (mysqli_connect_error());
}
$query="select token,data,ora,ip from accessi";
$result=mysqli_query($connessione,$query);
$resAccessi=mysqli_fetch_array($result);
while ($resAccessi=mysqli_fetch_array($result)){
$token=$resAccessi[0];
$data=$resAccessi[1];
$ora=$resAccessi[2];
$ip=$resAccessi[3];
echo
"
<tr>
<th scope=\"row\">".$token."</th>
<td>".$data."</td>
<td>".$ora."</td>
<td>".$ip."</td>
</tr>
";
}
?>
</tbody>
</table>
</div>
</div>
<div class="container-fluid justify-content-center">
<div class="row"></div>
<div class="col-8 border float-left rounded-lg">
<div class="col-4 float-left">
<div class="container-fluid">
<h1 style="font-family: 'Open Sans', sans-serif;" class="text-center py-2">Aggiungi Utenti</h1>
</div>
<form action="backend/ammDashboardlogic.php" method="POST">
<div class="form-group row px-3">
<label for="prepend">Token</label>
<div class="col">
<div class="input-group-prepend">
<span class="input-group-text"
id="prepend"><?php $add=strtolower(calctoken()); echo $add;?></span>
</div>
</div>
<input type="hidden" class="form-control" value=<?php echo "\"".$add."\"";?> name="add">
</div>
<div class="form-group row px-3">
<label for="nome">Nome</label>
<div class="col">
<input type="text" class="form-control" id="nome" placeholder="Inserisci il Nome"
name="nome">
</div>
</div>
<div class="form-group row px-3">
<label for="regione">Regione</label>
<div class="col">
<input type="text" class="form-control" id="regione" placeholder="Inserisci Regione"
name="regione">
</div>
</div>
<div class="form-group row px-3">
<label for="citta">Citta</label>
<div class="col">
<input type="text" class="form-control" id="citta" placeholder="Inserisci Citta"
name="citta">
</div>
</div>
<div class="form-group row px-3">
<label for="struttura">Struttura</label>
<div class="col">
<select class="form-control"
name="struttura" id="struttura">
<option value="ospedale">Ospedale</option>
<option value="comune">Comune</option>
<option value="protezionecivile">Protezione Civile</option>
<option value="entegenerico">Ente Generico</option>
</select>
</div>
</div>
<div class="form-group row px-3">
<label for="ruolo">Ruolo</label>
<div class="col">
<select class="form-control"
name="ruolo" id="ruolo">
<option value="admin">Amministratore</option>
<option value="user">Utente</option>
</select>
</div>
</div>
<div class="form-group row px-3">
<label for="pswd">Password</label>
<div class="col">
<input type="password" class="form-control" id="pswd" placeholder="Inserisci Password"
name="password">
</div>
</div>
<div class="form-group">
<input type="submit" class="btn btn-outline-success btn-block" value="Crea" name="crea">
</div>
</form>
</div>
<div class="col-4 float-right">
<div class="container-fluid">
<h1 style="font-family: 'Open Sans', sans-serif;" class="text-center py-2">Elimina Utenti</h1>
</div>
<form action="backend/ammDashboardlogic.php" method="POST">
<div class="form-group row px-3">
<label for="tokendel">Token</label>
<div class="col">
<input type="text" class="form-control" id="tokendel" name="del"
placeholder="Token Account">
</div>
</div>
<input type="submit" class="btn btn-outline-danger btn-block" value="Elimina">
</form>
</div>
</div>
</div>
</div>
<?php include "include/footer.php";?>
</body>
</html>