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.

581 lines
24 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. 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. $OUT[]= $STA[$idx] . $TPL . $END;
  155. } else break;
  156. $idx++;
  157. };
  158. if( $idx < 4 ){
  159. for( ;$idx<4;$idx++ ){
  160. $OUT[]= $STA[$idx] . $DUMMY['sensor'] . $END;
  161. };
  162. };
  163. } else {
  164. for( ;$idx<4;$idx++ ){
  165. $OUT[]= $STA[$idx] . $DUMMY['sensor'] . $END;
  166. };
  167. };
  168. $QS = "SELECT * FROM `nodes` WHERE `type`>9 AND `type`< 14 AND `enable`=1";
  169. $R = $DATABASE->Query( $QS );
  170. $idx = 0;
  171. if( count( $R ) ){
  172. foreach( $R as $DD ){
  173. if( $idx < 2 ){
  174. $TFN = 'dash/node_' . $DD['type'] . '.js';
  175. if(!file_exists( $TFN )) continue;
  176. $TPL = file_get_contents( $TFN );
  177. $TPL = inject_labels( $TPL );
  178. $TPL = str_replace('%%%NODEID%%%', ''.$DD['id'] , $TPL );
  179. $TPL = str_replace('%%%NODENAME%%%', ''.urldecode( $DD['name'] ) , $TPL );
  180. $TPL = str_replace('%%%USERID%%%', $UserID, $TPL );
  181. $TPL = str_replace('%%%SESSION%%%', $Session, $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. $OUT[]= $STA[$idx] . $TPL . $END;
  267. } else break;
  268. $idx++;
  269. };
  270. if( $idx < 2 ){
  271. for( ;$idx<2;$idx++ ){
  272. $OUT[]= $STA[$idx] . $DUMMY['sensor'] . $END;
  273. };
  274. };
  275. } else {
  276. for( ;$idx<2;$idx++ ){
  277. $OUT[]= $STA[$idx] . $DUMMY['sensor'] . $END;
  278. };
  279. };
  280. $QS = "SELECT * FROM `nodes` WHERE `type`>9 AND `type`< 14 AND `enable`=1";
  281. $R = $DATABASE->Query( $QS );
  282. $idx = 0;
  283. if( count( $R ) ){
  284. foreach( $R as $DD ){
  285. if( $idx < 1 ){
  286. $TFN = 'dash/node_' . $DD['type'] . '.js';
  287. if(!file_exists( $TFN )) continue;
  288. $TPL = file_get_contents( $TFN );
  289. $TPL = inject_labels( $TPL );
  290. $TPL = str_replace('%%%NODEID%%%', ''.$DD['id'] , $TPL );
  291. $TPL = str_replace('%%%NODENAME%%%', ''.urldecode($DD['name']) , $TPL );
  292. $TPL = str_replace('%%%USERID%%%', $UserID, $TPL );
  293. $TPL = str_replace('%%%SESSION%%%', $Session, $TPL );
  294. $QS="SELECT * FROM `nodes` WHERE `id`={$DD['id']}";
  295. $Z=$DATABASE->Query( $QS );
  296. $QS="SELECT * FROM `module_eve` WHERE `id`=1";
  297. $S=$DATABASE->Query( $QS );
  298. $MODULE_DATA = $S[0];
  299. $TPL = str_replace( '%%%NODENAME%%%', urldecode( $Z[0]['name'] ) , $TPL );
  300. //$FU = 'http://' . $_SERVER['SERVER_ADDR'].':' . $MODULE_DATA['web_port'] .'/stream?id='. $Z[0]['aux_parameter'];
  301. $FU = '/video_feed/stream?id='. $Z[0]['aux_parameter'];
  302. $CS[] = '[' . $Z[0]['aux_parameter'] . ',\'[ 120x120] Video\',\''. $FU .'\']';
  303. $TPL = str_replace( '%%%URLS%%%', '[' . implode( ',', $CS ) . ']' , $TPL );
  304. $TPL = str_replace( '%%%SELID%%%', 'value: '. $Z[0]['aux_parameter'] .',', $TPL );
  305. $TPL = str_replace( '%%%SELURL%%%', $FU, $TPL );
  306. $TPL = str_replace( '%%%STREAMID%%%', $DD['aux_parameter'], $TPL );
  307. if( $DD['type'] == 13 || $DD['type'] == 11 ){
  308. $QS = "SELECT `homing_enable` FROM `cameras` WHERE `id`={$DD['aux_id']}";
  309. $JUA = $DATABASE->Query( $QS );
  310. $CAMDATA = $JUA[0];
  311. if( $CAMDATA['homing_enable'] ){
  312. if( $CUser->Data['access'] > 5 ){
  313. $TPL = str_replace( '%%%HBTN%%%', '<img id="img_btn_0ZZ_'.$DD['aux_id'].'" class="ptz_ctrl_btn" src="/style/png/building/038.png">', $TPL );
  314. $TPL = str_replace('%%%CAM_CTRL_HOME_BTN_BIND%%%', 'document.getElementById(\'img_btn_0ZZ_'.$DD['aux_id'].'\').addEventListener( \'mousedown\', makePtzHome );', $TPL );
  315. } else {
  316. $TPL = str_replace('%%%HBTN%%%', '&nbsp;', $TPL );
  317. $TPL = str_replace('%%%CAM_CTRL_HOME_BTN_BIND%%%', '', $TPL );
  318. };
  319. } else {
  320. $TPL = str_replace('%%%HBTN%%%', '&nbsp;', $TPL );
  321. $TPL = str_replace('%%%CAM_CTRL_HOME_BTN_BIND%%%', '', $TPL );
  322. };
  323. };
  324. $FK = $MODULE_DATA['height'] /$MODULE_DATA['width'];
  325. $W = 244;
  326. $H = $W * $FK;
  327. $TPL = str_replace( '%%%WIDTH%%%', $W, $TPL );
  328. $TPL = str_replace( '%%%HEIGHT%%%', $H, $TPL );
  329. $OUT[]= $STA[2+$idx] . $TPL . $END;
  330. } else break;
  331. $idx++;
  332. };
  333. if( $idx < 1 ){
  334. for( ;$idx<1;$idx++ ){
  335. $T = str_replace( '%%ID%%', 2+$idx , $DUMMY['camera'] );
  336. $OUT[]= $STA[2+$idx] . $T . $END;
  337. };
  338. };
  339. } else {
  340. for( ;$idx<1;$idx++ ){
  341. $T = str_replace( '%%ID%%', 4+$idx , $DUMMY['camera'] );
  342. $OUT[]= $STA[2+$idx] . $T . $END;
  343. };
  344. };
  345. switch( $SP['type'] ){
  346. case 1:{
  347. // LA Metro
  348. $OUT[]= $STA[3] . $DUMMY['log'] . $END;
  349. break;
  350. };
  351. case 2:{
  352. //Togo
  353. $OUT[]= $STA[3] . $DUMMY['map'] . $END;
  354. break;
  355. };
  356. }
  357. break;
  358. };
  359. case 2:{
  360. $STA[0]="{ columnWidth: .33, stylse:'padding:10px 0 10px 10px', items:[";
  361. $STA[1]="{ columnWidth: .33, stylse:'padding:10px 0 10px 10px', items:[";
  362. $STA[2]="{ columnWidth: .33, stylse:'padding:10px 0 10px 10px', items:[";
  363. $STA[3]="{ columnWidth: .5, stylse:'padding:10px 0 10px 10px', items:[";
  364. $STA[4]="{ columnWidth: .5, stylde:'padding:10px 0 10px 10px', items:[";
  365. $idx = 0;
  366. $QS = "SELECT * FROM `nodes` WHERE `type`>0 AND `type`< 10 AND `enable`=1";
  367. $R = $DATABASE->Query( $QS );
  368. if( count( $R ) ){
  369. foreach( $R as $DD ){
  370. if( $idx < 3 ){
  371. $TFN = 'dash/node_' . $DD['type'] . '.js';
  372. if(!file_exists( $TFN )) continue;
  373. $TPL = file_get_contents( $TFN );
  374. $TPL = inject_labels( $TPL );
  375. $TPL = str_replace('%%%NODEID%%%', ''.$DD['id'] , $TPL );
  376. $TPL = str_replace('%%%NODENAME%%%', ''.html_entity_decode( $DD['name'] ) , $TPL );
  377. $TPL = str_replace('%%%USERID%%%', $UserID, $TPL );
  378. $TPL = str_replace('%%%SESSION%%%', $Session, $TPL );
  379. $OUT[]= $STA[$idx] . $TPL . $END;
  380. } else break;
  381. $idx++;
  382. };
  383. if( $idx < 3 ){
  384. for( ;$idx<3;$idx++ ){
  385. $OUT[]= $STA[$idx] . $DUMMY['sensor'] . $END;
  386. };
  387. };
  388. } else {
  389. for( ;$idx<3;$idx++ ){
  390. $OUT[]= $STA[$idx] . $DUMMY['sensor'] . $END;
  391. };
  392. };
  393. $QS = "SELECT * FROM `nodes` WHERE `type`>9 AND `type`< 14 AND `enable`=1";
  394. $R = $DATABASE->Query( $QS );
  395. $idx = 0;
  396. if( count( $R ) ){
  397. foreach( $R as $DD ){
  398. if( $idx < 2 ){
  399. $TFN = 'dash/node_' . $DD['type'] . '.js';
  400. if(!file_exists( $TFN )) continue;
  401. $TPL = file_get_contents( $TFN );
  402. $TPL = inject_labels( $TPL );
  403. $TPL = str_replace('%%%NODEID%%%', ''.$DD['id'] , $TPL );
  404. $TPL = str_replace('%%%NODENAME%%%', ''.urldecode($DD['name']) , $TPL );
  405. $TPL = str_replace('%%%USERID%%%', $UserID, $TPL );
  406. $TPL = str_replace('%%%SESSION%%%', $Session, $TPL );
  407. $QS="SELECT * FROM `nodes` WHERE `id`={$DD['id']}";
  408. $Z=$DATABASE->Query( $QS );
  409. $QS="SELECT * FROM `module_eve` WHERE `id`=1";
  410. $S=$DATABASE->Query( $QS );
  411. $MODULE_DATA = $S[0];
  412. $TPL = str_replace( '%%%NODENAME%%%', urldecode( $Z[0]['name'] ) , $TPL );
  413. //$FU = 'http://' . $_SERVER['SERVER_ADDR'].':' . $MODULE_DATA['web_port'] .'/stream?id='. $Z[0]['aux_parameter'];
  414. $FU = '/video_feed/stream?id='. $Z[0]['aux_parameter'];
  415. $CS[] = '[' . $Z[0]['aux_parameter'] . ',\'[ 120x120] Video\',\''. $FU .'\']';
  416. $TPL = str_replace( '%%%URLS%%%', '[' . implode( ',', $CS ) . ']' , $TPL );
  417. $TPL = str_replace( '%%%SELID%%%', 'value: '. $Z[0]['aux_parameter'] .',', $TPL );
  418. $TPL = str_replace( '%%%SELURL%%%', $FU, $TPL );
  419. $TPL = str_replace( '%%%STREAMID%%%', $DD['aux_parameter'], $TPL );
  420. if( $DD['type'] == 13 || $DD['type'] == 11 ){
  421. $QS = "SELECT `homing_enable` FROM `cameras` WHERE `id`={$DD['aux_id']}";
  422. $JUA = $DATABASE->Query( $QS );
  423. $CAMDATA = $JUA[0];
  424. if( $CAMDATA['homing_enable'] ){
  425. if( $CUser->Data['access'] > 5 ){
  426. $TPL = str_replace( '%%%HBTN%%%', '<img id="img_btn_0ZZ_'.$DD['aux_id'].'" class="ptz_ctrl_btn" src="/style/png/building/038.png">', $TPL );
  427. $TPL = str_replace('%%%CAM_CTRL_HOME_BTN_BIND%%%', 'document.getElementById(\'img_btn_0ZZ_'.$DD['aux_id'].'\').addEventListener( \'mousedown\', makePtzHome );', $TPL );
  428. } else {
  429. $TPL = str_replace('%%%HBTN%%%', '&nbsp;', $TPL );
  430. $TPL = str_replace('%%%CAM_CTRL_HOME_BTN_BIND%%%', '', $TPL );
  431. };
  432. } else {
  433. $TPL = str_replace('%%%HBTN%%%', '&nbsp;', $TPL );
  434. $TPL = str_replace('%%%CAM_CTRL_HOME_BTN_BIND%%%', '', $TPL );
  435. };
  436. };
  437. $FK = $MODULE_DATA['height'] /$MODULE_DATA['width'];
  438. $W = 244;
  439. $H = $W * $FK;
  440. $TPL = str_replace( '%%%WIDTH%%%', $W, $TPL );
  441. $TPL = str_replace( '%%%HEIGHT%%%', $H, $TPL );
  442. $OUT[]= $STA[3+$idx] . $TPL . $END;
  443. } else break;
  444. $idx++;
  445. };
  446. if( $idx < 2 ){
  447. for( ;$idx<2;$idx++ ){
  448. $T = str_replace( '%%ID%%', 2+$idx , $DUMMY['camera'] );
  449. $OUT[]= $STA[3+$idx] . $T . $END;
  450. };
  451. };
  452. } else {
  453. for( ;$idx<2;$idx++ ){
  454. $T = str_replace( '%%ID%%', 4+$idx , $DUMMY['camera'] );
  455. $OUT[]= $STA[3+$idx] . $T . $END;
  456. };
  457. };
  458. $OUT[]= $STA[3] . $DUMMY['log'] . $END;
  459. $OUT[]= $STA[4] . $DUMMY['map'] . $END;
  460. break;
  461. };
  462. case 3:{
  463. $STA[0]="{ columnWidth: .5, stylse:'padding:10px 0 10px 10px', items:[";
  464. $STA[1]="{ columnWidth: .5, stylse:'padding:10px 0 10px 10px', items:[";
  465. $STA[2]="{ columnWidth: .33, stylse:'padding:10px 0 10px 10px', items:[";
  466. $STA[3]="{ columnWidth: .67, stylse:'padding:10px 0 10px 10px', items:[";
  467. $OUT[]= $STA[0] . $DUMMY['map'] . $END;
  468. $QS = "SELECT * FROM `nodes` WHERE `type`>9 AND `type`< 14 AND `enable`=1";
  469. $R = $DATABASE->Query( $QS );
  470. $idx = 0;
  471. if( count( $R ) ){
  472. foreach( $R as $DD ){
  473. if( $idx < 1 ){
  474. $TFN = 'dash/node_' . $DD['type'] . '.js';
  475. if(!file_exists( $TFN )) continue;
  476. $TPL = file_get_contents( $TFN );
  477. $TPL = inject_labels( $TPL );
  478. $TPL = str_replace('%%%NODEID%%%', ''.$DD['id'] , $TPL );
  479. $TPL = str_replace('%%%NODENAME%%%', ''.urldecode($DD['name']) , $TPL );
  480. $TPL = str_replace('%%%USERID%%%', $UserID, $TPL );
  481. $TPL = str_replace('%%%SESSION%%%', $Session, $TPL );
  482. $QS="SELECT * FROM `nodes` WHERE `id`={$DD['id']}";
  483. $Z=$DATABASE->Query( $QS );
  484. $QS="SELECT * FROM `module_eve` WHERE `id`=1";
  485. $S=$DATABASE->Query( $QS );
  486. $MODULE_DATA = $S[0];
  487. $TPL = str_replace( '%%%NODENAME%%%', urldecode( $Z[0]['name'] ) , $TPL );
  488. //$FU = 'http://' . $_SERVER['SERVER_ADDR'].':' . $MODULE_DATA['web_port'] .'/stream?id='. $Z[0]['aux_parameter'];
  489. $FU = '/video_feed/stream?id='. $Z[0]['aux_parameter'];
  490. $CS[] = '[' . $Z[0]['aux_parameter'] . ',\'[ 120x120] Video\',\''. $FU .'\']';
  491. $TPL = str_replace( '%%%URLS%%%', '[' . implode( ',', $CS ) . ']' , $TPL );
  492. $TPL = str_replace( '%%%SELID%%%', 'value: '. $Z[0]['aux_parameter'] .',', $TPL );
  493. $TPL = str_replace( '%%%SELURL%%%', $FU, $TPL );
  494. $TPL = str_replace( '%%%STREAMID%%%', $DD['aux_parameter'], $TPL );
  495. if( $DD['type'] == 13 || $DD['type'] == 11 ){
  496. $QS = "SELECT `homing_enable` FROM `cameras` WHERE `id`={$DD['aux_id']}";
  497. $JUA = $DATABASE->Query( $QS );
  498. $CAMDATA = $JUA[0];
  499. if( $CAMDATA['homing_enable'] ){
  500. if( $CUser->Data['access'] > 5 ){
  501. $TPL = str_replace( '%%%HBTN%%%', '<img id="img_btn_0ZZ_'.$DD['aux_id'].'" class="ptz_ctrl_btn" src="/style/png/building/038.png">', $TPL );
  502. $TPL = str_replace('%%%CAM_CTRL_HOME_BTN_BIND%%%', 'document.getElementById(\'img_btn_0ZZ_'.$DD['aux_id'].'\').addEventListener( \'mousedown\', makePtzHome );', $TPL );
  503. } else {
  504. $TPL = str_replace('%%%HBTN%%%', '&nbsp;', $TPL );
  505. $TPL = str_replace('%%%CAM_CTRL_HOME_BTN_BIND%%%', '', $TPL );
  506. };
  507. } else {
  508. $TPL = str_replace('%%%HBTN%%%', '&nbsp;', $TPL );
  509. $TPL = str_replace('%%%CAM_CTRL_HOME_BTN_BIND%%%', '', $TPL );
  510. };
  511. };
  512. $FK = $MODULE_DATA['height'] /$MODULE_DATA['width'];
  513. $W = 244;
  514. $H = $W * $FK;
  515. $TPL = str_replace( '%%%WIDTH%%%', $W, $TPL );
  516. $TPL = str_replace( '%%%HEIGHT%%%', $H, $TPL );
  517. $OUT[]= $STA[1+$idx] . $TPL . $END;
  518. } else break;
  519. $idx++;
  520. };
  521. } else {
  522. for( ;$idx<1;$idx++ ){
  523. $T = str_replace( '%%ID%%', 4+$idx , $DUMMY['camera'] );
  524. $OUT[]= $STA[1+$idx] . $T . $END;
  525. };
  526. };
  527. $QS = "SELECT * FROM `nodes` WHERE `type`>0 AND `type`< 10 AND `enable`=1";
  528. $R = $DATABASE->Query( $QS );
  529. $idx = 0;
  530. if( count( $R ) ){
  531. foreach( $R as $DD ){
  532. if( $idx < 1 ){
  533. $TFN = 'dash/node_' . $DD['type'] . '.js';
  534. if(!file_exists( $TFN )) continue;
  535. $TPL = file_get_contents( $TFN );
  536. $TPL = inject_labels( $TPL );
  537. $TPL = str_replace('%%%NODEID%%%', ''.$DD['id'] , $TPL );
  538. $TPL = str_replace('%%%NODENAME%%%', ''.html_entity_decode( $DD['name'] ) , $TPL );
  539. $TPL = str_replace('%%%USERID%%%', $UserID, $TPL );
  540. $TPL = str_replace('%%%SESSION%%%', $Session, $TPL );
  541. $OUT[]= $STA[2+$idx] . $TPL . $END;
  542. } else break;
  543. $idx++;
  544. };
  545. } else {
  546. for( ;$idx<1;$idx++ ){
  547. $OUT[]= $STA[2+$idx] . $DUMMY['sensor'] . $END;
  548. };
  549. };
  550. $OUT[]= $STA[3] . $DUMMY['log'] . $END;
  551. break;
  552. };
  553. case 4:
  554. case 5:
  555. default:
  556. };
  557. $Data = '[' . implode( ',' , $OUT ) . ']';
  558. } else {
  559. $Data = '[{columnWidth: 1, items:{html:"NO SYSTEM PROPS"}} ]';
  560. };
  561. };
  562. if( $Data != '' ) {
  563. echo $Data;
  564. } else {
  565. echo '[]';
  566. };
  567. ?>