CVS: phpweather-1.x config-dist.inc,1.3,1.4 demo.php,1.8,1.9 phpweath...
Brought to you by:
iridium
From: Martin G. <gim...@us...> - 2002-10-04 21:31:43
|
Update of /cvsroot/phpweather/phpweather-1.x In directory usw-pr-cvs1:/tmp/cvs-serv5220 Modified Files: config-dist.inc demo.php phpweather.inc Log Message: Dave Yearke <ye...@en...> suggested that I should add an $offset so that the user can correct the time on servers that doesn't know their own timezone, etc. The demo-page was also updated so that it works with register_globals turned off which is the default for a new installation of PHP 4.2.0. Index: config-dist.inc =================================================================== RCS file: /cvsroot/phpweather/phpweather-1.x/config-dist.inc,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- config-dist.inc 3 Sep 2002 12:23:20 -0000 1.3 +++ config-dist.inc 4 Oct 2002 21:31:39 -0000 1.4 @@ -7,8 +7,13 @@ * file called 'config.php' and save your customizations there. The * 'config.php' file is loaded after this file so that you can * override the settings in this file. - * - * This $useXXX variables control the databaseformat PHP Weather uses. + */ + +/* Offset in hours to add to the time of a report. If all your times + * are 2 hours off, then set this to -2. */ +$offset = 0; + +/* The $useXXX variables control the databaseformat PHP Weather uses. * Set them all to 0 to turn database-support off. Then PHP Weather * will retrieve a new METAR everytime the script is called. It takes * about one second to retrieve a METAR, so you probably want to use a @@ -57,12 +62,13 @@ /* This lets you configure a proxy. If you want to use a proxy, set - the next variable to 1. */ + * the next variable to 1. */ $useProxy = 0; /* Then set this variable to the ip-number or hostname of the proxy. */ $proxy_host = 'proxy.your-isp.com'; /* Finally, change the port, if necessary. The popular Squid proxy - defaults to port 3128, but port 80 or 8080 is also commonly used. */ + * defaults to port 3128, but port 80 or 8080 is also commonly + * used. */ $proxy_port = 3128; ?> Index: demo.php =================================================================== RCS file: /cvsroot/phpweather/phpweather-1.x/demo.php,v retrieving revision 1.8 retrieving revision 1.9 diff -u -3 -r1.8 -r1.9 --- demo.php 3 Sep 2002 12:25:05 -0000 1.8 +++ demo.php 4 Oct 2002 21:31:40 -0000 1.9 @@ -16,6 +16,18 @@ /* Support for including images: */ include('images.inc'); +/* We prepare some variables we'll need later. The variables might + * have been submitted by the user: */ +if (empty($HTTP_POST_VARS['city'])) + $city = 'BGTL'; +else + $city = $HTTP_POST_VARS['city']; + +if (empty($HTTP_POST_VARS['language'])) + $language = 'en'; +else + $language = $HTTP_POST_VARS['language']; + ?> <h1><a href="http://sourceforge.net/projects/phpweather/">PHP Weather</a></h1> @@ -171,10 +183,6 @@ 'es' => 'Spanish' ); -if (empty($language)) { - $language = 'en'; -} - while (list($lang_code, $locale) = each($languages)) { if ($lang_code == $language) { echo "<option selected value=\"$lang_code\">$locale</option>\n"; @@ -187,12 +195,13 @@ </form></p> <? -if (empty($city)) { - $city = 'BGTL'; -} + $metar = get_metar($city); + include('locale_' . $language . '.inc'); + pretty_print_metar($metar, $cities[$city]) ?> + <blockquote> <?php $decoded_metar = process_metar($metar); ?> <img src="<?php get_temp_image($decoded_metar) ?>" height="50" width="20" border="1"> Index: phpweather.inc =================================================================== RCS file: /cvsroot/phpweather/phpweather-1.x/phpweather.inc,v retrieving revision 1.14 retrieving revision 1.15 diff -u -3 -r1.14 -r1.15 --- phpweather.inc 11 Sep 2002 20:24:56 -0000 1.14 +++ phpweather.inc 4 Oct 2002 21:31:40 -0000 1.15 @@ -650,7 +650,7 @@ * array with entries like 'temp_c', 'visibility_miles' etc. */ global $strings, $wind_dir_text_short_array, $wind_dir_text_array, - $cloud_condition_array, $weather_array; + $cloud_condition_array, $weather_array, $offset; $temp_visibility_miles = ''; $cloud_layers = 0; @@ -696,12 +696,8 @@ * Date and Time of Report * We return a standard Unix UTC/GMT timestamp suitable for * gmdate() - * There has been a report about the time beeing wrong. If you - * experience this, then change the next line. You should - * add/subtract some hours to $regs[2], e.g. if all your times - * are 960 minutes off (16 hours) then add 16 to $regs[2]. */ - $decoded_metar['time'] = gmmktime($regs[2], $regs[3], 0, + $decoded_metar['time'] = gmmktime($regs[2] + $offset, $regs[3], 0, gmdate('m'), $regs[1], gmdate('Y')); } elseif (ereg('(AUTO|COR|RTD|CC[A-Z]|RR[A-Z])', $part, $regs)) { /* |