-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontrol.php
More file actions
75 lines (64 loc) · 1.72 KB
/
control.php
File metadata and controls
75 lines (64 loc) · 1.72 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
<?php
$host='127.0.0.1';
$uname='root';
$pwd='';
$db="homeautomation";
$con = mysql_connect($host,$uname,$pwd) or die("connection failed");
mysql_select_db($db,$con) or die("db selection failed");
$port = fopen("COM15", "w");
echo $port;
//date_default_timezone_set('India/Kolkata');
//$cquery=mysql_query("select * from devices");
//$statesOfAppliances = mysql_fetch_array($cquery);
//print(json_encode($statesOfAppliances));
$light=$_REQUEST['light_hall'];
$tv=$_REQUEST['fan_hall'];
//$light="on";
//$flag = array();
//$flag['light']=0;
//$flag['tv']=0;
/*if($light=="on")
{
$query=mysql_query("UPDATE devices SET state = 'true' where appliances = 'light'");
//$flag['slight']=true;
}
if($light=="off")
{
$query=mysql_query("UPDATE devices SET state = 'false' where appliances = 'light'");
//$flag['slight']=false;
}
if($tv=="on")
{
//tv == fan
$query2=mysql_query("UPDATE devices SET state = 'true' where appliances = 'tv'");
//$flag['stv']=true;
}
if($tv=="off")
{
//tv == fan
$query2=mysql_query("UPDATE devices SET state = 'false' where appliances = 'tv'");
//$flag['stv']=false;
}*/
if ($light=="on")
{
//echo " 3rd LED Turned on";
mysql_query("Update `devices` set `state`='true' where `port`=8");
$ff=fwrite($port, "F");
echo $port." ".$ff;
}
if ($light=="off")
{
//echo "11th LED Turned off";
mysql_query("Update `devices` set `state`='false' where `port`=8");
$ff=fwrite($port, 'f');
echo " ".$port." ".$ff;
}
//$row=mysql_num_rows($query);
/*if($row && $user)
{
$flag['code']=1;
mysql_query("INSERT INTO logged_users (username,timestamp) VALUES ('$user','$timestamp') ");
}*/
//print(json_encode($flag));
mysql_close($con);
?>