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';
|
2024-03-11 17:52:34 +00:00
|
|
|
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'])) {
|
2024-03-11 17:52:34 +00:00
|
|
|
$logfile = escapeshellarg($_POST['logfile']);
|
|
|
|
$valid = '/(\/var\/log|\/tmp)/';
|
2022-09-26 19:53:06 +00:00
|
|
|
|
2024-03-11 17:52:34 +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);
|
|
|
|
}
|