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.

589 lines
24 KiB

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