Skip to content
Snippets Groups Projects
Commit 53cfa13f authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

experimen tell: delete server logs

parent 2a68fee7
No related branches found
No related tags found
1 merge request!18OP#7365 PHP-8.1 - Upgrade - cronlog Viewer (monitors.ascii)https://projects.iml.unibe.ch/work_packages/7365
......@@ -66,6 +66,10 @@ class cronlogrenderer extends cronlog
return '<div class="accessandage">'
. sprintf($this->t("request-time"), date("Y-m-d H:i:s")) . '<br>'
. sprintf($this->t("last-entry"), $sAge)
.($iAge > 60*24
? " <a href=\"?deleteserverlogs=$this->_sActiveServer\" class=\"btn btn-danger\">Delete server</a>"
: ''
)
. '</div>'
;
}
......@@ -594,7 +598,7 @@ class cronlogrenderer extends cronlog
var timeline = new vis.Timeline(container, items, options);
// set focus to newest jobs
timeline.moveTo("'.date("Y-m-d H:i:s", time()-60*60*24*4).'");
// timeline.moveTo("'.date("Y-m-d H:i:s", time()-60*60*24*4).'");
// fix: some timelines do not properly work ... but I make them visible
$(\'#' . $sDivId . ' .vis-timeline\').css(\'visibility\', \'visible\');
......
......@@ -147,6 +147,10 @@ class cronlog
$this->_sDataDir = str_replace("__APPDIR__", dirname(dirname(__FILE__)), $this->_sDataDir);
$this->_sDataDir = str_replace('\\', '/', $this->_sDataDir);
if (isset($_GET['deleteserverlogs']) && $_GET['deleteserverlogs']){
$this->_deleteServerlogs($_GET['deleteserverlogs']);
}
$this->getServers();
}
......@@ -155,6 +159,32 @@ class cronlog
// ----------------------------------------------------------------------
protected function _deleteServerlogs(string $sServer): bool
{
$dirCronlog="$this->_sDataDir/$sServer";
if (! is_dir($dirCronlog)) {
// throw new InvalidArgumentException("$dirCronlog must be a directory");
return false;
}
if (substr($dirCronlog, strlen($dirCronlog) - 1, 1) != '/') {
$dirCronlog .= '/';
}
$files = array_merge(
glob($dirCronlog . '*', GLOB_MARK),
glob($this->_getCacheDir() . "/*$sServer", GLOB_MARK)
);
foreach ($files as $file) {
/*
if (is_dir($file)) {
deleteDir($file);
} else {
*/
@unlink($file);
//}
}
return @rmdir($dirCronlog);
}
/**
* chaching: get the full path of directory for caching
* @return string
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment