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.

580 lines
23 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 years ago
​
​
​
​
​
​
4 years ago
​
​
​
​
4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 years ago
​
​
​
​
​
​
​
4 years ago
​
​
​
​
4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 years ago
​
​
​
​
​
​
​
4 years ago
​
​
​
​
4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 years ago
​
​
​
​
​
​
​
4 years ago
​
​
​
​
4 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. switch( $SP['app_layout'] ){
  131. case 0:{
  132. $STA[0]="{ columnWidth: .25, stylse:'padding:10px 0 10px 10px', items:[";
  133. $STA[1]="{ columnWidth: .25, stylse:'padding:10px 0 10px 10px', items:[";
  134. $STA[2]="{ columnWidth: .25, stylse:'padding:10px 0 10px 10px', items:[";
  135. $STA[3]="{ columnWidth: .25, stylse:'padding:10px 0 10px 10px', items:[";
  136. $STA[4]="{ columnWidth: .5, stylde:'padding:10px 0 10px 10px', items:[";
  137. $STA[5]="{ columnWidth: .5, stylde:'padding:10px 0 10px 10px', items:[";
  138. $STA[6]="{ columnWidth: 1.0, stydle:'padding:10px 0 10px 10px', items:[";
  139. $QS = "SELECT * FROM `nodes` WHERE `type`>0 AND `type`< 10 AND `enable`=1";
  140. $R = $DATABASE->Query( $QS );
  141. $idx = 0;
  142. if( count( $R ) ){
  143. foreach( $R as $DD ){
  144. if( $idx < 4 ){
  145. $TFN = 'dash/node_' . $DD['type'] . '.js';
  146. if(!file_exists( $TFN )) continue;
  147. $TPL = file_get_contents( $TFN );
  148. $TPL = inject_labels( $TPL );
  149. $TPL = str_replace('%%%NODEID%%%', ''.$DD['id'] , $TPL );
  150. $TPL = str_replace('%%%NODENAME%%%', ''. urldecode( $DD['name'] ), $TPL );
  151. $TPL = str_replace('%%%USERID%%%', $UserID, $TPL );
  152. $TPL = str_replace('%%%SESSION%%%', $Session, $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. $QS="SELECT * FROM `nodes` WHERE `id`={$DD['id']}";
  182. $Z=$DATABASE->Query( $QS );
  183. $QS="SELECT * FROM `module_eve` WHERE `id`=1";
  184. $S=$DATABASE->Query( $QS );
  185. $MODULE_DATA = $S[0];
  186. $TPL = str_replace( '%%%NODENAME%%%', urldecode( $Z[0]['name'] ) , $TPL );
  187. //$FU = 'http://' . $_SERVER['SERVER_ADDR'].':' . $MODULE_DATA['web_port'] .'/stream?id='. $Z[0]['aux_parameter'];
  188. $FU = '/video_feed/stream?id='. $Z[0]['aux_parameter'];
  189. $CS[] = '[' . $Z[0]['aux_parameter'] . ',\'[ 120x120] Video\',\''. $FU .'\']';
  190. $TPL = str_replace( '%%%URLS%%%', '[' . implode( ',', $CS ) . ']' , $TPL );
  191. $TPL = str_replace( '%%%SELID%%%', 'value: '. $Z[0]['aux_parameter'] .',', $TPL );
  192. $TPL = str_replace( '%%%SELURL%%%', $FU, $TPL );
  193. $TPL = str_replace( '%%%STREAMID%%%', $DD['aux_parameter'], $TPL );
  194. if( $DD['type'] == 13 || $DD['type'] == 11 ){
  195. $QS = "SELECT `homing_enable` FROM `cameras` WHERE `id`={$DD['aux_id']}";
  196. $JUA = $DATABASE->Query( $QS );
  197. $CAMDATA = $JUA[0];
  198. if( $CAMDATA['homing_enable'] ){
  199. if( $CUser->Data['access'] > 5 ){
  200. $TPL = str_replace( '%%%HBTN%%%', '<img id="img_btn_0ZZ_'.$DD['aux_id'].'" class="ptz_ctrl_btn" src="/style/png/building/038.png">', $TPL );
  201. $TPL = str_replace('%%%CAM_CTRL_HOME_BTN_BIND%%%', 'document.getElementById(\'img_btn_0ZZ_'.$DD['aux_id'].'\').addEventListener( \'mousedown\', makePtzHome );', $TPL );
  202. } else {
  203. $TPL = str_replace('%%%HBTN%%%', '&nbsp;', $TPL );
  204. $TPL = str_replace('%%%CAM_CTRL_HOME_BTN_BIND%%%', '', $TPL );
  205. };
  206. } else {
  207. $TPL = str_replace('%%%HBTN%%%', '&nbsp;', $TPL );
  208. $TPL = str_replace('%%%CAM_CTRL_HOME_BTN_BIND%%%', '', $TPL );
  209. };
  210. };
  211. $FK = $MODULE_DATA['height'] /$MODULE_DATA['width'];
  212. $W = 244;
  213. $H = $W * $FK;
  214. $TPL = str_replace( '%%%WIDTH%%%', $W, $TPL );
  215. $TPL = str_replace( '%%%HEIGHT%%%', $H, $TPL );
  216. $OUT[]= $STA[4+$idx] . $TPL . $END;
  217. } else break;
  218. $idx++;
  219. };
  220. if( $idx < 2 ){
  221. for( ;$idx<2;$idx++ ){
  222. $T = str_replace( '%%ID%%', 4+$idx , $DUMMY['camera'] );
  223. $OUT[]= $STA[4+$idx] . $T . $END;
  224. };
  225. };
  226. } else {
  227. for( ;$idx<2;$idx++ ){
  228. $T = str_replace( '%%ID%%', 4+$idx , $DUMMY['camera'] );
  229. $OUT[]= $STA[4+$idx] . $T . $END;
  230. };
  231. };
  232. switch( $SP['type'] ){
  233. case 1:{
  234. // LA Metro
  235. $OUT[]= $STA[6] . $DUMMY['log'] . $END;
  236. break;
  237. };
  238. case 2:{
  239. //Togo
  240. $OUT[]= $STA[6] . $DUMMY['map'] . $END;
  241. break;
  242. };
  243. }
  244. break;
  245. };
  246. case 1:{
  247. $STA[0]="{ columnWidth: .33, stylse:'padding:10px 0 10px 10px', items:[";
  248. $STA[1]="{ columnWidth: .33, stylse:'padding:10px 0 10px 10px', items:[";
  249. $STA[2]="{ columnWidth: .33, stylse:'padding:10px 0 10px 10px', items:[";
  250. $STA[3]="{ columnWidth: 1.0, stylse:'padding:10px 0 10px 10px', items:[";
  251. $QS = "SELECT * FROM `nodes` WHERE `type`>0 AND `type`< 10 AND `enable`=1";
  252. $R = $DATABASE->Query( $QS );
  253. $idx = 0;
  254. if( count( $R ) ){
  255. foreach( $R as $DD ){
  256. if( $idx < 2 ){
  257. $TFN = 'dash/node_' . $DD['type'] . '.js';
  258. if(!file_exists( $TFN )) continue;
  259. $TPL = file_get_contents( $TFN );
  260. $TPL = inject_labels( $TPL );
  261. $TPL = str_replace('%%%NODEID%%%', ''.$DD['id'] , $TPL );
  262. $TPL = str_replace('%%%NODENAME%%%', ''.html_entity_decode( $DD['name'] ) , $TPL );
  263. $TPL = str_replace('%%%USERID%%%', $UserID, $TPL );
  264. $TPL = str_replace('%%%SESSION%%%', $Session, $TPL );
  265. $OUT[]= $STA[$idx] . $TPL . $END;
  266. } else break;
  267. $idx++;
  268. };
  269. if( $idx < 2 ){
  270. for( ;$idx<2;$idx++ ){
  271. $OUT[]= $STA[$idx] . $DUMMY['sensor'] . $END;
  272. };
  273. };
  274. } else {
  275. for( ;$idx<2;$idx++ ){
  276. $OUT[]= $STA[$idx] . $DUMMY['sensor'] . $END;
  277. };
  278. };
  279. $QS = "SELECT * FROM `nodes` WHERE `type`>9 AND `type`< 14 AND `enable`=1";
  280. $R = $DATABASE->Query( $QS );
  281. $idx = 0;
  282. if( count( $R ) ){
  283. foreach( $R as $DD ){
  284. if( $idx < 1 ){
  285. $TFN = 'dash/node_' . $DD['type'] . '.js';
  286. if(!file_exists( $TFN )) continue;
  287. $TPL = file_get_contents( $TFN );
  288. $TPL = inject_labels( $TPL );
  289. $TPL = str_replace('%%%NODEID%%%', ''.$DD['id'] , $TPL );
  290. $TPL = str_replace('%%%NODENAME%%%', ''.urldecode($DD['name']) , $TPL );
  291. $TPL = str_replace('%%%USERID%%%', $UserID, $TPL );
  292. $TPL = str_replace('%%%SESSION%%%', $Session, $TPL );
  293. $QS="SELECT * FROM `nodes` WHERE `id`={$DD['id']}";
  294. $Z=$DATABASE->Query( $QS );
  295. $QS="SELECT * FROM `module_eve` WHERE `id`=1";
  296. $S=$DATABASE->Query( $QS );
  297. $MODULE_DATA = $S[0];
  298. $TPL = str_replace( '%%%NODENAME%%%', urldecode( $Z[0]['name'] ) , $TPL );
  299. //$FU = 'http://' . $_SERVER['SERVER_ADDR'].':' . $MODULE_DATA['web_port'] .'/stream?id='. $Z[0]['aux_parameter'];
  300. $FU = '/video_feed/stream?id='. $Z[0]['aux_parameter'];
  301. $CS[] = '[' . $Z[0]['aux_parameter'] . ',\'[ 120x120] Video\',\''. $FU .'\']';
  302. $TPL = str_replace( '%%%URLS%%%', '[' . implode( ',', $CS ) . ']' , $TPL );
  303. $TPL = str_replace( '%%%SELID%%%', 'value: '. $Z[0]['aux_parameter'] .',', $TPL );
  304. $TPL = str_replace( '%%%SELURL%%%', $FU, $TPL );
  305. $TPL = str_replace( '%%%STREAMID%%%', $DD['aux_parameter'], $TPL );
  306. if( $DD['type'] == 13 || $DD['type'] == 11 ){
  307. $QS = "SELECT `homing_enable` FROM `cameras` WHERE `id`={$DD['aux_id']}";
  308. $JUA = $DATABASE->Query( $QS );
  309. $CAMDATA = $JUA[0];
  310. if( $CAMDATA['homing_enable'] ){
  311. if( $CUser->Data['access'] > 5 ){
  312. $TPL = str_replace( '%%%HBTN%%%', '<img id="img_btn_0ZZ_'.$DD['aux_id'].'" class="ptz_ctrl_btn" src="/style/png/building/038.png">', $TPL );
  313. $TPL = str_replace('%%%CAM_CTRL_HOME_BTN_BIND%%%', 'document.getElementById(\'img_btn_0ZZ_'.$DD['aux_id'].'\').addEventListener( \'mousedown\', makePtzHome );', $TPL );
  314. } else {
  315. $TPL = str_replace('%%%HBTN%%%', '&nbsp;', $TPL );
  316. $TPL = str_replace('%%%CAM_CTRL_HOME_BTN_BIND%%%', '', $TPL );
  317. };
  318. } else {
  319. $TPL = str_replace('%%%HBTN%%%', '&nbsp;', $TPL );
  320. $TPL = str_replace('%%%CAM_CTRL_HOME_BTN_BIND%%%', '', $TPL );
  321. };
  322. };
  323. $FK = $MODULE_DATA['height'] /$MODULE_DATA['width'];
  324. $W = 244;
  325. $H = $W * $FK;
  326. $TPL = str_replace( '%%%WIDTH%%%', $W, $TPL );
  327. $TPL = str_replace( '%%%HEIGHT%%%', $H, $TPL );
  328. $OUT[]= $STA[2+$idx] . $TPL . $END;
  329. } else break;
  330. $idx++;
  331. };
  332. if( $idx < 1 ){
  333. for( ;$idx<1;$idx++ ){
  334. $T = str_replace( '%%ID%%', 2+$idx , $DUMMY['camera'] );
  335. $OUT[]= $STA[2+$idx] . $T . $END;
  336. };
  337. };
  338. } else {
  339. for( ;$idx<1;$idx++ ){
  340. $T = str_replace( '%%ID%%', 4+$idx , $DUMMY['camera'] );
  341. $OUT[]= $STA[2+$idx] . $T . $END;
  342. };
  343. };
  344. switch( $SP['type'] ){
  345. case 1:{
  346. // LA Metro
  347. $OUT[]= $STA[3] . $DUMMY['log'] . $END;
  348. break;
  349. };
  350. case 2:{
  351. //Togo
  352. $OUT[]= $STA[3] . $DUMMY['map'] . $END;
  353. break;
  354. };
  355. }
  356. break;
  357. };
  358. case 2:{
  359. $STA[0]="{ columnWidth: .33, stylse:'padding:10px 0 10px 10px', items:[";
  360. $STA[1]="{ columnWidth: .33, stylse:'padding:10px 0 10px 10px', items:[";
  361. $STA[2]="{ columnWidth: .33, stylse:'padding:10px 0 10px 10px', items:[";
  362. $STA[3]="{ columnWidth: .5, stylse:'padding:10px 0 10px 10px', items:[";
  363. $STA[4]="{ columnWidth: .5, stylde:'padding:10px 0 10px 10px', items:[";
  364. $idx = 0;
  365. $QS = "SELECT * FROM `nodes` WHERE `type`>0 AND `type`< 10 AND `enable`=1";
  366. $R = $DATABASE->Query( $QS );
  367. if( count( $R ) ){
  368. foreach( $R as $DD ){
  369. if( $idx < 3 ){
  370. $TFN = 'dash/node_' . $DD['type'] . '.js';
  371. if(!file_exists( $TFN )) continue;
  372. $TPL = file_get_contents( $TFN );
  373. $TPL = inject_labels( $TPL );
  374. $TPL = str_replace('%%%NODEID%%%', ''.$DD['id'] , $TPL );
  375. $TPL = str_replace('%%%NODENAME%%%', ''.html_entity_decode( $DD['name'] ) , $TPL );
  376. $TPL = str_replace('%%%USERID%%%', $UserID, $TPL );
  377. $TPL = str_replace('%%%SESSION%%%', $Session, $TPL );
  378. $OUT[]= $STA[$idx] . $TPL . $END;
  379. } else break;
  380. $idx++;
  381. };
  382. if( $idx < 3 ){
  383. for( ;$idx<3;$idx++ ){
  384. $OUT[]= $STA[$idx] . $DUMMY['sensor'] . $END;
  385. };
  386. };
  387. } else {
  388. for( ;$idx<3;$idx++ ){
  389. $OUT[]= $STA[$idx] . $DUMMY['sensor'] . $END;
  390. };
  391. };
  392. $QS = "SELECT * FROM `nodes` WHERE `type`>9 AND `type`< 14 AND `enable`=1";
  393. $R = $DATABASE->Query( $QS );
  394. $idx = 0;
  395. if( count( $R ) ){
  396. foreach( $R as $DD ){
  397. if( $idx < 2 ){
  398. $TFN = 'dash/node_' . $DD['type'] . '.js';
  399. if(!file_exists( $TFN )) continue;
  400. $TPL = file_get_contents( $TFN );
  401. $TPL = inject_labels( $TPL );
  402. $TPL = str_replace('%%%NODEID%%%', ''.$DD['id'] , $TPL );
  403. $TPL = str_replace('%%%NODENAME%%%', ''.urldecode($DD['name']) , $TPL );
  404. $TPL = str_replace('%%%USERID%%%', $UserID, $TPL );
  405. $TPL = str_replace('%%%SESSION%%%', $Session, $TPL );
  406. $QS="SELECT * FROM `nodes` WHERE `id`={$DD['id']}";
  407. $Z=$DATABASE->Query( $QS );
  408. $QS="SELECT * FROM `module_eve` WHERE `id`=1";
  409. $S=$DATABASE->Query( $QS );
  410. $MODULE_DATA = $S[0];
  411. $TPL = str_replace( '%%%NODENAME%%%', urldecode( $Z[0]['name'] ) , $TPL );
  412. //$FU = 'http://' . $_SERVER['SERVER_ADDR'].':' . $MODULE_DATA['web_port'] .'/stream?id='. $Z[0]['aux_parameter'];
  413. $FU = '/video_feed/stream?id='. $Z[0]['aux_parameter'];
  414. $CS[] = '[' . $Z[0]['aux_parameter'] . ',\'[ 120x120] Video\',\''. $FU .'\']';
  415. $TPL = str_replace( '%%%URLS%%%', '[' . implode( ',', $CS ) . ']' , $TPL );
  416. $TPL = str_replace( '%%%SELID%%%', 'value: '. $Z[0]['aux_parameter'] .',', $TPL );
  417. $TPL = str_replace( '%%%SELURL%%%', $FU, $TPL );
  418. $TPL = str_replace( '%%%STREAMID%%%', $DD['aux_parameter'], $TPL );
  419. if( $DD['type'] == 13 || $DD['type'] == 11 ){
  420. $QS = "SELECT `homing_enable` FROM `cameras` WHERE `id`={$DD['aux_id']}";
  421. $JUA = $DATABASE->Query( $QS );
  422. $CAMDATA = $JUA[0];
  423. if( $CAMDATA['homing_enable'] ){
  424. if( $CUser->Data['access'] > 5 ){
  425. $TPL = str_replace( '%%%HBTN%%%', '<img id="img_btn_0ZZ_'.$DD['aux_id'].'" class="ptz_ctrl_btn" src="/style/png/building/038.png">', $TPL );
  426. $TPL = str_replace('%%%CAM_CTRL_HOME_BTN_BIND%%%', 'document.getElementById(\'img_btn_0ZZ_'.$DD['aux_id'].'\').addEventListener( \'mousedown\', makePtzHome );', $TPL );
  427. } else {
  428. $TPL = str_replace('%%%HBTN%%%', '&nbsp;', $TPL );
  429. $TPL = str_replace('%%%CAM_CTRL_HOME_BTN_BIND%%%', '', $TPL );
  430. };
  431. } else {
  432. $TPL = str_replace('%%%HBTN%%%', '&nbsp;', $TPL );
  433. $TPL = str_replace('%%%CAM_CTRL_HOME_BTN_BIND%%%', '', $TPL );
  434. };
  435. };
  436. $FK = $MODULE_DATA['height'] /$MODULE_DATA['width'];
  437. $W = 244;
  438. $H = $W * $FK;
  439. $TPL = str_replace( '%%%WIDTH%%%', $W, $TPL );
  440. $TPL = str_replace( '%%%HEIGHT%%%', $H, $TPL );
  441. $OUT[]= $STA[3+$idx] . $TPL . $END;
  442. } else break;
  443. $idx++;
  444. };
  445. if( $idx < 2 ){
  446. for( ;$idx<2;$idx++ ){
  447. $T = str_replace( '%%ID%%', 2+$idx , $DUMMY['camera'] );
  448. $OUT[]= $STA[3+$idx] . $T . $END;
  449. };
  450. };
  451. } else {
  452. for( ;$idx<2;$idx++ ){
  453. $T = str_replace( '%%ID%%', 4+$idx , $DUMMY['camera'] );
  454. $OUT[]= $STA[3+$idx] . $T . $END;
  455. };
  456. };
  457. $OUT[]= $STA[3] . $DUMMY['log'] . $END;
  458. $OUT[]= $STA[4] . $DUMMY['map'] . $END;
  459. break;
  460. };
  461. case 3:{
  462. $STA[0]="{ columnWidth: .5, stylse:'padding:10px 0 10px 10px', items:[";
  463. $STA[1]="{ columnWidth: .5, stylse:'padding:10px 0 10px 10px', items:[";
  464. $STA[2]="{ columnWidth: .33, stylse:'padding:10px 0 10px 10px', items:[";
  465. $STA[3]="{ columnWidth: .67, stylse:'padding:10px 0 10px 10px', items:[";
  466. $OUT[]= $STA[0] . $DUMMY['map'] . $END;
  467. $QS = "SELECT * FROM `nodes` WHERE `type`>9 AND `type`< 14 AND `enable`=1";
  468. $R = $DATABASE->Query( $QS );
  469. $idx = 0;
  470. if( count( $R ) ){
  471. foreach( $R as $DD ){
  472. if( $idx < 1 ){
  473. $TFN = 'dash/node_' . $DD['type'] . '.js';
  474. if(!file_exists( $TFN )) continue;
  475. $TPL = file_get_contents( $TFN );
  476. $TPL = inject_labels( $TPL );
  477. $TPL = str_replace('%%%NODEID%%%', ''.$DD['id'] , $TPL );
  478. $TPL = str_replace('%%%NODENAME%%%', ''.urldecode($DD['name']) , $TPL );
  479. $TPL = str_replace('%%%USERID%%%', $UserID, $TPL );
  480. $TPL = str_replace('%%%SESSION%%%', $Session, $TPL );
  481. $QS="SELECT * FROM `nodes` WHERE `id`={$DD['id']}";
  482. $Z=$DATABASE->Query( $QS );
  483. $QS="SELECT * FROM `module_eve` WHERE `id`=1";
  484. $S=$DATABASE->Query( $QS );
  485. $MODULE_DATA = $S[0];
  486. $TPL = str_replace( '%%%NODENAME%%%', urldecode( $Z[0]['name'] ) , $TPL );
  487. //$FU = 'http://' . $_SERVER['SERVER_ADDR'].':' . $MODULE_DATA['web_port'] .'/stream?id='. $Z[0]['aux_parameter'];
  488. $FU = '/video_feed/stream?id='. $Z[0]['aux_parameter'];
  489. $CS[] = '[' . $Z[0]['aux_parameter'] . ',\'[ 120x120] Video\',\''. $FU .'\']';
  490. $TPL = str_replace( '%%%URLS%%%', '[' . implode( ',', $CS ) . ']' , $TPL );
  491. $TPL = str_replace( '%%%SELID%%%', 'value: '. $Z[0]['aux_parameter'] .',', $TPL );
  492. $TPL = str_replace( '%%%SELURL%%%', $FU, $TPL );
  493. $TPL = str_replace( '%%%STREAMID%%%', $DD['aux_parameter'], $TPL );
  494. if( $DD['type'] == 13 || $DD['type'] == 11 ){
  495. $QS = "SELECT `homing_enable` FROM `cameras` WHERE `id`={$DD['aux_id']}";
  496. $JUA = $DATABASE->Query( $QS );
  497. $CAMDATA = $JUA[0];
  498. if( $CAMDATA['homing_enable'] ){
  499. if( $CUser->Data['access'] > 5 ){
  500. $TPL = str_replace( '%%%HBTN%%%', '<img id="img_btn_0ZZ_'.$DD['aux_id'].'" class="ptz_ctrl_btn" src="/style/png/building/038.png">', $TPL );
  501. $TPL = str_replace('%%%CAM_CTRL_HOME_BTN_BIND%%%', 'document.getElementById(\'img_btn_0ZZ_'.$DD['aux_id'].'\').addEventListener( \'mousedown\', makePtzHome );', $TPL );
  502. } else {
  503. $TPL = str_replace('%%%HBTN%%%', '&nbsp;', $TPL );
  504. $TPL = str_replace('%%%CAM_CTRL_HOME_BTN_BIND%%%', '', $TPL );
  505. };
  506. } else {
  507. $TPL = str_replace('%%%HBTN%%%', '&nbsp;', $TPL );
  508. $TPL = str_replace('%%%CAM_CTRL_HOME_BTN_BIND%%%', '', $TPL );
  509. };
  510. };
  511. $FK = $MODULE_DATA['height'] /$MODULE_DATA['width'];
  512. $W = 244;
  513. $H = $W * $FK;
  514. $TPL = str_replace( '%%%WIDTH%%%', $W, $TPL );
  515. $TPL = str_replace( '%%%HEIGHT%%%', $H, $TPL );
  516. $OUT[]= $STA[1+$idx] . $TPL . $END;
  517. } else break;
  518. $idx++;
  519. };
  520. } else {
  521. for( ;$idx<1;$idx++ ){
  522. $T = str_replace( '%%ID%%', 4+$idx , $DUMMY['camera'] );
  523. $OUT[]= $STA[1+$idx] . $T . $END;
  524. };
  525. };
  526. $QS = "SELECT * FROM `nodes` WHERE `type`>0 AND `type`< 10 AND `enable`=1";
  527. $R = $DATABASE->Query( $QS );
  528. $idx = 0;
  529. if( count( $R ) ){
  530. foreach( $R as $DD ){
  531. if( $idx < 1 ){
  532. $TFN = 'dash/node_' . $DD['type'] . '.js';
  533. if(!file_exists( $TFN )) continue;
  534. $TPL = file_get_contents( $TFN );
  535. $TPL = inject_labels( $TPL );
  536. $TPL = str_replace('%%%NODEID%%%', ''.$DD['id'] , $TPL );
  537. $TPL = str_replace('%%%NODENAME%%%', ''.html_entity_decode( $DD['name'] ) , $TPL );
  538. $TPL = str_replace('%%%USERID%%%', $UserID, $TPL );
  539. $TPL = str_replace('%%%SESSION%%%', $Session, $TPL );
  540. $OUT[]= $STA[2+$idx] . $TPL . $END;
  541. } else break;
  542. $idx++;
  543. };
  544. } else {
  545. for( ;$idx<1;$idx++ ){
  546. $OUT[]= $STA[2+$idx] . $DUMMY['sensor'] . $END;
  547. };
  548. };
  549. $OUT[]= $STA[3] . $DUMMY['log'] . $END;
  550. break;
  551. };
  552. case 4:
  553. case 5:
  554. default:
  555. };
  556. $Data = '[' . implode( ',' , $OUT ) . ']';
  557. } else {
  558. $Data = '[{columnWidth: 1, items:{html:"NO SYSTEM PROPS"}} ]';
  559. };
  560. };
  561. if( $Data != '' ) {
  562. echo $Data;
  563. } else {
  564. echo '[]';
  565. };
  566. ?>