当前位置: 首页>>代码示例>>PHP>>正文


PHP _recaptcha_http_post函数代码示例

本文整理汇总了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;
}
开发者ID:purna89,项目名称:TrellisDesk,代码行数:37,代码来源:recaptchalib.php

示例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;
}
开发者ID:slaFFik,项目名称:l10n-ru,代码行数:35,代码来源:recaptchalib.php

示例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;
}
开发者ID:billyprice1,项目名称:whmcs,代码行数:34,代码来源:recaptchalib.php

示例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)
开发者ID:gp6shc,项目名称:aok,代码行数:27,代码来源:recaptchalib.php

示例5:

<?php
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:1,代码来源:recaptchalib.php


注:本文中的_recaptcha_http_post函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。