Web Interface For Lite Argus Control modules
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.

181 lines
8.0 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <?php
  2. require_once('../ajax_asm.php');
  3. $UID = intval( $CUser->Data['id'] );
  4. $Data = '';
  5. if( $UID > 1 ){
  6. $QS = "SELECT * FROM `system_props` LIMIT 1";
  7. $SPD = $DATABASE->Query( $QS );
  8. if( count( $SPD ) ){
  9. $SP = $SPD[0];
  10. $DUMM = array();
  11. $DUMM['camera']="{xtype:'panel',html:'NO CAMERA'}";
  12. $DUMM['sensor']="{xtype:'panel',html:'NO SENSOR'}";
  13. $DUMM['map']="{xtype:'panel',html:'NO MAP'}";
  14. $DUMM['log']="{xtype:'panel',html:'NO LOG'}";
  15. $STA = array();
  16. $END="]}";
  17. $STA[0]="{ columnWidth: 1, style:'padding:10px 0 10px 10px', items:[";
  18. $STA[1]="{ columnWidth: 0.5, style:'padding:10px 0 10px 10px', items:[";
  19. $STA[2]="{ columnWidth: 0.5, style:'padding:10px 0 10px 10px', items:[";
  20. $STA[3]="{ columnWidth: 0.25, style:'padding:10px 0 10px 10px', items:[";
  21. $STA[4]="{ columnWidth: 0.25, style:'padding:10px 0 10px 10px', items:[";
  22. $STA[5]="{ columnWidth: 0.25, style:'padding:10px 0 10px 10px', items:[";
  23. $STA[6]="{ columnWidth: 0.25, style:'padding:10px 0 10px 10px', items:[";
  24. $MCOL = 7;
  25. $P1="{ columnWidth: .25, style:'padding:10px 0 10px 10px', items:[";
  26. $P2="]}";
  27. $QS = "SELECT * FROM nodes WHERE `type`> 0 ";
  28. $result = $DATABASE->Query( $QS, false );
  29. if( count( $result ) > 0 ){
  30. $QS = "SELECT * FROM users_dash_layout WHERE user_id={$UID} ORDER BY x,y";
  31. $Lay = $DATABASE->Query( $QS, false );
  32. $AL = array();
  33. foreach( $Lay as $L ){
  34. $AL[$L['node_id']]=$L;
  35. };
  36. $COLS = array();
  37. $Z = array();
  38. foreach( $result as $R ){
  39. if( isset( $AL[$R['id']] ) ){
  40. $COLS[intval($AL[$R['id']]['x'])][intval($AL[$R['id']]['y'])] = $R;
  41. } else {
  42. $Z[] = $R;
  43. };
  44. };
  45. if( count( $Z ) ) foreach( $Z as $z ) $COLS[$MCOL-1][]=$z;
  46. $STOL = array();
  47. for( $i=0; $i < $MCOL; $i++ ){
  48. $index = 0;
  49. $TPL = array();
  50. $STOL[] = array();
  51. if( isset( $COLS[$i] ) ){
  52. foreach( $COLS[$i] as $R ){
  53. $TFN = 'dash/node_' . $R['type'] . '.js';
  54. if(!file_exists( $TFN )) continue;
  55. $TPL[$index] = file_get_contents( $TFN );
  56. $TPL[$index] = str_replace('%%%NODEID%%%', ''.$R['id'] , $TPL[$index] );
  57. $TPL[$index] = str_replace('%%%NODENAME%%%', ''.$R['name'] , $TPL[$index] );
  58. switch( $R['type'] ){
  59. case ARGUS_SERVER:{
  60. $TPL[$index] = str_replace('%%%SYSSERVERNAME%%%', $Labels->getLabel( 'SYS_SERVNAME' ), $TPL[$index] );
  61. if( $R['online']== 1 ){
  62. $TPL[$index] = str_replace('%%%SERVERSTATUS%%%', $Labels->getLabel('SRV_STATUS_ON') , $TPL[$index]);
  63. $TPL[$index] = str_replace('%%%SERVERSTATUSIMG%%%', 'accept.png' , $TPL[$index]);
  64. } else {
  65. $TPL[$index] = str_replace('%%%SERVERSTATUS%%%', $Labels->getLabel('SRV_STATUS_OFF') , $TPL[$index]);
  66. $TPL[$index] = str_replace('%%%SERVERSTATUSIMG%%%', 'stop.png' , $TPL[$index]);
  67. };
  68. $QS="SELECT * FROM `server_modules` WHERE `server_id`={$R['aux_id']}";
  69. $Z=$DATABASE->Query($QS);
  70. $MODULES = array();
  71. if(count($Z)){
  72. foreach( $Z as $mod ){
  73. $QS="SELECT * FROM server_module_types WHERE id={$mod['type']}";
  74. $mtt=$DATABASE->Query( $QS );
  75. $CM['xtype'] = 'panel';
  76. if( $mod['enabled'] == 1 ){
  77. $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>';
  78. } else {
  79. $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>';
  80. };
  81. $CM['height'] = 25;
  82. $MODULES[] = $CM;
  83. };
  84. $MODULES_CNT = json_encode( $MODULES );
  85. } else {
  86. $MODULES_CNT = '[{ html: \'No Modules Defined\'}]';
  87. };
  88. $TPL[$index] = str_replace('%%%MODULES%%%', ''.$MODULES_CNT , $TPL[$index] );
  89. break;
  90. };
  91. case ARGUS_LFS_SENSOR:
  92. case ARGUS_PLS_200_SENSOR:
  93. case ARGUS_PLS_360_SENSOR:{
  94. break;
  95. };
  96. case ARGUS_3D_SENSOR:{
  97. break;
  98. };
  99. case 10:
  100. case 11:
  101. case 12:
  102. case ARGUS_IP_PTZ_CAMERA:{
  103. //$QS="SELECT * FROM cameras WHERE node_id={$R['id']}";
  104. $QS="SELECT * FROM `nodes` WHERE `id`={$R['id']}";
  105. $Z=$DATABASE->Query( $QS );
  106. $QS="SELECT * FROM `module_eve` WHERE `id`=1";
  107. $S=$DATABASE->Query( $QS );
  108. $MODULE_DATA = $S[0];
  109. $TPL[$index] = str_replace( '%%%NODENAME%%%', urldecode( $Z[0]['name'] ) , $TPL[$index] );
  110. $FU = 'http://' . $_SERVER['SERVER_ADDR'].':' . $MODULE_DATA['web_port'] .'/stream?id='. $Z[0]['aux_parameter'];
  111. $CS[] = '[' . $Z[0]['aux_parameter'] . ',\'[ 120x120] Video\',\''. $FU .'\']';
  112. $TPL[$index] = str_replace( '%%%URLS%%%', '[' . implode( ',', $CS ) . ']' , $TPL[$index] );
  113. $TPL[$index] = str_replace( '%%%SELID%%%', 'value: '. $Z[0]['aux_parameter'] .',', $TPL[$index] );
  114. $TPL[$index] = str_replace( '%%%SELURL%%%', $FU, $TPL[$index] );
  115. $TPL[$index] = str_replace( '%%%STREAMID%%%', $R['aux_parameter'], $TPL[$index] );
  116. $FK = $MODULE_DATA['height'] /$MODULE_DATA['width'];
  117. $W = 244;
  118. $H = $W * $FK;
  119. $TPL[$index] = str_replace( '%%%WIDTH%%%', $W, $TPL[$index] );
  120. $TPL[$index] = str_replace( '%%%HEIGHT%%%', $H, $TPL[$index] );
  121. /*
  122. $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";
  123. $S=$DATABASE->Query( $QS );
  124. if( count( $S ) ){
  125. $CS = array();
  126. $FID = 0;
  127. $FUL = '';
  128. foreach( $S as $sou ){
  129. $QS = "SELECT * FROM media_servers WHERE id = {$sou['media_server_id']}";
  130. $F = $DATABASE->Query( $QS );
  131. $FF=$F[0];
  132. if( $FF['ip']=='127.0.0.1'){
  133. //Localhost
  134. $FF['ip'] = $_SERVER['SERVER_ADDR'];
  135. };
  136. $ACC_URL='http://' . $FF['ip'] . ':' . $FF['REST_port'];
  137. $CU = str_replace( $FF['virtual_host'], $ACC_URL, $sou['key'] ) . '/hls.m3u8';
  138. if( $FID == 0 ){
  139. // First URL as default
  140. $FID = $sou['id'];
  141. $FUL = $CU;
  142. };
  143. $CS[] = '[' . $sou['id'] . ',\'[' . $sou['img_width'] . 'x' . $sou['img_height'] . '] '. $sou['name'].'\',\'' . $CU .'\']';
  144. };
  145. $TPL[$index] = str_replace( '%%%URLS%%%', '['. implode( ',', $CS ) . ']' , $TPL[$index] );
  146. $TPL[$index] = str_replace( '%%%SELID%%%', 'value: '. $FID .',', $TPL[$index] );
  147. $TPL[$index] = str_replace( '%%%SELURL%%%', $FUL, $TPL[$index] );
  148. } else {
  149. // Handle No Video From Camera!
  150. $TPL[$index] = str_replace( '%%%URLS%%%', '[]' , $TPL[$index] );
  151. $TPL[$index] = str_replace( '%%%SELID%%%', 'value: \'No Video Sources\',', $TPL[$index] );
  152. $TPL[$index] = str_replace( '%%%SELURL%%%','', $TPL[$index] );
  153. };
  154. */
  155. break;
  156. };
  157. };
  158. $index++;
  159. };
  160. };
  161. //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>\'}]}';
  162. $STOL[$i] = $STA[$i] . implode( ',', $TPL ) . $END;
  163. };
  164. //$STOL[] = "{ columnWidth: 0.5, style:'padding:10px 0 10px 10px', items:[]}";
  165. //$STOL[] = "{ columnWidth: 0.5, style:'padding:10px 0 10px 10px', items:[]}";
  166. //$STOL[] = "{ columnWidth: 1, style:'padding:10px 0 10px 10px', items:[]}";
  167. $Data = '[' . implode( ',' , $STOL ) . ']';
  168. };
  169. } else {
  170. $Data = '[{columnWidth: 1, items:{html:"NO SYSTEM PROPS"}} ]';
  171. };
  172. };
  173. if( $Data != '' ) {
  174. echo $Data;
  175. } else {
  176. echo '[]';
  177. };
  178. ?>