monitor-frontend/index.php

312 lines
11 KiB
PHP
Executable File

<?php
require_once("config.inc.php");
// Filter Datum/Zeit erstellen
if( !$_GET["filter"] && !$_SESSION["filter"] )
{
$filter = 1;
}
elseif( !$_GET["filter"] && $_SESSION["filter"] )
{
$filter = $_SESSION["filter"];
}
elseif( $_GET["filter"] )
{
$filter = $_GET["filter"];
$_SESSION["filter"] = $_GET["filter"];
}
// Filter organisation
if( !$_GET["org_filter"] && !$_SESSION["org_filter"] )
{
$org_filter = '';
}
elseif( !$_GET["org_filter"] && $_SESSION["org_filter"] )
{
if( $_SESSION["org_filter"] == 'AND (org = "BF" OR org = "FF")' )
{
$org_filter = 'ff';
}
else
{
$org_filter = $_SESSION["org_filter"];
}
}
elseif( $_GET["org_filter"] && $_GET["org_filter"] != 'all' )
{
$org_filter = $_GET["org_filter"];
$_SESSION["org_filter"] = $_GET["org_filter"];
}
elseif( $_GET["org_filter"] == 'all' )
{
$org_filter = '';
$_SESSION["org_filter"] = '';
}
// Filter Status anzeigen
if( $_GET["stat"] == '' && !$_SESSION["stat"] )
{
$stat = '0';
}
elseif( $_GET["stat"] == '' && $_SESSION["stat"] )
{
$stat = $_SESSION["stat"];
}
elseif( $_GET["stat"] != '' )
{
$stat = $_GET["stat"];
$_SESSION["stat"] = $_GET["stat"];
}
// Wenn Aktualisierung ohne Ausgabe
if( $_GET["nooutput"] ) { $filter = 1; $stat = 1; }
$show_filter = filter_zeit($filter);
$show_filter = " WHERE a.zeit > '$show_filter' ";
$refresh = '
<input type=button name="refresh" value="Aktualisieren" onClick="history.go()">
';
$nav_org_filter = '
<select name="org_filter" onChange="MM_jumpMenu(\'parent\',this,0)">
<option value="'.$_SERVER["php_self"].'?filter='.$filter.'&org_filter=ff&stat=0"'; if( $org_filter == 'ff' && $stat == '0' ) $nav_org_filter .= 'selected'; $nav_org_filter .= '>Feuerwehr</option>
<option value="'.$_SERVER["php_self"].'?filter='.$filter.'&org_filter=rd&stat=0"'; if( $org_filter == 'rd' && $stat == '0' ) $nav_org_filter .= 'selected'; $nav_org_filter .= '>Rettungsdienst</option>
<option value="'.$_SERVER["php_self"].'?filter='.$filter.'&org_filter=all&stat=0"'; if( !$org_filter && $stat == '0' ) $nav_org_filter .= 'selected'; $nav_org_filter .= '>FW und RD</option>
</select>
';
$nav_filter = '
<select id="filter" name="filter" onChange="MM_jumpMenu(\'parent\',this,0)">
<option value="'.$_SERVER["php_self"].'?filter=48&org_filter='.$org_filter.'&stat='.$stat.'&aq='.$aq.'"'; if( $filter == 48 ) $nav_filter .= 'selected'; $nav_filter .= '>48</option>
<option value="'.$_SERVER["php_self"].'?filter=24&org_filter='.$org_filter.'&stat='.$stat.'&aq='.$aq.'"'; if( $filter == 24 ) $nav_filter .= 'selected'; $nav_filter .= '>24</option>
<option value="'.$_SERVER["php_self"].'?filter=10&org_filter='.$org_filter.'&stat='.$stat.'&aq='.$aq.'"'; if( $filter == 10 ) $nav_filter .= 'selected'; $nav_filter .= '>10</option>
<option value="'.$_SERVER["php_self"].'?filter=5&org_filter='.$org_filter.'&stat='.$stat.'&aq='.$aq.'"'; if( $filter == 5 ) $nav_filter .= 'selected'; $nav_filter .= '>5</option>
<option value="'.$_SERVER["php_self"].'?filter=2&org_filter='.$org_filter.'&stat='.$stat.'&aq='.$aq.'"'; if( $filter == 2 ) $nav_filter .= 'selected'; $nav_filter .= '>2</option>
<option value="'.$_SERVER["php_self"].'?filter=1&org_filter='.$org_filter.'&stat='.$stat.'&aq='.$aq.'"'; if( $filter == 1 ) $nav_filter .= 'selected'; $nav_filter .= '>1</option>
</select>
';
$java_script .= "
<script type=\"text/javascript\" language=\"javascript\">
function trim(txt){
return txt.replace(/^\s+|\s+$/g,\"\");
}
function toggleindicator(status){
//Diese Variable definiert wie lange der Indicator mindestens da sein soll.
var timetowait = 2100;
if(status=='off') {
window.setTimeout(toggleindicator(\"dooff\"),2100);
}else if (status=='dooff'){
document.getElementById(\"loading-indicator\").style.display='none';
} else {
document.getElementById(\"loading-indicator\").style.display='';
document.getElementById(\"loading-indicator\").style.position='absolute';
document.getElementById(\"loading-indicator\").style.left='40%';
document.getElementById(\"loading-indicator\").style.top='100px';
time = new Date().getTime();
}
}
var http_request = false;
var http_request2 = false;
function macheRequest(cleanCounter) {
var doreload = '5' // Realod in sek
var cleanIt = '600'; // Wann soll neu geladen werden in sek
autoclean = cleanIt / doreload;
doreload = doreload * 1000;
if( cleanCounter > 99999999) {
doreload = 5000;
}
if( cleanCounter >= autoclean ) {
var url = 'get.php?".$_SERVER['QUERY_STRING']."&clean=yes';
} else {
var url = 'get.php?".$_SERVER['QUERY_STRING']."';
}
http_request = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
http_request = new XMLHttpRequest();
} else if (window.ActiveXObject) { // IE
try {
http_request = new ActiveXObject(\"Msxml2.XMLHTTP\");
} catch (e) {
try {
http_request = new ActiveXObject(\"Microsoft.XMLHTTP\");
} catch (e) {}
}
}
if (!http_request) {
alert('Ende :( Kann keine XMLHTTP-Instanz erzeugen');
return false;
}
http_request.open('GET', url, true);
if( cleanCounter >= autoclean ) {
http_request.onreadystatechange = alertInhaltClean;
var cleanCounter = 1;
} else {
http_request.onreadystatechange = alertInhalt;
var cleanCounter = cleanCounter + 1;
}
http_request.send(null);
if (document.getElementById(\"filter\").options[5].selected == true) {
window.setTimeout(function() {macheRequest(cleanCounter);},doreload);
}
}
function alertInhalt() {
if (http_request.readyState == 4) {
var answer = http_request.responseText;
var answer = answer.replace(\"<html>\", \"\");
var answer = answer.replace(\"</html>\", \"\");
if (answer != '') {
if(document.getElementById(\"inhalt\").innerHTML != answer){
document.getElementById(\"inhalt\").innerHTML = answer + document.getElementById(\"inhalt\").innerHTML;
}
}
if(document.getElementById(\"loading-indicator\").style.display=='')
{
toggleindicator(\"off\");
}
}
}
function alertInhaltClean() {
if (http_request.readyState == 4) {
var answer = http_request.responseText;
var answer = answer.replace(\"<html>\", \"\");
var answer = answer.replace(\"</html>\", \"\");
if (answer != '') {
if(document.getElementById(\"inhalt\").innerHTML != answer){
document.getElementById(\"inhalt\").innerHTML = answer;
}
}
if(document.getElementById(\"loading-indicator\").style.display=='')
{
toggleindicator(\"off\");
}
}
}
/// second Request
function macheSecondaryRequest() {
var url = 'get_other.php';
http_request2 = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
http_request2 = new XMLHttpRequest();
} else if (window.ActiveXObject) { // IE
try {
http_request2 = new ActiveXObject(\"Msxml2.XMLHTTP\");
} catch (e) {
try {
http_request2 = new ActiveXObject(\"Microsoft.XMLHTTP\");
} catch (e) {}
}
}
if (!http_request2) {
alert('Ende :( Kann keine XMLHTTP-Instanz erzeugen');
return false;
}
http_request2.open('GET', url, true);
http_request2.onreadystatechange = alertSecondaryInhalt;
http_request2.send(null);
window.setTimeout(\"macheSecondaryRequest()\",5000);
}
function alertSecondaryInhalt() {
if (http_request2.readyState == 4) {
var answer = http_request2.responseText;
if (answer != '') {
var answer = answer.replace(\"<html>\", \"\");
var answer = answer.replace(\"</html>\", \"\");
var answerContents = answer.split(\"|\");
var answer_OnlUsers = trim(answerContents[0]);
var answer_Unwetter = trim(answerContents[1]);
var answer_Unwetter = answer_Unwetter.split(\"@\");
var answer_UserPM = trim(answerContents[2]);
if(document.getElementById(\"onlUsers\").innerHTML != answer_OnlUsers && answer_OnlUsers != \"\"){
document.getElementById(\"onlUsers\").innerHTML = answer_OnlUsers;
}
if(document.getElementById(\"Unwetter\").innerHTML != answer_Unwetter[1] && answer_Unwetter[1] != \"\"){
document.getElementById(\"Unwetter\").innerHTML = answer_Unwetter[0];
document.getElementById(\"UnwetterContent\").innerHTML = answer_Unwetter[1];
}
if(document.getElementById(\"PrivateMessage\").innerHTML != answer_UserPM && answer_UserPM != \"\"){
document.getElementById(\"PrivateMessage\").innerHTML = answer_UserPM;
} else {
document.getElementById(\"PrivateMessage\").innerHTML = \"\";
}
} else {
document.getElementById(\"onlUsers\").innerHTML = \"\";
}
}
}
// SQL ausfuehren
function execSQL(url) {
http_request2 = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
http_request2 = new XMLHttpRequest();
} else if (window.ActiveXObject) { // IE
try {
http_request2 = new ActiveXObject(\"Msxml2.XMLHTTP\");
} catch (e) {
try {
http_request2 = new ActiveXObject(\"Microsoft.XMLHTTP\");
} catch (e) {}
}
}
if (!http_request2) {
alert('Ende :( Kann keine XMLHTTP-Instanz erzeugen');
return false;
}
http_request2.open('POST', url, true);
// http_request2.onreadystatechange = alert(\"Geloescht, bitte kurz warten!\");
http_request2.send(null);
}
function doSQL(what, pk) {
if( what == \"deletepm\" ) {
url = \"pmfunctions.inc.php?pmdo=deletepm&msg_id=\"+pk;
// document.getElementById(\"PrivateMessage\").innerHTML = '<br>Wird gel&ouml;scht';
}
execSQL(url);
}
</script>
";
eval ("dooutput(\"".gettemplate($template_dir."rahmen")."\");");