2017-10-27 20:40:30 +02:00
|
|
|
<?php
|
2019-08-06 21:34:58 +02:00
|
|
|
|
2020-02-15 18:57:46 +01:00
|
|
|
require '../../includes/csrf.php';
|
2019-08-06 21:34:58 +02:00
|
|
|
|
2020-02-15 18:57:46 +01:00
|
|
|
require_once '../../includes/config.php';
|
|
|
|
require_once '../../includes/functions.php';
|
2017-10-27 20:40:30 +02:00
|
|
|
|
2019-08-12 12:02:40 +02:00
|
|
|
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'];
|
2017-10-27 20:40:30 +02:00
|
|
|
|
2017-10-29 19:21:34 +01:00
|
|
|
|
2019-08-12 12:02:40 +02:00
|
|
|
$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']];
|
2017-10-27 20:40:30 +02:00
|
|
|
} else {
|
2019-08-12 12:02:40 +02:00
|
|
|
$jsonData = ['return'=>1,'output'=>['Error saving network configuration to file']];
|
2017-10-27 20:40:30 +02:00
|
|
|
}
|
2019-08-12 12:02:40 +02:00
|
|
|
} else {
|
|
|
|
$jsonData = ['return'=>2,'output'=>'Unable to detect interface'];
|
|
|
|
}
|
|
|
|
|
|
|
|
echo json_encode($jsonData);
|