-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.php
42 lines (33 loc) · 1.25 KB
/
action.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
<?PHP
include 'seekrits.php';
$database = "keezer";
$server = "localhost";
$db_handle = mysql_connect($server, $user_name, $password);
$db_found = mysql_select_db($database, $db_handle);
if ($db_found) {
if( isset($_POST['calibrate'])) {
$cal = ",Calibrate=1,LastPulses=0";
$url = "http://" . $hostname . "/calibrate.php?kegID=" . $_POST['kegID'];
}
else {
$cal="";
$url="http://" . $hostname . "/default.php?tab=2";
}
$kegID = $_POST['kegID'];
$SQL = "UPDATE Keg SET " .
"KegName='" . str_replace("'","''",$_POST['kegName']) .
"', Capacity=" . $_POST['capacityLiters'] .
",CurrentLevel=" . $_POST['currentLevel'] .
",KegSoundNormal='" . str_replace("'","''",$_POST['soundNormal']) . "'" .
",KegSoundLow='" . str_replace("'","''",$_POST['soundLow']) . "'" .
",KegSoundOut='" . str_replace("'","''",$_POST['soundOut']) . "'" . $cal . " WHERE KegID=" . $kegID;
$result = mysql_query($SQL);
$SQL = "SELECT PID FROM Keg WHERE KegID=" . $kegID;
$result = mysql_query($SQL);
$res = mysql_fetch_assoc($result);
$pid = $res['PID'];
#Send signal to daemon to refresh from DB
$handle = fopen("/var/www/keezerd/pid/" . $pid,'w') or die ('Cannot open file: ' . $pid);
header( "Location: $url" );
}
?>