ini_set("display_errors","on");
if(isset($_GET["debug"]))
{
echo weather_load();
}
function weather_load()
{
global $langID;
/*
return '
";
$wd = fopen("$URL", "r");
$wx = fread($wd, 16384);
$xml = xml2array($wx);
if(isset($_GET['debug']))
print_r($xml);
$f1 = $xml[0]["elements"][12]["elements"][5]["attributes"];
$f2 = $xml[0]["elements"][12]["elements"][6]["attributes"];
$f3 = $xml[0]["elements"][12]["elements"][7]["attributes"];
$_f1 = $f1["day"];
$_f2 = $f2["day"];
$_f3 = $f3["day"];
$return .= "
| ".$WD[$langID][$_f1]." |
".$WD[$langID][$_f2]." |
".$WD[$langID][$_f3]." |
.".png\") |
.".png\") |
.".png\") | ";
$return .= "
| ".$f1["low"]."° ".$f1["high"]."° | ";
$return .= "".$f2["low"]."° ".$f2["high"]."° | ";
$return .= "".$f3["low"]."° ".$f3["high"]."° |
";
return $return;
}
function img($code)
{
$imgs = array
(
"Thunderstorms", // 0 : Thunderstorms
"Thunderstorms", // 1 : Thunderstorms
"Thunderstorms", // 2 : Thunderstorms
"Thunderstorms", // 3 : Thunderstorms
"Thunderstorms", // 4 : Thunderstorms
"Hail", // 5 : Icy Snowy Rain ***
"Hail", // 6 : Sleet & Rain ***
"Hail", // 7 : Icy Snowy Rain (hail/rain/snow) ***
"Showers", // 8 : Icy Drizzle ***
"Showers", // 9 : Drizzle
"Rain", // 10 : Icy Rain ***
"Showers", // 11 : Light Showers ***
"Rain", // 12 : Showers ***
"Flurries", // 13 : Light Snow Flurries
"Snow", // 14 : Med Snow ***
"Ice", // 15 : Friged (Very Cold) ***
"Snow", // 16 : Normal Snow
"Thunderstorms", // 17 : Thunderstorms
"Hail", // 18 : Sleet ***
"Haze", // 19 : Dust ***
"Fog", // 20 : Fog
"Haze", // 21 : Hazy (do some mini-icon smarts here) ***
"Haze", // 22 : Smoke ***
"Wind", // 23 : Windy
"Wind", // 24 : Windy
"Ice", // 25 : Friged/Icy
"Clouds", // 26 : Cloudy (no sun/moon)
"Moon And Clouds", // 27 : Mostly Cloudy Night
"Sun And Clouds", // 28 : Mostly Cloudy Day
"Moon And Clouds", // 29 : Partially Cloudy Night
"Sun And Clouds", // 30 : Partially Cloudy Day
"Moon", // 31 : Clear Night
"Sun", // 32 : Clear Day
"Moon Few Clouds", // 33 : Tiny bit of clouds at night
"Sun Few Clouds", // 34 : Tiny bit of clouds during the day
"Thunderstorms", // 35 : Thunderstorms
"Sun", // 36 : Hot
"Sunny Thunderstorms", // 37 : Sunny Thunderstorms
"Sunny Thunderstorms", // 38 : Sunny Thunderstorms
"Sun And Rain", // 39 : Sunny Showers
"Rain", // 40 : Rain ***
"Snow", // 41 : Normal Snow (sunny)
"Snow", // 42 : Normal Snow
"Snow", // 43 : Blowing/Windy Snow (normal snow) ***
"Sun Few Clouds", // 44 : Partially Cloudy Day (N/A) ***
"Moon And Rain", // 45 : Night Rain ***
"Snow", // 46 : Night Snow ***
"Thunderstorms", // 47 : Night Thunder Storm
"Sun And Rain" // 48 : Sunny Rain ***
);
return $imgs[$code];
}
function xml2array ($xml)
{
$xmlary = array ();
if ((strlen ($xml) < 256) && is_file ($xml))
$xml = file_get_contents ($xml);
$ReElements = '/<(\w+)\s*([^\/>]*)\s*(?:\/>|>(.*?)<(\/\s*\1\s*)>)/s';
$ReAttributes = '/(\w+)=(?:"|\')([^"\']*)(:?"|\')/';
preg_match_all ($ReElements, $xml, $elements);
foreach ($elements[1] as $ie => $xx) {
$xmlary[$ie]["name"] = $elements[1][$ie];
if ( $attributes = trim($elements[2][$ie])) {
preg_match_all ($ReAttributes, $attributes, $att);
foreach ($att[1] as $ia => $xx)
// all the attributes for current element are added here
$xmlary[$ie]["attributes"][$att[1][$ia]] = $att[2][$ia];
} // if $attributes
// get text if it's combined with sub elements
$cdend = strpos($elements[3][$ie],"<");
if ($cdend > 0) {
$xmlary[$ie]["text"] = substr($elements[3][$ie],0,$cdend -1);
} // if cdend
if (preg_match ($ReElements, $elements[3][$ie])){
$xmlary[$ie]["elements"] = xml2array ($elements[3][$ie]);
}
else if (isset($elements[3][$ie])){
$xmlary[$ie]["text"] = $elements[3][$ie];
}
$xmlary[$ie]["closetag"] = $elements[4][$ie];
}//foreach ?
return $xmlary;
}
$WEATHER = weather_load();
?>