|
// -------------------
// INCLUDES
// -------------------
include("class.xml.parser.php");
include("class.weather.php");
include 'inc_servertime.php';
$st = new servertime;
$st->InstallClockHead();
// -------------------
// LOGIC
// -------------------
// Create the new weather object!
// CIXX0020 = Location Code from weather.yahoo.com
// 3600 = seconds of cache lifetime (expires after that)
// C = Units in Celsius! (Option: F = Fahrenheit)
$timeout=1*60*60; // 3 hours
if (isset($_ENV["TEMP"]))
$cachedir=$_ENV["TEMP"];
else if (isset($_ENV["TMP"]))
$cachedir=$_ENV["TMP"];
else if (isset($_ENV["TMPDIR"]))
$cachedir=$_ENV["TMPDIR"];
else
// Default Cache Directory
$cachedir="/tmp";
$cachedir=str_replace('\\\\','/',$cachedir);
if (substr($cachedir,-1)!='/') $cachedir.='/';
$weather_chile = new weather("USNY0998", 1800, "F", $cachedir);
// Parse the weather object via cached
// This checks if there's an valid cache object allready. if yes
// it takes the local object data, what's much FASTER!!! if it
// is expired, it refreshes automatically from rss online!
$weather_chile->parsecached(); // => RECOMMENDED!
// allway refreshes from rss online. NOT SO FAST.
//$weather_chile->parse(); // => NOT recommended!
// -------------------
// OUTPUT
// -------------------
$st->InstallClock();
$st->InstallClockBody();
print " ".$weather_chile->forecast['CITY']." "; print " ".$weather_chile->forecast['CURRENT']['TEMP']." ºF"; print " "; for ($day=1; isset($weather_chile->forecast[$day]); $day++) { print "Tomorrow: "; //print " ".$weather_chile->forecast[$day]['DAY']." "; // Wed //print "".$weather_chile->forecast[$day]['DATE']." "; // 26 Oct 2005 print "low °F: ".$weather_chile->forecast[$day]['LOW']." / "; // 8 print "high °F: ".$weather_chile->forecast[$day]['HIGH']." "; // 19 // print "imgcode: ".$weather_chile->forecast[$day]['CODE']." "; // 29=Image for partly cloudy print " "; // Partly Cloudy } // 16 ?> |
|---|