四虎精品视频-四虎精品成人免费网站-四虎黄色网-四虎国产视频-国产免费91-国产蜜臀97一区二区三区

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)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請第一時間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 绝不放弃电影| 贝加尔湖畔指弹吉他谱| 王宝强盲井| 孙子兵法三十六计完整解释电子书| 男男性恋免费视频网站| 二次元炫酷帅气壁纸| 彭丹丹最惊艳的电影| 张子枫的全部作品| 暗潮危机电影完整版在线观看| 一直很安静简谱| 周秀娜全部三级视频| 董卿简历| 永远的经典影片永远的| 朱莉安妮全集高清免费| 逆光飞翔 电影| deathnote| angela white在线播放| 人世间演员表| 北京卫视今晚的电视剧是什么| 社会主义建设在探索中曲折发展| 洛城僵尸| 汤姆·塞兹摩尔| cctv16体育台节目表| 防冲撞应急处置预案| 妈妈的朋友泡妞| 漂亮孕妇突然肚子疼视频| 节目单| 通天长老电影在线观看完整版| 小姨的朋友| 流浪地球2演员表| 膨腹爱好者撑肚子视频| 老阿姨视频| 一个都不能少电影| 寻梦环游记英文| 柳濑早纪| 冲出月亮岛演员表| 都市频道今日节目表| 女孩们的周末| juliet stevenson| 狼来了电影免费观看| 日别视频|