|
// -------------------
// 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
// -------------------
print " ".$weather_chile->forecast['CITY']." "; print " ".$weather_chile->forecast['CURRENT']['TEMP']." ºF"; print " "; // Partly Cloudy $st->InstallClock(); $st->InstallClockBody(); // 16 ?> |
|---|