diff options
Diffstat (limited to 'mod/logrotate/start.php')
-rw-r--r-- | mod/logrotate/start.php | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/mod/logrotate/start.php b/mod/logrotate/start.php new file mode 100644 index 000000000..f9a9a0449 --- /dev/null +++ b/mod/logrotate/start.php @@ -0,0 +1,47 @@ +<?php + /** + * Elgg log rotator. + * + * @package ElggLogRotate + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Curverider Ltd + * @copyright Curverider Ltd 2008 + * @link http://elgg.com/ + */ + + /** + * Initialise the plugin. + * + */ + function logrotate_init() + { + $period = get_plugin_setting('period','logrotate'); + switch ($period) + { + case 'weekly': + case 'monthly' : + case 'yearly' : + break; + default: $period = 'monthly'; + } + + // Register cron hook + register_plugin_hook('cron', $period, 'logrotate_cron'); + } + + /** + * Trigger the log rotation. + * + */ + function logrotate_cron($hook, $entity_type, $returnvalue, $params) + { + $resulttext = elgg_echo("logrotate:logrotated"); + if (!archive_log()) + $resulttext = elgg_echo("logrotate:lognotrotated"); + + return $returnvalue . $resulttext; + } + + // Initialise plugin + register_elgg_event_handler('init','system','logrotate_init'); +?>
\ No newline at end of file |