mirror of
https://github.com/billz/raspap-webgui.git
synced 2025-03-01 10:31:47 +00:00
Remove networking dhcp config (deprecated)
This commit is contained in:
@@ -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);
|
Reference in New Issue
Block a user