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.

104 lines
3.9 KiB

6 years ago
​
​
​
​
6 years ago
​
​
6 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. break;
  42. };
  43. case ARGUS_LFS_SENSOR:
  44. case ARGUS_PLS_200_SENSOR:
  45. case ARGUS_PLS_360_SENSOR:{
  46. break;
  47. };
  48. case ARGUS_3D_SENSOR:{
  49. break;
  50. };
  51. case ARGUS_IP_PTZ_CAMERA:{
  52. $QS="SELECT * FROM cameras WHERE node_id={$R['id']}";
  53. $Z=$DATABASE->Query( $QS );
  54. $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";
  55. $S=$DATABASE->Query( $QS );
  56. $TPL[$index] = str_replace( '%%%NODENAME%%%', urldecode( $Z[0]['name'] ) , $TPL[$index] );
  57. if( count( $S ) ){
  58. $CS = array();
  59. $FID = 0;
  60. $FUL = '';
  61. foreach( $S as $sou ){
  62. $QS = "SELECT * FROM media_servers WHERE id = {$sou['media_server_id']}";
  63. $F = $DATABASE->Query( $QS );
  64. $FF=$F[0];
  65. if( $FF['ip']=='127.0.0.1'){
  66. //Localhost
  67. $FF['ip'] = $_SERVER['SERVER_ADDR'];
  68. };
  69. $ACC_URL='http://' . $FF['ip'] . ':' . $FF['REST_port'];
  70. $CU = str_replace( $FF['virtual_host'], $ACC_URL, $sou['key'] ) . '/hls.m3u8';
  71. if( $FID == 0 ){
  72. // First URL as default
  73. $FID = $sou['id'];
  74. $FUL = $CU;
  75. };
  76. $CS[] = '[' . $sou['id'] . ',\'[' . $sou['img_width'] . 'x' . $sou['img_height'] . '] '. $sou['name'].'\',\'' . $CU .'\']';
  77. };
  78. $TPL[$index] = str_replace( '%%%URLS%%%', '['. implode( ',', $CS ) . ']' , $TPL[$index] );
  79. $TPL[$index] = str_replace( '%%%SELID%%%', 'value: '. $FID .',', $TPL[$index] );
  80. $TPL[$index] = str_replace( '%%%SELURL%%%', $FUL, $TPL[$index] );
  81. } else {
  82. // Handle No Video From Camera!
  83. $TPL[$index] = str_replace( '%%%URLS%%%', '[]' , $TPL[$index] );
  84. $TPL[$index] = str_replace( '%%%SELID%%%', 'value: \'No Video Sources\',', $TPL[$index] );
  85. $TPL[$index] = str_replace( '%%%SELURL%%%','', $TPL[$index] );
  86. };
  87. break;
  88. };
  89. };
  90. $index++;
  91. };
  92. };
  93. //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>\'}]}';
  94. $STOL[$i] = $P1 . implode( ',', $TPL ) . $P2;
  95. };
  96. $Data = '[' . implode( ',' , $STOL ) . ']';
  97. };
  98. if( $Data != '' ) {
  99. echo $Data;
  100. } else {
  101. echo '[]';
  102. };
  103. } else echo "[]";
  104. ?>