-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhomesecurity.php
55 lines (54 loc) · 1.37 KB
/
homesecurity.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
<?php
require_once 'security/DB_Functions.php';
$db = new DB_Functions();
if(isset($_GET["on"]))
{
$myfile = fopen("newfile.txt", "w") or die("Unable to open file!");
fwrite($myfile, $_GET["on"]);
}
else if(isset($_GET["type"])&&isset($_GET["discription"])&&isset($_GET["date"])&&isset($_GET["time"])&& isset($_GET["resolved"]))
{
$db->insertAlert($_GET["type"],$_GET["discription"],$_GET["date"],$_GET["time"],$_GET["resolved"]);
}
else if(isset($_GET["date"])&& isset($_GET["resolved"]))
{
$result=$db->updateAlert($_GET["date"],$_GET["resolved"]);
if($result)
{
$data->error="FALSE";
$data->message="the problem has been solved";
}
else
{
$data->error="TRUE";
$data->message="the problem still persist please hurry up";
}
echo json_encode($data);
}
else if(isset($_GET["device"]))
{
if($_GET["device"]=="android")
{
$result = $db->data("select * from security where Resolved='no'");
if($result->num_rows>0)
{
while($row = $result->fetch_assoc())
{
$data["alerts"][]=$row;
}
}
else
{
$data->error="TRUE";
$data->message="the data is not present";
}
echo json_encode($data);
}
}
else
{
$myfile = fopen("newfile.txt", "r") or die("Unable to open file!");
$data["on"]=fread($myfile,filesize("newfile.txt"));
echo json_encode($data);
}
?>