--- outerbridge-humancaptcha.orig.php 2014-08-27 14:08:59.804507500 +0200 +++ outerbridge-humancaptcha.php 2014-08-27 14:08:29.753606000 +0200 @@ -112,7 +112,7 @@ $mysql = "CREATE TABLE $obr_hc_table_name ( fld_ref int(11) NOT NULL AUTO_INCREMENT, fld_questions varchar(100) NOT NULL, - fld_answers varchar(20) NOT NULL, + fld_answers varchar(100) NOT NULL, UNIQUE KEY fld_ref (fld_ref) ) $charset_collate;"; require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); @@ -207,7 +207,7 @@ $selected = $this->obr_select_question(); $question = $selected['question']; $answer = $selected['answer']; - $_SESSION['obr_answer'] = md5(strtolower(trim($answer))); + $_SESSION['obr_answer'] = strtolower(trim($answer)); // use the comment-form-email class as it works better with 2011 $fields['obr_hlc'] = '

*

'; return $fields; @@ -237,7 +237,7 @@ $selected = $this->obr_select_question(); $question = $selected['question']; $answer = $selected['answer']; - $_SESSION['obr_answer'] = md5(strtolower(trim($answer))); + $_SESSION['obr_answer'] = strtolower(trim($answer)); $fields['obr_hlc'] = '

'; echo $fields['obr_hlc']; return $fields; @@ -272,9 +272,17 @@ if ((!isset($_POST['answer'])) || ($_POST['answer'] == '')){ $errors->add('obr_error', __('Error: please fill the required field (humancaptcha).', 'humancaptcha')); } else { - $user_answer = md5(strtolower(trim($_POST['answer']))); + $user_answer = strtolower(trim($_POST['answer'])); $obr_answer = strtolower(trim($_SESSION['obr_answer'])); - if ($user_answer != $obr_answer){ + $valid = false; + $tok = strtok($obr_answer, ","); + while ($tok !== false){ + if ($user_answer === $tok){ + $valid = true; + } + $tok = strtok(","); + } + if ($valid !== true){ $errors->add('obr_error', __('Error: your answer to the humancaptcha question is incorrect.', 'humancaptcha')); } } @@ -295,12 +303,16 @@ if ((!isset($_POST['answer'])) || ($_POST['answer'] == '')){ wp_die(__('Error: please fill the required field (humancaptcha).', 'humancaptcha')); } - $user_answer = md5(strtolower(trim($_POST['answer']))); + $user_answer = strtolower(trim($_POST['answer'])); $obr_answer = strtolower(trim($_SESSION['obr_answer'])); - if ($user_answer != $obr_answer){ - wp_die(__('Error: your answer to the humancaptcha question is incorrect. Use your browser\'s back button to try again.', 'humancaptcha')); + $tok = strtok($obr_answer, ","); + while ($tok !== false){ + if ($user_answer === $tok){ + return true; + } + $tok = strtok(","); } - return true; + wp_die(__('Error: your answer to the humancaptcha question is incorrect. Use your browser\'s back button to try again.', 'humancaptcha')); } function obr_admin_menu(){ @@ -324,7 +336,7 @@ $counter = 1; foreach($wpdb->get_results($mysql) as $key => $row){ echo '
'; - echo '',$counter,''; + echo '',$counter,''; echo ''; echo '
'; echo '
'; @@ -342,7 +354,7 @@ if (isset($answer)){ echo $answer; } - echo '" style="width: 140px; text-align: left;" />'; + echo '" style="width: 490px; text-align: left;" />'; echo ''; if (isset($message)){ echo '',$message,'';