Control and count clicks.
Typically used by log in forms to prevent brute force attacks. For example, can count user log in attempts and script can then lock the form for a period of time if they fail to use correct credentials within that limit.
| package | dstruct_auth |
|---|
__construct()
Attempts to grab the default cache object and will set an identifier for the user (session or the IP).
| see | \Prefs::CLICK_CONTROL_IDENTIFIER_IS_SESSION |
|---|
\DStructGeneralException |
If can not find 'global' cache |
|---|
allowClick(string $userkey) : boolean
See if click can be authorised by the current click count being a lower value than the allowed clicks set and the current timestamp being less than the timestamp stored in the cache under the current object key, returning true or false.
stringKey used to identify the clickable object in the script
booleanclear(string $userkey)
This will have the effect of resetting the clicks etc.
stringKey used to identify the clickable object in the script
click(string $userkey)
stringKey used to identify the clickable object in the script
getClickCount(string $userkey) : integer
stringKey used to identify the clickable object in the script
integergetTimeOut() : integer
Is the time between the web users final allowed click before access is granted to click again
| see | \setTimeOut() |
|---|
integergetTimestamp(string $userkey) : mixed
stringKey used to identify the clickable object in the script
mixedInteger or falsesetTimeOut(integer $timeout)
TimeOut to block access to a web user once the number of click attempts matches the number of allowed clicks set.
integer
getKey(string $userkey) : string
The key that is used in the cache is a concatenation of the application name (Prefs::APP_NAME), the $userkey and the identifier (either the session or the IP).
stringKey used to identify the clickable object in the script
string$cache : object
$clickcount : integer
$timeout : integer
In seconds. Default is 172800 - two days.
$ttl : integer
In seconds. Default is 173100 - two days, five minutes. The entry in the cache will be invalidated at this time - essentially five minutes after the $timeout as it is no longer needed.
$useridentifier : string