mirror of
https://github.com/billz/raspap-webgui.git
synced 2023-10-10 13:37:24 +02:00
Processed with phpcs for PSR-2 coding standard
This commit is contained in:
parent
5b041e6899
commit
9cb564a15f
@ -5,19 +5,19 @@ require('../../includes/csrf.php');
|
|||||||
include_once('../../includes/config.php');
|
include_once('../../includes/config.php');
|
||||||
include_once('../../includes/functions.php');
|
include_once('../../includes/functions.php');
|
||||||
|
|
||||||
if(isset($_POST['generate'])) {
|
if (isset($_POST['generate'])) {
|
||||||
$cnfNetworking = array_diff(scandir(RASPI_CONFIG_NETWORKING, 1),array('..','.','dhcpcd.conf'));
|
$cnfNetworking = array_diff(scandir(RASPI_CONFIG_NETWORKING, 1), array('..','.','dhcpcd.conf'));
|
||||||
$cnfNetworking = array_combine($cnfNetworking,$cnfNetworking);
|
$cnfNetworking = array_combine($cnfNetworking, $cnfNetworking);
|
||||||
$strConfFile = "";
|
$strConfFile = "";
|
||||||
foreach($cnfNetworking as $index=>$file) {
|
foreach ($cnfNetworking as $index => $file) {
|
||||||
if($index != "defaults") {
|
if ($index != "defaults") {
|
||||||
$cnfFile = parse_ini_file(RASPI_CONFIG_NETWORKING.'/'.$file, false, INI_SCANNER_RAW);
|
$cnfFile = parse_ini_file(RASPI_CONFIG_NETWORKING.'/'.$file, false, INI_SCANNER_RAW);
|
||||||
if($cnfFile['static'] === 'true') {
|
if ($cnfFile['static'] === 'true') {
|
||||||
$strConfFile .= "interface ".$cnfFile['interface']."\n";
|
$strConfFile .= "interface ".$cnfFile['interface']."\n";
|
||||||
$strConfFile .= "static ip_address=".$cnfFile['ip_address']."\n";
|
$strConfFile .= "static ip_address=".$cnfFile['ip_address']."\n";
|
||||||
$strConfFile .= "static routers=".$cnfFile['routers']."\n";
|
$strConfFile .= "static routers=".$cnfFile['routers']."\n";
|
||||||
$strConfFile .= "static domain_name_servers=".$cnfFile['domain_name_server']."\n";
|
$strConfFile .= "static domain_name_servers=".$cnfFile['domain_name_server']."\n";
|
||||||
} elseif($cnfFile['static'] === 'false' && $cnfFile['failover'] === 'true') {
|
} elseif ($cnfFile['static'] === 'false' && $cnfFile['failover'] === 'true') {
|
||||||
$strConfFile .= "profile static_".$cnfFile['interface']."\n";
|
$strConfFile .= "profile static_".$cnfFile['interface']."\n";
|
||||||
$strConfFile .= "static ip_address=".$cnfFile['ip_address']."\n";
|
$strConfFile .= "static ip_address=".$cnfFile['ip_address']."\n";
|
||||||
$strConfFile .= "static routers=".$cnfFile['routers']."\n";
|
$strConfFile .= "static routers=".$cnfFile['routers']."\n";
|
||||||
@ -32,7 +32,7 @@ if(isset($_POST['generate'])) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(file_put_contents(RASPI_CONFIG_NETWORKING.'/dhcpcd.conf',$strConfFile)) {
|
if (file_put_contents(RASPI_CONFIG_NETWORKING.'/dhcpcd.conf', $strConfFile)) {
|
||||||
exec('sudo /bin/cp /etc/raspap/networking/dhcpcd.conf /etc/dhcpcd.conf');
|
exec('sudo /bin/cp /etc/raspap/networking/dhcpcd.conf /etc/dhcpcd.conf');
|
||||||
$output = ['return'=>0,'output'=>'Settings successfully applied'];
|
$output = ['return'=>0,'output'=>'Settings successfully applied'];
|
||||||
} else {
|
} else {
|
||||||
@ -40,5 +40,3 @@ if(isset($_POST['generate'])) {
|
|||||||
}
|
}
|
||||||
echo json_encode($output);
|
echo json_encode($output);
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
require('../../includes/csrf.php');
|
require('../../includes/csrf.php');
|
||||||
|
|
||||||
exec("ls /sys/class/net | grep -v lo", $interfaces);
|
exec("ls /sys/class/net | grep -v lo", $interfaces);
|
||||||
echo json_encode($interfaces);
|
echo json_encode($interfaces);
|
||||||
?>
|
|
||||||
|
@ -6,9 +6,9 @@ include_once('../../includes/config.php');
|
|||||||
include_once('../../includes/functions.php');
|
include_once('../../includes/functions.php');
|
||||||
|
|
||||||
|
|
||||||
if(isset($_POST['interface'])) {
|
if (isset($_POST['interface'])) {
|
||||||
$int = preg_replace('/[^a-z0-9]/', '', $_POST['interface']);
|
$int = preg_replace('/[^a-z0-9]/', '', $_POST['interface']);
|
||||||
if(!file_exists(RASPI_CONFIG_NETWORKING.'/'.$int.'.ini')) {
|
if (!file_exists(RASPI_CONFIG_NETWORKING.'/'.$int.'.ini')) {
|
||||||
touch(RASPI_CONFIG_NETWORKING.'/'.$int.'.ini');
|
touch(RASPI_CONFIG_NETWORKING.'/'.$int.'.ini');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -17,9 +17,7 @@ if(isset($_POST['interface'])) {
|
|||||||
echo json_encode($jsonData);
|
echo json_encode($jsonData);
|
||||||
|
|
||||||
// Todo - get dhcp lease information from `dhcpcd -U eth0` ? maybe ?
|
// Todo - get dhcp lease information from `dhcpcd -U eth0` ? maybe ?
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$jsonData = ['return'=>2,'output'=>['Error getting data']];
|
$jsonData = ['return'=>2,'output'=>['Error getting data']];
|
||||||
echo json_encode($jsonData);
|
echo json_encode($jsonData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,9 +4,9 @@ require('../../includes/csrf.php');
|
|||||||
|
|
||||||
include_once('../../includes/functions.php');
|
include_once('../../includes/functions.php');
|
||||||
|
|
||||||
if(isset($_POST['interface'])) {
|
if (isset($_POST['interface'])) {
|
||||||
$int = preg_replace('/[^a-z0-9]/','',$_POST['interface']);
|
$int = preg_replace('/[^a-z0-9]/', '', $_POST['interface']);
|
||||||
exec('ip a s '.$int,$intOutput,$intResult);
|
exec('ip a s '.$int, $intOutput, $intResult);
|
||||||
$intOutput = array_map('htmlentities', $intOutput);
|
$intOutput = array_map('htmlentities', $intOutput);
|
||||||
$jsonData = ['return'=>$intResult,'output'=>$intOutput];
|
$jsonData = ['return'=>$intResult,'output'=>$intOutput];
|
||||||
echo json_encode($jsonData);
|
echo json_encode($jsonData);
|
||||||
@ -14,5 +14,3 @@ if(isset($_POST['interface'])) {
|
|||||||
$jsonData = ['return'=>2,'output'=>['Error getting data']];
|
$jsonData = ['return'=>2,'output'=>['Error getting data']];
|
||||||
echo json_encode($jsonData);
|
echo json_encode($jsonData);
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
require('../../includes/csrf.php');
|
require('../../includes/csrf.php');
|
||||||
|
|
||||||
include_once('../../includes/config.php');
|
include_once('../../includes/config.php');
|
||||||
include_once('../../includes/functions.php');
|
include_once('../../includes/functions.php');
|
||||||
if(isset($_POST['interface'])) {
|
|
||||||
|
if (isset($_POST['interface'])) {
|
||||||
$int = $_POST['interface'];
|
$int = $_POST['interface'];
|
||||||
$cfg = [];
|
$cfg = [];
|
||||||
$file = $int.".ini";
|
$file = $int.".ini";
|
||||||
@ -21,13 +22,13 @@
|
|||||||
$cfg['static'] = $_POST[$int.'-static'];
|
$cfg['static'] = $_POST[$int.'-static'];
|
||||||
$cfg['failover'] = $_POST[$int.'-failover'];
|
$cfg['failover'] = $_POST[$int.'-failover'];
|
||||||
|
|
||||||
if(write_php_ini($cfg,RASPI_CONFIG_NETWORKING.'/'.$file)) {
|
if (write_php_ini($cfg, RASPI_CONFIG_NETWORKING.'/'.$file)) {
|
||||||
$jsonData = ['return'=>0,'output'=>['Successfully Updated Network Configuration']];
|
$jsonData = ['return'=>0,'output'=>['Successfully Updated Network Configuration']];
|
||||||
} else {
|
} else {
|
||||||
$jsonData = ['return'=>1,'output'=>['Error saving network configuration to file']];
|
$jsonData = ['return'=>1,'output'=>['Error saving network configuration to file']];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$jsonData = ['return'=>2,'output'=>'Unable to detect interface'];
|
$jsonData = ['return'=>2,'output'=>'Unable to detect interface'];
|
||||||
}
|
}
|
||||||
echo json_encode($jsonData);
|
|
||||||
?>
|
echo json_encode($jsonData);
|
||||||
|
Loading…
Reference in New Issue
Block a user