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.

141 lines
4.3 KiB

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