Pour présenter les tableaux noaa (utilisant les fichiers noaayyyymm.txt générés par wswin) j'utilise les fichiers climatom.php, climatoa.php, redirclimatoa.php et redirclimatom.php. Le fichier climatom.php est (je crois) un mix de ceux de Jackt et de Chriss avec une petite touche personnelle.
Voir ici : http://meteo-plouguerneau.fr/tableaux_043.htm
Afin d'harmoniser la présentation des tableaux avec le nouveau look de mon site (voir http://meteo-plouguerneau.fr/text2/climatom.php) j'ai utilisé des balises div et un fichier .js.
Pour le look, pas de problème...
Le seul soucis, c'est que les boutons mois précédent, mois suivant et climatologie année ne fonctionnent plus
Pourriez-vous m'aider ? Merci d'avance.
Voici le code du fichier :
Code : Tout sélectionner
<?php
################################################
#Variables définissant le mois et année ˆ partir duquel les rapporst noaaAAAMM.txt sont disponibles
################################################
$moisdebut = 10;
$anneedebut = 2006;
$yearstr=$_GET['annee'];
$monthstr=$_GET['mois'];
$today = getdate();
$disablenext = '';
$disableprev = '';
$moisdebut = $moisdebut-1;
$anneedebut = $anneedebut-1;
if ($yearstr=='') {
$yearstr = str_pad($today[year], 4, "0", STR_PAD_LEFT);
;
}
if ($monthstr=='') {
$monthstr = str_pad($today[mon], 2, "0", STR_PAD_LEFT);
}
$nextmonth = $monthstr + 1;
$nextyear = $yearstr;
if ($nextmonth == 13) {
$nextmonth='01';
$nextyear= $yearstr + 1;
}
if (($nextyear==$today[year]) && ($nextmonth > $today[mon])) {
$nextmonth = $today[mon];
$disablenext="disabled='disabled'";
}
$nextmonth = str_pad($nextmonth, 2, "0", STR_PAD_LEFT);
$prevmonth = $monthstr - 1;
$prevyear = $yearstr;
if ($prevmonth == 0) {
$prevmonth='12';
$prevyear= $yearstr - 1;
}
if (($prevyear==$anneedebut) && ($prevmonth =$moisdebut)) {
$prevmonth = '04';
$disableprev="disabled='disabled'";
}
$prevmonth = str_pad($prevmonth, 2, "0", STR_PAD_LEFT);
$fichier="noaa".$yearstr.$monthstr.".txt";
$title="Relevés du mois en cours";
echo"
<head>
<title>Climatologie mensuelle </title>
<script type='text/javascript'>
function donoaaprevmonth() {
var yearv='$prevyear'
var monthv='$prevmonth'
mypath='climatom.php?annee='+yearv+'&mois='+monthv
document.location.href=mypath
}
function donoaanextmonth() {
var yearv1='$nextyear'
var monthv1='$nextmonth'
mypath='climatom.php?annee='+yearv1+'&mois='+monthv1
document.location.href=mypath
}
function donoaayear() {
var yearv='$yearstr'
mypath='climatoa.php?annee='+yearv
document.location.href=mypath
}
<script type='text/JavaScript' src='curvycorners.js'></script>
<style type='text/css'>
.myBox {
margin: 0.5in auto;
color: #fff;
width: 864px;
padding-top: 10px;
padding-left: 0px;
padding-right: 0px;
text-align: center;
background-color: #3f557a;
border: 3px solid #3f557a;
/* Do rounding (native in Firefox and Safari) */
-webkit-border-top-left-radius: 10px;
-webkit-border-top-right-radius: 10px;
-moz-border-radius-topleft: 10px;
-moz-border-radius-topright: 10px;
}
html,body{
height: 100%;
text-align: center;
margin: 0;
}
.box_tableau {
margin: 0.5in auto;
color: #fff;
width: 844px;
padding: 10px;
text-align: center;
background-color: #e6edf7;
border: 3px solid #3f557a;
/* Do rounding (native in Firefox and Safari) */
-webkit-border-bottom-left-radius: 10px;
-webkit-border-bottom-right-radius: 10px;
-moz-border-radius-bottomleft: 10px;
-moz-border-radius-bottomright: 10px;
}
html,body{
height: 100%;
text-align: center;
margin: 0;
}
.myBox_bottom {
margin: 0.5in auto;
color: #fff;
width: 854px;
padding-left: 10px;
padding-right: 0px;
text-align: center;
background-color: #b6c7db;
border: 3px solid #3f557a;
/* Do rounding (native in Firefox and Safari) */
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
}
html,body{
height: 100%;
text-align: center;
margin: 0;
}
</style>
</script>
</script>
</head>
"
;
$fp = fopen ("$fichier",'r');
$content = fread ($fp,filesize($fichier));
$separ_1 = explode("----------
",$content);
$separ_2 = explode("
----------",$separ_1[1]);
$table =$separ_2[0];
$total = $separ_1[2];
$linetitle= explode("
",$separ_1[0]);
$char = array (" ","W");
$newchar = array ("","O");
########################################
#Récupération des moyennes mensuelles ##
########################################
$title1=trim($linetitle[0]);
$title2=trim($linetitle[2]);
$meantemp_m = substr ($separ_1[2],7,5);
$highttemp_m = substr ($separ_1[2],15,5);
$hourhighttemp_m = substr ($separ_1[2],25,5);
$lowtemp_m = substr ($separ_1[2],30,5);
$hourlowtemp_m = substr ($separ_1[2],40,5);
$hum_m = substr ($separ_1[2],47,3);
$baro_m = substr ($separ_1[2],55,6);
$rain_m = substr ($separ_1[2],66,5);
$ventmoyen_m = substr ($separ_1[2],75,5);
$rafales_m = substr ($separ_1[2],85,5);
$hourrafales_m = substr ($separ_1[2],95,5);
$domdir_m = substr ($separ_1[2],103,5);
$domdir_m = trim($domdir_m);
$sunh_m = substr ($separ_1[2],113,7);
########################################
#Récupération des données journalieres##
########################################
$nb = substr_count ($table, "
");
$ligne ="";
$color = array('#ffffff','#ffff00','#ff00ff','#ffffff');
$gel=0;
$fortgel=0;
$sansdegel=0;
$chaleur=0;
$canicule=0;
$pluie=0;
$pluie_1=0;
$pluie_5=0;
$pluie_10=0;
$maxrain=0;
$replow=array(' ',' ');
$rephight=array(' ',' ');
$repmean=array(' ',' ');
for ($i=0; $i<$nb+1; $i++)
{
#selection ligne
$line = explode("
",$table);
#séparation et classement des valeurs
$jour = substr ($line[$i],2,2);
$jour = trim($jour);
$day = str_pad($jour, 2, "0", STR_PAD_LEFT);
$meantemp = substr ($line[$i],7,5);
$highttemp = substr ($line[$i],15,5);
$hourhighttemp = substr ($line[$i],22,5);
$lowtemp = substr ($line[$i],30,5);
$hourlowtemp = substr ($line[$i],37,5);
$hum = substr ($line[$i],47,3);
$baro = substr ($line[$i],55,6);
$rain = substr ($line[$i],66,5);
$ventmoyen = substr ($line[$i],75,5);
$rafales = substr ($line[$i],85,5);
$hourrafales = substr ($line[$i],92,5);
$domdir = substr ($line[$i],103,4);
$domdir=trim($domdir);
$sunh = substr ($line[$i],112,5);
$sunmin = substr ($line[$i],115,2) ;
$sunminu = $sunmin * 60;
$sunminut = $sunminu / 100;
$sunminute = round ($sunminut);
$sunminutes = ($sunminute<10?'0':'').$sunminute;
$sunheures = substr ($line[$i],112,2);
$tempe = array($meantemp,$highttemp,$lowtemp);
$color = array('#ff0000','#ffff00','#ff00ff','#ff00ff','#ffff00','#ffff00');
$white = array (0,0,0,0,0,0);
for ($c=0; $c<count($tempe); $c++)
{
#colorisation température
if($tempe[$c] <= '-25') {$color[$c]='#003366';}
elseif($tempe[$c] > '-25' && $tempe[$c] <= '-20') {$color[$c]='#003399'; $white[$c]=1;}
elseif($tempe[$c] > '-20' && $tempe[$c] <= '-15') {$color[$c]='#0000cc'; $white[$c]=1;}
elseif($tempe[$c] > '-15' && $tempe[$c] <= '-10') {$color[$c]='#0000ff'; $white[$c]=1;}
elseif($tempe[$c] > '-10' && $tempe[$c] <= '-5') {$color[$c]='#0099ff'; $white[$c]=0;}
elseif($tempe[$c] > '-5' && $tempe[$c] <= '0') {$color[$c]='#66ffff'; $white[$c]=0; }
elseif($tempe[$c] > '0' && $tempe[$c] <= '5') {$color[$c]='#66ff99'; $white[$c]=0; }
elseif($tempe[$c] > '5' && $tempe[$c] <= '10') {$color[$c]='#66ff00'; $white[$c]=0;}
elseif($tempe[$c] > '10' && $tempe[$c] <= '15') {$color[$c]='#ffff00'; $white[$c]=0; }
elseif($tempe[$c] > '15' && $tempe[$c] <= '20') {$color[$c]='#ffcc00'; $white[$c]=0; }
elseif($tempe[$c] > '20' && $tempe[$c] <= '25') {$color[$c]='#ff9900'; $white[$c]=0; }
elseif($tempe[$c] > '25' && $tempe[$c] <= '30') {$color[$c]='#ff6600'; $white[$c]=0; }
elseif($tempe[$c] > '30' && $tempe[$c] <= '35') {$color[$c]='#ff3300'; $white[$c]=0; }
elseif($tempe[$c] > '35' && $tempe[$c] <= '40') {$color[$c]='#cc0000'; $white[$c]=0;}
elseif($tempe[$c] > '40') {$color[$c]='#660000'; $white[$c]=0;}
else {$color[$c]='#ff00ff';}
}
#colorisation pluie
if($rain >= '0.1' && $rain <= '0.2') {$color[3]='#49FBB2'; $white[3]=0;}
elseif($rain > '0.2' && $rain <= '1') {$color[3]='#00fe96'; $white[3]=0;}
elseif($rain > '1' && $rain <= '2.5') {$color[3]='#00fefe'; $white[3]=0;}
elseif($rain > '2.5' && $rain <= '5') {$color[3]='#00c8fe'; $white[3]=0;}
elseif($rain > '5' && $rain <= '7.5') {$color[3]='#0096fe'; $white[3]=0; }
elseif($rain > '7.5' && $rain <= '10') {$color[3]='#0064fe'; $white[3]=1; }
elseif($rain > '10' && $rain <= '15') {$color[3]='#3200fe'; $white[3]=1; }
elseif($rain > '15' && $rain <= '30') {$color[3]='#6400fe'; $white[3]=1;}
elseif($rain > '30' && $rain <= '60') {$color[3]='#9600fe'; $white[3]=1; }
elseif($rain > '60' && $rain <= '100') {$color[3]='#c800fe'; $white[3]=1; }
elseif($rain > '100') {$color[]='#640064'; $white[3]=1;}
else {$color[3]='#ffffff';}
#colorisation vent
if($rafales < '10' ) {$color[4]='#ECF3F8';}
elseif($rafales >= '10' && $rafales < '20') {$color[4]='#ebebeb'; $white[4]=0;}
elseif($rafales >= '20' && $rafales < '30') {$color[4]='#d7d7d7'; $white[4]=0;}
elseif($rafales >= '30' && $rafales < '40') {$color[4]='#c4c4c4'; $white[4]=0; }
elseif($rafales >= '40' && $rafales < '50') {$color[4]='#afafaf'; $white[4]=0; }
elseif($rafales >= '50' && $rafales < '60') {$color[4]='#AB8787'; $white[4]=0; }
elseif($rafales >= '60' && $rafales < '70') {$color[4]='#D07676'; $white[4]=0;}
elseif($rafales >= '70' ) {$color[4]='#ff0000'; $white[4]=0; }
else {$color[4]='#222222';}
#colorisation pression
if($baro <= '990') {$color[5]='##0000ff'; $white[5]=1;}
elseif($baro > '990' && $baro <= '995') {$color[5]='##0099ff'; $white[5]=0; }
elseif($baro > '995' && $baro <= '1000') {$color[5]='#66ffff'; $white[5]=0; }
elseif($baro > '1000' && $baro <= '1005') {$color[5]='#66ff99'; $white[5]=0; }
elseif($baro > '1005' && $baro <= '1010') {$color[5]='#66ff00'; $white[5]=0;}
elseif($baro > '1010' && $baro <= '1015') {$color[5]='#ffff00'; $white[5]=0; }
elseif($baro > '1015' && $baro <= '1020') {$color[5]='#ffcc00'; $white[5]=0; }
elseif($baro > '1020' && $baro <= '1025') {$color[5]='#ff9900'; $white[5]=0; }
elseif($baro > '1025' && $baro <= '1030') {$color[5]='#ff6600'; $white[5]=0; }
elseif($baro > '1030' && $baro <= '1035') {$color[5]='#ff3300'; $white[5]=0; }
elseif($baro > '1035' && $baro <= '1040') {$color[5]='#cc0000'; $white[5]=0;}
elseif($baro > '1040') {$color[5]='#660000'; $white[5]=1;}
else {$color[5]='#ff00ff';}
#colorisation ensoleillement
if($sunh <= '1') {$color[6]='#ffffff';}
elseif($sunh > '1' && $sunh <= '2') {$color[6]='#ffffa0'; $white[6]=0; }
elseif($sunh > '2' && $sunh <= '4') {$color[6]='#ffff60'; $white[6]=0; }
elseif($sunh > '4' && $sunh <= '6') {$color[6]='#ffff20'; $white[6]=0; }
elseif($sunh > '6' && $sunh <= '8') {$color[6]='#ff9900'; $white[6]=0;}
elseif($sunh > '8' && $sunh <= '10') {$color[6]='#ff6600'; $white[6]=0; }
elseif($sunh > '10' && $sunh <= '12') {$color[6]='#ff3300'; $white[6]=0; }
elseif($sunh > '12') {$color[6]='#cc0000'; $white[6]=1; }
else {$color[6]='#ECF3F8';}
#repère des extremes
$replow=array('','');
$rephight=array('','');
$repmean=array('','');
$reprafales=array('','');
$colortext=array('','','','','','','');
for ($c=0; $c<7; $c++)
{
if ($white[$c]==1) {$colortext[$c]='color="white"';}
else {$colortext[$c]='';}
}
if ($lowtemp == $lowtemp_m) {$replow = array("<b>","</b></font>");}
if ($highttemp == $highttemp_m) {$rephight = array("<b>","</b></font>");}
if ($rafales == $rafales_m) {$reprafales = array("<b>","</b></font>");}
if ($lowtemp <='0' && $lowtemp !="") {$gel=$gel+1;} else {$gel=$gel;}
if ($lowtemp <='-5'&& $lowtemp !="") {$fortgel=$fortgel+1;} else {$fortgel=$fortgel;}
if ($lowtemp <='0' && $highttemp <='0' && $lowtemp !="") {$sansdegel=$sansdegel+1;} else {$sansdegel=$sansdegel;}
if ($highttemp >='30') {$chaleur=$chaleur+1;} else {$chaleur=$chaleur;}
if ($highttemp >='35') {$canicule=$canicule+1;} else {$canicule=$canicule;}
if ($rain >'0' && $rain !="") {$pluie=$pluie+1;} else {$pluie=$pluie;}
if ($rain >='1' && $rain !="") {$pluie_1=$pluie_1+1;} else {$pluie_1=$pluie_1;}
if ($rain >='5' && $rain !="") {$pluie_5=$pluie_5+1;} else {$pluie_5=$pluie_5;}
if ($rain >='10' && $rain !="") {$pluie_10=$pluie_10+1;} else {$pluie_10=$pluie_10;}
if ($rain > $maxrain && $rain !="") {$maxrain="$rain";} else {$maxrain=$maxrain;}
#incrémentation du tableau
$lien=$yearstr.$monthstr.$day.".gif";
$ligne .= "<tr >
<td bgcolor='#b6c7db' align='center'><font color='black' ><a target='_blank' href='../$yearstr/$lien'>$jour</td>
<td bgcolor='$color[2]' width='65' align='center'><font $colortext[2] >$replow[0] $lowtemp °C $replow[1]</td>
<td bgcolor='$color[0]' width='65' align='center'><font $colortext[0] >$repmean[0] $meantemp °C $rephight[1]</td>
<td bgcolor='$color[1]' width='65' align='center'><font $colortext[1] >$rephight[0] $highttemp °C $rephight[1]</td>
<td bgcolor='$color[3]' width='90' align='center'><font $colortext[3] >$rain mm</td>
<td bgcolor='$color[4]' width='180' align='center'><font $colortext[4] >$ventmoyen km/h ($reprafales[0] $rafales km/h $reprafales[1])</td>
<td bgcolor='#ECF3F8' width='60' align='center'><font >$domdir</td>
<td bgcolor='#ffffff' width='80' align='center'><font >$hum %</td>
<td bgcolor='$color[5]' width='80' align='center'><font $colortext[5] >$baro hPa</td>
<td bgcolor='$color[6]' width='80' align='center'><font $colortext[6] >$sunheures:$sunminutes h</td>
</tr>
";}
#################
#affichage final#
#################
echo "
<body BGCOLOR=#F0F0F0>
<font face='Verdana'; size='2'>Pour afficher un graphique journalier, cliquer sur la date souhaitée.</font>
<br><br>
<table width='850' cellspacing='0' cellpadding='0' border='0'>
<tr>
<td width='50%'; valign='top'>
<input onclick='donoaaprevmonth();' type='button' $disableprev name='nooaprev'id='nooaprev' value='Mois précédent' >
<input onclick='donoaanextmonth();' type='button' $disablenext name='nooanext'id='nooanext' value='Mois suivant' >
<input onclick='donoaayear();' type='button' name='nooayear' id='nooayear' value='Climatologie année' >
</td>
<td width='50%'; align='right'>
<form name='date' method='GET' action='redirclimatom.php'>
<b><font face='Arial'; size='2'>Rechercher
un mois :</font></b> <select name='mois' size='1'>
<option>Mois</option>
<option value='01'>Janvier</option>
<option value='02'>Février</option>
<option value='03'>Mars</option>
<option value='04'>Avril</option>
<option value='05'>Mai</option>
<option value='06'>Juin</option>
<option value='07'>Juillet</option>
<option value='08'>Août</option>
<option value='09'>Septembre</option>
<option value='10'>Octobre</option>
<option value='11'>Novembre</option>
<option value='12'>Décembre</option>
</select> <select name='annee' size='1'>";
$today = getdate();
$year = $today[year];
echo" <option>Année</option>";
for ($i=$anneedebut;$i <= $year; $i=$i+1){echo "<option value='$i'>$i</option>";
}
echo"
</select>
<input type='submit' name='AFFICHER' value='Afficher'>
</form>
</td>
</tr>
</table>
<br>
<div style='margin-top: 2px; height: 25px;' class='myBox'>
<span style='font-weight: bold;'>
<span style='font-family: Arial; color: white;'>$title1</span></span>
</div>
<div style='margin-top: -48px;' class='box_tableau'>
<table style='border-collapse: collapse' border='1' bordercolor='#3f557a'>
<tr bgcolor='#b6c7db'>
<td rowspan='2'><font color='black' ><b>Jour</b></font></td>
<td colspan='3' align='center'><font color='black' ><b>Température</b></font></td>
<td rowspan='2' align='center'><font color='black' ><b>Pluie/Rosée</b></font></td>
<td colspan='2' align='center'><font color='black' ><b>Vent</b></font></td>
<td rowspan='2' align='center'><font color='black' ><b>Humidité</b></font></td>
<td rowspan='2' align='center'><font color='black' ><b>Pression</b></font></td>
<td rowspan='2' align='center'><font color='black' ><b>Ensoleillement</b></font></td>
</tr>
<tr bgcolor='#b6c7db'>
<td align='center'><font color='black' >min</font></td>
<td align='center'><font color='black' >moy</font></td>
<td align='center'><font color='black' >max</font></td>
<td align='center'><font color='black' >Vent moyen (rafale max)</font></td>
<td align='center'><font color='black' >Secteur</font></td>
</tr>
$ligne
<tr bgcolor='#b6c7db'>
<td><font color='black' ><b> </b></font></td>
<td align='center'><font color='black' >$lowtemp_m °C</font></td>
<td align='center'><font color='black' >$meantemp_m °C</font></td>
<td align='center'><font color='black' >$highttemp_m °C</font></td>
<td align='center'><font color='black' >$rain_m mm</font></td>
<td align='center'><font color='black' >$ventmoyen_m km/h ($rafales_m km/h)</font></td>
<td align='center'><font color='black' ><img src='pictos/$domdir_m.gif'/>$domdir_m</font></td>
<td align='center'><font color='black' >$hum_m %</font></td>
<td align='center'><font color='black' >$baro_m hPa</font></td>
<td align='center'><font color='black' >$sunh_m h</font></td>
</tr>
</table>
</div>
<div style='margin-top: 0px;' class='myBox_bottom'>
<table width='844'; style='border-collapse: collapse' border='1' bordercolor='#b6c7db'>
<tr bgcolor='#b6c7db'>
<td><font color='black' >
<p><font face='Verdana'; size='2'> Température moyenne mensuelle : </font><b>$meantemp_m °C</b></b> <br><font face='Verdana'; size='2'> Tn mensuelle : </font><b>$lowtemp_m °C</b> <br><font face='Verdana'; size='2'> Tx mensuelle : </font><b>$highttemp_m °C</b></p>
<p><font face='Verdana'; size='2'> Vent moyen pour le mois : </font><b>$ventmoyen_m km/h</b> <font face='Verdana'; size='2'>de secteur </font><b>$domdir_m </b><br><font face='Verdana'; size='2'> Rafale maxi : </font><b>$rafales_m km/h</b></p>
<p><font face='Verdana'; size='2'> Pluviometrie mensuelle : </font><b>$rain_m mm</b><br> <font face='Verdana'; size='2'> avec un maximum journalier de </font><b>$maxrain mm</b></p></font></td>
<td><font color='black'>
<p><font face='Verdana'; size='2'> Nombre de jours :</font></p>
<ul>
<li><font face='Verdana'; size='2'>avec gelée : </font><b>$gel</b> </li>
<li><font face='Verdana'; size='2'>avec forte gelée (<=-5) : </font><b>$fortgel</b> </li>
<li><font face='Verdana'; size='2'>sans dégel : </font><b>$sansdegel</b> </li>
<li><font face='Verdana'; size='2'>avec chaleur (>=30) : </font><b>$chaleur</b> </li>
</ul>
<ul>
<li><font face='Verdana'; size='2'>avec pluie ou rosée : </font><b>$pluie</b></li>
<li><font face='Verdana'; size='2'>avec plus de 1mm : </font><b>$pluie_1</b></li>
<li><font face='Verdana'; size='2'>avec plus de 5mm : </font><b>$pluie_5</b></li>
<li><font face='Verdana'; size='2'>avec plus de 10mm : </font><b>$pluie_10</b></li>
</ul>
</font></td>
</tr>
</table>
</div>
<br>
</body>";
?>