-
-
Save design-innovations/12f45b6bc900e8f5216ee83652bf9e93 to your computer and use it in GitHub Desktop.
Joomla RSForm Honeypot inspired by https://webaim.org/blog/spam_free_accessible_forms/
This file contains 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
A small honeypot method to catch spam bots. | |
Inspired by blog post on https://webaim.org/blog/spam_free_accessible_forms/ |
This file contains 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
Name: usefulName | |
Caption: usefulName |
This file contains 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
<style> | |
.rsform-block-usefulName{ | |
display:none; | |
visibility:hidden; | |
} | |
</style> |
This file contains 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
/** | |
* https://webaim.org/blog/spam_free_accessible_forms/ | |
*/ | |
$spam = false; | |
// Detect form elements for the most common header injections and other code | |
if (preg_match( "/bcc:|cc:|multipart|\[url|Content-Type:/i", implode($_POST['form']))) | |
{ | |
$spam=true; | |
} | |
// Detect more than 3 outgoing links | |
if (preg_match_all("/<a|https?:/i", implode($_POST['form']), $out) > 3) | |
{ | |
$spam=true; | |
} | |
// Detect content within a hidden form element | |
if( !empty($_POST['form']['usefulName'])) | |
{ | |
$spam = true; | |
} | |
// Ensure the form is posted from your server | |
//if((isset($_SERVER['HTTP_REFERER']) && stristr($_SERVER['HTTP_REFERER'],$_SERVER['HTTP_HOST']))) { | |
// $spam=true; | |
//} | |
// Sent spammer to somewhere else | |
if ($spam) | |
{ | |
header('Location: https://www.example.com/'); | |
die; | |
} | |
// END Honeypot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment