Skip to content

Instantly share code, notes, and snippets.

@cfalzone
Created April 25, 2014 13:08
Show Gist options
  • Select an option

  • Save cfalzone/11288997 to your computer and use it in GitHub Desktop.

Select an option

Save cfalzone/11288997 to your computer and use it in GitHub Desktop.
LeadForm Spam Detection
// HoneyPot Protection - if this field is filled in then this is probably a bot
if(UtilMethods.isSet(honeypot)) {
response.sendRedirect(errorPage);
Logger.debug(this, "Honey Pot detected, ignoring the request. Params: "+params);
return;
}
// Simple Spam Verification
if(firstName == null) firstName = "";
if(lastName == null) lastName = "";
if(phoneNumber == null) phoneNumber = "";
if(firstName.toLowerCase().equals(lastName.toLowerCase()) ||
firstName.toLowerCase().contains("http://") || lastName.toLowerCase().contains("http://") ||
firstName.toLowerCase().contains("@gmail.com") || lastName.toLowerCase().contains("@gmail.com") ||
phoneNumber.replaceAll("[^0-9]","").equals("123456") ||
(!UtilMethods.isSet(agentId))) {
response.sendRedirect(errorPage);
Logger.debug(this, "Case Considered spam, ignoring the request. Params: "+params);
return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment