'admin/settings/captcha/riddler', 'title' => t('Riddler'), 'description' => t('Allows you to force a question to a number of forms to counter f.e. spammers.'), 'callback' => 'drupal_get_form', 'callback arguments' => array('riddler_settings'), 'access' => $access, 'type' => MENU_LOCAL_TASK ); return $items; } /* Riddler settings form, called by drupal_get_form in menu */ function riddler_settings() { $form['question'] = array( '#type' => 'textfield', '#title' => t('Question'), '#description' => t('A question that you require anonymous users to answer'), '#default_value' => variable_get("riddler_question", "Do you hate spam? (yes or no)"), '#required' => TRUE, ); $form['answer'] = array( '#type' => 'textfield', '#title' => t('Answer'), '#default_value' => variable_get("riddler_answer", "yes"), '#description' => t('Answer to the above question. Answers are not case sensitive'), '#required' => TRUE, ); return system_settings_form($form); } /* Processing the settings form */ function riddler_settings_submit ($form_id, $form_values) { variable_set("riddler_question", $form_values['question']); variable_set("riddler_answer", $form_values['answer']); } /* Captcha implementation of Riddler */ function riddler_captcha() { $args = func_get_args(); $op = array_shift($args); switch ($op) { case 'list' : return array("Riddler"); break; case 'generate' : $result = array(); $captcha_type = array_shift($args); if ($captcha_type == "Riddler") { $result = riddler_form(); } return $result; break; } } function riddler_form () { $form['value'] = (string)(variable_get("riddler_answer", "yes")); $form['form']['captcha_challenge'] = array( '#type' => 'textfield', '#title' => variable_get("riddler_question", "Do you hate spam? (yes or no)"), '#required' => TRUE, '#description' => t('Security question, designed to stop automated spam bots'), '#weight' => 0, ); return $form; }