weather.php (1493B)
1 <?php 2 $zip = $_GET["z"]; 3 if ($zip == "") { 4 $zip = 9520; 5 } 6 ?> 7 <!DOCTYPE html> 8 <html lang="en"> 9 <meta charset="utf-8"> 10 <meta name="viewport" content="width=device-width, initial-scale=1"> 11 <title>Weather in <?php echo $zip; ?></title> 12 <style> 13 body{ 14 margin:1em auto; 15 max-width:40em; 16 padding:0 .62em; 17 font:1.2em/1.62 sans-serif; 18 color:#4d4d4c; 19 } 20 h1,h2,h3 { 21 color:#333; 22 line-height:1.2; 23 } 24 a { 25 color:#126b8c; 26 text-decoration:none; 27 } 28 img { 29 max-width:100%; 30 } 31 @media print { 32 body{ 33 max-width:none 34 } 35 } 36 </style> 37 <article> 38 <header> 39 <h1>Weather in <?php echo $zip; ?></h1> 40 <aside> 41 <center> 42 <p> 43 <a href="?z=1000">København</a>, 44 <a href="?z=7700">Thisted</a>, 45 <a href="?z=8000">Aarhus</a>, 46 <a href="?z=9520">Skørping</a> 47 </p> 48 </center> 49 </aside> 50 </header> 51 <img src="https://servlet.dmi.dk/byvejr/servlet/byvejr_dag1?by=<?php echo $zip; ?>&mode=long&eps=true" alt="0-2 days"> 52 <br> 53 <img src="https://servlet.dmi.dk/byvejr/servlet/byvejr?by=<?php echo $zip; ?>&tabel=dag3_9&eps=true" alt="3-9 days"> 54 <?php 55 $lon = ""; 56 $lat = ""; 57 if ($zip == 1000) { 58 $lon = "55.68"; 59 $lat = "12.57"; 60 } elseif ($zip == 7700) { 61 $lon = "56.96"; 62 $lat = "8.70"; 63 } elseif ($zip == 8000) { 64 $lon = "56.16"; 65 $lat = "10.20"; 66 } elseif ($zip == 9520) { 67 $lon = "56.84"; 68 $lat = "9.89"; 69 } 70 if ($lon != "") { 71 echo "<br><p><img src=\"https://clearoutside.com/forecast_image_large/{$lon}/{$lat}/forecast.png\" alt=\"Clear Outside forecast\"></p>"; 72 } 73 ?> 74 </article>