// Version 2.00 - 22-Apr-2010 - major changes to support major meteoalarm.eu website changes // // Modded by Henkka, nordicweather.net // error_reporting(E_ALL); // uncomment for error checking // // this script is designed to be used by // include("get-meteoalarm-warning-inc.php"); // // Find the warning area for your location by going to www.meteoalarm.eu // Navigate to the warning area that represents your region and view the detail page for that area. // For standalone script use, // Copy the URL in the browser address bar into the $EUA_URL area as shown below. // // For Carterlake/WD/PHP template use, add to your Settings.php: // // $SITE['EUwarningURL'] = ''; // // where the is replaced by the URL in the browser address bar found // by the method above. No other customization is needed in the script for use in the Carterlake/WD/PHP template. // // -------------Settings --------------------------------- $Lang = 'nl'; // default language to be used (lowercase, must correspond to available // template languages of // 'en','ct','de','dk','el','es','fi','fr','it','nl','no','pl','pt','se' // $isFIN = false; // Does the warning show warnings from Finland? true/false If true, we need to crop // the texts as all languages (3) are all in one row... // $EUA_URL = 'http://www.meteoalarm.eu/ne_NL/0/0/NL012-Limburg.html'; //$EUA_URL = 'http://www.meteoalarm.eu/index3.php?lang=en_UK&area=DE001&day=0'; //$EUA_URL = 'http://www.meteoalarm.eu/index3.php?area=DE012&day=0&lang=fr_FR'; // // create a 'meteoalarm-en.txt' file in the same directory as the script. // you may have to set the permissions on the file to '666' so it is writable // by the webserver. Repeat for each language supported by your site. // $EUAcacheName = "./meteoalarm.txt"; // prototype for path/filename for cache file // note: $EUAcacheName will be changed to -$Lang.txt (like -en.txt) to allow languages to have unique cache files. // $EUArefetchSeconds = 600; // refresh every hour // $EUAtarget = ''; // set to 'target="_blank"' for links.. note: makes output not XHTML 1.0-Strict //$EUAtarget = 'target="_blank"'; // to launch links in new page .. not XHTML 1.0-Strict though // -------------End Settings ----------------------------- // $EUAversion = 'get-meteoalarm-warning-inc.php V2.06 - 05-Jun-2011'; // the following note is required by agreement with the authors of the website www.meteoalarm.eu /* ----------------------------------------------------------------------------------------- Date: Thu, 11 Sep 2008 11:39:52 +0200 From: karin buchauer Organization: zamg Dear Mr True, you are quite right: you can use the material featured on the website, without modifying it, providing the source (link) as well as time and date of issue of the data, as stipulated in the Terms & Conditions. With best regards, Karin Buchauer Ken True schrieb: > Dear Sirs, > > I am an amateur weather enthusiast who also writes scripting for other weather enthusiasts to incorporate weather data into their personal, non-commercial weather websites. Many of my scripts (which I write as a hobby, and are distributed gratis) are in use on personal weather websites worldwide. > > I've had requests to package the excellent data from www.meteoalarm.eu for weather advisories in EU countries, and before I generate a script for that purpose, I'd like to have your permission to proceed. > > Your Terms and Conditions page (http://www.meteoalarm.eu/terms.asp?lang=EN ) says: > > "The material featured on this site is the common property of the Meteoalarm partners, and is subject to copyright protection. > The ownership and intellectual rights on all operational and updated awareness and warning information delivered to the Meteoalarm system remain with the Meteoalarm partners who originally delivered this information. The information on this web site may be used freely by the public. > Before using information obtained from this server special attention should be given to the date & time of the data and products being displayed. > In case this information is re-used: This information shall not be modified in content and the source of the information has always to be displayed as EUMETNET - MeteoAlarm, or if a single country, the providing national Institute (for internet application in all cases in the form of a link to: www.meteoalarm.eu). The time of issue at www.meteoalarm.eu must be count. > > Third parties producing copyrighted works consisting predominantly of the material of this website must provide notice with such work(s) identifying the source of material incorporated and stating that such material is not subject to copyright protection. Further information can be obtained from this following address: meteoalarm@zamg.ac.at" > > My reading of this implies that you do permit re-use/publishing of the information with attribution and an active link to the source page for the data on your site, and a note that the data is copyrighted by the data providing organization (and not subject to copyright by the 3rd-party website including/displaying the data). Is that correct? > > Is it ok with you for me to generate a script for displaying national/regional weather alerts using your data from www.meteoalarm.eu with the appropriate attribution. > > Please feel free to examine other scripts I've written which use NOAA, Environment Canada, US Geological Services, and temis.nl as data sources (http://saratoga-weather.org/scripts.php ). > > Thank you in advance for your response, > > Best regards, > Ken True > webmaster@saratoga-weather.org > Saratoga, California, USA -- Karin Buchauer Assistant to the Project Manager EMMA Zentralanstalt für Meteorologie und Geodynamik Regionalstelle für Salzburg und Oberösterreich Freisaalweg 16 A - 5020 SALZBURG Fon ++43 (0)662 626301-22 Fax ++43 (0)662 625838 karin.buchauer@zamg.ac.at www.zamg.ac.at ----------------------------------------------------------------------------------------- */ // // overrides from Settings.php if available global $SITE; if (isset($SITE['tz'])) {$ourTZ = $SITE['tz']; } if (isset($SITE['lang'])) {$Lang = $SITE['lang']; } if (isset($SITE['EUwarningURL'])) {$EUA_URL = $SITE['EUwarningURL']; } // end of overrides from Settings.php if (isset($_REQUEST['bron']) && strtolower($_REQUEST['bron']) == 'view' ) { //--self downloader -- $filenameReal = __FILE__; $download_size = filesize($filenameReal); header('Pragma: public'); header('Cache-Control: private'); header('Cache-Control: no-cache, must-revalidate'); header("Content-type: text/plain"); header("Accept-Ranges: bytes"); header("Content-Length: $download_size"); header('Connection: close'); readfile($filenameReal); exit; } $EUA_languages = array( // our names for lang= to meteoalarm.eu names for lang= // the uncommented ones are supported by the WD/AJAX/PHP World-ML template set 'en' => 'en_UK', // english 'ct' => 'ca_ES', // català // 'xx' => 'ce_CZ', // ceština 'dk' => 'da_DK', // dansk 'de' => 'de_GE', // deutsch 'es' => 'es_ES', // español // 'xx' => 'ee_EE', // eesti // 'xx' => 'eu_VA', // euskera 'fr' => 'fr_FR', // français // 'xx' => 'ga_UK', // galego // 'xx' => 'hr_HR', // hrvatski // 'xx' => 'is_IS', // íslenska 'it' => 'it_IT', // italiano // 'xx' => 'li_LT', // lietuviu // 'xx' => 'la_LV', // latviešu 'hu' => 'ma_HU', // magyar // 'xx' => 'ma_MT', // malti 'nl' => 'ne_NL', // nederlands 'no' => 'no_NO', // norsk 'pl' => 'po_PL', // polski 'pt' => 'po_PT', // português 'ro' => 'ro_RO', // româna // 'xx' => 'cp_RS', // russian // 'xx' => 'sl_SI', // slovenšcina // 'xx' => 'sl_SK', // slovencina 'fi' => 'su_FI', // suomi 'se' => 'sv_SE', // svenska 'el' => 'gr_GR', // greek ); $EUA_lang = $EUA_languages[$Lang]; if (isset($_REQUEST['lang'])) { // $tlang = strtolower($_REQUEST['lang']); if (isset($EUA_languages[$tlang])) { $EUA_lang = $EUA_languages[$tlang]; $Lang = $tlang; //$Lang = $tlang; } } print "\n"; $EUA_URL = preg_replace('|lang=[^&]+|',"lang=$EUA_lang",$EUA_URL); $EUAcacheName = preg_replace('|\.txt$|',"-$Lang.txt",$EUAcacheName); $EUA_URLLink = htmlspecialchars($EUA_URL); // Translations if(($Lang == "dk") or ($Lang == '')) { $intensity = array("Vind", "Sne/Isslag", "Torden", "Skovbrande","Tåge","Ekstremt høje temperaturer","Ekstremt lave temperaturer","Forhøjet vandstand ved kysten","Laviner","Regn"); $levels = array("","Gul","Orange","Rød"); $requiredNoteEUA = '
Warning data courtesy of and Copyright © EUMETNET-MeteoAlarm. Time delays between this website and the www.meteoalarm.eu website are possible, for the most up to date information about alert levels as published by the participating National Meteorological Services please use www.meteoalarm.eu. Local data provided by Finnish Meteorological Institute. Used with permission.
'; } else if($Lang == "se") { $intensity = array("Vind", "Snö/Is", "Åska", "Skogsbrand","Dimma","Extremt hög temperatur","Extremt låg temperatur","Kusthändelse","Laviner","Regn"); $levels = array("","Gul","Orange","Röd"); $requiredNoteEUA = '
Warning data courtesy of and Copyright © EUMETNET-MeteoAlarm. Time delays between this website and the www.meteoalarm.eu website are possible, for the most up to date information about alert levels as published by the participating National Meteorological Services please use www.meteoalarm.eu. Local data provided by Finnish Meteorological Institute. Used with permission.
'; } else if($Lang == "no") { $intensity = array("Vind", "Snø/Is", "Torden", "Skogbrann","Tåke","Ekstremt høy temperatur","Ekstremt lav temperatur","Kysthendelse","Snøskred","Regn"); $levels = array("","Gul","Orange","Rød"); $requiredNoteEUA = '
Warning data courtesy of and Copyright © EUMETNET-MeteoAlarm. Time delays between this website and the www.meteoalarm.eu website are possible, for the most up to date information about alert levels as published by the participating National Meteorological Services please use www.meteoalarm.eu. Local data provided by Finnish Meteorological Institute. Used with permission.
'; } else if($Lang == "en") { $intensity = array("Wind", "Snow/Ice", "Thunderstorms", "Forestfire","Fog","Extreme high temperature","Extreme low temperature","Coastal Event","Avalanches","Rain"); $levels = array("","Yellow","Orange","Red"); $requiredNoteEUA = '
Warning data courtesy of and Copyright © EUMETNET-MeteoAlarm. Time delays between this website and the www.meteoalarm.eu website are possible, for the most up to date information about alert levels as published by the participating National Meteorological Services please use www.meteoalarm.eu. Local data provided by Finnish Meteorological Institute. Used with permission.
'; } else if($Lang == "nl") { $intensity = array("Wind", "Sneeuw/IJzel/Bevriezing", "Onweer", "Bos- en heidebranden","Mist","Extreme hitte","Extreme koude","Kustbedreiging","Lawines","Regen"); $levels = array("","Geel","Oranje","Rood"); $requiredNoteEUA = '
Warning data courtesy of and Copyright © EUMETNET-MeteoAlarm. Time delays between this website and the www.meteoalarm.eu website are possible, for the most up to date information about alert levels as published by the participating National Meteorological Services please use www.meteoalarm.eu. Local data provided by Finnish Meteorological Institute. Used with permission.
'; } else if($Lang == "fi") { $intensity = array("Tuuli", "Lumi/Jää/Keli", "Ukkonen", "Metsäpalo","Sumu","Poikkeuksellisen korkea lämpötila","Poikkeuksellisen alhainen lämpötila","Rannikkoalueiden vaarat","Lumivyöry","Sade"); $levels = array("","Keltainen","Oranssi","Punainen"); $requiredNoteEUA = '
Varoitustiedot tuottaa ja on copyright © EUMETNET-MeteoAlarm. Viivästyksiä tämän websivun ja www.meteoalarm.eu:n välillä saattaa ajoittain esiintyä, tuoreimmat tiedot voimassa olevista varoituksista julkaisee kansalliset ilmatieteen laitkoset sivulla www.meteoalarm.eu. Suomen varoitukset tuottaa Ilmatieteen laitos. Käytetty luvalla.
'; } else { $intensity = array("Vind", "Snö/Is", "Åska", "Skogsbrand","Dimma","Extremt hög temperatur","Extremt l åg temperatur","Kusthändelse","Laviner","Regn"); $levels = array("","Gul","Orange","Röd"); $requiredNoteEUA = '
Varningarna utfärdas av och är copyright © EUMETNET-MeteoAlarm. Fördröjning mellan denna websida och the www.meteoalarm.eu är möjliga, de nyaste uppgifterna on aktiva varningar från de nationella Meteorologiska instituten går att få på www.meteoalarm.eu. Lokal data för Finland produceras av Meteorologiska institutet. Använt med lov.
'; } // Translations end $wxicon = array("wf_01.jpg","wf_02.jpg","wf_03.jpg","wf_08.jpg","wf_04.jpg","wf_05.jpg","wf_06.jpg","wf_27.jpg","wf_09.jpg","wf_010.jpg"); $levelicon = array("lvlbox1.gif","lvlbox2.gif","lvlbox3.gif","lvlbox4.gif"); if (isset($_REQUEST['debug'])) {$doDebug = false; } else {$doDebug = true; } print "\n\n"; // You can now force the cache to update by adding ?force=1 to the end of the URL if ( empty($_REQUEST['force']) ) $_REQUEST['force']="0"; $Force = $_REQUEST['force']; if ($Force==1) { $html = fetchEUAUrlWithoutHanging($EUA_URL,$EUAcacheName); print "\n"; $fp = fopen($EUAcacheName, "w"); if($fp) { $write = fputs($fp, $html); fclose($fp); } else { print "\n"; } } // refresh cached copy of page if needed // fetch/cache code by Tom at carterlake.org if (file_exists($EUAcacheName) and filemtime($EUAcacheName) + $EUArefetchSeconds > time()) { $WhereLoaded = "from cache $EUAcacheName"; $html = implode('', file($EUAcacheName)); } else { $WhereLoaded = "from URL $EUA_URL"; $html = fetchEUAUrlWithoutHanging($EUA_URL); $fp = fopen($EUAcacheName, "w"); if($fp) { $write = fputs($fp, $html); fclose($fp); } else { print "\n"; } } print "\n"; if(strlen($html) < 50 ) { print "\n"; return; } // now slice it up // Get the table to use: preg_match_all('!]*(class|width)="([^"]+)"[^>]*>(.*)!Uis',$html,$betweenspan); if($doDebug) { print "\n"; } $cTypes = $betweenspan[1]; // contains 'class' or 'width' $cNames = $betweenspan[2]; // contains the class="(.*)" or width="(.*)" values $cData = $betweenspan[3]; // contains the (.*) data area $EUAregionName = ''; $EUAwarning = ''; $moreInfo = 'More...'; if($doDebug) { // print "\n"; // print "\n"; print "\n"; } for ($idx = 0;$idx < count($cData);$idx++) { // loop over the parts to extract the data for use if (preg_match_all('|\s*

(.*)

|Uis',$cData[$idx],$matches) ) { // print "\n"; if(isset($matches[0]) and count($matches[0]) > 0) { // take the last entry $i = count($matches[0]) -1; $moreInfo = '
' . trim($matches[2][$i]).''; if ($doDebug) { print "\n"; } } } } // $EUAregionName = 'MeteoAlarm.eu '. preg_replace('| |',"",strip_tags($cData[0])); $EUAwarning = ''."\n"; preg_match_all('|
(.*)\t
|Uis',$cData[1],$warnboxes); if ($doDebug) { print "\n"; } for ($idx = 0;$idx < count($warnboxes[1]);$idx++) { // loop over the warning box notices $rawle = ''; $leic = ''; $rawic = ''; $wxic = ''; $rawWarning = trim($warnboxes[1][$idx]); if ($doDebug) { print "\n"; } $EUAwarning .= "\n"; preg_match('|\n"; } preg_match_all('|
(.*)
|Uis',$rawWarning,$matches); if($doDebug) { print "\n"; } // wxicon preg_match_all('|(.*)|Uis',$matches[0][1],$ic); $rawic = str_replace(" ",'',$ic[1][0]); $wxic = str_replace($intensity, $wxicon, $rawic); if($wxic <> '') { $wxic = '
'; } // level $rawle = str_replace(" ",'',$ic[1][1]); $leic = str_replace($levels, $levelicon, trim($rawle)); if($wxic <> '') { $acva = true; $leic = ''; } else { $leic = ''; } $warnTxt = ''; foreach ($matches[2] as $i => $txt) { $t = strip_tags($txt,''); if (strlen($t)>0) {$warnTxt .= $t . "
\n";} } if ($doDebug) { print "\n"; } if($isFIN == true && $acva == true) { $strip = explode(")", $warnTxt); if($Lang == "en") { $warnTxt = $strip[0].')'; } elseif($Lang == "en") { $warnTxt = $strip[1].')'; } else { $warnTxt = $strip[2].')'; } } $EUAwarning .= '
'."\n"; $EUAwarning .= ''."\n"; $EUAwarning .= " \n"; } $EUAwarning .= "
'.$leic.' '.$wxic.' '.utf8_decode($warnTxt).'
\n"; if(($acva == true && $frontpage == true) || $frontpage == false) { print "

$EUAregionName

\n"; print "$EUAwarning"; } else { $requiredNoteEUA = false; } return; // ----------------------------functions ----------------------------------- function fetchEUAUrlWithoutHanging($url) // thanks to Tom at Carterlake.org for this script fragment { // Set maximum number of seconds (can have floating-point) to wait for feed before displaying page without feed $numberOfSeconds=4; // Suppress error reporting so Web site visitors are unaware if the feed fails error_reporting(0); // Extract resource path and domain from URL ready for fsockopen $url = str_replace("http://","",$url); $urlComponents = explode("/",$url); $domain = $urlComponents[0]; $resourcePath = str_replace($domain,"",$url); // Establish a connection $socketConnection = fsockopen($domain, 80, $errno, $errstr, $numberOfSeconds); if (!$socketConnection) { // You may wish to remove the following debugging line on a live Web site print("\n"); } // end if else { $xml = ''; fputs($socketConnection, "GET $resourcePath HTTP/1.1\r\nHost: $domain\r\nConnection: Close\r\n\r\n"); // Loop until end of file while (!feof($socketConnection)) { $xml .= fgets($socketConnection, 4096); } // end while fclose ($socketConnection); } // end else return($xml); } // end function // ---------------------------------------------------------- ?>