mirror of
https://github.com/RaspAP/raspap-webgui.git
synced 2024-11-25 09:00:25 +00:00
Remove networking dhcp config (deprecated)
This commit is contained in:
parent
495f33eaa3
commit
a21009e049
5 changed files with 14 additions and 181 deletions
|
@ -1,48 +0,0 @@
|
|||
<?php
|
||||
|
||||
require '../../includes/csrf.php';
|
||||
|
||||
require_once '../../includes/config.php';
|
||||
require_once '../../includes/functions.php';
|
||||
|
||||
if (isset($_POST['generate'])) {
|
||||
$cnfNetworking = array_diff(scandir(RASPI_CONFIG_NETWORKING, 1), array('..','.','dhcpcd.conf','defaults'));
|
||||
$cnfNetworking = array_combine($cnfNetworking, $cnfNetworking);
|
||||
$strConfFile = file_get_contents(RASPI_CONFIG_NETWORKING.'/defaults')."\n";
|
||||
foreach ($cnfNetworking as $index => $file) {
|
||||
if ($index != "defaults") {
|
||||
$cnfFile = parse_ini_file(RASPI_CONFIG_NETWORKING.'/'.$file, false, INI_SCANNER_RAW);
|
||||
if ($cnfFile['static'] === 'true') {
|
||||
$strConfFile .= "#Static IP configured for ".$cnfFile['interface']."\n";
|
||||
$strConfFile .= "interface ".$cnfFile['interface']."\n";
|
||||
if (isset($cnfFile['metric'])) {
|
||||
$strConfFile .= "metric ".$cnfFile['metric']."\n";
|
||||
}
|
||||
$strConfFile .= "static ip_address=".$cnfFile['ip_address']."\n";
|
||||
$strConfFile .= "static routers=".$cnfFile['routers']."\n";
|
||||
$strConfFile .= "static domain_name_servers=".$cnfFile['domain_name_server']."\n\n";
|
||||
} elseif ($cnfFile['static'] === 'false' && $cnfFile['failover'] === 'true') {
|
||||
$strConfFile .= "#Failover static IP configured for ".$cnfFile['interface']."\n";
|
||||
$strConfFile .= "profile static_".$cnfFile['interface']."\n";
|
||||
$strConfFile .= "static ip_address=".$cnfFile['ip_address']."\n";
|
||||
$strConfFile .= "static routers=".$cnfFile['routers']."\n";
|
||||
$strConfFile .= "static domain_name_servers=".$cnfFile['domain_name_server']."\n\n";
|
||||
$strConfFile .= "interface ".$cnfFile['interface']."\n";
|
||||
if (isset($cnfFile['metric'])) {
|
||||
$strConfFile .= "metric ".$cnfFile['metric']."\n";
|
||||
}
|
||||
$strConfFile .= "fallback static_".$cnfFile['interface']."\n\n";
|
||||
} else {
|
||||
$strConfFile .= "#DHCP configured for ".pathinfo($file, PATHINFO_FILENAME)."\n\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (file_put_contents(RASPI_CONFIG_NETWORKING.'/dhcpcd.conf', $strConfFile)) {
|
||||
exec('sudo /bin/cp '.RASPI_CONFIG_NETWORKING.'/dhcpcd.conf '.RASPI_DHCPCD_CONFIG);
|
||||
$output = ['return'=>0,'output'=>'Settings successfully applied'];
|
||||
} else {
|
||||
$output = ['return'=>2,'output'=>'Unable to write to apply settings'];
|
||||
}
|
||||
echo json_encode($output);
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
<?php
|
||||
|
||||
require '../../includes/csrf.php';
|
||||
|
||||
require_once '../../includes/config.php';
|
||||
require_once '../../includes/functions.php';
|
||||
|
||||
|
||||
if (isset($_POST['interface'])) {
|
||||
$int = preg_replace('/[^a-z0-9]/', '', $_POST['interface']);
|
||||
if (!file_exists(RASPI_CONFIG_NETWORKING.'/'.$int.'.ini')) {
|
||||
touch(RASPI_CONFIG_NETWORKING.'/'.$int.'.ini');
|
||||
}
|
||||
|
||||
$intConfig = parse_ini_file(RASPI_CONFIG_NETWORKING.'/'.$int.'.ini', false, INI_SCANNER_RAW);
|
||||
$jsonData = ['return'=>1,'output'=>['intConfig'=>$intConfig]];
|
||||
echo json_encode($jsonData);
|
||||
|
||||
// Todo - get dhcp lease information from `dhcpcd -U eth0` ? maybe ?
|
||||
} else {
|
||||
$jsonData = ['return'=>2,'output'=>['Error getting data']];
|
||||
echo json_encode($jsonData);
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
<?php
|
||||
|
||||
require '../../includes/csrf.php';
|
||||
|
||||
require_once '../../includes/config.php';
|
||||
require_once '../../includes/functions.php';
|
||||
|
||||
if (isset($_POST['interface'])) {
|
||||
$int = $_POST['interface'];
|
||||
$cfg = [];
|
||||
$file = $int.".ini";
|
||||
$ip = $_POST[$int.'-ipaddress'];
|
||||
$netmask = mask2cidr($_POST[$int.'-netmask']);
|
||||
$dns1 = $_POST[$int.'-dnssvr'];
|
||||
$dns2 = $_POST[$int.'-dnssvralt'];
|
||||
|
||||
|
||||
$cfg['interface'] = $int;
|
||||
$cfg['routers'] = $_POST[$int.'-gateway'];
|
||||
$cfg['ip_address'] = $ip."/".$netmask;
|
||||
$cfg['domain_name_server'] = $dns1." ".$dns2;
|
||||
$cfg['static'] = $_POST[$int.'-static'];
|
||||
$cfg['failover'] = $_POST[$int.'-failover'];
|
||||
$cfg['metric'] = $_POST[$int.'-metric'];
|
||||
|
||||
if (write_php_ini($cfg, RASPI_CONFIG_NETWORKING.'/'.$file)) {
|
||||
$jsonData = ['return'=>0,'output'=>['Successfully Updated Network Configuration']];
|
||||
} else {
|
||||
$jsonData = ['return'=>1,'output'=>['Error saving network configuration to file']];
|
||||
}
|
||||
} else {
|
||||
$jsonData = ['return'=>2,'output'=>'Unable to detect interface'];
|
||||
}
|
||||
|
||||
echo json_encode($jsonData);
|
|
@ -49,74 +49,6 @@ function setupTabs() {
|
|||
});
|
||||
}
|
||||
|
||||
function loadCurrentSettings(strInterface) {
|
||||
$.post('ajax/networking/get_int_config.php',{interface:strInterface},function(data){
|
||||
jsonData = JSON.parse(data);
|
||||
$.each(jsonData['output'],function(i,v) {
|
||||
var int = v['interface'];
|
||||
$.each(v,function(i2,v2) {
|
||||
switch(i2) {
|
||||
case "static":
|
||||
if(v2 == 'true') {
|
||||
$('#'+int+'-static').click();
|
||||
$('#'+int+'-nofailover').click();
|
||||
} else {
|
||||
$('#'+int+'-dhcp').click();
|
||||
}
|
||||
break;
|
||||
case "failover":
|
||||
if(v2 === 'true') {
|
||||
$('#'+int+'-failover').click();
|
||||
} else {
|
||||
$('#'+int+'-nofailover').click();
|
||||
}
|
||||
break;
|
||||
case "ip_address":
|
||||
var arrIPNetmask = v2.split('/');
|
||||
$('#'+int+'-ipaddress').val(arrIPNetmask[0]);
|
||||
$('#'+int+'-netmask').val(createNetmaskAddr(arrIPNetmask[1]));
|
||||
break;
|
||||
case "routers":
|
||||
$('#'+int+'-gateway').val(v2);
|
||||
break;
|
||||
case "domain_name_server":
|
||||
svrsDNS = v2.split(" ");
|
||||
$('#'+int+'-dnssvr').val(svrsDNS[0]);
|
||||
$('#'+int+'-dnssvralt').val(svrsDNS[1]);
|
||||
break;
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function saveNetworkSettings(int) {
|
||||
var frmInt = $('#frm-'+int).find(':input');
|
||||
var arrFormData = {};
|
||||
$.each(frmInt,function(i3,v3){
|
||||
if($(v3).attr('type') == 'radio') {
|
||||
arrFormData[$(v3).attr('id')] = $(v3).prop('checked');
|
||||
} else {
|
||||
arrFormData[$(v3).attr('id')] = $(v3).val();
|
||||
}
|
||||
});
|
||||
arrFormData['interface'] = int;
|
||||
$.post('ajax/networking/save_int_config.php',arrFormData,function(data){
|
||||
var jsonData = JSON.parse(data);
|
||||
$('#msgNetworking').html(msgShow(jsonData['return'],jsonData['output']));
|
||||
});
|
||||
}
|
||||
|
||||
function applyNetworkSettings() {
|
||||
var int = $(this).data('int');
|
||||
arrFormData = {};
|
||||
arrFormData['generate'] = '';
|
||||
$.post('ajax/networking/gen_int_config.php',arrFormData,function(data){
|
||||
var jsonData = JSON.parse(data);
|
||||
$('#msgNetworking').html(msgShow(jsonData['return'],jsonData['output']));
|
||||
});
|
||||
}
|
||||
|
||||
$(document).on("click", ".js-add-dhcp-static-lease", function(e) {
|
||||
e.preventDefault();
|
||||
var container = $(".js-new-dhcp-static-lease");
|
||||
|
@ -240,6 +172,10 @@ function loadWifiStations(refresh) {
|
|||
}
|
||||
$(".js-reload-wifi-stations").on("click", loadWifiStations(true));
|
||||
|
||||
/*
|
||||
Populates the DHCP server form fields
|
||||
Option toggles are set dynamically depending on the loaded configuration
|
||||
*/
|
||||
function loadInterfaceDHCPSelect() {
|
||||
var iface = $('#cbxdhcpiface').val();
|
||||
$.get('ajax/networking/get_netcfg.php?iface='+iface,function(data){
|
||||
|
@ -258,6 +194,7 @@ function loadInterfaceDHCPSelect() {
|
|||
$('#no-resolv')[0].checked = jsonData.upstreamServersEnabled;
|
||||
$('#cbxdhcpupstreamserver').val(jsonData.upstreamServers[0]);
|
||||
$('#txtmetric').val(jsonData.Metric);
|
||||
|
||||
if (jsonData.StaticIP !== null && jsonData.StaticIP !== '' && !jsonData.FallbackEnabled) {
|
||||
$('#chkstatic').closest('.btn').button('toggle');
|
||||
$('#chkstatic').closest('.btn').button('toggle').blur();
|
||||
|
@ -269,15 +206,23 @@ function loadInterfaceDHCPSelect() {
|
|||
$('#chkdhcp').blur();
|
||||
$('#chkfallback').prop('disabled', false);
|
||||
}
|
||||
if (jsonData.FallbackEnabled) {
|
||||
if (jsonData.FallbackEnabled || $('#chkdhcp').is(':checked')) {
|
||||
$('#dhcp-iface').prop('disabled', true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function setDHCPToggles(state) {
|
||||
if ($('#chkfallback').is(':checked') && state) {
|
||||
$('#chkfallback').prop('checked', state);
|
||||
}
|
||||
if ($('#dhcp-iface').is(':checked') && !state) {
|
||||
$('#dhcp-iface').prop('checked', state);
|
||||
}
|
||||
|
||||
$('#chkfallback').prop('disabled', state);
|
||||
$('#dhcp-iface').prop('disabled', !state);
|
||||
//$('#dhcp-iface').prop('checked', state);
|
||||
}
|
||||
|
||||
function loadChannel() {
|
||||
|
|
|
@ -18,12 +18,6 @@
|
|||
// defaults to false
|
||||
$bridgedEnabled = $arrHostapdConf['BridgedEnable'];
|
||||
?>
|
||||
<?php if (!$bridgedEnabled) : // no interface details when bridged ?>
|
||||
<?php foreach ($interfaces as $if): ?>
|
||||
<?php $if_quoted = htmlspecialchars($if, ENT_QUOTES) ?>
|
||||
<li role="presentation" class="nav-item"><a class="nav-link" href="#<?php echo $if_quoted ?>" aria-controls="<?php echo $if_quoted ?>" role="tab" data-toggle="tab"><?php echo $if_quoted ?></a></li>
|
||||
<?php endforeach ?>
|
||||
<?php endif ?>
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
<div role="tabpanel" class="tab-pane active" id="summary">
|
||||
|
|
Loading…
Reference in a new issue