5 changed files with 42 additions and 48 deletions
-
18ajax/networking/gen_int_config.php
-
7ajax/networking/get_all_interfaces.php
-
6ajax/networking/get_int_config.php
-
8ajax/networking/get_ip_summary.php
-
51ajax/networking/save_int_config.php
@ -1,7 +1,6 @@ |
|||
<?php |
|||
|
|||
require('../../includes/csrf.php'); |
|||
require('../../includes/csrf.php'); |
|||
|
|||
exec("ls /sys/class/net | grep -v lo", $interfaces); |
|||
echo json_encode($interfaces); |
|||
?>
|
|||
exec("ls /sys/class/net | grep -v lo", $interfaces); |
|||
echo json_encode($interfaces); |
@ -1,33 +1,34 @@ |
|||
<?php |
|||
|
|||
require('../../includes/csrf.php'); |
|||
require('../../includes/csrf.php'); |
|||
|
|||
include_once('../../includes/config.php'); |
|||
include_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']; |
|||
include_once('../../includes/config.php'); |
|||
include_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']; |
|||
|
|||
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']]; |
|||
} |
|||
$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']; |
|||
|
|||
if (write_php_ini($cfg, RASPI_CONFIG_NETWORKING.'/'.$file)) { |
|||
$jsonData = ['return'=>0,'output'=>['Successfully Updated Network Configuration']]; |
|||
} else { |
|||
$jsonData = ['return'=>2,'output'=>'Unable to detect interface']; |
|||
$jsonData = ['return'=>1,'output'=>['Error saving network configuration to file']]; |
|||
} |
|||
echo json_encode($jsonData); |
|||
?>
|
|||
} else { |
|||
$jsonData = ['return'=>2,'output'=>'Unable to detect interface']; |
|||
} |
|||
|
|||
echo json_encode($jsonData); |
Write
Preview
Loading…
Cancel
Save
Reference in new issue