Zend - The PHP Company




Weather

Add Code


Meteosat  

Type: code fragment
Added by: karakas
Entered: 28/11/2002
Last modified: 02/11/2001
Rating: - (fewer than 3 votes)
Views: 7304
This PHP script will display the most recent Meteosat images of the World and Europe. The images are taken from http://www.wetter.com.


<?php

/************************************************************************/
/*                                                                      */
/* Meteosat Block v.1.0                                                 */
/* ====================                                                 */
/*                                                                      */
/* Copyright (c) 2002 by Chris Karakas <chris@karakas-online.de>        */
/* http://www.karakas-online.de                                         */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/*                                                                      */
/* This PHP         block will display the most recent Meteosat         */
/* images of the World and Europe. The images are taken from            */
/* www.wetter.com at                                                    */
/*                                                                      */
/* http://www.wetter.com/home/img/sat/METEOSAT_vis_c/xl/                */
/* http://www.wetter.com/home/img/sat/METEOSAT-FULL_ir_c/xl/            */
/*                                                                      */
/* The images are named YYYYMMDDHHMM.jpg, in GMT, so the script has     */
/* to compute the year, month, day, hour and minutes in GMT,            */
/* then round down the minutes to either 00 or 30.                      */
/* Due to delays, I don't try to get the exact latest image,            */
/* rather I prefer to subtract a safety intervall of 3600 sec           */
/* from the current time, before I start the calculations.              */
/* This way I make sure an image will always be there.                  */
/*                                                                      */
/* Please mail me if this should not work some day. In the meantime,    */
/* enjoy!                                                               */
/*                                                                      */
/* Chris                                                                */
/*                                                                      */
/************************************************************************/



/************************************************************************/
/* For safety, I subtract one hour, so I am sure the image is there.    */
/************************************************************************/
$timestamp time()-3600;


/************************************************************************/
/* Get month, day, year, hour and minutes in GMT                        */
/************************************************************************/
$month gmdate('m'$timestamp);
$day gmdate('d'$timestamp);
$year gmdate('Y'$timestamp);
$hour gmdate('H'$timestamp);
$minutes gmdate('i'$timestamp);

/************************************************************************/
/* Round minutes down to either 00 or 30                                */
/************************************************************************/
$minutes floor($minutes/30)*30;
switch (
$minutes) {
  case 
0:
    
$minutes "00";
    break;
  case 
30:
    
$minutes "30";
    break;
}


$worldurl "http://www.wetter.com/home/img/sat/METEOSAT-FULL_ir_c/xl/";
$worldurl .= "$year$month$day$hour$minutes.jpg";
$europeurl "http://www.wetter.com/home/img/sat/METEOSAT_vis_c/xl/";
$europeurl .= "$year$month$day$hour$minutes.jpg";
$updateurl "http://www.wetter.com";
$updatetext "Update by wetter.com";
$alttext "Click here for a larger image";

$content "<table align=center>";
$content .= "<tr><td>";

/* Uncomment for testing
$content .= "<p><center> day=$day month=$month year=$year hour=$hour min=$minutes</center></p>";
*/

$content .= "</td></tr>";
$content .= "<tr><td>";
$content .= "<center><A HREF="$worldurl" target="_blank"><IMG SRC="$worldurl" alt="$alttext" height=284 width=270></A></center>";
$content .= "</td></tr>";
$content .= "<tr><td>";
$content .= "<center>World</center>";
$content .= "</td></tr>";
$content .= "<tr><td>";
$content .= "<center><A HREF="$europeurl" target="_blank"><IMG SRC="$europeurl" alt="$alttext" height=230 width=288></A></center>";
$content .= "</td></tr>";
$content .= "<tr><td>";
$content .= "<center>Europe</center>";
$content .= "</td></tr>";
$content .= "<tr><td>";
$content .= "<center><a href="$updateurl"target="_blank">$updatetext</a></center><br>";
$content .= "</td></tr>";
$content .= "</table>";

$content .= "<p>";
$content .= "See the <a href="http://www.karakas-online.de/myServices/showfile.php?highlight=meteosat">source code.</a>";


echo $content;

?>




Usage Example


See the example


Rate This Script





Search



This Category All Categories