/
wxgraphs.php
396 lines (363 loc) · 16.9 KB
/
wxgraphs.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
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
<?php
############################################################################
# A Project of TNET Services, Inc. and Saratoga-Weather.org (Canada/World-ML template set)
############################################################################
#
# Project: Sample Included Website Design
# Module: sample.php
# Purpose: Sample Page
# Authors: Kevin W. Reed <kreed@tnet.com>
# TNET Services, Inc.
#
# Copyright: (c) 1992-2007 Copyright TNET Services, Inc.
############################################################################
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
############################################################################
# This document uses Tab 4 Settings
############################################################################
//Version 1.01 - 9-Aug-2011 - added Meteohub support
//Version 1.02 - 24-Mar-2012 - added WeatherCat support
//Version 1.03 - 03-Jul-2012 - added wview support
require_once("Settings.php");
require_once("common.php");
############################################################################
$TITLE= $SITE['organ'] . " - " . langtransstr("Trend Graphs");
$showGizmo = true; // set to false to exclude the gizmo
include("top.php");
############################################################################
?>
</head>
<body>
<?php
############################################################################
include("header.php");
############################################################################
include("menubar.php");
############################################################################
$graphImageDir = 'vwsimages/';
if(isset($SITE['graphImageDir'])) {$graphImageDir = $SITE['graphImageDir']; }
?>
<div id="main-copy">
<h1><?php langtrans('Weather Trend Graphs'); ?></h1>
<?php if($SITE['WXsoftware'] <> '') { // have software defined ?>
<p><?php print langtrans('Graphs generated by')." ".$SITE['WXsoftwareLongName']." "; ?>
<?php if(isset($wdversion)) {echo " (".$wdversion.")";} ?></p>
<?php } else { // software not defined yet ?>
<p> </p>
<p>Weather software not specified in configuration.</p>
<?php } // end software not defined yet ?>
<?php if($SITE['WXsoftware'] == 'WL') { // WeatherLink graph names ?>
<h2><?php echo langtransstr('Temperature') . ' / ' . langtransstr('Humidity'); ?></h2>
<?php genImageLink('OutsideTempHistory.gif','Temperature'); ?>
<?php genImageLink('OutsideHumidityHistory.gif','Humidity'); ?>
<br />
<?php genImageLink('DewPointHistory.gif','Dew Point'); ?>
<?php genImageLink('THWHistory.gif','THW Index'); ?>
<br />
<?php genImageLink('WindChillHistory.gif','Wind Chill'); ?>
<?php genImageLink('HeatIndexHistory.gif','Heat Index'); ?>
<br />
<h2><?php echo langtransstr('Wind') . ' / ' . langtransstr('Barometer'); ?></h2>
<?php genImageLink('WindSpeedHistory.gif','Wind Speed'); ?>
<?php genImageLink('WindDirectionHistory.gif','Wind Direction'); ?>
<br />
<?php genImageLink('HiWindSpeedHistory.gif','High Wind Speed'); ?>
<?php genImageLink('BarometerHistory.gif','Barometer'); ?>
<br />
<h2><?php langtrans('Rain'); ?></h2>
<?php genImageLink('RainHistory.gif','Rain'); ?>
<?php genImageLink('RainRateHistory.gif','Rain Rate'); ?>
<br />
<?php // figure out to display solar and/or UV based on site settings
if($SITE['SOLAR'] and $SITE['UV']) { // have both sensors ?>
<h2><?php echo langtransstr('Solar Radiation') . ' / ' . langtransstr('UV Index'); ?></h2>
<?php genImageLink('SolarRadHistory.gif','Solar Radiation'); ?>
<?php genImageLink('UVHistory.gif','UV Index'); ?>
<?php } elseif ($SITE['SOLAR']) { ?>
<h2><?php echo langtransstr('Solar Radiation'); ?></h2>
<?php genImageLink('SolarRadHistory.gif','Solar Radiation'); ?>
<?php } elseif ($SITE['UV']) { ?>
<h2><?php echo langtransstr('UV Index'); ?></h2>
<?php genImageLink('UVHistory.gif','UV Index'); ?>
<?php } // end solar/uv selection ?>
<?php } // end WeatherLink graph names ?>
<?php if($SITE['WXsoftware'] == 'VWS') { // VWS graph names ?>
<h2><?php echo langtransstr('Temperature') . ' / ' . langtransstr('Humidity'); ?></h2>
<?php genImageLink('vws742.jpg','Temperature'); ?>
<?php genImageLink('vws740.jpg','Humidity'); ?>
<br />
<?php genImageLink('vws757.jpg','Dew Point'); ?>
<?php genImageLink('vws2811.jpg','THW Index'); ?>
<br />
<?php genImageLink('vws754.jpg','Wind Chill'); ?>
<?php genImageLink('vws756.jpg','Heat Index'); ?>
<br />
<h2><?php echo langtransstr('Wind') . ' / ' . langtransstr('Barometer'); ?></h2>
<?php genImageLink('vws737.jpg','Wind Speed'); ?>
<?php genImageLink('vws736.jpg','Wind Direction'); ?>
<br />
<?php genImageLink('vws1325.jpg','High Wind Speed'); ?>
<?php genImageLink('vws758.jpg','Barometer'); ?>
<br />
<h2><?php langtrans('Rain'); ?></h2>
<?php genImageLink('vws744.jpg','Rain'); ?>
<?php genImageLink('vws859.jpg','Rain Rate'); ?>
<br />
<?php // figure out to display solar and/or UV based on site settings
if($SITE['SOLAR'] and $SITE['UV']) { // have both sensors ?>
<h2><?php echo langtransstr('Solar Radiation') . ' / ' . langtransstr('UV Index'); ?></h2>
<?php genImageLink('vws753.jpg','Solar Radiation'); ?>
<?php genImageLink('vws752.jpg','UV Index'); ?>
<?php } elseif ($SITE['SOLAR']) { ?>
<h2><?php echo langtransstr('Solar Radiation'); ?></h2>
<?php genImageLink('vws753.jpg','Solar Radiation'); ?>
<?php } elseif ($SITE['UV']) { ?>
<h2><?php echo langtransstr('UV Index'); ?></h2>
<?php genImageLink('vws752.jpg','UV Index'); ?>
<?php } // end solar/uv selection ?>
<?php } // end VWS graph names ?>
<?php if($SITE['WXsoftware'] == 'CU') { // Cumulus graph names ?>
<h2><?php echo langtransstr('Temperature') . ' / ' . langtransstr('Humidity'); ?></h2>
<?php genImageLink('temp.png','Temperature',620,248); ?>
<br />
<?php genImageLink('hum.png','Humidity',620,248); ?>
<br />
<h2><?php echo langtransstr('Wind') . ' / ' . langtransstr('Barometer'); ?></h2>
<?php genImageLink('wind.png','Wind Speed',620,248); ?>
<br />
<?php genImageLink('windd.png','Wind Direction',620,248); ?>
<br />
<?php genImageLink('press.png','Barometer',620,248); ?>
<br />
<h2><?php langtrans('Rain'); ?></h2>
<?php genImageLink('raint.png','Rain',620,248); ?>
<br />
<?php genImageLink('rain.png','Rain Rate',620,248); ?>
<br />
<?php } // end VWS graph names ?>
<?php if($SITE['WXsoftware'] == 'WD') { // Weather-Display graph names ?>
<h1><?php langtrans('Last 24 Hours'); ?></h1>
<?php genImageLink('curr24hourgraph.gif','Last 24 hours',469,555); ?>
<br /><br />
<h1><?php langtrans('Last 72 Hours'); ?></h1>
<?php genImageLink('curr72hourgraph.gif','Last 72 hours',469,555); ?>
<br /><br />
<h1><?php langtrans('Month to Date'); ?></h1>
<?php genImageLink('monthtodate.gif','Month to Date',469,555); ?>
<?php } // end WD graph names ?>
<?php if($SITE['WXsoftware'] == 'MH') { // Meteohub graph names ?>
<h2><?php echo langtransstr('Temperature') . ' / ' . langtransstr('Dew Point'). ' / ' . langtransstr('Barometer'); ?></h2>
<?php genImageLink('tdpb2day.png','Last 48 hours',610,300); ?>
<br /><br />
<h2><?php echo langtransstr('Wind') . ' / ' . langtransstr('Rain'); ?></h2>
<?php genImageLink('windrain2day.png','Last 48 hours',610,300); ?>
<?php if(isset($VPsolar) and isset($VPuv) and file_exists($graphImageDir.'soluv2day.png')) { ?>
<br /><br />
<h2><?php echo langtransstr('Solar') . ' / ' . langtransstr('UV Index'); ?></h2>
<?php genImageLink('soluv2day.png','Last 48 hours',610,300); ?>
<?php } // solar/uv only if both have sensors present ?>
<?php if(!isset($VPuv) and isset($VPsolar) and file_exists($graphImageDir.'solhi2day.png')) { ?>
<br /><br />
<h2><?php echo langtransstr('Solar') . ' / ' . langtransstr('Heat Index'); ?></h2>
<?php genImageLink('solhi2day.png','Last 48 hours',610,300); ?>
<?php } // only Solar sensor present ?>
<?php if(!isset($VPsolar) and isset($VPuv) and file_exists($graphImageDir.'uvhi2day.png')) { ?>
<br /><br />
<h2><?php echo langtransstr('UV Index') . ' / ' . langtransstr('Heat Index'); ?></h2>
<?php genImageLink('uvhi2day.png','Last 48 hours',610,300); ?>
<?php } // only UV sensor present ?>
<?php } // end MH graph names ?>
<?php if($SITE['WXsoftware'] == 'WCT') { // WeatherCat graph names
/*
$WX['GRTEMPO'] = 'temperature1.jpg'; // Current outside temperature graph.
$WX['GRDEW'] = 'dewpoint1.jpg'; // Current dew point graph.
$WX['GRHUMO'] = 'rh1.jpg'; // Current outside humidity graph.
$WX['GRWINDCH'] = 'windchill1.jpg'; // Current wind chill graph.
$WX['GRHEATI'] = 'heatindex1.jpg'; // Current heat index graph.
$WX['GRSOLAR'] = 'solarrad1.jpg'; // Current solar radiation graph.
$WX['GRUV'] = 'uv1.jpg'; // Current U.V. graph. Note: There's no U.V. sensor on the station here.
$WX['GRWINDD'] = 'winddirection1.jpg'; // Current wind direction graph.
$WX['GRWINDS'] = 'windspeed1.jpg'; // Current wind speed graph.
$WX['GRPRESSURE'] = 'pressure1.jpg'; // Current barometric pressure graph.
$WX['GRCLOUDB'] = 'cloudbase1.jpg'; // Current calculated cloud base graph.
$WX['GRRAIN1'] = 'precipitation1.jpg'; // Current 1 hour rain rate graph.
$WX['GRRAIN24'] = 'precipitationc1.jpg'; // Current daily rain rate graph.
*/
?>
<h2><?php echo langtransstr('Temperature') . ' / ' . langtransstr('Humidity'); ?></h2>
<?php genImageLink($WX['GRTEMPO'],'Temperature'); ?>
<?php genImageLink($WX['GRHUMO'],'Humidity'); ?>
<br />
<?php genImageLink($WX['GRWINDCH'],'Wind Chill'); ?>
<?php genImageLink($WX['GRHEATI'],'Heat Index'); ?>
<h2><?php echo langtransstr('Dew Point') . ' / ' . langtransstr('Barometer'); ?></h2>
<?php genImageLink($WX['GRDEW'],'Dew Point'); ?>
<?php genImageLink($WX['GRPRESSURE'],'Barometer'); ?>
<br />
<h2><?php echo langtransstr('Wind'); ?></h2>
<?php genImageLink($WX['GRWINDS'],'Wind Speed'); ?>
<?php genImageLink($WX['GRWINDD'],'Wind Direction'); ?>
<br />
<h2><?php langtrans('Rain'); ?></h2>
<?php genImageLink($WX['GRRAIN24'],'Rain'); ?>
<?php genImageLink($WX['GRRAIN1'],'Rain Rate'); ?>
<br />
<?php // figure out to display solar and/or UV based on site settings
if($SITE['SOLAR'] and $SITE['UV']) { // have both sensors ?>
<h2><?php echo langtransstr('Solar Radiation') . ' / ' . langtransstr('UV Index'); ?></h2>
<?php genImageLink($WX['GRSOLAR'],'Solar Radiation'); ?>
<?php genImageLink($WX['GRUV'],'UV Index'); ?>
<?php } elseif ($SITE['SOLAR']) { ?>
<h2><?php echo langtransstr('Solar Radiation'); ?></h2>
<?php genImageLink($WX['GRSOLAR'],'Solar Radiation'); ?>
<?php } elseif ($SITE['UV']) { ?>
<h2><?php echo langtransstr('UV Index'); ?></h2>
<?php genImageLink($WX['GRUV'],'UV Index'); ?>
<?php } // end solar/uv selection ?>
<?php } // end WeatherCat graph names ?>
<?php if($SITE['WXsoftware'] == 'WV') { // wview graph names
$WVgraphDescs = array(
'd' => 'Daily',
'w' => 'Weekly',
'm' => 'Monthly',
'y' => 'Yearly',
);
$WVgraphPeriods = array(
'd' => '24h',
'w' => '7d',
'm' => '28d',
'y' => '365d',
);
$WVgraphs = array(
# 24h graphs
'24h-temp' => 'tempdaycomp.png',
'24h-hc' => 'heatchillcomp.png',
'24h-hum' => 'humidday.png',
'24h-baro' => 'baromday.png',
'24h-rain' => 'rainday.png',
'24h-wdir' => 'wdirday.png',
'24h-wsp' => 'wspeeddaycomp.png',
'24h-rad' => 'radiationDay.png',
'24h-uv' => 'UVDay.png',
# 7d graphs
'7d-temp' => 'tempweekcomp.png',
'7d-hc' => 'heatchillweekcomp.png',
'7d-hum' => 'humidweek.png',
'7d-baro' => 'baromweek.png',
'7d-rain' => 'rainweek.png',
'7d-wdir' => 'wdirweek.png',
'7d-wsp' => 'wspeedweekcomp.png',
'7d-rad' => 'radiationWeek.png',
'7d-uv' => 'UVWeek.png',
# 28d graphs
'28d-temp' => 'tempmonthcomp.png',
'28d-hc' => 'heatchillmonthcomp.png',
'28d-hum' => 'humidmonth.png',
'28d-baro' => 'barommonth.png',
'28d-rain' => 'rainmonth.png',
'28d-wdir' => 'wdirmonth.png',
'28d-wsp' => 'wspeedmonthcomp.png',
'28d-rad' => 'radiationMonth.png',
'28d-uv' => 'UVMonth.png',
# 365d graphs
'365d-temp' => 'tempyear.png',
'365d-hum' => 'humidyear.png',
# http://192.168.189.133/weather/wchillyear.png',
# http://192.168.189.133/weather/hindexyear.png',
'365d-hc' => 'hindexyear.png',
'365d-baro' => 'baromyear.png',
'365d-rain' => 'rainyear.png',
# http://192.168.189.133/weather/dewyear.png',
'365d-wsp' => 'wspeedyear.png',
'365d-wdir' => 'wdiryear.png',
# http://192.168.189.133/weather/hiwspeedyear.png',
'365d-rad' => 'radiationYear.png',
'365d-uv' => 'UVYear.png',
);
$WVgraphIdx = 'w'; // default is 7-day set
$WVgraphName = $WVgraphDescs[$WVgraphIdx];
$WVgraphSet = $WVgraphPeriods[$WVgraphIdx];
if(isset($_REQUEST['graph'])) { // check out selection
$req = strtolower($_REQUEST['graph']);
foreach ($WVgraphDescs as $i => $v) {
if ($req == $i) {
$WVgraphIdx = $i; // default is 7-day set
$WVgraphName = $WVgraphDescs[$i];
$WVgraphSet = $WVgraphPeriods[$i];
break;
}
}
}
// generate the links for the available periods to display
print "<p style=\"text-align: center\">";
foreach ($WVgraphDescs as $i => $v) {
if ($i == $WVgraphIdx) {
print "<strong>".langtransstr($v)."</strong> ";
} else {
print "<a href=\"?graph=$i\">".langtransstr($v)."</a> ";
}
}
print "</p>\n";
?>
<h2><?php echo langtransstr('Temperature') . ' - ' . langtransstr('Dew Point') . ' / ' . langtransstr('Wind Chill') . ' - ' .langtransstr('Heat Index'); ?></h2>
<?php genImageLink($WVgraphs[$WVgraphSet."-temp"],'Temperature'); ?>
<?php genImageLink($WVgraphs[$WVgraphSet."-hc"],'Wind Chill'); ?>
<br />
<h2><?php echo langtransstr('Humidity') . ' / ' . langtransstr('Barometer'); ?></h2>
<?php genImageLink($WVgraphs[$WVgraphSet."-hum"],'Humidity'); ?>
<?php genImageLink($WVgraphs[$WVgraphSet."-baro"],'Barometer'); ?>
<br />
<h2><?php echo langtransstr('Wind'); ?></h2>
<?php genImageLink($WVgraphs[$WVgraphSet."-wsp"],'Wind Speed'); ?>
<?php genImageLink($WVgraphs[$WVgraphSet."-wdir"],'Wind Direction'); ?>
<br />
<h2><?php langtrans('Rain'); ?></h2>
<?php genImageLink($WVgraphs[$WVgraphSet."-rain"],'Rain'); ?>
<br />
<?php // figure out to display solar and/or UV based on site settings
if($SITE['SOLAR'] and $SITE['UV']) { // have both sensors ?>
<h2><?php echo langtransstr('Solar Radiation') . ' / ' . langtransstr('UV Index'); ?></h2>
<?php genImageLink($WVgraphs[$WVgraphSet."-rad"],'Solar Radiation'); ?>
<?php genImageLink($WVgraphs[$WVgraphSet."-uv"],'UV Index'); ?>
<?php } elseif ($SITE['SOLAR']) { ?>
<h2><?php echo langtransstr('Solar Radiation'); ?></h2>
<?php genImageLink($WVgraphs[$WVgraphSet."-rad"],'Solar Radiation'); ?>
<?php } elseif ($SITE['UV']) { ?>
<h2><?php echo langtransstr('UV Index'); ?></h2>
<?php genImageLink($WVgraphs[$WVgraphSet."-uv"],'UV Index'); ?>
<?php } // end solar/uv selection ?>
<?php } // end wview graph names ?>
</div><!-- end main-copy -->
<?php
#--------------------------------------------------------------------------
# function genImageLink
#--------------------------------------------------------------------------
function genImageLink ( $imagename, $alttext, $width=310, $height=200) {
global $graphImageDir;
if(!file_exists($graphImageDir.$imagename)) {
print "$graphImageDir$imagename not found.";
} else {
print "<img src=\"$graphImageDir$imagename\" alt=\"$alttext\" width=\"$width\" height=\"$height\" />\n";
}
}
#--------------------------------------------------------------------------
# end genImageLink function
#--------------------------------------------------------------------------
############################################################################
include("footer.php");
############################################################################
# End of Page
############################################################################
?>