phpweather-checkins Mailing List for PHP Weather (Page 11)
Brought to you by:
iridium
You can subscribe to this list here.
2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
(7) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2002 |
Jan
(1) |
Feb
(1) |
Mar
(184) |
Apr
(31) |
May
(45) |
Jun
(15) |
Jul
(11) |
Aug
(40) |
Sep
(19) |
Oct
(8) |
Nov
(6) |
Dec
(17) |
2003 |
Jan
(5) |
Feb
|
Mar
(12) |
Apr
(5) |
May
(2) |
Jun
(3) |
Jul
(3) |
Aug
(3) |
Sep
(17) |
Oct
(10) |
Nov
|
Dec
(4) |
2004 |
Jan
(21) |
Feb
(11) |
Mar
|
Apr
|
May
(3) |
Jun
(7) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2005 |
Jan
(4) |
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2006 |
Jan
|
Feb
|
Mar
(2) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Martin G. <gim...@us...> - 2002-05-18 09:20:23
|
Update of /cvsroot/phpweather/phpweather In directory usw-pr-cvs1:/tmp/cvs-serv27173 Modified Files: phpweather.php Log Message: It seams that pow() cannot handle floats passed to it as strings, at least not in PHP 4.2.0 at gimpster.com. The strange thing is that it works in PHP 4.1.2 at my local machine. Index: phpweather.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/phpweather.php,v retrieving revision 1.26 retrieving revision 1.27 diff -u -3 -r1.26 -r1.27 --- phpweather.php 18 May 2002 08:39:08 -0000 1.26 +++ phpweather.php 18 May 2002 09:20:20 -0000 1.27 @@ -240,14 +240,15 @@ } else { $month = gmdate('n'); } - $decoded_metar['time'] = gmmktime($regs[2] + $this->properties['offset'], $regs[3], 0, $month, $regs[1], gmdate('Y')); + $decoded_metar['time'] = + gmmktime($regs[2] + $this->properties['offset'], + $regs[3], 0, $month, $regs[1], gmdate('Y')); } elseif (ereg('(AUTO|COR|RTD|CC[A-Z]|RR[A-Z])', $part, $regs)) { /* * Report Modifier: AUTO, COR, CCx or RRx */ - - $decoded_metar['report_mod'] = $regs[1]; + $decoded_metar['report_mod'] = $regs[1]; } elseif (ereg('([0-9]{3}|VRB)([0-9]{2,3})G?([0-9]{2,3})?(KT|MPS|KMH)', $part, $regs)) { /* Wind Group */ @@ -258,8 +259,7 @@ $regs[4], $decoded_metar['wind']['knots'], $decoded_metar['wind']['meters_per_second'], - $decoded_metar['wind']['miles_per_hour'] - ); + $decoded_metar['wind']['miles_per_hour']); if (!empty($regs[3])) { @@ -646,9 +646,9 @@ $decoded_metar['wind']['miles_per_hour'] > 3) { $decoded_metar['windchill']['windchill_f'] = number_format(35.74 + 0.6215*$decoded_metar['temperature']['temp_f'] - - 35.75*pow($decoded_metar['wind']['miles_per_hour'], 0.16) + - 35.75*pow((float)$decoded_metar['wind']['miles_per_hour'], 0.16) + 0.4275*$decoded_metar['temperature']['temp_f'] * - pow($decoded_metar['wind']['miles_per_hour'], 0.16)); + pow((float)$decoded_metar['wind']['miles_per_hour'], 0.16)); $decoded_metar['windchill']['windchill_c'] = number_format(13.112 + 0.6215*$decoded_metar['temperature']['temp_c'] - 13.37*pow(($decoded_metar['wind']['miles_per_hour']/1.609), 0.16) @@ -662,26 +662,27 @@ if (!empty($decoded_metar['temperature']['temp_f']) && $decoded_metar['temperature']['temp_f'] > 70 && !empty($decoded_metar['rel_humidity'])) { - $decoded_metar['heatindex']['heatindex_f']= - number_format(-42.379 + 2.04901523*$decoded_metar['temperature']['temp_f'] - + 10.14333127*$decoded_metar['rel_humidity'] - - 0.22475541*$decoded_metar['temperature']['temp_f'] - *$decoded_metar['rel_humidity'] - - 0.00683783*$decoded_metar['temperature']['temp_f'] - *$decoded_metar['temperature']['temp_f'] - - 0.05481717*$decoded_metar['rel_humidity'] - *$decoded_metar['rel_humidity'] - + 0.00122874*$decoded_metar['temperature']['temp_f'] - *$decoded_metar['temperature']['temp_f'] - *$decoded_metar['rel_humidity'] - + 0.00085282*$decoded_metar['temperature']['temp_f'] - *$decoded_metar['rel_humidity'] - *$decoded_metar['rel_humidity'] - - 1.99*pow(10,-6)*$decoded_metar['temperature']['temp_f'] - *$decoded_metar['temperature']['temp_f'] - *$decoded_metar['rel_humidity'] - *$decoded_metar['rel_humidity']); - $decoded_metar['heatindex']['heatindex_c']= + $decoded_metar['heatindex']['heatindex_f'] = + number_format(-42.379 + + 2.04901523 * $decoded_metar['temperature']['temp_f'] + + 10.1433312 * $decoded_metar['rel_humidity'] + - 0.22475541 * $decoded_metar['temperature']['temp_f'] + * $decoded_metar['rel_humidity'] + - 0.00683783 * $decoded_metar['temperature']['temp_f'] + * $decoded_metar['temperature']['temp_f'] + - 0.05481717 * $decoded_metar['rel_humidity'] + * $decoded_metar['rel_humidity'] + + 0.00122874 * $decoded_metar['temperature']['temp_f'] + * $decoded_metar['temperature']['temp_f'] + * $decoded_metar['rel_humidity'] + + 0.00085282 * $decoded_metar['temperature']['temp_f'] + * $decoded_metar['rel_humidity'] + * $decoded_metar['rel_humidity'] + - 0.00000199 * $decoded_metar['temperature']['temp_f'] + * $decoded_metar['temperature']['temp_f'] + * $decoded_metar['rel_humidity'] + * $decoded_metar['rel_humidity']); + $decoded_metar['heatindex']['heatindex_c'] = number_format(($decoded_metar['heatindex']['heatindex_f'] - 32) / 1.8); } |
From: Martin G. <gim...@us...> - 2002-05-18 08:39:12
|
Update of /cvsroot/phpweather/phpweather In directory usw-pr-cvs1:/tmp/cvs-serv18817 Modified Files: phpweather.php Log Message: When the windchill and heatindex was calculated, the temperature and windspeed was compared to strings and not integers. I also re-indented some of the code. Index: phpweather.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/phpweather.php,v retrieving revision 1.25 retrieving revision 1.26 diff -u -3 -r1.25 -r1.26 --- phpweather.php 15 May 2002 22:23:26 -0000 1.25 +++ phpweather.php 18 May 2002 08:39:08 -0000 1.26 @@ -23,7 +23,8 @@ /** * PHP Weather is a class that understands how to parse a raw METAR. * - * The decoded METAR is saved in $decoded_metar, in a language-neutral format. + * The decoded METAR is saved in $decoded_metar, in a language-neutral + * format. * * @author Martin Geisler <gim...@gi...> * @version $Id$ @@ -143,22 +144,27 @@ if ($windunit == 'KT') { /* The windspeed measured in knots: */ $knots = number_format($value); - /* The windspeed measured in meters per second, rounded to one decimal place */ + /* The windspeed measured in meters per second, rounded to one + decimal place */ $meterspersec = number_format($value * 0.5144, 1); - /* The windspeed measured in miles per hour, rounded to one decimal place */ + /* The windspeed measured in miles per hour, rounded to one + decimal place */ $milesperhour = number_format($value * 1.1508, 1); } elseif ($windunit == 'MPS') { /* The windspeed measured in meters per second */ $meterspersec = number_format($value); - /* The windspeed measured in knots, rounded to one decimal place */ + /* The windspeed measured in knots, rounded to one decimal + place */ $knots = number_format($value / 0.5144, 1); - /* The windspeed measured in miles per hour, rounded to one decimal place */ + /* The windspeed measured in miles per hour, rounded to one + decimal place */ $milesperhour = number_format($value / 0.5144 * 1.1508, 1); } elseif ($windunit == 'KMH') { /* The windspeed measured in kilometers per hour */ $meterspersec = number_format($value * 1000 / 3600, 1); $knots = number_format($value * 1000 / 3600 / 0.5144, 1); - /* The windspeed measured in miles per hour, rounded to one decimal place */ + /* The windspeed measured in miles per hour, rounded to one + decimal place */ $milesperhour = number_format($knots * 1.1508, 1); } } @@ -274,7 +280,7 @@ */ $decoded_metar['wind']['var_beg'] = $regs[1]; $decoded_metar['wind']['var_end'] = $regs[2]; - } elseif(ereg('^([0-9]{4})([NS]?[EW]?)$', $part, $regs)) { + } elseif (ereg('^([0-9]{4})([NS]?[EW]?)$', $part, $regs)) { /* * Visibility in meters (4 digits only) */ @@ -466,24 +472,32 @@ /* * Temperature/Dew Point Group. */ - $decoded_metar['temperature']['temp_c'] = round(strtr($regs[1], 'M', '-')); - $decoded_metar['temperature']['temp_f'] = round(strtr($regs[1], 'M', '-') * (9/5) + 32); + $decoded_metar['temperature']['temp_c'] = + round(strtr($regs[1], 'M', '-')); + $decoded_metar['temperature']['temp_f'] = + round(strtr($regs[1], 'M', '-') * (9/5) + 32); if (!empty($regs[2])) { - $decoded_metar['temperature']['dew_c'] = round(strtr($regs[2], 'M', '-')); - $decoded_metar['temperature']['dew_f'] = round(strtr($regs[2], 'M', '-') * (9/5) + 32); + $decoded_metar['temperature']['dew_c'] = + round(strtr($regs[2], 'M', '-')); + $decoded_metar['temperature']['dew_f'] = + round(strtr($regs[2], 'M', '-') * (9/5) + 32); } - } elseif(ereg('A([0-9]{4})', $part, $regs)) { + } elseif (ereg('A([0-9]{4})', $part, $regs)) { /* * Altimeter. * The pressure measured in inHg. */ - $decoded_metar['altimeter']['inhg'] = number_format($regs[1]/100, 2); + $decoded_metar['altimeter']['inhg'] = + number_format($regs[1]/100, 2); /* The pressure measured in mmHg, hPa and atm */ - $decoded_metar['altimeter']['mmhg'] = number_format($regs[1] * 0.254, 1, '.', ''); - $decoded_metar['altimeter']['hpa'] = round($regs[1] * 0.33864); - $decoded_metar['altimeter']['atm'] = number_format($regs[1] * 3.3421e-4, 3, '.', ''); - } elseif(ereg('Q([0-9]{4})', $part, $regs)) { + $decoded_metar['altimeter']['mmhg'] = + number_format($regs[1] * 0.254, 1, '.', ''); + $decoded_metar['altimeter']['hpa'] = + round($regs[1] * 0.33864); + $decoded_metar['altimeter']['atm'] = + number_format($regs[1] * 3.3421e-4, 3, '.', ''); + } elseif (ereg('Q([0-9]{4})', $part, $regs)) { /* * Altimeter. * The specification doesn't say anything about @@ -494,9 +508,12 @@ $decoded_metar['altimeter']['hpa'] = round($regs[1]); /* The pressure measured in mmHg, inHg and atm */ - $decoded_metar['altimeter']['mmhg'] = number_format($regs[1] * 0.75006, 1, '.', ''); - $decoded_metar['altimeter']['inhg'] = number_format($regs[1] * 0.02953, 2); - $decoded_metar['altimeter']['atm'] = number_format($regs[1] * 9.8692e-4, 3, '.', ''); + $decoded_metar['altimeter']['mmhg'] = + number_format($regs[1] * 0.75006, 1, '.', ''); + $decoded_metar['altimeter']['inhg'] = + number_format($regs[1] * 0.02953, 2); + $decoded_metar['altimeter']['atm'] = + number_format($regs[1] * 9.8692e-4, 3, '.', ''); } elseif (ereg('^T([0-9]{4})([0-9]{4})', $part, $regs)) { /* @@ -540,7 +557,7 @@ $this->store_temp($regs[2] / 10, $decoded_metar['temp_min_max']['min24h_c'], $decoded_metar['temp_min_max']['min24h_f']); - } elseif(ereg('^P([0-9]{4})', $part, $regs)) { + } elseif (ereg('^P([0-9]{4})', $part, $regs)) { /* * Precipitation during last hour in hundredths of an inch @@ -549,10 +566,12 @@ $decoded_metar['precipitation']['in'] = -1; $decoded_metar['precipitation']['mm'] = -1; } else { - $decoded_metar['precipitation']['in'] = number_format($regs[1]/100, 2); - $decoded_metar['precipitation']['mm'] = number_format($regs[1]*0.254, 2); + $decoded_metar['precipitation']['in'] = + number_format($regs[1]/100, 2); + $decoded_metar['precipitation']['mm'] = + number_format($regs[1]*0.254, 2); } - } elseif(ereg('^6([0-9]{4})', $part, $regs)) { + } elseif (ereg('^6([0-9]{4})', $part, $regs)) { /* * Precipitation during last 3 or 6 hours in hundredths of an @@ -562,10 +581,12 @@ $decoded_metar['precipitation']['in_6h'] = -1; $decoded_metar['precipitation']['mm_6h'] = -1; } else { - $decoded_metar['precipitation']['in_6h'] = number_format($regs[1]/100, 2); - $decoded_metar['precipitation']['mm_6h'] = number_format($regs[1]*0.254, 2); + $decoded_metar['precipitation']['in_6h'] = + number_format($regs[1]/100, 2); + $decoded_metar['precipitation']['mm_6h'] = + number_format($regs[1]*0.254, 2); } - } elseif(ereg('^7([0-9]{4})', $part, $regs)) { + } elseif (ereg('^7([0-9]{4})', $part, $regs)) { /* * Precipitation during last 24 hours in hundredths of an inch. @@ -574,10 +595,12 @@ $decoded_metar['precipitation']['in_24h'] = -1; $decoded_metar['precipitation']['mm_24h'] = -1; } else { - $decoded_metar['precipitation']['in_24h'] = number_format($regs[1]/100, 2, '.', ''); - $decoded_metar['precipitation']['mm_24h'] = number_format($regs[1]*0.254, 2, '.', ''); + $decoded_metar['precipitation']['in_24h'] = + number_format($regs[1]/100, 2, '.', ''); + $decoded_metar['precipitation']['mm_24h'] = + number_format($regs[1]*0.254, 2, '.', ''); } - } elseif(ereg('^4/([0-9]{3})', $part, $regs)) { + } elseif (ereg('^4/([0-9]{3})', $part, $regs)) { /* * Snow depth in inches @@ -615,12 +638,12 @@ /* - * Compute windchill if temp < 40f and windspeed > 3 mph - */ + * Compute windchill if temp < 40f and windspeed > 3 mph + */ if (!empty($decoded_metar['temperature']['temp_f']) && - $decoded_metar['temperature']['temp_f'] <= '40' && + $decoded_metar['temperature']['temp_f'] <= 40 && !empty($decoded_metar['wind']['miles_per_hour']) && - $decoded_metar['wind']['miles_per_hour'] > '3'){ + $decoded_metar['wind']['miles_per_hour'] > 3) { $decoded_metar['windchill']['windchill_f'] = number_format(35.74 + 0.6215*$decoded_metar['temperature']['temp_f'] - 35.75*pow($decoded_metar['wind']['miles_per_hour'], 0.16) @@ -633,12 +656,13 @@ pow(($decoded_metar['wind']['miles_per_hour']/1.609), 0.16)); } - /* - * Compute heat index if temp > 70F - */ - if (!empty($decoded_metar['temperature']['temp_f']) && $decoded_metar['temperature']['temp_f'] > '70' && - !empty($decoded_metar['rel_humidity'])){ - $decoded_metar['heatindex']['heatindex_f']= + /* + * Compute heat index if temp > 70F + */ + if (!empty($decoded_metar['temperature']['temp_f']) && + $decoded_metar['temperature']['temp_f'] > 70 && + !empty($decoded_metar['rel_humidity'])) { + $decoded_metar['heatindex']['heatindex_f']= number_format(-42.379 + 2.04901523*$decoded_metar['temperature']['temp_f'] + 10.14333127*$decoded_metar['rel_humidity'] - 0.22475541*$decoded_metar['temperature']['temp_f'] @@ -660,12 +684,10 @@ $decoded_metar['heatindex']['heatindex_c']= number_format(($decoded_metar['heatindex']['heatindex_f'] - 32) / 1.8); } - /* Finally we store our decoded METAR in $this->decoded_metar so * that other methods can use it. */ - $this->decoded_metar = $decoded_metar; return $decoded_metar; } |
From: Martin G. <gim...@us...> - 2002-05-17 22:26:17
|
Update of /cvsroot/phpweather/phpweather-1.x In directory usw-pr-cvs1:/tmp/cvs-serv5080 Modified Files: ChangeLog Log Message: Updated with logentries from CVS. Index: ChangeLog =================================================================== RCS file: /cvsroot/phpweather/phpweather-1.x/ChangeLog,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -3 -r1.1.1.1 -r1.2 --- ChangeLog 7 Mar 2002 09:49:11 -0000 1.1.1.1 +++ ChangeLog 17 May 2002 22:26:14 -0000 1.2 @@ -1,3 +1,244 @@ +2002-05-17 22:13 Martin Geisler <gim...@gi...> + + * demo.php: + + Small updates. + +2002-05-17 22:12 Martin Geisler <gim...@gi...> + + * .cvsignore: + + That should come in handy... + +2002-05-17 22:12 Martin Geisler <gim...@gi...> + + * phpweather.inc: + + Removed configuration-variables. I also indented some of the code + and broke some long lines. + + I haven't tested the PostgreSQL code - it's taken from the PHP + manual so I hope it works... + +2002-05-17 22:10 Martin Geisler <gim...@gi...> + + * config-dist.inc: + + I've splitted the configuration out from phpweather.inc as + requested by Ondrej Jombik. You should save customizations in + config.php and use config-dist.php as a template. + +2002-05-17 15:52 Martin Geisler <gim...@gi...> + + * phpweather.inc: + + Fixed problem with newlines - thanks to Mark Liffiton (liffiton) + for noticing this. + +2002-04-19 18:27 Martin Geisler <gim...@gi...> + + * demo.php: + + Added a small description of the icons with a link to table.php. + +2002-04-19 18:15 Martin Geisler <gim...@gi...> + + * wap.php: + + This URL should be much better... I haven't really tested it, but + it should work. + +2002-04-19 18:14 Martin Geisler <gim...@gi...> + + * images.inc: + + The pages at gimpster.com will be removed soon, so we shouldn't + link to them any more. + +2002-04-19 18:13 Martin Geisler <gim...@gi...> + + * demo.php: + + Wow, time flies by - I've actually managed to move while developing + PHP Weather... EKAH is the closest airport to where I live now. + +2002-04-19 18:09 Martin Geisler <gim...@gi...> + + * demo.php: + + Various updates, nothing major... + +2002-04-19 18:08 Martin Geisler <gim...@gi...> + + * INSTALL, README: + + Small updates. + +2002-04-19 18:08 Martin Geisler <gim...@gi...> + + * phpweather.inc: + + We now use intval() together with round() when accessing arrays. + Some versions of PHP didn't like it when we just used round() as + round() returns a float and not an integer. + + It was Manuel Herrera <ing...@in...> tracked this bug + down, thanks a lot! + +2002-04-04 16:48 Martin Geisler <gim...@gi...> + + * locale_hu.inc: + + This is also based on the translation for 2.x, but since I don't + understand a word of Hungarian, there's a good change that this + isn't correct. + +2002-04-04 16:45 Martin Geisler <gim...@gi...> + + * locale_no.inc: + + This is based on the translation for 2.x so I think OK. + +2002-04-04 16:38 Martin Geisler <gim...@gi...> + + * locale_es.inc: + + Another update thanks to the good people at sci.lang.translation. + +2002-04-02 22:21 Martin Geisler <gim...@gi...> + + * locale_de.inc, locale_es.inc, locale_fr.inc, locale_hu.inc, + locale_it.inc, locale_mt.inc, locale_nl.inc, locale_no.inc, + locale_po_br.inc: + + Updated Portuguese (po_br) translation with a translation of + 'windchill' by João Luiz <Joa...@MB...>. I + asked for help in the newsgroup sci.lang.translation and he + replied. + + I've updated the other translations by replacing 'degrees Celsius' + with ' °C'. + +2002-03-27 10:55 Max Hammond <ma...@fl...> + + * INSTALL: + + General updates + +2002-03-26 23:51 Martin Geisler <gim...@gi...> + + * locale_cz.inc: + + Translation of 'windchill'. + +2002-03-26 10:44 Martin Geisler <gim...@gi...> + + * locale_nl.inc: + + Updated translation thanks to Raymond van Bek + <r_v...@ho...>. I've also reformated the text - I don't + know if it's worth doing, but I think it it looks better this way. + +2002-03-25 21:50 Max Hammond <ma...@fl...> + + * locale_nl.inc: + + Updated translation, thanks to Ray van Beek <r_v...@ho...> + +2002-03-25 13:08 Martin Geisler <gim...@gi...> + + * locale_it.inc: + + Correct translation of 'windchill' thanks to Carlo Gulin + (carlogulin). + +2002-03-24 20:12 Max Hammond <ma...@fl...> + + * locale_de.inc: + + Fixed windchill with a good german word, 'der Wind-chill-Index' :) + +2002-03-24 19:53 Martin Geisler <gim...@gi...> + + * AUTHORS: + + Yet another contribution - thanks! + +2002-03-24 19:52 Martin Geisler <gim...@gi...> + + * locale_cz.inc, locale_da.inc, locale_de.inc, locale_en.inc, + locale_es.inc, locale_fr.inc, locale_hu.inc, locale_it.inc, + locale_mt.inc, locale_nl.inc, locale_no.inc, locale_po_br.inc, + phpweather.inc: + + Thanks to David Kjellquist <da...@kj...> PHP Weather now + has support for windchill. + +2002-03-15 13:57 Martin Geisler <gim...@gi...> + + * icons/: temp_nodata.gif, wind_nodata.gif: + + We need these files too. Perhaps we should use something else than + the text 'No data' - something more international. I think we could + use the question-mark for the temperature, but unfortunately that's + already used with the wind... + +2002-03-10 20:22 Martin Geisler <gim...@gi...> + + * images.inc, list.php, table.php: + + This is the files that enables you to use icons in PHP Weather - + Raymond van Beek <ra...@de...> has made the hard work. + +2002-03-10 20:20 Martin Geisler <gim...@gi...> + + * icons/: 0cloud.gif, 0cloud_fog.gif, 1cloud_fog.gif, + 1cloud_heavyrain.gif, 1cloud_lightrain.gif, 1cloud_modrain.gif, + 1cloud_norain.gif, 2cloud_fog.gif, 2cloud_hail.gif, + 2cloud_heavyrain.gif, 2cloud_lightrain.gif, 2cloud_modrain.gif, + 2cloud_norain.gif, 2cloud_snow.gif, 2cloud_thunders.gif, + 3cloud_fog.gif, 3cloud_hail.gif, 3cloud_heavyrain.gif, + 3cloud_lightrain.gif, 3cloud_modrain.gif, 3cloud_norain.gif, + 3cloud_snow.gif, 3cloud_thunders.gif, 4cloud_fog.gif, + 4cloud_heavyhail.gif, 4cloud_heavyrain.gif, 4cloud_heavysnow.gif, + 4cloud_lighthail.gif, 4cloud_lightrain.gif, 4cloud_lightsnow.gif, + 4cloud_modrain.gif, 4cloud_norain.gif, 4cloud_thunders.gif, + eee.gif, n_0cloud.gif, n_0cloud_fog.gif, n_1cloud_fog.gif, + n_1cloud_heavyrain.gif, n_1cloud_lightrain.gif, + n_1cloud_modrain.gif, n_1cloud_norain.gif, n_2cloud_fog.gif, + n_2cloud_hail.gif, n_2cloud_heavyrain.gif, n_2cloud_lightrain.gif, + n_2cloud_modrain.gif, n_2cloud_norain.gif, n_2cloud_snow.gif, + n_2cloud_thunders.gif, n_3cloud_fog.gif, n_3cloud_hail.gif, + n_3cloud_heavyrain.gif, n_3cloud_lightrain.gif, + n_3cloud_modrain.gif, n_3cloud_norain.gif, n_3cloud_snow.gif, + n_3cloud_thunders.gif, ne.gif, nee.gif, nne.gif, nnn.gif, nnw.gif, + nodir.gif, nw.gif, nww.gif, se.gif, see.gif, sse.gif, sss.gif, + ssw.gif, sw.gif, sww.gif, temphigh.gif, templow.gif, vrb.gif, + www.gif: + + Icons for PHP Weather - yeah! Raymond van Beek <ra...@de...> is + the man behind this - thanks a lot! + +2002-03-07 09:49 Martin Geisler <gim...@gi...> + + * AUTHORS, COPYING, ChangeLog, INSTALL, README, cache.xml, + demo.php, locale_cz.inc, locale_da.inc, locale_de.inc, + locale_en.inc, locale_es.inc, locale_fr.inc, locale_hu.inc, + locale_it.inc, locale_mt.inc, locale_nl.inc, locale_no.inc, + locale_po_br.inc, phpweather.inc, wap.php: + + Initial revision + +2002-03-07 09:49 Martin Geisler <gim...@gi...> + + * AUTHORS, COPYING, ChangeLog, INSTALL, README, cache.xml, + demo.php, locale_cz.inc, locale_da.inc, locale_de.inc, + locale_en.inc, locale_es.inc, locale_fr.inc, locale_hu.inc, + locale_it.inc, locale_mt.inc, locale_nl.inc, locale_no.inc, + locale_po_br.inc, phpweather.inc, wap.php: + + Initial import into CVS + 2002-02-24 Martin Geisler <gim...@gi...> * phpweather.inc: Little bugfix with the current weather. |
From: Martin G. <gim...@us...> - 2002-05-17 22:13:25
|
Update of /cvsroot/phpweather/phpweather-1.x In directory usw-pr-cvs1:/tmp/cvs-serv1438 Modified Files: demo.php Log Message: Small updates. Index: demo.php =================================================================== RCS file: /cvsroot/phpweather/phpweather-1.x/demo.php,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- demo.php 19 Apr 2002 18:27:42 -0000 1.4 +++ demo.php 17 May 2002 22:13:22 -0000 1.5 @@ -37,11 +37,9 @@ <h1>Your version: <?php echo $version ?></h1> -<p>Your source was last modified on <b><?php echo $last_modified ?></b>. -Click <a href="http://sourceforge.net/projects/phpweather/">here</a> -to download the newest version from <a -href="http://www.sourceforge.net/">SourceForge</a>. I'm currently -working on the next version of <a +<p>You can download new version from <a +href="http://sourceforge.net/projects/phpweather/">this page</a>. I'm +currently working on the next version of <a href="http://www.sourceforge.net/projects/phpweather/">PHP Weather</a>. You can try it by downloading a snapshot of CVS, but as I don't make these all the time, the best way to follow the development @@ -51,19 +49,21 @@ <p>If you are having problems with <a href="http://sourceforge.net/projects/phpweather/">PHP Weather</a>, -then please upgrade to the latest version. If that doesn't help, then ask for help at the maillinglist, by sending a mail to <a +then please upgrade to the latest version. If that doesn't help, then +ask for help at the maillinglist, by sending a mail to <a href="mailto:php...@li...">php...@li...</a>. But before doing that, you <b>must</b> be subscribed to the list - go to <a href="http://lists.sourceforge.net/lists/listinfo/phpweather-devel">this page</a>.</p> -To help speed up the development, you should take a look at the latest -code from CVS. Try and see if you can figure out what is happening in -there, and then tell me what you think. Or even better: create a -user-account at <a href="http://www.sourceforge.net/">SourceForge</a>, -and mail me the username. I'll then add you to the project, so that -you can help by changing the code yourself.</p> +<p>To help speed up the development, you should take a look at the +latest code from CVS. Try and see if you can figure out what is +happening in there, and then tell me what you think. Or even better: +create a user-account at <a +href="http://www.sourceforge.net/">SourceForge</a>, and mail me the +username. I'll then add you to the project, so that you can help by +changing the code yourself.</p> <h1>A sample METAR-report</h1> |
From: Martin G. <gim...@us...> - 2002-05-17 22:12:50
|
Update of /cvsroot/phpweather/phpweather-1.x In directory usw-pr-cvs1:/tmp/cvs-serv1313 Added Files: .cvsignore Log Message: That should come in handy... --- NEW FILE --- config.inc |
From: Martin G. <gim...@us...> - 2002-05-17 22:12:15
|
Update of /cvsroot/phpweather/phpweather-1.x In directory usw-pr-cvs1:/tmp/cvs-serv850 Modified Files: phpweather.inc Log Message: Removed configuration-variables. I also indented some of the code and broke some long lines. I haven't tested the PostgreSQL code - it's taken from the PHP manual so I hope it works... Index: phpweather.inc =================================================================== RCS file: /cvsroot/phpweather/phpweather-1.x/phpweather.inc,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- phpweather.inc 17 May 2002 15:52:43 -0000 1.4 +++ phpweather.inc 17 May 2002 22:12:13 -0000 1.5 @@ -1,9 +1,10 @@ <?php -/* Copyright (c) 2000, 2001 Martin Geisler <gim...@gi...>. +/* Copyright (c) 2000-2002 Martin Geisler <gim...@gi...>. Licensed under the GPL, see the file COPYING. -Also see - http://www.gimpster.com/php/phpweather/ or +See + + http://www.phpweather.net/ and http://www.sourceforge.net/projects/phpweather for updates and further instructions on how to use PHP Weather. @@ -12,98 +13,50 @@ /* This stores the version number in the variable $version. */ $version = '1.60-CVS'; -/* Global variables. You control PHP Weather by setting these. - * - * This $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 - * database. - * - * If $useDBM is set to 1, the program will create the appropriate - * files, but the owner will be set to the user running the webserver, - * usually nobody. This will fail if that user does not have write - * permission to the current directory. - */ - -/* set to 1 to use a MySQL database */ -$useMySQL = 0; - -/* set to 1 to use a DBM database */ -$useDBM = 0; - -/* set to 1 to use a PostgreSQL database */ -$usePSQL = 0; +require('config-dist.inc'); -/* set to 1 to use a Oracle 8 database */ -$useOCI = 0; - -/* set to 1 to use XML */ -$useXML = 0; - -/* This lets you configure a proxy. If you want to use a proxy, set - 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. */ -$proxy_port = 3128; - -$dbmMetar = 0; -$dbmTimestamp = 0; +if (file_exists('config.inc')) include('config.inc'); if ($useMySQL) { - /* Here's a good place to connect to the MySQL database. You can do - this by using the code below, but if you do, then please make - sure that others can't see this file! */ - $db_hostname = 'localhost'; - $db_name = 'database_name'; - $db_username = 'your_username'; - $db_password = 'your_secret'; - - if (mysql_pconnect($db_hostname, $db_username, $db_password)) { - mysql_select_db($db_name); - } else { - echo "<p>Unable to connect to MySQL database!</p>"; - $useMySQL = 0; /* turn off so rest of program won't use */ - } - + /* Make a connection to the MySQL database: */ + if (mysql_pconnect($db_hostname, $db_username, $db_password)) { + mysql_select_db($db_name); + } else { + echo "<p>Unable to connect to MySQL database!</p>"; + $useMySQL = 0; /* turn off so rest of program won't use */ + } + } elseif ($useDBM) { + /* Open the DBM databases: */ $dbmMetar = dbmopen ("metar", "c"); $dbmTimestamp = dbmopen ("metarTimestamp", "c"); - if (!$dbmMetar || !dbmTimestamp) { + if (!$dbmMetar || !$dbmTimestamp) { echo "<p>Unable to open DBM files!</p>"; $useDBM = 0; /* turn off so rest of program won't use */ - } + } + } elseif ($usePSQL) { - $db_name = 'database_name'; - $conn = pg_Connect("", "", "", "", $db_name); + /* Make a connection to the PostgreSQL database: */ + $conn = pg_Connect("host=$db_hostname dbname=$db_name port=5432 " . + "user=$db_username password=$db_password "); if (!$conn) { echo "<p>Unable to connect to PostgreSQL database!</p>"; $usePSQL = 0; } + } elseif ($useOCI) { - $conn = OCILogon ("ced","weah","svil"); + /* Make a connection to the Oracle 8 database: */ + $conn = OCILogon ($db_username, $db_password, $db_name); if (!$conn) { echo "<p>Unable to connect to Oracle 8 database!</p>"; $useOCI = 0; } + } elseif ($useXML) { - // Configure XML + /* Read the XML file: */ $XMLFile = 'cache.xml'; - /* - The file must exist for this to work. So save the following three - lines in the file $XMLFile, and make sure that the webserver can - read and write to it: - - <?xml version="1.0" encoding="UTF-8"?> - <metardata> - </metardata> - */ - - // Check for existance of the file + // Check for existence of the file: if (!file_exists($XMLFile) || !is_readable($XMLFile) || !is_writable($XMLFile)){ @@ -111,10 +64,10 @@ $useXML = 0; // Turn off so we do not try to use later } else { $XMLMetar = array (); - // Read XML Here ParseXML ($XMLParser, $XMLFile); } + } @@ -171,22 +124,27 @@ if ($windunit == 'KT') { /* The windspeed measured in knots: */ $knots = number_format($value); - /* The windspeed measured in meters per second, rounded to one decimal place: */ + /* The windspeed measured in meters per second, rounded to one + * decimal place: */ $meterspersec = number_format($value * 0.51444, 1); - /* The windspeed measured in miles per hour, rounded to one decimal place: */ + /* The windspeed measured in miles per hour, rounded to one + * decimal place: */ $milesperhour = number_format($value * 1.1507695060844667, 1); } elseif ($windunit == 'MPS') { /* The windspeed measured in meters per second: */ $meterspersec = number_format($value); - /* The windspeed measured in knots, rounded to one decimal place: */ + /* The windspeed measured in knots, rounded to one decimal + * place: */ $knots = number_format($value / 0.51444, 1); - /* The windspeed measured in miles per hour, rounded to one decimal place: */ + /* The windspeed measured in miles per hour, rounded to one + * decimal place: */ $milesperhour = number_format($value / 0.51444 * 1.1507695060844667, 1); } elseif ($windunit == 'KMH') { /* The windspeed measured in kilometers per hour: */ $meterspersec = number_format($value * 1000 / 3600, 1); $knots = number_format($value * 1000 / 3600 / 0.51444, 1); - /* The windspeed measured in miles per hour, rounded to one decimal place: */ + /* The windspeed measured in miles per hour, rounded to one + * decimal place: */ $milesperhour = number_format($knots * 1.1507695060844667, 1); } } @@ -470,7 +428,8 @@ if (isset($metar)) { /* found station */ if ($always_use_cache || $timestamp > time() - 3600) { - /* We have asked explicit for a cached metar, or the metar is still fresh. */ + /* We have asked explicit for a cached metar, or the metar is + * still fresh. */ return $metar; } else { /* We looked in the cache, but the metar was too old. */ @@ -554,23 +513,23 @@ if ($date_unixtime < (time() - 3300)) { /* The timestamp in the metar is more than 55 minutes old. We - adjust the timestamp, so that we won't try to fetch a new - METAR within the next 5 minutes. After 5 minutes, the - timestamp will again be more than 1 hour old. */ + * adjust the timestamp, so that we won't try to fetch a new + * METAR within the next 5 minutes. After 5 minutes, the + * timestamp will again be more than 1 hour old. */ $date_unixtime = time() - 3300; } } else { /* If we end up here, it means that there was no file, we then set - the metar to and empty string. We set the date to time() - 3000 - to give the server 10 minutes of peace. If the file is - unavailable, we don't want to stress the server. */ + * the metar to and empty string. We set the date to time() - 3000 + * to give the server 10 minutes of peace. If the file is + * unavailable, we don't want to stress the server. */ $metar = ''; $date_unixtime = time() - 3000; } /* It might seam strange, that we make a local date, but MySQL - expects a local when we insert the METAR. */ + * expects a local when we insert the METAR. */ $date = date('Y/m/d H:i', $date_unixtime); if ($useMySQL) { @@ -655,7 +614,7 @@ if (ereg('RMK|TEMPO|BECMG', $part)) { /* The rest of the METAR is either a remark or temporary - information. We skip the rest of the METAR. */ + * information. We skip the rest of the METAR. */ $decoded_metar['remarks'] .= ' ' . $part; break; } elseif ($part == 'METAR') { @@ -683,7 +642,8 @@ * 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, gmdate('m'), $regs[1], gmdate('Y')); + $decoded_metar['time'] = gmmktime($regs[2], $regs[3], 0, + gmdate('m'), $regs[1], gmdate('Y')); } elseif (ereg('(AUTO|COR|RTD|CC[A-Z]|RR[A-Z])', $part, $regs)) { /* * Report Modifier: AUTO, COR, CCx or RRx @@ -814,35 +774,37 @@ $decoded_metar['runway_vis_ft'] = $prefix . number_format($regs[2]); $decoded_metar['runway_vis_meter'] = $prefix . number_format($regs[2] * 0.3048); } - } elseif (ereg('^(-|\+|VC)?(TS|SH|FZ|BL|DR|MI|BC|PR|RA|DZ|SN|SG|GR|GS|PE|IC|UP|BR|FG|FU|VA|DU|SA|HZ|PY|PO|SQ|FC|SS|DS)+$', $part)) { + } elseif (ereg('^(-|\+|VC)?(TS|SH|FZ|BL|DR|MI|BC|PR|RA|DZ|SN|SG|GR|' . + 'GS|PE|IC|UP|BR|FG|FU|VA|DU|SA|HZ|PY|PO|SQ|FC|SS|DS)+$', + $part)) { /* * Current weather-group */ if ($part[0] == '-') { - /* A light phenomenon */ - $decoded_metar['weather'] .= $strings['light']; - $part = substr($part, 1); + /* A light phenomenon */ + $decoded_metar['weather'] .= $strings['light']; + $part = substr($part, 1); } elseif ($part[0] == '+') { - /* A heavy phenomenon */ - $decoded_metar['weather'] .= $strings['heavy']; - $part = substr($part, 1); + /* A heavy phenomenon */ + $decoded_metar['weather'] .= $strings['heavy']; + $part = substr($part, 1); } elseif ($part[0].$part[1] == 'VC') { - /* Proximity Qualifier */ - $decoded_metar['weather'] .= $strings['nearby']; - $part = substr($part, 2); + /* Proximity Qualifier */ + $decoded_metar['weather'] .= $strings['nearby']; + $part = substr($part, 2); } else { /* no intensity code => moderate phenomenon */ $decoded_metar['weather'] .= $strings['moderate']; } while ($bite = substr($part, 0, 2)) { - /* Now we take the first two letters and determine what they - mean. We append this to the variable so that we gradually - build up a phrase. */ - $decoded_metar['weather'] .= $weather_array[$bite]; - /* Here we chop off the two first letters, so that we can take - a new bite at top of the while-loop. */ - $part = substr($part, 2); + /* Now we take the first two letters and determine what they + mean. We append this to the variable so that we gradually + build up a phrase. */ + $decoded_metar['weather'] .= $weather_array[$bite]; + /* Here we chop off the two first letters, so that we can take + a new bite at top of the while-loop. */ + $part = substr($part, 2); } } elseif (ereg('(SKC|CLR)', $part, $regs)) { /* @@ -852,35 +814,42 @@ */ $cloud_layers++; /* Again we have to translate the code-characters to a - meaningful string. */ - $decoded_metar['cloud_layer'. $cloud_layers.'_condition'] = $cloud_condition_array[$regs[1]]; - $decoded_metar['cloud_layer'.$cloud_layers.'_coverage'] = $cloud_coverage_array[$regs[1]]; - } elseif (ereg('^(VV|FEW|SCT|BKN|OVC)([0-9]{3})(CB|TCU)?$', $part, $regs)) { + meaningful string. */ + $decoded_metar['cloud_layer'. $cloud_layers.'_condition'] = + $cloud_condition_array[$regs[1]]; + $decoded_metar['cloud_layer'.$cloud_layers.'_coverage'] = + $cloud_coverage_array[$regs[1]]; + } elseif (ereg('^(VV|FEW|SCT|BKN|OVC)([0-9]{3})(CB|TCU)?$', + $part, $regs)) { /* We have found (another) a cloud-layer-group. There can be up - to three of these groups, so we store them as cloud_layer1, - cloud_layer2 and cloud_layer3. */ + to three of these groups, so we store them as cloud_layer1, + cloud_layer2 and cloud_layer3. */ $cloud_layers++; - /* Again we have to translate the code-characters to a meaningful string. */ + /* Again we have to translate the code-characters to a + meaningful string. */ if ($regs[1] == 'OVC') { - $clouds_str_temp = ''; + $clouds_str_temp = ''; } else { - $clouds_str_temp = $strings['clouds']; + $clouds_str_temp = $strings['clouds']; } if ($regs[3] == 'CB') { - /* cumulonimbus (CB) clouds were observed. */ - $decoded_metar['cloud_layer'.$cloud_layers.'_condition'] = - $cloud_condition_array[$regs[1]] . $strings['clouds_cb']; + /* cumulonimbus (CB) clouds were observed. */ + $decoded_metar['cloud_layer'.$cloud_layers.'_condition'] = + $cloud_condition_array[$regs[1]] . $strings['clouds_cb']; } elseif ($regs[3] == 'TCU') { - /* towering cumulus (TCU) clouds were observed. */ - $decoded_metar['cloud_layer'.$cloud_layers.'_condition'] = - $cloud_condition_array[$regs[1]] . $strings['clouds_tcu']; + /* towering cumulus (TCU) clouds were observed. */ + $decoded_metar['cloud_layer'.$cloud_layers.'_condition'] = + $cloud_condition_array[$regs[1]] . $strings['clouds_tcu']; } else { - $decoded_metar['cloud_layer'.$cloud_layers.'_condition'] = - $cloud_condition_array[$regs[1]] . $clouds_str_temp; + $decoded_metar['cloud_layer'.$cloud_layers.'_condition'] = + $cloud_condition_array[$regs[1]] . $clouds_str_temp; } - $decoded_metar['cloud_layer'.$cloud_layers.'_coverage'] = $cloud_coverage[$regs[1]]; - $decoded_metar['cloud_layer'.$cloud_layers.'_altitude_ft'] = $regs[2] *100; - $decoded_metar['cloud_layer'.$cloud_layers.'_altitude_m'] = round($regs[2] * 30.48); + $decoded_metar['cloud_layer'.$cloud_layers.'_coverage'] = + $cloud_coverage[$regs[1]]; + $decoded_metar['cloud_layer'.$cloud_layers.'_altitude_ft'] = + $regs[2] *100; + $decoded_metar['cloud_layer'.$cloud_layers.'_altitude_m'] = + round($regs[2] * 30.48); } elseif (ereg('^(M?[0-9]{2})/(M?[0-9]{2})?$', $part, $regs)) { /* * Temperature/Dew Point Group @@ -888,7 +857,8 @@ */ $decoded_metar['temp_c'] = number_format(strtr($regs[1], 'M', '-')); $decoded_metar['dew_c'] = number_format(strtr($regs[2], 'M', '-')); - /* The temperature and dew-point measured in Fahrenheit, rounded to the nearest degree. */ + /* The temperature and dew-point measured in Fahrenheit, rounded + to the nearest degree. */ $decoded_metar['temp_f'] = round(strtr($regs[1], 'M', '-') * (9/5) + 32); $decoded_metar['dew_f'] = round(strtr($regs[2], 'M', '-') * (9/5) + 32); } elseif(ereg('A([0-9]{4})', $part, $regs)) { @@ -1025,8 +995,6 @@ */ global $useMySQL, $useDBM, $usePSQL, $conn, $dbmMetar, $dbmTimestamp; - - // XML Globals I did this seperate so you could see it. global $useXML, $XMLMetar, $XMLParser, $XMLFile; if ($useMySQL) { @@ -1041,8 +1009,8 @@ $num=pg_numrows($result); if (pg_numrows($result)) { for ($i = 0; $i < $num; $i++) { - list($station) = pg_fetch_row($result, $i); - fetch_metar($station, 0); + list($station) = pg_fetch_row($result, $i); + fetch_metar($station, 0); } } } elseif ($useDBM) { @@ -1058,34 +1026,33 @@ $nrows = OCIFetchStatement($stmt,$results); if ( $nrows > 0 ) { for ($i = 0; $i < $nrows; $i++) { - list($station) = $results[i]; - fetch_metar($station, 0); + list($station) = $results[i]; + fetch_metar($station, 0); } } } elseif ($useXML) { // File Update here // Parse the XML ParseXML ($XMLParser, $XMLFile); - + reset ($XMLMetar); - while (list ($station) = each ($XMLMetar)) - { + while (list ($station) = each ($XMLMetar)) { fetch_metar ($station, 0); } } } /* - XML Handling Tools -*/ + * XML Handling Tools + */ function ParseXML($XMLParser, $XMLFile){ // Open the file for reading $FileHandle = fopen($XMLFile, "r"); - + // Suck the information out $XMLData = fread($FileHandle, filesize($XMLFile)); - + // Close the file fclose($FileHandle); @@ -1134,8 +1101,7 @@ fwrite($FileHandle, $Head, strlen ($Head)); // Walk the stations and write them to the file - while (list ($Station, $Info) = each ($XMLMetar)) - { + while (list ($Station, $Info) = each ($XMLMetar)) { // Check for actual station value in array! if (!empty($Station)) { $CacheString = "\n\t<cache station=\"" . $Info['station'] . |
From: Martin G. <gim...@us...> - 2002-05-17 22:10:47
|
Update of /cvsroot/phpweather/phpweather-1.x In directory usw-pr-cvs1:/tmp/cvs-serv32760 Added Files: config-dist.inc Log Message: I've splitted the configuration out from phpweather.inc as requested by Ondrej Jombik. You should save customizations in config.php and use config-dist.php as a template. --- NEW FILE --- <?php /* These variables control the behavious of PHP Weather. * * You should only use this file as a template - it will be overridden * when you upgrade to a new version. You should instead make a new * 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. * 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 * database. * * If $useDBM is set to 1, the program will create the appropriate * files, but the owner will be set to the user running the webserver, * usually nobody. This will fail if that user does not have write * permission to the current directory. */ /* set to 1 to use a MySQL database */ $useMySQL = 0; /* set to 1 to use a DBM database */ $useDBM = 0; /* set to 1 to use a PostgreSQL database */ $usePSQL = 0; /* set to 1 to use a Oracle 8 database */ $useOCI = 0; /* set to 1 to use XML */ $useXML = 0; /* If you're using a database that requires you to log on, then set * the following variables. Make sure to protect the 'config.php' file * so that other people cannot read your password! */ $db_hostname = 'localhost'; $db_name = 'database_name'; $db_username = 'your_username'; $db_password = 'your_secret'; /* This lets you configure a proxy. If you want to use a proxy, set 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. */ $proxy_port = 3128; ?> |
From: Martin G. <gim...@us...> - 2002-05-17 16:21:52
|
Update of /cvsroot/phpweather/phpweather/output In directory usw-pr-cvs1:/tmp/cvs-serv30495 Modified Files: pw_text_da.php Log Message: Updated with translation of 'feelslike'. Index: pw_text_da.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/output/pw_text_da.php,v retrieving revision 1.6 retrieving revision 1.7 diff -u -3 -r1.6 -r1.7 --- pw_text_da.php 16 May 2002 20:02:35 -0000 1.6 +++ pw_text_da.php 17 May 2002 16:21:49 -0000 1.7 @@ -96,7 +96,7 @@ $this->strings['hPa'] = ' hPa'; $this->strings['inHg'] = ' inHg'; $this->strings['rel_humidity'] = 'Den relative luftfugtigheden var '; - $this->strings['feelslike'] = 'The Temperature feels like '; + $this->strings['feelslike'] = 'Temperaturen vil føles som '; $this->strings['cloud_group_beg'] = 'Der var '; $this->strings['cloud_group_end'] = '.'; $this->strings['cloud_clear'] = 'Himlen var %sskyfri%s.'; |
From: Martin G. <gim...@us...> - 2002-05-17 15:52:49
|
Update of /cvsroot/phpweather/phpweather-1.x In directory usw-pr-cvs1:/tmp/cvs-serv19910 Modified Files: phpweather.inc Log Message: Fixed problem with newlines - thanks to Mark Liffiton (liffiton) for noticing this. Index: phpweather.inc =================================================================== RCS file: /cvsroot/phpweather/phpweather-1.x/phpweather.inc,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- phpweather.inc 19 Apr 2002 18:08:20 -0000 1.3 +++ phpweather.inc 17 May 2002 15:52:43 -0000 1.4 @@ -10,8 +10,7 @@ */ /* This stores the version number in the variable $version. */ -$version = '1.60'; -$last_modified = '2002-02-05'; +$version = '1.60-CVS'; /* Global variables. You control PHP Weather by setting these. * @@ -531,10 +530,11 @@ /* Here we test to see if we actually got a METAR. */ if (is_array($file)) { - list($i, $date) = each($file); - $date = trim($date); - unset($file[0]); - $metar = trim(implode(' ', $file)); + $date = trim($file[0]); + $metar = trim($file[1]); + for ($i = 2; $i < count($file); $i++) { + $metar .= ' ' . trim($file[i]); + } /* The date is in the form 2000/10/09 14:50 UTC. This seperates the different parts. */ |
From: Martin G. <gim...@us...> - 2002-05-16 20:35:59
|
Update of /cvsroot/phpweather/phpweather/output In directory usw-pr-cvs1:/tmp/cvs-serv15909 Modified Files: pw_text_en.php Log Message: How did that happen? :-) Index: pw_text_en.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/output/pw_text_en.php,v retrieving revision 1.6 retrieving revision 1.7 diff -u -3 -r1.6 -r1.7 --- pw_text_en.php 16 May 2002 20:02:35 -0000 1.6 +++ pw_text_en.php 16 May 2002 20:35:53 -0000 1.7 @@ -120,7 +120,7 @@ $this->strings['weather'] = array( '-' => ' light', - ' ' => '- moderate -', + ' ' => ' moderate ', '+' => ' heavy ', 'VC' => ' in the vicinity', 'PR' => ' partial', |
From: Martin G. <gim...@us...> - 2002-05-16 20:02:39
|
Update of /cvsroot/phpweather/phpweather/output In directory usw-pr-cvs1:/tmp/cvs-serv22753 Modified Files: pw_text_da.php pw_text_en.php pw_text_hu.php pw_text_no.php Log Message: Made the second argument optional with these constructors as well. Index: pw_text_da.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/output/pw_text_da.php,v retrieving revision 1.5 retrieving revision 1.6 diff -u -3 -r1.5 -r1.6 --- pw_text_da.php 16 May 2002 19:44:20 -0000 1.5 +++ pw_text_da.php 16 May 2002 20:02:35 -0000 1.6 @@ -15,7 +15,7 @@ * * @param array This is just passed on to locale_common() */ - function pw_text_da($weather, $input) { + function pw_text_da($weather, $input = array()) { $this->strings['charset'] = 'ISO-8859-1'; $this->strings['no_data'] = 'Desværre! Der er ingen data for %s%s%s.'; $this->strings['list_sentences_and'] = ' og '; Index: pw_text_en.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/output/pw_text_en.php,v retrieving revision 1.5 retrieving revision 1.6 diff -u -3 -r1.5 -r1.6 --- pw_text_en.php 16 May 2002 19:44:20 -0000 1.5 +++ pw_text_en.php 16 May 2002 20:02:35 -0000 1.6 @@ -17,7 +17,7 @@ * * @param array This is just passed on to locale_common() */ - function pw_text_en($weather, $input) { + function pw_text_en($weather, $input = array()) { $this->strings['charset'] = 'ISO-8859-1'; $this->strings['no_data'] = 'Sorry! There\'s no data available for %s%s%s.'; $this->strings['list_sentences_and'] = ' and '; @@ -120,9 +120,9 @@ $this->strings['weather'] = array( '-' => ' light', - ' ' => 'moderate ', - '+' => 'heavy ', - 'VC' => ' in the vicinity', + ' ' => '- moderate -', + '+' => ' heavy ', + 'VC' => ' in the vicinity', 'PR' => ' partial', 'BC' => ' patches of', 'MI' => ' shallow', Index: pw_text_hu.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/output/pw_text_hu.php,v retrieving revision 1.10 retrieving revision 1.11 diff -u -3 -r1.10 -r1.11 --- pw_text_hu.php 16 May 2002 19:52:12 -0000 1.10 +++ pw_text_hu.php 16 May 2002 20:02:35 -0000 1.11 @@ -20,7 +20,7 @@ * @param array This is just passed on to locale_common() * Ezt a paramétert átadjuk locale_common() -nak. */ - function pw_text_hu($weather, $input) { + function pw_text_hu($weather, $input = array()) { $this->strings['charset'] = 'ISO-8859-2'; $this->strings['no_data'] = 'Sajnos nincs adat %s%s%s számára.'; $this->strings['list_sentences_and'] = ' és '; Index: pw_text_no.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/output/pw_text_no.php,v retrieving revision 1.5 retrieving revision 1.6 diff -u -3 -r1.5 -r1.6 --- pw_text_no.php 16 May 2002 19:44:21 -0000 1.5 +++ pw_text_no.php 16 May 2002 20:02:35 -0000 1.6 @@ -16,7 +16,7 @@ * * @param array This is just passed on to locale_common() */ - function pw_text_no($weather, $input) { + function pw_text_no($weather, $input = array()) { $this->strings['charset'] = 'ISO-8859-1'; $this->strings['no_data'] = 'Beklager! Det var ingen ingen data tilgjengelig for %s%s%s.'; $this->strings['list_sentences_and'] = ' og '; |
From: Mihaly G. <mis...@us...> - 2002-05-16 19:52:16
|
Update of /cvsroot/phpweather/phpweather/output In directory usw-pr-cvs1:/tmp/cvs-serv10778 Modified Files: pw_text_hu.php Log Message: Translation of '...feels like'. Index: pw_text_hu.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/output/pw_text_hu.php,v retrieving revision 1.9 retrieving revision 1.10 diff -u -3 -r1.9 -r1.10 --- pw_text_hu.php 16 May 2002 19:44:20 -0000 1.9 +++ pw_text_hu.php 16 May 2002 19:52:12 -0000 1.10 @@ -106,7 +106,7 @@ $this->strings['hPa'] = ' hPa'; $this->strings['inHg'] = ' inHg'; $this->strings['rel_humidity'] = 'A relatív páratartalom '; - $this->strings['feelslike'] = 'The temperature feels like '; + $this->strings['feelslike'] = 'A hõérzet '; $this->strings['cloud_group_beg'] = 'Az égbolton'; $this->strings['cloud_group_end'] = ' magasságban.'; $this->strings['cloud_clear'] = 'Az égbolt %sfelhõtlen%s volt.'; @@ -183,4 +183,4 @@ } } -?> \ No newline at end of file +?> |
From: Max H. <ir...@us...> - 2002-05-16 19:46:21
|
Update of /cvsroot/phpweather/phpweather/output In directory usw-pr-cvs1:/tmp/cvs-serv4133 Modified Files: pw_text.php Log Message: rats Index: pw_text.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/output/pw_text.php,v retrieving revision 1.12 retrieving revision 1.13 diff -u -3 -r1.12 -r1.13 --- pw_text.php 16 May 2002 19:44:20 -0000 1.12 +++ pw_text.php 16 May 2002 19:46:19 -0000 1.13 @@ -1064,8 +1064,8 @@ $output['feelslike'] = $this->print_pretty_feelslike($heatindex); } elseif (!in_array('windchill', $this->properties['exclude']) && !empty($windchill)) { - $windchill['feelslike_c'] = $windchill['heatindex_c']; - $windchill['feelslike_f'] = $windchill['heatindex_f']; + $windchill['feelslike_c'] = $windchill['windchill_c']; + $windchill['feelslike_f'] = $windchill['windchill_f']; $output['feelslike'] = $this->print_pretty_feelslike($windchill); } |
From: Max H. <ir...@us...> - 2002-05-16 19:44:27
|
Update of /cvsroot/phpweather/phpweather/output In directory usw-pr-cvs1:/tmp/cvs-serv3089 Modified Files: pw_text.php pw_text_da.php pw_text_en.php pw_text_hu.php pw_text_no.php Log Message: Combined windchill and heatindex into one 'feels like' - sorry translators. I think this is a better solution Index: pw_text.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/output/pw_text.php,v retrieving revision 1.11 retrieving revision 1.12 diff -u -3 -r1.11 -r1.12 --- pw_text.php 15 May 2002 22:23:26 -0000 1.11 +++ pw_text.php 16 May 2002 19:44:20 -0000 1.12 @@ -804,6 +804,17 @@ $this->properties['mark_end'] . ' °F') . '.'; return $output; } + + function print_pretty_feelslike($feelslike) { + extract($feelslike); + $output = $this->strings['feelslike'] . + $this->pref_units($this->properties['mark_begin'] . $feelslike_c . + $this->properties['mark_end'] . ' °C', + $this->properties['mark_begin'] . $feelslike_f . + $this->properties['mark_end'] . ' °F') . '.'; + return $output; + } + function print_pretty_clouds($clouds) { if (empty($clouds[0]) || $clouds[0]['condition'] == 'CLR' || @@ -1042,22 +1053,23 @@ $output['temperature'] = $this->print_pretty_temperature($temperature); } - /********************************* - * Windchill * - *********************************/ - if (!in_array('windchill', $this->properties['exclude']) && - !empty($windchill)) { - $output['windchill'] = $this->print_pretty_windchill($windchill); - } - + /**************************** - * Heatindex * + * Feelslike * ****************************/ if (!in_array('heatindex', $this->properties['exclude']) && !empty($heatindex)) { - $output['heatindex'] = $this->print_pretty_heatindex($heatindex); + $heatindex['feelslike_c'] = $heatindex['heatindex_c']; + $heatindex['feelslike_f'] = $heatindex['heatindex_f']; + $output['feelslike'] = $this->print_pretty_feelslike($heatindex); + } elseif (!in_array('windchill', $this->properties['exclude']) && + !empty($windchill)) { + $windchill['feelslike_c'] = $windchill['heatindex_c']; + $windchill['feelslike_f'] = $windchill['heatindex_f']; + $output['feelslike'] = $this->print_pretty_feelslike($windchill); } - + + /**************************** * Altimeter (pressure) * ****************************/ Index: pw_text_da.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/output/pw_text_da.php,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- pw_text_da.php 12 May 2002 15:08:24 -0000 1.4 +++ pw_text_da.php 16 May 2002 19:44:20 -0000 1.5 @@ -96,8 +96,7 @@ $this->strings['hPa'] = ' hPa'; $this->strings['inHg'] = ' inHg'; $this->strings['rel_humidity'] = 'Den relative luftfugtigheden var '; - $this->strings['windchill'] = 'Temperaturen, inklusiv afkølingsfaktoren, var '; - $this->strings['heatindex'] = 'The heat index was '; + $this->strings['feelslike'] = 'The Temperature feels like '; $this->strings['cloud_group_beg'] = 'Der var '; $this->strings['cloud_group_end'] = '.'; $this->strings['cloud_clear'] = 'Himlen var %sskyfri%s.'; Index: pw_text_en.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/output/pw_text_en.php,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- pw_text_en.php 12 May 2002 15:08:24 -0000 1.4 +++ pw_text_en.php 16 May 2002 19:44:20 -0000 1.5 @@ -98,8 +98,7 @@ $this->strings['hPa'] = ' hPa'; $this->strings['inHg'] = ' inHg'; $this->strings['rel_humidity'] = 'The relative humidity was '; - $this->strings['windchill'] = 'The temperature including windchill was '; - $this->strings['heatindex'] = 'The heat index was '; + $this->strings['feelslike'] = 'The temperature feels like '; $this->strings['cloud_group_beg'] = 'There were '; $this->strings['cloud_group_end'] = '.'; $this->strings['cloud_clear'] = 'The sky was %sclear%s.'; Index: pw_text_hu.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/output/pw_text_hu.php,v retrieving revision 1.8 retrieving revision 1.9 diff -u -3 -r1.8 -r1.9 --- pw_text_hu.php 12 May 2002 15:08:24 -0000 1.8 +++ pw_text_hu.php 16 May 2002 19:44:20 -0000 1.9 @@ -106,8 +106,7 @@ $this->strings['hPa'] = ' hPa'; $this->strings['inHg'] = ' inHg'; $this->strings['rel_humidity'] = 'A relatív páratartalom '; - $this->strings['windchill'] = 'A hõérzet '; - $this->strings['heatindex'] = 'The heat index was '; + $this->strings['feelslike'] = 'The temperature feels like '; $this->strings['cloud_group_beg'] = 'Az égbolton'; $this->strings['cloud_group_end'] = ' magasságban.'; $this->strings['cloud_clear'] = 'Az égbolt %sfelhõtlen%s volt.'; Index: pw_text_no.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/output/pw_text_no.php,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- pw_text_no.php 12 May 2002 15:08:24 -0000 1.4 +++ pw_text_no.php 16 May 2002 19:44:21 -0000 1.5 @@ -97,8 +97,7 @@ $this->strings['hPa'] = ' hPa'; $this->strings['inHg'] = ' inHg'; $this->strings['rel_humidity'] = 'Den relative fuktigheten var '; - $this->strings['windchill'] = 'Temperaturen, med vindfaktor, var '; - $this->strings['heatindex'] = 'The heat index was '; + $this->strings['feelslike'] = 'The temperature feels like '; $this->strings['cloud_group_beg'] = 'Det var '; $this->strings['cloud_group_end'] = '.'; $this->strings['cloud_clear'] = 'Himmelen var %sclear%s.'; |
From: Martin G. <gim...@us...> - 2002-05-15 22:28:03
|
Update of /cvsroot/phpweather/phpweather In directory usw-pr-cvs1:/tmp/cvs-serv7855 Removed Files: configurator.php Log Message: This file is no longer needed now that /config/make_db.php handles the creation of the necessary tables in the database. --- configurator.php DELETED --- |
From: Martin G. <gim...@us...> - 2002-05-15 22:26:53
|
Update of /cvsroot/phpweather/phpweather/config In directory usw-pr-cvs1:/tmp/cvs-serv7237 Modified Files: index.php Added Files: make_config.php make_db.php Log Message: I've moved the Configuration Builder from index.php to make_config.php and added make_db.php which can be used to (re)create the database. --- NEW FILE --- <?php error_reporting(E_ALL); /* Require a couple of validators: */ require_once('pw_validator.php'); require_once('pw_validator_ereg.php'); require_once('pw_validator_range.php'); /* Require_once some options: */ require_once('pw_option.php'); require_once('pw_option_text.php'); require_once('pw_option_select.php'); require_once('pw_option_multi_select.php'); require_once('pw_option_boolean.php'); require_once('pw_option_integer.php'); /* We want to group the options: */ require_once('pw_optiongroup.php'); /* A couple of dependencies: */ require_once('pw_dependency.php'); require_once('pw_dependency_or.php'); /* We have to strip slashes from the GPC variables. */ if (get_magic_quotes_gpc() == 1) { function recursive_stripslashes(&$array) { $keys = array_keys($array); foreach($keys as $key) { if (is_array($array[$key])) { recursive_stripslashes($array[$key]); } else { $array[$key] = stripslashes($array[$key]); } } } recursive_stripslashes($HTTP_POST_VARS); } /* Start the session. */ session_start(); /* If $options isn't registered, then we should make the variable and * register it: */ if (!session_is_registered('options')) { /* Common dependencies: */ $db_dep = new pw_dependency_or('db_type', array('mysql', 'pgsql', 'dba')); $sql_dep = new pw_dependency_or('db_type', array('mysql', 'pgsql')); $dba_dep = new pw_dependency('db_type', 'dba'); $proxy_dep = new pw_dependency('use_proxy', 'true'); $port_validator = new pw_validator_range("Sorry, '%s' is not a valid port-number " . "because is't outside the range 1-65536", 1, 65536); $port_validator_empty = new pw_validator_range("Sorry, '%s' is not a valid port-number " . "because is't outside the range 1-65536", 1, 65536, true); /* This just catches the most obvious errors. */ $table_validator = new pw_validator_ereg("Sorry, '%s' is not a valid name.", '^[^./]+$'); $icao_validator = new pw_validator_ereg("Sorry, '%s' is not a valid ICAO.", '^[a-zA-Z0-9]{4}$'); /* This just catches the most obvious errors. */ $host_validator = new pw_validator_ereg("Sorry, '%s' is not a valid hostname.", '^[^/#?~]+$'); /* Next comes all the options: */ $options['verbosity'] = new pw_option_select('verbosity', "The setting of this variable controls the amount of " . "errors, warnings, and debug-information PHP Weather " . "will print. It is suggested that you always include " . "errors in the output and perhaps also warnings.", array(), array('1' => 'Errors only', '2' => 'Warnings only', '4' => 'Debug information only', '3' => 'Errors + warnings', '5' => 'Errors + debug information', '6' => 'Warnings + debug information', '7' => 'Everything')); $options['icao'] = new pw_option_text('icao', 'This will be the default station used by PHP Weather. ' . 'You should enter a valid four-letter ICAO.', array(), $icao_validator, 'EKYT'); $options['pref_units'] = new pw_option_select('pref_units', 'You may choose to display the data in several ' . 'formats. Please choose one that fits your need.', array(), array('both_metric' => 'Metric first, then imperial', 'both_imperial' => 'Imperial first, then metric', 'only_metric' => 'Only metric', 'only_imperial' => 'Only imperial')); $options['language'] = new pw_option_select('language', 'PHP Weather can produce output in several languages ' . '- please select your default from the list.', array(), array('en' => 'English', 'da' => 'Danish', 'hu' => 'Hungarian', 'no' => 'Norwegian')); $options['offset'] = new pw_option_integer('offset', "Due to a bug in PHP, on some systems the time reported may " . "be incorrect. If you experience this, you specify the " . "offset here. For example, if your times generated are 1 " . "hour too early (so METARs appear an hour older than they " . "are), set this option to be +1.", array(), false, 0); $options['use_proxy'] = new pw_option_boolean('use_proxy', "Set this option to 'Yes' to enable support for a " . "proxy server.", array(), array('false' => 'No', 'true' => 'Yes')); $options['proxy_host'] = new pw_option_text('proxy_host', "This is the hostname of the proxy server.", array($proxy_dep), $host_validator); $options['proxy_port'] = new pw_option_integer('proxy_port', "This is the port number of the proxy server. The " . "default is what is used by the Squid proxy server. " . "Another common port number is '8080'", array($proxy_dep), $port_validator, 3128); $options['db_type'] = new pw_option_select('db_type', 'PHP Weather can use several kinds of databases.', array(), array('null' => 'No database at all', 'mysql' => 'A MySQL database', 'pgsql' => 'A PostgreSQL database', 'dba' => 'A DBA database')); $options['db_handler'] = new pw_option_select('db_handler', "If you've chosen to use a Berkeley DB style database " . "through the PHP database abstraction layer (DBA), then " . "please select the handler you would like to use.", array($dba_dep), array('dbm' => 'dbm - The oldest (original) type of ' . 'Berkeley DB style databases', 'ndbm' => 'ndbm - a newer and more flexible type.', 'gdbm' => 'gdbm - The GNU database manager', 'db2' => 'db2 - Sleepycat Softwares DB2', 'db3' => 'db3 - Sleepycat Softwares DB3')); $options['always_use_db'] = new pw_option_boolean('always_use_db', "If you set this option to 'Yes', then PHP Weather " . "will always use the data it finds in the database, " . "even if it's too old. But if the data isn't there, " . "it will still fetch new data from the Internet.", array($db_dep), array('false' => 'No', 'true' => 'Yes')); $options['cache_timeout'] = new pw_option_integer('cache_timeout', "This specifies when a METAR in the cache is " . "considered to be old. If a METAR is older than this " . "number of seconds, then an attempt is made to fetch " . "a new METAR from the web. The default value is 3600 " . "seconds (1 hour), but some stations make two " . "reports each hour, so you might want to lower this " . "number to perhaps 2400 or even 1800.", array(new pw_dependency('always_use_db', 'false'), $db_dep), false, '3600'); $options['db_pconnect'] = new pw_option_boolean('db_pconnect', "If you want to make a persistent connection to the " . "database, then set this option to 'Yes'.", array($sql_dep), array('false' => 'No', 'true' => 'Yes')); $options['db_port'] = new pw_option_integer('db_port', 'If you have to use a non-standard port when ' . 'connecting to the database, then please specify it ' . 'here. If not, then just leave this field blank.', array($sql_dep), $port_validator_empty); $options['db_hostname'] = new pw_option_text('db_hostname', 'This is the hostname that PHP Weather will use, ' . 'if you choose to use a database-backend, that ' . 'supports network connections.', array($sql_dep), $host_validator); $options['db_database'] = new pw_option_text('db_database', 'This is the name of the database that PHP Weather ' . 'should use.', array($sql_dep), $table_validator); $options['db_username'] = new pw_option_text('db_username', 'This is the username that PHP Weather will use ' . 'for accessing the database.', array($sql_dep)); $options['db_password'] = new pw_option_text('db_password', 'This is the password that PHP Weather will use when ' . 'trying to make a connection to the database. Please ' . "remember to protect the file after you've stored the " . "password in it.", array($sql_dep)); $options['db_metars'] = new pw_option_text('db_metars', 'This is the name of the table that is used ' . 'to cache the METARs.', array($db_dep), $table_validator, 'pw_metars'); $options['db_stations'] = new pw_option_text('db_stations', 'This is the name of the database/table that is used ' . 'to store the names of the stations.', array($db_dep), $table_validator, 'pw_stations'); $options['db_countries'] = new pw_option_text('db_countries', 'This is the name of the database that is used to ' . 'store the names of the countries together with ' . 'country-codes.', array($dba_dep), $table_validator, 'pw_countries'); $options['mark_begin'] = new pw_option_text('mark_begin', 'This string will be placed in front of all the ' . "changable parts of the output. If you don't want " . 'this to happen, then just use an empty string. ' . "Other good choices include <code><i></code>, <code><font " . 'color="red"></code>, etc.', array(), false, '<b>'); $options['mark_end'] = new pw_option_text('mark_end', 'This string is placed after all the changable parts. ' . 'You should make sure that it closes any tags ' . "you've opened in <code>mark_begin</code>.", array(), false, '</b>'); $options['exclude'] = new pw_option_multi_select('exclude', 'You can disable some of the output produced. If ' . "you're not interested in information about " . 'runways-visibility, then select it in this list. ' . 'You can select several options at once in Netscape ' . 'by holding down Ctrl while clicking on the option.', array(), array('time' => 'Leave out the time part', 'wind' => 'Leave out the wind part', 'runway' => 'Leave out information about runways')); /* Finally - we register all the options with the session. */ session_register('options'); } /* The options should now be ready - they might come from a restored * session, or they might just have been created. */ /* We update the options with the latest information. We have to be carefull when we do this, because we have to operate directly on the options in $options and not on a copy. */ $keys = array_keys($options); foreach ($keys as $option) { $options[$option]->update_value($HTTP_POST_VARS); } /* Grouping */ $general_group = new pw_optiongroup('general_group', 'General Options', 'This is some general options for PHP Weather.', array('verbosity', 'icao', 'pref_units', 'language', 'offset', 'use_proxy', 'proxy_host', 'proxy_port'), !empty($HTTP_POST_VARS['general_group_visible'])); $db_group = new pw_optiongroup('db_group', 'Database Options', 'These options deal with the database. PHP Weather ' . 'can use a database for caching the METARs it ' . 'retrieves. This is very nice, since it takes at ' . 'least a second or two to fetch a METAR from the ' . 'National Weather Service.', array('db_type', 'db_handler', 'db_pconnect', 'always_use_db', 'cache_timeout', 'db_hostname', 'db_port', 'db_username', 'db_password', 'db_database', 'db_metars', 'db_stations', 'db_countries'), !empty($HTTP_POST_VARS['db_group_visible'])); $rendering_group = new pw_optiongroup('rendering_group', 'Rendering Options', 'You can customize the looks of PHP Weather using these options.', array('mark_begin', 'mark_end', 'exclude'), !empty($HTTP_POST_VARS['rendering_group_visible'])); /* We can now generate a configuration file with the options selected so far: */ $timestamp = date ('dS of F, Y H:i:s'); $config = "<?php /* This is a local configuration file for PHP Weather. It was generated on the $timestamp. */\n" . $general_group->get_config() . $db_group->get_config() . $rendering_group->get_config() . "\n?>\n"; if (!empty($HTTP_POST_VARS['download'])) { header('Content-type: application/octet-stream'); header('Content-Disposition: attachment; filename="defaults.php"'); echo $config; exit(); } ?> <html> <head> <title>Configuration Builder for PHP Weather</title> <style type="text/css"> <!-- BODY { font-family: Verdana, Tahoma, Geneva, Arial, Helvetica, sans-serif; font-size: small; } DT { font-weight: bold } P { margin-top: 0.5em; margin-bottom: 0.5em; } --> </style> </head> <body> <script language="JavaScript1.2"> function update(accepted, error, value, output) { if (accepted) { document.getElementById(output).innerHTML = "<font color=\"green\">Input accepted.</font>"; } else { while ((index = error.indexOf("%s")) > -1) { error = error.substring(0, index) + value + error.substring(index+2); } document.getElementById(output).innerHTML = "<font color=\"red\">" + error + "</font>"; } } function validate(error, value, output, field) { update(field.value == value, error, field.value, output); } function validate_ereg(error, ereg, output, field) { regex = new RegExp(ereg); update(regex.test(field.value), error, field.value, output); } function validate_range(error, low, high, empty_ok, output, field) { update((empty_ok == 1 && field.value == "") || (field.value >= low && field.value <= high), error, field.value, output); } function toggle_group(id) { group = document.getElementById(id); text = document.getElementById(id + "_text"); input = document.getElementById(id + "_input"); if (group.style.display == "none") { text.innerHTML = "Hide options."; group.style.display = "block"; input.value = 1; } else { text.innerHTML = "Show options."; group.style.display = "none"; input.value = 0; } } </script> <img src="../icons/phpweather-long-white.gif" alt="PHP Weather" align="right"> <h1>Configuration Builder for PHP Weather</h1> <p>This is the Configuretor shipped with PHP Weather.</p> <p>Change the options below - when you're done, then press one of the 'Update Configuration' buttons. Depending on your choices, more options might appear. Continue to change the options until they all say <span style="color: green">Input accepted.</span></p> <form action="<? echo $PHP_SELF . '?' . SID ?>" method="POST"> <p>You can <input type="submit" name="download" value="Download the Configuration"> or <input type="reset" value="Reset Everything" onclick="document.location='reset_session.php'"></p> <dl> <?php $general_group->show(); $db_group->show(); $rendering_group->show(); ?> </dl> <p><input type="submit" value="Update options"></p> <p>This is a configuration file bases on your answers above:</p> <?php highlight_string($config); ?> <p>You should copy the above configuration to a file called <code>defaults.php</code> in the root directory of your PHP Weather installation. It's very important that the lines with <code><font color="#0000CC"><?php</font></code> and <code><font color="#0000CC">?></font></code> are the very first and very last, respectively. There should be no blank lines outside these two tags.</p> <p>You can also <input type="submit" name="download" value="Download the Configuration"> or <input type="reset" value="Reset Everything" onclick="document.location='reset_session.php'"></p> </form> </body> </html> --- NEW FILE --- <html> <head> <title>Database Builder for PHP Weather</title> <style type="text/css"> <!-- BODY { font-family: Verdana, Tahoma, Geneva, Arial, Helvetica, sans-serif; font-size: small; } DT { font-weight: bold } P { margin-top: 0.5em; margin-bottom: 0.5em; } --> </style> </head> <body> <img src="../icons/phpweather-long-white.gif" alt="PHP Weather" align="right"> <h1>Database Builder for PHP Weather</h1> <p>This is the tool you use to create the tables used by PHP Weather. PHP Weather uses the tables for several things: the lists of countries and the stations in each country is stored in two tables, and then the METARs are cached in a third table.</p> <p>If you want to use a different database than the default <code>null</code> database, then you should start by making a <code>defaults.php</code> file using the <a href="make_config.php">Configuration Builder</a>. After you've made the file and uploaded it to your webserver, then you can proceed on this page.</p> <h2>Create Tables</h2> <p>If you're installing PHP Weather for the first time, then you'll need to make the tables. <b>This will delete any tables with the same name in the database!</b></p> <p>You can also use this button to update the list of stations from <code>stations.cvs</code>. The list changes from time to time as we discover new stations and when old stations disappear. This will remove any cached METARs from the database, but they would have been removed sooner or later anyway, so this isn't a problem.</p> <form action="make_db.php" method="POST"> <input type="submit" name="do_sql" value="Create or Recreate Tables"> </form> <?php if (!empty($HTTP_POST_VARS['do_sql'])) { echo "<blockquote>\n"; define('PHPWEATHER_BASE_DIR', dirname(__FILE__) . '/..'); require_once(PHPWEATHER_BASE_DIR . '/db_layer.php'); $db = new db_layer(); if ($db->db->create_tables()) { $num_rows = 0; $num_countries = 0; echo "<p>The tables have been created. They will now be " . "filled with data, please wait...</p>\n"; flush(); $fp = fopen(PHPWEATHER_BASE_DIR . '/stations.csv', 'r'); while ($row = fgets($fp, 1024)) { $row = trim($row); if (substr($row, 0, 2) == '##' && substr($row, -2) == '##') { /* We've found a country */ $cc = substr($row, 3, 2); // The country-code. $country = substr($row, 6, -3); // The name of the country. $countries[$cc] = $country; $num_countries++; //echo "<p>Now processing stations in $country.</p>\n"; } elseif ($row[0] != '#' && $row != '') { list($icao, $name) = explode(';', $row, 2); $num_rows++; $data[$cc][$icao] = $name; } } $db->db->insert_stations($data, $countries); echo "<p>Data about <b>$num_rows</b> stations from " . "<b>$num_countries</b> countries were inserted.</p>\n"; } else { echo "<p>The was a problem with the creation of the tables!</p>\n"; } echo "</blockquote>\n"; } ?> </body> </html> Index: index.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/config/index.php,v retrieving revision 1.5 retrieving revision 1.6 diff -u -3 -r1.5 -r1.6 --- index.php 14 Apr 2002 18:27:38 -0000 1.5 +++ index.php 15 May 2002 22:26:50 -0000 1.6 @@ -1,343 +1,6 @@ -<?php - -error_reporting(E_ALL); - -/* Require a couple of validators: */ -require_once('pw_validator.php'); -require_once('pw_validator_ereg.php'); -require_once('pw_validator_range.php'); - -/* Require_once some options: */ -require_once('pw_option.php'); -require_once('pw_option_text.php'); -require_once('pw_option_select.php'); -require_once('pw_option_multi_select.php'); -require_once('pw_option_boolean.php'); -require_once('pw_option_integer.php'); - -/* We want to group the options: */ -require_once('pw_optiongroup.php'); - -/* A couple of dependencies: */ -require_once('pw_dependency.php'); -require_once('pw_dependency_or.php'); - -/* We have to strip slashes from the GPC variables. */ -if (get_magic_quotes_gpc() == 1) { - - function recursive_stripslashes(&$array) { - $keys = array_keys($array); - foreach($keys as $key) { - if (is_array($array[$key])) { - recursive_stripslashes($array[$key]); - } else { - $array[$key] = stripslashes($array[$key]); - } - } - } - - recursive_stripslashes($HTTP_POST_VARS); -} - -/* Start the session. */ -session_start(); - -/* If $options isn't registered, then we should make the variable and - * register it: */ -if (!session_is_registered('options')) { - /* Common dependencies: */ - $db_dep = new pw_dependency_or('db_type', array('mysql', 'pgsql', 'dba')); - $sql_dep = new pw_dependency_or('db_type', array('mysql', 'pgsql')); - $dba_dep = new pw_dependency('db_type', 'dba'); - $proxy_dep = new pw_dependency('use_proxy', 'true'); - - $port_validator = new pw_validator_range("Sorry, '%s' is not a valid port-number " . - "because is't outside the range 1-65536", - 1, 65536); - $port_validator_empty = new pw_validator_range("Sorry, '%s' is not a valid port-number " . - "because is't outside the range 1-65536", - 1, 65536, true); - - /* This just catches the most obvious errors. */ - $table_validator = new pw_validator_ereg("Sorry, '%s' is not a valid name.", - '^[^./]+$'); - $icao_validator = new pw_validator_ereg("Sorry, '%s' is not a valid ICAO.", - '^[a-zA-Z0-9]{4}$'); - - /* This just catches the most obvious errors. */ - $host_validator = new pw_validator_ereg("Sorry, '%s' is not a valid hostname.", - '^[^/#?~]+$'); - - /* Next comes all the options: */ - - $options['verbosity'] = - new pw_option_select('verbosity', - "The setting of this variable controls the amount of " . - "errors, warnings, and debug-information PHP Weather " . - "will print. It is suggested that you always include " . - "errors in the output and perhaps also warnings.", - array(), - array('1' => 'Errors only', - '2' => 'Warnings only', - '4' => 'Debug information only', - '3' => 'Errors + warnings', - '5' => 'Errors + debug information', - '6' => 'Warnings + debug information', - '7' => 'Everything')); - - $options['icao'] = - new pw_option_text('icao', - 'This will be the default station used by PHP Weather. ' . - 'You should enter a valid four-letter ICAO.', - array(), $icao_validator, 'EKYT'); - - $options['pref_units'] = - new pw_option_select('pref_units', - 'You may choose to display the data in several ' . - 'formats. Please choose one that fits your need.', - array(), - array('both_metric' => 'Metric first, then imperial', - 'both_imperial' => 'Imperial first, then metric', - 'only_metric' => 'Only metric', - 'only_imperial' => 'Only imperial')); - - $options['language'] = - new pw_option_select('language', - 'PHP Weather can produce output in several languages ' . - '- please select your default from the list.', - array(), - array('en' => 'English', - 'da' => 'Danish', - 'hu' => 'Hungarian', - 'no' => 'Norwegian')); - - $options['offset'] = - new pw_option_integer('offset', - "Due to a bug in PHP, on some systems the time reported may " . - "be incorrect. If you experience this, you specify the " . - "offset here. For example, if your times generated are 1 " . - "hour too early (so METARs appear an hour older than they " . - "are), set this option to be +1.", - array(), false, 0); - - $options['use_proxy'] = - new pw_option_boolean('use_proxy', - "Set this option to 'Yes' to enable support for a " . - "proxy server.", - array(), - array('false' => 'No', - 'true' => 'Yes')); - - $options['proxy_host'] = - new pw_option_text('proxy_host', - "This is the hostname of the proxy server.", - array($proxy_dep), $host_validator); - - $options['proxy_port'] = - new pw_option_integer('proxy_port', - "This is the port number of the proxy server. The " . - "default is what is used by the Squid proxy server. " . - "Another common port number is '8080'", - array($proxy_dep), $port_validator, 3128); - - $options['db_type'] = - new pw_option_select('db_type', - 'PHP Weather can use several kinds of databases.', - array(), - array('null' => 'No database at all', - 'mysql' => 'A MySQL database', - 'pgsql' => 'A PostgreSQL database', - 'dba' => 'A DBA database')); - - $options['db_handler'] = - new pw_option_select('db_handler', - "If you've chosen to use a Berkeley DB style database " . - "through the PHP database abstraction layer (DBA), then " . - "please select the handler you would like to use.", - array($dba_dep), - array('dbm' => 'dbm - The oldest (original) type of ' . - 'Berkeley DB style databases', - 'ndbm' => 'ndbm - a newer and more flexible type.', - 'gdbm' => 'gdbm - The GNU database manager', - 'db2' => 'db2 - Sleepycat Softwares DB2', - 'db3' => 'db3 - Sleepycat Softwares DB3')); - - $options['always_use_db'] = - new pw_option_boolean('always_use_db', - "If you set this option to 'Yes', then PHP Weather " . - "will always use the data it finds in the database, " . - "even if it's too old. But if the data isn't there, " . - "it will still fetch new data from the Internet.", - array($db_dep), - array('false' => 'No', 'true' => 'Yes')); - - $options['cache_timeout'] = - new pw_option_integer('cache_timeout', - "This specifies when a METAR in the cache is " . - "considered to be old. If a METAR is older than this " . - "number of seconds, then an attempt is made to fetch " . - "a new METAR from the web. The default value is 3600 " . - "seconds (1 hour), but some stations make two " . - "reports each hour, so you might want to lower this " . - "number to perhaps 2400 or even 1800.", - array(new pw_dependency('always_use_db', 'false'), $db_dep), - false, '3600'); - - $options['db_pconnect'] = - new pw_option_boolean('db_pconnect', - "If you want to make a persistent connection to the " . - "database, then set this option to 'Yes'.", - array($sql_dep), - array('false' => 'No', 'true' => 'Yes')); - - $options['db_port'] = - new pw_option_integer('db_port', - 'If you have to use a non-standard port when ' . - 'connecting to the database, then please specify it ' . - 'here. If not, then just leave this field blank.', - array($sql_dep), $port_validator_empty); - - $options['db_hostname'] = - new pw_option_text('db_hostname', - 'This is the hostname that PHP Weather will use, ' . - 'if you choose to use a database-backend, that ' . - 'supports network connections.', - array($sql_dep), $host_validator); - - $options['db_database'] = - new pw_option_text('db_database', - 'This is the name of the database that PHP Weather ' . - 'should use.', - array($sql_dep), $table_validator); - - $options['db_username'] = - new pw_option_text('db_username', - 'This is the username that PHP Weather will use ' . - 'for accessing the database.', - array($sql_dep)); - - $options['db_password'] = - new pw_option_text('db_password', - 'This is the password that PHP Weather will use when ' . - 'trying to make a connection to the database. Please ' . - "remember to protect the file after you've stored the " . - "password in it.", - array($sql_dep)); - - $options['db_metars'] = - new pw_option_text('db_metars', - 'This is the name of the table that is used ' . - 'to cache the METARs.', - array($db_dep), $table_validator, 'pw_metars'); - - $options['db_stations'] = - new pw_option_text('db_stations', - 'This is the name of the database/table that is used ' . - 'to store the names of the stations.', - array($db_dep), $table_validator, 'pw_stations'); - - $options['db_countries'] = - new pw_option_text('db_countries', - 'This is the name of the database that is used to ' . - 'store the names of the countries together with ' . - 'country-codes.', - array($dba_dep), $table_validator, 'pw_countries'); - - - $options['mark_begin'] = - new pw_option_text('mark_begin', - 'This string will be placed in front of all the ' . - "changable parts of the output. If you don't want " . - 'this to happen, then just use an empty string. ' . - "Other good choices include <code><i></code>, <code><font " . - 'color="red"></code>, etc.', - array(), false, '<b>'); - - $options['mark_end'] = - new pw_option_text('mark_end', - 'This string is placed after all the changable parts. ' . - 'You should make sure that it closes any tags ' . - "you've opened in <code>mark_begin</code>.", - array(), false, '</b>'); - - $options['exclude'] = - new pw_option_multi_select('exclude', - 'You can disable some of the output produced. If ' . - "you're not interested in information about " . - 'runways-visibility, then select it in this list. ' . - 'You can select several options at once in Netscape ' . - 'by holding down Ctrl while clicking on the option.', - array(), - array('time' => 'Leave out the time part', - 'wind' => 'Leave out the wind part', - 'runway' => 'Leave out information about runways')); - - - /* Finally - we register all the options with the session. */ - session_register('options'); -} - -/* The options should now be ready - they might come from a restored - * session, or they might just have been created. */ - -/* We update the options with the latest information. We have to be - carefull when we do this, because we have to operate directly on the - options in $options and not on a copy. */ -$keys = array_keys($options); -foreach ($keys as $option) { - $options[$option]->update_value($HTTP_POST_VARS); -} - -/* Grouping */ -$general_group = - new pw_optiongroup('general_group', 'General Options', - 'This is some general options for PHP Weather.', - array('verbosity', 'icao', 'pref_units', 'language', 'offset', - 'use_proxy', 'proxy_host', 'proxy_port'), - !empty($HTTP_POST_VARS['general_group_visible'])); - -$db_group = - new pw_optiongroup('db_group', 'Database Options', - 'These options deal with the database. PHP Weather ' . - 'can use a database for caching the METARs it ' . - 'retrieves. This is very nice, since it takes at ' . - 'least a second or two to fetch a METAR from the ' . - 'National Weather Service.', - array('db_type', 'db_handler', 'db_pconnect', 'always_use_db', - 'cache_timeout', 'db_hostname', 'db_port', - 'db_username', 'db_password', 'db_database', - 'db_metars', 'db_stations', 'db_countries'), - !empty($HTTP_POST_VARS['db_group_visible'])); - -$rendering_group = - new pw_optiongroup('rendering_group', 'Rendering Options', - 'You can customize the looks of PHP Weather using these options.', - array('mark_begin', 'mark_end', 'exclude'), - !empty($HTTP_POST_VARS['rendering_group_visible'])); - -/* We can now generate a configuration file with the options selected so far: */ - -$timestamp = date ('dS of F, Y H:i:s'); -$config = "<?php -/* This is a local configuration file for PHP Weather. - It was generated on the $timestamp. */\n" . -$general_group->get_config() . -$db_group->get_config() . -$rendering_group->get_config() . -"\n?>\n"; - -if (!empty($HTTP_POST_VARS['download'])) { - header('Content-type: application/octet-stream'); - header('Content-Disposition: attachment; filename="defaults.php"'); - echo $config; - exit(); -} - -?> - <html> <head> - <title>Configuration Builder for PHP Weather</title> + <title>Configuration of PHP Weather</title> <style type="text/css"> <!-- BODY { @@ -359,88 +22,34 @@ </head> <body> -<script language="JavaScript1.2"> -function update(accepted, error, value, output) { - if (accepted) { - document.getElementById(output).innerHTML = "<font color=\"green\">Input accepted.</font>"; - } else { - while ((index = error.indexOf("%s")) > -1) { - error = error.substring(0, index) + value + error.substring(index+2); - } - document.getElementById(output).innerHTML = "<font color=\"red\">" + error + "</font>"; - } -} - -function validate(error, value, output, field) { - update(field.value == value, error, field.value, output); -} - -function validate_ereg(error, ereg, output, field) { - regex = new RegExp(ereg); - update(regex.test(field.value), error, field.value, output); -} - -function validate_range(error, low, high, empty_ok, output, field) { - update((empty_ok == 1 && field.value == "") || - (field.value >= low && field.value <= high), - error, field.value, output); -} - -function toggle_group(id) { - group = document.getElementById(id); - text = document.getElementById(id + "_text"); - input = document.getElementById(id + "_input"); - if (group.style.display == "none") { - text.innerHTML = "Hide options."; - group.style.display = "block"; - input.value = 1; - } else { - text.innerHTML = "Show options."; - group.style.display = "none"; - input.value = 0; - } -} -</script> - -<img src="../icons/phpweather-long-white.gif" alt="PHP Weather" align="right"> -<h1>Configuration Builder for PHP Weather</h1> - -<p>This is the Configuretor shipped with PHP Weather.</p> - -<p>Change the options below - when you're done, then press one of the -'Update Configuration' buttons. Depending on your choices, more options -might appear. Continue to change the options until they all say <span style="color: green">Input accepted.</span></p> - - <form action="<? echo $PHP_SELF . '?' . SID ?>" method="POST"> - -<p>You can <input type="submit" name="download" value="Download the Configuration"> or <input type="reset" value="Reset Everything" onclick="document.location='reset_session.php'"></p> - - <dl> - <?php - - $general_group->show(); - $db_group->show(); - $rendering_group->show(); - - ?> - </dl> - - <p><input type="submit" value="Update options"></p> - - <p>This is a configuration file bases on your answers above:</p> - - <?php highlight_string($config); ?> + <h1>Configuration of PHP Weather</h1> - <p>You should copy the above configuration to a file called - <code>defaults.php</code> in the root directory of your PHP Weather - installation. It's very important that the lines with <code><font - color="#0000CC"><?php</font></code> and <code><font - color="#0000CC">?></font></code> are the very first and very last, - respectively. There should be no blank lines outside these two tags.</p> - -<p>You can also <input type="submit" name="download" value="Download the Configuration"> or <input type="reset" value="Reset Everything" onclick="document.location='reset_session.php'"></p> + <p>This is the place where you configurate PHP Weather. You'll need + to complete two steps to fully utilise PHP Weather: make a local + configuration file with information about which database to use, + and then create the database.</p> + + <p>It's save to leave these pages unprotected as they wont do + anything destructive. You cannot actually change the configuration + of PHP Weather using these pages, instead you download a new + configuration-file which you'll have to upload to the webserver + before it becomes effective. The <a href="make_db.php">Database + Builder</a> will also just recreate the existing tables - nothing + permanent will be deleted.</p> + + <dl> + <dt><a href="make_config.php">Configuration Builder</a></dt> + + <dd><p>Use this page to build a custom configuration-file for PHP + Weather.</p></dd> + + <dt><a href="make_db.php">Database Builder</a></dt> + + <dd><p>After you've made a custom configuration using the link + above, you'll need to use this page to create the database and fill + it with data.</p></dd> - </form> + </dl> </body> </html> |
From: Martin G. <gim...@us...> - 2002-05-15 22:23:29
|
Update of /cvsroot/phpweather/phpweather/output In directory usw-pr-cvs1:/tmp/cvs-serv5905/output Modified Files: pw_images.php pw_text.php Log Message: All constructors can now be called without any parameters - they all use an empty array as the default. This was removed some time ago because it didn't work in PHP3, but now that we're using PHP4 it works again. I also made an extra check in output/pw_text.php so that missing clouds no longer trigger a warning. Index: pw_images.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/output/pw_images.php,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- pw_images.php 26 Mar 2002 18:39:45 -0000 1.4 +++ pw_images.php 15 May 2002 22:23:26 -0000 1.5 @@ -226,7 +226,7 @@ var $weather = null; - function pw_images($w, $input) { + function pw_images($w, $input = array()) { $this->weather = $w; Index: pw_text.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/output/pw_text.php,v retrieving revision 1.10 retrieving revision 1.11 diff -u -3 -r1.10 -r1.11 --- pw_text.php 12 May 2002 15:08:24 -0000 1.10 +++ pw_text.php 15 May 2002 22:23:26 -0000 1.11 @@ -45,7 +45,7 @@ * @param phpweather The object with the weather. * @access public */ - function pw_text($w, $input) { + function pw_text($w, $input = array()) { $this->weather = $w; /* We call the parent constructor. */ @@ -1077,7 +1077,8 @@ /******************* * Cloudgroups * *******************/ - if (!in_array('clouds', $this->properties['exclude'])) { + if (!in_array('clouds', $this->properties['exclude']) && + !empty($clouds)) { $output['clouds'] = $this->print_pretty_clouds($clouds); } |
From: Martin G. <gim...@us...> - 2002-05-15 22:23:29
|
Update of /cvsroot/phpweather/phpweather In directory usw-pr-cvs1:/tmp/cvs-serv5905 Modified Files: base_object.php data_retrieval.php db_layer.php phpweather.php Log Message: All constructors can now be called without any parameters - they all use an empty array as the default. This was removed some time ago because it didn't work in PHP3, but now that we're using PHP4 it works again. I also made an extra check in output/pw_text.php so that missing clouds no longer trigger a warning. Index: base_object.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/base_object.php,v retrieving revision 1.12 retrieving revision 1.13 diff -u -3 -r1.12 -r1.13 --- base_object.php 20 Mar 2002 19:26:50 -0000 1.12 +++ base_object.php 15 May 2002 22:23:26 -0000 1.13 @@ -59,7 +59,7 @@ * @param $input array The initial properties of the object * @see $properties */ - function base_object($input) { + function base_object($input = array()) { include(PHPWEATHER_BASE_DIR . '/defaults-dist.php'); Index: data_retrieval.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/data_retrieval.php,v retrieving revision 1.22 retrieving revision 1.23 diff -u -3 -r1.22 -r1.23 --- data_retrieval.php 12 Apr 2002 22:10:43 -0000 1.22 +++ data_retrieval.php 15 May 2002 22:23:26 -0000 1.23 @@ -40,7 +40,7 @@ * @access private * @param array The initial properties of the object. */ - function data_retrieval($input) { + function data_retrieval($input = array()) { /* We start by calling the parent constructor. */ $this->db_layer($input); Index: db_layer.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/db_layer.php,v retrieving revision 1.12 retrieving revision 1.13 diff -u -3 -r1.12 -r1.13 --- db_layer.php 20 Mar 2002 19:26:50 -0000 1.12 +++ db_layer.php 15 May 2002 22:23:26 -0000 1.13 @@ -31,7 +31,7 @@ * * @param $input array Initial properties for the object. */ - function db_layer($input) { + function db_layer($input = array()) { /* We call the parent constructor. */ $this->base_object($input); Index: phpweather.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/phpweather.php,v retrieving revision 1.24 retrieving revision 1.25 diff -u -3 -r1.24 -r1.25 --- phpweather.php 12 May 2002 15:08:59 -0000 1.24 +++ phpweather.php 15 May 2002 22:23:26 -0000 1.25 @@ -50,7 +50,7 @@ * * @param array The initial properties of the object. */ - function metar_parser($input) { + function metar_parser($input = array()) { /* This class doesn't have any defaults, so it just calls the * parent constructor. */ |
From: Max H. <ma...@fl...> - 2002-05-12 16:47:35
|
Apparantly, it's a measure of how hot it feels to a person - it's a measu= re of temperature and humidity combined. A bit like a wind-chill in reverse,= I guess :) Max -- Quidquid latine dictum sit, altum viditur. > -----Original Message----- > From: php...@li... > [mailto:php...@li...]On Behalf > Of Gyulai Mih=E1ly > Sent: 12 May 2002 17:43 > To: php...@li... > Subject: Re: CVS: phpweather phpweather.php,1.23,1.24 > > > Max Hammond =EDrta, 2002-05-12, 08:09-kor kelt level=E9ben, ami 66 > sorb=F3l =E1llt: > > > Modified Files: > > phpweather.php > > Log Message: > > Added heat index, thanks to David Kjellquist > > What's that 'heat-index'? > > I've seen the function calculating it, and noticed it's > computed only above 70F, but I don't know how to translate it. > > -- > Mih=E1ly Gyulai http://gyulai.freeyellow.com/ > > > > _______________________________________________________________ > > Have big pipes? SourceForge.net is looking for download mirrors. We sup= ply > the hardware. You get the recognition. Email Us: bandwidth@sourceforge.= net > _______________________________________________ > PHPWeather-checkins mailing list > PHP...@li... > https://lists.sourceforge.net/lists/listinfo/phpweather-checkins > |
From: Gyulai <gy...@fb...> - 2002-05-12 16:43:39
|
Max Hammond =EDrta, 2002-05-12, 08:09-kor kelt level=E9ben, ami 66 so= rb=F3l =E1llt: > Modified Files: > =09phpweather.php=20 > Log Message: > Added heat index, thanks to David Kjellquist What's that 'heat-index'? I've seen the function calculating it, and noticed it's computed only above 70F, but I don't know how to translate it. --=20 Mih=E1ly Gyulai http://gyulai.freeyellow.com/ |
From: Max H. <ir...@us...> - 2002-05-12 15:09:32
|
Update of /cvsroot/phpweather/phpweather In directory usw-pr-cvs1:/tmp/cvs-serv31772 Modified Files: test.php Log Message: Made it work again Index: test.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/test.php,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- test.php 26 Mar 2002 18:39:45 -0000 1.3 +++ test.php 12 May 2002 15:09:30 -0000 1.4 @@ -13,16 +13,16 @@ require('pw_utilities.php'); $weather = new phpweather(array()); -$weather->set_metar('EGBE 241450Z 18030KT 140V230 9000 FEW025 M10/M15 Q1032'); +$weather->set_metar('RPLL 121400Z 13010KT 9999 FEW025 28/21 Q1011 A 29.86 NOSIG'); $language = "en"; - include(PHPWEATHER_BASE_DIR . "/output/pw_text_$language.php"); - include(PHPWEATHER_BASE_DIR . "/output/pw_images.php"); + require(PHPWEATHER_BASE_DIR . "/output/pw_text_$language.php"); + require(PHPWEATHER_BASE_DIR . "/output/pw_images.php"); $type = 'pw_text_' . $language; $text = new $type($weather, array()); -$text->print_pretty(); +echo $text->print_pretty() . "<br />\n"; $icons = new pw_images($weather, array()); echo '<img src="'.$icons->get_sky_image().'" />'; echo '<img src="'.$icons->get_winddir_image().'" />'; |
From: Max H. <ir...@us...> - 2002-05-12 15:09:01
|
Update of /cvsroot/phpweather/phpweather In directory usw-pr-cvs1:/tmp/cvs-serv31635 Modified Files: phpweather.php Log Message: Added heat index, thanks to David Kjellquist Index: phpweather.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/phpweather.php,v retrieving revision 1.23 retrieving revision 1.24 diff -u -3 -r1.23 -r1.24 --- phpweather.php 13 Apr 2002 13:23:41 -0000 1.23 +++ phpweather.php 12 May 2002 15:08:59 -0000 1.24 @@ -632,6 +632,35 @@ + 0.3965*$decoded_metar['temperature']['temp_c'] * pow(($decoded_metar['wind']['miles_per_hour']/1.609), 0.16)); } + + /* + * Compute heat index if temp > 70F + */ + if (!empty($decoded_metar['temperature']['temp_f']) && $decoded_metar['temperature']['temp_f'] > '70' && + !empty($decoded_metar['rel_humidity'])){ + $decoded_metar['heatindex']['heatindex_f']= + number_format(-42.379 + 2.04901523*$decoded_metar['temperature']['temp_f'] + + 10.14333127*$decoded_metar['rel_humidity'] + - 0.22475541*$decoded_metar['temperature']['temp_f'] + *$decoded_metar['rel_humidity'] + - 0.00683783*$decoded_metar['temperature']['temp_f'] + *$decoded_metar['temperature']['temp_f'] + - 0.05481717*$decoded_metar['rel_humidity'] + *$decoded_metar['rel_humidity'] + + 0.00122874*$decoded_metar['temperature']['temp_f'] + *$decoded_metar['temperature']['temp_f'] + *$decoded_metar['rel_humidity'] + + 0.00085282*$decoded_metar['temperature']['temp_f'] + *$decoded_metar['rel_humidity'] + *$decoded_metar['rel_humidity'] + - 1.99*pow(10,-6)*$decoded_metar['temperature']['temp_f'] + *$decoded_metar['temperature']['temp_f'] + *$decoded_metar['rel_humidity'] + *$decoded_metar['rel_humidity']); + $decoded_metar['heatindex']['heatindex_c']= + number_format(($decoded_metar['heatindex']['heatindex_f'] - 32) / 1.8); + } + /* Finally we store our decoded METAR in $this->decoded_metar so * that other methods can use it. |
From: Max H. <ir...@us...> - 2002-05-12 15:08:27
|
Update of /cvsroot/phpweather/phpweather/output In directory usw-pr-cvs1:/tmp/cvs-serv31482 Modified Files: pw_text.php pw_text_da.php pw_text_en.php pw_text_hu.php pw_text_no.php Log Message: Added heat index, thanks to David Kjellquist Index: pw_text.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/output/pw_text.php,v retrieving revision 1.9 retrieving revision 1.10 diff -u -3 -r1.9 -r1.10 --- pw_text.php 29 Mar 2002 00:38:19 -0000 1.9 +++ pw_text.php 12 May 2002 15:08:24 -0000 1.10 @@ -16,7 +16,7 @@ * @version $Id$ */ class pw_text extends base_object { - + /** * The strings used in the translation are stored here. * @@ -34,7 +34,7 @@ * @var phpweather $weather */ var $weather = null; - + /** * Constructor. * @@ -795,7 +795,15 @@ $this->properties['mark_end'] . ' °F') . '.'; return $output; } - + function print_pretty_heatindex($heatindex) { + extract($heatindex); + $output = $this->strings['heatindex'] . + $this->pref_units($this->properties['mark_begin'] . $heatindex_c . + $this->properties['mark_end'] . ' °C', + $this->properties['mark_begin'] . $heatindex_f . + $this->properties['mark_end'] . ' °F') . '.'; + return $output; + } function print_pretty_clouds($clouds) { if (empty($clouds[0]) || $clouds[0]['condition'] == 'CLR' || @@ -1043,13 +1051,21 @@ } /**************************** + * Heatindex * + ****************************/ + if (!in_array('heatindex', $this->properties['exclude']) && + !empty($heatindex)) { + $output['heatindex'] = $this->print_pretty_heatindex($heatindex); + } + + /**************************** * Altimeter (pressure) * ****************************/ if (!in_array('altimeter', $this->properties['exclude']) && !empty($altimeter)) { $output['altimeter'] = $this->print_pretty_altimeter($altimeter); } - + /************************** * Relative humidity * **************************/ @@ -1057,14 +1073,14 @@ !empty($rel_humidity)) { $output['rel_humidity'] = $this->print_pretty_rel_humidity($rel_humidity); } - + /******************* * Cloudgroups * *******************/ if (!in_array('clouds', $this->properties['exclude'])) { $output['clouds'] = $this->print_pretty_clouds($clouds); } - + /****************** * Visibility * ******************/ @@ -1072,7 +1088,7 @@ !empty($visibility)) { $output['visibility'] = $this->print_pretty_visibility($visibility); } - + /********************* * Precipitation * *********************/ @@ -1080,7 +1096,7 @@ !empty($precipitation)) { $output['precip'] = $this->print_pretty_precipitation($precipitation); } - + /******************************** * Min and max temperatures * ********************************/ @@ -1088,8 +1104,8 @@ !empty($temp_min_max)) { $output['temp_min_max'] = $this->print_pretty_temp_min_max($temp_min_max); } - - + + /************************** * Runway information * **************************/ @@ -1097,7 +1113,7 @@ !empty($runway)) { $output['runway'] = $this->print_pretty_runway($runway); } - + /*********************** * Present weather * ***********************/ @@ -1105,15 +1121,15 @@ !empty($weather)) { $output['weather'] = $this->print_pretty_weather($weather); } - + /* * This is where we make the HTML output. */ return '<!-- Generated by PHP Weather ' . $this->version . " -->\n" . implode("\n", $output); } - - + + /** * Just get the time of the last report. * @@ -1125,7 +1141,7 @@ $data = $this->weather->decode_metar(); return gmdate('H:i \U\T\C', $data['time']); } - + /** * Extract some value from the metar. * @@ -1143,8 +1159,8 @@ return $data[$index]; } } - - + + /** * Makes a short weather-report in a table. * @@ -1154,7 +1170,7 @@ function print_table() { // We use our own weather-object. $data = $this->weather->decode_metar(); - + /* This doesn't work yet... $location = $data['location']; @@ -1162,17 +1178,17 @@ $date = $this->print_pretty_time($data['time']); $wind = $this->print_pretty_wind($data['wind']); - + $temperature = $this->print_pretty_temperature($data['temperature']); $pressure = $this->print_pretty_altimeter($data['altimeter']); $humidity = $this->print_pretty_rel_humidity($data['rel_humidity']); - + if ($this->properties['orientation'] == 'vertical') { - + } else { - + echo '<table border="1">'; echo "\n <tr>\n"; echo ' <th>' . $this->strings['location'] . "</th>\n"; Index: pw_text_da.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/output/pw_text_da.php,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- pw_text_da.php 24 Mar 2002 19:18:16 -0000 1.3 +++ pw_text_da.php 12 May 2002 15:08:24 -0000 1.4 @@ -97,6 +97,7 @@ $this->strings['inHg'] = ' inHg'; $this->strings['rel_humidity'] = 'Den relative luftfugtigheden var '; $this->strings['windchill'] = 'Temperaturen, inklusiv afkølingsfaktoren, var '; + $this->strings['heatindex'] = 'The heat index was '; $this->strings['cloud_group_beg'] = 'Der var '; $this->strings['cloud_group_end'] = '.'; $this->strings['cloud_clear'] = 'Himlen var %sskyfri%s.'; Index: pw_text_en.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/output/pw_text_en.php,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- pw_text_en.php 24 Mar 2002 17:25:48 -0000 1.3 +++ pw_text_en.php 12 May 2002 15:08:24 -0000 1.4 @@ -99,6 +99,7 @@ $this->strings['inHg'] = ' inHg'; $this->strings['rel_humidity'] = 'The relative humidity was '; $this->strings['windchill'] = 'The temperature including windchill was '; + $this->strings['heatindex'] = 'The heat index was '; $this->strings['cloud_group_beg'] = 'There were '; $this->strings['cloud_group_end'] = '.'; $this->strings['cloud_clear'] = 'The sky was %sclear%s.'; Index: pw_text_hu.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/output/pw_text_hu.php,v retrieving revision 1.7 retrieving revision 1.8 diff -u -3 -r1.7 -r1.8 --- pw_text_hu.php 28 Mar 2002 15:50:14 -0000 1.7 +++ pw_text_hu.php 12 May 2002 15:08:24 -0000 1.8 @@ -107,6 +107,7 @@ $this->strings['inHg'] = ' inHg'; $this->strings['rel_humidity'] = 'A relatív páratartalom '; $this->strings['windchill'] = 'A hõérzet '; + $this->strings['heatindex'] = 'The heat index was '; $this->strings['cloud_group_beg'] = 'Az égbolton'; $this->strings['cloud_group_end'] = ' magasságban.'; $this->strings['cloud_clear'] = 'Az égbolt %sfelhõtlen%s volt.'; Index: pw_text_no.php =================================================================== RCS file: /cvsroot/phpweather/phpweather/output/pw_text_no.php,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- pw_text_no.php 26 Mar 2002 18:44:18 -0000 1.3 +++ pw_text_no.php 12 May 2002 15:08:24 -0000 1.4 @@ -98,6 +98,7 @@ $this->strings['inHg'] = ' inHg'; $this->strings['rel_humidity'] = 'Den relative fuktigheten var '; $this->strings['windchill'] = 'Temperaturen, med vindfaktor, var '; + $this->strings['heatindex'] = 'The heat index was '; $this->strings['cloud_group_beg'] = 'Det var '; $this->strings['cloud_group_end'] = '.'; $this->strings['cloud_clear'] = 'Himmelen var %sclear%s.'; |
From: Max H. <ir...@us...> - 2002-05-10 18:35:07
|
Update of /cvsroot/phpweather/phpweather In directory usw-pr-cvs1:/tmp/cvs-serv6334 Modified Files: stations.csv Log Message: Added new spanish station Index: stations.csv =================================================================== RCS file: /cvsroot/phpweather/phpweather/stations.csv,v retrieving revision 1.6 retrieving revision 1.7 diff -u -3 -r1.6 -r1.7 --- stations.csv 12 Apr 2002 21:39:51 -0000 1.6 +++ stations.csv 10 May 2002 18:35:03 -0000 1.7 @@ -1558,6 +1558,7 @@ LEMG;Malaga / Aeropuerto GEML;Melilla LEMH;Menorca / Mahon +LEMO;Moron De La Frontera LELC;Murcia / San Javier LEPA;Palma De Mallorca / Son San Juan LEPP;Pamplona / Noain |
From: Martin G. <gim...@us...> - 2002-04-19 18:27:45
|
Update of /cvsroot/phpweather/phpweather-1.x In directory usw-pr-cvs1:/tmp/cvs-serv11593 Modified Files: demo.php Log Message: Added a small description of the icons with a link to table.php. Index: demo.php =================================================================== RCS file: /cvsroot/phpweather/phpweather-1.x/demo.php,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- demo.php 19 Apr 2002 18:13:44 -0000 1.3 +++ demo.php 19 Apr 2002 18:27:42 -0000 1.4 @@ -11,6 +11,7 @@ include('locale_en.inc'); include('phpweather.inc'); +include('images.inc'); ?> @@ -34,9 +35,9 @@ for, decoding a METAR into plain-text, so you can use for something useful.</p> -<h1>Your version: <? echo $version ?></h1> +<h1>Your version: <?php echo $version ?></h1> -<p>Your source was last modified on <b><? echo $last_modified ?></b>. +<p>Your source was last modified on <b><?php echo $last_modified ?></b>. Click <a href="http://sourceforge.net/projects/phpweather/">here</a> to download the newest version from <a href="http://www.sourceforge.net/">SourceForge</a>. I'm currently @@ -71,7 +72,7 @@ <?php $metar = get_metar('EKAH'); ?> -<blockquote><code><? echo $metar ?></code></blockquote> +<blockquote><code><?php echo $metar ?></code></blockquote> <p>Not exactly a pretty sight? Well by using <a href="http://sourceforge.net/projects/phpweather/">PHP Weather</a> you @@ -81,11 +82,18 @@ pretty_print_metar($metar, 'Tirstrup, Denmark') ?> +<blockquote> +<?php $decoded_metar = process_metar($metar); ?> +<img src="<?php get_temp_image($decoded_metar) ?>" height="50" width="20" border="1"> +<img src="<?php get_winddir_image($decoded_metar) ?>" height="40" width="40" border="1"> +<img src="<?php get_sky_image($decoded_metar) ?>" height="50" width="80" border="1"> +</blockquote> + <p>Here is the same piece of text with the current weather in Honolulu, Hawaii. This time the information is presented in Spanish. First comes the raw METAR:</p> -<blockquote><code><? echo $metar = get_metar('PHNL') ?></code></blockquote> +<blockquote><code><?php echo $metar = get_metar('PHNL') ?></code></blockquote> <p>and then the pretty-printed output:</p> @@ -93,6 +101,12 @@ include('locale_es.inc'); pretty_print_metar($metar, 'Honolulu, Hawaii'); ?> +<blockquote> +<?php $decoded_metar = process_metar($metar); ?> +<img src="<?php get_temp_image($decoded_metar) ?>" height="50" width="20" border="1"> +<img src="<?php get_winddir_image($decoded_metar) ?>" height="40" width="40" border="1"> +<img src="<?php get_sky_image($decoded_metar) ?>" height="50" width="80" border="1"> +</blockquote> <p>The only thing I changed between the two pieces of code was the identifier of the weather station, and the include-file with the @@ -107,7 +121,7 @@ <form action="demo.php" method="post"> <select name="city" onChange="this.form.submit()"> -<? +<?php $cities = array( 'BGTL' => 'Thule A. B., Greenland', @@ -175,8 +189,14 @@ $metar = get_metar($city); include('locale_' . $language . '.inc'); pretty_print_metar($metar, $cities[$city]) ?> -<p>The METAR for <? echo $cities[$city] ?>, presented in <? echo $languages[$language] ?>, was:</p> -<blockquote><code><? echo $metar ?></code></blockquote> +<blockquote> +<?php $decoded_metar = process_metar($metar); ?> +<img src="<?php get_temp_image($decoded_metar) ?>" height="50" width="20" border="1"> +<img src="<?php get_winddir_image($decoded_metar) ?>" height="40" width="40" border="1"> +<img src="<?php get_sky_image($decoded_metar) ?>" height="50" width="80" border="1"> +</blockquote> +<p>The METAR for <?php echo $cities[$city] ?>, presented in <?php echo $languages[$language] ?>, was:</p> +<blockquote><code><?php echo $metar ?></code></blockquote> <h1>Using PHP Weather</h1> @@ -208,6 +228,18 @@ </font> </code> +<p>To get matching icons you'll use the functions +<code>get_temp_image($data)</code>, +<code>get_winddir_image($data)</code>, and +<code>get_sky_image($code)</code> like this:</p> + +<code><font color="#000000"> +<blockquote><br /><font color="#0000CC"><?php $decoded_metar </font><font color="#006600">= </font><font color="#0000CC">process_metar</font><font color="#006600">(</font><font color="#0000CC">$metar</font><font color="#006600">); </font><font color="#0000CC">?><br /></font><img src="<font color="#0000CC"><?php get_temp_image</font><font color="#006600">(</font><font color="#0000CC">$decoded_metar</font><font color="#006600">) </font><font color="#0000CC">?></font>" height="50" width="20" border="1">&nbsp;<br /><img src="<font color="#0000CC"><?php get_winddir_image</font><font color="#006600">(</font><font color="#0000CC">$decoded_metar</font><font color="#006600">) </font><font color="#0000CC">?></font>" height="40" width="40" border="1"><br /><img src="<font color="#0000CC"><?php get_sky_image</font><font color="#006600">(</font><font color="#0000CC">$decoded_metar</font><font color="#006600">) </font><font color="#0000CC">?></font>" height="50" width="80" border="1">&nbsp;<br /></blockquote><br /></font> +</code> + +<p>Please refer to <a href="table.php">this document</a> for more +information about how to use these functions.</p> + <p>If you wan't to see all the data in the METAR, then try the following code:</p> <code><font color="#000000"> @@ -328,7 +360,7 @@ <code>wap.php</code>-page is a smaller and more compact format than the one shown on this page. It looks like this:</p> -<pre><? pretty_print_metar_wap(get_metar('EKAH'), 'Tirstrup'); ?></pre> +<pre><?php pretty_print_metar_wap(get_metar('EKAH'), 'Tirstrup'); ?></pre> <h1>Related information</h1> |