Latest JAS v1.1.0
144 plugins online

Modules / Attempts

The attempts module is a simple little module that allows you to check whether something has been done too often (in a certain time frame). It was build for the users module however it can be deployed for anything.

Let say you want to block some from bruteforcing some page.
Brute force protection
PHP
require_once($_path["modules"]."attempts.php");

if(System_Module_attempts::active()) //optional validation to see if module is active (i.e. table exists)
{
  $key="bf ".$_SERVER["REMOTE_ADDR"]; //generate a unique key (in this case based on the IP)
  if(!System_Module_attempts::check($key, 5)) //check if the IP has knocked on the door more than 5 times
  {
    print "You ain't welcome here anymore!";
    exit;
  }
}

Alternatively you want to restrict a user to only view something every 2 minutes
Time restriction
PHP
  $key="tr ".$_config->get("usernr"); //generate a unique key (in this case based on the user's ID)
  if(!System_Module_attempts::check($key, 1, 120)) //check if the user has viewed the page in the last 120 seconds
  {
    print "That's enough of that";
    exit;
  }
}

Comments (0)