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.
 
 
 
 

148 lines
6.3 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:{
$TPL[$index] = str_replace('%%%SYSSERVERNAME%%%', $Labels->getLabel( 'SYS_SERVNAME' ), $TPL[$index] );
if( $R['online']== 1 ){
$TPL[$index] = str_replace('%%%SERVERSTATUS%%%', $Labels->getLabel('SRV_STATUS_ON') , $TPL[$index]);
$TPL[$index] = str_replace('%%%SERVERSTATUSIMG%%%', 'accept.png' , $TPL[$index]);
} else {
$TPL[$index] = str_replace('%%%SERVERSTATUS%%%', $Labels->getLabel('SRV_STATUS_OFF') , $TPL[$index]);
$TPL[$index] = str_replace('%%%SERVERSTATUSIMG%%%', 'stop.png' , $TPL[$index]);
};
$QS="SELECT * FROM `server_modules` WHERE `server_id`={$R['aux_id']}";
$Z=$DATABASE->Query($QS);
$MODULES = array();
if(count($Z)){
foreach( $Z as $mod ){
$QS="SELECT * FROM server_module_types WHERE id={$mod['type']}";
$mtt=$DATABASE->Query( $QS );
$CM['xtype'] = 'panel';
if( $mod['enabled'] == 1 ){
$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>';
} else {
$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>';
};
$CM['height'] = 25;
$MODULES[] = $CM;
};
} else {
$MODULES[] = '[{ html: \'No Modules Defined\'}]';
};
$MODULES_CNT = json_encode( $MODULES );
$TPL[$index] = str_replace('%%%MODULES%%%', ''.$MODULES_CNT , $TPL[$index] );
break;
};
case ARGUS_LFS_SENSOR:
case ARGUS_PLS_200_SENSOR:
case ARGUS_PLS_360_SENSOR:{
break;
};
case ARGUS_3D_SENSOR:{
break;
};
case 10:
case 11:
case 12:
case ARGUS_IP_PTZ_CAMERA:{
//$QS="SELECT * FROM cameras WHERE node_id={$R['id']}";
$QS="SELECT * FROM `nodes` WHERE `id`={$R['id']}";
$Z=$DATABASE->Query( $QS );
$QS="SELECT * FROM `module_embed_video_settings` WHERE `id`=1";
$S=$DATABASE->Query( $QS );
$TPL[$index] = str_replace( '%%%NODENAME%%%', urldecode( $Z[0]['name'] ) , $TPL[$index] );
$FU = 'http://' . $_SERVER['SERVER_ADDR'].':' . $S[0]['web_port'] .'/stream?id='. $Z[0]['aux_parameter'];
$CS[] = '[' . $Z[0]['aux_parameter'] . ',\'[ 120x120] Video\',\''. $FU .'\']';
$TPL[$index] = str_replace( '%%%URLS%%%', '[' . $CS . ']' , $TPL[$index] );
$TPL[$index] = str_replace( '%%%SELID%%%', 'value: '. $Z[0]['aux_parameter'] .',', $TPL[$index] );
$TPL[$index] = str_replace( '%%%SELURL%%%', $FU, $TPL[$index] );
/*
$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 );
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 "[]";
?>