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.
 
 
 
 

105 lines
3.9 KiB

<?php
require_once('../ajax_asm.php');
if( $CUser->Data['id'] > 1 ){
$SiteID = intval( $_POST['SITE'] );
$UID = intval( $CUser->Data['id'] );
$QS = "SELECT * FROM nodes WHERE site_id = {$SiteID}";
$result = $DATABASE->Query( $QS, false );
$P1="{ columnWidth: '320px', style:'padding:10px 0 10px 10px', items:[";
$P2="]}";
if( count( $result ) > 0 ){
$QS = "SELECT * FROM users_dash_layout WHERE user_id={$UID} ORDER BY x,y";
$Lay = $DATABASE->Query( $QS, false );
$AL = array();
foreach( $Lay as $L ){
$AL[$L['node_id']]=$L;
};
$COLS = array();
$Z = array();
foreach( $result as $R ){
if( isset( $AL[$R['id']] ) ){
$COLS[intval($AL[$R['id']]['x'])][intval($AL[$R['id']]['y'])] = $R;
} else {
$Z[] = $R;
};
};
if( count( $Z ) ) foreach( $Z as $z ) $COLS[0][]=$z;
$STOL = array();
for( $i=0; $i < 4; $i++ ){
$index = 0;
$TPL = array();
$STOL[] = array();
if( isset( $COLS[$i] ) ){
foreach( $COLS[$i] as $R ){
$TFN = 'dash/node_' . $R['type'] . '.js';
if(!file_exists( $TFN )) continue;
$TPL[$index] = file_get_contents( $TFN );
$TPL[$index] = str_replace('%%%NODEID%%%', ''.$R['id'] , $TPL[$index] );
$TPL[$index] = str_replace('%%%NODENAME%%%', ''.$R['name'] , $TPL[$index] );
switch( $R['type'] ){
case ARGUS_SERVER:{
break;
};
case ARGUS_LFS_SENSOR:
case ARGUS_PLS_200_SENSOR:
case ARGUS_PLS_360_SENSOR:{
break;
};
case ARGUS_3D_SENSOR:{
break;
};
case ARGUS_IP_PTZ_CAMERA:{
$QS="SELECT * FROM cameras WHERE node_id={$R['id']}";
$Z=$DATABASE->Query( $QS );
$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";
$S=$DATABASE->Query( $QS );
$TPL[$index] = str_replace( '%%%NODENAME%%%', urldecode( $Z[0]['name'] ) , $TPL[$index] );
if( count( $S ) ){
$CS = array();
$FID = 0;
$FUL = '';
foreach( $S as $sou ){
$QS = "SELECT * FROM media_servers WHERE id = {$sou['media_server_id']}";
$F = $DATABASE->Query( $QS );
$FF=$F[0];
if( $FF['ip']=='127.0.0.1'){
//Localhost
$FF['ip'] = $_SERVER['SERVER_ADDR'];
};
$ACC_URL='http://' . $FF['ip'] . ':' . $FF['REST_port'];
$CU = str_replace( $FF['virtual_host'], $ACC_URL, $sou['key'] ) . '/hls.m3u8';
if( $FID == 0 ){
// First URL as default
$FID = $sou['id'];
$FUL = $CU;
};
$CS[] = '[' . $sou['id'] . ',\'[' . $sou['img_width'] . 'x' . $sou['img_height'] . '] '. $sou['name'].'\',\'' . $CU .'\']';
};
$TPL[$index] = str_replace( '%%%URLS%%%', '['. implode( ',', $CS ) . ']' , $TPL[$index] );
$TPL[$index] = str_replace( '%%%SELID%%%', 'value: '. $FID .',', $TPL[$index] );
$TPL[$index] = str_replace( '%%%SELURL%%%', $FUL, $TPL[$index] );
} else {
// Handle No Video From Camera!
$TPL[$index] = str_replace( '%%%URLS%%%', '[]' , $TPL[$index] );
$TPL[$index] = str_replace( '%%%SELID%%%', 'value: \'No Video Sources\',', $TPL[$index] );
$TPL[$index] = str_replace( '%%%SELURL%%%','', $TPL[$index] );
};
break;
};
};
$index++;
};
};
//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>\'}]}';
$STOL[$i] = $P1 . implode( ',', $TPL ) . $P2;
};
$Data = '[' . implode( ',' , $STOL ) . ']';
};
if( $Data != '' ) {
echo $Data;
} else {
echo '[]';
};
} else echo "[]";
?>