Codice PHP:
<?php
$debug = false;
$Version = "<!-- WU-History-inc.php - Version 3.3 - 4-Mar-2016 -->\r";
/*------------------------------------------------
//WU-History.php
//PHP script by Jim McMurry - [email]jmcmurry@mwt.net[/email] - jcweather.us
//Current version maintained at [url]http://jcweather.us/scripts.php[/url]
//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
//
//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 = "Europe/Rome"; // Change to your TZ. Ken True has a list available at [url]http://saratoga-weather.org/timezone.txt[/url]
$WUID = "ICALABRI44"; // Your stations Wunderground ID
$units = "M"; // Default units which are changeable at runtime. "M" for Metric, "E" for English or "B" for Both
$birthday = "02-03-2013"; // Stations first day of operation format dd-mm-yyyy. This will determine years on the date selector.
$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 = "100%"; // 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 = "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 = "./top.htm"; // 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 = "./bottom.htm"; // Same but for the area below the right blue box. Paths to the files must be relative to the calling page.