Monday 5 July 2010

ZXTM - Filter content in forms

There is nothing more annoying than getting spammed via your webforms. Using ZXTM's trafficscript you can filter out unwanted content. In the below example a reviews webform was getting badly spammed with links, advertising and attempted hacking. You could use Regex rules in the below as well if you wanted. It is also possible to maintain a "bad word" list in a database and have the ZXTM look it up.


$path = http.getpath();
$body = http.getBody(4000);
if( http.getmethod() == "POST"
&& $path == "/review/add_review"
&& ( string.contains( $body, "groups.google." )
|| string.contains( $body, "freehost.com" )
|| string.contains( $body, "blog.360.yahoo.com" )
|| string.contains( $body, "dreamstation.com" )
|| string.contains( $body, "cialis" )
|| string.contains( $body, "Bactrim" )
|| string.contains( $body, "Mumbai" )
|| string.contains( $body, "href" )
|| string.contains( $body, "javascript" )
|| string.contains( $body, "iframe" )
|| string.contains( $body, ".js" )
|| string.contains( $body, "SCRIPT" )
|| string.contains( $body, "HREF" )
|| string.contains( $body, "EMBED" )
|| string.contains( $body, "xmlns" )
|| string.contains( $body, "IMG SRC" )
|| string.contains( $body, "videoUrl" )
|| string.contains( $body, "http" )
|| string.contains( $body, "HTTP" )
|| string.contains( $body, "Umeh" )
|| string.contains( $body, "mpacuk.org" )
|| string.contains( $body, "drugsnoprescription" )
|| string.contains( $body, "xbox" ))

){
#log.info( "Review".$body); ### unremark to log info for testing
connection.discard();

}

No comments:

Post a Comment