User Tools

Site Tools


res:plugins:fulk:commentipblacklist

CommentIPBlackList plugin

Add IP addresses to block in the $BLACKLIST_IP array. Save as plugin.commentipblacklist.php and put it under fp-plugins/commentipblacklist/, then enable via plugin panel

<?php
/*
Plugin Name: CommentIPBlackList
Plugin URI: http://www.kickball.com/dcgold
Description: Simple IP based blacklist plugin for blocking comments from specific IP addresses. Can be used to block some annoying posters. 
Author: G Fulk
Version: 1.0
*/
 
add_action('comment_validate', 'plugin_ipblacklist_validate');
 
function plugin_ipblacklist_validate($bool) {
 
	if (!$bool) return false;
 
	$BLACKLIST_IP = array(
		'0.0.0.0', '1.1.1.1'
	);
 
	$ip = utils_ipget();
 
	if ($ip) {
		if (in_array($ip, $BLACKLIST_IP)) {
			global $_FP_SMARTY;
			$_FP_SMARTY->assign('error', array('ERROR: You have been blocked from posting comments.  Your IP address (' . $ip . ') has been logged on our servers.'));
			return false;
		} 
	}
 
	return true;
 
}
?>
res/plugins/fulk/commentipblacklist.txt · Last modified: 2008/06/19 00:29 by fulk