class BotchaRecipeHoneypot2 in BOTCHA Spam Prevention 6.3
Same name and namespace in other branches
- 6.2 controller/botcha_recipe.controller.inc \BotchaRecipeHoneypot2
- 7.2 controller/botcha_recipe.controller.inc \BotchaRecipeHoneypot2
- 7.3 controller/recipe/botcha.recipe.controller.inc \BotchaRecipeHoneypot2
Hierarchy
- class \BotchaRecipe
- class \BotchaRecipeUsingJsAbstract
- class \BotchaRecipeHoneypot
- class \BotchaRecipeHoneypot2
- class \BotchaRecipeHoneypot
- class \BotchaRecipeUsingJsAbstract
Expanded class hierarchy of BotchaRecipeHoneypot2
1 string reference to 'BotchaRecipeHoneypot2'
- botcha_update_6200 in ./
botcha.install - Implementation of hook_update_N(). Create flexible relationships between recipe books and recipes and between recipe books and forms.
File
- controller/
recipe/ botcha.recipe.controller.inc, line 712 - Controller layer of the BotchaRecipe objects.
View source
class BotchaRecipeHoneypot2 extends BotchaRecipeHoneypot {
protected function getFieldName($delta) {
switch ($delta) {
case 0:
default:
return parent::getFieldName($delta);
break;
}
}
public function generateFormElements() {
$fields = $this
->getProperty($this->settings['fields'], 'getFields');
$js = $this
->getProperty($this->settings['js'], 'getJs');
$chops_positions = array_keys($js['chops']);
$css_tok2 = substr($js['secure_token'], $chops_positions[0] + $chops_positions[1]);
$form_elements = parent::generateFormElements();
// Set 'style' attribute for our field. It will be used by JavaScript to
// calculate and fill in correct value to this hidden field.
// 'a' before css token is because font name must start with a letter.
$form_elements[$fields[0]['name']]['#attributes']['style'] = "font-family: \"a{$css_tok2}\"";
return $form_elements;
}
public function getJsValue() {
$fields = $this
->getProperty($this->settings['fields'], 'getFields');
$js = $this
->getProperty($this->settings['js'], 'getJs');
$js_tok1 = reset($js['chops']);
$selector = "input.{$fields[0]['class']}";
// @todo Abstract it.
return <<<END
Drupal.behaviors.{<span class="php-variable">$js</span>[<span class="php-string">'name'</span>]} = function() {
\$("{<span class="php-variable">$selector</span>}").each(function() {
f=\$(this)[0];
tok2 = f.style.fontFamily;
if(tok2.charAt(0) == "'" || tok2.charAt(0) == '"') tok2=tok2.substring(1, tok2.length-1);
tok2=tok2.substring(1, tok2.length);
if (f.value.indexOf("{<span class="php-variable">$js</span>[<span class="php-string">'match'</span>]}")==0){f.value="{<span class="php-variable">$js_tok1</span>}"+f.value.substring({<span class="php-variable">$js</span>[<span class="php-string">'pos'</span>]})+tok2;}
});
};
END;
}
}
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 | Used to get default recipe data structure. @todo ?Do we need it? | |
BotchaRecipe:: |
public | function | ||
BotchaRecipe:: |
protected | function | ||
BotchaRecipe:: |
protected | function | ||
BotchaRecipe:: |
protected | function | ||
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. | |
BotchaRecipeHoneypot2:: |
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 BotchaRecipeUsingJsAbstract:: |
|
BotchaRecipeHoneypot2:: |
protected | function |
Overrides BotchaRecipe:: |
|
BotchaRecipeHoneypot2:: |
public | function |
Overrides BotchaRecipeHoneypot:: |
|
BotchaRecipeHoneypot:: |
public | function |
Used to get information about the recipe.
Must be overridden. Overrides BotchaRecipeUsingJsAbstract:: |
|
BotchaRecipeHoneypot:: |
public | function |
Spam check. Overrides BotchaRecipe:: |
|
BotchaRecipeUsingJsAbstract:: |
public | function |
Should be overridden. Overrides BotchaRecipe:: |
|
BotchaRecipeUsingJsAbstract:: |
protected | function |
Overrides BotchaRecipe:: |
|
BotchaRecipeUsingJsAbstract:: |
protected | function | 1 | |
BotchaRecipeUsingJsAbstract:: |
protected | function | What server sends to JS in the field. | |
BotchaRecipeUsingJsAbstract:: |
public | function |
Should be overridden. Overrides BotchaRecipe:: |
|
BotchaRecipeUsingJsAbstract:: |
protected | function | ||
BotchaRecipeUsingJsAbstract:: |
protected | function | What JS matches in the field. | |
BotchaRecipeUsingJsAbstract:: |
protected | function | Get name of JS-script, attached to field. | |
BotchaRecipeUsingJsAbstract:: |
protected | function | What position is the part of the token. | |
BotchaRecipeUsingJsAbstract:: |
protected | function |