2018-08-04 10:53:24 +02:00
< ? php
/*
* PHP Frontend for pocsag monitor
*
* Copyright ( C ) 2004 - 2005
* Manuel Weiser ( manuelw @ fire - devils . org )
*
* 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 , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software
* Foundation , Inc . , 675 Mass Ave , Cambridge , MA 0213 9 , USA .
*/
2018-08-04 11:33:52 +02:00
$result = mysqli_query ( " SELECT u_meldung, u_text, u_farbe, DATE_FORMAT(u_lastcheck, '%Y%m%d%H%i%s') AS u_lastcheck, DATE_FORMAT(u_lastchange, '%Y%m%d%H%i%s') AS u_lastchange FROM unwetter WHERE id = '1' " ) or die ( mysqli_error ());
$row = mysqli_fetch_array ( $result );
2018-08-04 10:53:24 +02:00
if ( ( $timestampnow - $row [ " u_lastcheck " ]) > ( $uw_checktime * 100 ) && $_GET [ " nooutput " ] == 1 )
{
// if( $lines = file('http://www.dwd.de/de/WundK/Warnungen/zeige.php?ID='.$uw_landkreis.'#O') )
if ( $lines = file ( 'http://www.dwd.de/dyn/app/ws/html/reports/' . $uw_landkreis . '_warning_de.html' ) )
{
// Durchgehen des Arrays und Anzeigen des HTML Source inkl. Zeilennummern
if ( is_array ( $lines ) )
{
foreach ( $lines as $line_num => $line )
{
if ( $line_num == 34 && htmlspecialchars ( substr ( $line , 75 , 6 )) )
{
$unwetter_aktiv = 1 ;
if ( htmlspecialchars ( substr ( $line , 75 , 6 )) == " D90202 " ) { $unwetter_status = " Warnung vor extremem Unwetter " ; $unwetter_farbe = " #D90202 " ; }
if ( htmlspecialchars ( substr ( $line , 75 , 6 )) == " FF0000 " ) { $unwetter_status = " Unwetterwarnung " ; $unwetter_farbe = " #FF6B39 " ; }
if ( htmlspecialchars ( substr ( $line , 75 , 6 )) == " FFB599 " ) { $unwetter_status = " Vorwarnung zur Unwetterwarnung " ; $unwetter_farbe = " #FFB599 " ; }
if ( htmlspecialchars ( substr ( $line , 75 , 6 )) == " FA9600 " ) { $unwetter_status = " Warnung vor markantem Wetter " ; $unwetter_farbe = " #FFD553 " ; }
if ( htmlspecialchars ( substr ( $line , 75 , 6 )) == " FFFF00 " ) { $unwetter_status = " Wetterwarnung " ; $unwetter_farbe = " #F0F805 " ; }
if ( htmlspecialchars ( substr ( $line , 75 , 6 )) == " 6F6FFF " ) { $unwetter_status = " Seewetterwarnung " ; $unwetter_farbe = " #6F6FFF " ; }
}
if ( $unwetter_aktiv == 1 && $line_num > 36 && $line_num < 56 )
{
$unwetter_meldung .= $line ;
}
2018-08-04 11:33:52 +02:00
// Zum Pr<50> fen der Ausgabe deaktivieren
2018-08-04 10:53:24 +02:00
//echo "Line #<b>{$line_num}</b> : " . htmlspecialchars($line) . "<br>\n";
}
// Text von HTML Tags reinigen
$unwetter_meldung = htmlCode_message ( $unwetter_meldung );
//$unwetter_meldung = clean_htmlCode($unwetter_meldung);
//$unwetter_meldung = stripslashes($unwetter_meldung);
//$unwetter_meldung = strip_tags($unwetter_meldung, '<br>');
//echo '<br>--------------<br>msg: '.$unwetter_meldung;
}
}
else
{
$unwetter_status = 'keine Verbindung !!!' ;
$unwetter_farbe = '#FFFFFF' ;
2018-08-04 11:33:52 +02:00
$unwetter_meldung = 'Verbindung zu dwd.de nicht m<> glich !' ;
2018-08-04 10:53:24 +02:00
}
// Wenn noch kein Eintrag in DB existiert
if ( empty ( $row [ " u_lastcheck " ]) )
{
2018-08-04 11:33:52 +02:00
mysqli_query ( " INSERT INTO unwetter (id, u_meldung, u_text, u_farbe, u_lastchange) VALUES ('1', ' $unwetter_status ', ' $unwetter_meldung ', ' $unwetter_farbe ', ' $timestampnow ') " ) or die ( mysqli_error ());
2018-08-04 10:53:24 +02:00
}
// Wenn bereits Eintrag vorhanden und Checktime erreicht
if ( $unwetter_meldung == $row [ " u_text " ] )
{
2018-08-04 11:33:52 +02:00
mysqli_query ( " UPDATE unwetter SET u_lastcheck=' $timestampnow ' WHERE id = '1' " ) or die ( mysqli_error ());
2018-08-04 10:53:24 +02:00
}
else
{
2018-08-04 11:33:52 +02:00
mysqli_query ( " UPDATE unwetter SET u_meldung=' $unwetter_status ', u_text=' $unwetter_meldung ', u_farbe=' $unwetter_farbe ', u_lastcheck=' $timestampnow ', u_lastchange=' $timestampnow ' WHERE id = '1' " ) or die ( mysqli_error ());
2018-08-04 10:53:24 +02:00
}
}
2018-08-04 11:33:52 +02:00
// Ausgabe f<> r User erzeugen
2018-08-04 10:53:24 +02:00
if ( ! empty ( $row [ " u_meldung " ]) && $_GET [ " nooutput " ] != '1' )
{
$uw_show_link = '<a href="javascript:animatedcollapse.toggle(\'wetter\')"><font style="background-color:#FFFFFF;"> toggle </font></a>' ;
$uw_warntime = time_format ( get_time ( $row [ " u_lastchange " ]));
$uw_text = $row [ " u_text " ];
// Neu markieren wenn ungelesen
if ( $_SESSION [ " last_seen " ] <= $row [ " u_lastchange " ] ) $_SESSION [ " uw_isnew " ] = 'neu' ;
eval ( " \$ unwetter_field .= \" " . gettemplate ( $template_dir . " body_unwetter " ) . " \" ; " );
}
?>