-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.php
executable file
·264 lines (227 loc) · 7.81 KB
/
main.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
<?PHP
////////////////////////////////////////////////////
//
// WeatherOffice
//
// http://www.sourceforge.net/projects/weatheroffice
//
// Copyright (C) 04/2007 Mathias Zuckermann &
// Bernhard Heibler
//
// See COPYING for license info
//
////////////////////////////////////////////////////
include "weatherInclude.php";
function testComp($compWoffice)
{
echo "$compWoffice";
//Die Session initialisieren
$ch = curl_init($compWoffice . "/main.php");
$fp = fopen("/tmp/compWoffice.txt", "w");
//Session Optionen setzen
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
//Ausführen der Aktionen
curl_exec($ch);
//Session beenden
curl_close($ch);
fclose($fp);
$fp = fopen("/tmp/compWoffice.txt", "r");
fclose($fp);
}
echo "<html>";
echo "<head>";
echo "<meta http-equiv=\"content-type\" content=\"text/html;charset=iso-8859-1\">";
echo "<meta http-equiv=\"Refresh\" CONTENT=\"120\">";
echo "<title>Weather</title>";
echo "<link rel=\"stylesheet\" href=\"woffice.css\">";
echo "</head>";
echo "<body bgcolor=\"#d6e5ca\" marginheight=\"25\" marginwidth=\"20\" topmargin=\"25\" leftmargin=\"0\">";
$timestamp = $database->getWeatherLastDate();
if (!$timestamp) {
exit();
}
$values = $database->getWeatherFromDate($timestamp);
$day = substr($timestamp, 6, 2);
$month = substr($timestamp, 4, 2);
$year = substr($timestamp, 0, 4);
$hour = substr($timestamp, 8, 2);
$minute = substr($timestamp, 10, 2);
$second = substr($timestamp, 12, 4);
$windkmh = $values['windspeed']*3.6;
$bftTxt = beaufort($values['windspeed'], $lang);
$diff = tendency($timestamp);
$hrmin = hourMinute($hour, $minute, $text);
$comfTxt = comfortText($values['temp_in'], $values['rel_hum_in'], $text);
//testComp($COMP_WOFFICE);
echo "<h2>{$text['current_values']} {$text['for_date']} $day.$month.$year in <span id=\"location\">$STATION_NAME</span>,
{$text['measured_at']} $hrmin</h2>";
// Temperature and Humidity
$absHum=absoluteHumidity($values['temp_out'],$values['rel_hum_out']);
echo "<Table border=\"1\" valign=\"center\">";
echo "<tr>";
echo "<td colspan=\"2\"><b>{$text['temperature']} {$text['and']} {$text['humidity']}</b></td>";
echo "<td colspan=\"2\"><b>{$text['tendency']}</b></td>";
echo "</tr>";
echo "<tr>";
echo "<td>{$text['temperature']}</td>";
echo "<td><span id=\"tempout\">$values[temp_out] °C</span></td>";
displayTendency($diff['temp_out'],"°C/h", $text);
echo "</tr>";
echo "<tr>";
echo "<td>{$text['humidity']}</td>";
echo "<td>$values[rel_hum_out] % ($absHum g/m³)</td>";
displayTendency($diff['rel_hum_out'],"%%/h", $text);
echo "</tr>";
echo "<tr>";
echo "<td>{$text['dewpoint']}</td>";
echo "<td>$values[dewpoint] °C</td>";
displayTendency($diff['dewpoint'],"°C/h", $text);
echo "</tr>";
if($values['temp_out'] >= 27)
{
$heatIdx = heatIndex($values['temp_out'], $values['rel_hum_out'], $text);
echo "<tr>";
echo "<td colspan=\"1\">{$text['heat_index']}</td>";
echo "<td colspan=\"3\">$heatIdx</td>";
echo "</tr>";
}
// Wind
if(isDisplayEnabled(DISPLAY_WIND_INFO))
{
echo "<tr>";
echo "<td colspan=\"4\"><b>{$text['wind']}</b></td>";
echo "</tr>";
echo "<tr>";
echo "<td>{$text['speed']}</td>";
echo "<td>$windkmh km/h ($bftTxt) ($values[windspeed] m/s) {$text['from']} $values[wind_direction] ($values[wind_angle]) </td>";
displayTendency($diff['windspeed'],"km/h", $text);
echo "</tr>";
echo "<tr>";
echo "<td>{$text['windchill']}</td>";
echo "<td>$values[wind_chill] °C</td>";
displayTendency($diff['wind_chill'],"°C/h", $text);
echo "</tr>";
}
// Air Pressure
if(isDisplayEnabled(DISPLAY_PRES_INFO))
{
echo "<tr>";
echo "<td colspan=\"4\"><b>{$text['pressure']}</b></td>";
echo "</tr>";
echo "<tr>";
echo "<td>{$text['nn_pressure']}</td>";
echo "<td>$values[rel_pressure] hPa</td>";
displayTendency($diff['rel_pressure'],"hPa/h", $text);
echo "</tr>";
echo "<tr>";
echo "<td>{$text['tendency']}</td>";
$tendName = tendencyName($values['tendency'], $text);
$foreName = forecastName($values['forecast'], $text);
echo "<td>$tendName ({$text['forecast']}: $foreName)";
echo "</td><td colspan=\"2\"><center>";
forecastSymbol($values['forecast']);
echo "</center></td></tr>";
}
// Precipitation
if(isDisplayEnabled(DISPLAY_RAIN_INFO))
{
echo "<tr>";
echo "<td colspan=\"4\"><b>{$text['precipitation']}</b></td>";
echo "</tr>";
echo "<tr>";
echo "<td>{$text['last_hour']}</td>";
echo "<td colspan=\"3\">$values[rain_1h] mm</td>";
echo "</tr>";
echo "<tr>";
echo "<td>{$text['today']}</td>";
echo "<td colspan=\"3\">$values[rain_24h] mm</td>";
echo "</tr>";
echo "<td>{$text['last_24_hours']}</td>";
echo "<td colspan=\"3\">$diff[rain_last24] mm</td>";
echo "</tr>";
echo "<tr>";
echo "<td>{$text['overall']}</td>";
echo "<td colspan=\"3\">$values[rain_total] mm</td>";
echo "</tr>";
}
if(phpMajorVersion() < 5)
{
require_once('sunriseSunset.php');
}
$prevTime = strtotime("-1 day", mktime($hour, $minute, $second, $month, $day, $year));
$sunRiseYesterday = date_sunrise($prevTime, SUNFUNCS_RET_STRING, $STATION_LAT, $STATION_LON, 90+5/6, date("O")/100);
$sunDownYesterday = date_sunset($prevTime, SUNFUNCS_RET_STRING, $STATION_LAT, $STATION_LON, 90+5/6, date("O")/100);
$sunRise = date_sunrise(time(), SUNFUNCS_RET_STRING, $STATION_LAT, $STATION_LON, 90+5/6, date("O")/100);
$sunDown = date_sunset(time(), SUNFUNCS_RET_STRING, $STATION_LAT, $STATION_LON, 90+5/6, date("O")/100);
echo "<tr>";
echo "<td colspan=\"4\"><b>{$text['sun_position']}</b></td>";
echo "</tr>";
echo "<tr>";
echo "<td>{$text['sun_rise']}</td>";
echo "<td colspan=\"1\">$sunRise{$text['uhr']}</td>";
echo "<td colspan=\"2\">{$text['yesterday']} $sunRiseYesterday{$text['uhr']}</td>";
echo "</tr>";
echo "<tr>";
echo "<td>{$text['sun_down']}</td>";
echo "<td colspan=\"1\">$sunDown{$text['uhr']}</td>";
echo "<td colspan=\"2\">{$text['yesterday']} $sunDownYesterday{$text['uhr']}</td>";
echo "</tr>";
// Indoor
if(isDisplayEnabled(DISPLAY_ROOM_INFO))
{
$absHum=absoluteHumidity($values['temp_in'],$values['rel_hum_in']);
echo "<tr>";
echo "<td colspan=\"4\"><b>{$text['indoor']}</b></td>";
echo "</tr>";
echo "<tr>";
echo "<td>{$text['temperature']}</td>";
echo "<td colspan=\"1\">$values[temp_in] °C</td>";
displayTendency($diff['temp_in'],"°C/h", $text);
echo "</tr>";
echo "<tr>";
echo "<td>{$text['humidity']}</td>";
echo "<td colspan=\"1\">$values[rel_hum_in] % ($absHum g/m³)</td>";
displayTendency($diff['rel_hum_in'],"%%/h", $text);
echo "</tr>";
echo "<tr>";
echo "<td>{$text['comfort']}</td>";
echo "<td colspan=\"3\">$comfTxt</td>";
echo "</tr>";
}
if($values['temp_in'] >= 27)
{
$heatIdxIn = heatIndex($values['temp_in'], $values['rel_hum_in'], $text);
echo "<tr>";
echo "<td colspan=\"1\">{$text['heat_index']}</td>";
echo "<td colspan=\"3\">$heatIdxIn</td>";
echo "</tr>";
}
// Additional Sensors
if($database->haveSensors(true))
{
echo "<tr>";
echo "<td colspan=\"4\"><b>{$text['additionalSensors']}</b></td>";
echo "</tr>";
echo "<tr>";
$database->listSensors(true);
while($datarow = $database->getNextRow())
{
$name=$datarow['name'];
$filename=$datarow['filename'];
$linenumber=$datarow['linenumber'];
$unit=$datarow['unit'];
$value=GetCurrentSensorValue($filename, $linenumber);
echo "<tr>";
echo "<td colspan=\"1\">$name</td>";
echo "<td colspan=\"3\">$value $unit</td>";
echo "</tr>";
}
$database->free();
}
// End
echo "</table>";
$database->close();
?>
</body>
</html>