add('name', PLUGIN_EVENT_DBCLEAN_NAME); $propbag->add('description', PLUGIN_EVENT_DBCLEAN_DESC); $propbag->add('stackable', false); $propbag->add('author', 'Malte Paskuda, Matthias Mees'); $propbag->add('version', '0.2.8'); $propbag->add('requirements', array( 'serendipity' => '0.8' )); $propbag->add('event_hooks', array( 'backend_sidebar_admin' => true, 'backend_sidebar_entries_event_display_dbclean' => true, 'external_plugin' => true, 'css_backend' => true, 'cronjob' => true ) ); $propbag->add('groups', array('BACKEND_FEATURES')); $propbag->add('configuration', array('cronjob', 'days')); } function generate_content(&$title) { $title = $this->title; } function introspect_config_item($name, &$propbag) { switch($name) { case 'cronjob': if (class_exists('serendipity_event_cronjob')) { $propbag->add('type', 'select'); $propbag->add('name', PLUGIN_EVENT_DBCLEAN_CRONJOB); $propbag->add('description', ''); $propbag->add('default', 'daily'); $propbag->add('select_values', serendipity_event_cronjob::getValues()); } break; case 'days': $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_EVENT_DBCLEAN_MENU_KEEP . ' (' . DAYS . ')'); $propbag->add('description', ''); $propbag->add('default', '30'); break; default: return false; } return true; } function event_hook($event, &$bag, &$eventData, $addData = null) { global $serendipity; $hooks = &$bag->get('event_hooks'); if (isset($hooks[$event])) { switch($event) { case 'cronjob': if ($this->get_config('cronjob') == $eventData) { serendipity_event_cronjob::log('DBClean', 'plugin'); $days = (int)$this->get_config('days'); if ($days > 0) { $this->cleanDB('cronjoblog', $days); $this->cleanDB('spamblocklog', $days); $this->cleanDB('spamblock_htaccess', $days); $this->cleanDB('visitors', $days); $this->cleanDB('referrers', $days); $this->cleanDB('exits', $days); } } return true; break; case 'external_plugin': switch ($eventData) { case 'dbclean': if (! (serendipity_checkPermission('siteConfiguration') || serendipity_checkPermission('blogConfiguration'))) { return; } $days = $_REQUEST['days']; if (is_numeric($days)) { if (isset($_REQUEST['cronjoblog'])) { $this->cleanDB('cronjoblog', $days); } if (isset($_REQUEST['spamblocklog'])) { $this->cleanDB('spamblocklog', $days); } if (isset($_REQUEST['spamblock_htaccess'])) { $this->cleanDB('spamblock_htaccess', $days); } if (isset($_REQUEST['visitors'])) { $this->cleanDB('visitors', $days); } if (isset($_REQUEST['referrers'])) { $this->cleanDB('referrers', $days); } if (isset($_REQUEST['exits'])) { $this->cleanDB('exits', $days); } } #redirect the user back to the menu echo ''; return true; break; } return true; break; case 'backend_sidebar_admin': if ($serendipity['version'][0] == '1') { echo '