diff --git a/ajax/networking/gen_int_config.php b/ajax/networking/gen_int_config.php new file mode 100644 index 00000000..2cfdd4c5 --- /dev/null +++ b/ajax/networking/gen_int_config.php @@ -0,0 +1,42 @@ +$file) { + if($index != "defaults") { + $cnfFile = parse_ini_file(RASPI_CONFIG_NETWORKING.'/'.$file); + if($cnfFile['static'] === 'true') { + $strConfFile .= "interface ".$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"; + } elseif($cnfFile['static'] === 'false' && $cnfFile['failover'] === 'true') { + $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"; + $strConfFile .= "fallback static_".$cnfFile['interface']."\n\n"; + } else { + $strConfFile .= "#DHCP configured for ".$cnfFile['interface']."\n\n"; + } + } else { + $strConfFile .= file_get_contents(RASPI_CONFIG_NETWORKING.'/'.$index)."\n\n"; + } + } + + if(file_put_contents(RASPI_CONFIG_NETWORKING.'/dhcpcd.conf',$strConfFile)) { + exec('sudo /bin/cp /etc/raspap/networking/dhcpcd.conf /etc/dhcpcd.conf'); + $output = ['return'=>0,'output'=>'Settings successfully applied']; + } else { + $output = ['return'=>2,'output'=>'Unable to write to apply settings']; + } + echo json_encode($output); +} + +?> diff --git a/ajax/networking/get_all_interfaces.php b/ajax/networking/get_all_interfaces.php new file mode 100644 index 00000000..432d0a5d --- /dev/null +++ b/ajax/networking/get_all_interfaces.php @@ -0,0 +1,4 @@ + diff --git a/ajax/networking/get_int_config.php b/ajax/networking/get_int_config.php new file mode 100644 index 00000000..59b3a762 --- /dev/null +++ b/ajax/networking/get_int_config.php @@ -0,0 +1,24 @@ +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); +} + +?> diff --git a/ajax/networking/get_ip_summary.php b/ajax/networking/get_ip_summary.php new file mode 100644 index 00000000..cd42f575 --- /dev/null +++ b/ajax/networking/get_ip_summary.php @@ -0,0 +1,15 @@ +$intResult,'output'=>$intOutput]; + echo json_encode($jsonData); +} else { + $jsonData = ['return'=>2,'output'=>['Error getting data']]; + echo json_encode($jsonData); +} + +?> diff --git a/ajax/networking/save_int_config.php b/ajax/networking/save_int_config.php new file mode 100644 index 00000000..77fcd865 --- /dev/null +++ b/ajax/networking/save_int_config.php @@ -0,0 +1,31 @@ +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); +?> diff --git a/includes/config.php b/includes/config.php new file mode 100644 index 00000000..58033aa4 --- /dev/null +++ b/includes/config.php @@ -0,0 +1,23 @@ + diff --git a/includes/functions.php b/includes/functions.php index ebcb8791..417190fc 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -55,7 +55,7 @@ function safefilerewrite($fileName, $dataToSave) { */ function CSRFToken() { ?> - + + +