Web Interface For Lite Argus Control modules
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.
 
 
 
 

182 lines
8.0 KiB

<?php
require_once('../ajax_asm.php');
$UID = intval( $CUser->Data['id'] );
$Data = '';
if( $UID > 1 ){
$QS = "SELECT * FROM `system_props` LIMIT 1";
$SPD = $DATABASE->Query( $QS );
if( count( $SPD ) ){
$SP = $SPD[0];
$DUMM = array();
$DUMM['camera']="{xtype:'panel',html:'NO CAMERA'}";
$DUMM['sensor']="{xtype:'panel',html:'NO SENSOR'}";
$DUMM['map']="{xtype:'panel',html:'NO MAP'}";
$DUMM['log']="{xtype:'panel',html:'NO LOG'}";
$STA = array();
$END="]}";
$STA[0]="{ columnWidth: 1, style:'padding:10px 0 10px 10px', items:[";
$STA[1]="{ columnWidth: 0.5, style:'padding:10px 0 10px 10px', items:[";
$STA[2]="{ columnWidth: 0.5, style:'padding:10px 0 10px 10px', items:[";
$STA[3]="{ columnWidth: 0.25, style:'padding:10px 0 10px 10px', items:[";
$STA[4]="{ columnWidth: 0.25, style:'padding:10px 0 10px 10px', items:[";
$STA[5]="{ columnWidth: 0.25, style:'padding:10px 0 10px 10px', items:[";
$STA[6]="{ columnWidth: 0.25, style:'padding:10px 0 10px 10px', items:[";
$MCOL = 7;
$P1="{ columnWidth: .25, style:'padding:10px 0 10px 10px', items:[";
$P2="]}";
$QS = "SELECT * FROM nodes WHERE `type`> 0 ";
$result = $DATABASE->Query( $QS, false );
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[$MCOL-1][]=$z;
$STOL = array();
for( $i=0; $i < $MCOL; $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;
};
$MODULES_CNT = json_encode( $MODULES );
} else {
$MODULES_CNT = '[{ html: \'No Modules Defined\'}]';
};
$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_eve` WHERE `id`=1";
$S=$DATABASE->Query( $QS );
$MODULE_DATA = $S[0];
$TPL[$index] = str_replace( '%%%NODENAME%%%', urldecode( $Z[0]['name'] ) , $TPL[$index] );
$FU = 'http://' . $_SERVER['SERVER_ADDR'].':' . $MODULE_DATA['web_port'] .'/stream?id='. $Z[0]['aux_parameter'];
$CS[] = '[' . $Z[0]['aux_parameter'] . ',\'[ 120x120] Video\',\''. $FU .'\']';
$TPL[$index] = str_replace( '%%%URLS%%%', '[' . implode( ',', $CS ) . ']' , $TPL[$index] );
$TPL[$index] = str_replace( '%%%SELID%%%', 'value: '. $Z[0]['aux_parameter'] .',', $TPL[$index] );
$TPL[$index] = str_replace( '%%%SELURL%%%', $FU, $TPL[$index] );
$TPL[$index] = str_replace( '%%%STREAMID%%%', $R['aux_parameter'], $TPL[$index] );
$FK = $MODULE_DATA['height'] /$MODULE_DATA['width'];
$W = 244;
$H = $W * $FK;
$TPL[$index] = str_replace( '%%%WIDTH%%%', $W, $TPL[$index] );
$TPL[$index] = str_replace( '%%%HEIGHT%%%', $H, $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] = $STA[$i] . implode( ',', $TPL ) . $END;
};
//$STOL[] = "{ columnWidth: 0.5, style:'padding:10px 0 10px 10px', items:[]}";
//$STOL[] = "{ columnWidth: 0.5, style:'padding:10px 0 10px 10px', items:[]}";
//$STOL[] = "{ columnWidth: 1, style:'padding:10px 0 10px 10px', items:[]}";
$Data = '[' . implode( ',' , $STOL ) . ']';
};
} else {
$Data = '[{columnWidth: 1, items:{html:"NO SYSTEM PROPS"}} ]';
};
};
if( $Data != '' ) {
echo $Data;
} else {
echo '[]';
};
?>