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.

429 lines
12 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_name = $Labels->GetLabel('_RES_HW_UART_DESC_');
  188. $R_dev = $CR['device'];
  189. $R_nfo = 'Speed: ' . $Z['speed'] . ', Bits: ' . $Z['bit'] . ', Parity: ' . $Z['parity'] . ', Stop Bit: '. $Z['stop_bit'];
  190. $R_image = 'unnamed.png';
  191. $TPL =<<<EFUFU
  192. {
  193. xtype: 'form',
  194. labelAlign: 'right',
  195. items:[{
  196. border: false,
  197. frame: false,
  198. xtype: 'panel',
  199. 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/>'
  200. },{
  201. id: 'uart_spd',
  202. xtype: 'combo',
  203. fieldLabel: '%%%SPD%%%',
  204. lazyRender: true,
  205. mode: 'local',
  206. forceSelection: true,
  207. triggerAction: 'all',
  208. editable: false,
  209. disableKeyFilter: true,
  210. store: new Ext.data.ArrayStore({
  211. fields: ['speed'],
  212. data: [[1200],[2400],[9600],[19200],[38400],[57600],[115200]]
  213. }),
  214. valueField: 'speed',
  215. displayField: 'speed',
  216. listeners:{
  217. change: function(){
  218. settingsChangeNotifier( 'uart_spd' );
  219. Ext.getCmp('ua_apply_btn').enable();
  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. $TPL = str_ireplace( '%%%NAME%%%', $R_name, $TPL );
  325. $TPL = str_ireplace( '%%%INFO%%%', $R_dev, $TPL );
  326. $TPL = str_ireplace( '%%%SPD%%%', $Labels->GetLabel('UART_COM_SPEED'), $TPL );
  327. $TPL = str_ireplace( '%%%SPD_VAL%%%', $Z['speed'], $TPL );
  328. $TPL = str_ireplace( '%%%BITS_VAL%%%',$Z['bit'], $TPL );
  329. $TPL = str_ireplace( '%%%PARITY_VAL%%%',$Z['parity'], $TPL );
  330. $TPL = str_ireplace( '%%%STOPS_VAL%%%',$Z['stop_bit'], $TPL );
  331. $TPL = str_ireplace( '%%%%RES_ID%%%',$EID, $TPL );
  332. $TPL = str_ireplace( '%%%USER_ID%%%',$UserID, $TPL );
  333. $TPL = str_ireplace( '%%%SESSION%%%',$Session, $TPL );
  334. echo $TPL;
  335. break;
  336. case 31: //Video In
  337. $R_name = 'Video Frame Grabber';
  338. $R_dev = $CR['device'];
  339. $QS="SELECT * FROM `media_streams` WHERE `id`={$CR['aux_id']}";
  340. $II = $DATABASE->Query( $QS );
  341. $CI = $II[0];
  342. $R_nfo = 'Frame Size: '.$CI['img_width'].'x'.$CI['img_height'].'<br/>Driver: '.$CI['mrl_proto'];
  343. $R_image = 'RCA-Connector-Plug-icon.png';
  344. break;
  345. case 101: // Ethernet
  346. $R_name = $Labels->GetLabel('_RES_ETHERNET_DESC_');
  347. $R_dev = $CR['device'];
  348. $QS="SELECT * FROM `network_interfaces` WHERE `id`={$CR['aux_id']}";
  349. echo makeEthernetInfo( $CR['aux_id'] );
  350. exit;
  351. $II = $DATABASE->Query( $QS );
  352. $CI = $II[0];
  353. switch( $CI['mode'] ){
  354. case 0: $MS = $Labels->GetLabel( 'MODE_DISABLED' ); break;
  355. case 1: $MS = $Labels->GetLabel( 'MODE_ETHDYNAMIC' ); break;
  356. case 2: $MS = $Labels->GetLabel( 'MODE_ETHSTATIC' ); break;
  357. case 1: $MS = $Labels->GetLabel( 'MODE_ETHROUTER' ); break;
  358. };
  359. $QS="SELECT * FROM `networks` WHERE `nif_id`={$CR['aux_id']}";
  360. $II = $DATABASE->Query( $QS );
  361. $NetInfo ='';
  362. foreach($II as $I){
  363. if( $I['type'] == 0 ){
  364. $NetInfo .= '<br/>Address IPv4: '.$I['address'].'<br/>Net Mask: '.$I['mask'];
  365. } else {
  366. $NetInfo .= '<br/>Address IPv6: '.$I['address'].'<br/>Net Mask: '.$I['mask'];
  367. };
  368. };
  369. $R_nfo = 'Mode: '.$MS.'<br/>MAC: '.$CI['mac'] . $NetInfo;
  370. $R_image = 'Ethernet-Cable-icon.png';
  371. break;
  372. case 102: // WiFi
  373. $R_name = $Labels->GetLabel('_RES_WIFI_DESC_');
  374. $R_dev = $CR['device'];
  375. $QS="SELECT * FROM `network_interfaces` WHERE `id`={$CR['aux_id']}";
  376. $II = $DATABASE->Query( $QS );
  377. $CI = $II[0];
  378. switch( $CI['mode'] ){
  379. case 0: $MS = $Labels->GetLabel( 'MODE_DISABLED' ); break;
  380. case 1: $MS = $Labels->GetLabel( 'MODE_ETHDYNAMIC' ); break;
  381. case 2: $MS = $Labels->GetLabel( 'MODE_ETHSTATIC' ); break;
  382. case 3: $MS = $Labels->GetLabel( 'MODE_ACCESS_POINT' ); break;
  383. };
  384. $QS="SELECT * FROM `networks` WHERE `nif_id`={$CR['aux_id']}";
  385. $II = $DATABASE->Query( $QS );
  386. $NetInfo ='';
  387. foreach($II as $I){
  388. if( $I['type'] == 0 ){
  389. $NetInfo .= '<br/>Address IPv4: '.$I['address'].'<br/>Net Mask: '.$I['mask'];
  390. } else {
  391. $NetInfo .= '<br/>Address IPv6: '.$I['address'].'<br/>Net Mask: '.$I['mask'];
  392. };
  393. };
  394. $R_nfo = 'Mode: '.$MS.'<br/>MAC: '.$CI['mac'] . $NetInfo;
  395. $R_image = 'wifi-modem-Vista-icon.png';
  396. break;
  397. case 105:
  398. $R_name = $Labels->GetLabel('_RES_WAN_DESC_');
  399. $R_dev = $CR['device'];
  400. $QS="SELECT * FROM `network_interfaces` WHERE `id`={$CR['aux_id']}";
  401. $II = $DATABASE->Query( $QS );
  402. $CI = $II[0];
  403. switch( $CI['mode'] ){
  404. case 0: $MS = $Labels->GetLabel( 'MODE_DISABLED' ); break;
  405. case 1: $MS = $Labels->GetLabel( 'MODE_ETHDYNAMIC' ); break;
  406. case 2: $MS = $Labels->GetLabel( 'MODE_ETHSTATIC' ); break;
  407. case 3: $MS = $Labels->GetLabel( 'MODE_ACCESS_POINT' ); break;
  408. };
  409. $QS="SELECT * FROM `networks` WHERE `nif_id`={$CR['aux_id']}";
  410. $II = $DATABASE->Query( $QS );
  411. $NetInfo ='';
  412. foreach($II as $I){
  413. if( $I['type'] == 0 ){
  414. $NetInfo .= '<br/>Address IPv4: '.$I['address'].'<br/>Net Mask: '.$I['mask'];
  415. } else {
  416. $NetInfo .= '<br/>Address IPv6: '.$I['address'].'<br/>Net Mask: '.$I['mask'];
  417. };
  418. };
  419. $R_nfo = 'Mode: '.$MS.'<br/>MAC: '.$CI['mac'] . $NetInfo;
  420. $R_image = 'wifi-modem-Vista-icon.png';
  421. break;
  422. };
  423. } else {
  424. echo '{ xtype: \'panel\', html: \'Node '.$_POST['NODE'].' Loadded\'}';
  425. };
  426. } else {
  427. header('location: /');
  428. };
  429. ?>