monitor-frontend/profile.php

226 lines
9.3 KiB
PHP
Raw Normal View History

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 02139, USA.
*/
require('config.inc.php');
$_SESSION["load_complete"] = "";
$_SESSION["lastupdate"] = "";
$_SESSION["online_users"] = "";
/**************************/
// Seite zusammenstellen
//
//
// Startseite
if( !$_GET["do"] )
{
$result = mysql_query("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 (mysql_error());
$row = mysql_fetch_array($result);
$wap_pass = $row["wap_pass"];
if( $row["a_alarmmail2sms"] == 1 ) $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 .= '>&nbsp;&nbsp;1 Stunde</option>
<option value="6"'; if( $row["wap_show"] == '6' ) $select_wap_show .= 'selected'; $select_wap_show .= '>&nbsp;&nbsp;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 .= '>&nbsp;&nbsp;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 = mysql_query("SELECT id, org_name, org FROM organisation WHERE org != '' ORDER BY org ASC, org_name ASC") or die (mysql_error());
while($row = mysql_fetch_array($result))
{
$select_search_ric .= '
<option value="'.$row["id"].'">'.$row["org"].' &nbsp;&nbsp;'.$row["org_name"].'</option>
';
}
$select_search_ric .= '
</select>
';
$result = mysql_query("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 (mysql_error());
while($row = mysql_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 = ""; }
$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"].'">&nbsp; '.$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.' &nbsp;</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;">&nbsp; <a href="'.$_SERVER["PHP_SELF"].'?do=abodel&id='.$row["id"].'">&nbsp;l&ouml;schen</a></td>
</tr>
';
}
// Seiteninhalt ausgeben
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 = mysql_query("SELECT id, org_name, org FROM organisation WHERE id = '$_REQUEST[search_ric]'") or die (mysql_error());
$row = mysql_fetch_array($result);
$org_id = $row["id"];
$org = $row["org"];
$org_name = $row["org_name"];
$result = mysql_query("SELECT id, adresse, bezeichnung, rec_typ FROM ric_zvei WHERE org_id = '$org_id'") or die (mysql_error());
while($row = mysql_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 = mysql_query("SELECT id FROM alarm2mail WHERE userid = '$_SESSION[userid]' AND adresse = '$v'") or die (mysql_error());
$row = mysql_fetch_array($result);
if( empty($row["id"]) )
{
$result = mysql_query("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(mysql_error());
}
}
echo gohome($_SERVER["PHP_SELF"]);
}
// Abo l<>schen
elseif( $_GET["do"] == 'abodel' )
{
$result = mysql_query("DELETE FROM alarm2mail WHERE id = '$_GET[id]' AND userid = '$_SESSION[userid]'") or die(mysql_error());
echo gohome($_SERVER["PHP_SELF"]);
}
// Alarmmail Form setzen
elseif( $_GET["do"] == 'setmailform' )
{
if( $_REQUEST["mail2sms"] == 1 ) { $setto = 1; } else { $setto = 0; }
$result = mysql_query("UPDATE admin_users SET a_alarmmail2sms='$setto', a_alarmmail='$_REQUEST[alarmmail]' WHERE id = '$_SESSION[userid]'") or die(mysql_error());
echo gohome($_SERVER["PHP_SELF"]);
}
// Wap Einstellungen speichern
elseif( $_GET["do"] == 'setwap' )
{
$result = mysql_query("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(mysql_error());
echo gohome($_SERVER["PHP_SELF"]);
}
/**************************/
// Ausgabe Rahmen
//
eval ("dooutput(\"".gettemplate($template_dir."rahmen")."\");");
/**************************/
// Datenbank schliessen
//
mysql_close($dbconn);
?>