CVS: web index.php,1.6,1.7
Brought to you by:
iridium
From: Martin G. <gim...@us...> - 2002-03-18 16:52:32
|
Update of /cvsroot/phpweather/web In directory usw-pr-cvs1:/tmp/cvs-serv4601 Modified Files: index.php Log Message: New fancy frontpage for our website. Index: index.php =================================================================== RCS file: /cvsroot/phpweather/web/index.php,v retrieving revision 1.6 retrieving revision 1.7 diff -u -3 -r1.6 -r1.7 --- index.php 4 Mar 2002 22:20:11 -0000 1.6 +++ index.php 18 Mar 2002 16:52:28 -0000 1.7 @@ -1,22 +1,132 @@ -<html> - <head> - <title>PHP Weather</title> - </head> - <body> - <a href="http://sourceforge.net/projects/phpweather/"><img - src="http://sourceforge.net/sflogo.php?group_id=23245" width="88" - height="31" border="0" alt="SourceForge Logo" align="right"></a> - - <h1>PHP Weather</h1> +<?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>. There isn't very - much here at the moment, but that should (hopefully) change over - time...</p> - - <p>For the moment, you should see <a - href="http://www.sourceforge.net/projects/phpweather/">The - SourceForge Page</a> if you're interested in downloading files.</p> + href="http://www.sourceforge.net/">SourceForge</a>. You should go <a href="http://sourceforge.net/project/showfiles.php?group_id=23245">here to download</a> files.</p> + + <p>PHP Weather helps you do this on your webpages:</p> + +<?php +$weather = new phpweather(array('db_handler' => 'ndbm', + 'db_type' => 'dba')); +$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 in ' . $weather->get_location() . ': ' . + '<img src="' . $images->get_sky_image() . + '" height="50" width="80" border="1"> ' . + '<img src="' . $images->get_winddir_image() . + '" height="40" width="40" border="1"> ' . + '<img src="' . $images->get_temp_image() . + '" height="50" width="20" border="1">'; + +echo ". 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="get"> +<input type="hidden" name="action" value="show_stations"> +'; + + make_countries_select($weather, ''); + + echo ' +<input type="submit"> +</form> +</p> +'; + +} 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="get"> +<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> +'; + +} elseif ($action == 'show_weather' && !empty($language)) { + /* A station has just been selected - we print the weather. */ + echo ' +<p> +<form action="index.php" method="get"> +<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> +'; + + 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->print_pretty(); + + echo "<p>The matching icons are:</p>\n"; + + include_once(PHPWEATHER_BASE_DIR . "/output/pw_images.php"); + + $icons = new pw_images($weather, array('icons_path' => 'phpweather/icons/')); + + echo "<blockquote>\n"; + echo '<img src="' . $icons->get_sky_image() . + '" height="50" width="80" border="1"> '; + echo '<img src="' . $icons->get_winddir_image() . + '" height="40" width="40" border="1"> '; + echo '<img src="' . $icons->get_temp_image() . + '" height="50" width="20" border="1">'; + echo "</blockquote>\n"; + + + echo "<p>The raw METAR is <code>" . $weather->get_metar() . "</code></p>\n"; + + } +} + +require_once('include/footer.php'); - </body> -</html> +?> |