2009-11-16 11:49:16 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
setlocale (LC_ALL, 'de_DE.utf8');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function website_WEATHER($station, $land, $sprache)
|
|
|
|
{
|
|
|
|
$icons_src="/";
|
|
|
|
$icons_google = "/ig/images/weather/";
|
|
|
|
|
|
|
|
$api = simplexml_load_string(utf8_encode(file_get_contents("http://www.google.com/ig/api?weather=".$station."&hl=".$sprache)));
|
|
|
|
if (!$api) {$WEATHER="FALSE"; return $WEATHER;};
|
|
|
|
#print_r($api);
|
|
|
|
#exit;
|
|
|
|
|
|
|
|
$WEATHER = array();
|
|
|
|
|
|
|
|
$WEATHER['city'] = $api->weather->forecast_information->city->attributes()->data;
|
|
|
|
$WEATHER['datum'] = $api->weather->forecast_information->forecast_date->attributes()->data;
|
|
|
|
$WEATHER['zeit'] = $api->weather->forecast_information->current_date_time->attributes()->data;
|
|
|
|
|
|
|
|
$WEATHER[0]['condition'] = $api->weather->current_conditions->condition->attributes()->data;
|
|
|
|
$WEATHER[0]['temperatur'] = $api->weather->current_conditions->temp_c->attributes()->data;
|
2009-11-16 16:01:37 +00:00
|
|
|
$WEATHER[0]['humidity'] = $api->weather->current_conditions->humidity->attributes()->data;
|
2009-11-16 11:49:16 +00:00
|
|
|
$WEATHER[0]['wind'] = $api->weather->current_conditions->wind_condition->attributes()->data;
|
|
|
|
$WEATHER[0]['icon'] = str_replace($icons_google, $icons_src, $api->weather->current_conditions->icon->attributes()->data);
|
|
|
|
|
|
|
|
$i = 1;
|
|
|
|
foreach($api->weather->forecast_conditions as $weather)
|
|
|
|
{
|
|
|
|
$WEATHER[$i]['weekday'] = $weather->day_of_week->attributes()->data;
|
|
|
|
$WEATHER[$i]['condition'] = $weather->condition->attributes()->data;
|
|
|
|
$WEATHER[$i]['low'] = $weather->low->attributes()->data;
|
|
|
|
$WEATHER[$i]['high'] = $weather->high->attributes()->data;
|
|
|
|
$WEATHER[$i]['icon'] = str_replace($icons_google, $icons_src, $weather->icon->attributes()->data);
|
|
|
|
$i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $WEATHER;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$WEATHER = website_WEATHER($weathercity, $weathercountry, $weatherlang);
|
|
|
|
if ($WEATHER=="FALSE")
|
|
|
|
{
|
|
|
|
echo "<td colspan=4 $bg2>Google-Weather-Api is not reachable.</td>";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
$city=str_replace(" ","<br>",$WEATHER['city']);
|
|
|
|
echo "<td colspan=4 $bg2><table cellspacing='1' cellpadding='0' align='center' border=0 width='100%' $bg2><tr $bg2>";
|
2009-11-16 14:21:34 +00:00
|
|
|
echo "<td $bg2><font $fontcolor3><b>".$city."</b></font></td><font $fontcolor3>";
|
2009-11-16 11:49:16 +00:00
|
|
|
if ($weatherlang=='de') {$now='Jetzt';} else $now='Now';
|
|
|
|
|
2009-11-16 14:21:34 +00:00
|
|
|
echo "<td><font $fontcolor3><b>$now: </b>";
|
2009-11-16 11:49:16 +00:00
|
|
|
echo $WEATHER[0]['condition']."<br/>\n";
|
|
|
|
|
2009-11-16 16:01:37 +00:00
|
|
|
$pos=strrpos($WEATHER[0]['humidity'],':');
|
|
|
|
$hum=substr($WEATHER[0]['humidity'],$pos+2,strlen($WEATHER[0]['humidity']));
|
2009-11-16 11:49:16 +00:00
|
|
|
|
|
|
|
echo "T/Hum: ".$WEATHER[0]['temperatur']."° / $hum<br/>\n";
|
|
|
|
echo $WEATHER[0]['wind']."<br/>\n";
|
|
|
|
echo "<img src=\"http://www.google.com/ig/images/weather".$WEATHER[0]['icon']."\" alt=\"".$WEATHER[0]['condition']."\" />\n";
|
2009-11-16 14:21:34 +00:00
|
|
|
echo "</font></td><td>";
|
2009-11-16 11:49:16 +00:00
|
|
|
|
|
|
|
for($i=1; $i<5; $i++)
|
|
|
|
{
|
2009-11-16 14:21:34 +00:00
|
|
|
echo "<b><font $fontcolor3>".$WEATHER[$i]['weekday']."</b><br/>\n";
|
2009-11-16 11:49:16 +00:00
|
|
|
echo $WEATHER[$i]['condition']."<br/>\n";
|
|
|
|
echo "min. ".$WEATHER[$i]['low']."° max. ".$WEATHER[$i]['high']."°<br/>\n";
|
|
|
|
echo "<img src=\"http://www.google.com/ig/images/weather".$WEATHER[$i]['icon']."\" alt=\"".$WEATHER[$i]['condition']."\" />\n";
|
2009-11-16 14:21:34 +00:00
|
|
|
echo "</font></td><td>";
|
2009-11-16 11:49:16 +00:00
|
|
|
}
|
|
|
|
|
2009-11-16 14:21:34 +00:00
|
|
|
echo "</font></td></tr></table></td></tr>";
|
2009-11-16 11:49:16 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
?>
|