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.

716 lines
30 KiB

​
​
​
​
​
​
​
​
​
10 months ago
​
​
​
​
​
​
​
​
​
​
​
2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 years ago
​
​
​
​
4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
2 years ago
​
​
​
2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 years ago
​
3 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 years ago
​
3 years ago
​
​
​
4 years ago
​
​
​
​
4 years ago
4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 years ago
​
3 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 years ago
​
​
3 years ago
​
​
​
4 years ago
​
​
​
​
4 years ago
4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 years ago
​
​
​
​
​
2 years ago
​
​
​
​
​
​
​
4 years ago
​
3 years ago
2 years ago
​
​
2 years ago
​
​
​
​
​
2 years ago
2 years ago
​
​
​
​
4 years ago
​
​
3 years ago
​
​
​
4 years ago
​
​
​
​
4 years ago
4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 years ago
​
​
​
​
​
2 years ago
​
​
​
2 years ago
​
2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 years ago
​
​
3 years ago
​
​
​
4 years ago
​
​
​
​
4 years ago
4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 years ago
​
​
​
​
​
​
​
​
​
3 years ago
​
​
​
​
3 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 years ago
​
​
​
​
​
​
​
​
​
3 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
​
5 months ago
​
​
​
​
​
​
​
​
​
  1. <?php
  2. require_once('../ajax_asm.php');
  3. function inject_labels( $TPL ){
  4. global $Labels;
  5. $TPL = str_replace('%%%LABEL%%%TOOLBOX%%%', $Labels->GetLabel('_TOOLBOX_') , $TPL );
  6. $TPL = str_replace('%%%LABEL%%%CLEALARM%%%', $Labels->GetLabel('_CLEAR_ALARM_') , $TPL );
  7. $TPL = str_replace('%%%LABEL%%%DRABACKGROUND%%%', $Labels->GetLabel('_DRAW_BACKGROUND_') , $TPL );
  8. $TPL = str_replace('%%%LABEL%%%STUBACKGROUND%%%', $Labels->GetLabel('_STUDY_BACKGROUND_') , $TPL );
  9. $TPL = str_replace('%%%LABEL%%%MASKEDITOR%%%', $Labels->GetLabel('_MASK_EDITOR_') , $TPL );
  10. $TPL = str_replace('%%%LABEL%%%MASKMNGR%%%', $Labels->GetLabel('_MASK_MANAGER_') , $TPL );
  11. $TPL = str_replace('%%%LABEL%%%ACKNOLAGE%%%', $Labels->GetLabel('_DEV_ACK_BTN_') , $TPL );
  12. $TPL = str_replace('%%%LABEL%%%FREZBUBLE%%%', $Labels->GetLabel('_DEV_FRZ_BBL_BTN_') , $TPL );
  13. $TPL = str_replace('%%%LABEL%%%DELBUBLE%%%', $Labels->GetLabel('_DEV_DEL_BBL_BTN_') , $TPL );
  14. return $TPL;
  15. };
  16. $UID = intval( $CUser->Data['id'] );
  17. $Data = '';
  18. if( $UID > 1 ){
  19. $QS = "SELECT * FROM `system_props` LIMIT 1";
  20. $SPD = $DATABASE->Query( $QS );
  21. if( count( $SPD ) ){
  22. $SP = $SPD[0];
  23. $DUMMY = array();
  24. if( $CUser->Data['access'] > 5 ){
  25. //$CUser->Data['width']
  26. //$CUser->Data['height']
  27. $TABA =<<<_DATA_BOUNDARY
  28. {
  29. xtype: 'panel',
  30. 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>',
  31. listeners:{
  32. afterrender : function( ){
  33. var tb = document.getElementById('tbl_ph_ccc_%%ID%%');
  34. var W = tb.offsetWidth;
  35. var H = (W/16)*9;
  36. tb.setAttribute("height", H );
  37. tb.style.backgroundSize=W+"px "+H+"px";
  38. var p = Ext.getCmp('pan_ph_ccc_%%ID%%');
  39. p.setHeight( H+40 );
  40. var jaja = Ext.create({
  41. xtype: 'panel',
  42. title: '{$Labels->GetLabel('_MSG_CAM_NOT_ASS_')}',
  43. frame: true,
  44. renderTo: 'btn_ph_ccc_%%ID%%',
  45. layout: 'vbox',
  46. width: 500,
  47. height: 120,
  48. items:[{
  49. xtype: 'spacer',
  50. height: 10
  51. },{
  52. width: '100%',
  53. html: '<center>{$Labels->GetLabel('_MSG_CAM_PROC_NOT_ASS_')}</center>'
  54. },{
  55. xtype: 'spacer',
  56. height: 20
  57. },{
  58. xtype: 'button',
  59. width: '100%',
  60. text: 'Open Camera Settings',
  61. handler: function(){
  62. showContent( 2020 );
  63. }
  64. }]
  65. });
  66. jaja.doLayout();
  67. }
  68. }
  69. }
  70. _DATA_BOUNDARY;
  71. $DUMMY['camera']="{xtype:'panel', id:'pan_ph_ccc_%%ID%%', title: 'Camera Placeholder', frame: true, border: true, draggable: false, layouit: 'fit', items:{$TABA}}";
  72. $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);}}}";
  73. } else {
  74. $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);}}}";
  75. $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);}}}";
  76. };
  77. $LOGIO=<<<_DATA_BOUNDARY
  78. {
  79. xtype: 'grid',
  80. id: 'log_grid',
  81. border: false,
  82. frame: false,
  83. autoScroll: true,
  84. //width: '100%',
  85. lazyRender: true,
  86. height: 210,
  87. ds: log_store,
  88. cm: new Ext.grid.ColumnModel( log_ColModel_ops ),
  89. sm: new Ext.grid.RowSelectionModel( log_SelModel_ops ),
  90. viewConfig: {
  91. forceFit: true,
  92. getRowClass: function( record, rowIndex, rowParams, store){
  93. switch( record.get('node_id')%5 ){
  94. case 0: return 'row-level01';
  95. case 1: return 'row-level02';
  96. case 2: return 'row-level03';
  97. case 3: return 'row-level04';
  98. case 4: return 'row-level05';
  99. };
  100. return '';
  101. }
  102. },
  103. listeners:{
  104. afterrender : function( t ){
  105. var papa = Ext.getCmp('main_portal');
  106. var jj = papa.getComponent( 0 ).getHeight();
  107. var zz = t.ownerCt.ownerCt.getHeight();
  108. //alert( PanelW );
  109. //alert( PanelH - zz );
  110. //t.setHeight( PanelH - jj - 20 );
  111. t.setHeight( PanelH - zz - 42 );
  112. }
  113. }
  114. }
  115. _DATA_BOUNDARY;
  116. $MAPIO=<<<_DATA_BOUNDARY
  117. {
  118. id: 'event_map',
  119. height: 200,
  120. html: '&nbsp;',
  121. listeners:{
  122. afterrender : function( t ){
  123. var papa = Ext.getCmp('main_portal');
  124. var jj = papa.getComponent( 0 ).getHeight();
  125. t.setHeight( jj - 40 );
  126. geoMapIsPresent = true;
  127. }
  128. }
  129. }
  130. _DATA_BOUNDARY;
  131. $MH = 9;
  132. if( $SP['app_layout'] == 2 ) $MH = 6;
  133. $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();}} }";
  134. $DUMMY['log']="{xtype:'panel', id: 'lg_panel', title: '{$Labels->GetLabel('_EVENT_LOG_')}', frame: true, border: true, draggable: false, items:[{$LOGIO}] }";
  135. $STA = array();
  136. $END="]}";
  137. $OUT = array();
  138. switch( $SP['app_layout'] ){
  139. case 0:{
  140. $STA[0]="{ columnWidth: .25, stylse:'padding:10px 0 10px 10px', items:[";
  141. $STA[1]="{ columnWidth: .25, stylse:'padding:10px 0 10px 10px', items:[";
  142. $STA[2]="{ columnWidth: .25, stylse:'padding:10px 0 10px 10px', items:[";
  143. $STA[3]="{ columnWidth: .25, stylse:'padding:10px 0 10px 10px', items:[";
  144. $STA[4]="{ columnWidth: .5, stylde:'padding:10px 0 10px 10px', items:[";
  145. $STA[5]="{ columnWidth: .5, stylde:'padding:10px 0 10px 10px', items:[";
  146. $STA[6]="{ columnWidth: 1.0, stydle:'padding:10px 0 10px 10px', items:[";
  147. $QS = "SELECT * FROM `nodes` WHERE `type`>0 AND `type`< 10 AND `enable`=1";
  148. $R = $DATABASE->Query( $QS );
  149. $idx = 0;
  150. if( count( $R ) ){
  151. foreach( $R as $DD ){
  152. if( $idx < 4 ){
  153. $TFN = 'dash/node_' . $DD['type'] . '.js';
  154. if(!file_exists( $TFN )) continue;
  155. $TPL = file_get_contents( $TFN );
  156. $TPL = inject_labels( $TPL );
  157. $TPL = str_replace('%%%NODEID%%%', ''.$DD['id'] , $TPL );
  158. $TPL = str_replace('%%%NODENAME%%%', ''. urldecode( $DD['name'] ), $TPL );
  159. $TPL = str_replace('%%%USERID%%%', $UserID, $TPL );
  160. $TPL = str_replace('%%%SESSION%%%', $Session, $TPL );
  161. $TPL = str_replace('%%%APPTYPE%%%', $SP['type'], $TPL );
  162. $OUT[]= $STA[$idx] . $TPL . $END;
  163. } else break;
  164. $idx++;
  165. };
  166. if( $idx < 4 ){
  167. for( ;$idx<4;$idx++ ){
  168. $OUT[]= $STA[$idx] . $DUMMY['sensor'] . $END;
  169. };
  170. };
  171. } else {
  172. for( ;$idx<4;$idx++ ){
  173. $OUT[]= $STA[$idx] . $DUMMY['sensor'] . $END;
  174. };
  175. };
  176. $QS = "SELECT * FROM `nodes` WHERE `type`>9 AND `type`< 16 AND `enable`=1";
  177. $R = $DATABASE->Query( $QS );
  178. $idx = 0;
  179. if( count( $R ) ){
  180. foreach( $R as $DD ){
  181. if( $idx < 2 ){
  182. $TFN = 'dash/node_' . $DD['type'] . '.js';
  183. if(!file_exists( $TFN )) continue;
  184. $TPL = file_get_contents( $TFN );
  185. $TPL = inject_labels( $TPL );
  186. $TPL = str_replace('%%%NODEID%%%', ''.$DD['id'] , $TPL );
  187. $TPL = str_replace('%%%NODENAME%%%', ''.urldecode( $DD['name'] ) , $TPL );
  188. $TPL = str_replace('%%%USERID%%%', $UserID, $TPL );
  189. $TPL = str_replace('%%%SESSION%%%', $Session, $TPL );
  190. $TPL = str_replace('%%%APPTYPE%%%', $SP['type'], $TPL );
  191. $QS="SELECT * FROM `nodes` WHERE `id`={$DD['id']}";
  192. $Z=$DATABASE->Query( $QS );
  193. $QS="SELECT * FROM `module_eve` LIMIT 1";
  194. $S=$DATABASE->Query( $QS );
  195. $MODULE_DATA = $S[0];
  196. $TPL = str_replace( '%%%NODENAME%%%', urldecode( $Z[0]['name'] ) , $TPL );
  197. //$FU = 'http://' . $_SERVER['SERVER_ADDR'].':' . $MODULE_DATA['web_port'] .'/stream?id='. $Z[0]['aux_parameter'];
  198. $FU = '/video_feed/stream?id='. $Z[0]['aux_parameter'];
  199. $CS[] = '[' . $Z[0]['aux_parameter'] . ',\'[ 120x120] Video\',\''. $FU .'\']';
  200. $TPL = str_replace( '%%%URLS%%%', '[' . implode( ',', $CS ) . ']' , $TPL );
  201. $TPL = str_replace( '%%%SELID%%%', 'value: '. $Z[0]['aux_parameter'] .',', $TPL );
  202. $TPL = str_replace( '%%%SELURL%%%', $FU, $TPL );
  203. $TPL = str_replace( '%%%STREAMID%%%', $DD['aux_parameter'], $TPL );
  204. if( $DD['type'] == 15 || $DD['type'] == 14 || $DD['type'] == 13 || $DD['type'] == 11 ){
  205. $QS = "SELECT `homing_enable` FROM `cameras` WHERE `id`={$DD['aux_id']}";
  206. $JUA = $DATABASE->Query( $QS );
  207. $CAMDATA = $JUA[0];
  208. if( $CAMDATA['homing_enable'] ){
  209. if( $CUser->Data['access'] > 5 ){
  210. $TPL = str_replace( '%%%HBTN%%%', '<img id="img_btn_0ZZ_'.$DD['aux_id'].'" class="ptz_ctrl_btn" src="/style/png/building/038.png">', $TPL );
  211. $TPL = str_replace('%%%CAM_CTRL_HOME_BTN_BIND%%%', 'document.getElementById(\'img_btn_0ZZ_'.$DD['aux_id'].'\').addEventListener( \'mousedown\', makePtzHome );', $TPL );
  212. } else {
  213. $TPL = str_replace('%%%HBTN%%%', '&nbsp;', $TPL );
  214. $TPL = str_replace('%%%CAM_CTRL_HOME_BTN_BIND%%%', '', $TPL );
  215. };
  216. } else {
  217. $TPL = str_replace('%%%HBTN%%%', '&nbsp;', $TPL );
  218. $TPL = str_replace('%%%CAM_CTRL_HOME_BTN_BIND%%%', '', $TPL );
  219. };
  220. };
  221. $FK = $MODULE_DATA['height'] /$MODULE_DATA['width'];
  222. $W = 244;
  223. $H = $W * $FK;
  224. $TPL = str_replace( '%%%WIDTH%%%', $W, $TPL );
  225. $TPL = str_replace( '%%%HEIGHT%%%', $H, $TPL );
  226. $OUT[]= $STA[4+$idx] . $TPL . $END;
  227. } else break;
  228. $idx++;
  229. };
  230. if( $idx < 2 ){
  231. for( ;$idx<2;$idx++ ){
  232. $T = str_replace( '%%ID%%', 4+$idx , $DUMMY['camera'] );
  233. $OUT[]= $STA[4+$idx] . $T . $END;
  234. };
  235. };
  236. } else {
  237. for( ;$idx<2;$idx++ ){
  238. $T = str_replace( '%%ID%%', 4+$idx , $DUMMY['camera'] );
  239. $OUT[]= $STA[4+$idx] . $T . $END;
  240. };
  241. };
  242. switch( $SP['type'] ){
  243. case 1:{
  244. // LA Metro
  245. $OUT[]= $STA[6] . $DUMMY['log'] . $END;
  246. break;
  247. };
  248. case 2:{
  249. //Togo
  250. $OUT[]= $STA[6] . $DUMMY['map'] . $END;
  251. break;
  252. };
  253. }
  254. break;
  255. };
  256. case 1:{
  257. $STA[0]="{ columnWidth: .33, stylse:'padding:10px 0 10px 10px', items:[";
  258. $STA[1]="{ columnWidth: .33, stylse:'padding:10px 0 10px 10px', items:[";
  259. $STA[2]="{ columnWidth: .33, stylse:'padding:10px 0 10px 10px', items:[";
  260. $STA[3]="{ columnWidth: 1.0, stylse:'padding:10px 0 10px 10px', items:[";
  261. $QS = "SELECT * FROM `nodes` WHERE `type`>0 AND `type`< 10 AND `enable`=1";
  262. $R = $DATABASE->Query( $QS );
  263. $idx = 0;
  264. if( count( $R ) ){
  265. foreach( $R as $DD ){
  266. if( $idx < 2 ){
  267. $TFN = 'dash/node_' . $DD['type'] . '.js';
  268. if(!file_exists( $TFN )) continue;
  269. $TPL = file_get_contents( $TFN );
  270. $TPL = inject_labels( $TPL );
  271. $TPL = str_replace('%%%NODEID%%%', ''.$DD['id'] , $TPL );
  272. $TPL = str_replace('%%%NODENAME%%%', ''.html_entity_decode( $DD['name'] ) , $TPL );
  273. $TPL = str_replace('%%%USERID%%%', $UserID, $TPL );
  274. $TPL = str_replace('%%%SESSION%%%', $Session, $TPL );
  275. $TPL = str_replace('%%%APPTYPE%%%', $SP['type'], $TPL );
  276. $OUT[]= $STA[$idx] . $TPL . $END;
  277. } else break;
  278. $idx++;
  279. };
  280. if( $idx < 2 ){
  281. for( ;$idx<2;$idx++ ){
  282. $OUT[]= $STA[$idx] . $DUMMY['sensor'] . $END;
  283. };
  284. };
  285. } else {
  286. for( ;$idx<2;$idx++ ){
  287. $OUT[]= $STA[$idx] . $DUMMY['sensor'] . $END;
  288. };
  289. };
  290. $QS = "SELECT * FROM `nodes` WHERE `type`>9 AND `type`< 16 AND `enable`=1";
  291. $R = $DATABASE->Query( $QS );
  292. $idx = 0;
  293. if( count( $R ) ){
  294. foreach( $R as $DD ){
  295. if( $idx < 1 ){
  296. $TFN = 'dash/node_' . $DD['type'] . '.js';
  297. if(!file_exists( $TFN )) continue;
  298. $TPL = file_get_contents( $TFN );
  299. $TPL = inject_labels( $TPL );
  300. $TPL = str_replace('%%%NODEID%%%', ''.$DD['id'] , $TPL );
  301. $TPL = str_replace('%%%NODENAME%%%', ''.urldecode($DD['name']) , $TPL );
  302. $TPL = str_replace('%%%USERID%%%', $UserID, $TPL );
  303. $TPL = str_replace('%%%SESSION%%%', $Session, $TPL );
  304. $TPL = str_replace('%%%APPTYPE%%%', $SP['type'], $TPL );
  305. $QS="SELECT * FROM `nodes` WHERE `id`={$DD['id']}";
  306. $Z=$DATABASE->Query( $QS );
  307. $QS="SELECT * FROM `module_eve` LIMIT 1";
  308. $S=$DATABASE->Query( $QS );
  309. $MODULE_DATA = $S[0];
  310. $TPL = str_replace( '%%%NODENAME%%%', urldecode( $Z[0]['name'] ) , $TPL );
  311. //$FU = 'http://' . $_SERVER['SERVER_ADDR'].':' . $MODULE_DATA['web_port'] .'/stream?id='. $Z[0]['aux_parameter'];
  312. $FU = '/video_feed/stream?id='. $Z[0]['aux_parameter'];
  313. $CS[] = '[' . $Z[0]['aux_parameter'] . ',\'[ 120x120] Video\',\''. $FU .'\']';
  314. $TPL = str_replace( '%%%URLS%%%', '[' . implode( ',', $CS ) . ']' , $TPL );
  315. $TPL = str_replace( '%%%SELID%%%', 'value: '. $Z[0]['aux_parameter'] .',', $TPL );
  316. $TPL = str_replace( '%%%SELURL%%%', $FU, $TPL );
  317. $TPL = str_replace( '%%%STREAMID%%%', $DD['aux_parameter'], $TPL );
  318. if( $DD['type'] == 15 || $DD['type'] == 14 || $DD['type'] == 13 || $DD['type'] == 11 ){
  319. $QS = "SELECT `homing_enable` FROM `cameras` WHERE `id`={$DD['aux_id']}";
  320. $JUA = $DATABASE->Query( $QS );
  321. $CAMDATA = $JUA[0];
  322. if( $CAMDATA['homing_enable'] ){
  323. if( $CUser->Data['access'] > 5 ){
  324. $TPL = str_replace( '%%%HBTN%%%', '<img id="img_btn_0ZZ_'.$DD['aux_id'].'" class="ptz_ctrl_btn" src="/style/png/building/038.png">', $TPL );
  325. $TPL = str_replace('%%%CAM_CTRL_HOME_BTN_BIND%%%', 'document.getElementById(\'img_btn_0ZZ_'.$DD['aux_id'].'\').addEventListener( \'mousedown\', makePtzHome );', $TPL );
  326. } else {
  327. $TPL = str_replace('%%%HBTN%%%', '&nbsp;', $TPL );
  328. $TPL = str_replace('%%%CAM_CTRL_HOME_BTN_BIND%%%', '', $TPL );
  329. };
  330. } else {
  331. $TPL = str_replace('%%%HBTN%%%', '&nbsp;', $TPL );
  332. $TPL = str_replace('%%%CAM_CTRL_HOME_BTN_BIND%%%', '', $TPL );
  333. };
  334. };
  335. $FK = $MODULE_DATA['height'] /$MODULE_DATA['width'];
  336. $W = 244;
  337. $H = $W * $FK;
  338. $TPL = str_replace( '%%%WIDTH%%%', $W, $TPL );
  339. $TPL = str_replace( '%%%HEIGHT%%%', $H, $TPL );
  340. $OUT[]= $STA[2+$idx] . $TPL . $END;
  341. } else break;
  342. $idx++;
  343. };
  344. if( $idx < 1 ){
  345. for( ;$idx<1;$idx++ ){
  346. $T = str_replace( '%%ID%%', 2+$idx , $DUMMY['camera'] );
  347. $OUT[]= $STA[2+$idx] . $T . $END;
  348. };
  349. };
  350. } else {
  351. for( ;$idx<1;$idx++ ){
  352. $T = str_replace( '%%ID%%', 4+$idx , $DUMMY['camera'] );
  353. $OUT[]= $STA[2+$idx] . $T . $END;
  354. };
  355. };
  356. switch( $SP['type'] ){
  357. case 1:{
  358. // LA Metro
  359. $OUT[]= $STA[3] . $DUMMY['log'] . $END;
  360. break;
  361. };
  362. case 2:{
  363. //Togo
  364. $OUT[]= $STA[3] . $DUMMY['map'] . $END;
  365. break;
  366. };
  367. }
  368. break;
  369. };
  370. case 2:{
  371. $STA[0]="{ columnWidth: .33, stylse:'padding:10px 0 10px 10px', items:[";//Sen1
  372. $STA[1]="{ columnWidth: .33, stylse:'padding:10px 0 10px 10px', items:[";//Cam1
  373. $STA[2]="{ columnWidth: .33, stylse:'padding:10px 0 10px 10px', items:[";//Cam2
  374. $STA[3]="{ columnWidth: .33, stylse:'padding:10px 0 10px 10px', items:[";//Sen2
  375. $STA[4]="{ columnWidth: .66, stylde:'padding:10px 0 10px 10px', items:[";//Log/Map
  376. $idx = 0;
  377. $QS = "SELECT * FROM `nodes` WHERE `type`>0 AND `type`< 10 AND `enable`=1";
  378. $DEVS = $DATABASE->Query( $QS );
  379. if( count( $DEVS ) ){
  380. $WOU = array();
  381. foreach( $DEVS as $DD ){
  382. if( $idx < 2 ){
  383. $TFN = 'dash/node_' . $DD['type'] . '.js';
  384. if(!file_exists( $TFN )) continue;
  385. $TPL = file_get_contents( $TFN );
  386. $TPL = inject_labels( $TPL );
  387. $TPL = str_replace('%%%NODEID%%%', ''.$DD['id'] , $TPL );
  388. $TPL = str_replace('%%%NODENAME%%%', ''.html_entity_decode( $DD['name'] ) , $TPL );
  389. $TPL = str_replace('%%%USERID%%%', $UserID, $TPL );
  390. $TPL = str_replace('%%%SESSION%%%', $Session, $TPL );
  391. $TPL = str_replace('%%%APPTYPE%%%', $SP['type'], $TPL );
  392. $WOU[]= $TPL;
  393. } else break;
  394. $idx++;
  395. };
  396. if( $idx < 2 ) for( ;$idx<2;$idx++ ) $WOU[]= $DUMMY['sensor'];
  397. $OUT[]= $STA[0] . implode(',', $WOU ) . $END;
  398. } else {
  399. for( ;$idx<3;$idx++ ){
  400. $OUT[]= $STA[$idx] . $DUMMY['sensor'] . $END;
  401. };
  402. };
  403. $QS = "SELECT * FROM `nodes` WHERE `type`>9 AND `type`< 16 AND `enable`=1";
  404. $CAMS = $DATABASE->Query( $QS );
  405. $idx = 0;
  406. if( count( $CAMS ) ){
  407. foreach( $CAMS as $DD ){
  408. if( $idx < 2 ){
  409. $TFN = 'dash/node_' . $DD['type'] . '.js';
  410. if(!file_exists( $TFN )) continue;
  411. $TPL = file_get_contents( $TFN );
  412. $TPL = inject_labels( $TPL );
  413. $TPL = str_replace('%%%NODEID%%%', ''.$DD['id'] , $TPL );
  414. $TPL = str_replace('%%%NODENAME%%%', ''.urldecode($DD['name']) , $TPL );
  415. $TPL = str_replace('%%%USERID%%%', $UserID, $TPL );
  416. $TPL = str_replace('%%%SESSION%%%', $Session, $TPL );
  417. $TPL = str_replace('%%%APPTYPE%%%', $SP['type'], $TPL );
  418. $QS="SELECT * FROM `nodes` WHERE `id`={$DD['id']}";
  419. $Z=$DATABASE->Query( $QS );
  420. $QS="SELECT * FROM `module_eve` LIMIT 1";
  421. $S=$DATABASE->Query( $QS );
  422. $MODULE_DATA = $S[0];
  423. $TPL = str_replace( '%%%NODENAME%%%', urldecode( $Z[0]['name'] ) , $TPL );
  424. //$FU = 'http://' . $_SERVER['SERVER_ADDR'].':' . $MODULE_DATA['web_port'] .'/stream?id='. $Z[0]['aux_parameter'];
  425. $FU = '/video_feed/stream?id='. $Z[0]['aux_parameter'];
  426. $CS[] = '[' . $Z[0]['aux_parameter'] . ',\'[ 120x120] Video\',\''. $FU .'\']';
  427. $TPL = str_replace( '%%%URLS%%%', '[' . implode( ',', $CS ) . ']' , $TPL );
  428. $TPL = str_replace( '%%%SELID%%%', 'value: '. $Z[0]['aux_parameter'] .',', $TPL );
  429. $TPL = str_replace( '%%%SELURL%%%', $FU, $TPL );
  430. $TPL = str_replace( '%%%STREAMID%%%', $DD['aux_parameter'], $TPL );
  431. if( $DD['type'] == 15 || $DD['type'] == 14 || $DD['type'] == 13 || $DD['type'] == 11 ){
  432. $QS = "SELECT `homing_enable` FROM `cameras` WHERE `id`={$DD['aux_id']}";
  433. $JUA = $DATABASE->Query( $QS );
  434. $CAMDATA = $JUA[0];
  435. if( $CAMDATA['homing_enable'] ){
  436. if( $CUser->Data['access'] > 5 ){
  437. $TPL = str_replace( '%%%HBTN%%%', '<img id="img_btn_0ZZ_'.$DD['aux_id'].'" class="ptz_ctrl_btn" src="/style/png/building/038.png">', $TPL );
  438. $TPL = str_replace('%%%CAM_CTRL_HOME_BTN_BIND%%%', 'document.getElementById(\'img_btn_0ZZ_'.$DD['aux_id'].'\').addEventListener( \'mousedown\', makePtzHome );', $TPL );
  439. } else {
  440. $TPL = str_replace('%%%HBTN%%%', '&nbsp;', $TPL );
  441. $TPL = str_replace('%%%CAM_CTRL_HOME_BTN_BIND%%%', '', $TPL );
  442. };
  443. } else {
  444. $TPL = str_replace('%%%HBTN%%%', '&nbsp;', $TPL );
  445. $TPL = str_replace('%%%CAM_CTRL_HOME_BTN_BIND%%%', '', $TPL );
  446. };
  447. };
  448. $FK = $MODULE_DATA['height'] /$MODULE_DATA['width'];
  449. $W = 244;
  450. $H = $W * $FK;
  451. $TPL = str_replace( '%%%WIDTH%%%', $W, $TPL );
  452. $TPL = str_replace( '%%%HEIGHT%%%', $H, $TPL );
  453. $OUT[]= $STA[1+$idx] . $TPL . $END;
  454. } else break;
  455. $idx++;
  456. };
  457. if( $idx < 2 ){
  458. for( ;$idx<2;$idx++ ){
  459. $T = str_replace( '%%ID%%', 2+$idx , $DUMMY['camera'] );
  460. $OUT[]= $STA[1+$idx] . $T . $END;
  461. };
  462. };
  463. } else {
  464. for( ;$idx<2;$idx++ ){
  465. $T = str_replace( '%%ID%%', 4+$idx , $DUMMY['camera'] );
  466. $OUT[]= $STA[1+$idx] . $T . $END;
  467. };
  468. };
  469. $OUT[]= $STA[4] . $DUMMY['map'] .','. $DUMMY['log'] . $END;
  470. //$OUT[]= $STA[4] . . $END;
  471. break;
  472. };
  473. case 3:{
  474. $STA[0]="{ columnWidth: .5, stylse:'padding:10px 0 10px 10px', items:[";
  475. $STA[1]="{ columnWidth: .5, stylse:'padding:10px 0 10px 10px', items:[";
  476. $STA[2]="{ columnWidth: .33, stylse:'padding:10px 0 10px 10px', items:[";
  477. $STA[3]="{ columnWidth: .67, stylse:'padding:10px 0 10px 10px', items:[";
  478. $OUT[]= $STA[0] . $DUMMY['map'] . $END;
  479. $QS = "SELECT * FROM `nodes` WHERE `type`>9 AND `type`< 16 AND `enable`=1";
  480. $R = $DATABASE->Query( $QS );
  481. $idx = 0;
  482. if( count( $R ) ){
  483. foreach( $R as $DD ){
  484. if( $idx < 1 ){
  485. $TFN = 'dash/node_' . $DD['type'] . '.js';
  486. if(!file_exists( $TFN )) continue;
  487. $TPL = file_get_contents( $TFN );
  488. $TPL = inject_labels( $TPL );
  489. $TPL = str_replace('%%%NODEID%%%', ''.$DD['id'] , $TPL );
  490. $TPL = str_replace('%%%NODENAME%%%', ''.urldecode($DD['name']) , $TPL );
  491. $TPL = str_replace('%%%USERID%%%', $UserID, $TPL );
  492. $TPL = str_replace('%%%SESSION%%%', $Session, $TPL );
  493. $TPL = str_replace('%%%APPTYPE%%%', $SP['type'], $TPL );
  494. $QS="SELECT * FROM `nodes` WHERE `id`={$DD['id']}";
  495. $Z=$DATABASE->Query( $QS );
  496. $QS="SELECT * FROM `module_eve` LIMIT 1";
  497. $S=$DATABASE->Query( $QS );
  498. $MODULE_DATA = $S[0];
  499. $TPL = str_replace( '%%%NODENAME%%%', urldecode( $Z[0]['name'] ) , $TPL );
  500. //$FU = 'http://' . $_SERVER['SERVER_ADDR'].':' . $MODULE_DATA['web_port'] .'/stream?id='. $Z[0]['aux_parameter'];
  501. $FU = '/video_feed/stream?id='. $Z[0]['aux_parameter'];
  502. $CS[] = '[' . $Z[0]['aux_parameter'] . ',\'[ 120x120] Video\',\''. $FU .'\']';
  503. $TPL = str_replace( '%%%URLS%%%', '[' . implode( ',', $CS ) . ']' , $TPL );
  504. $TPL = str_replace( '%%%SELID%%%', 'value: '. $Z[0]['aux_parameter'] .',', $TPL );
  505. $TPL = str_replace( '%%%SELURL%%%', $FU, $TPL );
  506. $TPL = str_replace( '%%%STREAMID%%%', $DD['aux_parameter'], $TPL );
  507. if( $DD['type'] == 15 || $DD['type'] == 14 || $DD['type'] == 13 || $DD['type'] == 11 ){
  508. $QS = "SELECT `homing_enable` FROM `cameras` WHERE `id`={$DD['aux_id']}";
  509. $JUA = $DATABASE->Query( $QS );
  510. $CAMDATA = $JUA[0];
  511. if( $CAMDATA['homing_enable'] ){
  512. if( $CUser->Data['access'] > 5 ){
  513. $TPL = str_replace( '%%%HBTN%%%', '<img id="img_btn_0ZZ_'.$DD['aux_id'].'" class="ptz_ctrl_btn" src="/style/png/building/038.png">', $TPL );
  514. $TPL = str_replace('%%%CAM_CTRL_HOME_BTN_BIND%%%', 'document.getElementById(\'img_btn_0ZZ_'.$DD['aux_id'].'\').addEventListener( \'mousedown\', makePtzHome );', $TPL );
  515. } else {
  516. $TPL = str_replace('%%%HBTN%%%', '&nbsp;', $TPL );
  517. $TPL = str_replace('%%%CAM_CTRL_HOME_BTN_BIND%%%', '', $TPL );
  518. };
  519. } else {
  520. $TPL = str_replace('%%%HBTN%%%', '&nbsp;', $TPL );
  521. $TPL = str_replace('%%%CAM_CTRL_HOME_BTN_BIND%%%', '', $TPL );
  522. };
  523. };
  524. $FK = $MODULE_DATA['height'] /$MODULE_DATA['width'];
  525. $W = 244;
  526. $H = $W * $FK;
  527. $TPL = str_replace( '%%%WIDTH%%%', $W, $TPL );
  528. $TPL = str_replace( '%%%HEIGHT%%%', $H, $TPL );
  529. $OUT[]= $STA[1+$idx] . $TPL . $END;
  530. } else break;
  531. $idx++;
  532. };
  533. } else {
  534. for( ;$idx<1;$idx++ ){
  535. $T = str_replace( '%%ID%%', 4+$idx , $DUMMY['camera'] );
  536. $OUT[]= $STA[1+$idx] . $T . $END;
  537. };
  538. };
  539. $QS = "SELECT * FROM `nodes` WHERE `type`>0 AND `type`< 10 AND `enable`=1";
  540. $R = $DATABASE->Query( $QS );
  541. $idx = 0;
  542. if( count( $R ) ){
  543. foreach( $R as $DD ){
  544. if( $idx < 1 ){
  545. $TFN = 'dash/node_' . $DD['type'] . '.js';
  546. if(!file_exists( $TFN )) continue;
  547. $TPL = file_get_contents( $TFN );
  548. $TPL = inject_labels( $TPL );
  549. $TPL = str_replace('%%%NODEID%%%', ''.$DD['id'] , $TPL );
  550. $TPL = str_replace('%%%NODENAME%%%', ''.html_entity_decode( $DD['name'] ) , $TPL );
  551. $TPL = str_replace('%%%USERID%%%', $UserID, $TPL );
  552. $TPL = str_replace('%%%SESSION%%%', $Session, $TPL );
  553. $TPL = str_replace('%%%APPTYPE%%%', $SP['type'], $TPL );
  554. $OUT[]= $STA[2+$idx] . $TPL . $END;
  555. } else break;
  556. $idx++;
  557. };
  558. } else {
  559. for( ;$idx<1;$idx++ ){
  560. $OUT[]= $STA[2+$idx] . $DUMMY['sensor'] . $END;
  561. };
  562. };
  563. $OUT[]= $STA[3] . $DUMMY['log'] . $END;
  564. break;
  565. };
  566. case 4:{
  567. $STA[0]="{ columnWidth: .25, stylse:'padding:10px 0 10px 10px', items:[";
  568. $STA[1]="{ columnWidth: .25, stylse:'padding:10px 0 10px 10px', items:[";
  569. $STA[2]="{ columnWidth: .25, stylse:'padding:10px 0 10px 10px', items:[";
  570. $STA[3]="{ columnWidth: .25, stylse:'padding:10px 0 10px 10px', items:[";
  571. $STA[4]="{ columnWidth: 1, stylse:'padding:10px 0 10px 10px', items:[";
  572. $idx = 0;
  573. $QS = "SELECT * FROM `nodes` WHERE `type`>0 AND `type`< 10 AND `enable`=1";
  574. $R = $DATABASE->Query( $QS );
  575. if( count( $R ) ){
  576. foreach( $R as $DD ){
  577. if( $idx < 3 ){
  578. $TFN = 'dash/node_' . $DD['type'] . '.js';
  579. if(!file_exists( $TFN )) continue;
  580. $TPL = file_get_contents( $TFN );
  581. $TPL = inject_labels( $TPL );
  582. $TPL = str_replace('%%%NODEID%%%', ''.$DD['id'] , $TPL );
  583. $TPL = str_replace('%%%NODENAME%%%', ''.html_entity_decode( $DD['name'] ) , $TPL );
  584. $TPL = str_replace('%%%USERID%%%', $UserID, $TPL );
  585. $TPL = str_replace('%%%SESSION%%%', $Session, $TPL );
  586. $TPL = str_replace('%%%APPTYPE%%%', $SP['type'], $TPL );
  587. $OUT[]= $STA[$idx] . $TPL . $END;
  588. } else break;
  589. $idx++;
  590. };
  591. if( $idx < 3 ){
  592. for( ;$idx<3;$idx++ ){
  593. $OUT[]= $STA[$idx] . $DUMMY['sensor'] . $END;
  594. };
  595. };
  596. } else {
  597. for( ;$idx<3;$idx++ ){
  598. $OUT[]= $STA[$idx] . $DUMMY['sensor'] . $END;
  599. };
  600. };
  601. $QS = "SELECT * FROM `nodes` WHERE `type`>9 AND `type`< 16 AND `enable`=1";
  602. $R = $DATABASE->Query( $QS );
  603. $idx = 0;
  604. if( count( $R ) ){
  605. foreach( $R as $DD ){
  606. if( $idx < 2 ){
  607. $TFN = 'dash/node_' . $DD['type'] . '.js';
  608. if(!file_exists( $TFN )) continue;
  609. $TPL = file_get_contents( $TFN );
  610. $TPL = inject_labels( $TPL );
  611. $TPL = str_replace('%%%NODEID%%%', ''.$DD['id'] , $TPL );
  612. $TPL = str_replace('%%%NODENAME%%%', ''.urldecode($DD['name']) , $TPL );
  613. $TPL = str_replace('%%%USERID%%%', $UserID, $TPL );
  614. $TPL = str_replace('%%%SESSION%%%', $Session, $TPL );
  615. $TPL = str_replace('%%%APPTYPE%%%', $SP['type'], $TPL );
  616. $QS="SELECT * FROM `nodes` WHERE `id`={$DD['id']}";
  617. $Z=$DATABASE->Query( $QS );
  618. $QS="SELECT * FROM `module_eve` LIMIT 1";
  619. $S=$DATABASE->Query( $QS );
  620. $MODULE_DATA = $S[0];
  621. $TPL = str_replace( '%%%NODENAME%%%', urldecode( $Z[0]['name'] ) , $TPL );
  622. //$FU = 'http://' . $_SERVER['SERVER_ADDR'].':' . $MODULE_DATA['web_port'] .'/stream?id='. $Z[0]['aux_parameter'];
  623. $FU = '/video_feed/stream?id='. $Z[0]['aux_parameter'];
  624. $CS[] = '[' . $Z[0]['aux_parameter'] . ',\'[ 120x120] Video\',\''. $FU .'\']';
  625. $TPL = str_replace( '%%%URLS%%%', '[' . implode( ',', $CS ) . ']' , $TPL );
  626. $TPL = str_replace( '%%%SELID%%%', 'value: '. $Z[0]['aux_parameter'] .',', $TPL );
  627. $TPL = str_replace( '%%%SELURL%%%', $FU, $TPL );
  628. $TPL = str_replace( '%%%STREAMID%%%', $DD['aux_parameter'], $TPL );
  629. if( $DD['type'] == 15 || $DD['type'] == 14 || $DD['type'] == 13 || $DD['type'] == 11 ){
  630. $QS = "SELECT `homing_enable` FROM `cameras` WHERE `id`={$DD['aux_id']}";
  631. $JUA = $DATABASE->Query( $QS );
  632. $CAMDATA = $JUA[0];
  633. if( $CAMDATA['homing_enable'] ){
  634. if( $CUser->Data['access'] > 5 ){
  635. $TPL = str_replace( '%%%HBTN%%%', '<img id="img_btn_0ZZ_'.$DD['aux_id'].'" class="ptz_ctrl_btn" src="/style/png/building/038.png">', $TPL );
  636. $TPL = str_replace('%%%CAM_CTRL_HOME_BTN_BIND%%%', 'document.getElementById(\'img_btn_0ZZ_'.$DD['aux_id'].'\').addEventListener( \'mousedown\', makePtzHome );', $TPL );
  637. } else {
  638. $TPL = str_replace('%%%HBTN%%%', '&nbsp;', $TPL );
  639. $TPL = str_replace('%%%CAM_CTRL_HOME_BTN_BIND%%%', '', $TPL );
  640. };
  641. } else {
  642. $TPL = str_replace('%%%HBTN%%%', '&nbsp;', $TPL );
  643. $TPL = str_replace('%%%CAM_CTRL_HOME_BTN_BIND%%%', '', $TPL );
  644. };
  645. };
  646. $FK = $MODULE_DATA['height'] /$MODULE_DATA['width'];
  647. $W = 244;
  648. $H = $W * $FK;
  649. $TPL = str_replace( '%%%WIDTH%%%', $W, $TPL );
  650. $TPL = str_replace( '%%%HEIGHT%%%', $H, $TPL );
  651. $OUT[]= $STA[3+$idx] . $TPL . $END;
  652. } else break;
  653. $idx++;
  654. };
  655. } else {
  656. for( ;$idx<1;$idx++ ){
  657. $T = str_replace( '%%ID%%', 4+$idx , $DUMMY['camera'] );
  658. $OUT[]= $STA[3+$idx] . $T . $END;
  659. };
  660. };
  661. $OUT[]= $STA[4] . $DUMMY['log'] . $END;
  662. break;
  663. };
  664. case 6:{
  665. $STA[0]="{ columnWidth: 1.0, stydle:'padding:10px 0 10px 10px', items:[";
  666. //$STA[1]="{ columnWidth: .25, stylse:'padding:10px 0 10px 10px', items:[";
  667. //$STA[2]="{ columnWidth: .75, stylse:'padding:10px 0 10px 10px', items:[";
  668. $STA[1]="{ columnWidth: 1.0, stylse:'padding:10px 0 10px 10px', items:[";
  669. $MH = 4;
  670. if( $CUser->Data['access'] > 2 ){
  671. $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();}} }";
  672. $DUMMY['log']="{xtype:'panel', id: 'lg_panel', title: '{$Labels->GetLabel('_EVENT_LOG_')}', frame: true, border: true, draggable: false, items:[{$LOGIO}] }";
  673. $OUT[]= $STA[0] . $DUMMY['map'] . $END;
  674. //$OUT[]= $STA[1] . $DUMMY['sensor'] . $END;
  675. $OUT[]= $STA[1] . $DUMMY['log'] . $END;
  676. } else {
  677. $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)*9); initMapMonitoring();}} }";
  678. $OUT[]= $STA[0] . $DUMMY['map'] . $END;
  679. };
  680. break;
  681. };
  682. default:
  683. };
  684. //$OUT[0]='{columnWidth: 1, items:{html:"Sys Layout:'.$SP['app_layout'].'"}}';
  685. $Data = '[' . implode( ',' , $OUT ) . ']';
  686. } else {
  687. $Data = '[{columnWidth: 1, items:{html:"NO SYSTEM PROPS"}} ]';
  688. };
  689. };
  690. if( $Data != '' ) {
  691. echo $Data;
  692. } else {
  693. echo '[]';
  694. };
  695. ?>