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.

823 lines
24 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  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( c, r, n ){
  219. doResourceOperation({$EID}, 2, 1, n );
  220. }
  221. },
  222. value: %%%SPD_VAL%%%
  223. },{
  224. xtype: 'combo',
  225. fieldLabel: 'Bits',
  226. id: 'ued_bit',
  227. lazyRender:true,
  228. mode: 'local',
  229. forceSelection: true,
  230. triggerAction: 'all',
  231. editable: false,
  232. disableKeyFilter: true,
  233. store: new Ext.data.ArrayStore({
  234. fields: ['bits'],
  235. data: [[5],[6],[7],[8],[9]]
  236. }),
  237. value: %%%BITS_VAL%%%,
  238. valueField: 'bits',
  239. displayField: 'bits'
  240. },{
  241. xtype: 'combo',
  242. fieldLabel: 'Stop Bit',
  243. lazyRender:true,
  244. id: 'ued_stops',
  245. mode: 'local',
  246. forceSelection: true,
  247. triggerAction: 'all',
  248. editable: false,
  249. disableKeyFilter: true,
  250. store: new Ext.data.ArrayStore({
  251. fields: ['stops'],
  252. data: [[1],[1.5],[2]]
  253. }),
  254. value: %%%STOPS_VAL%%%,
  255. valueField: 'stops',
  256. displayField: 'stops'
  257. },{
  258. xtype: 'combo',
  259. fieldLabel: 'Parity',
  260. lazyRender:true,
  261. id: 'ued_parity',
  262. mode: 'local',
  263. forceSelection: true,
  264. triggerAction: 'all',
  265. editable: false,
  266. disableKeyFilter: true,
  267. store: new Ext.data.ArrayStore({
  268. fields: ['par_val','parity'],
  269. data: [['O','Odd'], ['E','Even'],['N','None']]
  270. }),
  271. value: '%%%PARITY_VAL%%%',
  272. valueField: 'par_val',
  273. displayField: 'parity'
  274. },{
  275. xtype: 'spacer',
  276. height: 10
  277. },{
  278. xtype: 'button',
  279. id: 'ua_apply_btn',
  280. disabled: true,
  281. width: '100%',
  282. text: 'Apply Changes',
  283. handler: function(){
  284. var UART_SPD = Ext.getCmp('uart_spd').getValue();
  285. var UART_BIT = Ext.getCmp('ued_bit').getValue();
  286. var UART_STP = Ext.getCmp('ued_stops').getValue();
  287. var UART_PAR = Ext.getCmp('ued_parity').getValue();
  288. Ext.Ajax.request({
  289. url: '/lib/controller/updateResource.php',
  290. params: {
  291. RID: %%%%RES_ID%%%,
  292. UID: %%%USER_ID%%%,
  293. SID: '%%%SESSION%%%',
  294. USPD: UART_SPD,
  295. UBIT: UART_BIT,
  296. USTP: UART_STP,
  297. UPAR: UART_PAR
  298. },
  299. success: function( response, opts ){
  300. data = Ext.decode(response.responseText);
  301. if( data.status ){
  302. cleanupChangeNotifier();
  303. editResource( %%%%RES_ID%%% );
  304. } else {
  305. Ext.Msg.show({
  306. title:'Error',
  307. msg: data.msg,
  308. buttons: Ext.Msg.OK,
  309. icon: Ext.MessageBox.ERROR,
  310. fn: function(btn, text){
  311. cleanupChangeNotifier();
  312. editResource( %%%%RES_ID%%% );
  313. }
  314. });
  315. };
  316. //doRefresh();
  317. },
  318. failure: failureAJAXFunction
  319. });
  320. }
  321. }]
  322. }
  323. EFUFU;
  324. } else {
  325. $R_image = 'unnamed_n.png';
  326. $R_name = $Labels->GetLabel('_RES_EZ_UART_DESC_');
  327. $QS = "SELECT * FROM `nodes` WHERE `id`={$CR['node_id']}";
  328. $ZZ = $DATABASE->Query( $QS );
  329. $CN = $ZZ[0];
  330. $TPL =<<<EFUFU
  331. {
  332. xtype: 'form',
  333. labelAlign: 'right',
  334. items:[{
  335. border: false,
  336. frame: false,
  337. xtype: 'panel',
  338. 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/>'
  339. },{
  340. xtype: 'combo',
  341. fieldLabel: 'Status',
  342. lazyRender:true,
  343. id: 'ued_ena',
  344. mode: 'local',
  345. forceSelection: true,
  346. triggerAction: 'all',
  347. editable: false,
  348. disableKeyFilter: true,
  349. store: new Ext.data.ArrayStore({
  350. fields: ['en_val','en_text'],
  351. data: [[0,'Disabled'], [1,'Enabled']]
  352. }),
  353. listeners:{
  354. select: function( c, r, n ){
  355. doResourceOperation({$EID}, 2, 9, n );
  356. }
  357. },
  358. value: %%%STATUS_VAL%%%,
  359. valueField: 'en_val',
  360. displayField: 'en_text'
  361. },{
  362. xtype: 'textfield',
  363. id: 'ued_ip',
  364. fieldLabel: 'IP Address',
  365. value: '{$Z['path']}',
  366. listeners:{
  367. change: function( t, n, o ){
  368. if( n!=o && n!='' ){
  369. doResourceOperation({$EID}, 2, 6, n );
  370. };
  371. }
  372. }
  373. },{
  374. xtype: 'numberfield',
  375. id: 'ued_port',
  376. fieldLabel: 'TCP Port',
  377. value: '{$Z['port']}',
  378. listeners:{
  379. change: function( t, n, o ){
  380. if( n!=o && n!='' ){
  381. doResourceOperation({$EID}, 2, 5, n );
  382. };
  383. }
  384. }
  385. },{
  386. id: 'uart_spd',
  387. xtype: 'combo',
  388. fieldLabel: '%%%SPD%%%',
  389. lazyRender: true,
  390. mode: 'local',
  391. forceSelection: true,
  392. triggerAction: 'all',
  393. editable: false,
  394. disableKeyFilter: true,
  395. store: new Ext.data.ArrayStore({
  396. fields: ['speed'],
  397. data: [[1200],[2400],[9600],[19200],[38400],[57600],[115200]]
  398. }),
  399. valueField: 'speed',
  400. displayField: 'speed',
  401. listeners:{
  402. select: function( c, r, n ){
  403. doResourceOperation({$EID}, 2, 1, n );
  404. }
  405. },
  406. value: %%%SPD_VAL%%%
  407. },{
  408. xtype: 'combo',
  409. fieldLabel: 'Bits',
  410. id: 'ued_bit',
  411. lazyRender:true,
  412. mode: 'local',
  413. forceSelection: true,
  414. triggerAction: 'all',
  415. editable: false,
  416. disableKeyFilter: true,
  417. store: new Ext.data.ArrayStore({
  418. fields: ['bits'],
  419. data: [[5],[6],[7],[8],[9]]
  420. }),
  421. listeners:{
  422. select: function( c, r, n ){
  423. doResourceOperation({$EID}, 2, 2, n );
  424. }
  425. },
  426. value: %%%BITS_VAL%%%,
  427. valueField: 'bits',
  428. displayField: 'bits'
  429. },{
  430. xtype: 'combo',
  431. fieldLabel: 'Stop Bit',
  432. lazyRender:true,
  433. id: 'ued_stops',
  434. mode: 'local',
  435. forceSelection: true,
  436. triggerAction: 'all',
  437. editable: false,
  438. disableKeyFilter: true,
  439. store: new Ext.data.ArrayStore({
  440. fields: ['stops'],
  441. data: [[1],[1.5],[2]]
  442. }),
  443. listeners:{
  444. select: function( c, r, n ){
  445. doResourceOperation({$EID}, 2, 3, n );
  446. }
  447. },
  448. value: %%%STOPS_VAL%%%,
  449. valueField: 'stops',
  450. displayField: 'stops'
  451. },{
  452. xtype: 'combo',
  453. fieldLabel: 'Parity',
  454. lazyRender:true,
  455. id: 'ued_parity',
  456. mode: 'local',
  457. forceSelection: true,
  458. triggerAction: 'all',
  459. editable: false,
  460. disableKeyFilter: true,
  461. store: new Ext.data.ArrayStore({
  462. fields: ['par_val','parity'],
  463. data: [['O','Odd'], ['E','Even'],['N','None']]
  464. }),
  465. listeners:{
  466. select: function( c, r, n ){
  467. doResourceOperation({$EID}, 2, 4, n );
  468. }
  469. },
  470. value: '%%%PARITY_VAL%%%',
  471. valueField: 'par_val',
  472. displayField: 'parity'
  473. },{
  474. xtype: 'panel',
  475. frame: false,
  476. border: false,
  477. html:'<center><a href="http://{$Z['path']}/" target="_blank">Link to a Control page</a></center>'
  478. }],
  479. bbar:[{
  480. text: 'Remove Remote UART',
  481. handler: function(){
  482. doResourceOperation({$EID}, 2, 255 );
  483. }
  484. }]
  485. }
  486. EFUFU;
  487. };
  488. $TPL = str_ireplace( '%%%STATUS_VAL%%%', $CN['enable'], $TPL );
  489. $TPL = str_ireplace( '%%%NAME%%%', $R_name, $TPL );
  490. $TPL = str_ireplace( '%%%INFO%%%', $R_dev, $TPL );
  491. $TPL = str_ireplace( '%%%SPD%%%', $Labels->GetLabel('UART_COM_SPEED'), $TPL );
  492. $TPL = str_ireplace( '%%%SPD_VAL%%%', intval($Z['speed']), $TPL );
  493. $TPL = str_ireplace( '%%%BITS_VAL%%%',$Z['bit'], $TPL );
  494. $TPL = str_ireplace( '%%%PARITY_VAL%%%',$Z['parity'], $TPL );
  495. $TPL = str_ireplace( '%%%STOPS_VAL%%%',$Z['stop_bit'], $TPL );
  496. $TPL = str_ireplace( '%%%%RES_ID%%%',$EID, $TPL );
  497. $TPL = str_ireplace( '%%%USER_ID%%%',$UserID, $TPL );
  498. $TPL = str_ireplace( '%%%SESSION%%%',$Session, $TPL );
  499. echo $TPL;
  500. break;
  501. case 31: //Video In
  502. $R_name = 'Video Frame Grabber';
  503. $R_dev = $CR['device'];
  504. $STREAM = $CR['aux_id'];
  505. //$QS="SELECT * FROM `media_streams` WHERE `id`={$CR['aux_id']}";
  506. //$II = $DATABASE->Query( $QS );
  507. //$CI = $II[0];
  508. $R_nfo = 'Frame Size: '.$CI['img_width'].'x'.$CI['img_height'].'<br/>Driver: '.$CI['mrl_proto'];
  509. $R_image = 'RCA-Connector-Plug-icon.png';
  510. $QS = "SELECT * FROM `media_streams` WHERE `id`={$STREAM}";
  511. $Result = $DATABASE->Query( $QS, false );
  512. if( count( $Result ) ){
  513. $CS = $Result[0];
  514. $R_nfo = 'Frame Size: '.$CS['img_width'].'x'.$CS['img_height'].'<br/>Driver: '.$CS['mrl_proto'];
  515. $R_image = 'RCA-Connector-Plug-icon.png';
  516. if( $CS['source_type'] == 'A' ){
  517. $Sizes = array();
  518. $Formats = array();
  519. //If Source not assigned or not active
  520. if( $CS['source_id'] == 0 || $CR['valid'] == 0 ){
  521. $CMD="v4l2-ctl -d {$CS['mrl']} --list-formats-ext";
  522. $Data = `$CMD`;
  523. $TArr = explode( "\n", $Data );
  524. foreach( $TArr as $R ){
  525. $CL = trim( $R );
  526. if( stripos($CL,']:')!== false ){
  527. $ID = intval( substr( $CL, 1 ) );
  528. $FCC = substr( $CL, stripos( $CL, ':' ) + 3, 4 );
  529. $DSC = substr( $CL, stripos( $CL, ':' ) + 9 );
  530. $Formats[] = array('id'=>$ID, '4cc'=>$FCC, 'desc'=>$DSC );
  531. };
  532. if( stripos($CL,'Size:')!== false ){
  533. $TBarr=explode( ' ', $CL );
  534. if( intval( $TBarr[1] ) ){
  535. $ZArr = explode( 'x', $TBarr[1] );
  536. $Sizes[$TBarr[1]] = array( 'width'=>$ZArr[0], 'height'=>$ZArr[1], 'title'=>$TBarr[1] );
  537. } else {
  538. $ZArr = explode( 'x', $TBarr[2] );
  539. $Sizes[$TBarr[2]] = array( 'width'=>$ZArr[0], 'height'=>$ZArr[1], 'title'=>$TBarr[2] );
  540. };
  541. };
  542. };
  543. };
  544. $CMD="v4l2-ctl -d {$CS['mrl']} --list-ctrls-menu";
  545. $Data = `$CMD`;
  546. $TArr = explode( "\n", $Data );
  547. $Controls = array();
  548. $MFlag = false;
  549. $MID = 0;
  550. $id = 0;
  551. foreach( $TArr as $R ){
  552. $CL = trim( $R );
  553. if( stripos( $CL, ':' ) !== false ){
  554. $ctrl = array();
  555. $RR = explode( ':', $CL );
  556. $TArr=explode( ' ', $CL );
  557. if( stripos( $CL, 'int' )!== false ){
  558. $ctrl['type'] = 'slider';
  559. $ctrl['name'] = trim( $TArr[0] );
  560. $ctrl['name_cod'] = md5( $ctrl['name'] );
  561. $ctrl['id'] = hexdec( $TArr[1] );
  562. $TArr=explode( ' ', $RR[1] );
  563. $TBrr = explode( '=', $TArr[1] );
  564. $ctrl['min'] = intval( $TBrr[1] );
  565. $TBrr = explode( '=', $TArr[2] );
  566. $ctrl['max'] = intval( $TBrr[1] );
  567. $TBrr = explode( '=', $TArr[3] );
  568. $ctrl['step'] = intval( $TBrr[1] );
  569. $TBrr = explode( '=', $TArr[5] );
  570. $ctrl['value'] = intval( $TBrr[1] );
  571. $MFlag = false;
  572. $Controls[$id] = $ctrl;
  573. $id++;
  574. } else if( stripos( $CL, 'bool' )!== false ){
  575. $ctrl['type'] = 'checkbox';
  576. $ctrl['name'] = trim( $TArr[0] );
  577. $ctrl['name_cod'] = md5( $ctrl['name'] );
  578. $ctrl['id'] = hexdec( $TArr[1] );
  579. $TArr=explode( ' ', $RR[1] );
  580. $TBrr = explode( '=', $TArr[2] );
  581. $ctrl['value'] = intval( $TBrr[1] );
  582. $MFlag = false;
  583. $Controls[$id] = $ctrl;
  584. $id++;
  585. } else if( stripos( $CL, 'menu' )!== false ){
  586. $ctrl['type'] = 'combo';
  587. $ctrl['name'] = trim( $TArr[0] );
  588. $ctrl['name_cod'] = md5( $ctrl['name'] );
  589. $ctrl['id'] = hexdec( $TArr[1] );
  590. $TArr=explode( ' ', $RR[1] );
  591. $TBrr = explode( '=', $TArr[4] );
  592. $ctrl['value'] = intval( $TBrr[1] );
  593. $MFlag = true;
  594. $MID = $id;
  595. $Controls[$id] = $ctrl;
  596. $id++;
  597. } else {
  598. if( $MFlag ){
  599. $ZV = explode( ':', $CL );
  600. $cmi= array();
  601. $cmi['id']=intval( $ZV[0] );
  602. $cmi['text']=trim( $ZV[1] );
  603. $Controls[$MID]['data'][]=$cmi;
  604. };
  605. };
  606. };
  607. };
  608. $CCC = 0;
  609. $OUT = array();
  610. if( count( $Formats ) ){
  611. $ll = "{
  612. xtype: 'combo',
  613. fieldLabel: '". $Labels->GetLabel('_FRAME_FORMAT_') ."',
  614. lazyRender: true,
  615. id: 'frmt_id',
  616. name: 'frame_format',
  617. mode: 'local',
  618. forceSelection: true, triggerAction: 'all', editable: false, disableKeyFilter: true,
  619. listeners:{ change: function(t,n,o){ changeASS( {$STREAM }, 'frmt_id'); }},
  620. store: new Ext.data.ArrayStore({
  621. fields: ['fmt','fmt_txt'],
  622. data: [";
  623. $cl = array();
  624. foreach( $Formats as $F ){
  625. $cl[]="[{$F['id']},\"{$F['desc']}\"]";
  626. };
  627. $ll .= implode( ',', $cl );
  628. $ll .="]
  629. }),
  630. valueField: 'fmt',
  631. displayField: 'fmt_txt'
  632. }";
  633. $OUT[$CCC] = $ll;
  634. $CCC++;
  635. };
  636. if( count( $Sizes ) ){
  637. $ll = "{
  638. xtype: 'combo',
  639. fieldLabel: '". $Labels->GetLabel('_FRAME_SIZE_') ."',
  640. lazyRender: true,
  641. id: 'sizes_id',
  642. name: 'frame_size',
  643. mode: 'local',
  644. forceSelection: true, triggerAction: 'all', editable: false, disableKeyFilter: true,
  645. listeners:{ change: function(t,n,o){ changeASS( {$STREAM }, 'sizes_id'); }},
  646. store: new Ext.data.ArrayStore({
  647. fields: ['size','size_txt'],
  648. data: [";
  649. $cl = array();
  650. $id = 0;
  651. $csid = 0;
  652. foreach( $Sizes as $Key=>$Val ){
  653. if( $Val['width'] == $CS['img_width'] && $Val['height'] == $CS['img_height'] ) $csid = $Key;//$id;
  654. //$cl[]="[{$id},\"{$Key}\"]";
  655. $cl[]="[\"{$Key}\",\"{$Key}\"]";
  656. $id++;
  657. };
  658. $ll .= implode( ',', $cl );
  659. $ll .="]
  660. }),
  661. valueField: 'size',
  662. displayField: 'size_txt',
  663. value: '{$csid}'
  664. }";
  665. $OUT[$CCC] = $ll;
  666. $CCC++;
  667. };
  668. //print_r( $Controls );
  669. if( count( $Controls )){
  670. foreach( $Controls as $CC ){
  671. $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']}' ); } }, ";
  672. switch( $CC['type'] ){
  673. case 'slider':{
  674. $ll .= "minValue: {$CC['min']}, maxValue: {$CC['max']}, width: 235 }";
  675. break;
  676. };
  677. case 'checkbox':{
  678. if( $CC['value'] == 1 ){
  679. $ll .= "checked: true }";
  680. } else {
  681. $ll .= "checked: false }";
  682. };
  683. break;
  684. };
  685. case 'combo':{
  686. $ll .= "lazyRender: true, mode: 'local', forceSelection: true, triggerAction: 'all', editable: false, disableKeyFilter: true, store: new Ext.data.ArrayStore({
  687. fields: ['{$CC['id']}_id','{$CC['id']}_txt'],
  688. data: [";
  689. $cl = array();
  690. foreach( $CC['data'] as $D ) $cl[]="[{$D['id']},\"{$D['text']}\"]";
  691. $ll .= implode(',', $cl );
  692. $ll .="]
  693. }),
  694. valueField: '{$CC['id']}_id',
  695. displayField: '{$CC['id']}_txt'
  696. }";
  697. break;
  698. };
  699. };
  700. $OUT[$CCC] = $ll;
  701. $CCC++;
  702. };
  703. }; //https://www.waveshare.com/wiki/SIM7600E-H_4G_HAT
  704. $TOPLER=<<<JUJUAS
  705. {
  706. border: false,
  707. frame: false,
  708. xtype: 'panel',
  709. 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/>'
  710. },
  711. JUJUAS;
  712. $TOPLER = str_ireplace( '%%%NAME%%%', $R_name . '['. $R_dev . ']', $TOPLER );
  713. $TOPLER = str_ireplace( '%%%INFO%%%', $R_nfo, $TOPLER );
  714. if( count( $OUT ) ){
  715. $CCA = $TOPLER . implode( ',', $OUT );
  716. } else {
  717. $CCA = $TOPLER . '{ html: "-Device-Enquiry-Failure-" }';
  718. };
  719. echo "{ xtype: 'form', id:'an_str_edit', frame: false, autoScroll: true, border: false, layout: 'form', labelAlign: 'right', labelWidth: 150, items: [". $CCA ."] }";
  720. } else {
  721. echo "{ xtype: 'panel', html: '<center>Incorrect Stream</center>'}";
  722. };
  723. } else {
  724. echo "{ xtype: 'panel', html: '<center>Incorrect Stream</center>'}";
  725. };
  726. break;
  727. case 101: // Ethernet
  728. $R_name = $Labels->GetLabel('_RES_ETHERNET_DESC_');
  729. $R_dev = $CR['device'];
  730. $QS="SELECT * FROM `network_interfaces` WHERE `id`={$CR['aux_id']}";
  731. echo makeEthernetInfo( $CR['aux_id'] );
  732. exit;
  733. $II = $DATABASE->Query( $QS );
  734. $CI = $II[0];
  735. switch( $CI['mode'] ){
  736. case 0: $MS = $Labels->GetLabel( 'MODE_DISABLED' ); break;
  737. case 1: $MS = $Labels->GetLabel( 'MODE_ETHDYNAMIC' ); break;
  738. case 2: $MS = $Labels->GetLabel( 'MODE_ETHSTATIC' ); break;
  739. case 1: $MS = $Labels->GetLabel( 'MODE_ETHROUTER' ); break;
  740. };
  741. $QS="SELECT * FROM `networks` WHERE `nif_id`={$CR['aux_id']}";
  742. $II = $DATABASE->Query( $QS );
  743. $NetInfo ='';
  744. foreach($II as $I){
  745. if( $I['type'] == 0 ){
  746. $NetInfo .= '<br/>Address IPv4: '.$I['address'].'<br/>Net Mask: '.$I['mask'];
  747. } else {
  748. $NetInfo .= '<br/>Address IPv6: '.$I['address'].'<br/>Net Mask: '.$I['mask'];
  749. };
  750. };
  751. $R_nfo = 'Mode: '.$MS.'<br/>MAC: '.$CI['mac'] . $NetInfo;
  752. $R_image = 'Ethernet-Cable-icon.png';
  753. break;
  754. case 102: // WiFi
  755. $R_name = $Labels->GetLabel('_RES_WIFI_DESC_');
  756. $R_dev = $CR['device'];
  757. $QS="SELECT * FROM `network_interfaces` WHERE `id`={$CR['aux_id']}";
  758. $II = $DATABASE->Query( $QS );
  759. $CI = $II[0];
  760. switch( $CI['mode'] ){
  761. case 0: $MS = $Labels->GetLabel( 'MODE_DISABLED' ); break;
  762. case 1: $MS = $Labels->GetLabel( 'MODE_ETHDYNAMIC' ); break;
  763. case 2: $MS = $Labels->GetLabel( 'MODE_ETHSTATIC' ); break;
  764. case 3: $MS = $Labels->GetLabel( 'MODE_ACCESS_POINT' ); break;
  765. };
  766. $QS="SELECT * FROM `networks` WHERE `nif_id`={$CR['aux_id']}";
  767. $II = $DATABASE->Query( $QS );
  768. $NetInfo ='';
  769. foreach($II as $I){
  770. if( $I['type'] == 0 ){
  771. $NetInfo .= '<br/>Address IPv4: '.$I['address'].'<br/>Net Mask: '.$I['mask'];
  772. } else {
  773. $NetInfo .= '<br/>Address IPv6: '.$I['address'].'<br/>Net Mask: '.$I['mask'];
  774. };
  775. };
  776. $R_nfo = 'Mode: '.$MS.'<br/>MAC: '.$CI['mac'] . $NetInfo;
  777. $R_image = 'wifi-modem-Vista-icon.png';
  778. break;
  779. case 105:
  780. $R_name = $Labels->GetLabel('_RES_WAN_DESC_');
  781. $R_dev = $CR['device'];
  782. $QS="SELECT * FROM `network_interfaces` WHERE `id`={$CR['aux_id']}";
  783. $II = $DATABASE->Query( $QS );
  784. $CI = $II[0];
  785. switch( $CI['mode'] ){
  786. case 0: $MS = $Labels->GetLabel( 'MODE_DISABLED' ); break;
  787. case 1: $MS = $Labels->GetLabel( 'MODE_ETHDYNAMIC' ); break;
  788. case 2: $MS = $Labels->GetLabel( 'MODE_ETHSTATIC' ); break;
  789. case 3: $MS = $Labels->GetLabel( 'MODE_ACCESS_POINT' ); break;
  790. };
  791. $QS="SELECT * FROM `networks` WHERE `nif_id`={$CR['aux_id']}";
  792. $II = $DATABASE->Query( $QS );
  793. $NetInfo ='';
  794. foreach($II as $I){
  795. if( $I['type'] == 0 ){
  796. $NetInfo .= '<br/>Address IPv4: '.$I['address'].'<br/>Net Mask: '.$I['mask'];
  797. } else {
  798. $NetInfo .= '<br/>Address IPv6: '.$I['address'].'<br/>Net Mask: '.$I['mask'];
  799. };
  800. };
  801. $R_nfo = 'Mode: '.$MS.'<br/>MAC: '.$CI['mac'] . $NetInfo;
  802. $R_image = 'wifi-modem-Vista-icon.png';
  803. break;
  804. };
  805. } else {
  806. echo '{ xtype: \'panel\', html: \'Node '.$_POST['NODE'].' Loadded\'}';
  807. };
  808. } else {
  809. header('location: /');
  810. };
  811. ?>