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.

153 lines
6.7 KiB

6 years ago
​
​
​
​
6 years ago
​
​
6 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
6 years ago
​
5 years ago
6 years ago
​
5 years ago
​
​
​
​
​
​
​
6 years ago
6 years ago
  1. <?php
  2. require_once('../ajax_asm.php');
  3. if( $CUser->Data['id'] > 1 ){
  4. $SiteID = intval( $_POST['SITE'] );
  5. $UID = intval( $CUser->Data['id'] );
  6. $QS = "SELECT * FROM nodes WHERE site_id = {$SiteID}";
  7. $result = $DATABASE->Query( $QS, false );
  8. $P1="{ columnWidth: '320px', style:'padding:10px 0 10px 10px', items:[";
  9. $P2="]}";
  10. if( count( $result ) > 0 ){
  11. $QS = "SELECT * FROM users_dash_layout WHERE user_id={$UID} ORDER BY x,y";
  12. $Lay = $DATABASE->Query( $QS, false );
  13. $AL = array();
  14. foreach( $Lay as $L ){
  15. $AL[$L['node_id']]=$L;
  16. };
  17. $COLS = array();
  18. $Z = array();
  19. foreach( $result as $R ){
  20. if( isset( $AL[$R['id']] ) ){
  21. $COLS[intval($AL[$R['id']]['x'])][intval($AL[$R['id']]['y'])] = $R;
  22. } else {
  23. $Z[] = $R;
  24. };
  25. };
  26. if( count( $Z ) ) foreach( $Z as $z ) $COLS[0][]=$z;
  27. $STOL = array();
  28. for( $i=0; $i < 4; $i++ ){
  29. $index = 0;
  30. $TPL = array();
  31. $STOL[] = array();
  32. if( isset( $COLS[$i] ) ){
  33. foreach( $COLS[$i] as $R ){
  34. $TFN = 'dash/node_' . $R['type'] . '.js';
  35. if(!file_exists( $TFN )) continue;
  36. $TPL[$index] = file_get_contents( $TFN );
  37. $TPL[$index] = str_replace('%%%NODEID%%%', ''.$R['id'] , $TPL[$index] );
  38. $TPL[$index] = str_replace('%%%NODENAME%%%', ''.$R['name'] , $TPL[$index] );
  39. switch( $R['type'] ){
  40. case ARGUS_SERVER:{
  41. $TPL[$index] = str_replace('%%%SYSSERVERNAME%%%', $Labels->getLabel( 'SYS_SERVNAME' ), $TPL[$index] );
  42. if( $R['online']== 1 ){
  43. $TPL[$index] = str_replace('%%%SERVERSTATUS%%%', $Labels->getLabel('SRV_STATUS_ON') , $TPL[$index]);
  44. $TPL[$index] = str_replace('%%%SERVERSTATUSIMG%%%', 'accept.png' , $TPL[$index]);
  45. } else {
  46. $TPL[$index] = str_replace('%%%SERVERSTATUS%%%', $Labels->getLabel('SRV_STATUS_OFF') , $TPL[$index]);
  47. $TPL[$index] = str_replace('%%%SERVERSTATUSIMG%%%', 'stop.png' , $TPL[$index]);
  48. };
  49. $QS="SELECT * FROM `server_modules` WHERE `server_id`={$R['aux_id']}";
  50. $Z=$DATABASE->Query($QS);
  51. $MODULES = array();
  52. if(count($Z)){
  53. foreach( $Z as $mod ){
  54. $QS="SELECT * FROM server_module_types WHERE id={$mod['type']}";
  55. $mtt=$DATABASE->Query( $QS );
  56. $CM['xtype'] = 'panel';
  57. if( $mod['enabled'] == 1 ){
  58. $CM['html'] = '<table width="100%"><tr><td><p class="super_small">'.$Labels->getLabel( $mtt[0]['name'] ).'</p></td><td width="16px"><img title="'.$Labels->getLabel( '__ENABLED__' ).'" src="/style/icons/icons/plugin_add.png"></td></tr></table>';
  59. } else {
  60. $CM['html'] = '<table width="100%"><tr><td><p class="super_small">'.$Labels->getLabel( $mtt[0]['name'] ).'</p></td><td width="16px"><img title="'.$Labels->getLabel( '__DISABLED__' ).'" src="/style/icons/icons/plugin_delete.png"></td></tr></table>';
  61. };
  62. $CM['height'] = 25;
  63. $MODULES[] = $CM;
  64. };
  65. $MODULES_CNT = json_encode( $MODULES );
  66. } else {
  67. $MODULES_CNT = '[{ html: \'No Modules Defined\'}]';
  68. };
  69. $TPL[$index] = str_replace('%%%MODULES%%%', ''.$MODULES_CNT , $TPL[$index] );
  70. break;
  71. };
  72. case ARGUS_LFS_SENSOR:
  73. case ARGUS_PLS_200_SENSOR:
  74. case ARGUS_PLS_360_SENSOR:{
  75. break;
  76. };
  77. case ARGUS_3D_SENSOR:{
  78. break;
  79. };
  80. case 10:
  81. case 11:
  82. case 12:
  83. case ARGUS_IP_PTZ_CAMERA:{
  84. //$QS="SELECT * FROM cameras WHERE node_id={$R['id']}";
  85. $QS="SELECT * FROM `nodes` WHERE `id`={$R['id']}";
  86. $Z=$DATABASE->Query( $QS );
  87. $QS="SELECT * FROM `module_embed_video_settings` WHERE `id`=1";
  88. $S=$DATABASE->Query( $QS );
  89. $MODULE_DATA = $S[0];
  90. $TPL[$index] = str_replace( '%%%NODENAME%%%', urldecode( $Z[0]['name'] ) , $TPL[$index] );
  91. $FU = 'http://' . $_SERVER['SERVER_ADDR'].':' . $MODULE_DATA['web_port'] .'/stream?id='. $Z[0]['aux_parameter'];
  92. $CS[] = '[' . $Z[0]['aux_parameter'] . ',\'[ 120x120] Video\',\''. $FU .'\']';
  93. $TPL[$index] = str_replace( '%%%URLS%%%', '[' . implode( ',', $CS ) . ']' , $TPL[$index] );
  94. $TPL[$index] = str_replace( '%%%SELID%%%', 'value: '. $Z[0]['aux_parameter'] .',', $TPL[$index] );
  95. $TPL[$index] = str_replace( '%%%SELURL%%%', $FU, $TPL[$index] );
  96. $TPL[$index] = str_replace( '%%%STREAMID%%%', $R['aux_parameter'], $TPL[$index] );
  97. $W = 244;
  98. $H = $W * ( $MODULE_DATA['height'] /$MODULE_DATA['width'] );
  99. $TPL[$index] = str_replace( '%%%WIDTH%%%', $W, $TPL[$index] );
  100. $TPL[$index] = str_replace( '%%%HEIGHT%%%', $H, $TPL[$index] );
  101. /*
  102. $QS="SELECT mss.*, ms.name, ms.img_width, ms.img_height FROM media_server_streams mss LEFT JOIN media_streams ms ON ( mss.media_stream_id = ms.id ) WHERE ms.source_id={$Z[0]['id']} AND mss.valid=1 AND mss.online=1";
  103. $S=$DATABASE->Query( $QS );
  104. if( count( $S ) ){
  105. $CS = array();
  106. $FID = 0;
  107. $FUL = '';
  108. foreach( $S as $sou ){
  109. $QS = "SELECT * FROM media_servers WHERE id = {$sou['media_server_id']}";
  110. $F = $DATABASE->Query( $QS );
  111. $FF=$F[0];
  112. if( $FF['ip']=='127.0.0.1'){
  113. //Localhost
  114. $FF['ip'] = $_SERVER['SERVER_ADDR'];
  115. };
  116. $ACC_URL='http://' . $FF['ip'] . ':' . $FF['REST_port'];
  117. $CU = str_replace( $FF['virtual_host'], $ACC_URL, $sou['key'] ) . '/hls.m3u8';
  118. if( $FID == 0 ){
  119. // First URL as default
  120. $FID = $sou['id'];
  121. $FUL = $CU;
  122. };
  123. $CS[] = '[' . $sou['id'] . ',\'[' . $sou['img_width'] . 'x' . $sou['img_height'] . '] '. $sou['name'].'\',\'' . $CU .'\']';
  124. };
  125. $TPL[$index] = str_replace( '%%%URLS%%%', '['. implode( ',', $CS ) . ']' , $TPL[$index] );
  126. $TPL[$index] = str_replace( '%%%SELID%%%', 'value: '. $FID .',', $TPL[$index] );
  127. $TPL[$index] = str_replace( '%%%SELURL%%%', $FUL, $TPL[$index] );
  128. } else {
  129. // Handle No Video From Camera!
  130. $TPL[$index] = str_replace( '%%%URLS%%%', '[]' , $TPL[$index] );
  131. $TPL[$index] = str_replace( '%%%SELID%%%', 'value: \'No Video Sources\',', $TPL[$index] );
  132. $TPL[$index] = str_replace( '%%%SELURL%%%','', $TPL[$index] );
  133. };
  134. */
  135. break;
  136. };
  137. };
  138. $index++;
  139. };
  140. };
  141. //if( $i == 0 ) $TPL[] = '{ id: \'db_node_22311232\', frame: false, colspan: 2, width: 516, height: 200, border: true, title: \'PIZDA\', items:[{ html: \'<p>Server</p>\'}]}';
  142. $STOL[$i] = $P1 . implode( ',', $TPL ) . $P2;
  143. };
  144. $Data = '[' . implode( ',' , $STOL ) . ']';
  145. };
  146. if( $Data != '' ) {
  147. echo $Data;
  148. } else {
  149. echo '[]';
  150. };
  151. } else echo "[]";
  152. ?>