Add validate serverBind, save settings

This commit is contained in:
billz 2020-08-05 18:57:42 +01:00
parent eeccb19b35
commit b0ebd7bf00

View file

@ -78,32 +78,35 @@ function DisplaySystem()
if (!RASPI_MONITOR_ENABLED) { if (!RASPI_MONITOR_ENABLED) {
if (isset($_POST['SaveServerSettings'])) { if (isset($_POST['SaveServerSettings'])) {
// Save server port $good_input = true;
// Validate server port
if (isset($_POST['serverPort'])) { if (isset($_POST['serverPort'])) {
if (strlen($_POST['serverPort']) > 4 || !is_numeric($_POST['serverPort'])) { if (strlen($_POST['serverPort']) > 4 || !is_numeric($_POST['serverPort'])) {
$status->addMessage('Invalid value for port number', 'danger'); $status->addMessage('Invalid value for port number', 'danger');
$good_input = false;
} else { } else {
$serverPort = escapeshellarg($_POST['serverPort']); $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) { foreach ($return as $line) {
$status->addMessage($line, 'info'); $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'])) { if (isset($_POST['system_reboot'])) {
$status->addMessage("System Rebooting Now!", "warning", false); $status->addMessage("System Rebooting Now!", "warning", false);
$result = shell_exec("sudo /sbin/reboot"); $result = shell_exec("sudo /sbin/reboot");