raspap-webgui-mirror/ajax/logging/clearlog.php

21 lines
555 B
PHP
Raw Normal View History

2022-09-26 19:53:06 +00:00
<?php
2023-02-16 22:25:43 +00:00
require '../../includes/csrf.php';
2022-09-26 19:53:06 +00:00
require_once '../../includes/config.php';
require_once '../../src/RaspAP/Auth/HTTPAuth.php';
require_once '../../includes/authenticate.php';
2022-09-26 19:53:06 +00:00
require_once '../../includes/functions.php';
2022-09-27 09:46:59 +00:00
if (isset($_POST['logfile'])) {
$logfile = escapeshellarg($_POST['logfile']);
$valid = '/(\/var\/log|\/tmp)/';
2022-09-26 19:53:06 +00:00
if (preg_match($valid, $logfile)) {
// truncate requested log file
exec("sudo truncate -s 0 $logfile", $return);
} else {
$return = 1;
}
2022-09-26 19:53:06 +00:00
echo json_encode($return);
}