You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
142 lines
4.3 KiB
142 lines
4.3 KiB
<?php
|
|
require_once('../ajax_asm.php');
|
|
function getNodeName( $NID ){
|
|
global $DATABASE;
|
|
$EID = intval( $NID );
|
|
if( $EID ){
|
|
$QS = "SELECT name FROM nodes WHERE id={$EID}";
|
|
$RV = $DATABASE->Query( $QS );
|
|
if( count( $RV ) ){
|
|
return $RV[0]['name'];
|
|
};
|
|
return '-NoName-';
|
|
} else {
|
|
return 'Argus Server';
|
|
};
|
|
};
|
|
function getEventImages( $eid ){
|
|
global $DATABASE;
|
|
$QS = "SELECT pic.md5 AS md5 FROM events_2_pictures ep LEFT JOIN pictures pic ON ( pic.id = ep.picture_id ) WHERE ep.evt_id={$eid}";
|
|
$r = $DATABASE->Query( $QS );
|
|
$rv = array();
|
|
foreach( $r as $t ) $rv[] = $r['md5'];
|
|
return $rv;
|
|
};
|
|
|
|
if( $CUser->Data['id'] > 1 ){
|
|
$Data = array();
|
|
//$GID = intval($_POST['']);
|
|
if( isset( $_POST['SITE'] ) ) $SITE = intval( $_POST['SITE'] ); else $SITE = 1;
|
|
if( isset( $_POST['MODE'] ) ) if( $_POST['MODE'] == 'live' ) $Mode = 1; else $Mode = 0;
|
|
if( isset( $_POST['FIL'] ) ) $FIL = intval( $_POST['FIL'] ); else $FIL = 0;
|
|
if( $Mode ){
|
|
if( $FIL ){
|
|
$QS = "SELECT * FROM events_cloud WHERE node_id={$FIL} ORDER BY id DESC LIMIT 20";
|
|
} else {
|
|
$QS = "SELECT * FROM events_cloud ORDER BY id DESC LIMIT 20";
|
|
};
|
|
} else {
|
|
if( isset( $_POST['SDA'] ) ) $SDA = intval( $_POST['SDA'] ); else $SDA = 0;
|
|
if( $SDA ){
|
|
if( isset( $_POST['SMO'] ) ) $SMO = intval( $_POST['SMO'] );
|
|
if( isset( $_POST['SYE'] ) ) $SYE = intval( $_POST['SYE'] );
|
|
if( isset( $_POST['STM'] ) ) $STM = intval( $_POST['STM'] );
|
|
if( isset( $_POST['ETM'] ) ) $ETM = intval( $_POST['ETM'] );
|
|
date_default_timezone_set('UTC');
|
|
$T = sprintf( "%04d-%02d-%02d", $SYE, $SMO, $SDA );
|
|
$CTS = strtotime( $T );
|
|
if( $STM && $ETM ){
|
|
$STS = $CTS + $STM;
|
|
$ETS = $CTS + $ETM;
|
|
} else {
|
|
$STS = $CTS;
|
|
$ETS = $CTS + 86400;
|
|
};
|
|
if( $FIL ){
|
|
$QS = "SELECT * FROM events_archive WHERE node_id={$FIL} AND ts >= {$STS} AND ts <= {$ETS} ORDER BY id DESC LIMIT 20";
|
|
} else {
|
|
$QS = "SELECT * FROM events_archive WHERE ts >= {$STS} AND ts <= {$ETS} ORDER BY id DESC LIMIT 20";
|
|
};
|
|
} else {
|
|
if( $FIL ){
|
|
$QS = "SELECT * FROM events_archive WHERE node_id={$FIL} ORDER BY id DESC LIMIT 20";
|
|
} else {
|
|
$QS = "SELECT * FROM events_archive ORDER BY id DESC LIMIT 20";
|
|
};
|
|
};
|
|
};
|
|
$Result = $DATABASE->Query( $QS, false );
|
|
date_default_timezone_set('UTC');
|
|
//foreach( array_reverse ( $Result ) as $CD ){
|
|
foreach( $Result as $CD ){
|
|
$cnode['has_target'] = false;
|
|
$cnode['has_geo'] = false;
|
|
$cnode['images'] = getEventImages( $CD['id'] );
|
|
$cnode['has_images'] = count( $cnode['images'] ) > 0;
|
|
switch( intval( $CD['evt_type'] ) ){
|
|
case 0:// NoInit
|
|
case 1:// Ready
|
|
case 2:// Alarm
|
|
case 3:// Command
|
|
case 4:// Key
|
|
case 5:// Joystick
|
|
continue;
|
|
case 6:// STUDY
|
|
$cnode['event']='Device Enters Into Study Mode';
|
|
break;
|
|
case 7:// BUSY
|
|
$cnode['event']='Device Is BUSY';
|
|
break;
|
|
case 8:// FLIP
|
|
$cnode['event']='Flip Complete';
|
|
break;
|
|
case 9:// SCAN
|
|
$cnode['event']='Scan Complete';
|
|
break;
|
|
case 10:// Target 1D
|
|
case 11:// Target 3DW
|
|
case 12:// Target 3DB
|
|
case 13:// Target 2DW
|
|
case 14:// Target 2DB
|
|
$cnode['event']='Target';
|
|
$cnode['data'] = sprintf("AZ: %0.2f El: %0.2f R: %0.2f", floatval($CD['azimuth']), floatval($CD['elevation']), floatval($CD['range']));
|
|
$cnode['has_target'] = true;
|
|
$cnode['has_geo'] = true;
|
|
break;
|
|
case 15:// Capture Start
|
|
case 16:// Capture End
|
|
case 17:// Capture Done
|
|
case 18:// Mission Begin
|
|
case 19:// Cancel Action
|
|
case 20:// Fly To
|
|
case 21:// WayPoint
|
|
case 22:// Dest Reached
|
|
case 23:// Jaming Begin
|
|
case 24:// Jamer On
|
|
case 25:// Jamer Off
|
|
case 26:// Target Locked
|
|
case 27:// Intercept Begin
|
|
case 28:// Intercept OK
|
|
case 29:// Intercept NOK
|
|
case 20:// Mission End
|
|
case 31:// Landed
|
|
case 32:// FH Busy
|
|
case 33:// Camera DM
|
|
case 34:// Error
|
|
default:
|
|
continue;
|
|
};
|
|
$cnode['id'] = intval( $CD['id'] );
|
|
$uts = intval($CD['ts']);
|
|
$cnode['date'] = date( "m.d.y", $uts );
|
|
$cnode['time'] = date( "H:m:s", $uts );
|
|
$cnode['device'] = getNodeName( $CD['node_id'] );
|
|
$Data[] = $cnode;
|
|
};
|
|
$RA['log']=$Data;
|
|
$RA['totalCount'] = count( $Data );
|
|
echo json_encode( $RA );
|
|
} else {
|
|
header('location: /');
|
|
};
|
|
?>
|