-
Notifications
You must be signed in to change notification settings - Fork 1
/
additionalSensors.php
executable file
·135 lines (112 loc) · 3.93 KB
/
additionalSensors.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
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
<title>Weather</title>
<link rel="stylesheet" href="woffice.css">
</head>
<body bgcolor="#d6e5ca" marginheight="25" marginwidth="20" topmargin="25" leftmargin="0">
<?PHP
////////////////////////////////////////////////////
//
// WeatherOffice
//
// http://www.sourceforge.net/projects/weatheroffice
//
// Copyright (C) 04/2007 Mathias Zuckermann &
// Bernhard Heibler
//
// See COPYING for license info
//
////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// addSensor
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// MAIN
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//
// Data in weather (as stored by mysql2300)
//
// timestamp: uniqe bigint(14) in format YYYYMMDDhhmmss
//
//////////////////////////////////////////////////////////////////////
include("weatherInclude.php");
function GetNextSensorID()
{
global $database;
$sensorID = $database->getSensorLastId() + 1;
return $sensorID;
}
if($database->haveSensors())
{
$addSensor = $_REQUEST["addSensor"];
if($addSensor == "false")
{
// Sensorentabelle
echo "<hr><table border=\"1\"><tr>";
echo "<th>" . $text['sensors']['id'] . "</th>";
echo "<th>" . $text['sensors']['name'] . "</th>";
echo "<th>" . $text['sensors']['filename'] . "</th>";
echo "<th>" . $text['sensors']['linenumber'] . "</th>";
echo "<th>" . $text['sensors']['value'] . "</th>";
echo "<th>" . $text['sensors']['unit'] . "</th>";
echo "<th>" . $text['sensors']['active'] . "</th></tr>";
$database->listSensors();
while($datarow = $database->getNextRow())
{
$id=$datarow['id'];
$name=$datarow['name'];
$filename=$datarow['filename'];
$linenumber=$datarow['linenumber'];
$unit=$datarow['unit'];
$active=$datarow['Active'];
$value=GetCurrentSensorValue($filename, $linenumber);
echo "<tr>";
echo "<td>$id</td>";
echo "<td>$name</td>";
echo "<td>$filename</td>";
echo "<td>$linenumber</td>";
echo "<td>$value</td>";
echo "<td>$unit</td>";
echo "<td>$active</td>";
echo "</tr>";
}
$database->free();
echo "</table>";
// New Sensor
echo "<p><hr><b>" . $text['sensors']['new'] . ":</b></p>";
echo "<form action = \"additionalSensors.php\" method=\"post\" target=\"main\">";
echo " " . $text['sensors']['name'] . ": ";
printf( "<input type = \"text\" size=\"15\" maxlenght=\"30\" name=\"name\" value=\"\">");
echo " " . $text['sensors']['filename'] . ": ";
printf( "<input type = \"text\" size=\"20\" maxlenght=\"255\" name=\"filename\" value=\"\">");
echo " " . $text['sensors']['linenumber'] . ": ";
printf( "<input type = \"text\" size=\"3\" name=\"linenumber\" value=\"\">");
echo " " . $text['sensors']['unit'] . ": ";
printf( "<input type = \"text\" size=\"7\" maxlenght=\"20\" name=\"unit\" value=\"\">");
echo " <input type = \"submit\" value = \"" . $text['sensors']['add'] . "\">";
echo "<input type = \"hidden\" name=\"addSensor\" value=\"true\">";
echo "</form>";
}
else
{
$name = $_REQUEST["name"];
$filename = $_REQUEST["filename"];
$linenumber = $_REQUEST["linenumber"];
$unit = $_REQUEST["unit"];
$newSensorId = GetNextSensorID();
$database->addSensors($newSensorId, $name, $filename, $linenumber, $unit);
printf($text['sensors']['added'] . "<br>", $name);
}
}
else
{
printf($text['sensors']['no_table'] . "<br>", $table);
}
$database->close();
?>