FoxHoneyPot

Summary: Adds honeypot trap for bots to Fox forms
Version: 2024-04-15
Prerequisites: Fox
Status: New
Maintainer: HansB
License: open
Categories: Fox Security Forms Markup
Users: (view? / edit)
Discussion: FoxHoneyPot-Talk?

Questions answered by this recipe

How can I stop bots from submitting Fox forms, for forms which are accessible to the public?

Description

Add an input field acting as a honey pot for bots to a Fox form. If a bot posts anything into that field, the form submission aborts

Installation

Add the following to config.php, somewhere above where fox.php is included:

//foxhoneypot directive and filter function, set input a_password as hidden bot trap
Markup('foxhoneypot','directives','/\\(:foxhoneypot:\\)/',"Fox_Honeypot");
function Fox_Honeypot() {
  $out = '<input type="hidden" name="foxfilter" value="pot" />'.
   '<input type="text" name="a_password" style="display:none !important" tabindex="-1" autocomplete="off">';
  return Keep($out);
}
$FoxFilterFunctions['pot'] = 'Fox_Honeypot_Filter';
function Fox_Honeypot_Filter($pagename, $fx) {
  if (!empty($fx['a_password'])) FoxAbort($pagename, 'Are you a bot?');
  return $fx;
}

Add to any Fox form this directive:

(:foxhoneypot:)

This adds to a Fox form an input field named 'a_password', which is not visible to a user, but may attract a bot to put something into. A hidden input field 'foxfilter' is added too. On submission it will be checked by a FoxFilter function, which will abort the submission if there is content in that field.

Change log / Release notes

  • 2024-04-15: initial release

See also

Contributors

Comments

See discussion at FoxHoneyPot-Talk?

User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.