|
|
<?php require_once('../ajax_asm.php'); function makeEthernetInfo( $RessourceID ){ global $DATABASE, $CUser, $Labels; $TTL = $Labels->GetLabel('_RES_ETHERNET_DESC_'); $QS="SELECT * FROM `network_interfaces` WHERE `id`={$RessourceID}"; $II = $DATABASE->Query( $QS ); $CI = $II[0]; switch( $CI['mode'] ){ case 0: $MS = $Labels->GetLabel( 'MODE_DISABLED' ); break; case 1: $MS = $Labels->GetLabel( 'MODE_ETHDYNAMIC' ); break; case 2: $MS = $Labels->GetLabel( 'MODE_ETHSTATIC' ); break; case 3: $MS = $Labels->GetLabel( 'MODE_ETHROUTER' ); break; }; $QS="SELECT * FROM `networks` WHERE `nif_id`={$RessourceID}"; $II = $DATABASE->Query( $QS ); $NetInfo =''; $IP = array(); foreach($II as $I){ if( $I['type'] == 0 ){ $IP = $I; $NetInfo .= '<br/>Address IPv4: '.$I['address'].'<br/>Net Mask: '.$I['mask']; } else { $NetInfo .= '<br/>Address IPv6: '.$I['address'].'<br/>Net Mask: '.$I['mask']; }; }; if( count( $IP ) ){ $TArr = explode( '.', $IP['address'] ); $Base = ''; } else { }; $R_nfo = 'Mode: '.$MS.'<br/>MAC: '.$CI['mac'] . $NetInfo; $R_image = 'Ethernet-Cable-icon.png'; $POPUS = 123; $A_EDIT = ( $CI['mode'] < 2 )?'true':'false'; $TPL = <<<END_TEMPLATE { xtype: 'panel', border: false, frame: false, layout:'table', //autoHeight:true,
autoWidth:true, defaults: { bodyStyle:'padding:0px' }, layoutConfig: { tableAttrs: { style: { width: '100%' } }, columns: 4 }, items: [{ border: false, width: 10 },{ border: false, width: 270, html: '<img width="256px" id="res_info_image" src="/style/assets/{$R_image}">', },{ xtype: 'panel', border: false, frame: false, width: 420, height: 320, items:[{ frame: false, border: false, html: '<p style="font-size: 16px;">{$TTL}</p>' },{ xtype: 'tabpanel', id: 'ifo_tab', activeTab: 0, items:[{ title: 'Info', html: '{$R_nfo}' },{ title: 'Settings', layout: 'form', labelAlign: 'right', labelWidth: 150, items:[{ xtype: 'combo', fieldLabel: 'Address Allocation', lazyRender: true, id: 'aa_type', mode: 'local', forceSelection: true, triggerAction: 'all', editable: false, disableKeyFilter: true, listeners:{ change: function(t,n,o){ if( n < 2 ){ Ext.getCmp('aa_adr').disable(); } else { Ext.getCmp('aa_adr').enable(); }; } }, store: new Ext.data.ArrayStore({ fields: ['aa_t','aa_txt'], data: [ [0,'Disabled'], [1,'Dynamic (DHCP)'], [2,'Static'], [3,'Router'], ] }), value: {$CI['mode']}, valueField: 'aa_t', displayField: 'aa_txt' },{ xtype: 'textfield', id: 'aa_adr', fieldLabel: 'Address', value: '{$IP['address']}', disabled: {$A_EDIT} },{ xtype: 'textfield', id: 'aa_mask', fieldLabel: 'Net Mask', value: '{$IP['mask']}', disabled: {$A_EDIT} },{ xtype: 'textfield', id: 'aa_gtw', fieldLabel: 'Gateway', value: '{$IP['gateway']}', disabled: true },{ xtype: 'textfield', id: 'aa_bcast', fieldLabel: 'Broadcast', value: '{$IP['broadcast']}', disabled: true },{ xtype: 'spacer', height: 100 },{ xtype: 'button', width: '100%', text: 'Apply Changes' },{ xtype: 'spacer', height: 20 }] },{ title: 'Router', layout: 'form', labelAlign: 'right', labelWidth: 150, items:[{ xtype: 'checkbox', fieldLabel: 'Act as DHCP Server', },{ xtype: 'textfield', fieldLabel: 'Start IP Range' },{ xtype: 'textfield', fieldLabel: 'End IP Range' }] }] }] },{ border: false, width: 10 }], koko: {$POPUS} }END_TEMPLATE; return $TPL; }; if( $CUser->Data['id'] > 1 ){ $EID = intval( $_POST['RID'] ); $QS = "SELECT * FROM resources WHERE id = {$EID}"; $Result = $DATABASE->Query( $QS, false ); if( count( $Result ) ){ $CR = $Result[0]; switch( $CR['type'] ){ case 1: //https://bufferwall.com/posts/330881001ji1a/
$QS = "SELECT * FROM uart_settings WHERE id={$CR['aux_id']}"; $Result = $DATABASE->Query( $QS ); $Z = $Result[0]; $R_name = $Labels->GetLabel('_RES_HW_UART_DESC_'); $R_dev = $CR['device']; $R_nfo = 'Speed: ' . $Z['speed'] . ', Bits: ' . $Z['bit'] . ', Parity: ' . $Z['parity'] . ', Stop Bit: '. $Z['stop_bit']; $R_image = 'unnamed.png'; $TPL =<<<EFUFU{ xtype: 'form', labelAlign: 'right', items:[{ border: false, frame: false, xtype: 'panel', 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/>' },{ id: 'uart_spd', xtype: 'combo', fieldLabel: '%%%SPD%%%', lazyRender: true, mode: 'local', forceSelection: true, triggerAction: 'all', editable: false, disableKeyFilter: true, store: new Ext.data.ArrayStore({ fields: ['speed'], data: [[1200],[2400],[9600],[19200],[38400],[57600],[115200]] }), valueField: 'speed', displayField: 'speed', listeners:{ change: function(){ settingsChangeNotifier( 'uart_spd' ); Ext.getCmp('ua_apply_btn').enable(); } }, value: %%%SPD_VAL%%% },{ xtype: 'combo', fieldLabel: 'Bits', id: 'ued_bit', lazyRender:true, mode: 'local', forceSelection: true, triggerAction: 'all', editable: false, disableKeyFilter: true, store: new Ext.data.ArrayStore({ fields: ['bits'], data: [[5],[6],[7],[8],[9]] }), value: %%%BITS_VAL%%%, valueField: 'bits', displayField: 'bits' },{ xtype: 'combo', fieldLabel: 'Stop Bit', lazyRender:true, id: 'ued_stops', mode: 'local', forceSelection: true, triggerAction: 'all', editable: false, disableKeyFilter: true, store: new Ext.data.ArrayStore({ fields: ['stops'], data: [[1],[1.5],[2]] }), value: %%%STOPS_VAL%%%, valueField: 'stops', displayField: 'stops' },{ xtype: 'combo', fieldLabel: 'Parity', lazyRender:true, id: 'ued_parity', mode: 'local', forceSelection: true, triggerAction: 'all', editable: false, disableKeyFilter: true, store: new Ext.data.ArrayStore({ fields: ['par_val','parity'], data: [['O','Odd'], ['E','Even'],['N','None']] }), value: '%%%PARITY_VAL%%%', valueField: 'par_val', displayField: 'parity' },{ xtype: 'spacer', height: 10 },{ xtype: 'button', id: 'ua_apply_btn', disabled: true, width: '100%', text: 'Apply Changes', handler: function(){ var UART_SPD = Ext.getCmp('uart_spd').getValue(); var UART_BIT = Ext.getCmp('ued_bit').getValue(); var UART_STP = Ext.getCmp('ued_stops').getValue(); var UART_PAR = Ext.getCmp('ued_parity').getValue(); Ext.Ajax.request({ url: '/lib/controller/updateResource.php', params: { RID: %%%%RES_ID%%%, UID: %%%USER_ID%%%, SID: '%%%SESSION%%%', USPD: UART_SPD, UBIT: UART_BIT, USTP: UART_STP, UPAR: UART_PAR }, success: function( response, opts ){ data = Ext.decode(response.responseText); if( data.status ){ cleanupChangeNotifier(); editResource( %%%%RES_ID%%% ); } else { Ext.Msg.show({ title:'Error', msg: data.msg, buttons: Ext.Msg.OK, icon: Ext.MessageBox.ERROR, fn: function(btn, text){ cleanupChangeNotifier(); editResource( %%%%RES_ID%%% ); } }); }; //doRefresh();
}, failure: failureAJAXFunction }); } }] }EFUFU; $TPL = str_ireplace( '%%%NAME%%%', $R_name, $TPL ); $TPL = str_ireplace( '%%%INFO%%%', $R_dev, $TPL ); $TPL = str_ireplace( '%%%SPD%%%', $Labels->GetLabel('UART_COM_SPEED'), $TPL ); $TPL = str_ireplace( '%%%SPD_VAL%%%', $Z['speed'], $TPL ); $TPL = str_ireplace( '%%%BITS_VAL%%%',$Z['bit'], $TPL ); $TPL = str_ireplace( '%%%PARITY_VAL%%%',$Z['parity'], $TPL ); $TPL = str_ireplace( '%%%STOPS_VAL%%%',$Z['stop_bit'], $TPL ); $TPL = str_ireplace( '%%%%RES_ID%%%',$EID, $TPL ); $TPL = str_ireplace( '%%%USER_ID%%%',$UserID, $TPL ); $TPL = str_ireplace( '%%%SESSION%%%',$Session, $TPL ); echo $TPL; break; case 31: //Video In
$R_name = 'Video Frame Grabber'; $R_dev = $CR['device']; $QS="SELECT * FROM `media_streams` WHERE `id`={$CR['aux_id']}"; $II = $DATABASE->Query( $QS ); $CI = $II[0]; $R_nfo = 'Frame Size: '.$CI['img_width'].'x'.$CI['img_height'].'<br/>Driver: '.$CI['mrl_proto']; $R_image = 'RCA-Connector-Plug-icon.png'; break; case 101: // Ethernet
$R_name = $Labels->GetLabel('_RES_ETHERNET_DESC_'); $R_dev = $CR['device']; $QS="SELECT * FROM `network_interfaces` WHERE `id`={$CR['aux_id']}"; echo makeEthernetInfo( $CR['aux_id'] ); exit; $II = $DATABASE->Query( $QS ); $CI = $II[0]; switch( $CI['mode'] ){ case 0: $MS = $Labels->GetLabel( 'MODE_DISABLED' ); break; case 1: $MS = $Labels->GetLabel( 'MODE_ETHDYNAMIC' ); break; case 2: $MS = $Labels->GetLabel( 'MODE_ETHSTATIC' ); break; case 1: $MS = $Labels->GetLabel( 'MODE_ETHROUTER' ); break; }; $QS="SELECT * FROM `networks` WHERE `nif_id`={$CR['aux_id']}"; $II = $DATABASE->Query( $QS ); $NetInfo =''; foreach($II as $I){ if( $I['type'] == 0 ){ $NetInfo .= '<br/>Address IPv4: '.$I['address'].'<br/>Net Mask: '.$I['mask']; } else { $NetInfo .= '<br/>Address IPv6: '.$I['address'].'<br/>Net Mask: '.$I['mask']; }; }; $R_nfo = 'Mode: '.$MS.'<br/>MAC: '.$CI['mac'] . $NetInfo; $R_image = 'Ethernet-Cable-icon.png'; break; case 102: // WiFi
$R_name = $Labels->GetLabel('_RES_WIFI_DESC_'); $R_dev = $CR['device']; $QS="SELECT * FROM `network_interfaces` WHERE `id`={$CR['aux_id']}"; $II = $DATABASE->Query( $QS ); $CI = $II[0]; switch( $CI['mode'] ){ case 0: $MS = $Labels->GetLabel( 'MODE_DISABLED' ); break; case 1: $MS = $Labels->GetLabel( 'MODE_ETHDYNAMIC' ); break; case 2: $MS = $Labels->GetLabel( 'MODE_ETHSTATIC' ); break; case 3: $MS = $Labels->GetLabel( 'MODE_ACCESS_POINT' ); break; }; $QS="SELECT * FROM `networks` WHERE `nif_id`={$CR['aux_id']}"; $II = $DATABASE->Query( $QS ); $NetInfo =''; foreach($II as $I){ if( $I['type'] == 0 ){ $NetInfo .= '<br/>Address IPv4: '.$I['address'].'<br/>Net Mask: '.$I['mask']; } else { $NetInfo .= '<br/>Address IPv6: '.$I['address'].'<br/>Net Mask: '.$I['mask']; }; }; $R_nfo = 'Mode: '.$MS.'<br/>MAC: '.$CI['mac'] . $NetInfo; $R_image = 'wifi-modem-Vista-icon.png'; break; case 105: $R_name = $Labels->GetLabel('_RES_WAN_DESC_'); $R_dev = $CR['device']; $QS="SELECT * FROM `network_interfaces` WHERE `id`={$CR['aux_id']}"; $II = $DATABASE->Query( $QS ); $CI = $II[0]; switch( $CI['mode'] ){ case 0: $MS = $Labels->GetLabel( 'MODE_DISABLED' ); break; case 1: $MS = $Labels->GetLabel( 'MODE_ETHDYNAMIC' ); break; case 2: $MS = $Labels->GetLabel( 'MODE_ETHSTATIC' ); break; case 3: $MS = $Labels->GetLabel( 'MODE_ACCESS_POINT' ); break; }; $QS="SELECT * FROM `networks` WHERE `nif_id`={$CR['aux_id']}"; $II = $DATABASE->Query( $QS ); $NetInfo =''; foreach($II as $I){ if( $I['type'] == 0 ){ $NetInfo .= '<br/>Address IPv4: '.$I['address'].'<br/>Net Mask: '.$I['mask']; } else { $NetInfo .= '<br/>Address IPv6: '.$I['address'].'<br/>Net Mask: '.$I['mask']; }; }; $R_nfo = 'Mode: '.$MS.'<br/>MAC: '.$CI['mac'] . $NetInfo; $R_image = 'wifi-modem-Vista-icon.png'; break; }; } else { echo '{ xtype: \'panel\', html: \'Node '.$_POST['NODE'].' Loadded\'}'; }; } else { header('location: /'); };?>
|