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.

139 lines
4.5 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <?php
  2. require_once('../ajax_asm.php');
  3. $UID = intval( $CUser->Data['id'] );
  4. $ACCESS = intval( $CUser->Data['access'] );
  5. if( $UID > 1 ){
  6. $SiteID = intval( $_POST['SITE'] );
  7. $LastNID = intval( $_POST['LNID'] );
  8. $LastServerPID = intval( $_POST['SPID'] );
  9. $Data = array();
  10. $ServerWasHuped = false;
  11. $ServerIsOnLine = true;
  12. $Data['status'] = 'OK';
  13. $CTS = time();
  14. $Data['nodes'] = array();
  15. $QS = "SELECT * FROM nodes WHERE site_id = {$SiteID} ORDER BY `type`";
  16. $result = $DATABASE->Query( $QS, false );
  17. if( count( $result ) > 0 ){
  18. foreach( $result as $R ){
  19. $CN = array();
  20. $CN['id'] = $R['id'];
  21. $CN['type'] = intval($R['type']);
  22. if( $ServerIsOnLine ){
  23. $CN['status'] = intval($R['online']);
  24. } else {
  25. $CN['status'] = 0;
  26. };
  27. if( $CN['status'] == 1 || $ServerIsOnLine ){
  28. switch( $R['type'] ){
  29. case ARGUS_SERVER:{
  30. $QS="SELECT * FROM `servers` WHERE `id`={$R['aux_id']}";
  31. $zult = $DATABASE->Query( $QS );
  32. if( $zult[0]['online'] == 1 ){
  33. $STS = intval( $zult[0]['ts'] );
  34. $CN['CTS'] = $CTS;
  35. $CN['STS'] = $STS;
  36. if( ( $CTS - $STS ) > 1 ){ //3 seconds offline
  37. $ServerIsOnLine = false;
  38. $CN['status'] = 0;
  39. } else {
  40. $CN['status'] = 1;
  41. };
  42. } else {
  43. $ServerIsOnLine = false;
  44. $CN['status'] = 0;
  45. };
  46. $CN['cpu1'] = intval( $zult[0]['stat_cpu1'] * 2.5 );
  47. $CN['cpu5'] = intval( $zult[0]['stat_cpu5'] );
  48. $CN['cpu15'] = intval( $zult[0]['stat_cpu15'] * 2.5 );
  49. $CN['mem'] = intval( $zult[0]['stat_mem']*100 );
  50. $CN['disk']= intval( $zult[0]['stat_disk']*100 );
  51. break;
  52. };
  53. case ARGUS_ALS_SENSOR:
  54. case ARGUS_LFS_SENSOR:
  55. case ARGUS_PLS_200_SENSOR:
  56. case ARGUS_PLS_360_SENSOR:
  57. case ARGUS_NET_PLS_200:{
  58. // check Targets
  59. $CN['targets'] = array();
  60. $QS="SELECT * FROM events_cloud WHERE node_id={$CN['id']} AND ( evt_type=13 OR evt_type=14) ORDER BY id DESC LIMIT 32";
  61. //$QS="SELECT * FROM events_cloud WHERE node_id={$CN['id']} AND ( evt_type=13 OR evt_type=14) AND (UNIX_TIMESTAMP(NOW())-ts)<60 ORDER BY id DESC LIMIT 32";
  62. //$QS="SELECT * FROM events_cloud WHERE node_id={$CN['id']} AND ( evt_type=13 OR evt_type=14) ORDER BY ts, ts_ms DESC LIMIT 32";
  63. //echo $QS . "\n\n";
  64. $zult = $DATABASE->Query( $QS );
  65. if( count( $zult ) ){
  66. $CN['status'] = 4; // Alarmed
  67. $CT = array();
  68. foreach( $zult as $Z ){
  69. $CT['digital'] = $Z['range_digital'];
  70. $CT['az'] = $Z['azimuth'];
  71. $CN['targets'][] = $CT;
  72. };
  73. };
  74. break;
  75. };
  76. case ARGUS_3D_SENSOR:{
  77. break;
  78. };
  79. case ARGUS_ANALOG_STATIC_CAMERA:
  80. case ARGUS_ANALOG_PTZ_CAMERA:
  81. case ARGUS_IP_STATIC_CAMERA:
  82. case ARGUS_IP_PTZ_CAMERA:{
  83. if( $ServerIsOnLine ){
  84. $QS="SELECT * FROM `media_streams` WHERE `id`={$R['aux_parameter']}";
  85. $SR=$DATABASE->Query( $QS );
  86. if( count( $SR ) ) {
  87. $ST = $SR[0];
  88. if( $ST['valid'] == 1 ){
  89. $CN['valid'] = true;
  90. $QS="SELECT * FROM `module_embed_video_settings` WHERE `id`=1";
  91. $S=$DATABASE->Query( $QS );
  92. $CN['src'] = 'http://' . $_SERVER['SERVER_ADDR'].':' . $S[0]['web_port'] .'/stream?id='. $R['aux_parameter'];
  93. break;
  94. };
  95. };
  96. };
  97. $CN['valid'] = false;
  98. $CN['src'] = "/style/assets/no-signal.png";
  99. break;
  100. };
  101. };
  102. };
  103. $Data['nodes'][] = $CN;
  104. };
  105. };
  106. // Notifications
  107. $Data['notifications'] = array();
  108. $QS = "SELECT * FROM `notifications` WHERE `status`='A' AND `site_id`={$SiteID} AND `id` > {$LastNID}";
  109. $result = $DATABASE->Query( $QS );
  110. if( count( $result ) ){
  111. foreach( $result as $R ){
  112. $cn['id'] = intval( $R['id'] );
  113. $cn['react'] = false;
  114. $cn['hide'] = true;
  115. $cn['action']= '';
  116. switch( intval( $R['type'] ) ){
  117. case 0:{
  118. $cn['type']= 'info';
  119. $cn['msg'] = $Labels->GetLabel('SYS_WELCOME_MSG');
  120. break;
  121. };
  122. case 1:{
  123. $cn['type']= 'error';
  124. $QS="SELECT `name` FROM `nodes` WHERE `id`={$R['obj_id']}";
  125. $RR = $DATABASE->Query( $QS );
  126. $cn['msg'] = $Labels->GetLabel('SYS_MSG_DEVINV') . ' <b>' . $RR[0]['name'] .'</b>';
  127. $cn['hide'] = false;
  128. $cn['react'] = true;
  129. $cn['action'] = $R['obj_id'].':'.$cn['id'];
  130. };
  131. };
  132. $Data['notifications'][] = $cn;
  133. };
  134. };
  135. } else {
  136. $Data['notifications'] = array();
  137. $Data['status']='LOGOUT';
  138. };
  139. echo json_encode( $Data );
  140. ?>