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.

99 lines
3.6 KiB

6 years ago
​
​
​
​
6 years ago
​
​
6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 years ago
6 years ago
​
​
​
​
​
​
​
6 years ago
6 years ago
​
6 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 $Z[] = $R;
  23. };
  24. if( count( $Z ) ) foreach( $Z as $z ) $COLS[0][]=$z;
  25. $STOL = array();
  26. for( $i=0; $i < 4; $i++ ){
  27. $index = 0;
  28. $TPL = array();
  29. $STOL[] = array();
  30. if( isset( $COLS[$i] ) )
  31. foreach( $COLS[$i] as $R ){
  32. $TFN = 'dash/node_' . $R['type'] . '.js';
  33. if(!file_exists( $TFN )) continue;
  34. $TPL[$index] = file_get_contents( $TFN );
  35. $TPL[$index] = str_replace('%%%NODEID%%%', ''.$R['id'] , $TPL[$index] );
  36. $TPL[$index] = str_replace('%%%NODENAME%%%', ''.$R['name'] , $TPL[$index] );
  37. switch( $R['type'] ){
  38. case ARGUS_SERVER:{
  39. break;
  40. };
  41. case ARGUS_2D_SENSOR:{
  42. break;
  43. };
  44. case ARGUS_3D_SENSOR:{
  45. break;
  46. };
  47. case ARGUS_IP_PTZ_CAMERA:{
  48. $QS="SELECT * FROM cameras WHERE node_id={$R['id']}";
  49. $Z=$DATABASE->Query( $QS );
  50. $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";
  51. $S=$DATABASE->Query( $QS );
  52. $TPL[$index] = str_replace( '%%%NODENAME%%%', urldecode( $Z[0]['name'] ) , $TPL[$index] );
  53. if( count( $S ) ){
  54. $CS = array();
  55. $FID = 0;
  56. $FUL = '';
  57. foreach( $S as $sou ){
  58. $QS = "SELECT * FROM media_servers WHERE id = {$sou['media_server_id']}";
  59. $F = $DATABASE->Query( $QS );
  60. $FF=$F[0];
  61. if( $FF['ip']=='127.0.0.1'){
  62. //Localhost
  63. $FF['ip'] = $_SERVER['SERVER_ADDR'];
  64. };
  65. $ACC_URL='http://' . $FF['ip'] . ':' . $FF['REST_port'];
  66. $CU = str_replace( $FF['virtual_host'], $ACC_URL, $sou['key'] ) . '/hls.m3u8';
  67. if( $FID == 0 ){
  68. // First URL as default
  69. $FID = $sou['id'];
  70. $FUL = $CU;
  71. };
  72. $CS[] = '[' . $sou['id'] . ',\'[' . $sou['img_width'] . 'x' . $sou['img_height'] . '] '. $sou['name'].'\',\'' . $CU .'\']';
  73. };
  74. $TPL[$index] = str_replace( '%%%URLS%%%', '['. implode( ',', $CS ) . ']' , $TPL[$index] );
  75. $TPL[$index] = str_replace( '%%%SELID%%%', 'value: '. $FID .',', $TPL[$index] );
  76. $TPL[$index] = str_replace( '%%%SELURL%%%', $FUL, $TPL[$index] );
  77. } else {
  78. // Handle No Video From Camera!
  79. $TPL[$index] = str_replace( '%%%URLS%%%', '[]' , $TPL[$index] );
  80. $TPL[$index] = str_replace( '%%%SELID%%%', 'value: \'No Video Sources\',', $TPL[$index] );
  81. $TPL[$index] = str_replace( '%%%SELURL%%%','', $TPL[$index] );
  82. };
  83. break;
  84. };
  85. };
  86. $index++;
  87. };
  88. //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>\'}]}';
  89. $STOL[$i] = $P1 . implode( ',', $TPL ) . $P2;
  90. };
  91. $Data = '[' . implode( ',' , $STOL ) . ']';
  92. };
  93. if( $Data != '' ) {
  94. echo $Data;
  95. } else {
  96. echo '[]';
  97. };
  98. } else echo "[]";
  99. ?>