Docstoc

weather

Document Sample
weather Powered By Docstoc
					<?php /************************************************************************ *** * weather.php * ------------------* begin : Monday, December 26, 2005 * copyright : (C) 2005 MichaelLewisMusic.com Web Team * email : Francis@michaellewismusic.com * * $Id: weather.php,v 2.0.1 2006/01/31 11:53:14 Handyman Exp $ * * ************************************************************************* **/ /************************************************************************ *** * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * ************************************************************************* **/ function weather($weather_code) { global $lang; // Current Conditions $cityStart = '<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" WIDTH="100%" CLASS="module" >'; $cityEnd = '<TD colspan="3" valign="top">'; // Ten day forecast $tendayStart = '<!-- day 1 -->'; $tendayEnd = '</B><BR><DIV STYLE="padding:3px;"></DIV>'; if ($weather_code) { $fp = fopen("http://www.weather.com/outlook/recreation/boatandbeach/local/$weat her_code", "r"); socket_set_timeout($fp, 2); while (!feof($fp)) { $RetrieveFile .= fgets($fp,1024); } fclose($fp); } // Get 10 day forecast if ($weather_code) {

$fp2 = fopen("http://www.weather.com/outlook/recreation/boatandbeach/tenday/$wea ther_code", "r"); socket_set_timeout($fp2, 2); while (!feof($fp2)) { $RetrieveFile2 .= fgets($fp2,1024); } fclose($fp2); } // Get City Name $tendayData = eregi("$tendayStart(.*)$tendayEnd", $RetrieveFile2, $tendayPrint); // Acquire The Data $gotTenDay = str_replace('<TD BACKGROUND="http://image.weather.com/web/common/backgrounds/graph_backgro und_10day.jpg"', '<td', $tendayPrint[1]); // $gotTenDay = $tendayPrint[1]; // Get current Conditions $cityData = eregi("$cityStart(.*)$cityEnd", $RetrieveFile, $cityDataPrint); // Acquire The Data $gotCityName = $cityDataPrint[1]; // end Get Current conditions if ($weatherData == "") { $gotWeather = $lang['no_city_selected']; } $gotCityName = $gotCityName . "&nbsp;</td></tr></table></td></tr></table></td></tr></table></td></tr></ table></td></tr></table>"; $gotTenDay = "<table border=\"2\">" . $gotTenDay . "</td></tr></table>"; $gotWeather = $gotCityName . $gotTenDay; $gotWeather = ereg_replace("\n","",$gotWeather); //remove newlines $gotWeather = ereg_replace("\r","",$gotWeather); //remove returns $gotWeather = ereg_replace("\t","",$gotWeather); //remove tabs return $gotWeather; } ?>


				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:16
posted:12/28/2008
language:English
pages:2