Created
April 25, 2014 13:08
-
-
Save cfalzone/11288997 to your computer and use it in GitHub Desktop.
LeadForm Spam Detection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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