Pastoid

SpamPurge

The page you are looking at now is at this URL: http://pastoid.com/bm2

This paste was last updated on January 21, 2009 at 9:23 am.

Pasted Coderaw

<?php
 
/**
 * Spam Purge
 *
 * @version $Id$
 * @copyright 2009
 */
 
class SpamPurge extends Plugin
{
	function init(){
		return array (
			'name' => 'Spam Purge',
			'url' => 'http://habariproject.org/',
			'author' => 'Owen Winkler',
			'authorurl' => 'http://asymptomatic.net/',
			'version' => '1.0',
			'description' => 'Deletes spam comments older than a certain number of days',
			'license' => 'Apache License 2.0',
		);
 
	}
 
	function action_plugin_activation( $plugin_file ) {
		if( Plugins::id_from_file(__FILE__) == Plugins::id_from_file($plugin_file) ) {
			CronTab::add_daily_cron('spampurge', 'purge_spam', 'Deletes spam comments after a certain number of days.');
			Options::set('spampurge__days', 3);
		}
	}
 
	function filter_purge_spam()
	{
		$days = Options::get('spampurge__days');
 
		// This part doesn't work:
		$sql = "DELETE FROM {comments} c, {commentinfo} ci WHERE c.id = ci.comment_id AND c.date < ? AND c.status = ?";
		$oldest = time() - 86400 * $days;
 
		DB::query($sql, array($oldest, Comment::STATUS_SPAM));
	}
 
}
 
?>

Toggle wordwrap

Referring DomainHits
Unknown Referer 127
pastoid.com 3
search.live.com 2
Is this paste spam?
<Hide