本文整理汇总了PHP中recaptcha_check_answer函数的典型用法代码示例。如果您正苦于以下问题:PHP recaptcha_check_answer函数的具体用法?PHP recaptcha_check_answer怎么用?PHP recaptcha_check_answer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了recaptcha_check_answer函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkAnswer
public static function checkAnswer()
{
// global private key of ThinPHP subscription from reCAPTCHA. You can use this.
$privatekey = "6LfUVcISAAAAABtSNKYdZIcbfo8-_qA5kkg8ONPM";
$resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
return $resp->is_valid;
}
示例2: reCaptcha
private function reCaptcha()
{
require_once '/var/www/html/laravel/app/library/recaptchalib.php';
$privatekey = "6LdaP_oSAAAAAE3zyUWf_XpZmVE_Qbbj7ggRIoiC";
$resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], Input::get("recaptcha_challenge_field"), Input::get("recaptcha_response_field"));
return array('valid' => $resp->is_valid, 'error' => $resp->error);
}
示例3: ValidateCaptcha
function ValidateCaptcha($Value = NULL)
{
require_once PATH_LIBRARY . '/vendors/recaptcha/functions.recaptchalib.php';
$CaptchaPrivateKey = C('Garden.Registration.CaptchaPrivateKey', '');
$Response = recaptcha_check_answer($CaptchaPrivateKey, Gdn::Request()->IpAddress(), Gdn::Request()->Post('recaptcha_challenge_field', ''), Gdn::Request()->Post('recaptcha_response_field', ''));
return $Response->is_valid ? TRUE : 'The reCAPTCHA value was not entered correctly. Please try again.';
}
示例4: grab_value
function grab_value()
{
if ($this->keys_available()) {
$request = $this->get_request();
if (!empty($request["recaptcha_challenge_field"]) && !empty($request["recaptcha_response_field"])) {
$resp = recaptcha_check_answer($this->get_private_key(), $_SERVER["REMOTE_ADDR"], $request["recaptcha_challenge_field"], $request["recaptcha_response_field"]);
if ($resp->is_valid) {
return 1;
} else {
if ($resp->error == 'invalid-site-private-key') {
trigger_error("The reCAPTCHA challenge was ignored - reCAPTCHA reports that your site private key is invalid.");
} elseif ($resp->error == 'invalid-request-cookie') {
// lets remove this trigger since this can happens often with the non-javascript version.
//trigger_error ("Recaptcha challenge parameter was not correctly passed - make sure reCAPTCHA is properly configured.");
$this->set_error("The reCAPTCHA wasn't entered correctly. Please try again.");
} elseif ($resp->error == 'incorrect-captcha-sol') {
$this->set_error("The reCAPTCHA wasn't entered correctly. Please try again.");
}
}
} else {
$this->set_error("You must respond to the reCAPTCHA challenge question to complete the form");
}
return 0;
}
}
示例5: conta_click
public function conta_click($url, $captcha)
{
global $db_host, $db_user, $db_pass, $db_name;
$this->Open($db_host, $db_user, $db_pass, $db_name);
if (@$_POST['send'] == 1) {
//Anti Flood
$privatekey = "6Lc7yMASAAAAANiJ4_F-BbnxvC3hUlxdAT85PCUE";
$userip = $_SERVER["REMOTE_ADDR"];
$reCAPTCHA_f = $_POST["recaptcha_challenge_field"];
$reCAPTCHA_r = $_POST["recaptcha_response_field"];
$resp = recaptcha_check_answer($privatekey, $userip, $reCAPTCHA_f, $reCAPTCHA_r);
if (!$resp->is_valid) {
die("<br /><br /><center>Errore! Captcha Inserito non corretto!\n<br />Errore reCaptcha: " . $resp->error . "<br />\n<a href=\"index.php?page=visita&go_url=" . @$_GET['go_url'] . "\">Riprova</a></center>");
}
//Hijacking control - Thanks gabry9191 for the bug
$this->check_url($this->mysql_parse($url));
$url = $this->mysql_parse($url);
$num_click = $this->Query("SELECT `num_click` FROM page_rank_hack WHERE site = '{$url}'");
$row = mysql_fetch_row($num_click);
$app = $row[0] + 1;
$sql = $this->Query("UPDATE `page_rank_hack` SET num_click = '{$app}' WHERE site = '{$url}'");
die(header('Location: ' . $url));
} else {
$publickey = "6Lc7yMASAAAAAPYmegj3CxwkLJlg3demRNHEzsUd";
print "\n<center>" . "\n<h2 align=\"center\">Captcha Security (Anti-Flood)</h2><br /><br />\n" . "\n<form method=\"POST\" action=\"index.php?page=visita&go_url=" . htmlspecialchars($_GET['go_url']) . "\" />" . "\n";
print recaptcha_get_html($publickey);
print "<br />" . "\n<input type=\"hidden\" name=\"send\" value=\"1\" />" . "\n<input type=\"submit\" value=\"Visita\" />" . "\n</form>" . "\n</center>" . "";
}
}
示例6: faucet_valid_captcha
function faucet_valid_captcha($SETTINGS, $remote_address, $captcha_data = array())
{
$isGood = false;
if ($SETTINGS->config["use_captcha"]) {
if ($SETTINGS->config["captcha"] == "recaptcha") {
//Load re-captcha library
require_once './libraries/recaptchalib.php';
$resp = @recaptcha_check_answer($SETTINGS->config["captcha_config"]["recpatcha_private_key"], $remote_address, $captcha_data['recaptcha_challenge_field'], $captcha_data['recaptcha_response_field']);
$isGood = $resp->is_valid;
// $resp->error;
} elseif ($SETTINGS->config["captcha"] == "solvemedia") {
//Load solvemedia library
require_once './libraries/solvemedialib.php';
$resp = @solvemedia_check_answer($SETTINGS->config["captcha_config"]["solvemedia_private_key"], $remote_address, $captcha_data['adcopy_challenge'], $captcha_data['adcopy_response'], $SETTINGS->config["captcha_config"]["solvemedia_hash_key"]);
$isGood = $resp->is_valid;
// $resp->error;
} else {
//Load simple captcha library
@session_name($SETTINGS->config["captcha_config"]["simple_captcha_session_name"]);
@session_start();
$isGood = $captcha_data['captcha_code'] == @$_SESSION['captcha']['code'];
//Prevent re-submissions
unset($_SESSION['captcha']['code']);
}
} else {
//If no CAPTCHA is in use, then return true
$isGood = true;
}
return $isGood;
}
示例7: validate
public function validate($row, $postData)
{
$ret = parent::validate($row, $postData);
$sess = new Kwf_Session_Namespace('recaptcha');
if ($sess->validated) {
//if user did solve one captcha we store that in session and don't annoy him again
return $ret;
}
if (empty($_POST["recaptcha_challenge_field"]) || empty($_POST["recaptcha_response_field"])) {
$ret[] = array('message' => trlKwf('Please solve captcha correctly'), 'field' => $this);
return $ret;
}
require_once 'vendor/koala-framework/recaptcha-php/recaptchalib.php';
$resp = recaptcha_check_answer(Kwf_Config::getValue('recaptcha.privateKey'), $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
$msg = $resp->error;
if ($msg == 'incorrect-captcha-sol') {
$msg = trlKwf('Please solve captcha correctly');
}
$ret[] = array('message' => $msg, 'field' => $this);
} else {
$sess->validated = true;
}
return $ret;
}
示例8: postContact
public function postContact()
{
require_once public_path() . '/recaptcha/recaptchalib.php';
$private_key = "6LeqigQTAAAAAG8dmp7aH1HuPeJqB3lfJ_Fjx3xw";
$resp = recaptcha_check_answer($private_key, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
// What happens when the CAPTCHA was entered incorrectly
return Redirect::route('get-contact')->with('global', 'Human user verification did not match. Try again!');
} else {
// Your code here to handle a successful verification
$validator = Validator::make(Input::all(), array('name' => 'required|max:50', 'email' => 'required|email', 'comments' => 'required', 'phone' => 'numeric'));
if ($validator->fails()) {
return Redirect::route('get-contact')->withInput()->withErrors($validator);
} else {
$name = Input::get('name');
$email = Input::get('email');
$phone = Input::get('phone');
$comments = Input::get('comments');
Mail::send('emails.contact', array('name' => $name, 'email' => $email, 'comments' => $comments), function ($message) use($name, $email, $comments, $phone) {
$message->from($email, $name);
$message->to('info@srilankahotels.travel', 'Thilina Herath')->subject('Contact us emails');
});
// Redirect to page
return Redirect::route('default-message')->with('global', 'Your message has been sent. Thank You!');
}
}
}
示例9: checkCaptcha
function checkCaptcha($input, $options = array())
{
$this->load();
$privatekey = $options['privatekey'];
$resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
return $resp->is_valid;
}
示例10: performRegistration
private function performRegistration()
{
global $config, $userdb, $user;
// Check recaptcha answer
$resp = recaptcha_check_answer($this->options["recaptcha_privatekey"], $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
if (empty($_POST["user"])) {
echo "<p>Es wurde kein Nutzername angegeben.</p>";
} else {
if (strlen($_POST["user"]) < 3) {
echo "<p>Der Nutzername muss aus mindestens 3 Zeichen bestehen.</p>";
} else {
if (!preg_match("/^[-a-zA-Z0-9\\.]+\$/", $_POST["user"])) {
echo "<p>Der Nutzername darf nur Buchstaben (A-Z), Zahlen (0-9), Bindestriche und Punkte enthalten.</p>";
} else {
if ($userdb->userExists($_POST["user"])) {
echo "<p>Der angegebene Nutzername ist leider schon vergeben.</p>";
} else {
if (empty($_POST["mail"])) {
echo "<p>Es wurde keine E-Mail Adresse angegeben.</p>";
} else {
if (!$userdb->isValidMailAddress($_POST["mail"])) {
echo "<p>Die angegebene E-Mail Adresse ist ungültig.</p>";
} else {
if ($config["misc"]["singletonmail"] && $userdb->mailUsed($_POST["mail"])) {
echo "<p>Die angegebene E-Mail Adresse wird bereits bei einem anderen Account verwendet.</p>";
} else {
if (empty($_POST["pass"])) {
echo "<p>Es wurde kein Passwort angegeben.</p>";
} else {
if ($_POST["pass"] != $_POST["pass_repeat"]) {
echo "<p>Die beiden Passwörter stimmen nicht überein.</p>";
} else {
if (strlen($_POST["pass"]) < 6) {
echo "<p>Das Passwort muss mindestens 6 Zeichen lang sein.</p>";
} else {
if (empty($_POST["recaptcha_challenge_field"]) || empty($_POST["recaptcha_response_field"])) {
echo "<p>Der Captcha muss gelöst werden!</p>";
} else {
if (!$resp->is_valid) {
echo "<p>Falsche Captcha-Lösung.</p>";
} else {
if ($user = $userdb->registerUser($_POST["user"], $_POST["pass"], $_POST["mail"])) {
header("Location: index.php?module=profile&do=verify_mail&mail=" . urlencode($_POST["mail"]));
return;
} else {
echo "<p>Fehler beim Registrieren!</p>";
}
}
}
}
}
}
}
}
}
}
}
}
}
}
示例11: submit
public function submit($vars)
{
$form = $this->db->fetch("SELECT * FROM lf_forms WHERE id = " . intval($this->ini));
$pos = strpos($form['content'], '{recaptcha}');
if ($pos !== false) {
if (!isset($_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"])) {
return 'Invalid POST';
}
$privatekey = "6LffguESAAAAACsudOF71gJLJE_qmvl4ey37qx8l";
$resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
return 'Invalid recaptcha';
}
unset($_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
}
$data = json_encode($_POST);
$result = $this->db->query("INSERT INTO lf_formdata (`id`, `form_id`, `data`, `date`) VALUES (\n\t\t\tNULL, " . intval($this->ini) . ", '" . $this->db->escape($data) . "', NOW()\n\t\t)");
if (!$result) {
return '<p>Failed to submit. Contact an admin.</p>';
}
if ($form['email'] != '') {
$msg = "Hello,\n\t\t\t\nNew form data has been submitted for '" . $form['title'] . "':\n\n";
foreach ($_POST as $var => $val) {
$msg .= $var . ": " . $val . "\n";
}
$msg .= '
Do not reply to this message. It was automated.';
mail($form['email'], "New form data submitted: " . $form['title'], $msg, 'From: noreply@' . $_SERVER['SERVER_NAME']);
}
echo '<p>Form submitted successfully. Thank you!</p>';
}
示例12: book
public function book()
{
require_once 'recaptchalib.php';
$privatekey = "6LdEweMSAAAAAGI1hyasxa4pPu_Fd_HP0QXU9rEY";
$resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
$this->load->model("bookingtaxi_model");
$precount = $this->bookingtaxi_model->count_order_temp();
if ($this->input->post('rad_Ready_to_go') == 'Now') {
$string = date('Y-m-d h:m:s A');
} else {
$select_date = $this->input->post("ddl_Select_Date");
$am = $this->input->post("ddl_AM");
$hours = $this->input->post("ddl_hours");
$minutes = $this->input->post("ddl_minutes");
$string = $select_date . " " . $hours . ":" . $minutes . ":" . '00' . ' ' . $am;
}
$object = array("passenger" => $this->input->post("rad_passenger"), "name" => $this->input->post("txt_Name"), "contact_number" => $this->input->post("txt_Contact_Number"), "start_address" => $this->input->post("txt_Start_Address"), "unit_or_flat" => $this->input->post("txt_Unit_or_Flat"), "building_type" => $this->input->post("rad_Building_Type"), "business_name" => $this->input->post("txt_Business_name"), "remember_detail" => $this->input->post("chk_Remember_Details"), "end_address" => $this->input->post("txt_End_Address"), "distance" => $this->input->post("txt_Distance"), "car_type" => $this->input->post("rad_Car_Type"), "node_for_driver" => $this->input->post("ddl_Notes"), "time_to_go" => $string, "price" => floatval($this->input->post("txt_Distance")) * '1.617', "status_id" => "1", "payment" => $this->input->post("rad_Payment"), "driver" => "null");
$inform = array("passenger" => $this->input->post("rad_passenger"), "name" => $this->input->post("txt_Name"), "contact_number" => $this->input->post("txt_Contact_Number"), "address" => $this->input->post("txt_Start_Address"), "unit_or_flat" => $this->input->post("txt_Unit_or_Flat"), "building_type" => $this->input->post("rad_Building_Type"), "business_name" => $this->input->post("txt_Business_name"));
$this->bookingtaxi_model->booking($object);
$lastcount = $this->bookingtaxi_model->count_order_temp();
if ($lastcount > $precount) {
echo 'booking success!!!';
echo '<meta http-equiv="refresh" content="2;' . base_url() . '" />';
} else {
echo 'bookingfail!!!';
break;
}
if ($this->input->post("chk_Remember_Details") == '1') {
$this->bookingtaxi_model->addcustomer_temp($inform);
}
}
示例13: doPost
function doPost(&$post)
{
$id = 0;
// reCAPTCHA.
if ($this->conf['useRecaptcha']) {
$resp = recaptcha_check_answer($this->conf['privkey'], $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
$this->errors[] = "The CAPTCHA you entered was incorrect. If you have trouble with the image you can refresh it, or simply use the speaker icon to hear it.";
return $id;
}
}
// Validate some inputs.
$post["title"] = $this->_cleanUsername($post["title"]);
$post["format"] = $this->_cleanFormat($post["format"]);
$post["expiry"] = $this->_cleanExpiry($post["expiry"]);
// Set/clear the persistName cookie.
if (isset($post["remember"])) {
$value = $post["title"] . '#' . $post["format"] . '#' . $post['expiry'];
// Set cookie if not set.
if (!isset($_COOKIE["persistName"]) || $value != $_COOKIE["persistName"]) {
setcookie("persistName", $value, time() + 3600 * 24 * 365);
}
} else {
// Clear cookie if set.
if (isset($_COOKIE['persistName'])) {
setcookie('persistName', '', 0);
}
}
if (strlen($post['code'])) {
$title = preg_replace('/[^A-Za-z0-9_ \\-]/', '', $post['title']);
$title = $post['title'];
if (strlen($title) == 0) {
$title = 'Untitled';
}
$format = $post['format'];
if (!array_key_exists($format, $this->conf['geshiformats'])) {
$format = '';
}
$code = $post["code"];
if (empty($post["password"]) || $post["password"] == "") {
$password = "EMPTY";
} else {
$password = sha1($post["password"] . $salt);
}
// Now insert..
$parent_pid = 0;
if (isset($post["parent_pid"])) {
$parent_pid = intval($post["parent_pid"]);
}
if ($logged_in == 1) {
$user_id = $user->id;
} else {
$user_id = 0;
}
$id = $this->db->addPost($title, $format, $code, $parent_pid, $post["expiry"], $password, $user_id);
} else {
$this->errors[] = "Please specify a paste to submit.";
}
return $id;
}
示例14: checkCode
function checkCode($checkarray, $captchatype = 'myCaptcha')
{
if ($captchatype == 'myCaptcha') {
// First, delete old captchas
$expiration = time() - 3600;
// Two hour limit
$db =& JFactory::getDBO();
$db->setQuery("DELETE FROM #__cb_mycaptcha WHERE captcha_time < " . $expiration);
$db->query();
// Then see if a captcha exists:
$sql = "SELECT COUNT(*) AS count " . "\n FROM #__cb_mycaptcha " . "\n WHERE word = '{$checkarray['word']}' AND ip_address = '{$checkarray['ip']}' AND captcha_time > {$expiration}";
$query = $db->setQuery($sql);
if ($db->loadResult()) {
return true;
} else {
return false;
}
}
if ($captchatype == 'reCaptcha') {
require_once 'recaptcha' . DS . 'recaptchalib.php';
$res = recaptcha_check_answer($checkarray['privatekey'], CbmycaptchaModel::GetUserIp(), $checkarray["rec_ch_field"], $checkarray["rec_res_field"]);
if (!$res->is_valid) {
return false;
} else {
return true;
}
}
}
示例15: send
function send()
{
$mail = HTTP::_GP('mail', '', true);
$errorMessages = array();
if (empty($mail)) {
$errorMessages[] = t('passwordErrorMailEmpty');
}
if (Config::get('capaktiv') === '1') {
require_once 'includes/libs/reCAPTCHA/recaptchalib.php';
$resp = recaptcha_check_answer(Config::get('capprivate'), $_SERVER['REMOTE_ADDR'], $_REQUEST['recaptcha_challenge_field'], $_REQUEST['recaptcha_response_field']);
if (!$resp->is_valid) {
$errorMessages[] = t('registerErrorCaptcha');
}
}
if (!empty($errorMessages)) {
$message = implode("<br>\r\n", $errorMessages);
$this->printMessage($message, NULL, array(array('label' => t('passwordBack'), 'url' => 'index.php?page=lostPassword')));
}
$userID = $GLOBALS['DATABASE']->getFirstCell("SELECT id FROM " . USERS . " WHERE universe = " . $GLOBALS['UNI'] . " AND email_2 = '" . $GLOBALS['DATABASE']->escape($mail) . "';");
if (empty($userID)) {
$this->printMessage(t('passwordErrorUnknown'), NULL, array(array('label' => t('passwordBack'), 'url' => 'index.php?page=lostPassword')));
}
$hasChanged = $GLOBALS['DATABASE']->getFirstCell("SELECT COUNT(*) FROM " . LOSTPASSWORD . " WHERE userID = " . $userID . " AND time > " . (TIMESTAMP - 86400) . " AND hasChanged = 0;");
if (!empty($hasChanged)) {
$this->printMessage(t('passwordErrorOnePerDay'), NULL, array(array('label' => t('passwordBack'), 'url' => 'index.php?page=lostPassword')));
}
$validationKey = md5(uniqid());
$MailRAW = $GLOBALS['LNG']->getTemplate('email_lost_password_validation');
$MailContent = str_replace(array('{USERNAME}', '{GAMENAME}', '{VALIDURL}'), array($mail, Config::get('game_name') . ' - ' . Config::get('uni_name'), HTTP_PATH . 'index.php?page=lostPassword&mode=newPassword&u=' . $userID . '&k=' . $validationKey), $MailRAW);
require 'includes/classes/Mail.class.php';
Mail::send($mail, $mail, t('passwordValidMailTitle', Config::get('game_name')), $MailContent);
$GLOBALS['DATABASE']->query("INSERT INTO " . LOSTPASSWORD . " SET userID = " . $userID . ", `key` = '" . $validationKey . "', time = " . TIMESTAMP . ", fromIP = '" . $_SERVER['REMOTE_ADDR'] . "';");
$this->printMessage(t('passwordValidMailSend'), NULL, array(array('label' => t('passwordNext'), 'url' => 'index.php')));
}