Files
dokuwiki-plugin-botmon/cleanup.php
Sascha Leib 93a5b18bb1 Visitor logs
Enable showing visitor logs
2025-09-03 18:22:29 +02:00

27 lines
650 B
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<h1>BotMon Cleanup Script</h1>
<ul><?php
// get all files in the logs directory
$dir = scandir('logs');
$today = gmdate('Y-m-d');
$yesterday = gmdate('Y-m-d', time() - 86400);
foreach($dir as $file) {
$fName = pathinfo($file, PATHINFO_BASENAME);
$bName = strtok($fName, '.');
echo "<li>File “{$fName} ";
if ($bName == '' || $bName == 'logfiles') {
echo " <em>ignored</em></li>";
} else if ($bName == $today || $bName == $yesterday) {
echo " <em>skipped</em></li>";
} else {
if (unlink('logs/' . $file)) {
echo "deleted.</li>";
} else {
echo " <strong>not deleted!</strong></li>";
}
}
}
?></ul>