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 .
*/
require ( 'config.inc.php' );
2018-08-04 15:49:43 +02:00
if ( ! isset ( $_SESSION [ " querystring " ])) $_SESSION [ " querystring " ] = " " ;
2018-08-04 10:53:24 +02:00
if ( $_SERVER [ 'QUERY_STRING' ] != $_SESSION [ " querystring " ] )
{
//$_SESSION["lastupdate"] = "";
$_SESSION [ " online_users " ] = " " ;
$_SESSION [ " querystring " ] = $_SERVER [ 'QUERY_STRING' ];
}
// Filter Datum/Zeit erstellen
2018-08-04 15:49:43 +02:00
if ( ! isset ( $_GET [ " filter " ]) || $_GET [ " filter " ] == 1 )
2018-08-04 10:53:24 +02:00
{
$show_filter = 1 ;
}
else
{
$filter = $_GET [ " filter " ];
}
2018-08-05 22:37:33 +02:00
if ( ! isset ( $_SESSION [ " lastupdate " ])) $_SESSION [ " lastupdate " ] = " " ;
2018-08-04 19:22:23 +02:00
if ( ! isset ( $show_filter )) $show_filter = " " ;
2018-08-04 15:49:43 +02:00
if ( $show_filter == 1 && $_SESSION [ " lastupdate " ] == " " && ! isset ( $_GET [ " clean " ]) ) {
$show_filter = filter_zeit ( 1 );
2018-08-04 10:53:24 +02:00
$show_filter = " WHERE a.zeit > ' $show_filter ' " ;
}
2018-08-04 15:49:43 +02:00
elseif ( $show_filter == 1 && $_SESSION [ " lastupdate " ] != " " && ! isset ( $_GET [ " clean " ]) ) {
2018-08-04 10:53:24 +02:00
$show_filter = " WHERE a.num > " . $_SESSION [ " lastupdate " ];
2018-08-04 15:49:43 +02:00
}
elseif ( $show_filter == 1 && $_SESSION [ " lastupdate " ] != " " && isset ( $_GET [ " clean " ]) && $_GET [ " clean " ] == " yes " ) {
$show_filter = filter_zeit ( 1 );
2018-08-04 10:53:24 +02:00
$show_filter = " WHERE a.zeit > ' $show_filter ' " ;
}
2018-08-04 17:21:54 +02:00
else { //if( $show_filter != 1 ) {
2018-08-04 19:22:23 +02:00
$show_filter = filter_zeit (( isset ( $filter )) ? $filter : 1 );
2018-08-04 10:53:24 +02:00
$show_filter = " WHERE a.zeit > ' $show_filter ' " ;
}
/////////
2018-08-04 15:49:43 +02:00
if ( ! isset ( $_GET [ " org_filter " ])) $_GET [ " org_filter " ] = " " ;
2018-08-04 10:53:24 +02:00
if ( $_GET [ " org_filter " ] == 'ff' )
{
$sql_org_filter = 'AND (org = "BF" OR org = "FF" OR org = "THW")' ;
}
elseif ( $_GET [ " org_filter " ] == 'rd' )
{
$sql_org_filter = 'AND org = "RD"' ;
}
else
{
$sql_org_filter = '' ;
}
$_SESSION [ " orgfiltered " ] = $sql_org_filter ;
$show_filter = $show_filter . ' ' . $sql_org_filter ;
//
// Daten f¸ r Formatierung holen und in array->session schreiben
2018-08-04 19:22:23 +02:00
if ( ( ! isset ( $_SESSION [ " formatierung " ]) || $_SESSION [ " formatierung " ] == " " ) && ( ! isset ( $_GET [ " nooutput " ]) || $_GET [ " nooutput " ] == " " ) )
2018-08-04 10:53:24 +02:00
{
2018-08-04 15:49:43 +02:00
$result = mysqli_query ( $dbconn , " SELECT id, bg_farbe, text_farbe, text_format, text_groesse, text_groesse_text FROM formatierung ORDER BY id ASC " ) or die ( mysqli_error ( $dbconn ));
2018-08-04 11:33:52 +02:00
while ( $row = mysqli_fetch_array ( $result ))
2018-08-04 10:53:24 +02:00
{
$formatierung [ $row [ " id " ]] = array (
" bg_farbe " => $row [ " bg_farbe " ],
" text_farbe " => $row [ " text_farbe " ],
" text_format " => $row [ " text_format " ],
" text_groesse " => $row [ " text_groesse " ],
" text_groesse_text " => $row [ " text_groesse_text " ]
);
$_SESSION [ " formatierung " ] = $formatierung ;
}
} else {
$formatierung = $_SESSION [ " formatierung " ];
}
//
// Auslesen pocsag
//
2018-08-04 11:50:40 +02:00
$result = mysqli_query ( $dbconn , " SELECT a.num, a.adresse AS adresse_neu, a.bezeichnung AS bezeichnung_neu, a.text, DATE_FORMAT(a.zeit, '%Y%m%d%H%i%s') AS zeit, a.funktion, a.REC_TYP, a.done,
2018-08-04 10:53:24 +02:00
b . adresse , b . formatierung_id , b . bezeichnung ,
d . id AS org_id , d . org_name , d . org , d . alarm_count , d . last_alarm
FROM dme a
LEFT JOIN ric_zvei b ON b . adresse = a . adresse
LEFT JOIN organisation d ON d . id = b . org_id
$show_filter
2018-08-04 15:49:43 +02:00
ORDER BY a . zeit DESC " ) or die (mysqli_error( $dbconn ));
2018-08-04 11:33:52 +02:00
while ( $row = mysqli_fetch_array ( $result ))
2018-08-04 10:53:24 +02:00
{
2018-08-04 15:49:43 +02:00
//echo "<br>-----------";
if ( ! isset ( $_GET [ " filter " ]) || $_GET [ " filter " ] == 1 || ( isset ( $_GET [ " clean " ]) && $_GET [ " clean " ] == " yes " ) )
2018-08-04 10:53:24 +02:00
{
if ( $row [ " num " ] > $_SESSION [ " lastupdate " ] ) $_SESSION [ " lastupdate " ] = $row [ " num " ];
}
$bezeichnung = $row [ " bezeichnung " ];
// Tageswechsel ausgeben
2018-08-04 15:49:43 +02:00
if ( isset ( $lastday ) && get_date ( $row [ " zeit " ]) != $lastday )
2018-08-04 10:53:24 +02:00
{
$tageswechsel = get_timestamp ( str_replace ( " - " , " " , date_dbformat ( $lastday )) . " 000000 " );
//$nextday = '
$show [ $tageswechsel ] .= '
< tr >
2018-08-04 19:22:23 +02:00
< td colspan = " 5 " bgcolor = " black " >< span style = " color:white;font-size:16px;font-weight:bold " >& nbsp ; Tageswechsel : '.get_date_long($row["zeit"]).' </ span ></ td >
2018-08-04 10:53:24 +02:00
</ tr >
' ;
}
else
{
$nextday = '' ;
}
$lastday = get_date ( $row [ " zeit " ]);
// Eintragen der Bezeichnung wenn Bezeichnung in monrc vorhanden und update 1
if ( $update_adresse_monrc && ! $bezeichnung )
{
// prfen ob die ric schon vorhanden ist, wenn nicht eintragen
2018-08-04 11:50:40 +02:00
$result_check = mysqli_query ( $dbconn , " SELECT id FROM ric_zvei WHERE adresse= " . $row [ " adresse_neu " ]);
2018-08-04 11:33:52 +02:00
$row_check = mysqli_fetch_array ( $result_check );
2018-08-04 10:53:24 +02:00
if ( ! $row_check [ " id " ] )
{
2018-08-04 15:49:43 +02:00
$result_check = mysqli_query ( $dbconn , " INSERT INTO ric_zvei (adresse, bezeichnung, rec_typ, formatierung_id) VALUES (' $row[adresse_neu] ', ' $row[bezeichnung_neu] ', ' $row[REC_TYP] ', '0') " ) or die ( mysqli_error ( $dbconn ));
2018-08-04 10:53:24 +02:00
$bezeichnung = $row [ " bezeichnung_neu " ];
}
}
// Wenn unbekannte Ric Wert setzen
if ( ! $bezeichnung && ! $row [ " org_name " ] ) $bezeichnung = 'Unbekannt' ;
if ( ! $row [ " org_name " ] ) $row [ " org_name " ] = $row [ " adresse_neu " ];
// Wenn ZVEI
if ( $row [ " REC_TYP " ] == 'ZVEI' ) $row [ " funktion " ] = $row [ " text " ];
2018-08-04 17:21:54 +02:00
if ( isset ( $formatierung [ $row [ " formatierung_id " ]][ " bg_farbe " ])) $row [ " bg_farbe " ] = $formatierung [ $row [ " formatierung_id " ]][ " bg_farbe " ];
if ( isset ( $formatierung [ $row [ " formatierung_id " ]][ " text_farbe " ])) $row [ " text_farbe " ] = $formatierung [ $row [ " formatierung_id " ]][ " text_farbe " ];
if ( isset ( $formatierung [ $row [ " formatierung_id " ]][ " text_farbe_text " ])) $row [ " text_farbe_text " ] = $formatierung [ $row [ " formatierung_id " ]][ " text_farbe_text " ];
if ( isset ( $formatierung [ $row [ " formatierung_id " ]][ " bg_farbe_text " ])) $row [ " bg_farbe_text " ] = $formatierung [ $row [ " formatierung_id " ]][ " bg_farbe_text " ];
if ( isset ( $formatierung [ $row [ " formatierung_id " ]][ " text_groesse " ])) $row [ " text_groesse " ] = $formatierung [ $row [ " formatierung_id " ]][ " text_groesse " ];
if ( isset ( $formatierung [ $row [ " formatierung_id " ]][ " text_groesse_text " ])) $row [ " text_groesse_text " ] = $formatierung [ $row [ " formatierung_id " ]][ " text_groesse_text " ];
if ( isset ( $formatierung [ $row [ " formatierung_id " ]][ " text_format " ])) $row [ " text_format " ] = $formatierung [ $row [ " formatierung_id " ]][ " text_format " ];
2018-08-04 10:53:24 +02:00
// default Farben bestimmen
2018-08-04 15:49:43 +02:00
if ( ! isset ( $row [ " bg_farbe " ]) ) $row [ " bg_farbe " ] = 'white' ;
if ( ! isset ( $row [ " text_farbe " ]) ) $row [ " text_farbe " ] = 'black' ;
if ( ! isset ( $row [ " text_farbe_text " ]) ) $row [ " text_farbe_text " ] = 'black' ;
if ( ! isset ( $row [ " bg_farbe_text " ]) ) $row [ " bg_farbe_text " ] = '#CCCCCC' ;
if ( ! isset ( $row [ " text_groesse " ]) ) $row [ " text_groesse " ] = '13' ;
if ( ! isset ( $row [ " text_groesse_text " ]) ) $row [ " text_groesse_text " ] = '12' ;
2018-08-04 17:21:54 +02:00
if ( ! isset ( $row [ " text_format " ]) ) $row [ " text_format " ] = '1' ;
2018-08-04 10:53:24 +02:00
// pocsag in Array schreiben
//$thisday = $nextday.'
$thisday = '
< tr bgcolor = " '. $row["bg_farbe"] .' " >
< td width = " '. $pocsag_sp[1] .' " align = " center " >< span style = " color:white;font-size:'. $status_size .';font-weight:bold " > '.get_time($row["zeit"]).' & nbsp ; </ span ></ td >
< td width = " '. $pocsag_sp[2] .' " align = " center " >< span style = " color:'. $row["text_farbe"] .';font-size:'. $row["text_groesse"] .';font-weight:'. $row["text_format"] .' " > '.$row["org"].' </ span ></ td >
< td width = " '. $pocsag_sp[3] .' " align = " center " >< span style = " color:'. $row["text_farbe"] .';font-size:'. $row["text_groesse"] .';font-weight:'. $row["text_format"] .' " > '.$bezeichnung.' </ span ></ td >
< td >< span title = " '. $row["adresse"] .' " style = " color:'. $row["text_farbe"] .';font-size:'. $row["text_groesse"] .';font-weight:'. $row["text_format"] .' " > & nbsp ; & nbsp ; '.$row["org_name"].' </ span ></ td >
< td width = " '. $pocsag_sp[5] .' " >
< span style = " color:'. $row["text_farbe"] .';font-size:'. $row["text_groesse"] .';font-weight:'. $row["text_format"] .' " >& nbsp ; '.$row["funktion"].' </ span >
</ td >
</ tr >
' ;
// wenn das ne ZVEI ist keine Textzeile ausgeben
if ( $row [ " REC_TYP " ] != " ZVEI " )
{
$thisday .= '
< tr bgcolor = " '. $row["bg_farbe_text"] .' " >
< td colspan = " 5 " >
< span style = " color:'. $row["text_farbe_text"] .';font-size:'. $row["text_groesse_text"] .' " > '.$row["text"].' </ span >
</ td >
</ tr >
' ;
}
// Falls sich Zeit letzter Status mit pocsag berschneiden um eins erhÔøΩen
$show_time = get_timestamp ( $row [ " zeit " ]);
2018-08-04 15:49:43 +02:00
if ( isset ( $show ) )
2018-08-04 10:53:24 +02:00
{
while ( array_key_exists ( $show_time , $show ) )
{
$show_time = ( $show_time + 1 );
}
}
$show [ $show_time ] = $thisday ;
}
/**************************/
// Datenbank schliessen
//
2018-08-04 11:33:52 +02:00
mysqli_close ( $dbconn );
2018-08-04 10:53:24 +02:00
// Ausgabe für Ajax
echo "
< html >
" ;
//if ($new_unwetter == 1) echo '<meta http-equiv="refresh" content="1">';
2018-08-04 15:49:43 +02:00
if ( isset ( $show ) )
2018-08-04 10:53:24 +02:00
{
echo '<table width="98%" border="0" cellspacing="1" cellpadding="0" bgcolor="#000000" valign="top">' ;
foreach ( $show as $item )
{
echo $item ;
}
echo '</table>' ;
}
echo "
</ html >
" ;
?>