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.

696 lines
28 KiB

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