-
Notifications
You must be signed in to change notification settings - Fork 7
/
WU-History-inc.php
1631 lines (1558 loc) · 66.8 KB
/
WU-History-inc.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
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
$debug = false;
$Version = "<!-- WU-History-inc.php - Version 3.4j - 11-Nov-2023 -->\r";
/*------------------------------------------------
//WU-History.php
//PHP script by Jim McMurry - [email protected] - jcweather.us
//Current version maintained at http://jcweather.us/scripts.php
//Version 1.0 February 18, 2008
// 1.1 February 19, 2008 - Fixed a broken link to WU & added optional selection of other stations.
// 1.2 February 20, 2008 - Fixed an obscure link bug dealing with the new "other station" option.
// 1.3 February 22, 2008 - Added option to omit cloud conditions from tabular listing. Fixed solar & rain issue in the summary section.
// 1.4 February 22, 2008 - Supressed Solar & UV graphs in monthly & longer modes. Supressed current conditions in the summary except when viewing current day.
// 1.5 February 23, 2008 - Fixed precip error when viewing previous days. Added optional top link in header to return to "today" when off somewhere else.
// 1.6 February 27, 2008 - Fixed some missing </b> tags that were missing in the English mode that were preventing validation.
// 1.7 March 25, 2008 - Removed a superfluous <td> tag that caused a failed validation when using the option for multiple stations.
// 1.8 April, 05, 2008 - added Settings.php awareness to script (K True/saratoga-weather.org) for Carterlake/WD/AJAX/PHP templates.
// 1.9 April 07, 2008 - Made the tabular data listing optional.
// 2.0 December 23, 2008 - Fixes bugs in code to determine units output. (Thanks to Jozef (Pinto) for finding those.
// 2.1 December 23, 2008 - Fixes the modes other than Daily that were affected. (Jozef is now officially a co-author)
// 2.2 January 31, 2009 - Fixes errors in average wind and some metric rain conversions. (Thanks to Paul Gogan for finding these)
// 2.3 February 10, 2009 - A better fix to the average wind issue and a variable we can turn off when they fix the problem.
// 2.4 April 18, 2009 - Changed cm to mm in tabular section when showing units "both" in daily mode. Added Solar to daily tabular data
// 2.5 April 15, 2010 - Fixed a bug found by Pelle where metric rain wasn't being converted to mm in the summary section
// 2.6 August 8, 2011 - Chenged the above back to get the rain right again due to problem reported by Oebel
// 2.7 February 3, 2012 - Put in a check to preclude selecting a future date which was causing problems for Wunderground
// 2.8 October 10, 2013 - Fixed the spacing on some of the units. Found by Han
// 2.9 December 1, 2013 - Fixed first of the week/month or other times that there's no data in the csv file. Found by Han
// 3.0 December 29, 2014 - WU doesn't remove deleted lines, but makes temps -999 so this removes those. Found by Jerry Callahan
// 3.1 April 28, 2015 - Jachym found - If data is missing WU will usually report -999.9 or -573.3 (that is -999.9 F converted to C....)
// 3.2 January 28, 2016 - ereg_replace changed to str_replace for PHP 7.0. Thanks Wim
// 3.3 March 4, 2016 - Changed code for getting WU data. Thanks once again Wim
// 3.4 November 7, 2016 - Changed the 'getcsv' code for cURL+https Ken True
// 3.4a February 21, 2017 - fixed two Notice: errata Ken True
// 3.4b December 1, 2017 - more Notice: errata fixed - Ken True
// 3.4c October 3, 2018 - return with message if data not available, fix notice errata for no data
// 3.4d May, 23, 2019 - added support for local WXDailyHistory.php as WU discontinued WXDailyHistory.asp
// 3.4e June 4, 2019 - fixed check for data present
// 3.4f April 16,2020 - removed link to graphic as WU discontinued the image generation
// 3.4g April 27,2020 - fixed rain total for weekly display
// 3.4h March 21,2021 - fixed mktime issue with PHP8+
// 3.4i March 23,2021 - fixed divide by zero issue in wDirAvg() routine
// 3.4j November 11, 2023 - fix PHP errors with negative days (Thanks to Jerry Wilkins https://www.gwwilkins.org/)
//
//Portions of the code was borrowed from:
//Weather Underground - wunderground.com
//Ken True - saratoga-weather.org
//Tom Chaplin - carterlake.org
//Kevin Reed - tnetweather.com
//and probably several others.
//This script retrieves a weather station's raw data from Weather Underground
//and displays it in a similar way to how they do it on their site.
//Weather Underground is very willing to share the graphics and data
//on their site with those who provide weather data to them.
//In a correspondence with Ken True, John Celenza, Director of Weather
//Technology at Wunderground stated:
//"Please feel free to use Wunderground images and data on personal sites,
//as long as you link those images to Wunderground or give direct credit.
//Something like 'This image courtesy of Weather Underground' is appropriate."
//This script does NOT generate a complete HTML page and is intended for use
//ONLY by being included in an existing webpage on your site by:
// include("./WU-History.php");
//You'll also have to place the following in the <head> section of your calling
//page:
// <link rel="stylesheet" type="text/css" href="./WU-HistoryTan.css" />
//See the enclosed test file TestHistory.php to see how this is done.
//If your WU-history files are to be kept in a folder other than where your
//calling page is, you'll have to adjust the above. As an example,
//if your calling page is in the root folder of your web site and the WU files
//have been placed in a folder named /abc/, the paths above would need to be
// ./abc/WU-History.xxx
//If using the optional files below to place information to the right of the
//summary area, the same path will have to be used with those files as well.
//Just remember that the paths are always relative to the calling page.
//The supporting graphics are in the enclosed wuicons folder, and that folder
//must be placed in the same folder with this script. If you wish the icons
//elsewhere, just make the appropriate changes in WU-History.css.
//Optional parameters are normally not necessary, but there are a few available:
//ID=xxxxxxx should you wish to call it with a different station ID for some reason
//day=xx for a day other than today
//month=xx for a month other than this month
//year=xxxx for a different year
//There must be a "?" to signal the beginning of the parameters and "&" between items
//So, if you wished to call it for my station and show last Christmas, you'd use
//WU-History.php?ID=KWIMAUST1&day=25&month=12&year=2007
//Folks with graphic talent may want to modify the css and create graphics in other
//colors in order to come up with different color schemes. If you put something
//together that you'd like to share, please send me copies of the .css and the
//graphics and I'd be happy to add them to this package for others to use.
//This script Is Valid XHTML 1.0 Strict!
$WunderWrong
//settings ----------------------------- */
// Special Temporary Setting. In week, month or year modes, Wundergrund is sending Average Wind in mph instead of km/h. Only affects metric users.
// I'll get the word out if they fix it and you can turn it off.
$WunderWrong = true;
//
$timezone = "America/Los_Angeles"; // Change to your TZ. Ken True has a list available at http://saratoga-weather.org/timezone.txt
$WUID = "KCASARAT1"; // Your stations Wunderground ID
$units = "E"; // Default units which are changeable at runtime. "M" for Metric, "E" for English or "B" for Both
$birthday = "07-02-2004"; // Stations first day of operation format dd-mm-yyyy. This will determine years on the date selector.
$birthday = "01-01-2008"; // all that's left in wu API data
$gwidth = "500"; // Width of the graph - normally 500
$gtemp = true; // =true if you want the temperature graph =false if no
$gpress = true; // =true if baro graph =false if no
$gwind = true; // =true if wind velocity graph =false if no
$gwindir = true; // =true if wind direction graph =false if no
$grain = true; // =true if rain graph =false if no
$gsolar = true; // =true if solar graph =false if no
$guv = true; // =true if UV graph =false if no
$pwidth = "620px"; // The width of the summary and graph portion of the page (% or px). Normally 100%
// Optional header info
$header = true; // true if you wish to use it
$Langtitle = "Saratoga-Weather Station Historical Data"; // The Bold text at the top
$LcurDay = "Return to Current Day"; // The link back to the current day if off in one of the other modes. "" to disable it.
// Optional footer bar
$footer = true; // true if you wish to have the colored footer bar at the bottom
$LangFtext = "Juneau County Weather"; // Anything you wish or "" for a plain bar
// Optional content to be placed to the right of the Summary/Graph portion of the page
$inboxfile = ""; // A file of html to be placed in the right outlined box. Make it "" if not using, or just don't have a file available.
$outboxfile = ""; // Same but for the area below the right blue box. Paths to the files must be relative to the calling page.
// Optional "Return to Top" link on the right side
$toTop = false; // Most will want this, but some folks have alternative methods.
$LtopPg = "Return to Top";
// Optional selector for other PWS data
$selOthers = false; // true if you wish to show other stations, false if not
$otherIds = array('KWIMAUST1', 'ISILKEBO2', 'IVLAAMSG7', 'IBOUCHES4'); // Only works for PWS - Not Airports!
$otherLocat = array('Mauston, WI', 'Silkeborg, DK', 'Kampenhout, BE', 'Cassis, FR');
// Option to not show sky conditions in the daily tabular listing
$skipSolar = false; // true to skip solar data, false to include them
$skipSky = true; // true to skip sky conditions, false to include them
// Option to not show the tabular data
$skipTab = false; // true if you wish to suppress the tabular data
//
// Language changes follow. If unsure about any of them, try it and see what happens.
$mnthname = array('Nil', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
// Next are for the Summary Table
$Langtabs = array('Daily', 'Weekly', 'Monthly', 'Yearly', 'Custom'); // Tabs above the Summary Table
$LangSumHeads = array("Temperature", "Dew Point", "Humidity", "Wind Speed", "Wind Gust", "Wind", "Pressure", "Precipitation", "Solar");
// Headings for the Summary Table
$LangSumCols = array("Current", "High", "Low", "Average");
$LSumfor = "Summary for";
$Lunits = "Units";
$Lboth = "Both";
$Lenglish = "English";
$Lmetric = "Metric";
$Lnext = "Next";
$Lprev = "Previous";
$Ltarget = array("Day", "Week", "Month", "Year");
$Lview = "View";
$LNoData = "No Data Available for This Period"; // added 12/1/13
$Ltab1 = "Tabular Data for"; // Next 5 for Blue bar above the Tabular listing
$Ltab2 = "Weeks Tabular Data";
$Ltab3 = "Months Tabular Data";
$Ltab4 = "Years Tabular Data";
$Ltab5 = "Custom Date Range Tabular Data";
// Next are for the Tabular Table
$Lheadings = array('Time', 'Temperature', 'Dew Point', 'Pressure', 'Wind', 'Wind Speed', 'Wind Gust', 'Humidity', 'Rainfall Rate (Hourly)', 'solar', 'Conditions');
// Headings when in weekly, monthly etc modes
$Lhdngs2 = array("Temp", "Dew Point", "Humidity", "Sea Level Pressure", "Wind", "Gust Speed", "Precip");
$Lcols2 = array("high", "ave", "low", "sum");
$Lcommafile= "Comma Delimited File";
$Lthanks = "Compliments of";
//
// end of settings
//------------------------------------------------
// overrides from Settings.php if available
global $SITE;
if (isset($SITE['tz'])) {$timezone = $SITE['tz'];}
if (isset($SITE['WUID'])) {$WUID = $SITE['WUID'];}
if (isset($SITE['uomTemp'])) {
$units = preg_match('|C|i',$SITE['uomTemp']) ? 'M':'E';
}
if (isset($SITE['WUunits'])) {$units = $SITE['WUunits'];}
if (isset($SITE['WUstationname'])) {$LangFtext = $SITE['WUstationname'];}
if (isset($SITE['WUbirthday'])) {$birthday = $SITE['WUbirthday'];}
if (isset($SITE['UV'])) {$guv = $SITE['UV'];}
if (isset($SITE['SOLAR'])) {$gsolar = $SITE['SOLAR'];}
if (isset($SITE['timeFormat'])) {$timeFormat = $SITE['timeFormat'];}
// end of overrides from Settings.php if available
if (!function_exists('date_default_timezone_set')) {
putenv("TZ=" . $timezone);
} else {
date_default_timezone_set($timezone);
}
if (isset($_REQUEST['sce']) && strtolower($_REQUEST['sce']) == 'view' ) {
//--self downloader --
$filenameReal = __FILE__;
$download_size = filesize($filenameReal);
header('Pragma: public');
header('Cache-Control: private');
header('Cache-Control: no-cache, must-revalidate');
header("Content-type: text/plain");
header("Accept-Ranges: bytes");
header("Content-Length: $download_size");
header('Connection: close');
readfile($filenameReal);
exit;
}
echo $Version;
if(isset($_REQUEST['debug'])) {$debug = true; }
// Set some dates
$mo = date("m");
$da = date("d");
$yr = date("Y");
$FIRST_YEAR = substr($birthday,6,4);
$LAST_YEAR = $yr;
if ($debug) {
print "<!-- initial units='$units' -->\n";
print "<!-- initial request \n".print_r($_REQUEST,true)." \n-->\n";
}
// Defaults if called without parameters
$PHP_SELF = $_SERVER['PHP_SELF'];
if ( empty($_REQUEST['ID']) )
$_REQUEST['ID']=$WUID;
if ( empty($_REQUEST['day']) )
$_REQUEST['day']=$da;
if ( empty($_REQUEST['dayend']) )
$_REQUEST['dayend']=$da;
if ( empty($_REQUEST['month']) )
$_REQUEST['month']=$mo;
if ( empty($_REQUEST['monthend']) )
$_REQUEST['monthend']=$mo;
if ( empty($_REQUEST['year']) )
$_REQUEST['year']=$yr;
if ( empty($_REQUEST['yearend']) )
$_REQUEST['yearend']=$yr;
if ( empty($_REQUEST['units']) )
$_REQUEST['units']=$units;
if ( empty($_REQUEST['mode']) )
$_REQUEST['mode']=1;
if ($debug) {print "<!-- final request \n".print_r($_REQUEST,true)." \n-->\n";}
//Pass into PHP variables
//------------------------------------------------
$WUID = $_REQUEST['ID'];
$da = $_REQUEST['day'];
$mo = $_REQUEST['month'];
$yr = $_REQUEST['year'];
$da2 = $_REQUEST['dayend'];
$mo2 = $_REQUEST['monthend'];
$yr2 = $_REQUEST['yearend'];
$units = $_REQUEST['units'];
$mode = $_REQUEST['mode'];
print "<!-- final units='$units' -->\n";
// Find out if it's today or in the past
$reqdate = $da . "-" . $mo . "-" . $yr;
$isToday = strtotime($reqdate) == strtotime(date("d-m-Y"));
if (time() < strtotime($mo . "/" . $da . "/" . $yr)) { // preclude any dates in the future that were causing problems for Wunderground
$mo = date("n");
$da = date("j");
$yr = date("Y");
}
// Gather the csv data
$WUgraphstr = "https://www.wunderground.com/cgi-bin/wxStationGraphAll";
$WUdatastr = "https://www.wunderground.com/weatherstation/WXDailyHistory.asp";
$tPage = getCurrentPageURL(false);
$WUdatastr = str_replace(pathinfo($_SERVER['PHP_SELF'],PATHINFO_BASENAME),'WXDailyHistory.php',$tPage);
if ($mode == 1) {
$wunderstring = $WUdatastr . "?ID=" . $WUID . "&month=" . $mo . "&day=" . $da . "&year=" . $yr . "&format=1&graphspan=day"; // Day
} elseif ($mode == 2) {
$wunderstring = $WUdatastr . "?ID=" . $WUID . "&month=" . $mo . "&day=" . $da . "&year=" . $yr . "&format=1&graphspan=week"; // Week
} elseif ($mode == 3) {
$wunderstring = $WUdatastr . "?ID=" . $WUID . "&month=" . $mo . "&day=" . $da . "&year=" . $yr . "&format=1&graphspan=month"; // Month
} elseif ($mode == 4) {
$wunderstring = $WUdatastr . "?ID=" . $WUID . "&month=" . $mo . "&day=" . $da . "&year=" . $yr . "&format=1&graphspan=year"; // Year
} elseif ($mode == 5) {
$wunderstring = $WUdatastr . "?ID=" . $WUID . "&month=" . $mo . "&day=" . $da . "&year=" . $yr . "&monthend=" . $mo2 . "&dayend=" . $da2 . "&yearend=" . $yr2 . "&format=1&graphspan=custom"; // Custom
}
$rawstring=getcsvWithoutHanging($wunderstring);
$csvraw = array();
$rawstring = str_replace("<br>", "",$rawstring); // remove any embedded html newlines
foreach (explode("\n",$rawstring) as $i => $line) {
$csvraw[] = explode(",", $line);
}
if(count($csvraw) < 1) {
echo "<p>Sorry... the WU data for this date is not currently available. Please try again later.</p>\n";
return;
}
//echo $wunderstring;
//print_r($csvraw);
//exit;
$csvdata = array_pure($csvraw); //$csvdata has headings in row 0. Saving a copy for no good reason
if(!is_array($csvdata)) {
echo "<p>Sorry... the WU data for this date is not currently available. Please try again later.</p>\n";
echo "<p><small>Reason: no data returned from WU/TWC API</small></p>\n";
return;
}
echo "<!-- Size of the array is " . sizeof($csvdata) . " -->\r"; // Thanks to Jerry Callahan for finding this issue
foreach($csvdata as $key => &$line) { // See if there are any deleted entries and remove them
if ($line[1] < -100 || $line[1] > 150) { // If data is missing WU will usually report -999.9 or -573.3 (that is -999.9 F converted to C....)
// if ($line[1] == -999.0) { // Temp is this when the line's been deleted by the user
echo "<!-- Removing line " . $key . " -->\r";
unset($csvdata[$key]);
}
}
unset($line); // break the reference with the last element
echo "<!-- Size of the final array is " . sizeof($csvdata) . " -->\r";
$csvarray = $csvdata;
if ($mode == 1){
array_shift($csvarray); // Now $csvarray has nothing but 2D data. The other modes don't need this treatment
if ($csvarray[0][3] > 50) { // Use Baro to determine whether raw data is metric or not
$rawunits = "metric"; // Depends on how the user's wunderground cookie is set
} else {
$rawunits = "english";
}
if ($debug) { echo "<!-- $rawunits - " . $csvarray[0][3] . " -->\n"; }
} else {
if ($csvarray[0][10] > 50) { // Baro is in a different position in the other modes
$rawunits = "metric";
} else {
$rawunits = "english";
}
if ($debug) {echo "<!-- $rawunits - " . $csvarray[0][10] . " -->\n";}
}
sizeof($csvarray) > 0 ? $DataGood = true : $DataGood = false; // changed 12/1/13
$wunderCSVstring = str_replace("&","&",$wunderstring); // So the link to the csv output will validate
?>
<div id="wuwrap">
<table cellpadding="0" cellspacing="0" class="full" >
<tr>
<td class="vaT" id="content" >
<div style="margin-top: 15px;">
<?php
if ($header) { // This provides an option whether to show the top heading
echo '<div class = "heading">' . $Langtitle . '</div>' . "\r";
// Display link back to current day if not currently showing "today"
if (($mode > 1 or ! $isToday) && $LcurDay <> "") {
$callstr = $PHP_SELF . '?ID=' . $WUID . '&month=' . date("m") . '&day=' . date("d") . '&year=' . date("Y") . '&mode=1&units=' . $units;
echo '<div class="titleBar"><a href="' . $callstr . '">' . $LcurDay . '</a></div>' . "\r";
} else {
echo ' <div class="titleBar"> </div>' . "\r";
}
}
if ($mode == 1) {
$bannerphrase = $Langtabs[0] . ' ' . $LSumfor . ' ' . $mnthname[intval($mo)] . ' ' . $da . ', ' . $yr;
} elseif ($mode == 2) {
$bannerphrase = $Langtabs[1] . ' ' . $LSumfor . ' ' . $mnthname[intval($mo)] . ' ' . $da . ', ' . $yr;
} elseif ($mode == 3) {
$bannerphrase = $Langtabs[2] . ' ' . $LSumfor . ' ' . $mnthname[intval($mo)] . ' ' . $yr;
} elseif ($mode == 4) {
$bannerphrase = $Langtabs[3] . ' ' . $LSumfor . ' ' . $yr;
} else {
$bannerphrase = $LSumfor . ' ' . $mnthname[intval($mo)] . ' ' . $da . ', ' . $yr . ' - ' . $mnthname[intval($mo2)] . ' ' . $da2 . ', ' . $yr2;
}
?>
<table cellspacing="0" cellpadding="0" style="width: <?php echo($pwidth); ?>;">
<tr class="vaT">
<td class="full">
<table cellspacing="0" cellpadding="0" class="colorTop">
<tr>
<td class="hLeft"></td>
<td class="hCenter vaM" ><?php echo $bannerphrase; ?></td>
<td id="unitmenu" class="hMenu taL nobr vaM noprint myMenu" style="padding-top: 3px">
<?php
$callstr = $PHP_SELF . '?ID=' . $WUID . '&month=' . $mo . '&day=' . $da . '&year=' . $yr . '&mode=' . $mode . '&units=';
if ($units == "M") {
echo $Lunits . ': <b>' . $Lmetric . '</b> <a href="' . $callstr . '&units=E' . '">' . $Lenglish . '</a> <a href="' . $callstr . 'B">' . $Lboth . '</a>';
} elseif ($units == "E") {
echo $Lunits . ': <b>' . $Lenglish . '</b> <a href="' . $callstr . '&units=M' . '"> ' . $Lmetric . '</a> <a href="' . $callstr . 'B">' . $Lboth . '</a>';
} else {
echo $Lunits . ': <b>' . $Lboth . '</b> <a href="' . $callstr . '&units=E' . '">' . $Lenglish . '</a> <a href="' . $callstr . 'M">' . $Lmetric . '</a>';
}
?>
</td>
<td class="hRight"></td>
</tr>
<tr>
<td class="sLeft"></td>
<td class="sCenter"></td>
<td class="sCenter"></td>
<td class="sRight"></td>
</tr>
</table>
<div class="colorBox">
<div class="selectorBox noPrint">
<table cellspacing="0" cellpadding="0" class="full dateTable">
<tr>
<?php
if ($mode == 1) {
$ndate = AddDate($mo, $da, $yr, -1);
echo '<td class="nobr noprint"><!-- a href="' . $_SERVER['PHP_SELF'] . '?ID=' . $WUID . '&month=' . $ndate['mon'] . '&day=' . $ndate['mday'] . '&year=' . $ndate['year'] . '&units=' . $units . '&mode=' . $mode . '">« ' . $Lprev . ' ' . $Ltarget[0] . '</a --></td>';
} elseif ($mode == 2) {
$ndate = AddDate($mo, $da, $yr, -7);
echo '<td class="nobr noprint"><!-- a href="' . $_SERVER['PHP_SELF'] . '?ID=' . $WUID . '&month=' . $ndate['mon'] . '&day=' . $ndate['mday'] . '&year=' . $ndate['year'] . '&units=' . $units . '&mode=' . $mode . '">« ' . $Lprev . ' ' . $Ltarget[1] . '</a --></td>';
} elseif ($mode == 3) {
$ndate = AddDate($mo, $da, $yr, -30);
echo '<td class="nobr noprint"><!-- a href="' . $_SERVER['PHP_SELF'] . '?ID=' . $WUID . '&month=' . $ndate['mon'] . '&day=' . $ndate['mday'] . '&year=' . $ndate['year'] . '&units=' . $units . '&mode=' . $mode . '">« ' . $Lprev . ' ' . $Ltarget[2] . '</a --></td>';
} elseif ($mode == 4) {
$ndate = AddDate($mo, $da, $yr, -365);
echo '<td class="nobr noprint"><!-- a href="' . $_SERVER['PHP_SELF'] . '?ID=' . $WUID . '&month=' . $ndate['mon'] . '&day=' . $ndate['mday'] . '&year=' . $ndate['year'] . '&units=' . $units . '&mode=' . $mode . '">« ' . $Lprev . ' ' . $Ltarget[3] . '</a --></td>';
}
?>
<td class="taC full noprint">
<?php // These are the date selectors
echo '<form method="post" action="' . $_SERVER['PHP_SELF'] . '" />';
echo '<table border="0" cellpadding="0" cellspacing="0" style="margin-left: auto; margin-right: auto;">
<tr>';
if ($selOthers) {
echo '<td>
<select name="ID">' . "\n";
for ( $i = 0; $i < sizeof($otherLocat); $i ++ ) {
echo '<option value="' . $otherIds[$i] . '"';
if ($otherIds[$i]==$WUID) echo ' selected="selected"';
echo '>' . $otherLocat[ $i ] . '</option>' . "\n";
}
echo '</select>
</td>';
}
echo '<td>
<select name="month">' . "\n";
for ( $mon = 1; $mon < 13; $mon ++ ) {
echo '<option value="' . $mon . '"';
if ($mon==$mo) echo ' selected="selected"';
echo '>' . $mnthname[ $mon ] . '</option>' . "\n";
}
echo '</select>
</td><td>
<select name="day">' . "\n";
for ( $dd = 1 ; $dd < 32 ; $dd ++ ) {
echo '<option value="' . $dd . '"';
if ($dd==$da) echo ' selected="selected"';
echo '>' . $dd . '</option>' . "\n";
}
echo '</select>
</td><td>
<select name="year">' . "\n";
for ( $yy = $FIRST_YEAR ; $yy < $LAST_YEAR +1 ; $yy++ ) {
echo '<option value="' . $yy . '"';
if ($yy==$yr) echo ' selected="selected"';
echo '>' . $yy . '</option>' . "\n";
}
echo '</select>
</td>';
if ($mode == 5) { //Add second set here
echo '<td class="nobr" style="vertical-align: middle;">- TO -</td><td>
<select name="monthend">' . "\n";
for ( $mon2 = 1; $mon2 < 13; $mon2 ++ ) {
echo '<option value="' . $mon2 . '"';
if ($mon2==$mo2) echo ' selected="selected"';
echo '>' . $mnthname[ $mon2 ] . '</option>' . "\n";
}
echo '</select>
</td><td>
<select name="dayend">' . "\n";
for ( $dd2 = 1 ; $dd2 < 32 ; $dd2 ++ ) {
echo '<option value="' . $dd2 . '"';
if ($dd2==$da2) echo ' selected="selected"';
echo '>' . $dd2 . '</option>' . "\n";
}
echo '</select>
</td><td>
<select name="yearend">' . "\n";
for ( $yy2 = $FIRST_YEAR ; $yy2 < $LAST_YEAR +1 ; $yy2++ ) {
echo '<option value="' . $yy2 . '"';
if ($yy2==$yr2) echo ' selected="selected"';
echo '>' . $yy2 . '</option>' . "\n";
}
echo '</select>
</td>';
}
echo '<td><input type="submit" value="' . $Lview . '" /></td>
</tr>
</table>' . "\n";
?>
</td>
<?php
if ($mode == 1) {
$ndate = AddDate($mo, $da, $yr, +1);
echo '<td class="nobr noprint"><!-- a href="' . $_SERVER['PHP_SELF'] . '?ID=' . $WUID . '&month=' . $ndate['mon'] . '&day=' . $ndate['mday'] . '&year=' . $ndate['year'] . '&units=' . $units . '&mode=' . $mode . '">' . $Lnext . ' ' . $Ltarget[0] . ' »</a --></td>';
} elseif ($mode == 2) {
$ndate = AddDate($mo, $da, $yr, +7);
echo '<td class="nobr noprint"><!-- a href="' . $_SERVER['PHP_SELF'] . '?ID=' . $WUID . '&month=' . $ndate['mon'] . '&day=' . $ndate['mday'] . '&year=' . $ndate['year'] . '&units=' . $units . '&mode=' . $mode . '">' . $Lnext . ' ' . $Ltarget[1] . ' »</a --></td>';
} elseif ($mode == 3) {
$ndate = AddDate($mo, $da, $yr, +30);
echo '<td class="nobr noprint"><!-- a href="' . $_SERVER['PHP_SELF'] . '?ID=' . $WUID . '&month=' . $ndate['mon'] . '&day=' . $ndate['mday'] . '&year=' . $ndate['year'] . '&units=' . $units . '&mode=' . $mode . '">' . $Lnext . ' ' . $Ltarget[2] . ' »</a --></td>';
} elseif ($mode == 4) {
$ndate = AddDate($mo, $da, $yr, +365);
echo '<td class="nobr noprint"><!-- a href="' . $_SERVER['PHP_SELF'] . '?ID=' . $WUID . '&month=' . $ndate['mon'] . '&day=' . $ndate['mday'] . '&year=' . $ndate['year'] . '&units=' . $units . '&mode=' . $mode . '">' . $Lnext . ' ' . $Ltarget[3] . ' »</a --></td>';
}
?>
</tr>
</table>
<table cellspacing="0" cellpadding="0" class="full" id="typeTable">
<tr>
<?php // These are the daily, weekly etc tabs
$ActTab = 'class="activeTab"';
$InacTab = 'class="inactiveTab"';
$callstr = $PHP_SELF . '?ID=' . $WUID . '&month=' . $mo . '&day=' . $da . '&year=' . $yr . '&units=' . $units;
if ($mode == 1) { echo '<td ' . $ActTab . '>' . $Langtabs[0] . '</td>' . "\n"; } else { echo '<td ' . $InacTab . '><a href="' . $callstr . '&mode=1">' . $Langtabs[0] . '</a></td>' . "\n"; }
if ($mode == 2) { echo '<td ' . $ActTab . '>' . $Langtabs[1] . '</td>' . "\n"; } else { echo '<td ' . $InacTab . '><a href="' . $callstr . '&mode=2">' . $Langtabs[1] . '</a></td>' . "\n"; }
if ($mode == 3) { echo '<td ' . $ActTab . '>' . $Langtabs[2] . '</td>' . "\n"; } else { echo '<td ' . $InacTab . '><a href="' . $callstr . '&mode=3">' . $Langtabs[2] . '</a></td>' . "\n"; }
if ($mode == 4) { echo '<td ' . $ActTab . '>' . $Langtabs[3] . '</td>' . "\n"; } else { echo '<td ' . $InacTab . '><a href="' . $callstr . '&mode=4">' . $Langtabs[3] . '</a></td>' . "\n"; }
//if ($mode == 5) { echo '<td ' . $ActTab . '>' . $Langtabs[4] . '</td>' . "\n"; } else { echo '<td ' . $InacTab . '><a href="' . $callstr . '&mode=5">' . $Langtabs[4] . '</a></td>' . "\n"; }
?>
</tr>
</table>
</div> <!-- div class="selectorBox noPrint" -->
<?php if($DataGood) { ?> <!-- added 12/1/13 -->
<!-- Begin Summary Area -->
<table cellspacing="0" cellpadding="0" class="summaryTable tm10">
<thead>
<tr style="width:100%">
<td style="width: 25%;"> </td>
<?php if ($mode==1 && $isToday) echo '<td>' . $LangSumCols[0] . ':</td>'; ?>
<td><?php echo $LangSumCols[1]; ?>:</td>
<td><?php echo $LangSumCols[2]; ?>:</td>
<td><?php echo $LangSumCols[3]; ?>:</td>
</tr>
</thead>
<tbody>
<tr>
<td><?php echo $LangSumHeads[0] . ":"; ?></td>
<?php
print "<!-- units='$units' mode='$mode' -->\n";
if ($mode == 1) {
$result=temp_stats($csvarray, 1); // Temp
$current=convertTemps($csvarray[count($csvarray)-1][1]);
} else {
$t = temp_stats($csvarray, 1); // Process column 1 of the raw data
$result[0] = $t[0]; // Store just the Hi (of the Hi's)
$t = temp_stats($csvarray, 3); // Then column 2 which are the Lo's
$result[1] = $t[1]; // Store the Lo (of the Lo's)
$t = temp_stats($csvarray, 2); // Lastly proces column 3 which are the ave's
$result[2] = $t[2]; // Store the Ave (of the Ave's)
}
if ($units == "M") {
if ($mode == 1 && $isToday) echo '<td class="nobr"><b>' . $current[0] . '</b> °C</td>' . "\n";
echo '<td class="nobr"><b>' . $result[0][0] . '</b> °C</td>' . "\n";
echo '<td class="nobr"><b>' . $result[1][0] . '</b> °C</td>' . "\n";
echo '<td class="nobr"><b>' . $result[2][0] . '</b> °C</td>' . "\n";
} elseif ($units == "E"){
if ($mode == 1 && $isToday) echo '<td class="nobr"><b>' . $current[1] . '</b> °F</td>' . "\n";
echo '<td class="nobr"><b>' . $result[0][1] . '</b> °F</td>' . "\n";
echo '<td class="nobr"><b>' . $result[1][1] . '</b> °F</td>' . "\n";
echo '<td class="nobr"><b>' . $result[2][1] . '</b> °F</td>' . "\n";
} else {
if ($mode == 1 && $isToday) echo '<td class="nobr"><b>' . $current[1] . '</b> °F / <b>' . $current[0] . '</b> °C</td>' . "\n";
echo '<td class="nobr"><b>' . $result[0][1] . '</b> °F / <b>' . $result[0][0] . '</b> °C</td>' . "\n";
echo '<td class="nobr"><b>' . $result[1][1] . '</b> °F / <b>' . $result[1][0] . '</b> °C</td>' . "\n";
echo '<td class="nobr"><b>' . $result[2][1] . '</b> °F / <b>' . $result[2][0] . '</b> °C</td>' . "\n";
}
?>
</tr>
<tr>
<td><?php echo $LangSumHeads[1] . ":"; ?></td>
<?php
if ($mode == 1) {
$result=temp_stats($csvarray, 2); // Dew Point
$current=convertTemps($csvarray[count($csvarray)-1][2]);
} else {
$t = temp_stats($csvarray, 4);
$result[0] = $t[0];
$t = temp_stats($csvarray, 6);
$result[1] = $t[1];
$t = temp_stats($csvarray, 5);
$result[2] = $t[2];
}
if ($units == "M") {
if ($mode == 1 && $isToday) echo '<td class="nobr"><b>' . $current[0] . '</b> °C</td>' . "\n";
echo '<td class="nobr"><b>' . $result[0][0] . '</b> °C</td>' . "\n";
echo '<td class="nobr"><b>' . $result[1][0] . '</b> °C</td>' . "\n";
echo '<td class="nobr"><b>' . $result[2][0] . '</b> °C</td>' . "\n";
} elseif ($units == "E"){
if ($mode == 1 && $isToday) echo '<td class="nobr"><b>' . $current[1] . '</b> °F</td>' . "\n";
echo '<td class="nobr"><b>' . $result[0][1] . '</b> °F</td>' . "\n";
echo '<td class="nobr"><b>' . $result[1][1] . '</b> °F</td>' . "\n";
echo '<td class="nobr"><b>' . $result[2][1] . '</b> °F</td>' . "\n";
} else {
if ($mode == 1 && $isToday) echo '<td class="nobr"><b>' . $current[1] . '</b> °F / <b>' . $current[0] . '</b> °C</td>' . "\n";
echo '<td class="nobr"><b>' . $result[0][1] . '</b> °F / <b>' . $result[0][0] . '</b> °C</td>' . "\n";
echo '<td class="nobr"><b>' . $result[1][1] . '</b> °F / <b>' . $result[1][0] . '</b> °C</td>' . "\n";
echo '<td class="nobr"><b>' . $result[2][1] . '</b> °F / <b>' . $result[2][0] . '</b> °C</td>' . "\n";
}
?>
</tr>
<tr>
<td><?php echo $LangSumHeads[2] . ":"; ?></td>
<?php
if ($mode == 1) {
$result=col_stats($csvarray, 8); // Humidity
} else {
$t = col_stats($csvarray, 7);
$result[0] = $t[0];
$t = col_stats($csvarray, 9);
$result[1] = $t[1];
$t = col_stats($csvarray, 8);
$result[2] = $t[2];
}
if ($mode == 1 && $isToday) echo '<td>' . $csvarray[count($csvarray)-1][8] . '%</td>' . "\n";
echo '<td>' . $result[0] . '%</td>' . "\n";
echo '<td>' . $result[1] . '%</td>' . "\n";
echo '<td>' . round($result[2],0) . '%</td>' . "\n";
?>
</tr>
<tr>
<td><?php echo $LangSumHeads[3] . ":"; ?></td>
<?php
if ($mode == 1) {
$result=wind_stats($csvarray, 6); // Wind Speed
$current=convertWind($csvarray[count($csvarray)-1][6]);
} else {
$t = wind_stats($csvarray, 12);
$result[0] = $t[0];
$result[1] = 0;
$t = wind_stats($csvarray, 13);
$result[2] = $t[2];
if ($WunderWrong) {
if ($rawunits=="metric") $result[2][0] = miTokm($result[2][0],1); //PG 28/01/2009 (WU send mi/h instead of km/h for average wind speed)
}
/*
if ($rawunits=="metric") $result[2][0] = miTokm($result[2][0],1); //PG 28/01/2009 (WU send mi/h instead of km/h for average wind speed)
*/
}
if ($units == "M") {
if ($mode == 1 && $isToday) echo '<td class="nobr"><b>' . $current[0] . '</b>km/h</td>' . "\n";
echo '<td class="nobr"><b>' . $result[0][0] . '</b>km/h</td>' . "\n";
if ($result[1] == 0){ echo '<td>-</td>' . "\n";} else{ echo '<td class="nobr"><b>' . $result[1][0] . '</b>km/h</td>' . "\n";}
echo '<td class="nobr"><b>' . $result[2][0] . '</b>km/h</td>' . "\n";
} elseif ($units == "E"){
if ($mode == 1 && $isToday) echo '<td class="nobr"><b>' . $current[1] . '</b>mph</td>' . "\n";
echo '<td class="nobr"><b>' . $result[0][1] . '</b>mph</td>' . "\n";
if ($result[1] == 0){ echo '<td>-</td>' . "\n";} else{ echo '<td class="nobr"><b>' . $result[1][1] . '</b>mph</td>' . "\n";}
echo '<td class="nobr"><b>' . $result[2][1] . '</b>mph</td>' . "\n";
} else {
if ($mode == 1 && $isToday) echo '<td class="nobr"><b>' . $current[1] . '</b>mph / <b>' . $current[0] . '</b>km/h</td>' . "\n";
echo '<td class="nobr"><b>' . $result[0][1] . '</b>mph / <b>' . $result[0][0] . '</b>km/h</td>' . "\n";
echo '<td>-</td>' . "\n";
echo '<td class="nobr"><b>' . $result[2][1] . '</b>mph / <b>' . $result[2][0] . '</b>km/h</td>' . "\n";
}
?>
</tr>
<tr>
<td><?php echo $LangSumHeads[4] . ":"; ?></td>
<?php
if ($mode == 1) {
$result=wind_stats($csvarray, 7); // Wind Gust
$current=convertWind($csvarray[count($csvarray)-1][7]);
} else {
$t = wind_stats($csvarray, 14);
$result[0] = $t[0];
}
if ($units == "M") {
if ($mode == 1 && $isToday) echo '<td class="nobr"><b>' . $current[0] . '</b>km/h</td>' . "\n";
echo '<td class="nobr"><b>' . $result[0][0] . '</b>km/h</td>' . "\n";
echo '<td>-</td>' . "\n";
echo '<td>-</td>' . "\n";
} elseif ($units == "E"){
if ($mode == 1 && $isToday) echo '<td class="nobr"><b>' . $current[1] . '</b>mph</td>' . "\n";
echo '<td class="nobr"><b>' . $result[0][1] . '</b>mph</td>' . "\n";
echo '<td>-</td>' . "\n";
echo '<td>-</td>' . "\n";
} else {
if ($mode == 1 && $isToday) echo '<td class="nobr"><b>' . $current[1] . '</b>mph / <b>' . $current[0] . '</b>km/h</td>' . "\n";
echo '<td class="nobr"><b>' . $result[0][1] . '</b>mph / <b>' . $result[0][0] . '</b>km/h</td>' . "\n";
echo '<td>-</td>' . "\n";
echo '<td>-</td>' . "\n";
}
?>
</tr>
<?php
if ($mode == 1) {
echo '<tr>';
echo '<td>' . $LangSumHeads[5] . '</td>';
$result=wDirAvg($csvarray); // Wind Direction
if ($csvarray[count($csvarray)-1][6]==0) { $current = "Calm"; } else { $current = $csvarray[count($csvarray)-1][4]; }
if ($mode == 1 && $isToday) echo '<td>' . $current . '</td>' . "\n";
echo '<td>-</td>' . "\n";
echo '<td>-</td>' . "\n";
echo '<td>' . degTotxt($result) . '</td>' . "\n";
echo '</tr>' . "\n";
}
?>
<tr>
<td><?php echo $LangSumHeads[6] . ":"; ?></td>
<?php
if ($mode == 1) {
$result=baro_stats($csvarray, 3); // Pressure
$current=convertBaro($csvarray[count($csvarray)-1][3]);
} else {
$t = baro_stats($csvarray, 10);
$result[0] = $t[0];
$t = baro_stats($csvarray, 11);
$result[1] = $t[1];
}
if ($units == "M") {
if ($mode == 1 && $isToday) echo '<td class="nobr"><b>' . $current[0] . '</b> hPa</td>' . "\n";
echo '<td class="nobr"><b>' . $result[0][0] . '</b> hPa</td>' . "\n";
echo '<td class="nobr"><b>' . $result[1][0] . '</b> hPa</td>' . "\n";
echo '<td>-</td>' . "\n";
} elseif ($units == "E"){
if ($mode == 1 && $isToday) echo '<td class="nobr"><b>' . $current[1] . '</b> in</td>' . "\n";
echo '<td class="nobr"><b>' . $result[0][1] . '</b> in</td>' . "\n";
echo '<td class="nobr"><b>' . $result[1][1] . '</b> in</td>' . "\n";
echo '<td>-</td>' . "\n";
} else {
if ($mode == 1 && $isToday) echo '<td class="nobr"><b>' . $current[1] . '</b> in / <b>' . $current[0] . '</b> hPa</td>' . "\n";
echo '<td class="nobr"><b>' . $result[0][1] . '</b> in / <b>' . $result[0][0] . '</b> hPa</td>' . "\n";
echo '<td class="nobr"><b>' . $result[1][1] . '</b> in / <b>' . $result[1][0] . '</b> hPa</td>' . "\n";
echo '<td>-</td>';
}
?>
</tr>
<tr>
<td><?php echo $LangSumHeads[7] . ":"; ?></td>
<?php
if ($mode == 1) {
$current=convertRainMM($csvarray[count($csvarray)-1][12]);
} elseif ($mode == 2) {
$current=total_rain_week($csvarray,15);
} else {
$current=total_rain($csvarray, 15);
}
if ($units == "M") { // Precip
// echo '<td class="nobr"><b>' . $current[0] * 10 . '</b> mm</td>'; // To fix the cm to mm conversion problem found by Pelle
echo '<td class="nobr"><b>' . $current[0] . '</b> mm</td>'; // Changed back 8/2011
} elseif ($units == "E"){
echo '<td class="nobr"><b>' . $current[1] . '</b> in</td>';
} else {
// echo '<td class="nobr"><b>' . $current[1] . '</b> in / <b>' . $current[0] * 10 . '</b> mm</td>'; // Same
echo '<td class="nobr"><b>' . $current[1] . '</b> in / <b>' . $current[0] . '</b> mm</td>';
}
?>
<td> </td>
<td> </td>
<?php
if ($mode == 1 && $isToday) {
echo ' <td> </td>';
}
?>
</tr>
</tbody>
</table>
<!-- End Summary Area & Show the Graph -->
<?php } else { // added 12/1/13
echo '<p> </p><div style="text-align:center;"><h1 style="color:black;">' . $LNoData . '</h1></div><p> </p>';
}
?>
<?php
if ($mode == 1) {
$gphrase='type=3'; // Day
} elseif ($mode == 2) {
$gphrase='type=2'; // Week
} elseif ($mode == 3) {
$gphrase='type=1'; // Month
} elseif ($mode == 4) {
$gphrase='type=0'; // Year
} elseif ($mode == 5) {
$gphrase='type=6&yearend=' . $yr2 . '&monthend=' . $mo2 . '&dayend=' . $da2; // Custom
}
?>
<div class="taC tm10">
<?php if(false) { // discontinue image 3.4f as WU stopped the service ?>
<img src="<?php echo($WUgraphstr); ?>?day=<?php echo($da); ?>&year=<?php echo($yr); ?>&month=<?php echo($mo); ?>&ID=<?php echo($WUID); ?>&width=<?php echo($gwidth); ?>&showsolarradiation=<?php if ($mode < 3) echo $gsolar?'1':'0';?>&showuv=<?php if ($mode < 3) echo $guv?'1':'0'; ?>&showtemp=<?php echo $gtemp?'1':'0'; ?>&showpressure=<?php echo $gpress?'1':'0'; ?>&showwind=<?php echo $gwind?'1':'0'; ?>&showwinddir=<?php echo $gwindir?'1':'0'; ?>&showrain=<?php echo $grain?'1':'0'; ?>&type=<?php echo($gphrase); ?>" alt="Historical Graphs" id="wxHistoryImage" />
<?php } // end discontinue image ?>
<div class="noGap"> </div>
</div>
</div> <!--div class="colorBox" -->
<table cellspacing="0" cellpadding="0" class="colorBottom">
<tr>
<td class= "bLeft"><div></div></td>
<td class= "bCenter full"><div></div></td>
<td class= "bRight"><div></div></td>
</tr>
</table>
<div> </div>
</td>
<!-- This is the area for the blue box right of the graph -->
<?php
if (file_exists($inboxfile)) {
echo '<td class="noPrint">';
echo ' <div class="rightCol">';
echo ' <div class="rtTop"></div>';
echo ' <div class="contentBox taC">';
include ($inboxfile);
echo ' </div>';
echo ' <div class="rtBottom"></div>';
if (file_exists($outboxfile)) {
include ($outboxfile);
}
echo ' </div>';
echo '</td>';
}
?>
</tr>
</table>
<?php
if ($toTop == 1) { // Optional link to top of the page
echo '<div class="pageTop noprint"><a href="#">' . $LtopPg . '</a></div>';
}
if (! $skipTab) { // Begin tabular section with option to suppress
if ($mode == 1) {
$bannerphrase = $Ltab1 . ' ' . $mnthname[intval($mo)] . ' ' . $da . ', ' . $yr;
} elseif ($mode == 2) {
$bannerphrase = $Ltab2;
} elseif ($mode == 3) {
$bannerphrase = $Ltab3;
} elseif ($mode == 4) {
$bannerphrase = $Ltab4;
} else {
$bannerphrase = $Ltab5;
}
echo '<table cellspacing="0" cellpadding="0" class="colorTop">' . "\n";
echo '<tr>' . "\n";
echo '<td class="hLeft"></td>' . "\n";
echo '<td class="hCenter">' . $bannerphrase . '</td>' . "\n";
echo '<td class="hMenu"></td>' . "\n";
echo '<td class="hRight"></td>' . "\n";
echo '</tr>' . "\n";
echo '<tr>' . "\n";
echo '<td class="sLeft"></td>' . "\n";
echo '<td class="sCenter"></td>' . "\n";
echo '<td></td>' . "\n";
echo '<td class="sRight"></td>' . "\n";
echo '</tr>' . "\n";
echo '</table>' . "\n";
echo '<div class="colorBox">' . "\n";
// This is the lower data table when in Daily mode
if ($mode == 1) {
echo '<table cellspacing="0" cellpadding="0" class="dailyTable">' . "\n";
echo '<thead>' . "\n";
echo '<tr>' . "\n";
echo '<td>' . $Lheadings[0] . '</td>' . "\n";
echo '<td>' . $Lheadings[1] . '</td>' . "\n";
echo '<td>' . $Lheadings[2] . '</td>' . "\n";
echo '<td>' . $Lheadings[3] . '</td>' . "\n";
echo '<td>' . $Lheadings[4] . '</td>' . "\n";
echo '<td>' . $Lheadings[5] . '</td>' . "\n";
echo '<td>' . $Lheadings[6] . '</td>' . "\n";
echo '<td>' . $Lheadings[7] . '</td>' . "\n";
echo '<td>' . $Lheadings[8] . '</td>' . "\n";
$columns = 10;
if (! $skipSolar) {
echo '<td>' . $Lheadings[9] . '</td>' . "\n";
$columns++;
}
if (! $skipSky) {
echo '<td>' . $Lheadings[10] . '</td>' . "\n";
$columns++;
}
echo '</tr>' . "\n";
echo '</thead>' . "\n";
echo '<tbody>' . "\n";
for ($row=0; $row<count($csvarray); $row++) {
echo "<tr>" . "\n";
for ($col=0; $col<$columns; $col++) {
$data = $csvarray[$row][$col];
if ($col == 0) {print "<!-- data='$data' -->"; $data = substr($data,11,5);} //Date/Time
if ($col == 1 || $col == 2){ // Temp or DP
$convarray = convertTemps($data);
if ($units == "M") {
$data = "<b>" . $convarray[0] . "</b> °C";
} elseif ($units == "E"){
$data = "<b>" . $convarray[1] . "</b> °F";
} else {
$data = "<b>" . $convarray[1] . "</b> °F / " . "<b>" . $convarray[0] . "</b> °C";
}
}
if ($col == 3) { // Baro
$convarray = convertBaro($data);
if ($units == "M") {
$data = "<b>" . $convarray[0] . "</b> hPa";
} elseif ($units == "E"){
$data = "<b>" . $convarray[1] . "</b> in";
} else {
$data = "<b>" . $convarray[1] . "</b>in / " . "<b>" . $convarray[0] . "</b>hPa";
}
}
if ($col == 4) { // Wind direction
if ($csvarray[$row][$col+2]==0) $data = "Calm";
$col++; // Skip the wind "degrees" column
}
if ($col == 6 || $col == 7){ // Wind or Gust
$convarray = convertWind($data);
if ($data == 0) {
$data = " ";
} elseif ($units == "M") {
$data = "<b>" . $convarray[0] . "</b> km/h";
} elseif ($units == "E"){
$data = "<b>" . $convarray[1] . "</b> mph";
} else {
$data = "<b>" . $convarray[1] . "</b>mph / " . "<b>" . $convarray[0] . "</b>km/h";
}
}
if ($col == 8) $data = $data . "%"; //Humidity
if ($col == 9) { // Rain
$convarray = convertRainMM($data);
if ($units == "M") {
$data = "<b>" . $convarray[0] . "</b> mm";
} elseif ($units == "E"){
$data = "<b>" . $convarray[1] . "</b> in";
} else {
$data = "<b>" . $convarray[1] . "</b>in / " . "<b>" . $convarray[0] . "</b>mm";
}
/*
if ($skipSolar) {
$col = $col + 1; // Skip the solar column
}
if ($skipSky) {
$col = $col + 1; // Skip the condition column
}
*/
}
if ($col == 10 && ! $skipSolar) { // Solar
$data = $csvarray[$row][$col+3];
$data = "<b>" . $data . "</b> W/m<sup>2</sup>";
}
if ($col == 11 && ! $skipSky) { // Conditions
$data = $csvarray[$row][$col-1];
}
echo '<td>' . $data . "</td>" . "\n";
} // for $col
echo "</tr>";
} // for $row
echo '</tbody>';
echo '</table>';
} else { // Its weekly, monthly, yearly or custom
if ($units == "M") {
$tsym = "°C";
$bsym = "hPa";
$dsym = "km/h";
$vsym = "km";
$rsym = "cm";
// $rsym = "mm"; // Change to mm for Pelle
} elseif ($units == "E") {
$tsym = "°F";
$bsym = "in";
$dsym = "mph";
$vsym = "mi";
$rsym = "in";
} else {
$tsym = "°F / °C";
$bsym = "in / hPa";
$dsym = "mph / km/h";
$vsym = "mi / km";
$rsym = "in / cm";
// $rsym = "in / mm"; // Change to mm for Pelle
}
$pmo = substr($csvarray[0][0], 5, 2);
$pda = substr($csvarray[0][0], strrpos($csvarray[0][0],"-")+1, 2);
$pyr = substr($csvarray[0][0], 0, 4);
$columns = 16;
$needheading = true;
for ($row=0; $row<count($csvarray); $row++) {
if ($needheading) {
$pmo = substr($csvarray[$row][0], 5, 2);
$pyr = substr($csvarray[$row][0], 0, 4);
$col1title = $mnthname[intval($pmo)];
echo '<table cellspacing="0" cellpadding="0" class="obsTable" style="width:100%;">' . "\n";
echo '<thead>' . "\n";
echo '<tr>' . "\n";
echo '<td colspan="2">' . $pyr . '</td>' . "\n";
echo '<td colspan="3">' . $Lhdngs2[0] . ' (' . $tsym . ')</td>' . "\n";
echo '<td colspan="3">' . $Lhdngs2[1] . ' (' . $tsym . ')</td>' . "\n";
echo '<td colspan="3">' . $Lhdngs2[2] . ' (%)</td>' . "\n";
echo '<td colspan="2">' . $Lhdngs2[3] . ' (' . $bsym . ')</td>' . "\n";
echo '<td colspan="2">' . $Lhdngs2[4] . ' (' . $dsym . ')</td>' . "\n";
echo '<td>' . $Lhdngs2[5] . ' (' . $dsym . ')</td>' . "\n";
echo '<td>' . $Lhdngs2[6] . ' (' . $rsym . ')</td>' . "\n";
echo '</tr>' . "\n";
echo '</thead>' . "\n";
echo '<tbody>' . "\n";
echo '<tr>' . "\n";
echo '<td class="b HdgLt" colspan="2">' . $col1title . '</td>' . "\n";
echo '<td class="HdgDk Left">' . $Lcols2[0] . '</td>' . "\n";
echo '<td class="HdgDk">' . $Lcols2[1] . '</td>' . "\n";
echo '<td class="HdgDk Right">' . $Lcols2[2] . '</td>' . "\n";
echo '<td class="HdgLt">' . $Lcols2[0] . '</td>' . "\n";
echo '<td class="HdgLt">' . $Lcols2[1] . '</td>' . "\n";
echo '<td class="HdgLt">' . $Lcols2[2] . '</td>' . "\n";
echo '<td class="HdgDk Left">' . $Lcols2[0] . '</td>' . "\n";
echo '<td class="HdgDk">' . $Lcols2[1] . '</td>' . "\n";
echo '<td class="HdgDk Right">' . $Lcols2[2] . '</td>' . "\n";
echo '<td class="HdgLt">' . $Lcols2[0] . '</td>' . "\n";
echo '<td class="taC HdgLt">' . $Lcols2[2] . '</td>' . "\n";
echo '<td class="HdgDk Left">' . $Lcols2[0] . '</td>' . "\n";
echo '<td class="HdgDk Right">' . $Lcols2[1] . '</td>' . "\n";