'. t('The CSS CAPTCHA uses CSS tricks to obfuscate a random text code for spam bots. The characters of the code are scrambled in the HTML markup but are displayed in the correct order when rendered with a CSS capable browser.') .'
' ; } } /** * Implementation of hook_menu(). */ function css_captcha_menu() { $items = array(); $items['admin/user/captcha/css_captcha'] = array( 'title' => 'CSS CAPTCHA', 'file' => 'css_captcha.admin.inc', 'page callback' => 'drupal_get_form', 'page arguments' => array('css_captcha_settings_form'), 'access arguments' => array('administer CAPTCHA settings'), 'type' => MENU_LOCAL_TASK, ); return $items; } /** * Implementation of hook_captcha() */ function css_captcha_captcha($op, $captcha_type='', $response='') { switch ($op) { case 'list': return array("CSS CAPTCHA"); case 'generate': if ($captcha_type == "CSS CAPTCHA") { // get settings $allowed_chars = _text_captcha_utf8_split(variable_get('css_captcha_allowed_characters', CSS_CAPTCHA_DEFAULT_ALLOWED_CHARACTERS)); $code_length = (int) variable_get('css_captcha_code_length', 6); // build solution and $code_struct $solution = ''; $code_struct = array(); for ($i = 0; $i < $code_length; $i++) { $character = $allowed_chars[array_rand($allowed_chars)]; $code_struct[$i] = array('content' => $character, 'size' => 1.25); $solution .= $character; } // generate css scrambling while (count($code_struct) > 1) { // pick random neighbouring items from $code_struct $i = mt_rand(0, count($code_struct) - 2); $item_left = $code_struct[$i]; $item_right = $code_struct[$i+1]; // merge $merged_size = $item_left['size'] + $item_right['size'] + .25; if (mt_rand(0, 1)) { // normal merge: $item_left first and $item_right second $merged_content = "