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

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

1.修改recaptchalib.php中的兩個方法
復(fù)制代碼 代碼如下:
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數(shù)據(jù)哦!
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
復(fù)制代碼 代碼如下:
<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技術(shù)php空間不支持socket但支持curl時recaptcha的用法,轉(zhuǎn)載需保留來源!

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

主站蜘蛛池模板: 久久久国产麻豆 | 国产一区二区三区免费 | 国产区视频在线观看 | 狠狠综合久久久综合 | 四虎影视永久在线 | 国产成在线人视频免费视频 | 免费人成在线观看视频色 | 亚洲精品国产精品乱码不97 | 免费毛片在线视频 | 色婷婷一区二区三区四区成人 | 日本一区二区三区在线 观看网站 | 久久综合九色综合77 | 国产精品三区四区 | 婷婷六月丁香 | 在线青草| 嫩草免费 | 97超级碰在线精品视频 | 亚洲女人在线 | 在线播放亚洲美女视频网站 | 亚洲毛片视频 | 九九综合九九综合 | 国产精品日韩欧美一区二区三区 | 成人在线激情视频 | 韩国一级永久免费观看网址 | 五月天婷色 | 婷婷亚洲久悠悠色悠在线播放 | 亚色成人 | 精品国产网红福利在线观看 | 日本高清中文字幕一区二区三区a | 精品少妇一区二区三区视频 | 国产欧美日韩高清专区ho | 免费国产高清视频 | 久久免费公开视频 | 国产九九精品视频 | 久久久久久久成人午夜精品福利 | 好爽毛片一区二区三区四 | 中文字幕亚洲日韩无线码 | 国产成人综合在线观看网站 | 国内精品久久久久久久星辰影视 | 中文一区在线观看 | 青青自拍视频一区二区三区 |