Web UI for ARGUS server
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.

145 lines
4.7 KiB

​
5 years ago
​
​
5 years ago
​
5 years ago
5 years ago
5 years ago
5 years ago
​
​
5 years ago
​
5 years ago
5 years ago
​
​
​
​
​
​
​
​
5 years ago
5 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 years ago
5 years ago
​
​
5 years ago
5 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 years ago
​
​
​
​
5 years ago
​
  1. <?php
  2. require_once('../ajax_asm.php');
  3. function getNodeInfo( $NID ){
  4. global $DATABASE;
  5. $EID = intval( $NID );
  6. if( $EID ){
  7. $QS = "SELECT name, type FROM nodes WHERE id={$EID}";
  8. $RV = $DATABASE->Query( $QS );
  9. if( count( $RV ) ){
  10. return $RV[0];
  11. };
  12. return array( 'name'=>'-NoName-', 'type'=>'0');
  13. } else {
  14. return array( 'name'=>'-NoName-', 'type'=>'0');
  15. };
  16. };
  17. function getEventImages( $eid ){
  18. global $DATABASE;
  19. //$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}";
  20. $QS = "SELECT picture_id FROM events_2_pictures WHERE evt_id={$eid}";
  21. $r = $DATABASE->Query( $QS );
  22. $rv = array();
  23. foreach( $r as $t ) $rv[] = $t['picture_id'];
  24. return $rv;
  25. };
  26. if( $CUser->Data['id'] > 1 ){
  27. $Data = array();
  28. //$GID = intval($_POST['']);
  29. if( isset( $_POST['SITE'] ) ) $SITE = intval( $_POST['SITE'] ); else $SITE = 1;
  30. if( isset( $_POST['MODE'] ) ) if( $_POST['MODE'] == 'live' ) $Mode = 1; else $Mode = 0;
  31. if( isset( $_POST['FIL'] ) ) $FIL = intval( $_POST['FIL'] ); else $FIL = 0;
  32. if( $Mode ){
  33. if( $FIL ){
  34. $QS = "SELECT ec.* FROM events_cloud ec WHERE ec.node_id={$FIL} ORDER BY ec.id DESC LIMIT 20";
  35. } else {
  36. $QS = "SELECT ec.* FROM events_cloud ec ORDER BY ec.id DESC LIMIT 20";
  37. };
  38. } else {
  39. if( isset( $_POST['SDA'] ) ) $SDA = intval( $_POST['SDA'] ); else $SDA = 0;
  40. if( $SDA ){
  41. if( isset( $_POST['SMO'] ) ) $SMO = intval( $_POST['SMO'] );
  42. if( isset( $_POST['SYE'] ) ) $SYE = intval( $_POST['SYE'] );
  43. if( isset( $_POST['STM'] ) ) $STM = intval( $_POST['STM'] );
  44. if( isset( $_POST['ETM'] ) ) $ETM = intval( $_POST['ETM'] );
  45. date_default_timezone_set('UTC');
  46. $T = sprintf( "%04d-%02d-%02d", $SYE, $SMO, $SDA );
  47. $CTS = strtotime( $T );
  48. if( $STM && $ETM ){
  49. $STS = $CTS + $STM;
  50. $ETS = $CTS + $ETM;
  51. } else {
  52. $STS = $CTS;
  53. $ETS = $CTS + 86400;
  54. };
  55. if( $FIL ){
  56. $QS = "SELECT ea.* FROM events_archive ea WHERE ea.node_id={$FIL} AND ea.ts >= {$STS} AND ea.ts <= {$ETS} ORDER BY ea.id DESC LIMIT 20";
  57. } else {
  58. $QS = "SELECT ea.* FROM events_archive ea WHERE ea.ts >= {$STS} AND ea.ts <= {$ETS} ORDER BY ea.id DESC LIMIT 20";
  59. };
  60. } else {
  61. if( $FIL ){
  62. $QS = "SELECT ea.* FROM events_archive ea WHERE ea.node_id={$FIL} ORDER BY ea.id DESC LIMIT 20";
  63. } else {
  64. $QS = "SELECT ea.* FROM events_archive ea ORDER BY ea.id DESC LIMIT 20";
  65. };
  66. };
  67. };
  68. $Result = $DATABASE->Query( $QS, false );
  69. date_default_timezone_set('UTC');
  70. //foreach( array_reverse ( $Result ) as $CD ){
  71. foreach( $Result as $CD ){
  72. $cnode['has_target'] = false;
  73. $cnode['has_geo'] = false;
  74. $cnode['images'] = getEventImages( $CD['id'] );
  75. $cnode['has_images'] = count( $cnode['images'] ) > 0;
  76. switch( intval( $CD['evt_type'] ) ){
  77. case 0:// NoInit
  78. case 1:// Ready
  79. case 2:// Alarm
  80. case 3:// Command
  81. case 4:// Key
  82. case 5:// Joystick
  83. continue;
  84. case 6:// STUDY
  85. $cnode['event']='Device Enters Into Study Mode';
  86. break;
  87. case 7:// BUSY
  88. $cnode['event']='Device Is BUSY';
  89. break;
  90. case 8:// FLIP
  91. $cnode['event']='Flip Complete';
  92. break;
  93. case 9:// SCAN
  94. $cnode['event']='Scan Complete';
  95. break;
  96. case 10:// Target 1D
  97. case 11:// Target 3DW
  98. case 12:// Target 3DB
  99. case 13:// Target 2DW
  100. case 14:// Target 2DB
  101. $cnode['event']='Target';
  102. $cnode['data'] = sprintf("AZ: %0.2f El: %0.2f R: %0.2f", floatval($CD['azimuth']), floatval($CD['elevation']), floatval($CD['range']));
  103. $cnode['has_target'] = true;
  104. $cnode['has_geo'] = true;
  105. $cnode['geo'] = array( 'lat'=>floatval( $CD['lat'] ),'lon'=>floatval( $CD['lon'] ),'alt'=>floatval( $CD['alt'] ) );
  106. break;
  107. case 15:// Capture Start
  108. case 16:// Capture End
  109. case 17:// Capture Done
  110. case 18:// Mission Begin
  111. case 19:// Cancel Action
  112. case 20:// Fly To
  113. case 21:// WayPoint
  114. case 22:// Dest Reached
  115. case 23:// Jaming Begin
  116. case 24:// Jamer On
  117. case 25:// Jamer Off
  118. case 26:// Target Locked
  119. case 27:// Intercept Begin
  120. case 28:// Intercept OK
  121. case 29:// Intercept NOK
  122. case 20:// Mission End
  123. case 31:// Landed
  124. case 32:// FH Busy
  125. case 33:// Camera DM
  126. case 34:// Error
  127. default:
  128. continue;
  129. };
  130. $cnode['id'] = intval( $CD['id'] );
  131. $uts = intval($CD['ts']);
  132. $cnode['date'] = date( "m.d.y", $uts );
  133. $cnode['time'] = date( "H:m:s", $uts );
  134. $NIFO = getNodeInfo( $CD['node_id'] );
  135. $cnode['device'] = $NIFO['name'];
  136. $cnode['dev_type'] = intval( $NIFO['type'] );
  137. $Data[] = $cnode;
  138. };
  139. $RA['log']=$Data;
  140. $RA['totalCount'] = count( $Data );
  141. echo json_encode( $RA );
  142. } else {
  143. header('location: /');
  144. };
  145. ?>