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 .= '
Address IPv4: '.$I['address'].'
Net Mask: '.$I['mask']; } else { $NetInfo .= '
Address IPv6: '.$I['address'].'
Net Mask: '.$I['mask']; }; }; if( count( $IP ) ){ $TArr = explode( '.', $IP['address'] ); $Base = ''; } else { }; $R_nfo = 'Mode: '.$MS.'
MAC: '.$CI['mac'] . $NetInfo; $R_image = 'Ethernet-Cable-icon.png'; $POPUS = 123; $A_EDIT = ( $CI['mode'] < 2 )?'true':'false'; $TPL = <<', },{ xtype: 'panel', border: false, frame: false, width: 420, height: 320, items:[{ frame: false, border: false, html: '

{$TTL}

' },{ 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 =<<%%%NAME%%%%%%INFO%%%
' },{ 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']; $STREAM = $CR['aux_id']; //$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'].'
Driver: '.$CI['mrl_proto']; $R_image = 'RCA-Connector-Plug-icon.png'; $QS = "SELECT * FROM `media_streams` WHERE `id`={$STREAM}"; $Result = $DATABASE->Query( $QS, false ); if( count( $Result ) ){ $CS = $Result[0]; $R_nfo = 'Frame Size: '.$CS['img_width'].'x'.$CS['img_height'].'
Driver: '.$CS['mrl_proto']; $R_image = 'RCA-Connector-Plug-icon.png'; if( $CS['source_type'] == 'A' ){ $Sizes = array(); $Formats = array(); //If Source not assigned or not active if( $CS['source_id'] == 0 || $CR['active'] == 0 ){ $CMD="v4l2-ctl -d {$CS['mrl']} --list-formats-ext"; $Data = `$CMD`; $TArr = explode( "\n", $Data ); foreach( $TArr as $R ){ $CL = trim( $R ); if( stripos($CL,']:')!== false ){ $ID = intval( substr( $CL, 1 ) ); $FCC = substr( $CL, stripos( $CL, ':' ) + 3, 4 ); $DSC = substr( $CL, stripos( $CL, ':' ) + 9 ); $Formats[] = array('id'=>$ID, '4cc'=>$FCC, 'desc'=>$DSC ); }; if( stripos($CL,'Size:')!== false ){ $TBarr=explode( ' ', $CL ); if( intval( $TBarr[1] ) ){ $ZArr = explode( 'x', $TBarr[1] ); $Sizes[$TBarr[1]] = array( 'width'=>$ZArr[0], 'height'=>$ZArr[1], 'title'=>$TBarr[1] ); } else { $ZArr = explode( 'x', $TBarr[2] ); $Sizes[$TBarr[2]] = array( 'width'=>$ZArr[0], 'height'=>$ZArr[1], 'title'=>$TBarr[2] ); }; }; }; }; $CMD="v4l2-ctl -d {$CS['mrl']} --list-ctrls-menu"; $Data = `$CMD`; $TArr = explode( "\n", $Data ); $Controls = array(); $MFlag = false; $MID = 0; $id = 0; foreach( $TArr as $R ){ $CL = trim( $R ); if( stripos( $CL, ':' ) !== false ){ $ctrl = array(); $RR = explode( ':', $CL ); $TArr=explode( ' ', $CL ); if( stripos( $CL, 'int' )!== false ){ $ctrl['type'] = 'slider'; $ctrl['name'] = trim( $TArr[0] ); $ctrl['name_cod'] = md5( $ctrl['name'] ); $ctrl['id'] = hexdec( $TArr[1] ); $TArr=explode( ' ', $RR[1] ); $TBrr = explode( '=', $TArr[1] ); $ctrl['min'] = intval( $TBrr[1] ); $TBrr = explode( '=', $TArr[2] ); $ctrl['max'] = intval( $TBrr[1] ); $TBrr = explode( '=', $TArr[3] ); $ctrl['step'] = intval( $TBrr[1] ); $TBrr = explode( '=', $TArr[5] ); $ctrl['value'] = intval( $TBrr[1] ); $MFlag = false; $Controls[$id] = $ctrl; $id++; } else if( stripos( $CL, 'bool' )!== false ){ $ctrl['type'] = 'checkbox'; $ctrl['name'] = trim( $TArr[0] ); $ctrl['name_cod'] = md5( $ctrl['name'] ); $ctrl['id'] = hexdec( $TArr[1] ); $TArr=explode( ' ', $RR[1] ); $TBrr = explode( '=', $TArr[2] ); $ctrl['value'] = intval( $TBrr[1] ); $MFlag = false; $Controls[$id] = $ctrl; $id++; } else if( stripos( $CL, 'menu' )!== false ){ $ctrl['type'] = 'combo'; $ctrl['name'] = trim( $TArr[0] ); $ctrl['name_cod'] = md5( $ctrl['name'] ); $ctrl['id'] = hexdec( $TArr[1] ); $TArr=explode( ' ', $RR[1] ); $TBrr = explode( '=', $TArr[4] ); $ctrl['value'] = intval( $TBrr[1] ); $MFlag = true; $MID = $id; $Controls[$id] = $ctrl; $id++; } else { if( $MFlag ){ $ZV = explode( ':', $CL ); $cmi= array(); $cmi['id']=intval( $ZV[0] ); $cmi['text']=trim( $ZV[1] ); $Controls[$MID]['data'][]=$cmi; }; }; }; }; $CCC = 0; $OUT = array(); if( count( $Formats ) ){ $ll = "{ xtype: 'combo', fieldLabel: '". $Labels->GetLabel('_FRAME_FORMAT_') ."', lazyRender: true, id: 'frmt_id', name: 'frame_format', mode: 'local', forceSelection: true, triggerAction: 'all', editable: false, disableKeyFilter: true, listeners:{ change: function(t,n,o){ changeASS( {$STREAM }, 'frmt_id'); }}, store: new Ext.data.ArrayStore({ fields: ['fmt','fmt_txt'], data: ["; $cl = array(); foreach( $Formats as $F ){ $cl[]="[{$F['id']},\"{$F['desc']}\"]"; }; $ll .= implode( ',', $cl ); $ll .="] }), valueField: 'fmt', displayField: 'fmt_txt' }"; $OUT[$CCC] = $ll; $CCC++; }; if( count( $Sizes ) ){ $ll = "{ xtype: 'combo', fieldLabel: '". $Labels->GetLabel('_FRAME_SIZE_') ."', lazyRender: true, id: 'sizes_id', name: 'frame_size', mode: 'local', forceSelection: true, triggerAction: 'all', editable: false, disableKeyFilter: true, listeners:{ change: function(t,n,o){ changeASS( {$STREAM }, 'sizes_id'); }}, store: new Ext.data.ArrayStore({ fields: ['size','size_txt'], data: ["; $cl = array(); $id = 0; $csid = 0; foreach( $Sizes as $Key=>$Val ){ if( $Val['width'] == $CS['img_width'] && $Val['height'] == $CS['img_height'] ) $csid = $Key;//$id; //$cl[]="[{$id},\"{$Key}\"]"; $cl[]="[\"{$Key}\",\"{$Key}\"]"; $id++; }; $ll .= implode( ',', $cl ); $ll .="] }), valueField: 'size', displayField: 'size_txt', value: '{$csid}' }"; $OUT[$CCC] = $ll; $CCC++; }; //print_r( $Controls ); if( count( $Controls )){ foreach( $Controls as $CC ){ $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']}' ); } }, "; switch( $CC['type'] ){ case 'slider':{ $ll .= "minValue: {$CC['min']}, maxValue: {$CC['max']}, width: 235 }"; break; }; case 'checkbox':{ if( $CC['value'] == 1 ){ $ll .= "checked: true }"; } else { $ll .= "checked: false }"; }; break; }; case 'combo':{ $ll .= "lazyRender: true, mode: 'local', forceSelection: true, triggerAction: 'all', editable: false, disableKeyFilter: true, store: new Ext.data.ArrayStore({ fields: ['{$CC['id']}_id','{$CC['id']}_txt'], data: ["; $cl = array(); foreach( $CC['data'] as $D ) $cl[]="[{$D['id']},\"{$D['text']}\"]"; $ll .= implode(',', $cl ); $ll .="] }), valueField: '{$CC['id']}_id', displayField: '{$CC['id']}_txt' }"; break; }; }; $OUT[$CCC] = $ll; $CCC++; }; }; //https://www.waveshare.com/wiki/SIM7600E-H_4G_HAT $CCA = implode( ',', $OUT ); echo "{ xtype: 'form', id:'an_str_edit', frame: false, autoScroll: true, border: false, layout: 'form', labelAlign: 'right', labelWidth: 150, items: [". $CCA ."] }"; } else { echo "{ xtype: 'panel', html: '
Incorrect Stream
'}"; }; } else { echo "{ xtype: 'panel', html: '
Incorrect Stream
'}"; }; 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 .= '
Address IPv4: '.$I['address'].'
Net Mask: '.$I['mask']; } else { $NetInfo .= '
Address IPv6: '.$I['address'].'
Net Mask: '.$I['mask']; }; }; $R_nfo = 'Mode: '.$MS.'
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 .= '
Address IPv4: '.$I['address'].'
Net Mask: '.$I['mask']; } else { $NetInfo .= '
Address IPv6: '.$I['address'].'
Net Mask: '.$I['mask']; }; }; $R_nfo = 'Mode: '.$MS.'
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 .= '
Address IPv4: '.$I['address'].'
Net Mask: '.$I['mask']; } else { $NetInfo .= '
Address IPv6: '.$I['address'].'
Net Mask: '.$I['mask']; }; }; $R_nfo = 'Mode: '.$MS.'
MAC: '.$CI['mac'] . $NetInfo; $R_image = 'wifi-modem-Vista-icon.png'; break; }; } else { echo '{ xtype: \'panel\', html: \'Node '.$_POST['NODE'].' Loadded\'}'; }; } else { header('location: /'); }; ?>