-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
81 lines (72 loc) · 1.68 KB
/
index.php
File metadata and controls
81 lines (72 loc) · 1.68 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
76
77
78
79
80
81
<!DOCTYPE HTML>
<html>
<head>
<style>
.error {color: #FF0000;}
</style>
</head>
<body>
<?php
$myfile = fopen("instantDataFile.thr", "r") or die("Unable to open file!");
$line = fread($myfile,filesize("instantDataFile.thr"));
$words = explode(" ", $line);
fclose($myfile);
?>
<article>
<header>
<h1>Heater Control</h1>
<h3><?php echo "Machine update time: ".$words[0]." : ".$words[2];?></h1>
</header>
</article>
<table border="1" bgcolor="#E8E8E8">
<tr>
<th>Place</th>
<th>temp [c]</th>
</tr>
<tr>
<td>Room</td>
<td><?php echo $words[4];?></td>
</tr>
<tr>
<td>Heater water</td>
<td><?php echo $words[6];?></td>
</tr>
<tr>
<td>Calculated desired temp</td>
<td><?php echo $words[8];?></td>
</tr>
<tr>
<td>Heater is active </td>
<td><?php echo $words[10];?></td>
</tr>
</table>
<?php
$tempErr = "";
$sendTemp = "";
if( $_REQUEST["sendTemp"] )
{
if (empty( $_REQUEST["sendTemp"])) {
$tempErr = "SendTemp is required";
} else {
$sendTemp = $_REQUEST['sendTemp'];
if (!preg_match("/^[0-9]*$/",$sendTemp)) {
$tempErr = "Only Digits allowed";
} else{
$myfile = fopen("/var/www/roomTempFile.thr", "w") or $tempErr = "Unable to open file";
fwrite($myfile, "roomTemp ".$sendTemp."\n");
fclose($myfile);
$page = $_SERVER['PHP_SELF'];
$sec = "2";
header("Refresh: $sec; url=$page");
}
}
}
?>
<p>Menualy set the room temp:</p>
<form action="<?php $_PHP_SELF ?>" method="POST">
Temp: <input type="text" name="sendTemp" />
<span class="error">* <?php echo $tempErr?></span>
<input type="submit" />
</form>
</body>
</html>