function cptch_lmtttmpts_interaction() { global $cptch_options; $str_key = $cptch_options['cptch_str_key']['key']; if (1 == $cptch_options['cptch_login_form']) { /* check for captcha existing in login form */ if (isset($_REQUEST['cptch_result']) && isset($_REQUEST['cptch_number']) && isset($_REQUEST['cptch_time'])) { /* check for existing request by captcha */ if (0 !== strcasecmp(trim(cptch_decode($_REQUEST['cptch_result'], $str_key, $_REQUEST['cptch_time'])), $_REQUEST['cptch_number'])) { /* is captcha wrong */ if (isset($_SESSION["cptch_login"]) && false === $_SESSION["cptch_login"]) { return false; /* wrong captcha */ } } } } return true; /* no captcha in login form or its right */ }
function frm_check_cptch_post($errors, $values) { global $cptch_options; // skip captcha if user is logged in and the settings allow if (is_admin() and !defined('DOING_AJAX') or is_user_logged_in() && 1 == $cptch_options['cptch_hide_register']) { return $errors; } //don't require if editing $action_var = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action'; if (isset($values[$action_var]) and $values[$action_var] == 'update') { return $errors; } unset($action_var); //don't require if not on the last page global $frm_next_page, $frm_vars; if (is_array($frm_vars) and isset($frm_vars['next_page']) and isset($frm_vars['next_page'][$values['form_id']]) or is_array($frm_next_page) and isset($frm_next_page[$values['form_id']])) { return $errors; } //if the captcha wasn't incuded on the page if (!isset($_POST['cptch_number'])) { //$errors['form'] = __( 'You have entered an incorrect CAPTCHA value. Please try again.', 'cptch' ); return $errors; } if (!isset($cptch_options['cptch_str_key'])) { global $str_key; $str_key = get_option('frmcpt_str_key'); } else { $str_key = $cptch_options['cptch_str_key']['key']; } // If captcha not complete, return error if ($_POST['cptch_number'] == '') { $errors['cptch_number'] = __('Please complete the CAPTCHA.', 'cptch'); } if (function_exists('cptch_decode')) { $decoded = cptch_decode($_POST['cptch_result'], $str_key, isset($_REQUEST['cptch_time']) ? $_REQUEST['cptch_time'] : null); } else { if (function_exists('decode')) { $decoded = decode($_POST['cptch_result'], $str_key, isset($_REQUEST['cptch_time']) ? $_REQUEST['cptch_time'] : null); } else { // we don't know how to check it, so don't return $errors; } } if (isset($_POST['cptch_result']) and 0 == strcasecmp(trim($decoded), $_POST['cptch_number'])) { // captcha was matched } else { $errors['cptch_number'] = __('That CAPTCHA was incorrect.', 'cptch'); } return $errors; }