- 23 jul 2023, 21:35
#74875
Zoals eerder vermeld doet mijn weerbericht het weer na de upgrade.
Hieronder mijn script.
Ik vermoed dat de fout zit in de "strftime" functie.
Ik weet alleen niet hoe ik dit goed moet aanpassen.
Hieronder mijn script.
Ik vermoed dat de fout zit in de "strftime" functie.
Ik weet alleen niet hoe ik dit goed moet aanpassen.
Code: Selecteer alles
<style type="text/css">div.pre {
font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
width: 600px;
}
.basisverwachting {
font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
}
.realtable {
background-color: #EEEEEE;
font-size: 13px;
line-height:1.4;
width: 451px;
border-collapse: collapse;
border-bottom: solid 1px #E2E2E2;
margin-top: 11px;
margin-bottom: 11px;
}
.realtable th {
background-color: #054b81;
border-bottom: solid 1px #E2E2E2;
border-right: solid 1px #E2E2E2;
border-left: solid 1px #E2E2E2;
padding: 3px 0px 3px 4px;
text-align: left;
vertical-align: top;
color: #FFFFFF;
}
.realtable td {
border-bottom: solid 1px #E2E2E2;
border-right: solid 1px #E2E2E2;
border-left: solid 1px #E2E2E2;
vertical-align: top;
padding: 3px 0px 3px 4px;
}
.rubriekkop {
font-weight: bold;
font-size: 18px;
}
.hoofdkop {
font-size: 15px;
font-weight: bold;
color: #000;
}
.alineakop {
font-weight: bold;
font-size: 15px;
color: #000;
}
.datumtijd {
font-size: 8px;
font-style: italic;
color: #000000;
}
div.weer {
position: relative;
margin:0 auto;
line-height: 1.4em;
font-family:Arial, Helvetica, sans-serif;
font-size: 12px;
width: 600px;
padding-left: 25px;
}
@media only screen and (max-width: 479px){
#div.weer { width: 90%; }
}
.subkop {
font-size: 14px;
color: #000;
font-family: Arial, Helvetica, sans-serif;
overflow-x:hidden;
}
.trcolor {
color: #000;
}
</style>
<div class="weer">
<div class="hoofdkop">Verwachting KNMI <?php
setlocale(LC_ALL, 'nl_NL.ISO_8859-1');
if (file_exists('ftp://ftp.knmi.nl/pub_weerberichten/basisverwachting.xml'))
{
$xmlx = simplexml_load_file('ftp://ftp.knmi.nl/pub_weerberichten/basisverwachting.xml');
$weer = $xmlx->xpath("//field_content");
$tijd = $xmlx->xpath("//report_dtg_issued");
$d1 = $xmlx->xpath("//valid_start");
}
else {echo "Geen weerbericht ontvangen";
};
?><span class="alineakop"><? echo strftime("%A %e", strtotime($d1[0])); ?><?php
echo ' '; ?>tot en met <? echo strftime("%A %e %B %Y", strtotime($d1[0]) + 518400); ?></span></div>
<br />
<span class="hoofdkop"><? echo "Vandaag en morgen: "; ?></span><br />
<span class="subkop"><? echo $weer[0]; ?></span><br /><br />
<div><span class="basisverwachting"><? echo preg_replace(array('/[^(\x20-\x7F)]+[^(\x20-\x7F)]|[^(\x20-\x7F)]/','/\. /'),array('<br />','.'),$weer[2]); ?></span></div>
<br />
<span class="datumtijd">Opgemaakt <? echo strftime("%A %e %B %Y %H:%M", strtotime($tijd[0]))," uur"; ?></span><br />
<br />
<!--<div class="hoofdkop">Verwachting komende 5 dagen</div>--><?
if (file_exists('ftp://ftp.knmi.nl/pub_weerberichten/middellange_termijn_verwachting.xml'))
{
$xmly = simplexml_load_file('ftp://ftp.knmi.nl/pub_weerberichten/middellange_termijn_verwachting.xml');
}
else {echo "Geen bericht ontvangen";};
?><span class="alineakop">Vooruitzichten op (middel)lange termijn </span><br />
<div class="pre"><? $kop = $xmly->xpath("//verwachting_meerdaagse"); echo str_replace(". ",".<br>",$kop[0]); ?></div>
<table border="0" cellpadding="0" cellspacing="0" class="realtable" width="451">
<tbody>
<tr class="trcolor">
<th> </th>
<th align="left" width="40"><? $d0 = $xmly->xpath("//dag1_ddd"); echo $d0[0]; ?></th>
<th align="left" width="40"><? $d1 = $xmly->xpath("//dag2_ddd"); echo $d1[0]; ?></th>
<th align="left" width="40"><? $d2 = $xmly->xpath("//dag3_ddd"); echo $d2[0]; ?></th>
<th align="left" width="40"><? $d3 = $xmly->xpath("//dag4_ddd"); echo $d3[0]; ?></th>
<th align="left" width="40"><? $d4 = $xmly->xpath("//dag5_ddd"); echo $d4[0]; ?></th>
<th align="left" width="40"><? $d5 = $xmly->xpath("//dag6_ddd"); echo $d5[0]; ?></th>
</tr>
<tr class="trcolor">
<td style="text-align: left">Zonneschijn (%)</td>
<td><? $z0 = $xmly->xpath("//zonneschijnkans_dag1"); echo $z0[0]; ?></td>
<td><? $z1 = $xmly->xpath("//zonneschijnkans_dag2"); echo $z1[0]; ?></td>
<td><? $z2 = $xmly->xpath("//zonneschijnkans_dag3"); echo $z2[0]; ?></td>
<td><? $z3 = $xmly->xpath("//zonneschijnkans_dag4"); echo $z3[0]; ?></td>
<td><? $z4 = $xmly->xpath("//zonneschijnkans_dag5"); echo $z4[0]; ?></td>
<td><? $z5 = $xmly->xpath("//zonneschijnkans_dag6"); echo $z5[0]; ?></td>
</tr>
<tr class="trcolor">
<td style="text-align: left">Neerslagkans (%)</td>
<td><? $n0 = $xmly->xpath("//neerslagkans_dag1"); echo $n0[0]; ?></td>
<td><? $n1 = $xmly->xpath("//neerslagkans_dag2"); echo $n1[0]; ?></td>
<td><? $n2 = $xmly->xpath("//neerslagkans_dag3"); echo $n2[0]; ?></td>
<td><? $n3 = $xmly->xpath("//neerslagkans_dag4"); echo $n3[0]; ?></td>
<td><? $n4 = $xmly->xpath("//neerslagkans_dag5"); echo $n4[0]; ?></td>
<td><? $n5 = $xmly->xpath("//neerslagkans_dag6"); echo $n5[0]; ?></td>
</tr>
<tr class="trcolor">
<td style="text-align: left">Neerslaghoeveelheid (mm)</td>
<td><?
$nh0 = $xmly->xpath("//neerslaghoeveelheid_dag1"); if (empty($nh0)) {echo "";} else {echo $nh0[0];};
$nh5 = $xmly->xpath("//neerslaghoeveelheid_min_dag1"); echo $nh5[0];
$nh10 = $xmly->xpath("//neerslaghoeveelheid_max_dag1");
if (empty($nh0)) {echo "/";} else {echo " ";};
echo $nh10[0];
?></td>
<td><?
$nh1 = $xmly->xpath("//neerslaghoeveelheid_dag2"); if (empty($nh1)) {echo "";} else {echo $nh1[0];};
$nh6 = $xmly->xpath("//neerslaghoeveelheid_min_dag2"); echo $nh6[0];
$nh11 = $xmly->xpath("//neerslaghoeveelheid_max_dag2");
if (empty($nh1)) {echo "/";} else {echo " ";};
echo $nh11[0];
?></td>
<td><?
$nh2 = $xmly->xpath("//neerslaghoeveelheid_dag3"); if (empty($nh2)) {echo "";} else {echo $nh2[0];};
$nh7 = $xmly->xpath("//neerslaghoeveelheid_min_dag3"); echo $nh7[0];
$nh12 = $xmly->xpath("//neerslaghoeveelheid_max_dag3");
if (empty($nh2)) {echo "/";} else {echo " ";};
echo $nh12[0];
?></td>
<td><?
$nh3 = $xmly->xpath("//neerslaghoeveelheid_dag4");if (empty($nh3)) {echo "";} else {echo $nh3[0];};
$nh8 = $xmly->xpath("//neerslaghoeveelheid_min_dag4"); echo $nh8[0];
$nh13 = $xmly->xpath("//neerslaghoeveelheid_max_dag4");
if (empty($nh3)) {echo "/";} else {echo " ";};
echo $nh13[0];
?></td>
<td><?
$nh4 = $xmly->xpath("//neerslaghoeveelheid_dag5"); if (empty($nh4)) {echo "";} else {echo $nh4[0];};
$nh9 = $xmly->xpath("//neerslaghoeveelheid_min_dag5"); echo $nh9[0];
$nh14 = $xmly->xpath("//neerslaghoeveelheid_max_dag5");
if (empty($nh4)) {echo "/";} else {echo " ";};
echo $nh14[0];
?></td>
<td><?
$nh5 = $xmly->xpath("//neerslaghoeveelheid_dag6"); if (empty($nh5)) {echo "";} else {echo $nh5[0];};
$nh10 = $xmly->xpath("//neerslaghoeveelheid_min_dag6"); echo $nh10[0];
$nh15 = $xmly->xpath("//neerslaghoeveelheid_max_dag6");
if (empty($nh5)) {echo "/";} else {echo " ";};
echo $nh15[0];
?></td>
</tr>
<tr class="trcolor">
<td style="text-align: left">Minimumtemperatuur (°C)</td>
<td><?
$t0 = $xmly->xpath("//minimumtemperatuur_dag1"); if (empty($t0)) {echo "";} else {echo $t0[0];};
$t5 = $xmly->xpath("//minimumtemperatuur_min_dag1"); echo $t5[0];
$t10 = $xmly->xpath("//minimumtemperatuur_max_dag1");
if (empty($t0)) {echo "/";} else {echo " ";};
echo $t10[0];
?></td>
<td><?
$t1 = $xmly->xpath("//minimumtemperatuur_dag2"); if (empty($t1)) {echo "";} else {echo $t1[0];};
$t6 = $xmly->xpath("//minimumtemperatuur_min_dag2"); echo $t6[0];
$t11 = $xmly->xpath("//minimumtemperatuur_max_dag2");
if (empty($t1)) {echo "/";} else {echo " ";};
echo $t11[0];
?></td>
<td><?
$t2 = $xmly->xpath("//minimumtemperatuur_dag3"); if (empty($t2)) {echo "";} else {echo $t2[0];};
$t7 = $xmly->xpath("//minimumtemperatuur_min_dag3"); echo $t7[0];
$t12 = $xmly->xpath("//minimumtemperatuur_max_dag3");
if (empty($t2)) {echo "/";} else {echo " ";};
echo $t12[0];
?></td>
<td><?
$t3 = $xmly->xpath("//minimumtemperatuur_dag4"); if (empty($t3)) {echo "";} else {echo $t3[0];};
$t8 = $xmly->xpath("//minimumtemperatuur_min_dag4"); echo $t8[0];
$t13 = $xmly->xpath("//minimumtemperatuur_max_dag4");
if (empty($t3)) {echo "/";} else {echo " ";};
echo $t13[0];
?></td>
<td><?
$t4 = $xmly->xpath("//minimumtemperatuur_dag5"); if (empty($t4)) {echo "";} else {echo $t4[0];};
$t9 = $xmly->xpath("//minimumtemperatuur_min_dag5"); echo $t9[0];
$t14 = $xmly->xpath("//minimumtemperatuur_max_dag5");
if (empty($t4)) {echo "/";} else {echo " ";};
echo $t14[0];
?></td>
<td><?
$t5 = $xmly->xpath("//minimumtemperatuur_dag6"); if (empty($t5)) {echo "";} else {echo $t5[0];};
$t10 = $xmly->xpath("//minimumtemperatuur_min_dag6"); echo $t10[0];
$t15 = $xmly->xpath("//minimumtemperatuur_max_dag6");
if (empty($t5)) {echo "/";} else {echo " ";};
echo $t15[0];
?></td>
</tr>
<tr class="trcolor">
<td style="text-align: left">Middagtemperatuur (°C)</td>
<td><?
$m0 = $xmly->xpath("//maximumtemperatuur_dag1"); if (empty($m0)) {echo "";} else {echo $m0[0];};
$m5 = $xmly->xpath("//maximumtemperatuur_min_dag1"); echo $m5[0];
$m10 = $xmly->xpath("//maximumtemperatuur_max_dag1");
if (empty($m0)) {echo "/";} else {echo " ";};
echo $m10[0];
?></td>
<td><?
$m1 = $xmly->xpath("//maximumtemperatuur_dag2"); if (empty($m1)) {echo "";} else {echo $m1[0];};
$m6 = $xmly->xpath("//maximumtemperatuur_min_dag2"); echo $m6[0];
$m11 = $xmly->xpath("//maximumtemperatuur_max_dag2");
if (empty($m1)) {echo "/";} else {echo " ";};
echo $m11[0];
?></td>
<td><?
$m2 = $xmly->xpath("//maximumtemperatuur_dag3"); if (empty($m2)) {echo "";} else {echo $m2[0];};
$m7 = $xmly->xpath("//maximumtemperatuur_min_dag3"); echo $m7[0];
$m12 = $xmly->xpath("//maximumtemperatuur_max_dag3");
if (empty($m2)) {echo "/";} else {echo " ";};
echo $m12[0];
?></td>
<td><?
$m3 = $xmly->xpath("//maximumtemperatuur_dag4"); if (empty($m3)) {echo "";} else {echo $m3[0];};
$m8 = $xmly->xpath("//maximumtemperatuur_min_dag4"); echo $m8[0];
$m13 = $xmly->xpath("//maximumtemperatuur_max_dag4");
if (empty($m3)) {echo "/";} else {echo " ";};
echo $m13[0];
?></td>
<td><?
$m4 = $xmly->xpath("//maximumtemperatuur_dag5"); if (empty($m4)) {echo "";} else {echo $m4[0];};
$m9 = $xmly->xpath("//maximumtemperatuur_min_dag5"); echo $m9[0];
$m14 = $xmly->xpath("//maximumtemperatuur_max_dag5");
if (empty($m4)) {echo "/";} else {echo " ";};
echo $m14[0];
?></td>
<td><?
$m5 = $xmly->xpath("//maximumtemperatuur_dag6"); if (empty($m5)) {echo "";} else {echo $m5[0];};
$m10 = $xmly->xpath("//maximumtemperatuur_min_dag6"); echo $m10[0];
$m15 = $xmly->xpath("//maximumtemperatuur_max_dag6");
if (empty($m5)) {echo "/";} else {echo " ";};
echo $m15[0];
?></td>
</tr>
<tr class="trcolor">
<td style="text-align: left">Windrichting</td>
<td><? $wr0 = $xmly->xpath("//windrichting_dag1"); echo $wr0[0]; ?></td>
<td><? $wr1 = $xmly->xpath("//windrichting_dag2"); echo $wr1[0]; ?></td>
<td><? $wr2 = $xmly->xpath("//windrichting_dag3"); echo $wr2[0]; ?></td>
<td><? $wr3 = $xmly->xpath("//windrichting_dag4"); echo $wr3[0]; ?></td>
<td><? $wr4 = $xmly->xpath("//windrichting_dag5"); echo $wr4[0]; ?></td>
<td><? $wr5 = $xmly->xpath("//windrichting_dag6"); echo $wr5[0]; ?></td>
</tr>
<tr class="trcolor">
<td style="text-align: left">Windkracht (bft)</td>
<td><? $wk0 = $xmly->xpath("//windkracht_dag1"); echo $wk0[0]; ?></td>
<td><? $wk1 = $xmly->xpath("//windkracht_dag2"); echo $wk1[0]; ?></td>
<td><? $wk2 = $xmly->xpath("//windkracht_dag3"); echo $wk2[0]; ?></td>
<td><? $wk3 = $xmly->xpath("//windkracht_dag4"); echo $wk3[0]; ?></td>
<td><? $wk4 = $xmly->xpath("//windkracht_dag5"); echo $wk4[0]; ?></td>
<td><? $wk5 = $xmly->xpath("//windkracht_dag6"); echo $wk5[0]; ?></td>
</tr>
</tbody>
</table>
<span class="datumtijd">Opgemaakt <? echo strftime("%A %e %B %Y %H:%M", strtotime($tijd[0]))," uur"; ?></span><br />
<br />
<span class="alineakop">Vooruitzichten op lange termijn</span> <!--<div class="hoofdkop">Verwachting 6 tot 9 dagen vooruit</div>--><span class="alineakop"><? $d25 = $xmly->xpath("//dag7_dd");
$d26 = $xmly->xpath("//dag7_mm");
$d27 = $xmly->xpath("//dag7_yy");
$d27 = strftime("%A %e %B %Y", mktime(0, 0, 0,(int)$d26[0],(int)$d25[0],(int)$d27[0])+604800); ?><? $d10 = $xmly->xpath("//dag7_dddd_dd_mmmm"); echo $d10[0]; ?><?php
echo ' '; ?>tot en met <? echo $d27; ?></span><br />
<div class="pre"><? $d30 = $xmly->xpath("//verwachting_lange_termijn_tekst"); echo str_replace('. ','.<br>',$d30[0]); ?></div>
<div class="hoofdkop">Langjarige gemiddelden, tijdvak 1971-2000</div>
<table border="0" cellpadding="0" cellspacing="0" class="realtable" width="451">
<tbody>
<tr class="trcolor">
<th width="151"> </th>
<th colspan="3" width="150">
<center><? echo strftime("%B"); ?></center>
</th>
<th colspan="3" width="150">
<center><? echo strftime("%B",strtotime("+1 month")); ?></center>
</th>
</tr>
<tr class="trcolor">
<td style="text-align: left">Periode</td>
<td width="50">1-10</td>
<td width="50">11-20</td>
<td width="50">21-eind</td>
<td width="50">1-10</td>
<td width="50">11-20</td>
<td width="50">21-eind</td>
</tr>
<tr class="trcolor">
<td style="text-align: left">Maximumtemperatuur</td>
<td width="50"><? $m1decl1tx = $xmly->xpath("//norm_m1_dec1_tx"); echo $m1decl1tx[0]; ?></td>
<td width="50"><? $m1decl2tx = $xmly->xpath("//norm_m1_dec2_tx"); echo $m1decl2tx[0]; ?></td>
<td width="50"><? $m1decl3tx = $xmly->xpath("//norm_m1_dec3_tx"); echo $m1decl3tx[0]; ?></td>
<td width="50"><? $m2decl1tx = $xmly->xpath("//norm_m2_dec1_tx"); echo $m2decl1tx[0]; ?></td>
<td width="50"><? $m2decl2tx = $xmly->xpath("//norm_m2_dec2_tx"); echo $m2decl2tx[0]; ?></td>
<td width="50"><? $m2decl3tx = $xmly->xpath("//norm_m2_dec3_tx"); echo $m2decl3tx[0]; ?></td>
</tr>
<tr class="trcolor">
<td style="text-align: left">Minimumtemperatuur</td>
<td width="50"><? $m1decl1tn = $xmly->xpath("//norm_m1_dec1_tn"); echo $m1decl1tn[0]; ?></td>
<td width="50"><? $m1decl2tn = $xmly->xpath("//norm_m1_dec2_tn"); echo $m1decl2tn[0]; ?></td>
<td width="50"><? $m1decl3tn = $xmly->xpath("//norm_m1_dec3_tn"); echo $m1decl3tn[0]; ?></td>
<td width="50"><? $m2decl1tn = $xmly->xpath("//norm_m2_dec1_tn"); echo $m2decl1tn[0]; ?></td>
<td width="50"><? $m2decl2tn = $xmly->xpath("//norm_m2_dec2_tn"); echo $m2decl2tn[0]; ?></td>
<td width="50"><? $m2decl3tn = $xmly->xpath("//norm_m2_dec3_tn"); echo $m2decl3tn[0]; ?></td>
</tr>
</tbody>
</table>
<span class="datumtijd">Opgemaakt <?
$datum = $xmly->xpath("//dag0_dddd_dd_mmmm_yyyy"); echo $datum[0];
$tijd = $xmly->xpath("//tijd_aanmaak"); echo " ".$tijd[0]." uur";
echo "<br><br><font size='1' color='#000080'>Bron <a title='knmi.nl' href='https://www.knmi.nl/'>KNMI</a></font><br>";
?></span></div>