-
Notifications
You must be signed in to change notification settings - Fork 0
/
dashguest.php
361 lines (322 loc) · 10.5 KB
/
dashguest.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
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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
<?php
//verificacao se existe um usuario logado
session_start();
include("connection.php");
include("functions.php");
$user_data = check_login($con);
//acesso apenas ao privilégio guest
if($user_data['privileges'] != "guest"){
die("acess denied");
}
?>
<?php
//get valores
$value_temp = file_get_contents("api/files/temperature/value.txt");
$date_temp = file_get_contents("api/files/temperature/date.txt");
$value_lumi = file_get_contents("api/files/luminosity/value.txt");
$date_lumi = file_get_contents("api/files/luminosity/date.txt");
$value_humi = file_get_contents("api/files/humidity/value.txt");
$date_humi = file_get_contents("api/files/humidity/date.txt");
$value_door = file_get_contents("api/files/door/value.txt");
$date_door = file_get_contents("api/files/door/date.txt");
$value_lamp = file_get_contents("api/files/lamp/value.txt");
$date_lamp = file_get_contents("api/files/lamp/date.txt");
$value_motion = file_get_contents("api/files/motion/value.txt");
$date_motion = file_get_contents("api/files/motion/date.txt");
$value_fire = file_get_contents("api/files/fire/value.txt");
$date_fire = file_get_contents("api/files/fire/date.txt");
//qualificacao da badges da tabela de sensores e verificacao para alertas//
//temperature
if($value_temp > 35){
echo '<script>alert("Very hot outside, be careful!")</script>';
$temp_warn = "very hot";
//toca alrme para avisar o utilizador
exec('C:\\UniServerZ\\www\\SmartHouse\\python\\sound.py');
}
else if($value_temp > 27 && $value_temp < 35){
$temp_warn = "hot";
}
else if($value_temp > 20 && $value_temp < 27){
$temp_warn = "good";
}
else if($value_temp > 10 && $value_temp < 20){
$temp_warn = "cold";
}
else{
echo '<script>alert("Very cold outside, be careful!")</script>';
$temp_warn = "very cold";
//toca alrme para avisar o utilizador
exec('C:\\UniServerZ\\www\\SmartHouse\\python\\sound.py');
}
//humidity
if($value_humi < 20){
$humi_warn = "dry";
}
else if($value_humi > 20 && $value_humi < 40){
$humi_warn = "semi dry";
}
else if($value_humi > 40 && $value_humi < 60){
$humi_warn = "semi humid";
}
else if($value_humi > 60 && $value_humi < 80){
$humi_warn = "humid";
}
else{
$humi_warn = "very humid";
}
//luminosity
if($value_lumi == 1){
$lumi_warn = "Day time";
$value_lumi = "Light";
}
else if($value_lumi == 0){
$lumi_warn = "Night Time";
$value_lumi = "No light";
}
//motion
if($value_motion == 1){
$motion_warn = "Someone here";
$value_motion = "Motion";
}else if($value_motion == 0){
$motion_warn = "No one here";
$value_motion = "No motion";
}
//fire
if($value_fire == 0){
$fire_warn = "No fire";
$value_fire = "No";
}else if($value_fire == 1){
$fire_warn = "Fire";
echo '<script>alert("Theres a fire, call the fire department!! Fire Sprinkler activated. ")</script>';
//toca alrme para avisar o utilizador
exec('C:\\UniServerZ\\www\\SmartHouse\\python\\sound.py');
$value_fire = "Yes";
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="refresh" content="58">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css" integrity="sha384-B0vP5xmATw1+K9KRQjQERJvTumQW0nPEzvF6L/Z6nronJ3oUOFUFpCjEUQouq2+l" crossorigin="anonymous">
<link href="style.css" rel="stylesheet">
<link href='https://unpkg.com/boxicons@2.0.7/css/boxicons.min.css' rel='stylesheet'>
<link rel="stylesheet" href="calendar.css">
<title>Smart House</title>
</head>
<body>
<!-- sidebar -->
<div class="sidebar">
<div class="logo_content">
<div class="logo">
<i class='bx bx-home-heart' ></i>
<div class="logo_name">Smart House</div>
</div>
<i class='bx bx-menu' id="btn" ></i>
</div>
<ul class="nav_list">
<li>
<a href="dashguest.php">
<i class='bx bx-grid-alt' ></i>
<span class="links_name">Dashboard</span>
</a>
<span class="tooltip">Dashboard</span>
</li>
<li>
<a href="analyticsguest.php">
<i class='bx bx-pie-chart-alt-2' ></i>
<span class="links_name">Analytics</span>
</a>
<span class="tooltip">Analytics</span>
</li>
</ul>
<div class="logout">
<div>
<a href="logout.php">
<i class='bx bx-log-out' id="log_out" ></i>
</a>
<span class="tooltip">Logout</span>
</div>
</div>
</div>
<!-- fim da sidebar -->
<!-- ########## conteudo da pagina ######## -->
<div class="home_content">
<!-- header da pagina -->
<div class="row">
<div class="col-sm-12">
<video autoplay loop>
<source src="imgs/header.mp4" type="video/mp4">
</video>
</div>
</div>
<!-- fim do header da pagina -->
<br><br>
<div class="container">
<!-- divs dos 4 icons iniciais -->
<div class="row">
<div class="col-sm-4">
<div class="card text-center cardcolor">
<div class="card-body"><img src="imgs/sunicon.png" alt="sun image" class="icons">
<br><b>Luminosity:
<?php echo $value_lumi ?></b>
</div>
</div>
<br><br>
<div class="card text-center cardcolor">
<div class="card-body"><img src="imgs/tempicon.png" alt="temperature image" class="icons">
<br><b>Temperature: <?php echo $value_temp; ?>º</b>
</div>
</div>
</div>
<div class="col-sm-4">
<div class="card text-center cardcolor">
<div class="card-body">
<?php //fazer a mudanca de imagem
if($value_door == 1){
echo '<img src="imgs/dooricon.png" alt="door image" class="icons">';
}else if($value_door == 0){
echo '<img src="imgs/closeddooricon.png" alt="door image" class="icons">';
}
?>
<br><b>Door:
<?php //mudanca de texto
if($value_door == 0){
echo "Closed";
}elseif($value_door == 1){
echo "Open";
}else{
echo "Error";
}
?></b>
</div>
</div>
<br><br>
<div class="card text-center cardcolor">
<div class="card-body">
<?php
if($value_lamp == 2){
echo '<img src="imgs/lamponicon.png" alt="lamp image" class="icons">';
}else if($value_lamp == 0){
echo '<img src="imgs/lampicon.png" alt="lamp image" class="icons">';
}
?>
<br><b>Lamp:
<?php
if($value_lamp == 0){
echo "Off";
}elseif($value_lamp == 2){
echo "On";
}else{
echo "Error";
}
?></b></b>
</div>
</div>
</div>
<!-- calendario -->
<div class="col-sm-4">
<div class="card text-center cardcolor">
<div class="calendar">
<div class="calendar-header">
<span class="month-picker" id="month-picker">February</span>
<div class="year-picker">
<span id="year">2021</span>
</div>
</div>
<div class="calendar-body">
<div class="calendar-week-day">
<div>Sun</div>
<div>Mon</div>
<div>Tue</div>
<div>Wed</div>
<div>Thu</div>
<div>Fri</div>
<div>Sat</div>
</div>
<div class="calendar-days"></div>
</div>
<div class="month-list"></div>
<br><br><br>
</div>
</div>
</div>
<!-- fim de calendario -->
</div>
<br><br>
<!-- tabela de sensores -->
<!-- faltam 2 sensores -->
<div class="row">
<div class="col-sm-12">
<div class="card cardcolor">
<div class="card-header textcolor"><b>Sensor Table</b></div>
<div class="card-body">
<table class="table table-bordered">
<thead>
<tr class="textcolor">
<th scope="col">IoT Device Type</th>
<th scope="col">Value</th>
<th scope="col">Update date</th>
<th scope="col">Warnings</th>
</tr>
</thead>
<tbody>
<tr class="textcolor">
<td>Temperature Sensor</td>
<td><?php echo $value_temp; ?>º</td>
<td><?php echo $date_temp; ?></td>
<td><span class="badge badge-pill badge-info"><?php echo $temp_warn ?></span></td>
</tr>
<tr class="textcolor">
<td>Humidity Sensor</td>
<td><?php echo $value_humi; ?>%</td>
<td><?php echo $date_humi; ?></td>
<td><span class="badge badge-pill badge-primary"><?php echo $humi_warn ?></span></td>
</tr>
<tr class="textcolor">
<td>Luminosity Sensor</td>
<td><?php echo $value_lumi; ?></td>
<td><?php echo $date_lumi; ?></td>
<td><span class="badge badge-pill badge-info"><?php echo $lumi_warn ?></span></td>
</tr>
<tr class="textcolor">
<td>Motion Sensor</td>
<td><?php echo $value_motion?></td>
<td><?php echo $date_motion; ?></td>
<td><span class="badge badge-pill badge-primary"><?php echo $motion_warn ?></span></td>
</tr>
<tr class="textcolor">
<td>Fire Sensor</td>
<td><?php echo $value_fire; ?></td>
<td><?php echo $date_fire; ?></td>
<td><span class="badge badge-pill badge-info"><?php echo $fire_warn ?></span></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- ####### SCRIPTS ###### -->
<script>
//script para deixar a sidebar interativa
let btn = document.querySelector("#btn");
let sidebar = document.querySelector(".sidebar");
btn.onclick = function() {
sidebar.classList.toggle("active");
if(btn.classList.contains("bx-menu")){
btn.classList.replace("bx-menu" , "bx-menu-alt-right");
}else{
btn.classList.replace("bx-menu-alt-right", "bx-menu");
}
}
</script>
<script src="calendar.js"></script>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-Piv4xVNRyMGpqkS2by6br4gNJ7DXjqk09RmUpJ8jgGtD7zP9yug3goQfGII0yAns" crossorigin="anonymous"></script>
</body>
</html>