*/ /** * All DokuWiki plugins to extend the admin function * need to inherit from this class **/ class admin_plugin_botmon extends AdminPlugin { /** * Return the path to the icon being displayed in the main admin menu. * * @return string full path to the icon file **/ public function getMenuIcon() { $plugin = $this->getPluginName(); return DOKU_PLUGIN . $plugin . '/img/admin.svg'; } /** * output appropriate html */ public function html() { global $conf; // spinner animation as SVG image: $svg = ''; $pluginPath = $conf['basedir'] . 'lib/plugins/' . $this->getPluginName(); /* Plugin Headline */ echo '

Bot Monitoring Plugin

'; if ($this->hasOldLogFiles()) { echo '
Note: There are old log files that can be deleted. Click here to run a delete script, or use cron to automatically delete them.
'; } echo '

Today

Loading …
Bot overview (page views)
Web metrics
Visitor logs
'; } /** * Check if there are old log files that can be deleted. * * @return bool true if there are old log files, false otherwise */ private function hasOldLogFiles() { $today = gmdate('Y-m-d'); $yesterday = gmdate('Y-m-d', time() - 86400); // scan the log directory and delete all files except for today and yesterday: $dir = scandir(getcwd() . '/lib/plugins/botmon/logs'); foreach($dir as $file) { $fName = pathinfo($file, PATHINFO_BASENAME); $bName = strtok($fName, '.'); if ($bName == '' || $bName == 'logfiles') { // ignore } else if ($bName == $today || $bName == $yesterday) { // skip } else { return true; } } return false; } }