Thread: CVS: web index.php,1.19,1.20
Brought to you by:
iridium
From: Martin G. <gim...@us...> - 2002-03-28 16:27:48
|
Update of /cvsroot/phpweather/web In directory usw-pr-cvs1:/tmp/cvs-serv4809 Modified Files: index.php Log Message: I think it's time to put this one on the frontpage. The databases are updated regularly now, although they seam to be about 30 minutes behind NWS for some strange reason that I cannot figure out. So the system with cycle files are working, it just needs to be fine tuned. Index: index.php =================================================================== RCS file: /cvsroot/phpweather/web/index.php,v retrieving revision 1.19 retrieving revision 1.20 diff -u -3 -r1.19 -r1.20 --- index.php 28 Mar 2002 14:15:29 -0000 1.19 +++ index.php 28 Mar 2002 16:16:47 -0000 1.20 @@ -1,147 +1,113 @@ <?php -require_once('include/header.php'); require_once('phpweather/phpweather.php'); require_once('phpweather/output/pw_text_en.php'); require_once('phpweather/output/pw_images.php'); require_once('phpweather/pw_utilities.php'); -?> - -<p>This is the homepage of PHP Weather at <a -href="http://www.sourceforge.net/">SourceForge</a>.</p> - -<p>If you're interested in obtaining PHP Weather, then go to the <a -href="http://sourceforge.net/project/showfiles.php?group_id=23245">download -area at SourceForge</a> for released files. If you want to download -the latest CVS code, then try our <a href="downloads/">daily CVS -snapshot</a>.</p> -<p>PHP Weather helps you do this on your webpages:</p> - -<? $weather = new phpweather(array()); -$egbe = fread(fopen('egbe.txt', 'r'),filesize('egbe.txt')); -$weather->set_metar($egbe); -$text = new pw_text_en($weather, array('mark_begin' => '<font color="blue">', - 'mark_end' => '</font>')); -$images = new pw_images($weather, array('icons_path' => 'phpweather/icons/')); - -echo '<p>Current weather for ' . $weather->get_location() . ': <br />' . - '<img src="' . $images->get_sky_image() . - '" height="50" width="80" border="1" alt="Current weather" /> ' . - '<img src="' . $images->get_winddir_image() . - '" height="40" width="40" border="1" alt="Current wind" /> ' . - '<img src="' . $images->get_temp_image() . - '" height="50" width="20" border="1" alt="Current temperature" /></p>'; - -echo "<p>A textual report looks like this:</p>\n"; - -$text->print_pretty(); - -?> -<!-- -echo "<p>Now try it yourself:</p>\n"; if (empty($action)) { /* No action - we display a form from which the user can select a country. */ - - echo ' -<p> -<form action="index.php" method="post"> -<input type="hidden" name="action" value="show_stations" /> -'; - - make_countries_select($weather, ''); - - echo ' -<input type="submit" /> -</form> -</p> -'; + + $output = '<form action="index.php" method="get">' . "\n" . + '<p><input type="hidden" name="action" value="show_stations" /> ' . + get_countries_select($weather, '') . + ' <input type="submit" />' . "</p>\n</form>\n"; } elseif ($action == 'show_stations' && !empty($cc)) { /* A country has just been selected - we make a form with all stations in that country. */ - - echo ' -<p> -<form action="index.php" method="post"> -<input type="hidden" name="action" value="show_weather" /> -'; if (empty($icao)) $icao = ''; if (empty($language)) $language = ''; - - make_countries_select($weather, $cc); - make_stations_select($weather, $cc, $icao); - make_languages_select($weather, $language); - - echo ' -<input type="submit" /> -</form> -</p> -'; + $output = '<form action="index.php" method="get">' . "\n<p>" . + '<input type="hidden" name="action" value="show_weather" /> ' . + get_countries_select($weather, $cc) . + get_stations_select($weather, $cc, $icao) . + get_languages_select($weather, $language) . + '<input type="submit" />' . "</p>\n</form>\n"; } elseif ($action == 'show_weather' && !empty($language)) { /* A station has just been selected - we print the weather. */ - echo ' -<p> -<form action="index.php" method="post"> -<input type="hidden" name="action" value="show_weather" /> -'; - - make_countries_select($weather, $cc); - make_stations_select($weather, $cc, $icao); - make_languages_select($weather, $language); - - echo ' -<input type="submit"> -</form> -</p> -'; - + $output = '<form action="index.php" method="get">' . "\n<p>" . + '<input type="hidden" name="action" value="show_weather" /> ' . + get_countries_select($weather, $cc) . + get_stations_select($weather, $cc, $icao) . + get_languages_select($weather, $language) . + '<input type="submit" />' . "</p>\n</form>\n"; + if ($cc == $old_cc) { /* We should only display the current weather is the country isn't changed */ $weather->set_icao($icao); include_once(PHPWEATHER_BASE_DIR . "/output/pw_text_$language.php"); $type = 'pw_text_' . $language; - $text = new $type($weather, array('mark_begin' => '<font color="green">', - 'mark_end' => '</font>')); - - echo "<p>This is the current weather in " . - $weather->get_location() . ":</p>\n"; + $text = new $type($weather, array()); + + include_once(PHPWEATHER_BASE_DIR . "/output/pw_images.php"); + $icons = new pw_images($weather, array('icons_path' => + 'phpweather/icons/')); - $text->print_pretty(); + $output .= '<p>This is the current weather in ' . + $weather->get_location() . ":</p>\n<blockquote>\n" . + $text->print_pretty() . "\n</blockquote>\n" . + "<p>The matching icons are:</p>\n<blockquote>\n" . + '<img src="' . $icons->get_sky_image() . + '" height="50" width="80" border="1" alt="Current weather in ' . + $weather->get_location() . '" /> ' . + '<img src="' . $icons->get_winddir_image() . + '" height="40" width="40" border="1" alt="Current wind in ' . + $weather->get_location() . '" /> ' . + '<img src="' . $icons->get_temp_image() . + '" height="50" width="20" border="1" alt="Current weather in ' . + $weather->get_location() . '" />' . + "\n</blockquote>\n" . + "<p>The raw METAR is <code>" . + $weather->get_metar() . "</code></p>\n"; + } +} - echo "<p>The matching icons are:</p>\n"; +if (!empty($text)) { + $charset = $text->get_charset(); +} +require_once('include/header.php'); - include_once(PHPWEATHER_BASE_DIR . "/output/pw_images.php"); +?> - $icons = new pw_images($weather, array('icons_path' => 'phpweather/icons/')); +<p>This is the homepage of PHP Weather at <a +href="http://www.sourceforge.net/">SourceForge</a>.</p> - echo "<blockquote>\n"; - echo '<img src="' . $icons->get_sky_image() . - '" height="50" width="80" border="1" alt="Current weather" /> '; - echo '<img src="' . $icons->get_winddir_image() . - '" height="40" width="40" border="1" alt="Current wind" /> '; - echo '<img src="' . $icons->get_temp_image() . - '" height="50" width="20" border="1" alt="Current temperature" />'; - echo "</blockquote>\n"; +<p>If you're interested in obtaining PHP Weather, then go to the <a +href="http://sourceforge.net/project/showfiles.php?group_id=23245">download +area at SourceForge</a> for released files. If you want to download +the latest CVS code, then try our <a href="downloads/">daily CVS +snapshot</a>.</p> +<p>PHP Weather helps you do this on your webpages:</p> - echo "<p>The raw METAR is <code>" . $weather->get_metar() . "</code></p>\n"; - - } -} +<?php +$weather->set_icao('EGBE'); +$text = new pw_text_en($weather, array('mark_begin' => '<font color="blue">', + 'mark_end' => '</font>')); +$images = new pw_images($weather, array('icons_path' => 'phpweather/icons/')); +?> ---> +<p>Current weather for <? echo $weather->get_location() ?>: <br /> + <img src="<? echo $images->get_sky_image() ?>" + height="50" width="80" border="1" alt="Current weather" /> + <img src="<? echo $images->get_winddir_image() ?>" + height="40" width="40" border="1" alt="Current wind" /> + <img src="<? echo $images->get_temp_image() ?>" + height="50" width="20" border="1" alt="Current temperature" /></p> -<p>Due to limitations of the SourceForge server, we can not load the most up-to-date information for all stations here. To see -PHPWeather working properly, you can go <a href="http://www.warwick.ac.uk/~msufi/phpweather" target="new">here</a>.</p> -<? +<p>A textual report looks like this:</p> -require_once('include/footer.php'); +<blockquote><? echo $text->print_pretty() ?></blockquote> -?> +<p>Now try it out for yourself:</p> + +<? echo $output ?> + +<?php require_once('include/footer.php'); ?> |