Allow viewing of past logs.

Add a command-line PHP script for rotation in cron.
This commit is contained in:
Richard Underwood 2016-08-24 14:19:52 +01:00
parent 56c1789b30
commit f081d96b0c
4 changed files with 88 additions and 9 deletions

View file

@ -24,10 +24,21 @@ switch ($_GET['action']) {
case "list":
global $logging;
if ($logging !== TRUE)
if ($logging !== TRUE) {
jtable_respond(null, 'error', 'Logging is disabled');
break;
}
$entries=getlogs();
if(!empty($_POST['logfile'])) {
if(preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}-[0-9]{6}\.json/',$_POST['logfile']) == 1) {
$entries=json_decode(file_get_contents($logsdirectory . "/" . $_POST['logfile']),true);
} else {
jtable_respond(null, 'error', "Can't find log file");
break;
}
} else {
$entries=getlogs();
}
if(!empty($_POST['user'])) {
$entries=array_filter($entries,