本文整理汇总了PHP中_recaptcha_http_post函数的典型用法代码示例。如果您正苦于以下问题:PHP _recaptcha_http_post函数的具体用法?PHP _recaptcha_http_post怎么用?PHP _recaptcha_http_post使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_recaptcha_http_post函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: recaptcha_check_answer
/**
* Calls an HTTP POST function to verify if the user's guess was correct
* @param string $privkey
* @param string $remoteip
* @param string $challenge
* @param string $response
* @param array $extra_params an array of extra variables to post to the server
* @return ReCaptchaResponse
*/
function recaptcha_check_answer($privkey, $remoteip, $challenge, $response, $extra_params = array())
{
if ($privkey == null || $privkey == '') {
trigger_error("reCAPTCHA - No private key", E_USER_NOTICE);
return false;
}
if ($remoteip == null || $remoteip == '') {
trigger_error("reCAPTCHA - No remote ip", E_USER_NOTICE);
return false;
}
//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, "/verify", array('privatekey' => $privkey, 'remoteip' => $remoteip, 'challenge' => $challenge, 'response' => $response) + $extra_params);
$answers = explode("\n", $response[1]);
$recaptcha_response = new ReCaptchaResponse();
if (trim($answers[0]) == 'true') {
$recaptcha_response->is_valid = true;
} else {
$recaptcha_response->is_valid = false;
$recaptcha_response->error = $answers[1];
}
return $recaptcha_response;
}
示例2: recaptcha_check_answer
/**
* Calls an HTTP POST function to verify if the user's guess was correct
* @param string $privkey
* @param string $remoteip
* @param string $challenge
* @param string $response
* @param array $extra_params an array of extra variables to post to the server
* @return ReCaptchaResponse
*/
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 href='http://recaptcha.net/api/getkey'>http://recaptcha.net/api/getkey</a>", "wp-recaptcha"));
}
if ($remoteip == null || $remoteip == '') {
die(__("For security reasons, you must pass the remote ip to reCAPTCHA", "wp-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(gethostbyname('api-verify.recaptcha.net'), "/verify", array('privatekey' => $privkey, 'remoteip' => $remoteip, 'challenge' => $challenge, 'response' => $response) + $extra_params);
$answers = explode("\n", $response[1]);
$recaptcha_response = new ReCaptchaResponse();
if (trim($answers[0]) == 'true') {
$recaptcha_response->is_valid = true;
} else {
$recaptcha_response->is_valid = false;
$recaptcha_response->error = $answers[1];
}
return $recaptcha_response;
}
示例3: recaptcha_check_answer
/**
* Calls an HTTP POST function to verify if the user"s guess was correct
* @param string $privkey
* @param string $remoteip
* @param string $challenge
* @param string $response
* @param array $extra_params an array of extra variables to post to the server
* @return ReCaptchaResponse
*/
function recaptcha_check_answer($privkey, $remoteip, $challenge, $response, $extra_params = array())
{
if ($privkey == null || $privkey == "") {
return "Required reCAPTCHA Keys missing from Setup > General Settings > Security";
}
if ($remoteip == null || $remoteip == "") {
return "For security reasons, you must pass the remote ip to reCAPTCHA";
}
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();
if (trim($answers[0]) == "true") {
$recaptcha_response->is_valid = true;
} else {
$recaptcha_response->is_valid = false;
$recaptcha_response->error = $answers[1];
}
return $recaptcha_response;
}
示例4: strlen
$req = _recaptcha_qsencode($data);
$http_request = "POST {$path} HTTP/1.0\r\n";
$http_request .= "Host: {$host}\r\n";
$http_request .= "Content-Type: application/x-www-form-urlencoded;\r\n";
$http_request .= "Content-Length: " . strlen($req) . "\r\n";
$http_request .= "User-Agent: reCAPTCHA/PHP\r\n";
$http_request .= "\r\n";
$http_request .= $req;
$response = '';
if (false == ($fs = @fsockopen($host, $port, $errno, $errstr, 10))) {
die('Could not open socket');
}
fwrite($fs, $http_request);
while (!feof($fs)) {
$response .= fgets($fs, 1160);
}
// One TCP-IP packet
fclose($fs);
$response = explode("\r\n\r\n", $response, 2);
return $response;
}
/**
* Gets the challenge HTML (javascript and non-javascript version).
* This is called from the browser, and the resulting reCAPTCHA HTML widget
* is embedded within the HTML form it was called from.
* @param string $pubkey A public key for reCAPTCHA
* @param string $error The error given by reCAPTCHA (optional, default is null)