Add log size limit to Advanced tab, validate + set session var

This commit is contained in:
billz 2023-11-28 10:03:58 +00:00
parent cf53c575ff
commit 2a5241fb62
2 changed files with 19 additions and 2 deletions

View file

@ -39,6 +39,16 @@ function DisplaySystem(&$extraFooterScripts)
$serverBind = escapeshellarg($_POST['serverBind']); $serverBind = escapeshellarg($_POST['serverBind']);
} }
} }
// Validate log limit
if (isset($_POST['logLimit'])) {
if ( strlen($_POST['logLimit']) > 4 || !is_numeric($_POST['logLimit']) ) {
$status->addMessage('Invalid value for log size limit', 'danger');
$good_input = false;
} else {
$_SESSION['log_limit'] = intval($_POST['logLimit']);
$status->addMessage(sprintf(_('Changing log limit size to %s KB'), $_SESSION['log_limit']), 'info');
}
}
// Save settings // Save settings
if ($good_input) { if ($good_input) {
exec("sudo /etc/raspap/lighttpd/configport.sh $serverPort $serverBind " .RASPI_LIGHTTPD_CONFIG. " ".$_SERVER['SERVER_NAME'], $return); exec("sudo /etc/raspap/lighttpd/configport.sh $serverPort $serverBind " .RASPI_LIGHTTPD_CONFIG. " ".$_SERVER['SERVER_NAME'], $return);
@ -141,6 +151,7 @@ function DisplaySystem(&$extraFooterScripts)
$extraFooterScripts[] = array('src'=>'dist/huebee/huebee.pkgd.min.js', 'defer'=>false); $extraFooterScripts[] = array('src'=>'dist/huebee/huebee.pkgd.min.js', 'defer'=>false);
$extraFooterScripts[] = array('src'=>'app/js/huebee.js', 'defer'=>false); $extraFooterScripts[] = array('src'=>'app/js/huebee.js', 'defer'=>false);
$logLimit = isset($_SESSION['log_limit']) ? $_SESSION['log_limit'] : RASPI_LOG_SIZE_LIMIT;
echo renderTemplate("system", compact( echo renderTemplate("system", compact(
"arrLocales", "arrLocales",
@ -166,6 +177,7 @@ function DisplaySystem(&$extraFooterScripts)
"hostapd_status", "hostapd_status",
"hostapd_led", "hostapd_led",
"themes", "themes",
"selectedTheme" "selectedTheme",
"logLimit"
)); ));
} }

View file

@ -16,10 +16,15 @@
<input type="text" class="form-control" name="serverBind" value="<?php echo htmlspecialchars($serverBind, ENT_QUOTES); ?>" /> <input type="text" class="form-control" name="serverBind" value="<?php echo htmlspecialchars($serverBind, ENT_QUOTES); ?>" />
</div> </div>
</div> </div>
<div class="row">
<div class="form-group col-md-6">
<label for="code"><?php echo _("Diagnostic log size limit (KB)") ;?></label>
<input type="text" class="form-control" name="logLimit" value="<?php echo htmlspecialchars($logLimit, ENT_QUOTES); ?>" />
</div>
</div>
<input type="submit" class="btn btn-outline btn-primary" name="SaveServerSettings" value="<?php echo _("Save settings"); ?>" /> <input type="submit" class="btn btn-outline btn-primary" name="SaveServerSettings" value="<?php echo _("Save settings"); ?>" />
<input type="submit" class="btn btn-warning" name="RestartLighttpd" value="<?php echo _("Restart lighttpd"); ?>" /> <input type="submit" class="btn btn-warning" name="RestartLighttpd" value="<?php echo _("Restart lighttpd"); ?>" />
</form> </form>
<?php endif ?> <?php endif ?>
</div> </div>