} else { // Default Cache Directory $cachedir = "/tmp"; } } } $cachedir = str_replace('\\\\', '/', $cachedir); if (substr($cachedir, -1) != '/') { $cachedir .= '/'; } $weather_current = new weather($userzip, 600, "C", $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_current->parsecached(); // => RECOMMENDED! // allway refreshes from rss online. NOT SO FAST. //$weather_current->parse(); // => NOT recommended! // ------------------- // OUTPUT // ------------------- // VARIOUS $day = 0; $city_current = $weather_current->forecast['CITY']; // Santiago $temperature_current = $weather_current->forecast['CURRENT']['TEMP']; // 16 $lowtemp_current = $weather_current->forecast[$day]['LOW']; // 8 $hightemp_current = $weather_current->forecast[$day]['HIGH'];
$cachedir = $_ENV["TMPDIR"]; } else { $cachedir = "/tmp"; } } } $cachedir = str_replace('\\\\', '/', $cachedir); if (substr($cachedir, -1) != '/') { $cachedir .= '/'; } $weather_chile = new weather("CIXX0020", 3600, "C", $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 // ------------------- // VARIOUS print "<h1>Various</h1>"; print "title: " . $weather_chile->forecast['TITLE'] . "<br>"; // Yahoo! Weather - Santiago, CI print "city: " . $weather_chile->forecast['CITY'] . "<br>"; // Santiago print "sunrise: " . $weather_chile->forecast['SUNRISE'] . "<br>"; // 6:49 am print "sunset: " . $weather_chile->forecast['SUNSET'] . "<br>";
$cachedir = $_ENV["TMP"]; } else { if (isset($_ENV["TMPDIR"])) { $cachedir = $_ENV["TMPDIR"]; } else { $cachedir = "/tmp"; } } } $cachedir = str_replace('\\\\', '/', $cachedir); if (substr($cachedir, -1) != '/') { $cachedir .= '/'; } foreach ($yahooLocCodes as $locCode) { $weather = new weather($locCode, $timeout, $units, $cachedir); $weather->parsecached(); print "<tr>"; $attr = substr($locCode, 0, 2) == $country ? "style='background-color:yellow;'" : ""; print XmlCell($weather->forecast['CITY'], $attr); print XmlCell($weather->forecast['PUBDATE']); print XmlCell($weather->forecast['SUNRISE']); print XmlCell($weather->forecast['SUNSET']); @(print XmlCell($weather->forecast['CURRENT']['TEXT'])); @(print tempCell($weather->forecast['CURRENT']['TEMP'])); print tempCell($weather->forecast[0]['LOW']); print tempCell($weather->forecast[0]['HIGH']); print XmlCell($weather->forecast[0]['TEXT']); print XmlCell($weather->source); print "</tr>"; } print "\n" . "</rows>";