一区二区久久-一区二区三区www-一区二区三区久久-一区二区三区久久精品-麻豆国产一区二区在线观看-麻豆国产视频

php空間不支持socket但支持curl時recaptcha的用法

1.修改recaptchalib.php中的兩個方法
復制代碼 代碼如下:
function _recaptcha_http_post($host, $path, $data, $port = 80) {
$req = _recaptcha_qsencode ($data);
$response = '';
$url = $host.$path;
$post_data = $req;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// 我們在POST數據哦!
curl_setopt($ch, CURLOPT_POST, 1);
// 把post的變量加上
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
$output = curl_exec($ch);
curl_close($ch);
//echo $output;
$response = $output;
return $response;
}
function recaptcha_check_answer ($privkey, $remoteip, $challenge, $response, $extra_params = array())
{
if ($privkey == null || $privkey == '') {
die ("To use reCAPTCHA you must get an API key from <a );
}
if ($remoteip == null || $remoteip == '') {
die ("For security reasons, you must pass the remote ip to reCAPTCHA");
}
//discard spam submissions
if ($challenge == null || strlen($challenge) == 0 || $response == null || strlen($response) == 0) {
$recaptcha_response = new ReCaptchaResponse();
$recaptcha_response->is_valid = false;
$recaptcha_response->error = 'incorrect-captcha-sol';
return $recaptcha_response;
}
$response = _recaptcha_http_post (RECAPTCHA_VERIFY_SERVER, "/recaptcha/api/verify",
array (
'privatekey' => $privkey,
'remoteip' => $remoteip,
'challenge' => $challenge,
'response' => $response
) + $extra_params
);
$answers = explode ("/n", $response [1]);
$recaptcha_response = new ReCaptchaResponse();
$pos = strpos($response, 'true');
if ($pos === false) {
$recaptcha_response->is_valid = false;
$recaptcha_response->error = $response;
} else {
$recaptcha_response->is_valid = true;
}
return $recaptcha_response;
}

2.demo.php
復制代碼 代碼如下:
<html>
<body>
<form action="" method="post">
<?php
require_once('recaptchalib.php');
// Get a key from https://www.google.com/recaptcha/admin/create
$publickey = "你的公共key ---自己去http://www.google.com/recaptcha申請";
$privatekey = "你的私有key ---自己去http://www.google.com/recaptcha申請";
# the response from reCAPTCHA
$resp = null;
# the error code from reCAPTCHA, if any
$error = null;
# was there a reCAPTCHA response?
if ($_POST["recaptcha_response_field"]) {
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if ($resp->is_valid) {
echo "You got it!";
} else {
# set the error code so that we can display it
$error = $resp->error;
echo $error;
//echo $_POST["recaptcha_challenge_field"];
//echo $_POST["recaptcha_response_field"];
}
}
echo recaptcha_get_html($publickey, $error);
?>
<br/>
<input type="submit" value="submit" />
</form>
</body>
</html>

php技術php空間不支持socket但支持curl時recaptcha的用法,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 午夜视频www| 亚洲一区二区免费看 | 午夜亚洲国产成人不卡在线 | 在线播放黄色 | 色无极影视 | 欧美网站在线 | 久久免费精品一区二区 | 国产精品福利在线观看 | 狠狠穞老司机的福67194 | 激情亚洲婷婷 | caoporn97人人做人人爱最新 | 中文字幕在线观看国产 | 午夜宅宅宅影院在线观看 | 91麻豆影视 | 91网站免费在线观看 | 色久综合在线 | 精品中文字幕在线 | 精品伊人久久大线蕉地址 | 色操网 | 久久艹伊人 | 亚洲欧美黄 | 91观看视频 | 久久99国产亚洲精品 | 日韩美女拍拍免费视频网站 | 2020国产精品 | 五月婷婷基地 | 久夜tv | 国产三级欧美 | 精品久久天干天天天按摩 | 国产在线拍 | 国产精品久久久久久一区二区三区 | 97国产精品视频 | 播放久久国产乱子伦精品 | 日韩高清一区二区 | 亚洲天堂黄色 | 九九视频免费精品视频免费 | 精品视频网 | 色婷婷精品免费视频 | 久久综合丝袜日本网 | 免费三级网 | 国产精品区网红主播在线观看 |