J'ai une erreur de moyenne pour la température min du fichier climatom.php
J'ai analysé le fichier ainsi que le template.
(La moyenne est correcte dans le fichier noaaxxxx.txt.)
Il semblerait donc que celle-ci ne soit pas correctement reprise par le php.
Help aux experts en php.
Voici mon climatom.php
Code : Tout sélectionner
<php>=$today[year]) && ($nextmonth > $today[mon])) {
$nextmonth = $today[mon];
$disablenext="disabled='disabled'";
}
$anproch = $today[year] + 1;
if ($nextyear == ($today[year] + 1)) {
$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 = $moisdebut;
$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>
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>
</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);
$rafales_m=str_replace( ',' , '.', $rafales_m );
$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);
$moymin = substr ($separ_1[2],120,5);
$moymax = substr ($separ_1[2],126,5);
########################################
#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);
$rafales = str_replace( ',' , '.' ,$rafales);
$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> '100') {$sunpourcent= 100;}
$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 humidite
if($hum <= '10') {$color[7]='#FFFF99';}
elseif($hum > '10' && $hum <= '20') {$color[7]='#00ff80'; $white[7]=0; }
elseif($hum > '20' && $hum <= '30') {$color[7]='#00ffc0'; $white[7]=1; }
elseif($hum > '30' && $hum <= '40') {$color[7]='#00ffe0'; $white[7]=1; }
elseif($hum > '40' && $hum <= '50') {$color[7]='#00e0ff'; $white[7]=1; }
elseif($hum > '50' && $hum <= '60') {$color[7]='#00a0ff'; $white[7]=1; }
elseif($hum > '60' && $hum <= '70') {$color[7]='#0080ff'; $white[7]=1; }
elseif($hum > '70' && $hum <= '80') {$color[7]='#0060ff'; $white[7]=1; }
elseif($hum > '80' && $hum < '90') {$color[7]='#0040ff'; $white[7]=1; }
elseif($hum >= '90') {$color[7]='#0000c0'; $white[7]=1;}
else {$color[7]='#ffffff';}
#colorisation pluie
if($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]='#ffffff';}
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';}
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]=0;}
else {$color[5]='#ff00ff';}
#repère des extremes
$replow=array('','');
$rephight=array('','');
$repmean=array('','');
$reprafales=array('','');
$colortext=array('','','','','','','');
for ($c=0; $c<8; $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
if (intval($jour)==intval($today[mday]) && intval($monthstr) == intval($today[mon]) && intval($yearstr) == intval($today[year]))
{$dirvent = 'http://lacombe.dyndns.org/meteo/ddis_current.gif';}
else {$dirvent = "http://lacombe.dyndns.org/meteo/$yearstr/ddis_$yearstr$monthstr$day.gif";}
$ligne .= "<tr>
<td><font>$jour</td>
<td><font>$replow[0] $lowtemp °C <font>($hourlowtemp)</font> $replow[1]</td>
<td><font>$repmean[0] $meantemp °C $rephight[1]</td>
<td><font>$rephight[0] $highttemp °C <font>($hourhighttemp)</font> $rephight[1]</td>
<td><font>$ventmoyen km/h<br>($reprafales[0] $rafales km/h à $hourrafales $reprafales[1])</td>
<td><font><img>$domdir</td>
<td><font>$rain mm</td>
<td><font>$hum %</td>
<td><font>$baro hPa</td>
</tr>
";}
#################
#affichage final#
#################
echo "
<p><span><b><u>$title1</u></b></span></p>
<font>$title2</font><br><br>
<input>
<input>
<input>
</p>
<table>
<tr>
<td><font><b>Jour</b></font></td>
<td><font><b>Température</b></font></td>
<td><font><b>Vent</b></font></td>
<td><font><b>Pluie</b></font></td>
<td><font><b>Humidité</b></font></td>
<td><font><b>Pression</b></font></td>
</tr>
<tr>
<td><font>min</font></td>
<td><font>moy</font></td>
<td><font>max</font></td>
<td><font>Vent moyen<br>(rafale max)</font></td>
<td><font>Secteur</font></td>
</tr>
$ligne
<tr>
<td><font><b> Moyennes </b></font></td>
<td><font>$moymax °C</font></td>
<td><font>$meantemp_m °C</font></td>
<td><font>$moymin °C</font></td>
<td><font>$ventmoyen_m km/h<br>(max: $rafales_m km/h)</font></td>
<td><font><img>$domdir_m</font></td>
<td><font>Total:<br>$rain_m mm</font></td>
<td><font>$hum_m %</font></td>
<td><font>$baro_m hPa</font></td>
</tr>
</table>
<font>
<p>Température moyenne mensuelle : <b>$meantemp_m °C</b></b> <br>T° mensuelle la plus basse : <b>$lowtemp_m °C</b> <br>T° mensuelle la plus haute: <b>$highttemp_m °C</b></p>
<p>Vent moyen pour le mois : <b>$ventmoyen_m km/h</b> de secteur <b>$domdir_m </b><br>Rafale maxi : <b>$rafales_m km/h</b></p>
<p>Pluviometrie mensuelle : <b>$rain_m mm</b> avec un maximum journalier de <b>$maxrain mm</b></p>
<p>Nombre de jours :</p>
<ul>
<li>avec gelée : <b>$gel</b> </li>
<li>avec forte gelée (<=-5): <b>$fortgel</b> </li>
<li>sans dégel : <b>$sansdegel</b> </li>
<li>avec chaleur (>=30): <b>$chaleur</b> </li>
<li>avec canicule (>=35): <b>$canicule</b> </li>
</ul>
<ul>
<li>avec pluie : <b>$pluie</b></li>
<li>avec plus de 1mm : <b>$pluie_1</b></li>
<li>avec plus de 5mm : <b>$pluie_5</b></li>
<li>avec plus de 10mm : <b>$pluie_10</b></li>
</ul>
</font>
</body>";
?>
Bon amusement et merci d'avance.
Toff