232 lines
9.7 KiB
PHP
Executable File
232 lines
9.7 KiB
PHP
Executable File
<?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 02139, USA.
|
||
*/
|
||
|
||
require('config.inc.php');
|
||
|
||
$_SESSION["load_complete"] = "";
|
||
$_SESSION["lastupdate"] = "";
|
||
$_SESSION["online_users"] = "";
|
||
|
||
/**************************/
|
||
// Seite zusammenstellen
|
||
//
|
||
|
||
//
|
||
// Startseite
|
||
if( !isset($_GET["do"]) )
|
||
{
|
||
|
||
$result = mysqli_query($dbconn, "SELECT a_alarmmail, a_alarmmail2sms, wap_pass, wap_show, wap_rows, wap_def_orgfilter, wap_def_statfilter FROM admin_users WHERE id = '$_SESSION[userid]'") or die (mysqli_error($dbconn));
|
||
$row = mysqli_fetch_array($result);
|
||
|
||
$wap_pass = $row["wap_pass"];
|
||
|
||
( $row["a_alarmmail2sms"] == 1 ) ? $checked = 'checked' : $checked="";
|
||
$mailform_checkbox = '<input type="checkbox" name="mail2sms" value="1" '.$checked.'>';
|
||
$mailform_mail = '<input name="alarmmail" type="text" id="alarmmail" value="'.$row["a_alarmmail"].'">';
|
||
|
||
$select_wap_show = '
|
||
<select name="wap_show" id="wap_show">
|
||
<option value="0"'; if( $row["wap_show"] == '0' ) $select_wap_show .= 'selected'; $select_wap_show .= '>aktueller Tag</option>
|
||
<option value="1"'; if( $row["wap_show"] == '1' ) $select_wap_show .= 'selected'; $select_wap_show .= '> 1 Stunde</option>
|
||
<option value="6"'; if( $row["wap_show"] == '6' ) $select_wap_show .= 'selected'; $select_wap_show .= '> 6 Stunden</option>
|
||
<option value="12"'; if( $row["wap_show"] == '12' ) $select_wap_show .= 'selected'; $select_wap_show .= '>12 Stunden</option>
|
||
<option value="18"'; if( $row["wap_show"] == '18' ) $select_wap_show .= 'selected'; $select_wap_show .= '>18 Stunden</option>
|
||
<option value="24"'; if( $row["wap_show"] == '24' ) $select_wap_show .= 'selected'; $select_wap_show .= '>24 Stunden</option>
|
||
<option value="48"'; if( $row["wap_show"] == '48' ) $select_wap_show .= 'selected'; $select_wap_show .= '>48 Stunden</option>
|
||
</select>
|
||
';
|
||
|
||
$select_wap_rows = '
|
||
<select name="wap_rows" id="wap_rows">
|
||
<option value="5"'; if( $row["wap_rows"] == '5' ) $select_wap_rows .= 'selected'; $select_wap_rows .= '> 5 Meldungen</option>
|
||
<option value="10"'; if( $row["wap_rows"] == '10' ) $select_wap_rows .= 'selected'; $select_wap_rows .= '>10 Meldungen</option>
|
||
<option value="15"'; if( $row["wap_rows"] == '15' ) $select_wap_rows .= 'selected'; $select_wap_rows .= '>15 Meldungen</option>
|
||
<option value="20"'; if( $row["wap_rows"] == '20' ) $select_wap_rows .= 'selected'; $select_wap_rows .= '>20 Meldungen</option>
|
||
<option value="25"'; if( $row["wap_rows"] == '25' ) $select_wap_rows .= 'selected'; $select_wap_rows .= '>25 Meldungen</option>
|
||
<option value="30"'; if( $row["wap_rows"] == '30' ) $select_wap_rows .= 'selected'; $select_wap_rows .= '>30 Meldungen</option>
|
||
</select>
|
||
';
|
||
|
||
$select_wap_orgfilter = '
|
||
<select name="wap_orgfilter" id="wap_orgfilter">
|
||
<option value="all"'; if( $row["wap_def_orgfilter"] == 'all' ) $select_wap_orgfilter .= 'selected'; $select_wap_orgfilter .= '>Alles</option>
|
||
<option value="ff"'; if( $row["wap_def_orgfilter"] == 'ff' ) $select_wap_orgfilter .= 'selected'; $select_wap_orgfilter .= '>Feuerwehr</option>
|
||
<option value="rd"'; if( $row["wap_def_orgfilter"] == 'rd' ) $select_wap_orgfilter .= 'selected'; $select_wap_orgfilter .= '>Rettungsdienst</option>
|
||
</select>
|
||
';
|
||
|
||
$select_wap_statfilter = '
|
||
<select name="wap_statfilter" id="wap_statfilter">
|
||
<option value="0"'; if( $row["wap_def_statfilter"] == '0' ) $select_wap_statfilter .= 'selected'; $select_wap_statfilter .= '>Status aus</option>
|
||
<option value="1"'; if( $row["wap_def_statfilter"] == '1' ) $select_wap_statfilter .= 'selected'; $select_wap_statfilter .= '>Status ein</option>
|
||
</select>
|
||
';
|
||
|
||
$select_search_ric = '
|
||
<select name="search_ric" id="search_ric">'
|
||
;
|
||
|
||
$result = mysqli_query($dbconn, "SELECT id, org_name, org FROM organisation WHERE org != '' ORDER BY org ASC, org_name ASC") or die (mysqli_error($dbconn));
|
||
while($row = mysqli_fetch_array($result))
|
||
{
|
||
$select_search_ric .= '
|
||
<option value="'.$row["id"].'">'.$row["org"].' '.$row["org_name"].'</option>
|
||
';
|
||
}
|
||
|
||
$select_search_ric .= '
|
||
</select>
|
||
';
|
||
|
||
$result = mysqli_query($dbconn, "SELECT a.*,
|
||
b.adresse, b.formatierung_id, b.bezeichnung, b.rec_typ,
|
||
c.bg_farbe, c.text_farbe, c.text_format, c.text_groesse, c.text_groesse_text,
|
||
d.org_name, d.org
|
||
FROM alarm2mail a
|
||
LEFT JOIN ric_zvei b ON b.adresse = a.adresse
|
||
LEFT JOIN formatierung c ON c.id = b.formatierung_id
|
||
LEFT JOIN organisation d ON d.id = b.org_id
|
||
WHERE a.userid = '$_SESSION[userid]' ORDER BY org ASC, org_name ASC, rec_typ ASC") or die (mysqli_error($dbconn));
|
||
while($row = mysqli_fetch_array($result))
|
||
{
|
||
// Zeitfunktion
|
||
if( $row["time_from"] == '0' && $row["time_to"] == '0' )
|
||
{
|
||
$zeitfilter = 'immer';
|
||
}
|
||
else
|
||
{
|
||
$zeitfilter = time_format( $row["time_from"] ).' bis '.time_format( $row["time_to"] ).' Uhr';
|
||
}
|
||
|
||
if( !empty($row["stiwo"]) ) { $stiwo = "<span title=\"$row[stiwo]\">Stiwo</span>"; } else { $stiwo = ""; }
|
||
|
||
if (!isset($abos)) $abos="";
|
||
$abos .= '<tr>
|
||
<td bgcolor="'.$row["bg_farbe"].'" style="border-bottom-style:solid;border-bottom-width:thin;"><span style="font-family:Verdana;color:'.$row["text_farbe"].';font-size:'.$row["text_groesse"].' px;font-weight:'.$row["text_format"].'"> '.$row["org"].' '.$row["org_name"].' '.$row["bezeichnung"].' - '.$row["rec_typ"].'</span></td>
|
||
<td align="center" bgcolor="'.$row["bg_farbe"].'" style="border-bottom-style:solid;border-bottom-width:thin;">'.$stiwo.' </td>
|
||
<td align="center" bgcolor="'.$row["bg_farbe"].'" style="border-bottom-style:solid;border-bottom-width:thin;"><b>'.$zeitfilter.'</b></td>
|
||
<td style="border-bottom-style:solid;border-bottom-width:thin;"> <a href="'.$_SERVER["PHP_SELF"].'?do=abodel&id='.$row["id"].'"> löschen</a></td>
|
||
</tr>
|
||
';
|
||
}
|
||
|
||
// Seiteninhalt ausgeben
|
||
$page_middle="";
|
||
if (!isset($abos)) $abos="";
|
||
eval ("\$page_middle .= \"".gettemplate($template_dir."body_profil_alarmmail")."\";");
|
||
|
||
}
|
||
|
||
// Ric zum Abo w<>hlen
|
||
elseif( $_GET["do"] == 'abodet' )
|
||
{
|
||
|
||
for( $stunde = 0; $stunde <= 24; $stunde++ )
|
||
{
|
||
$select_time_filter .= '
|
||
<option value="'.$stunde.'">'.$stunde.':00</option>
|
||
';
|
||
}
|
||
|
||
$result = mysqli_query($dbconn, "SELECT id, org_name, org FROM organisation WHERE id = '$_REQUEST[search_ric]'") or die (mysqli_error($dbconn));
|
||
$row = mysqli_fetch_array($result);
|
||
|
||
$org_id = $row["id"];
|
||
$org = $row["org"];
|
||
$org_name = $row["org_name"];
|
||
|
||
$result = mysqli_query($dbconn, "SELECT id, adresse, bezeichnung, rec_typ FROM ric_zvei WHERE org_id = '$org_id'") or die (mysqli_error($dbconn));
|
||
while($row = mysqli_fetch_array($result))
|
||
{
|
||
$select_ric .= '<input name="abo_ric['.$i++.']" type="checkbox" value="'.$row["adresse"].'"> <b>'.$org.' '.$org_name.' '.$row["bezeichnung"].'</b> - '.$row["rec_typ"].'<br>';
|
||
}
|
||
|
||
// Seiteninhalt ausgeben
|
||
eval ("\$page_middle .= \"".gettemplate($template_dir."body_profil_alarmmail_select")."\";");
|
||
|
||
}
|
||
|
||
// Abo eintragen
|
||
elseif( $_GET["do"] == 'aboins' )
|
||
{
|
||
|
||
foreach( $_REQUEST["abo_ric"] AS $v )
|
||
{
|
||
// pr<70>fen ob der User diese Ric bereits Abonniert hat
|
||
$result = mysqli_query($dbconn, "SELECT id FROM alarm2mail WHERE userid = '$_SESSION[userid]' AND adresse = '$v'") or die (mysqli_error($dbconn));
|
||
$row = mysqli_fetch_array($result);
|
||
|
||
if( empty($row["id"]) )
|
||
{
|
||
$result = mysqli_query($dbconn, "INSERT INTO alarm2mail (adresse, userid, time_from, time_to, stiwo) VALUES ('$v', '$_SESSION[userid]', '$_REQUEST[alarm_time_filter_from]', '$_REQUEST[alarm_time_filter_to]', '$_REQUEST[alarm_stiwo]')") or die(mysqli_error($dbconn));
|
||
}
|
||
}
|
||
|
||
echo gohome($_SERVER["PHP_SELF"]);
|
||
|
||
}
|
||
|
||
// Abo l<>schen
|
||
elseif( $_GET["do"] == 'abodel' )
|
||
{
|
||
|
||
$result = mysqli_query($dbconn, "DELETE FROM alarm2mail WHERE id = '$_GET[id]' AND userid = '$_SESSION[userid]'") or die(mysqli_error($dbconn));
|
||
|
||
echo gohome($_SERVER["PHP_SELF"]);
|
||
|
||
}
|
||
|
||
// Alarmmail Form setzen
|
||
elseif( $_GET["do"] == 'setmailform' )
|
||
{
|
||
if( $_REQUEST["mail2sms"] == 1 ) { $setto = 1; } else { $setto = 0; }
|
||
|
||
$result = mysqli_query($dbconn, "UPDATE admin_users SET a_alarmmail2sms='$setto', a_alarmmail='$_REQUEST[alarmmail]' WHERE id = '$_SESSION[userid]'") or die(mysqli_error($dbconn));
|
||
|
||
echo gohome($_SERVER["PHP_SELF"]);
|
||
|
||
}
|
||
|
||
// Wap Einstellungen speichern
|
||
elseif( $_GET["do"] == 'setwap' )
|
||
{
|
||
$result = mysqli_query($dbconn, "UPDATE admin_users SET wap_show='$_REQUEST[wap_show]', wap_rows='$_REQUEST[wap_rows]', wap_pass='$_REQUEST[wap_pass]', wap_def_orgfilter='$_REQUEST[wap_orgfilter]', wap_def_statfilter='$_REQUEST[wap_statfilter]' WHERE id = '$_SESSION[userid]'") or die(mysqli_error($dbconn));
|
||
|
||
echo gohome($_SERVER["PHP_SELF"]);
|
||
}
|
||
|
||
/**************************/
|
||
// Ausgabe Rahmen
|
||
//
|
||
if( !isset($java_script)) $java_script="";
|
||
if( !isset($nav_org_filter)) $nav_org_filter="";
|
||
if( !isset($nav_filter)) $nav_filter="";
|
||
eval ("dooutput(\"".gettemplate($template_dir."rahmen")."\");");
|
||
|
||
/**************************/
|
||
// Datenbank schliessen
|
||
//
|
||
mysqli_close($dbconn);
|
||
?>
|