mirror of
https://github.com/billz/raspap-webgui.git
synced 2023-10-10 13:37:24 +02:00
Add validate serverBind, save settings
This commit is contained in:
parent
eeccb19b35
commit
b0ebd7bf00
@ -78,32 +78,35 @@ function DisplaySystem()
|
||||
|
||||
if (!RASPI_MONITOR_ENABLED) {
|
||||
if (isset($_POST['SaveServerSettings'])) {
|
||||
// Save server port
|
||||
$good_input = true;
|
||||
// Validate server port
|
||||
if (isset($_POST['serverPort'])) {
|
||||
if (strlen($_POST['serverPort']) > 4 || !is_numeric($_POST['serverPort'])) {
|
||||
$status->addMessage('Invalid value for port number', 'danger');
|
||||
$good_input = false;
|
||||
} else {
|
||||
$serverPort = escapeshellarg($_POST['serverPort']);
|
||||
exec("sudo /etc/raspap/lighttpd/configport.sh $serverPort " .RASPI_LIGHTTPD_CONFIG. " ".$_SERVER['SERVER_NAME'], $return);
|
||||
}
|
||||
}
|
||||
// Validate server bind address
|
||||
$serverBind = escapeshellarg('');
|
||||
if ($_POST['serverBind'] && $_POST['serverBind'] !== null ) {
|
||||
if (!filter_var($_POST['serverBind'], FILTER_VALIDATE_IP)) {
|
||||
$status->addMessage('Invalid value for bind address', 'danger');
|
||||
$good_input = false;
|
||||
} else {
|
||||
$serverBind = escapeshellarg($_POST['serverBind']);
|
||||
}
|
||||
}
|
||||
// Save settings
|
||||
if ($good_input) {
|
||||
exec("sudo /etc/raspap/lighttpd/configport.sh $serverPort $serverBind " .RASPI_LIGHTTPD_CONFIG. " ".$_SERVER['SERVER_NAME'], $return);
|
||||
foreach ($return as $line) {
|
||||
$status->addMessage($line, 'info');
|
||||
}
|
||||
}
|
||||
}
|
||||
// Save server bind address
|
||||
if (isset($_POST['serverBind'])) {
|
||||
if (!filter_var($_POST['serverBind'], FILTER_VALIDATE_IP)) {
|
||||
$status->addMessage('Invalid value for bind address', 'danger');
|
||||
} else {
|
||||
$serverBind = escapeshellarg($_POST['serverBind']);
|
||||
//exec("sudo /etc/raspap/lighttpd/configport.sh $serverPort " .RASPI_LIGHTTPD_CONFIG. " ".$_SERVER['SERVER_NAME'], $return);
|
||||
//foreach ($return as $line) {
|
||||
// $status->addMessage($line, 'info');
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (isset($_POST['system_reboot'])) {
|
||||
$status->addMessage("System Rebooting Now!", "warning", false);
|
||||
$result = shell_exec("sudo /sbin/reboot");
|
||||
|
Loading…
Reference in New Issue
Block a user