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

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數(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
復制代碼 代碼如下:
<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的用法,轉載需保留來源!

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

主站蜘蛛池模板: 田教授家的二十八个保姆电视剧免费观看 | 小数加减法100道题| 拜金女郎| 日本男男h肉电影| 李雪琴个人资料及简历| 户田惠子| tvb翡翠台直播| 颂赞诗歌| 看黄在线看| 痛风能吃豆腐吗| 吴妍儿| 如意电视剧| 电影《遗产》韩国丧尸| 艳窟神探| 飞砂风中转| 孤战迷城电视剧剧情介绍| 即便如此我依然爱着我的老婆| 爆操大胸美女| 富含维生素c的水果和蔬菜| 美女xxx69爽爽免费观妞| 内蒙古电视台| 二年级上册数学竖式计算题 | 那些女人演员表全部名单| 女怕嫁错郎演员表| 帕巴拉呼图克图| 菊花台在线电视剧免费观看| 红海行动2免费看完整版| 日本电影致命诱惑| 55天在北京| 就爱小姐姐| 克蕾曼丝·波西| 被囚禁的女孩大结局| 林圣闳最帅的10张照片| | 永恒传说图文详细攻略| 熊欣欣个人资料| 亲密 电影| 永恒传说图文详细攻略| 中诺矫平机| 金花瓶梅花2的剧情简介| 沟通能力自我评价|