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.

74 lines
2.7 KiB

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. $QS = "SELECT * FROM nodes WHERE site_id = {$SiteID}";
  6. $result = $DATABASE->Query( $QS, false );
  7. $Data = file_get_contents( 'dash/tpl.js' );
  8. if( count( $result ) > 0 ){
  9. $index = 0;
  10. $TPL = array();
  11. foreach( $result as $R ){
  12. $TFN = 'dash/node_' . $R['type'] . '.js';
  13. if(!file_exists( $TFN )) continue;
  14. $TPL[$index] = file_get_contents( $TFN );
  15. $TPL[$index] = str_replace('%%%NODEID%%%', ''.$R['id'] , $TPL[$index] );
  16. switch( $R['type'] ){
  17. case ARGUS_SERVER:{
  18. break;
  19. };
  20. case ARGUS_3D_SENSOR:{
  21. break;
  22. };
  23. case ARGUS_IP_PTZ_CAMERA:{
  24. $QS="SELECT * FROM cameras WHERE node_id={$R['id']}";
  25. $Z=$DATABASE->Query( $QS );
  26. $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";
  27. $S=$DATABASE->Query( $QS );
  28. $TPL[$index] = str_replace( '%%%NODENAME%%%', urldecode( $Z[0]['name'] ) , $TPL[$index] );
  29. if( count( $S ) ){
  30. $CS = array();
  31. $FID = 0;
  32. $FUL = '';
  33. foreach( $S as $sou ){
  34. $QS = "SELECT * FROM media_servers WHERE id = {$sou['media_server_id']}";
  35. $F = $DATABASE->Query( $QS );
  36. $FF=$F[0];
  37. if( $FF['ip']=='127.0.0.1'){
  38. //Localhost
  39. $FF['ip'] = $_SERVER['SERVER_ADDR'];
  40. };
  41. $ACC_URL='http://' . $FF['ip'] . ':' . $FF['REST_port'];
  42. $CU = str_replace( $FF['virtual_host'], $ACC_URL, $sou['key'] ) . '/hls.m3u8';
  43. if( $FID == 0 ){
  44. // First URL as default
  45. $FID = $sou['id'];
  46. $FUL = $CU;
  47. };
  48. $CS[] = '[' . $sou['id'] . ',\'[' . $sou['img_width'] . 'x' . $sou['img_height'] . '] '. $sou['name'].'\',\'' . $CU .'\']';
  49. };
  50. $TPL[$index] = str_replace( '%%%URLS%%%', '['. implode( ',', $CS ) . ']' , $TPL[$index] );
  51. $TPL[$index] = str_replace( '%%%SELID%%%', 'value: '. $FID .',', $TPL[$index] );
  52. $TPL[$index] = str_replace( '%%%SELURL%%%', $FUL, $TPL[$index] );
  53. } else {
  54. // Handle No Video From Camera!
  55. $TPL[$index] = str_replace( '%%%URLS%%%', '[]' , $TPL[$index] );
  56. $TPL[$index] = str_replace( '%%%SELID%%%', 'value: \'No Video Sources\',', $TPL[$index] );
  57. $TPL[$index] = str_replace( '%%%SELURL%%%','', $TPL[$index] );
  58. };
  59. break;
  60. };
  61. };
  62. $index++;
  63. };
  64. $ITEMS = implode( ',', $TPL );
  65. $Data = str_replace('%%%ITEMS%%%', ''.$ITEMS , $Data );
  66. };
  67. if( $Data != '' ) {
  68. echo $Data;
  69. } else {
  70. echo '{}';
  71. };
  72. exit();
  73. };
  74. echo "{}";
  75. ?>