Lago d'Iseo visto dal Sassabanek

{source}
<!-- You can place html anywhere within the source tags -->


<script language="javascript" type="text/javascript">
// You can place JavaScript like this

</script>
<?php
// You can place PHP like this

?>

<object width="290" height="130"><param name="movie" value="http://www.wunderground.com/swf/pws_mini_rf_nc.swf?station=ILOMBARD361&freq=&units=metric&lang=IT" /><embed src="http://www.wunderground.com/swf/pws_mini_rf_nc.swf?station=ILOMBARD361&freq=&units=metric&lang=IT" type="application/x-shockwave-flash" width="290" height="130" /></object>

 <br/>

 

<?
//The script shows the latest temperature value from various selected personal Wunderground stations. Also, if desired, it shows today's forecast for the selected city. If you want to use Fahrenheit degrees, please change every occurrence of 'temp_c' to 'temp_f' in the code. Be careful to avoid excessive API calls: you have about 120 calls per day before breaking Wunderground Terms!
//Script by flapane.com - Latest rev. 30-Dec-14
$expiretime=30; //cache expire time in minutes
$apikey="9d7d9af8b7607af7"; //your wunderground api key - 500 calls per day maximum!
$cachename="wunder_temp.txt"; //name of the cachefile
$forecastlang="IT"; //select forecasts language using uppercase letters
$forecastcity=""; //in form of State/City in english. Leave it EMPTY if you don't want any forecasts
$number_stations="1"; //total number of PWS stations.
$station[0]="ILOMBARD361"; //wunderground station name (just click on one of the personal weather stations and it will show you their name, ie. KNYBROOK40 for Williamsburg, NYC)
//$station[1]="INAPOLIP2";
//Add another station using: $station[2]="wunderground station name";

//do not mess with the next lines!!!
if (!file_exists($cachename)) { //create the cachefile if it doesn't exist
$create = fopen($cachename, 'w');
chmod ("$cachename", 0644); //set chmod 644
fclose($create);
}

// Is the file older than $expiretime, or is the file new/empty?
$FileAge = time() - filemtime($cachename); // Calculate file age in seconds
if ($FileAge > ($expiretime * 60) || 0 == filesize($cachename))
{
$handle = fopen($cachename, 'wb'); // Now refresh the cachefile with newer content
for($i=0; $i<$number_stations; $i++){
$parsed_json[$i] = json_decode(file_get_contents("http://api.wunderground.com/api/{$apikey}/conditions/q/pws:{$station[$i]}.json"));

$pws_freshness = (($parsed_json[$i]->{'current_observation'}->{'local_epoch'})-($parsed_json[$i]->{'current_observation'}->{'observation_epoch'})); //elapsed time since PWS sent updated data
$pws_freshness_human_time = round($pws_freshness/3600, 0)." hour(s)";
if (preg_replace("/[^0-9,.]/", "", $pws_freshness_human_time) > 24)
{
$pws_freshness_human_time = round($pws_freshness/86400, 1)." day(s)";
}

if ($pws_freshness < 3600) //the PWS has been sending fresh data in the last hour
{
$temp_c[$i] = $parsed_json[$i]->{'current_observation'}->{'temp_c'}."\n"; //add a new line \n (a capo) to every value
}
else
{
$temp_c[$i] = "<span style='font-weight:normal; font-style: italic;'>(station not reporting in the last $pws_freshness_human_time)</span> ".$parsed_json[$i]->{'current_observation'}->{'temp_c'}."\n"; //add a new line \n (a capo) to every value
}
$location_wunder[$i] = $parsed_json[$i]->{'current_observation'}->{'observation_location'}->{'city'}."\n";
fwrite($handle,$temp_c[$i]); //write temps
fwrite($handle,$location_wunder[$i]); //write locations
}

if(!empty ($forecastcity)){ //do you want to show the forecast for today?
$parsed_json_forecast = json_decode(file_get_contents("http://api.wunderground.com/api/{$apikey}/forecast/lang:{$forecastlang}/q/{$forecastcity}.json"));
for($j=0; $j<2; $j++) {
$icon_url[$j] = $parsed_json_forecast->forecast->txt_forecast->forecastday[$j]->icon_url."\n";
$part_of_day[$j] = $parsed_json_forecast->forecast->txt_forecast->forecastday[$j]->title.": ".$parsed_json_forecast->forecast->txt_forecast->forecastday[$j]->fcttext_metric."\n";
fwrite($handle,$icon_url[$j]); //write url of the daily forecast
fwrite($handle,$part_of_day[$j]); //write the forecasts for both parts of the day
}
}
}

// seconds to minutes - from http://forums.digitalpoint.com
$minutes = floor($FileAge/60)."m";
$secondsleft = $FileAge%60;
$ago = "ago";
if($secondsleft<10)
$secondsleft = "0" . $secondsleft ."s";
if($secondsleft>10)
$secondsleft = $secondsleft ."s";
if($minutes>$expiretime){ //avoid weird $FileAge values if cachefile has just been refreshed
$minutes = "now";
$secondsleft = "";
$ago = "";
}

// Display most recent temperatures and their average value
$display = file($cachename, FILE_IGNORE_NEW_LINES); //ignore \n for non-reporting stations
foreach ($display as $key=>$value){
if($key % 2 == 0){
$temperature[] = $value; // EVEN (righe del file cache pari)
}else{
$location_wunder[] = $value; // ODD
}
}

for($i=0; $i<$number_stations; $i++){
$temperature_stripped[$i] = preg_replace("/[^0-9,.-]/", "", $temperature[$i]);
}

$temp_avg = (array_sum($temperature_stripped)/$number_stations); //average temperature
for($i=0; $i<$number_stations; $i++){
if($temperature[$i] == null){ //if weather station is not reporting data
$temperature[$i] = "N/A";
$temp_avg = "N/A";
}
echo "<b>".$temperature[$i]."</b>°C (".$location_wunder[$i].") | ";
}
echo "<b>".$temp_avg."</b>°C (media) | updated $minutes$secondsleft $ago<br /><br />";

// Display the forecasts ONLY if $forecastcity is not empty
if(!empty ($forecastcity)){ //do you want to show the forecast for today?
$lines = array_slice($display, -4);
echo "<p><b>Previsioni per oggi:</b><br /><img src='$lines[0]' width='50' height='50' border='0' /> $lines[1]</p>";
echo "<p><img src='$lines[2]' width='50' height='50' border='0' /> $lines[3]</p>";
}

echo "<img src='/img/wundergroundlogo.png' />"; //showing WU logo is compulsory
?>

<br/>

 

<object width="600" height="400"><param name="movie" value="http://www.wunderground.com/swf/Rapid_Fire.swf?units=metric&station=ILOMBARD361" /><embed src="http://www.wunderground.com/swf/Rapid_Fire.swf?units=metric&station=ILOMBARD361" type="application/x-shockwave-flash" width="600" height="400" /></object>

 

 

<!--

<a href="http://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID=ILOMBARD361"><img src="http://banners.wunderground.com/cgi-bin/banner/ban/wxBanner?bannertype=pws250_metric&weatherstationcount=ILOMBARD361" width="250" height="150" border="0" alt="Weather Underground PWS ILOMBARD361" /></a>

-->


 

<!--
<a href="http://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID=ILOMBARD361"><img src="http://banners.wunderground.com/cgi-bin/banner/ban/wxBanner?bannertype=wxstnsticker_metric&weatherstationcount=ILOMBARD361" height="160" width="160" border="0" alt="Weather Underground PWS ILOMBARD361" /></a>
-->


{/source}

 http://api.wunderground.com/weatherstation/WXDailyHistory.asp?ID=ILOMBARD361&format=XML

Wonder Ground Sassabanek

Wonder Ground Sassabanek - Dati Storici

 

Smartphone

 

PSW

dati sql

{source}

<?php
$link = mysqli_connect('62.149.150.228', 'Sql823218', '02wga832h2','Sql823218_1');
if (!$link) {
    die ('Non riesco a connettermi: ' . mysqli_error());
}

$db_selected = mysqli_select_db($link,'Sql823218_1');
if (!$db_selected) {
    die ("Errore nella selezione del database: " . mysqli_error());
}

echo 'connesso al db con successo';

// preparo la query
$sql = "SELECT * FROM `METEO` ORDER BY `TIMESTAMP_LOCAL` DESC LIMIT 1";

// invio la query
$result = mysqli_query($link, $sql);


/*
array('TIMESTAMP_LOCAL'=>'2015-07-22 17:47:30','TIMESTAMP_IDX'=>'2015-07-22 15:47:30','WINDIR_CODE'=>'NW','WIND_DIR'=>'315','WIND_AVE'=>'0','WIND_GUST'=>'1.36069114471','TEMP'=>'37.3','PRESSURE'=>'1013.11476053','HUM'=>'28','RAIN'=>'9.3','RAIN_RATE'=>'-0.7','TEMPINT'=>'27.3','HUMINT'=>'65','WIND_CHILL'=>'37.3','TEMP_APPARENT'=>'39.1703825803','DEW_POINT'=>'15.6917159323','UV_INDEX'=>NULL,'SOLAR_RAD'=>NULL,'WIND_DAY_MIN'=>NULL,'WIND_DAY_MAX'=>NULL,'WIND_DAY_GUST_MIN'=>NULL,'WIND_DAY_GUST_MAX'=>NULL,'TEMP_OUT_DAY_MIN'=>NULL,'TEMP_OUT_DAY_MAX'=>NULL,'TEMP_IN_DAY_MIN'=>NULL,'TEMP_IN_DAY_MAX'=>NULL,'HUM_OUT_DAY_MIN'=>NULL,'HUM_OUT_DAY_MAX'=>NULL,'HUM_IN_DAY_MIN'=>NULL,'HUM_IN_DAY_MAX'=>NULL,'PRESSURE_DAY_MIN'=>NULL,'PRESSURE_DAY_MAX'=>NULL,'WIND_DIR_AVE'=>'-45'),
*/

echo '
<table border="1">
    <tr>
        <th>TIMESTAMP_LOCAL</th>
        <th>WINDIR_CODE</th>
        <th>WIND_DIR</th>
        <th>WIND_AVE</th>
        <th>WIND_GUST</th>
        <th>WIND_DAY_MAX</th>
        <th>WIND_DAY_GUST_MAX</th>
        <th>RAIN</th>
        <th>TEMP</th>
        <th>TEMP_OUT_DAY_MAX</th>
        <th>PRESSURE</th>
        <th>HUM</th>
    </tr>';

while ($row = mysqli_fetch_assoc($result)) {
    $TIMESTAMP_LOCAL      = htmlentities($row['TIMESTAMP_LOCAL']);
    $WIND_CODE                 = htmlentities($row['WINDIR_CODE']);
    $WIND_DIR                     = htmlentities($row['WIND_DIR']).'°';
    $WIND_AVE                    = htmlentities(ROUND($row['WIND_AVE'],1)).' nodi/h';
    $WIND_GUST                 = htmlentities(ROUND($row['WIND_GUST']),1).' nodi/h';
    $WIND_DAY_MAX           =htmlentities(ROUND($row['WIND_DAY_MAX']),1).' nodi/h';
    $WIND_DAY_GUST_MAX=htmlentities(ROUND($row['WIND_DAY_GUST_MAX']),1).' nodi/h'; 
    $RAIN                              =htmlentities($row['RAIN']).'mm'; 
    $TEMP                             = htmlentities($row['TEMP']).'°';
    $TEMP_OUT_DAY_MAX   = htmlentities($row['TEMP_OUT_DAY_MAX']).'°';
    $PRESSURE                   = htmlentities(ROUND($row['PRESSURE']),0).' hpa';
    $HUM                              = htmlentities($row['HUM']).'%';
    

    echo "<tr>
            <td>$TIMESTAMP_LOCAL</td>
            <td>$WIND_CODE</td>
            <td>$WIND_DIR</td>
            <td>$WIND_AVE</td>  
            <td> $WIND_GUST</td>
            <td>$WIND_DAY_MAX</td>
            <td>$WIND_DAY_GUST_MAX</td>
            <td> $RAIN</td>  
            <td>$TEMP</td>
            <td>$TEMP_OUT_DAY_MAX</td>
            <td>$PRESSURE</td>
            <td>$HUM</td>
        </tr>";
}

echo '</table>';



// libero la memoria di PHP occupata dai record estratti con la SELECT
mysqli_free_result($result);
mysqli_close($link);
?>

 {/source}

 

 

Sassa CO.RAM S.r.l Laba Salari Selcont