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.

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