Viewing file: zocalo.php (5.38 KB) -rw-rw-r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<div style="height: <?php echo $alto_zolcalo; ?>; line-height:<?php echo $alto_zolcalo; ?>; vertical-align: middle;
overflow: hidden;
width: 100%;">
<div style="padding-left:5%; padding-right:5%; float:left; line-height: 20px;">
<p>
<img src="img/logo-tdf_streaming.png" width="166" height="93" alt="Logo TDF">
<br>
<?php $fecha = ucfirst(strftime("%A")).' '.strftime("%d").' de '.ucfirst(strftime("%B")).' de '.strftime("%Y");
echo $fecha; ?><br>
Tierra del Fuego - Argentina
</p>
</div>
<div style="width:75%; float:left; font-size: 30px;">
<?php
//http://openweathermap.org/weather-conditions
$api_key = 'c779ce8e86c67ec234fd3c22a1845c3e'; //user diegojaviermenendez
try {
$xml_ushuaia = new SimpleXMLElement(@file_get_contents('http://api.openweathermap.org/data/2.5/weather?q=ushuaia,argentina&mode=xml&APPID='.$api_key));
$array_ushuaia = simpleXMLToArray($xml_ushuaia);
$temp_ushuaia = (int)($array_ushuaia['temperature']['value'] - 273.15);
$clouds_ushuaia = str_replace(' ', '-', $array_ushuaia['clouds']['name']).'.png';
echo '<div style="width:35%; float:left">
<div style="float:left; padding: 25px 10px 0 0;" ><img src="weather_icons/'.$clouds_ushuaia.'" width="100" height="100"></div><div style="float:left" >'.$temp_ushuaia.'° Ushuaia</div>
</div>';
} catch (Exception $e) {
}
try {
$xml_riogrande = new SimpleXMLElement(@file_get_contents('http://api.openweathermap.org/data/2.5/weather?q=rio%20%20grande,argentina&mode=xml&APPID='.$api_key));
$array_riogrande = simpleXMLToArray($xml_riogrande);
$temp_riogrande = (int)($array_riogrande['temperature']['value'] - 273.15);
$clouds_riogrande = str_replace(' ', '-', $array_riogrande['clouds']['name']).'.png';
echo '<div style="width:35%; float:left">
<div style="float:left; padding: 25px 10px 0 0;" ><img src="weather_icons/'.$clouds_riogrande.'" width="100" height="100"></div><div style="float:left" >'.$temp_riogrande.'° Rio Grande</div>
</div>';
} catch (Exception $e) {
}
try {
$xml_tolhuin = new SimpleXMLElement(@file_get_contents('http://api.openweathermap.org/data/2.5/weather?q=tolhuin,argentina&mode=xml&APPID='.$api_key));
$array_tolhuin = simpleXMLToArray($xml_tolhuin);
$temp_tolhuin = (int)($array_tolhuin['temperature']['value'] - 273.15);
$clouds_tolhuin = str_replace(' ', '-', $array_tolhuin['clouds']['name']).'.png';
echo '<div style="width:30%; float:left">
<div style="float:left; padding: 25px 10px 0 0;" ><img src="weather_icons/'.$clouds_tolhuin.'" width="100" height="100"></div><div style="float:left" >'.$temp_tolhuin.'° Tolhuin</div>
</div>';
} catch (Exception $e) {
}
?>
</div>
</div>
<?php
function simpleXMLToArray(SimpleXMLElement $xml,$attributesKey=null,$childrenKey=null,$valueKey=null){
if($childrenKey && !is_string($childrenKey)){$childrenKey = '@children';}
if($attributesKey && !is_string($attributesKey)){$attributesKey = '@attributes';}
if($valueKey && !is_string($valueKey)){$valueKey = '@values';}
$return = array();
$name = $xml->getName();
$_value = trim((string)$xml);
if(!strlen($_value)){$_value = null;};
if($_value!==null){
if($valueKey){$return[$valueKey] = $_value;}
else{$return = $_value;}
}
$children = array();
$first = true;
foreach($xml->children() as $elementName => $child){
$value = simpleXMLToArray($child,$attributesKey, $childrenKey,$valueKey);
if(isset($children[$elementName])){
if(is_array($children[$elementName])){
if($first){
$temp = $children[$elementName];
unset($children[$elementName]);
$children[$elementName][] = $temp;
$first=false;
}
$children[$elementName][] = $value;
}else{
$children[$elementName] = array($children[$elementName],$value);
}
}
else{
$children[$elementName] = $value;
}
}
if($children){
if($childrenKey){$return[$childrenKey] = $children;}
else{$return = array_merge($return,$children);}
}
$attributes = array();
foreach($xml->attributes() as $name=>$value){
$attributes[$name] = trim($value);
}
if($attributes){
if($attributesKey){$return[$attributesKey] = $attributes;}
else{$return = array_merge($return, $attributes);}
}
return $return;
}
?>
|