Kill Drupal Trackback Spam: The quick and dirty way

Aldon Hynes created this simple php script to erase trackback spams in drupal. To use it, simply create a new node and paste the PHP code I've included below. To run the script simply access the node. One click and 800 trackback spams destroyed. Take that JRCreations.

<?php

$sql = " where ";

$sql .= " subject like '%cialis%' or ";$sql .= " comment like '%cialis%' or ";

$sql .= " subject like '%fioricet%' or ";$sql .= " comment like '%fioricet%' or ";

$sql .= " subject like '%Casinos%' or ";$sql .= " comment like '%Casinos%' or ";

$sql .= " subject like '%jrcreations%' or ";$sql .= " comment like '%jrcreations%' or ";

$sql .= " comment like '%tramadol%' or ";$sql .= " subject like '%tramadol%' or ";

$sql .= " comment like '%propecia%' or ";$sql .= " subject like '%propecia%' or ";

$sql .= " comment like '%allegra%' or ";$sql .= " subject like '%allegra%' or ";

$sql .= " comment like '%levitra%' or ";$sql .= " subject like '%levitra%' or ";

$sql .= " comment like '%adipex%' or ";$sql .= " subject like '%adipex%' or ";

$sql .= " comment like '%phentermine%' or ";$sql .= " subject like '%phentermine%' or ";

$sql .= " comment like '%soma%' or ";$sql .= " subject like '%soma%' or ";

$sql .= " comment like '%poker%' or ";$sql .= " subject like '%poker%' or ";

$sql .= " comment like '%online casino%' or ";$sql .= " subject like '%online casino%' or ";

$sql .= " comment like '%5e4b5a4%' or ";$sql .= " subject like '%5e4b5a4%' or ";

$sql .= " comment like '%dir.web-marketings.com%' or ";$sql .= " subject like '%dir.web-marketings.com%' or ";

$sql .= " subject like '%8532a.com%' or ";$sql .= " comment like '%8532a.com%' or ";

$sql .= " subject like '%http://827.com%' or ";$sql .= " comment like '%http://827.com%' or ";

$sql .= " subject like '%http://shaffelrecords.com%' or ";$sql .= " comment like '%http://shaffelrecords.com%' or ";

$sql .= " subject like '%http://dawsonanddadrealty.com%' or ";$sql .= " comment like '%http://dawsonanddadrealty.com%' or ";

$sql .= " subject like '%http://kenwoodexcelon.com%' or ";$sql .= " comment like '%http://kenwoodexcelon.com%' or ";

$sql .= " subject like '%xxuz.com%' or ";$sql .= " comment like '%xxuz.com%' or ";

$sql .= " comment like '%Yellow Monkey%' or ";$sql .= " subject like '%Yellow Monkey%' or ";

$sql .= " comment like '%rape porn%' or ";$sql .= " subject like '%rape porn%' or ";

$sql .= " comment like '%holdem%' or ";$sql .= " subject like '%holdem%' or ";

$sql .= " comment like '%hold''em%' or ";$sql .= " subject like '%hold''em%'";

$ssql = "SELECT * from {comments} " . $sql ; $result = db_query($ssql);

while($comment = db_fetch_object($result)) {   print $comment->cid."<br>";   _comment_delete_thread($comment);}

$sql = str_replace('comment like','excerpt like', $sql);

$dsql = "DELETE FROM {trackback_received} " . $sql ;

$result = db_query($dsql);

?>