/** * Verify the user submitted form by checking anti-spam hooks and/or recaptcha if they exist * @static * */ static function Check() { global $page, $langmessage, $config, $dataDir; // if hooks return false, stop if (!gpPlugin::Filter('AntiSpam_Check', array(true))) { return false; } // if recaptcha inactive, stop if (!gp_recaptcha::hasRecaptcha()) { return true; } //prevent undefined index warnings if there is a bot $_POST += array('recaptcha_challenge_field' => '', 'recaptcha_response_field' => ''); //includeFile('thirdparty/recaptchalib.php'); require_once $dataDir . '/include/thirdparty/recaptchalib.php'; $resp = recaptcha_check_answer($config['recaptcha_private'], $_SERVER['REMOTE_ADDR'], $_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field']); if (!$resp->is_valid) { message($langmessage['INCORRECT_CAPTCHA']); //if( common::LoggedIn() ){ // message($langmessage['recaptcha_said'],$resp->error); //} return false; } return true; }
/** * Verify the user submitted form by checking anti-spam hooks and/or recaptcha if they exist * @static * */ static function Check() { global $page, $langmessage, $config, $dataDir; // if hooks return false, stop if (!gpPlugin::Filter('AntiSpam_Check', array(true))) { return false; } // if recaptcha inactive, stop if (!gp_recaptcha::hasRecaptcha()) { return true; } if (empty($_POST['g-recaptcha-response'])) { return false; } require_once $dataDir . '/include/thirdparty/recaptcha/autoload.php'; if (!ini_get('allow_url_fopen')) { // allow_url_fopen = Off $recaptcha = new \ReCaptcha\ReCaptcha($config['recaptcha_private'], new \ReCaptcha\RequestMethod\SocketPost()); } else { // allow_url_fopen = On $recaptcha = new \ReCaptcha\ReCaptcha($config['recaptcha_private']); } if (!empty($_SERVER['HTTP_CLIENT_IP'])) { $ip = $_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } else { $ip = $_SERVER['REMOTE_ADDR']; } $resp = $recaptcha->verify($_POST['g-recaptcha-response'], $ip); if (!$resp->isSuccess()) { //$error_codes = $resp->getErrorCodes(); //error_log(); msg($langmessage['INCORRECT_CAPTCHA']); return false; } return true; }