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.

817 lines
24 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <?php
  2. require_once('../ajax_asm.php');
  3. function makeEthernetInfo( $RessourceID ){
  4. global $DATABASE, $CUser, $Labels;
  5. $TTL = $Labels->GetLabel('_RES_ETHERNET_DESC_');
  6. $QS="SELECT * FROM `network_interfaces` WHERE `id`={$RessourceID}";
  7. $II = $DATABASE->Query( $QS );
  8. $CI = $II[0];
  9. switch( $CI['mode'] ){
  10. case 0: $MS = $Labels->GetLabel( 'MODE_DISABLED' ); break;
  11. case 1: $MS = $Labels->GetLabel( 'MODE_ETHDYNAMIC' ); break;
  12. case 2: $MS = $Labels->GetLabel( 'MODE_ETHSTATIC' ); break;
  13. case 3: $MS = $Labels->GetLabel( 'MODE_ETHROUTER' ); break;
  14. };
  15. $QS="SELECT * FROM `networks` WHERE `nif_id`={$RessourceID}";
  16. $II = $DATABASE->Query( $QS );
  17. $NetInfo ='';
  18. $IP = array();
  19. foreach($II as $I){
  20. if( $I['type'] == 0 ){
  21. $IP = $I;
  22. $NetInfo .= '<br/>Address IPv4: '.$I['address'].'<br/>Net Mask: '.$I['mask'];
  23. } else {
  24. $NetInfo .= '<br/>Address IPv6: '.$I['address'].'<br/>Net Mask: '.$I['mask'];
  25. };
  26. };
  27. if( count( $IP ) ){
  28. $TArr = explode( '.', $IP['address'] );
  29. $Base = '';
  30. } else {
  31. };
  32. $R_nfo = 'Mode: '.$MS.'<br/>MAC: '.$CI['mac'] . $NetInfo;
  33. $R_image = 'Ethernet-Cable-icon.png';
  34. $POPUS = 123;
  35. $A_EDIT = ( $CI['mode'] < 2 )?'true':'false';
  36. $TPL = <<<END_TEMPLATE
  37. {
  38. xtype: 'panel',
  39. border: false,
  40. frame: false,
  41. layout:'table',
  42. //autoHeight:true,
  43. autoWidth:true,
  44. defaults: {
  45. bodyStyle:'padding:0px'
  46. },
  47. layoutConfig: {
  48. tableAttrs: {
  49. style: {
  50. width: '100%'
  51. }
  52. },
  53. columns: 4
  54. },
  55. items: [{
  56. border: false,
  57. width: 10
  58. },{
  59. border: false,
  60. width: 270,
  61. html: '<img width="256px" id="res_info_image" src="/style/assets/{$R_image}">',
  62. },{
  63. xtype: 'panel',
  64. border: false,
  65. frame: false,
  66. width: 420,
  67. height: 320,
  68. items:[{
  69. frame: false,
  70. border: false,
  71. html: '<p style="font-size: 16px;">{$TTL}</p>'
  72. },{
  73. xtype: 'tabpanel',
  74. id: 'ifo_tab',
  75. activeTab: 0,
  76. items:[{
  77. title: 'Info',
  78. html: '{$R_nfo}'
  79. },{
  80. title: 'Settings',
  81. layout: 'form',
  82. labelAlign: 'right',
  83. labelWidth: 150,
  84. items:[{
  85. xtype: 'combo',
  86. fieldLabel: 'Address Allocation',
  87. lazyRender: true,
  88. id: 'aa_type',
  89. mode: 'local',
  90. forceSelection: true,
  91. triggerAction: 'all',
  92. editable: false,
  93. disableKeyFilter: true,
  94. listeners:{
  95. change: function(t,n,o){
  96. if( n < 2 ){
  97. Ext.getCmp('aa_adr').disable();
  98. } else {
  99. Ext.getCmp('aa_adr').enable();
  100. };
  101. }
  102. },
  103. store: new Ext.data.ArrayStore({
  104. fields: ['aa_t','aa_txt'],
  105. data: [
  106. [0,'Disabled'],
  107. [1,'Dynamic (DHCP)'],
  108. [2,'Static'],
  109. [3,'Router'],
  110. ]
  111. }),
  112. value: {$CI['mode']},
  113. valueField: 'aa_t',
  114. displayField: 'aa_txt'
  115. },{
  116. xtype: 'textfield',
  117. id: 'aa_adr',
  118. fieldLabel: 'Address',
  119. value: '{$IP['address']}',
  120. disabled: {$A_EDIT}
  121. },{
  122. xtype: 'textfield',
  123. id: 'aa_mask',
  124. fieldLabel: 'Net Mask',
  125. value: '{$IP['mask']}',
  126. disabled: {$A_EDIT}
  127. },{
  128. xtype: 'textfield',
  129. id: 'aa_gtw',
  130. fieldLabel: 'Gateway',
  131. value: '{$IP['gateway']}',
  132. disabled: true
  133. },{
  134. xtype: 'textfield',
  135. id: 'aa_bcast',
  136. fieldLabel: 'Broadcast',
  137. value: '{$IP['broadcast']}',
  138. disabled: true
  139. },{
  140. xtype: 'spacer',
  141. height: 100
  142. },{
  143. xtype: 'button',
  144. width: '100%',
  145. text: 'Apply Changes'
  146. },{
  147. xtype: 'spacer',
  148. height: 20
  149. }]
  150. },{
  151. title: 'Router',
  152. layout: 'form',
  153. labelAlign: 'right',
  154. labelWidth: 150,
  155. items:[{
  156. xtype: 'checkbox',
  157. fieldLabel: 'Act as DHCP Server',
  158. },{
  159. xtype: 'textfield',
  160. fieldLabel: 'Start IP Range'
  161. },{
  162. xtype: 'textfield',
  163. fieldLabel: 'End IP Range'
  164. }]
  165. }]
  166. }]
  167. },{
  168. border: false,
  169. width: 10
  170. }],
  171. koko: {$POPUS}
  172. }
  173. END_TEMPLATE;
  174. return $TPL;
  175. };
  176. if( $CUser->Data['id'] > 1 ){
  177. $EID = intval( $_POST['RID'] );
  178. $QS = "SELECT * FROM resources WHERE id = {$EID}";
  179. $Result = $DATABASE->Query( $QS, false );
  180. if( count( $Result ) ){
  181. $CR = $Result[0];
  182. switch( $CR['type'] ){
  183. case 1: //https://bufferwall.com/posts/330881001ji1a/
  184. $QS = "SELECT * FROM uart_settings WHERE id={$CR['aux_id']}";
  185. $Result = $DATABASE->Query( $QS );
  186. $Z = $Result[0];
  187. $R_dev = $CR['device'];
  188. $R_nfo = 'Speed: ' . $Z['speed'] . ', Bits: ' . $Z['bit'] . ', Parity: ' . $Z['parity'] . ', Stop Bit: '. $Z['stop_bit'];
  189. if( $Z['type'] == 1 ){
  190. $R_image = 'unnamed.png';
  191. $R_name = $Labels->GetLabel('_RES_HW_UART_DESC_');
  192. $TPL =<<<EFUFU
  193. {
  194. xtype: 'form',
  195. labelAlign: 'right',
  196. items:[{
  197. border: false,
  198. frame: false,
  199. xtype: 'panel',
  200. html: '<table width="100%" border=0 class="setEd_infoPanel" id="UART"><tr><td width="65px"><img width="64px" src="/style/assets/unnamed.png"></td><td valign="middle">%%%NAME%%%</td></tr><tr><td colspan=2>%%%INFO%%%</td></tr></table><br/>'
  201. },{
  202. id: 'uart_spd',
  203. xtype: 'combo',
  204. fieldLabel: '%%%SPD%%%',
  205. lazyRender: true,
  206. mode: 'local',
  207. forceSelection: true,
  208. triggerAction: 'all',
  209. editable: false,
  210. disableKeyFilter: true,
  211. store: new Ext.data.ArrayStore({
  212. fields: ['speed'],
  213. data: [[1200],[2400],[9600],[19200],[38400],[57600],[115200]]
  214. }),
  215. valueField: 'speed',
  216. displayField: 'speed',
  217. listeners:{
  218. select: function(){
  219. }
  220. },
  221. value: %%%SPD_VAL%%%
  222. },{
  223. xtype: 'combo',
  224. fieldLabel: 'Bits',
  225. id: 'ued_bit',
  226. lazyRender:true,
  227. mode: 'local',
  228. forceSelection: true,
  229. triggerAction: 'all',
  230. editable: false,
  231. disableKeyFilter: true,
  232. store: new Ext.data.ArrayStore({
  233. fields: ['bits'],
  234. data: [[5],[6],[7],[8],[9]]
  235. }),
  236. value: %%%BITS_VAL%%%,
  237. valueField: 'bits',
  238. displayField: 'bits'
  239. },{
  240. xtype: 'combo',
  241. fieldLabel: 'Stop Bit',
  242. lazyRender:true,
  243. id: 'ued_stops',
  244. mode: 'local',
  245. forceSelection: true,
  246. triggerAction: 'all',
  247. editable: false,
  248. disableKeyFilter: true,
  249. store: new Ext.data.ArrayStore({
  250. fields: ['stops'],
  251. data: [[1],[1.5],[2]]
  252. }),
  253. value: %%%STOPS_VAL%%%,
  254. valueField: 'stops',
  255. displayField: 'stops'
  256. },{
  257. xtype: 'combo',
  258. fieldLabel: 'Parity',
  259. lazyRender:true,
  260. id: 'ued_parity',
  261. mode: 'local',
  262. forceSelection: true,
  263. triggerAction: 'all',
  264. editable: false,
  265. disableKeyFilter: true,
  266. store: new Ext.data.ArrayStore({
  267. fields: ['par_val','parity'],
  268. data: [['O','Odd'], ['E','Even'],['N','None']]
  269. }),
  270. value: '%%%PARITY_VAL%%%',
  271. valueField: 'par_val',
  272. displayField: 'parity'
  273. },{
  274. xtype: 'spacer',
  275. height: 10
  276. },{
  277. xtype: 'button',
  278. id: 'ua_apply_btn',
  279. disabled: true,
  280. width: '100%',
  281. text: 'Apply Changes',
  282. handler: function(){
  283. var UART_SPD = Ext.getCmp('uart_spd').getValue();
  284. var UART_BIT = Ext.getCmp('ued_bit').getValue();
  285. var UART_STP = Ext.getCmp('ued_stops').getValue();
  286. var UART_PAR = Ext.getCmp('ued_parity').getValue();
  287. Ext.Ajax.request({
  288. url: '/lib/controller/updateResource.php',
  289. params: {
  290. RID: %%%%RES_ID%%%,
  291. UID: %%%USER_ID%%%,
  292. SID: '%%%SESSION%%%',
  293. USPD: UART_SPD,
  294. UBIT: UART_BIT,
  295. USTP: UART_STP,
  296. UPAR: UART_PAR
  297. },
  298. success: function( response, opts ){
  299. data = Ext.decode(response.responseText);
  300. if( data.status ){
  301. cleanupChangeNotifier();
  302. editResource( %%%%RES_ID%%% );
  303. } else {
  304. Ext.Msg.show({
  305. title:'Error',
  306. msg: data.msg,
  307. buttons: Ext.Msg.OK,
  308. icon: Ext.MessageBox.ERROR,
  309. fn: function(btn, text){
  310. cleanupChangeNotifier();
  311. editResource( %%%%RES_ID%%% );
  312. }
  313. });
  314. };
  315. //doRefresh();
  316. },
  317. failure: failureAJAXFunction
  318. });
  319. }
  320. }]
  321. }
  322. EFUFU;
  323. } else {
  324. $R_image = 'unnamed_n.png';
  325. $R_name = $Labels->GetLabel('_RES_EZ_UART_DESC_');
  326. $QS = "SELECT * FROM `nodes` WHERE `id`={$CR['node_id']}";
  327. $ZZ = $DATABASE->Query( $QS );
  328. $CN = $ZZ[0];
  329. $TPL =<<<EFUFU
  330. {
  331. xtype: 'form',
  332. labelAlign: 'right',
  333. items:[{
  334. border: false,
  335. frame: false,
  336. xtype: 'panel',
  337. html: '<table width="100%" border=0 class="setEd_infoPanel" id="UART"><tr><td width="65px"><img width="64px" src="/style/assets/unnamed_n.png"></td><td valign="middle">%%%NAME%%%</td></tr><tr><td colspan=2>%%%INFO%%%</td></tr></table><br/>'
  338. },{
  339. xtype: 'combo',
  340. fieldLabel: 'Status',
  341. lazyRender:true,
  342. id: 'ued_ena',
  343. mode: 'local',
  344. forceSelection: true,
  345. triggerAction: 'all',
  346. editable: false,
  347. disableKeyFilter: true,
  348. store: new Ext.data.ArrayStore({
  349. fields: ['en_val','en_text'],
  350. data: [[0,'Disabled'], [1,'Enabled']]
  351. }),
  352. listeners:{
  353. select: function( c, r, n ){
  354. doResourceOperation({$EID}, 2, 9, n );
  355. }
  356. },
  357. value: %%%STATUS_VAL%%%,
  358. valueField: 'en_val',
  359. displayField: 'en_text'
  360. },{
  361. xtype: 'textfield',
  362. id: 'ued_ip',
  363. fieldLabel: 'IP Address',
  364. value: '{$Z['path']}',
  365. listeners:{
  366. change: function( t, n, o ){
  367. if( n!=o && n!='' ){
  368. doResourceOperation({$EID}, 2, 6, n );
  369. };
  370. }
  371. }
  372. },{
  373. xtype: 'numberfield',
  374. id: 'ued_port',
  375. fieldLabel: 'TCP Port',
  376. value: '{$Z['port']}',
  377. listeners:{
  378. change: function( t, n, o ){
  379. if( n!=o && n!='' ){
  380. doResourceOperation({$EID}, 2, 5, n );
  381. };
  382. }
  383. }
  384. },{
  385. id: 'uart_spd',
  386. xtype: 'combo',
  387. fieldLabel: '%%%SPD%%%',
  388. lazyRender: true,
  389. mode: 'local',
  390. forceSelection: true,
  391. triggerAction: 'all',
  392. editable: false,
  393. disableKeyFilter: true,
  394. store: new Ext.data.ArrayStore({
  395. fields: ['speed'],
  396. data: [[1200],[2400],[9600],[19200],[38400],[57600],[115200]]
  397. }),
  398. valueField: 'speed',
  399. displayField: 'speed',
  400. listeners:{
  401. select: function( c, r, n ){
  402. doResourceOperation({$EID}, 2, 1, n );
  403. }
  404. },
  405. value: %%%SPD_VAL%%%
  406. },{
  407. xtype: 'combo',
  408. fieldLabel: 'Bits',
  409. id: 'ued_bit',
  410. lazyRender:true,
  411. mode: 'local',
  412. forceSelection: true,
  413. triggerAction: 'all',
  414. editable: false,
  415. disableKeyFilter: true,
  416. store: new Ext.data.ArrayStore({
  417. fields: ['bits'],
  418. data: [[5],[6],[7],[8],[9]]
  419. }),
  420. listeners:{
  421. select: function( c, r, n ){
  422. doResourceOperation({$EID}, 2, 2, n );
  423. }
  424. },
  425. value: %%%BITS_VAL%%%,
  426. valueField: 'bits',
  427. displayField: 'bits'
  428. },{
  429. xtype: 'combo',
  430. fieldLabel: 'Stop Bit',
  431. lazyRender:true,
  432. id: 'ued_stops',
  433. mode: 'local',
  434. forceSelection: true,
  435. triggerAction: 'all',
  436. editable: false,
  437. disableKeyFilter: true,
  438. store: new Ext.data.ArrayStore({
  439. fields: ['stops'],
  440. data: [[1],[1.5],[2]]
  441. }),
  442. listeners:{
  443. select: function( c, r, n ){
  444. doResourceOperation({$EID}, 2, 3, n );
  445. }
  446. },
  447. value: %%%STOPS_VAL%%%,
  448. valueField: 'stops',
  449. displayField: 'stops'
  450. },{
  451. xtype: 'combo',
  452. fieldLabel: 'Parity',
  453. lazyRender:true,
  454. id: 'ued_parity',
  455. mode: 'local',
  456. forceSelection: true,
  457. triggerAction: 'all',
  458. editable: false,
  459. disableKeyFilter: true,
  460. store: new Ext.data.ArrayStore({
  461. fields: ['par_val','parity'],
  462. data: [['O','Odd'], ['E','Even'],['N','None']]
  463. }),
  464. listeners:{
  465. select: function( c, r, n ){
  466. doResourceOperation({$EID}, 2, 4, n );
  467. }
  468. },
  469. value: '%%%PARITY_VAL%%%',
  470. valueField: 'par_val',
  471. displayField: 'parity'
  472. },{
  473. xtype: 'panel',
  474. frame: false,
  475. border: false,
  476. html:'<center><a href="http://{$Z['path']}/" target="_blank">Link to a Control page</a></center>'
  477. }]
  478. }
  479. EFUFU;
  480. };
  481. $TPL = str_ireplace( '%%%STATUS_VAL%%%', $CN['enable'], $TPL );
  482. $TPL = str_ireplace( '%%%NAME%%%', $R_name, $TPL );
  483. $TPL = str_ireplace( '%%%INFO%%%', $R_dev, $TPL );
  484. $TPL = str_ireplace( '%%%SPD%%%', $Labels->GetLabel('UART_COM_SPEED'), $TPL );
  485. $TPL = str_ireplace( '%%%SPD_VAL%%%', intval($Z['speed']), $TPL );
  486. $TPL = str_ireplace( '%%%BITS_VAL%%%',$Z['bit'], $TPL );
  487. $TPL = str_ireplace( '%%%PARITY_VAL%%%',$Z['parity'], $TPL );
  488. $TPL = str_ireplace( '%%%STOPS_VAL%%%',$Z['stop_bit'], $TPL );
  489. $TPL = str_ireplace( '%%%%RES_ID%%%',$EID, $TPL );
  490. $TPL = str_ireplace( '%%%USER_ID%%%',$UserID, $TPL );
  491. $TPL = str_ireplace( '%%%SESSION%%%',$Session, $TPL );
  492. echo $TPL;
  493. break;
  494. case 31: //Video In
  495. $R_name = 'Video Frame Grabber';
  496. $R_dev = $CR['device'];
  497. $STREAM = $CR['aux_id'];
  498. //$QS="SELECT * FROM `media_streams` WHERE `id`={$CR['aux_id']}";
  499. //$II = $DATABASE->Query( $QS );
  500. //$CI = $II[0];
  501. $R_nfo = 'Frame Size: '.$CI['img_width'].'x'.$CI['img_height'].'<br/>Driver: '.$CI['mrl_proto'];
  502. $R_image = 'RCA-Connector-Plug-icon.png';
  503. $QS = "SELECT * FROM `media_streams` WHERE `id`={$STREAM}";
  504. $Result = $DATABASE->Query( $QS, false );
  505. if( count( $Result ) ){
  506. $CS = $Result[0];
  507. $R_nfo = 'Frame Size: '.$CS['img_width'].'x'.$CS['img_height'].'<br/>Driver: '.$CS['mrl_proto'];
  508. $R_image = 'RCA-Connector-Plug-icon.png';
  509. if( $CS['source_type'] == 'A' ){
  510. $Sizes = array();
  511. $Formats = array();
  512. //If Source not assigned or not active
  513. if( $CS['source_id'] == 0 || $CR['active'] == 0 ){
  514. $CMD="v4l2-ctl -d {$CS['mrl']} --list-formats-ext";
  515. $Data = `$CMD`;
  516. $TArr = explode( "\n", $Data );
  517. foreach( $TArr as $R ){
  518. $CL = trim( $R );
  519. if( stripos($CL,']:')!== false ){
  520. $ID = intval( substr( $CL, 1 ) );
  521. $FCC = substr( $CL, stripos( $CL, ':' ) + 3, 4 );
  522. $DSC = substr( $CL, stripos( $CL, ':' ) + 9 );
  523. $Formats[] = array('id'=>$ID, '4cc'=>$FCC, 'desc'=>$DSC );
  524. };
  525. if( stripos($CL,'Size:')!== false ){
  526. $TBarr=explode( ' ', $CL );
  527. if( intval( $TBarr[1] ) ){
  528. $ZArr = explode( 'x', $TBarr[1] );
  529. $Sizes[$TBarr[1]] = array( 'width'=>$ZArr[0], 'height'=>$ZArr[1], 'title'=>$TBarr[1] );
  530. } else {
  531. $ZArr = explode( 'x', $TBarr[2] );
  532. $Sizes[$TBarr[2]] = array( 'width'=>$ZArr[0], 'height'=>$ZArr[1], 'title'=>$TBarr[2] );
  533. };
  534. };
  535. };
  536. };
  537. $CMD="v4l2-ctl -d {$CS['mrl']} --list-ctrls-menu";
  538. $Data = `$CMD`;
  539. $TArr = explode( "\n", $Data );
  540. $Controls = array();
  541. $MFlag = false;
  542. $MID = 0;
  543. $id = 0;
  544. foreach( $TArr as $R ){
  545. $CL = trim( $R );
  546. if( stripos( $CL, ':' ) !== false ){
  547. $ctrl = array();
  548. $RR = explode( ':', $CL );
  549. $TArr=explode( ' ', $CL );
  550. if( stripos( $CL, 'int' )!== false ){
  551. $ctrl['type'] = 'slider';
  552. $ctrl['name'] = trim( $TArr[0] );
  553. $ctrl['name_cod'] = md5( $ctrl['name'] );
  554. $ctrl['id'] = hexdec( $TArr[1] );
  555. $TArr=explode( ' ', $RR[1] );
  556. $TBrr = explode( '=', $TArr[1] );
  557. $ctrl['min'] = intval( $TBrr[1] );
  558. $TBrr = explode( '=', $TArr[2] );
  559. $ctrl['max'] = intval( $TBrr[1] );
  560. $TBrr = explode( '=', $TArr[3] );
  561. $ctrl['step'] = intval( $TBrr[1] );
  562. $TBrr = explode( '=', $TArr[5] );
  563. $ctrl['value'] = intval( $TBrr[1] );
  564. $MFlag = false;
  565. $Controls[$id] = $ctrl;
  566. $id++;
  567. } else if( stripos( $CL, 'bool' )!== false ){
  568. $ctrl['type'] = 'checkbox';
  569. $ctrl['name'] = trim( $TArr[0] );
  570. $ctrl['name_cod'] = md5( $ctrl['name'] );
  571. $ctrl['id'] = hexdec( $TArr[1] );
  572. $TArr=explode( ' ', $RR[1] );
  573. $TBrr = explode( '=', $TArr[2] );
  574. $ctrl['value'] = intval( $TBrr[1] );
  575. $MFlag = false;
  576. $Controls[$id] = $ctrl;
  577. $id++;
  578. } else if( stripos( $CL, 'menu' )!== false ){
  579. $ctrl['type'] = 'combo';
  580. $ctrl['name'] = trim( $TArr[0] );
  581. $ctrl['name_cod'] = md5( $ctrl['name'] );
  582. $ctrl['id'] = hexdec( $TArr[1] );
  583. $TArr=explode( ' ', $RR[1] );
  584. $TBrr = explode( '=', $TArr[4] );
  585. $ctrl['value'] = intval( $TBrr[1] );
  586. $MFlag = true;
  587. $MID = $id;
  588. $Controls[$id] = $ctrl;
  589. $id++;
  590. } else {
  591. if( $MFlag ){
  592. $ZV = explode( ':', $CL );
  593. $cmi= array();
  594. $cmi['id']=intval( $ZV[0] );
  595. $cmi['text']=trim( $ZV[1] );
  596. $Controls[$MID]['data'][]=$cmi;
  597. };
  598. };
  599. };
  600. };
  601. $CCC = 0;
  602. $OUT = array();
  603. if( count( $Formats ) ){
  604. $ll = "{
  605. xtype: 'combo',
  606. fieldLabel: '". $Labels->GetLabel('_FRAME_FORMAT_') ."',
  607. lazyRender: true,
  608. id: 'frmt_id',
  609. name: 'frame_format',
  610. mode: 'local',
  611. forceSelection: true, triggerAction: 'all', editable: false, disableKeyFilter: true,
  612. listeners:{ change: function(t,n,o){ changeASS( {$STREAM }, 'frmt_id'); }},
  613. store: new Ext.data.ArrayStore({
  614. fields: ['fmt','fmt_txt'],
  615. data: [";
  616. $cl = array();
  617. foreach( $Formats as $F ){
  618. $cl[]="[{$F['id']},\"{$F['desc']}\"]";
  619. };
  620. $ll .= implode( ',', $cl );
  621. $ll .="]
  622. }),
  623. valueField: 'fmt',
  624. displayField: 'fmt_txt'
  625. }";
  626. $OUT[$CCC] = $ll;
  627. $CCC++;
  628. };
  629. if( count( $Sizes ) ){
  630. $ll = "{
  631. xtype: 'combo',
  632. fieldLabel: '". $Labels->GetLabel('_FRAME_SIZE_') ."',
  633. lazyRender: true,
  634. id: 'sizes_id',
  635. name: 'frame_size',
  636. mode: 'local',
  637. forceSelection: true, triggerAction: 'all', editable: false, disableKeyFilter: true,
  638. listeners:{ change: function(t,n,o){ changeASS( {$STREAM }, 'sizes_id'); }},
  639. store: new Ext.data.ArrayStore({
  640. fields: ['size','size_txt'],
  641. data: [";
  642. $cl = array();
  643. $id = 0;
  644. $csid = 0;
  645. foreach( $Sizes as $Key=>$Val ){
  646. if( $Val['width'] == $CS['img_width'] && $Val['height'] == $CS['img_height'] ) $csid = $Key;//$id;
  647. //$cl[]="[{$id},\"{$Key}\"]";
  648. $cl[]="[\"{$Key}\",\"{$Key}\"]";
  649. $id++;
  650. };
  651. $ll .= implode( ',', $cl );
  652. $ll .="]
  653. }),
  654. valueField: 'size',
  655. displayField: 'size_txt',
  656. value: '{$csid}'
  657. }";
  658. $OUT[$CCC] = $ll;
  659. $CCC++;
  660. };
  661. //print_r( $Controls );
  662. if( count( $Controls )){
  663. foreach( $Controls as $CC ){
  664. $ll = "{ xtype: '{$CC['type']}', id: '{$CC['id']}', name: '{$CC['name']}', fieldLabel: '".$Labels->GetLabel($CC['name_cod'])."', value: {$CC['value']}, listeners:{ change: function(t,n,o){ changeASS( {$STREAM }, '{$CC['id']}' ); } }, ";
  665. switch( $CC['type'] ){
  666. case 'slider':{
  667. $ll .= "minValue: {$CC['min']}, maxValue: {$CC['max']}, width: 235 }";
  668. break;
  669. };
  670. case 'checkbox':{
  671. if( $CC['value'] == 1 ){
  672. $ll .= "checked: true }";
  673. } else {
  674. $ll .= "checked: false }";
  675. };
  676. break;
  677. };
  678. case 'combo':{
  679. $ll .= "lazyRender: true, mode: 'local', forceSelection: true, triggerAction: 'all', editable: false, disableKeyFilter: true, store: new Ext.data.ArrayStore({
  680. fields: ['{$CC['id']}_id','{$CC['id']}_txt'],
  681. data: [";
  682. $cl = array();
  683. foreach( $CC['data'] as $D ) $cl[]="[{$D['id']},\"{$D['text']}\"]";
  684. $ll .= implode(',', $cl );
  685. $ll .="]
  686. }),
  687. valueField: '{$CC['id']}_id',
  688. displayField: '{$CC['id']}_txt'
  689. }";
  690. break;
  691. };
  692. };
  693. $OUT[$CCC] = $ll;
  694. $CCC++;
  695. };
  696. }; //https://www.waveshare.com/wiki/SIM7600E-H_4G_HAT
  697. $TOPLER=<<<JUJUAS
  698. {
  699. border: false,
  700. frame: false,
  701. xtype: 'panel',
  702. html: '<table width="100%" border=0 class="setEd_infoPanel" id="GRABBER"><tr><td width="65px"><img width="64px" src="/style/assets/cam_analog_256.png"></td><td valign="middle">%%%NAME%%%</td></tr><tr><td colspan=2>%%%INFO%%%</td></tr></table><br/>'
  703. },
  704. JUJUAS;
  705. $TOPLER = str_ireplace( '%%%NAME%%%', $R_name . '['. $R_dev . ']', $TOPLER );
  706. $TOPLER = str_ireplace( '%%%INFO%%%', $R_nfo, $TOPLER );
  707. if( count( $OUT ) ){
  708. $CCA = $TOPLER . implode( ',', $OUT );
  709. } else {
  710. $CCA = $TOPLER . '{}';
  711. };
  712. echo "{ xtype: 'form', id:'an_str_edit', frame: false, autoScroll: true, border: false, layout: 'form', labelAlign: 'right', labelWidth: 150, items: [". $CCA ."] }";
  713. } else {
  714. echo "{ xtype: 'panel', html: '<center>Incorrect Stream</center>'}";
  715. };
  716. } else {
  717. echo "{ xtype: 'panel', html: '<center>Incorrect Stream</center>'}";
  718. };
  719. break;
  720. case 101: // Ethernet
  721. $R_name = $Labels->GetLabel('_RES_ETHERNET_DESC_');
  722. $R_dev = $CR['device'];
  723. $QS="SELECT * FROM `network_interfaces` WHERE `id`={$CR['aux_id']}";
  724. echo makeEthernetInfo( $CR['aux_id'] );
  725. exit;
  726. $II = $DATABASE->Query( $QS );
  727. $CI = $II[0];
  728. switch( $CI['mode'] ){
  729. case 0: $MS = $Labels->GetLabel( 'MODE_DISABLED' ); break;
  730. case 1: $MS = $Labels->GetLabel( 'MODE_ETHDYNAMIC' ); break;
  731. case 2: $MS = $Labels->GetLabel( 'MODE_ETHSTATIC' ); break;
  732. case 1: $MS = $Labels->GetLabel( 'MODE_ETHROUTER' ); break;
  733. };
  734. $QS="SELECT * FROM `networks` WHERE `nif_id`={$CR['aux_id']}";
  735. $II = $DATABASE->Query( $QS );
  736. $NetInfo ='';
  737. foreach($II as $I){
  738. if( $I['type'] == 0 ){
  739. $NetInfo .= '<br/>Address IPv4: '.$I['address'].'<br/>Net Mask: '.$I['mask'];
  740. } else {
  741. $NetInfo .= '<br/>Address IPv6: '.$I['address'].'<br/>Net Mask: '.$I['mask'];
  742. };
  743. };
  744. $R_nfo = 'Mode: '.$MS.'<br/>MAC: '.$CI['mac'] . $NetInfo;
  745. $R_image = 'Ethernet-Cable-icon.png';
  746. break;
  747. case 102: // WiFi
  748. $R_name = $Labels->GetLabel('_RES_WIFI_DESC_');
  749. $R_dev = $CR['device'];
  750. $QS="SELECT * FROM `network_interfaces` WHERE `id`={$CR['aux_id']}";
  751. $II = $DATABASE->Query( $QS );
  752. $CI = $II[0];
  753. switch( $CI['mode'] ){
  754. case 0: $MS = $Labels->GetLabel( 'MODE_DISABLED' ); break;
  755. case 1: $MS = $Labels->GetLabel( 'MODE_ETHDYNAMIC' ); break;
  756. case 2: $MS = $Labels->GetLabel( 'MODE_ETHSTATIC' ); break;
  757. case 3: $MS = $Labels->GetLabel( 'MODE_ACCESS_POINT' ); break;
  758. };
  759. $QS="SELECT * FROM `networks` WHERE `nif_id`={$CR['aux_id']}";
  760. $II = $DATABASE->Query( $QS );
  761. $NetInfo ='';
  762. foreach($II as $I){
  763. if( $I['type'] == 0 ){
  764. $NetInfo .= '<br/>Address IPv4: '.$I['address'].'<br/>Net Mask: '.$I['mask'];
  765. } else {
  766. $NetInfo .= '<br/>Address IPv6: '.$I['address'].'<br/>Net Mask: '.$I['mask'];
  767. };
  768. };
  769. $R_nfo = 'Mode: '.$MS.'<br/>MAC: '.$CI['mac'] . $NetInfo;
  770. $R_image = 'wifi-modem-Vista-icon.png';
  771. break;
  772. case 105:
  773. $R_name = $Labels->GetLabel('_RES_WAN_DESC_');
  774. $R_dev = $CR['device'];
  775. $QS="SELECT * FROM `network_interfaces` WHERE `id`={$CR['aux_id']}";
  776. $II = $DATABASE->Query( $QS );
  777. $CI = $II[0];
  778. switch( $CI['mode'] ){
  779. case 0: $MS = $Labels->GetLabel( 'MODE_DISABLED' ); break;
  780. case 1: $MS = $Labels->GetLabel( 'MODE_ETHDYNAMIC' ); break;
  781. case 2: $MS = $Labels->GetLabel( 'MODE_ETHSTATIC' ); break;
  782. case 3: $MS = $Labels->GetLabel( 'MODE_ACCESS_POINT' ); break;
  783. };
  784. $QS="SELECT * FROM `networks` WHERE `nif_id`={$CR['aux_id']}";
  785. $II = $DATABASE->Query( $QS );
  786. $NetInfo ='';
  787. foreach($II as $I){
  788. if( $I['type'] == 0 ){
  789. $NetInfo .= '<br/>Address IPv4: '.$I['address'].'<br/>Net Mask: '.$I['mask'];
  790. } else {
  791. $NetInfo .= '<br/>Address IPv6: '.$I['address'].'<br/>Net Mask: '.$I['mask'];
  792. };
  793. };
  794. $R_nfo = 'Mode: '.$MS.'<br/>MAC: '.$CI['mac'] . $NetInfo;
  795. $R_image = 'wifi-modem-Vista-icon.png';
  796. break;
  797. };
  798. } else {
  799. echo '{ xtype: \'panel\', html: \'Node '.$_POST['NODE'].' Loadded\'}';
  800. };
  801. } else {
  802. header('location: /');
  803. };
  804. ?>