class BotchaRecipeTimegate in BOTCHA Spam Prevention 7.3
Same name and namespace in other branches
- 6.2 controller/botcha_recipe.controller.inc \BotchaRecipeTimegate
- 6.3 controller/recipe/botcha.recipe.controller.inc \BotchaRecipeTimegate
- 7.2 controller/botcha_recipe.controller.inc \BotchaRecipeTimegate
Hierarchy
- class \BotchaRecipe
- class \BotchaRecipeTimegate
Expanded class hierarchy of BotchaRecipeTimegate
1 string reference to 'BotchaRecipeTimegate'
- botcha_update_7200 in ./
botcha.install - Create flexible relationships between recipe books and recipes and between recipe books and forms.
File
- controller/
recipe/ botcha.recipe.controller.inc, line 936 - Controller layer of the BotchaRecipe objects.
View source
class BotchaRecipeTimegate extends BotchaRecipe {
protected $time;
public function getInfo() {
parent::getInfo();
$this->description = t('Check time spended for submitting a form.') . ' ' . t('Bots submit form too fast.') . ' ' . t('Form is marked with timestamp which is checked during submit.');
$this->error_text .= '<br />' . t('Form is submitted too fast.') . '<br />' . t('Please spend more time filling in the form.');
}
protected function getFieldCount() {
return 1;
}
protected function getFieldName($delta) {
switch ($delta) {
case 0:
default:
return 'timegate';
break;
}
}
public function generateFormElements() {
$fields = $this
->getProperty($this->settings['fields'], 'getFields');
return array_merge(parent::generateFormElements(), array(
$fields[0]['name'] => array(
'#type' => 'hidden',
'#title' => 'Timegate',
'#weight' => 5,
'#required' => FALSE,
'#default_value' => time(),
),
));
}
public function isSpam($form, $form_state) {
$isSpam = parent::isSpam($form, $form_state);
// Timegate method validation.
$absence = empty($form['timegate']);
$minimal_delay = variable_get('botcha_timegate', 5);
$form_generated = !empty($form_state['botcha_submit_values']['timegate']) ? $form_state['botcha_submit_values']['timegate'] : NULL;
$form_submitted = !empty($form_state['values']['timegate']) ? $form_state['values']['timegate'] : NULL;
if ($absence || (int) $form_submitted < (int) $form_generated + (int) $minimal_delay) {
$isSpam = TRUE;
}
return $isSpam;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
BotchaRecipe:: |
protected | property | CSS to add to the page. | |
BotchaRecipe:: |
protected | property | Brief description of the recipe. It should contain explanation of how bots would fail with it and what the recipe exactly does. | |
BotchaRecipe:: |
public | property | Name of the field in the form to use in error messages (to mask botcha fields). | |
BotchaRecipe:: |
public | property | Text to give users if botcha recipe blocks submission. It should give some help to real human users in cases of disabled Javascript or CSS. | |
BotchaRecipe:: |
public | property | Identifier of the recipe. | |
BotchaRecipe:: |
protected | property | Javascript to add to the page. | |
BotchaRecipe:: |
protected | property | Method of recipe genration. | |
BotchaRecipe:: |
protected | property | ||
BotchaRecipe:: |
protected | property | Secret. | |
BotchaRecipe:: |
protected | property | Options that received as parameters turned into settings by merging with default values. | |
BotchaRecipe:: |
public | function | 1 | |
BotchaRecipe:: |
public | function | Should be overridden. | 1 |
BotchaRecipe:: |
public | function | Used to get default recipe data structure. @todo ?Do we need it? | |
BotchaRecipe:: |
public | function | ||
BotchaRecipe:: |
protected | function | 1 | |
BotchaRecipe:: |
protected | function | ||
BotchaRecipe:: |
protected | function | ||
BotchaRecipe:: |
protected | function | ||
BotchaRecipe:: |
public | function | Should be overridden. | 1 |
BotchaRecipe:: |
public | function | ||
BotchaRecipe:: |
protected | function | Universal getter. Wrapper getProperty is used to let class methods be used not only in getting default settings. It gives flexibility to make calls to the class methods in any order: the first of them will always calculate the property value and set… | |
BotchaRecipe:: |
public | function | ||
BotchaRecipe:: |
protected | function | ||
BotchaRecipe:: |
public | function | ||
BotchaRecipe:: |
public | function | ||
BotchaRecipe:: |
public | function | Handle form depending on the result of spam check. | 1 |
BotchaRecipe:: |
protected | function | 1 | |
BotchaRecipe:: |
public | function | ||
BotchaRecipe:: |
public | function | ||
BotchaRecipe:: |
public | function | ||
BotchaRecipe:: |
public | function | ||
BotchaRecipe:: |
public | function | ||
BotchaRecipe:: |
public | function | ||
BotchaRecipe:: |
public | function | Magic method __construct. | |
BotchaRecipeTimegate:: |
protected | property | ||
BotchaRecipeTimegate:: |
public | function |
Used to get information about the recipe.
Must be overridden with calling to parent::generateFormElements.
@todo Switch from indexed array to associative.
@see? Overrides BotchaRecipe:: |
|
BotchaRecipeTimegate:: |
protected | function | ||
BotchaRecipeTimegate:: |
protected | function |
Overrides BotchaRecipe:: |
|
BotchaRecipeTimegate:: |
public | function |
Used to get information about the recipe.
Must be overridden. Overrides BotchaRecipe:: |
|
BotchaRecipeTimegate:: |
public | function |
Spam check. Overrides BotchaRecipe:: |