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.

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