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.
 
 
 
 

697 lines
29 KiB

<?php
require_once('../ajax_asm.php');
function inject_labels( $TPL ){
global $Labels;
$TPL = str_replace('%%%LABEL%%%TOOLBOX%%%', $Labels->GetLabel('_TOOLBOX_') , $TPL );
$TPL = str_replace('%%%LABEL%%%CLEALARM%%%', $Labels->GetLabel('_CLEAR_ALARM_') , $TPL );
$TPL = str_replace('%%%LABEL%%%DRABACKGROUND%%%', $Labels->GetLabel('_DRAW_BACKGROUND_') , $TPL );
$TPL = str_replace('%%%LABEL%%%STUBACKGROUND%%%', $Labels->GetLabel('_STUDY_BACKGROUND_') , $TPL );
$TPL = str_replace('%%%LABEL%%%MASKEDITOR%%%', $Labels->GetLabel('_MASK_EDITOR_') , $TPL );
$TPL = str_replace('%%%LABEL%%%MASKMNGR%%%', $Labels->GetLabel('_MASK_MANAGER_') , $TPL );
$TPL = str_replace('%%%LABEL%%%ACKNOLAGE%%%', $Labels->GetLabel('_DEV_ACK_BTN_') , $TPL );
return $TPL;
};
$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];
$DUMMY = array();
if( $CUser->Data['access'] > 5 ){
//$CUser->Data['width']
//$CUser->Data['height']
$TABA =<<<_DATA_BOUNDARY
{
xtype: 'panel',
html: '<table id="tbl_ph_ccc_%%ID%%" style="color: black; background-image: url(\'/style/assets/16-9-nocam.png\');" width="100%" border=0><tr><td colspan=3>&nbsp;</td></tr><tr><td>&nbsp;</td><td align="center"><div id="btn_ph_ccc_%%ID%%"></div></td><td>&nbsp;</td></tr><tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr></table>',
listeners:{
afterrender : function( ){
var tb = document.getElementById('tbl_ph_ccc_%%ID%%');
var W = tb.offsetWidth;
var H = (W/16)*9;
tb.setAttribute("height", H );
tb.style.backgroundSize=W+"px "+H+"px";
var p = Ext.getCmp('pan_ph_ccc_%%ID%%');
p.setHeight( H+40 );
var jaja = Ext.create({
xtype: 'panel',
title: '{$Labels->GetLabel('_MSG_CAM_NOT_ASS_')}',
frame: true,
renderTo: 'btn_ph_ccc_%%ID%%',
layout: 'vbox',
width: 500,
height: 120,
items:[{
xtype: 'spacer',
height: 10
},{
width: '100%',
html: '<center>{$Labels->GetLabel('_MSG_CAM_PROC_NOT_ASS_')}</center>'
},{
xtype: 'spacer',
height: 20
},{
xtype: 'button',
width: '100%',
text: 'Open Camera Settings',
handler: function(){
showContent( 2020 );
}
}]
});
jaja.doLayout();
}
}
}
_DATA_BOUNDARY;
$DUMMY['camera']="{xtype:'panel', id:'pan_ph_ccc_%%ID%%', title: 'Camera Placeholder', frame: true, border: true, draggable: false, layouit: 'fit', items:{$TABA}}";
$DUMMY['sensor']="{xtype:'panel', title: '{$Labels->GetLabel('_SENSOR_PLACE_')}', frame: true, border: true, draggable: false, html:'NO SENSOR', listeners:{ afterrender: function(p){ var W=p.getWidth(); p.setHeight( 32+(W/16)*9);}}}";
} else {
$DUMMY['camera']="{xtype:'panel', title: false, frame: true, draggable: false, html: '&nbsp;', listeners:{ afterrender: function(p){ var W=p.getWidth(); p.setHeight( 32+(W/16)*9);}}}";
$DUMMY['sensor']="{xtype:'panel', title: false, frame: true, draggable: false, html: '&nbsp;', listeners:{ afterrender: function(p){ var W=p.getWidth(); p.setHeight( 32+(W/16)*9);}}}";
};
$LOGIO=<<<_DATA_BOUNDARY
{
xtype: 'grid',
id: 'log_grid',
border: false,
frame: false,
autoScroll: true,
//width: '100%',
lazyRender: true,
height: 210,
ds: log_store,
cm: new Ext.grid.ColumnModel( log_ColModel_ops ),
sm: new Ext.grid.RowSelectionModel( log_SelModel_ops ),
viewConfig: {
forceFit: true,
getRowClass: function( record, rowIndex, rowParams, store){
switch( record.get('node_id')%5 ){
case 0: return 'row-level01';
case 1: return 'row-level02';
case 2: return 'row-level03';
case 3: return 'row-level04';
case 4: return 'row-level05';
};
return '';
}
},
listeners:{
afterrender : function( t ){
var papa = Ext.getCmp('main_portal');
var jj = papa.getComponent( 0 ).getHeight();
var zz = t.ownerCt.ownerCt.getHeight();
//alert( PanelW );
//alert( PanelH - zz );
//t.setHeight( PanelH - jj - 20 );
t.setHeight( PanelH - zz - 42 );
}
}
}
_DATA_BOUNDARY;
$MAPIO=<<<_DATA_BOUNDARY
{
id: 'event_map',
height: 200,
html: '&nbsp;',
listeners:{
afterrender : function( t ){
var papa = Ext.getCmp('main_portal');
var jj = papa.getComponent( 0 ).getHeight();
t.setHeight( jj - 40 );
geoMapIsPresent = true;
}
}
}
_DATA_BOUNDARY;
$MH = 9;
if( $SP['app_layout'] == 2 ) $MH = 6;
$DUMMY['map']="{xtype:'panel', title: '{$Labels->GetLabel('_MAP_')}', frame: true, border: true, draggable: false, collapsible: false, tools: [{ id:'toggle', handler: function( a, b, p ){ fullScreen( 'event_map' ); }}], items:[{$MAPIO}],listeners:{ afterrender: function(p){ var W=p.getWidth(); p.setHeight( 32+(W/16)*{$MH}); initMapMonitoring();}} }";
$DUMMY['log']="{xtype:'panel', id: 'lg_panel', title: '{$Labels->GetLabel('_EVENT_LOG_')}', frame: true, border: true, draggable: false, items:[{$LOGIO}] }";
$STA = array();
$END="]}";
$OUT = array();
switch( $SP['app_layout'] ){
case 0:{
$STA[0]="{ columnWidth: .25, stylse:'padding:10px 0 10px 10px', items:[";
$STA[1]="{ columnWidth: .25, stylse:'padding:10px 0 10px 10px', items:[";
$STA[2]="{ columnWidth: .25, stylse:'padding:10px 0 10px 10px', items:[";
$STA[3]="{ columnWidth: .25, stylse:'padding:10px 0 10px 10px', items:[";
$STA[4]="{ columnWidth: .5, stylde:'padding:10px 0 10px 10px', items:[";
$STA[5]="{ columnWidth: .5, stylde:'padding:10px 0 10px 10px', items:[";
$STA[6]="{ columnWidth: 1.0, stydle:'padding:10px 0 10px 10px', items:[";
$QS = "SELECT * FROM `nodes` WHERE `type`>0 AND `type`< 10 AND `enable`=1";
$R = $DATABASE->Query( $QS );
$idx = 0;
if( count( $R ) ){
foreach( $R as $DD ){
if( $idx < 4 ){
$TFN = 'dash/node_' . $DD['type'] . '.js';
if(!file_exists( $TFN )) continue;
$TPL = file_get_contents( $TFN );
$TPL = inject_labels( $TPL );
$TPL = str_replace('%%%NODEID%%%', ''.$DD['id'] , $TPL );
$TPL = str_replace('%%%NODENAME%%%', ''. urldecode( $DD['name'] ), $TPL );
$TPL = str_replace('%%%USERID%%%', $UserID, $TPL );
$TPL = str_replace('%%%SESSION%%%', $Session, $TPL );
$TPL = str_replace('%%%APPTYPE%%%', $SP['type'], $TPL );
$OUT[]= $STA[$idx] . $TPL . $END;
} else break;
$idx++;
};
if( $idx < 4 ){
for( ;$idx<4;$idx++ ){
$OUT[]= $STA[$idx] . $DUMMY['sensor'] . $END;
};
};
} else {
for( ;$idx<4;$idx++ ){
$OUT[]= $STA[$idx] . $DUMMY['sensor'] . $END;
};
};
$QS = "SELECT * FROM `nodes` WHERE `type`>9 AND `type`< 16 AND `enable`=1";
$R = $DATABASE->Query( $QS );
$idx = 0;
if( count( $R ) ){
foreach( $R as $DD ){
if( $idx < 2 ){
$TFN = 'dash/node_' . $DD['type'] . '.js';
if(!file_exists( $TFN )) continue;
$TPL = file_get_contents( $TFN );
$TPL = inject_labels( $TPL );
$TPL = str_replace('%%%NODEID%%%', ''.$DD['id'] , $TPL );
$TPL = str_replace('%%%NODENAME%%%', ''.urldecode( $DD['name'] ) , $TPL );
$TPL = str_replace('%%%USERID%%%', $UserID, $TPL );
$TPL = str_replace('%%%SESSION%%%', $Session, $TPL );
$TPL = str_replace('%%%APPTYPE%%%', $SP['type'], $TPL );
$QS="SELECT * FROM `nodes` WHERE `id`={$DD['id']}";
$Z=$DATABASE->Query( $QS );
$QS="SELECT * FROM `module_eve` LIMIT 1";
$S=$DATABASE->Query( $QS );
$MODULE_DATA = $S[0];
$TPL = str_replace( '%%%NODENAME%%%', urldecode( $Z[0]['name'] ) , $TPL );
//$FU = 'http://' . $_SERVER['SERVER_ADDR'].':' . $MODULE_DATA['web_port'] .'/stream?id='. $Z[0]['aux_parameter'];
$FU = '/video_feed/stream?id='. $Z[0]['aux_parameter'];
$CS[] = '[' . $Z[0]['aux_parameter'] . ',\'[ 120x120] Video\',\''. $FU .'\']';
$TPL = str_replace( '%%%URLS%%%', '[' . implode( ',', $CS ) . ']' , $TPL );
$TPL = str_replace( '%%%SELID%%%', 'value: '. $Z[0]['aux_parameter'] .',', $TPL );
$TPL = str_replace( '%%%SELURL%%%', $FU, $TPL );
$TPL = str_replace( '%%%STREAMID%%%', $DD['aux_parameter'], $TPL );
if( $DD['type'] == 15 || $DD['type'] == 14 || $DD['type'] == 13 || $DD['type'] == 11 ){
$QS = "SELECT `homing_enable` FROM `cameras` WHERE `id`={$DD['aux_id']}";
$JUA = $DATABASE->Query( $QS );
$CAMDATA = $JUA[0];
if( $CAMDATA['homing_enable'] ){
if( $CUser->Data['access'] > 5 ){
$TPL = str_replace( '%%%HBTN%%%', '<img id="img_btn_0ZZ_'.$DD['aux_id'].'" class="ptz_ctrl_btn" src="/style/png/building/038.png">', $TPL );
$TPL = str_replace('%%%CAM_CTRL_HOME_BTN_BIND%%%', 'document.getElementById(\'img_btn_0ZZ_'.$DD['aux_id'].'\').addEventListener( \'mousedown\', makePtzHome );', $TPL );
} else {
$TPL = str_replace('%%%HBTN%%%', '&nbsp;', $TPL );
$TPL = str_replace('%%%CAM_CTRL_HOME_BTN_BIND%%%', '', $TPL );
};
} else {
$TPL = str_replace('%%%HBTN%%%', '&nbsp;', $TPL );
$TPL = str_replace('%%%CAM_CTRL_HOME_BTN_BIND%%%', '', $TPL );
};
};
$FK = $MODULE_DATA['height'] /$MODULE_DATA['width'];
$W = 244;
$H = $W * $FK;
$TPL = str_replace( '%%%WIDTH%%%', $W, $TPL );
$TPL = str_replace( '%%%HEIGHT%%%', $H, $TPL );
$OUT[]= $STA[4+$idx] . $TPL . $END;
} else break;
$idx++;
};
if( $idx < 2 ){
for( ;$idx<2;$idx++ ){
$T = str_replace( '%%ID%%', 4+$idx , $DUMMY['camera'] );
$OUT[]= $STA[4+$idx] . $T . $END;
};
};
} else {
for( ;$idx<2;$idx++ ){
$T = str_replace( '%%ID%%', 4+$idx , $DUMMY['camera'] );
$OUT[]= $STA[4+$idx] . $T . $END;
};
};
switch( $SP['type'] ){
case 1:{
// LA Metro
$OUT[]= $STA[6] . $DUMMY['log'] . $END;
break;
};
case 2:{
//Togo
$OUT[]= $STA[6] . $DUMMY['map'] . $END;
break;
};
}
break;
};
case 1:{
$STA[0]="{ columnWidth: .33, stylse:'padding:10px 0 10px 10px', items:[";
$STA[1]="{ columnWidth: .33, stylse:'padding:10px 0 10px 10px', items:[";
$STA[2]="{ columnWidth: .33, stylse:'padding:10px 0 10px 10px', items:[";
$STA[3]="{ columnWidth: 1.0, stylse:'padding:10px 0 10px 10px', items:[";
$QS = "SELECT * FROM `nodes` WHERE `type`>0 AND `type`< 10 AND `enable`=1";
$R = $DATABASE->Query( $QS );
$idx = 0;
if( count( $R ) ){
foreach( $R as $DD ){
if( $idx < 2 ){
$TFN = 'dash/node_' . $DD['type'] . '.js';
if(!file_exists( $TFN )) continue;
$TPL = file_get_contents( $TFN );
$TPL = inject_labels( $TPL );
$TPL = str_replace('%%%NODEID%%%', ''.$DD['id'] , $TPL );
$TPL = str_replace('%%%NODENAME%%%', ''.html_entity_decode( $DD['name'] ) , $TPL );
$TPL = str_replace('%%%USERID%%%', $UserID, $TPL );
$TPL = str_replace('%%%SESSION%%%', $Session, $TPL );
$TPL = str_replace('%%%APPTYPE%%%', $SP['type'], $TPL );
$OUT[]= $STA[$idx] . $TPL . $END;
} else break;
$idx++;
};
if( $idx < 2 ){
for( ;$idx<2;$idx++ ){
$OUT[]= $STA[$idx] . $DUMMY['sensor'] . $END;
};
};
} else {
for( ;$idx<2;$idx++ ){
$OUT[]= $STA[$idx] . $DUMMY['sensor'] . $END;
};
};
$QS = "SELECT * FROM `nodes` WHERE `type`>9 AND `type`< 16 AND `enable`=1";
$R = $DATABASE->Query( $QS );
$idx = 0;
if( count( $R ) ){
foreach( $R as $DD ){
if( $idx < 1 ){
$TFN = 'dash/node_' . $DD['type'] . '.js';
if(!file_exists( $TFN )) continue;
$TPL = file_get_contents( $TFN );
$TPL = inject_labels( $TPL );
$TPL = str_replace('%%%NODEID%%%', ''.$DD['id'] , $TPL );
$TPL = str_replace('%%%NODENAME%%%', ''.urldecode($DD['name']) , $TPL );
$TPL = str_replace('%%%USERID%%%', $UserID, $TPL );
$TPL = str_replace('%%%SESSION%%%', $Session, $TPL );
$TPL = str_replace('%%%APPTYPE%%%', $SP['type'], $TPL );
$QS="SELECT * FROM `nodes` WHERE `id`={$DD['id']}";
$Z=$DATABASE->Query( $QS );
$QS="SELECT * FROM `module_eve` LIMIT 1";
$S=$DATABASE->Query( $QS );
$MODULE_DATA = $S[0];
$TPL = str_replace( '%%%NODENAME%%%', urldecode( $Z[0]['name'] ) , $TPL );
//$FU = 'http://' . $_SERVER['SERVER_ADDR'].':' . $MODULE_DATA['web_port'] .'/stream?id='. $Z[0]['aux_parameter'];
$FU = '/video_feed/stream?id='. $Z[0]['aux_parameter'];
$CS[] = '[' . $Z[0]['aux_parameter'] . ',\'[ 120x120] Video\',\''. $FU .'\']';
$TPL = str_replace( '%%%URLS%%%', '[' . implode( ',', $CS ) . ']' , $TPL );
$TPL = str_replace( '%%%SELID%%%', 'value: '. $Z[0]['aux_parameter'] .',', $TPL );
$TPL = str_replace( '%%%SELURL%%%', $FU, $TPL );
$TPL = str_replace( '%%%STREAMID%%%', $DD['aux_parameter'], $TPL );
if( $DD['type'] == 15 || $DD['type'] == 14 || $DD['type'] == 13 || $DD['type'] == 11 ){
$QS = "SELECT `homing_enable` FROM `cameras` WHERE `id`={$DD['aux_id']}";
$JUA = $DATABASE->Query( $QS );
$CAMDATA = $JUA[0];
if( $CAMDATA['homing_enable'] ){
if( $CUser->Data['access'] > 5 ){
$TPL = str_replace( '%%%HBTN%%%', '<img id="img_btn_0ZZ_'.$DD['aux_id'].'" class="ptz_ctrl_btn" src="/style/png/building/038.png">', $TPL );
$TPL = str_replace('%%%CAM_CTRL_HOME_BTN_BIND%%%', 'document.getElementById(\'img_btn_0ZZ_'.$DD['aux_id'].'\').addEventListener( \'mousedown\', makePtzHome );', $TPL );
} else {
$TPL = str_replace('%%%HBTN%%%', '&nbsp;', $TPL );
$TPL = str_replace('%%%CAM_CTRL_HOME_BTN_BIND%%%', '', $TPL );
};
} else {
$TPL = str_replace('%%%HBTN%%%', '&nbsp;', $TPL );
$TPL = str_replace('%%%CAM_CTRL_HOME_BTN_BIND%%%', '', $TPL );
};
};
$FK = $MODULE_DATA['height'] /$MODULE_DATA['width'];
$W = 244;
$H = $W * $FK;
$TPL = str_replace( '%%%WIDTH%%%', $W, $TPL );
$TPL = str_replace( '%%%HEIGHT%%%', $H, $TPL );
$OUT[]= $STA[2+$idx] . $TPL . $END;
} else break;
$idx++;
};
if( $idx < 1 ){
for( ;$idx<1;$idx++ ){
$T = str_replace( '%%ID%%', 2+$idx , $DUMMY['camera'] );
$OUT[]= $STA[2+$idx] . $T . $END;
};
};
} else {
for( ;$idx<1;$idx++ ){
$T = str_replace( '%%ID%%', 4+$idx , $DUMMY['camera'] );
$OUT[]= $STA[2+$idx] . $T . $END;
};
};
switch( $SP['type'] ){
case 1:{
// LA Metro
$OUT[]= $STA[3] . $DUMMY['log'] . $END;
break;
};
case 2:{
//Togo
$OUT[]= $STA[3] . $DUMMY['map'] . $END;
break;
};
}
break;
};
case 2:{
$STA[0]="{ columnWidth: .33, stylse:'padding:10px 0 10px 10px', items:[";//Sen1
$STA[1]="{ columnWidth: .33, stylse:'padding:10px 0 10px 10px', items:[";//Cam1
$STA[2]="{ columnWidth: .33, stylse:'padding:10px 0 10px 10px', items:[";//Cam2
$STA[3]="{ columnWidth: .33, stylse:'padding:10px 0 10px 10px', items:[";//Sen2
$STA[4]="{ columnWidth: .66, stylde:'padding:10px 0 10px 10px', items:[";//Log/Map
$idx = 0;
$QS = "SELECT * FROM `nodes` WHERE `type`>0 AND `type`< 10 AND `enable`=1";
$DEVS = $DATABASE->Query( $QS );
if( count( $DEVS ) ){
$WOU = array();
foreach( $DEVS as $DD ){
if( $idx < 2 ){
$TFN = 'dash/node_' . $DD['type'] . '.js';
if(!file_exists( $TFN )) continue;
$TPL = file_get_contents( $TFN );
$TPL = inject_labels( $TPL );
$TPL = str_replace('%%%NODEID%%%', ''.$DD['id'] , $TPL );
$TPL = str_replace('%%%NODENAME%%%', ''.html_entity_decode( $DD['name'] ) , $TPL );
$TPL = str_replace('%%%USERID%%%', $UserID, $TPL );
$TPL = str_replace('%%%SESSION%%%', $Session, $TPL );
$TPL = str_replace('%%%APPTYPE%%%', $SP['type'], $TPL );
$WOU[]= $TPL;
} else break;
$idx++;
};
if( $idx < 2 ) for( ;$idx<2;$idx++ ) $WOU[]= $DUMMY['sensor'];
$OUT[]= $STA[0] . implode(',', $WOU ) . $END;
} else {
for( ;$idx<3;$idx++ ){
$OUT[]= $STA[$idx] . $DUMMY['sensor'] . $END;
};
};
$QS = "SELECT * FROM `nodes` WHERE `type`>9 AND `type`< 16 AND `enable`=1";
$CAMS = $DATABASE->Query( $QS );
$idx = 0;
if( count( $CAMS ) ){
foreach( $CAMS as $DD ){
if( $idx < 2 ){
$TFN = 'dash/node_' . $DD['type'] . '.js';
if(!file_exists( $TFN )) continue;
$TPL = file_get_contents( $TFN );
$TPL = inject_labels( $TPL );
$TPL = str_replace('%%%NODEID%%%', ''.$DD['id'] , $TPL );
$TPL = str_replace('%%%NODENAME%%%', ''.urldecode($DD['name']) , $TPL );
$TPL = str_replace('%%%USERID%%%', $UserID, $TPL );
$TPL = str_replace('%%%SESSION%%%', $Session, $TPL );
$TPL = str_replace('%%%APPTYPE%%%', $SP['type'], $TPL );
$QS="SELECT * FROM `nodes` WHERE `id`={$DD['id']}";
$Z=$DATABASE->Query( $QS );
$QS="SELECT * FROM `module_eve` LIMIT 1";
$S=$DATABASE->Query( $QS );
$MODULE_DATA = $S[0];
$TPL = str_replace( '%%%NODENAME%%%', urldecode( $Z[0]['name'] ) , $TPL );
//$FU = 'http://' . $_SERVER['SERVER_ADDR'].':' . $MODULE_DATA['web_port'] .'/stream?id='. $Z[0]['aux_parameter'];
$FU = '/video_feed/stream?id='. $Z[0]['aux_parameter'];
$CS[] = '[' . $Z[0]['aux_parameter'] . ',\'[ 120x120] Video\',\''. $FU .'\']';
$TPL = str_replace( '%%%URLS%%%', '[' . implode( ',', $CS ) . ']' , $TPL );
$TPL = str_replace( '%%%SELID%%%', 'value: '. $Z[0]['aux_parameter'] .',', $TPL );
$TPL = str_replace( '%%%SELURL%%%', $FU, $TPL );
$TPL = str_replace( '%%%STREAMID%%%', $DD['aux_parameter'], $TPL );
if( $DD['type'] == 15 || $DD['type'] == 14 || $DD['type'] == 13 || $DD['type'] == 11 ){
$QS = "SELECT `homing_enable` FROM `cameras` WHERE `id`={$DD['aux_id']}";
$JUA = $DATABASE->Query( $QS );
$CAMDATA = $JUA[0];
if( $CAMDATA['homing_enable'] ){
if( $CUser->Data['access'] > 5 ){
$TPL = str_replace( '%%%HBTN%%%', '<img id="img_btn_0ZZ_'.$DD['aux_id'].'" class="ptz_ctrl_btn" src="/style/png/building/038.png">', $TPL );
$TPL = str_replace('%%%CAM_CTRL_HOME_BTN_BIND%%%', 'document.getElementById(\'img_btn_0ZZ_'.$DD['aux_id'].'\').addEventListener( \'mousedown\', makePtzHome );', $TPL );
} else {
$TPL = str_replace('%%%HBTN%%%', '&nbsp;', $TPL );
$TPL = str_replace('%%%CAM_CTRL_HOME_BTN_BIND%%%', '', $TPL );
};
} else {
$TPL = str_replace('%%%HBTN%%%', '&nbsp;', $TPL );
$TPL = str_replace('%%%CAM_CTRL_HOME_BTN_BIND%%%', '', $TPL );
};
};
$FK = $MODULE_DATA['height'] /$MODULE_DATA['width'];
$W = 244;
$H = $W * $FK;
$TPL = str_replace( '%%%WIDTH%%%', $W, $TPL );
$TPL = str_replace( '%%%HEIGHT%%%', $H, $TPL );
$OUT[]= $STA[1+$idx] . $TPL . $END;
} else break;
$idx++;
};
if( $idx < 2 ){
for( ;$idx<2;$idx++ ){
$T = str_replace( '%%ID%%', 2+$idx , $DUMMY['camera'] );
$OUT[]= $STA[1+$idx] . $T . $END;
};
};
} else {
for( ;$idx<2;$idx++ ){
$T = str_replace( '%%ID%%', 4+$idx , $DUMMY['camera'] );
$OUT[]= $STA[1+$idx] . $T . $END;
};
};
$OUT[]= $STA[4] . $DUMMY['map'] .','. $DUMMY['log'] . $END;
//$OUT[]= $STA[4] . . $END;
break;
};
case 3:{
$STA[0]="{ columnWidth: .5, stylse:'padding:10px 0 10px 10px', items:[";
$STA[1]="{ columnWidth: .5, stylse:'padding:10px 0 10px 10px', items:[";
$STA[2]="{ columnWidth: .33, stylse:'padding:10px 0 10px 10px', items:[";
$STA[3]="{ columnWidth: .67, stylse:'padding:10px 0 10px 10px', items:[";
$OUT[]= $STA[0] . $DUMMY['map'] . $END;
$QS = "SELECT * FROM `nodes` WHERE `type`>9 AND `type`< 16 AND `enable`=1";
$R = $DATABASE->Query( $QS );
$idx = 0;
if( count( $R ) ){
foreach( $R as $DD ){
if( $idx < 1 ){
$TFN = 'dash/node_' . $DD['type'] . '.js';
if(!file_exists( $TFN )) continue;
$TPL = file_get_contents( $TFN );
$TPL = inject_labels( $TPL );
$TPL = str_replace('%%%NODEID%%%', ''.$DD['id'] , $TPL );
$TPL = str_replace('%%%NODENAME%%%', ''.urldecode($DD['name']) , $TPL );
$TPL = str_replace('%%%USERID%%%', $UserID, $TPL );
$TPL = str_replace('%%%SESSION%%%', $Session, $TPL );
$TPL = str_replace('%%%APPTYPE%%%', $SP['type'], $TPL );
$QS="SELECT * FROM `nodes` WHERE `id`={$DD['id']}";
$Z=$DATABASE->Query( $QS );
$QS="SELECT * FROM `module_eve` LIMIT 1";
$S=$DATABASE->Query( $QS );
$MODULE_DATA = $S[0];
$TPL = str_replace( '%%%NODENAME%%%', urldecode( $Z[0]['name'] ) , $TPL );
//$FU = 'http://' . $_SERVER['SERVER_ADDR'].':' . $MODULE_DATA['web_port'] .'/stream?id='. $Z[0]['aux_parameter'];
$FU = '/video_feed/stream?id='. $Z[0]['aux_parameter'];
$CS[] = '[' . $Z[0]['aux_parameter'] . ',\'[ 120x120] Video\',\''. $FU .'\']';
$TPL = str_replace( '%%%URLS%%%', '[' . implode( ',', $CS ) . ']' , $TPL );
$TPL = str_replace( '%%%SELID%%%', 'value: '. $Z[0]['aux_parameter'] .',', $TPL );
$TPL = str_replace( '%%%SELURL%%%', $FU, $TPL );
$TPL = str_replace( '%%%STREAMID%%%', $DD['aux_parameter'], $TPL );
if( $DD['type'] == 15 || $DD['type'] == 14 || $DD['type'] == 13 || $DD['type'] == 11 ){
$QS = "SELECT `homing_enable` FROM `cameras` WHERE `id`={$DD['aux_id']}";
$JUA = $DATABASE->Query( $QS );
$CAMDATA = $JUA[0];
if( $CAMDATA['homing_enable'] ){
if( $CUser->Data['access'] > 5 ){
$TPL = str_replace( '%%%HBTN%%%', '<img id="img_btn_0ZZ_'.$DD['aux_id'].'" class="ptz_ctrl_btn" src="/style/png/building/038.png">', $TPL );
$TPL = str_replace('%%%CAM_CTRL_HOME_BTN_BIND%%%', 'document.getElementById(\'img_btn_0ZZ_'.$DD['aux_id'].'\').addEventListener( \'mousedown\', makePtzHome );', $TPL );
} else {
$TPL = str_replace('%%%HBTN%%%', '&nbsp;', $TPL );
$TPL = str_replace('%%%CAM_CTRL_HOME_BTN_BIND%%%', '', $TPL );
};
} else {
$TPL = str_replace('%%%HBTN%%%', '&nbsp;', $TPL );
$TPL = str_replace('%%%CAM_CTRL_HOME_BTN_BIND%%%', '', $TPL );
};
};
$FK = $MODULE_DATA['height'] /$MODULE_DATA['width'];
$W = 244;
$H = $W * $FK;
$TPL = str_replace( '%%%WIDTH%%%', $W, $TPL );
$TPL = str_replace( '%%%HEIGHT%%%', $H, $TPL );
$OUT[]= $STA[1+$idx] . $TPL . $END;
} else break;
$idx++;
};
} else {
for( ;$idx<1;$idx++ ){
$T = str_replace( '%%ID%%', 4+$idx , $DUMMY['camera'] );
$OUT[]= $STA[1+$idx] . $T . $END;
};
};
$QS = "SELECT * FROM `nodes` WHERE `type`>0 AND `type`< 10 AND `enable`=1";
$R = $DATABASE->Query( $QS );
$idx = 0;
if( count( $R ) ){
foreach( $R as $DD ){
if( $idx < 1 ){
$TFN = 'dash/node_' . $DD['type'] . '.js';
if(!file_exists( $TFN )) continue;
$TPL = file_get_contents( $TFN );
$TPL = inject_labels( $TPL );
$TPL = str_replace('%%%NODEID%%%', ''.$DD['id'] , $TPL );
$TPL = str_replace('%%%NODENAME%%%', ''.html_entity_decode( $DD['name'] ) , $TPL );
$TPL = str_replace('%%%USERID%%%', $UserID, $TPL );
$TPL = str_replace('%%%SESSION%%%', $Session, $TPL );
$TPL = str_replace('%%%APPTYPE%%%', $SP['type'], $TPL );
$OUT[]= $STA[2+$idx] . $TPL . $END;
} else break;
$idx++;
};
} else {
for( ;$idx<1;$idx++ ){
$OUT[]= $STA[2+$idx] . $DUMMY['sensor'] . $END;
};
};
$OUT[]= $STA[3] . $DUMMY['log'] . $END;
break;
};
case 4:{
$STA[0]="{ columnWidth: .25, stylse:'padding:10px 0 10px 10px', items:[";
$STA[1]="{ columnWidth: .25, stylse:'padding:10px 0 10px 10px', items:[";
$STA[2]="{ columnWidth: .25, stylse:'padding:10px 0 10px 10px', items:[";
$STA[3]="{ columnWidth: .25, stylse:'padding:10px 0 10px 10px', items:[";
$STA[4]="{ columnWidth: 1, stylse:'padding:10px 0 10px 10px', items:[";
$idx = 0;
$QS = "SELECT * FROM `nodes` WHERE `type`>0 AND `type`< 10 AND `enable`=1";
$R = $DATABASE->Query( $QS );
if( count( $R ) ){
foreach( $R as $DD ){
if( $idx < 3 ){
$TFN = 'dash/node_' . $DD['type'] . '.js';
if(!file_exists( $TFN )) continue;
$TPL = file_get_contents( $TFN );
$TPL = inject_labels( $TPL );
$TPL = str_replace('%%%NODEID%%%', ''.$DD['id'] , $TPL );
$TPL = str_replace('%%%NODENAME%%%', ''.html_entity_decode( $DD['name'] ) , $TPL );
$TPL = str_replace('%%%USERID%%%', $UserID, $TPL );
$TPL = str_replace('%%%SESSION%%%', $Session, $TPL );
$TPL = str_replace('%%%APPTYPE%%%', $SP['type'], $TPL );
$OUT[]= $STA[$idx] . $TPL . $END;
} else break;
$idx++;
};
if( $idx < 3 ){
for( ;$idx<3;$idx++ ){
$OUT[]= $STA[$idx] . $DUMMY['sensor'] . $END;
};
};
} else {
for( ;$idx<3;$idx++ ){
$OUT[]= $STA[$idx] . $DUMMY['sensor'] . $END;
};
};
$QS = "SELECT * FROM `nodes` WHERE `type`>9 AND `type`< 16 AND `enable`=1";
$R = $DATABASE->Query( $QS );
$idx = 0;
if( count( $R ) ){
foreach( $R as $DD ){
if( $idx < 2 ){
$TFN = 'dash/node_' . $DD['type'] . '.js';
if(!file_exists( $TFN )) continue;
$TPL = file_get_contents( $TFN );
$TPL = inject_labels( $TPL );
$TPL = str_replace('%%%NODEID%%%', ''.$DD['id'] , $TPL );
$TPL = str_replace('%%%NODENAME%%%', ''.urldecode($DD['name']) , $TPL );
$TPL = str_replace('%%%USERID%%%', $UserID, $TPL );
$TPL = str_replace('%%%SESSION%%%', $Session, $TPL );
$TPL = str_replace('%%%APPTYPE%%%', $SP['type'], $TPL );
$QS="SELECT * FROM `nodes` WHERE `id`={$DD['id']}";
$Z=$DATABASE->Query( $QS );
$QS="SELECT * FROM `module_eve` LIMIT 1";
$S=$DATABASE->Query( $QS );
$MODULE_DATA = $S[0];
$TPL = str_replace( '%%%NODENAME%%%', urldecode( $Z[0]['name'] ) , $TPL );
//$FU = 'http://' . $_SERVER['SERVER_ADDR'].':' . $MODULE_DATA['web_port'] .'/stream?id='. $Z[0]['aux_parameter'];
$FU = '/video_feed/stream?id='. $Z[0]['aux_parameter'];
$CS[] = '[' . $Z[0]['aux_parameter'] . ',\'[ 120x120] Video\',\''. $FU .'\']';
$TPL = str_replace( '%%%URLS%%%', '[' . implode( ',', $CS ) . ']' , $TPL );
$TPL = str_replace( '%%%SELID%%%', 'value: '. $Z[0]['aux_parameter'] .',', $TPL );
$TPL = str_replace( '%%%SELURL%%%', $FU, $TPL );
$TPL = str_replace( '%%%STREAMID%%%', $DD['aux_parameter'], $TPL );
if( $DD['type'] == 15 || $DD['type'] == 14 || $DD['type'] == 13 || $DD['type'] == 11 ){
$QS = "SELECT `homing_enable` FROM `cameras` WHERE `id`={$DD['aux_id']}";
$JUA = $DATABASE->Query( $QS );
$CAMDATA = $JUA[0];
if( $CAMDATA['homing_enable'] ){
if( $CUser->Data['access'] > 5 ){
$TPL = str_replace( '%%%HBTN%%%', '<img id="img_btn_0ZZ_'.$DD['aux_id'].'" class="ptz_ctrl_btn" src="/style/png/building/038.png">', $TPL );
$TPL = str_replace('%%%CAM_CTRL_HOME_BTN_BIND%%%', 'document.getElementById(\'img_btn_0ZZ_'.$DD['aux_id'].'\').addEventListener( \'mousedown\', makePtzHome );', $TPL );
} else {
$TPL = str_replace('%%%HBTN%%%', '&nbsp;', $TPL );
$TPL = str_replace('%%%CAM_CTRL_HOME_BTN_BIND%%%', '', $TPL );
};
} else {
$TPL = str_replace('%%%HBTN%%%', '&nbsp;', $TPL );
$TPL = str_replace('%%%CAM_CTRL_HOME_BTN_BIND%%%', '', $TPL );
};
};
$FK = $MODULE_DATA['height'] /$MODULE_DATA['width'];
$W = 244;
$H = $W * $FK;
$TPL = str_replace( '%%%WIDTH%%%', $W, $TPL );
$TPL = str_replace( '%%%HEIGHT%%%', $H, $TPL );
$OUT[]= $STA[3+$idx] . $TPL . $END;
} else break;
$idx++;
};
} else {
for( ;$idx<1;$idx++ ){
$T = str_replace( '%%ID%%', 4+$idx , $DUMMY['camera'] );
$OUT[]= $STA[3+$idx] . $T . $END;
};
};
$OUT[]= $STA[4] . $DUMMY['log'] . $END;
break;
};
case 5:
default:
};
$Data = '[' . implode( ',' , $OUT ) . ']';
} else {
$Data = '[{columnWidth: 1, items:{html:"NO SYSTEM PROPS"}} ]';
};
};
if( $Data != '' ) {
echo $Data;
} else {
echo '[]';
};
?>