Stop Comment Spam

A while ago I posted some PHP code that helps block spam from known IP address by redirecting them to another page.  Check out the original post here: Since then I have updated the script to include logging functionality.

Or read the rest of this article to for the updated code.

$file_handle = file_get_contents("commentblocklist.txt");

$block = explode("\n", $file_handle);

if (in_array ($_SERVER['REMOTE_ADDR'], $block)) {
$v_date = date("l d F H:i:s");

$fp = fopen("ips.txt", "a");
fputs($fp, "IP: $v_ip - DATE: $v_date\n");

Or click here to download the complete file as a .txt then rename it with a .php extension and upload it to your server:

This entry was posted in Site Development, Updates and tagged , , , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *