You are here

class BotchaRecipeHoneypot2 in BOTCHA Spam Prevention 7.2

Same name and namespace in other branches
  1. 6.2 controller/botcha_recipe.controller.inc \BotchaRecipeHoneypot2
  2. 6.3 controller/recipe/botcha.recipe.controller.inc \BotchaRecipeHoneypot2
  3. 7.3 controller/recipe/botcha.recipe.controller.inc \BotchaRecipeHoneypot2

Hierarchy

Expanded class hierarchy of BotchaRecipeHoneypot2

1 string reference to 'BotchaRecipeHoneypot2'
botcha_update_7200 in ./botcha.install
Create flexible relationships between recipe books and recipes and between recipe books and forms.

File

controller/botcha_recipe.controller.inc, line 657
Controller layer of the BotchaRecipe objects.

View source
class BotchaRecipeHoneypot2 extends BotchaRecipeHoneypot {
  function getFieldName($delta) {
    switch ($delta) {
      case 0:
      default:
        return parent::getFieldName($delta);
        break;
    }
  }
  function getCss() {
    $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]);

    // 'a' before css token is because font name must start with a letter.
    return parent::getCss() . " input.{$fields[0]['class']} { font-family: sans-serif, a{$css_tok2} !important; }";
  }
  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']}";
    return <<<END
(function (\$) {
  Drupal.behaviors.{<span class="php-variable">$js</span>[<span class="php-string">'name'</span>]} = {
    attach: function (context, settings) {
      \$("{<span class="php-variable">$selector</span>}").each(function() {
        f=\$(this)[0];
        tok2=\$.trim(\$(f).css('fontFamily').split(',')[1]);
        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;}
      });
    }
  };
}(jQuery));
END;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
BotchaRecipe::$css protected property CSS to add to the page.
BotchaRecipe::$description 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::$error_field public property @todo Do we really need it? Probably the best way is to provide mail field always - it hides our fields. Name of the field in the form to use in error messages (to mask botcha fields).
BotchaRecipe::$error_text 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::$id public property Identifier of the recipe.
BotchaRecipe::$js protected property Javascript to add to the page.
BotchaRecipe::$method protected property Method of recipe genration.
BotchaRecipe::$recipebooks protected property
BotchaRecipe::$secret protected property Secret.
BotchaRecipe::$settings protected property Options that received as parameters turned into settings by merging with default values.
BotchaRecipe::$status public property Status of the spam check.
BotchaRecipe::applyRecipe public function 2
BotchaRecipe::getDefaultSettings function Used to get default recipe data structure.
BotchaRecipe::getDescription function
BotchaRecipe::getFieldClass function
BotchaRecipe::getFieldPrefix function
BotchaRecipe::getFields function
BotchaRecipe::getMethod function
BotchaRecipe::getProperty 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::getRecipe public static function
BotchaRecipe::getSecret function
BotchaRecipe::getSeed function
BotchaRecipe::getSetting function
BotchaRecipe::getStatus function
BotchaRecipe::getTitle function
BotchaRecipe::handle function Handle form depending on the result of spam check. 1
BotchaRecipe::save public function
BotchaRecipe::setDescription function
BotchaRecipe::setMethod function
BotchaRecipe::setRecipebook public function
BotchaRecipe::setSecret function
BotchaRecipe::setSetting function
BotchaRecipe::setStatus function
BotchaRecipe::setTitle function
BotchaRecipe::__construct function Magic method __construct.
BotchaRecipeHoneypot2::getCss function Should be overridden. Overrides BotchaRecipeUsingJsAbstract::getCss
BotchaRecipeHoneypot2::getFieldName function Overrides BotchaRecipe::getFieldName
BotchaRecipeHoneypot2::getJsValue function Overrides BotchaRecipeHoneypot::getJsValue
BotchaRecipeHoneypot::getInfo function Used to get information about the recipe. Must be overridden. Overrides BotchaRecipeUsingJsAbstract::getInfo
BotchaRecipeHoneypot::isSpam function Spam check. Overrides BotchaRecipe::isSpam
BotchaRecipeUsingJsAbstract::generateFormElements function Used to get information about the recipe. Must be overridden with calling to parent::generateFormElements. @todo BotchaRecipe generateFormElements Switch from indexed array to associative. Overrides BotchaRecipe::generateFormElements 1
BotchaRecipeUsingJsAbstract::getField function Overrides BotchaRecipe::getField
BotchaRecipeUsingJsAbstract::getFieldCount function 1
BotchaRecipeUsingJsAbstract::getFieldDefault function What server sends to JS in the field.
BotchaRecipeUsingJsAbstract::getJs public function Should be overridden. Overrides BotchaRecipe::getJs
BotchaRecipeUsingJsAbstract::getJsChops function
BotchaRecipeUsingJsAbstract::getJsMatch function What JS matches in the field.
BotchaRecipeUsingJsAbstract::getJsName function Get name of JS-script, attached to field.
BotchaRecipeUsingJsAbstract::getJsPos function What position is the part of the token.
BotchaRecipeUsingJsAbstract::getJsSecureToken function