You are here

function _botcha_recipe_test1 in BOTCHA Spam Prevention 6

Same name and namespace in other branches
  1. 7 botcha.botcha.inc \_botcha_recipe_test1()

Botcha recipe. Simple honeypot, no randomization, for test purposes.

1 string reference to '_botcha_recipe_test1'
_botcha_recipes in ./botcha.botcha.inc

File

./botcha.botcha.inc, line 147
Implementation of botcha form logic.

Code

function _botcha_recipe_test1($form, $secret, $error_field) {
  $myseed = 'itr_r2' . substr($secret, 0, 7);
  $spf = md5($myseed . substr('secret', 0, -4));
  $field_class = 'botcha_field';
  $field_name = 'botcha_response';
  $secure_token = 'Test 123';
  $field_dflt = 'Test 123';

  // What server sends in the field.
  $recipe = new stdClass();
  $recipe->name = 'test_honeypot_field';
  $recipe->description = t('Insert CSS+honeypot field');
  $recipe->description_bots = t('Bots will will mess with the field value');
  $recipe->description_how = t('%parts is added to the form.', array(
    '%parts' => t('Honeypot field') . ',CSS',
  )) . ' ' . t('CSS hides the input field.');
  $recipe->error_field = $error_field;
  $recipe->error_text = _botcha_error_text_errorcode($spf) . '<li>' . _botcha_error_text();
  $recipe->form_elements = array(
    $field_name => array(
      '#type' => 'textfield',
      '#title' => t('Enter your name'),
      // Leave the bot enough hints for it to guess it is a good name field
      '#default_value' => $field_dflt,
      // Store part of secure_token
      '#description' => t('Your first name.'),
      // This is for human users without CSS.
      '#prefix' => '<div class="' . $field_class . '">' . '<span class="description"> (' . t('If you\'re a human, don\'t change the following field') . ')</span>',
      '#suffix' => '</div>',
      '#attributes' => array(
        'class' => $field_class,
        'autocomplete' => 'off',
      ),
      '#weight' => -20,
      '!valid_token' => $secure_token,
    ),
  );
  $recipe->css = 'div.' . $field_class . ' { display: none; visibility: hidden; }';
  return $recipe;
}