forked from sosprz/nettemp
-
Notifications
You must be signed in to change notification settings - Fork 1
/
receiver.php
executable file
·39 lines (32 loc) · 979 Bytes
/
receiver.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
<?php
if (isset($_GET['temp'])) {
// if (filter_var($_GET['temp'], FILTER_VALIDATE_URL)) {
$temp = $_GET['temp'];
//}
}
if (isset($_GET['mac'])) {
// if (filter_var($_GET['mac'], FILTER_VALIDATE_URL)) {
$mac = $_GET['mac'];
// }
}
$file = 'wireless_' . $mac . '_temp.sql';
$rom = 'wireless_' . $mac . '_temp';
if ( !empty($temp) && !empty($mac) ) {
if (file_exists("db/$file")) {
$db = new PDO("sqlite:db/$file");
$db->exec("INSERT OR IGNORE INTO def (value) VALUES ('$temp')") or die ("cannot insert to DB 1" );
$dbn = new PDO("sqlite:dbf/nettemp.db");
$dbn->exec("UPDATE sensors SET tmp='$temp' WHERE rom='$rom'") or die ("cannot insert to status" );
echo "ok";
}
else {
$dbnew = new PDO("sqlite:dbf/nettemp.db");
$dbnew->exec("INSERT OR IGNORE INTO newdev (list) VALUES ('$rom')");
$dbnew==NULL;
echo "New wireless sensor $rom added";
}
}
else {
echo "no values";
}
?>