本文整理汇总了PHP中ReCaptcha::verify方法的典型用法代码示例。如果您正苦于以下问题:PHP ReCaptcha::verify方法的具体用法?PHP ReCaptcha::verify怎么用?PHP ReCaptcha::verify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReCaptcha
的用法示例。
在下文中一共展示了ReCaptcha::verify方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testVerifyReturnsResponse
public function testVerifyReturnsResponse()
{
$method = $this->getMock('\\ReCaptcha\\RequestMethod', array('submit'));
$method->expects($this->once())->method('submit')->with($this->callback(function ($params) {
return true;
}))->will($this->returnValue('{"success": true}'));
$rc = new ReCaptcha('secret', $method);
$response = $rc->verify('response');
$this->assertTrue($response->isSuccess());
}
示例2: frontend_validate
/**
* {@inheritdoc}
*/
public function frontend_validate(array $item, $input_value)
{
$mesages = array('not-configured' => __('Could not validate the form', 'fw'), 'not-human' => __('Please fill the recaptcha', 'fw'));
$keys = fw_ext('forms')->get_db_settings_option('recaptcha-keys');
if (empty($keys)) {
return $mesages['not-configured'];
}
$recaptcha = new ReCaptcha($keys['secret-key']);
$gRecaptchaResponse = FW_Request::POST('g-recaptcha-response');
if (empty($gRecaptchaResponse)) {
return $mesages['not-human'];
}
$resp = $recaptcha->verify($gRecaptchaResponse);
if ($resp->isSuccess()) {
return false;
} else {
$errors = $resp->getErrorCodes();
return $mesages['not-human'];
}
}
示例3: verify_recaptcha
private function verify_recaptcha($client_ip, $response)
{
$rcmail = rcmail::get_instance();
$privatekey = $rcmail->config->get('recaptcha_privatekey');
require_once $this->home . '/lib/recaptchalib.php';
$reCaptcha = new ReCaptcha($privatekey);
$resp = $reCaptcha->verify($response, $client_ip);
return $resp != null && $resp->success;
}
示例4: ReCaptcha
* \details Pantalla de registro en la aplicación. Añade cabeceras, muestra
* los mensajes de error de action_register.php y define la estructura del layout.
* \author auth.agoraUS
*/
require_once 'captcha/ReCaptcha.php';
require_once 'captcha/RequestMethod.php';
require_once 'captcha/RequestParameters.php';
require_once 'captcha/Response.php';
require_once 'captcha/RequestMethod/Post.php';
require_once 'captcha/RequestMethod/Socket.php';
require_once 'captcha/RequestMethod/SocketPost.php';
$clave_del_sitio = "6LfD6hcTAAAAAOLQVRMu_oJA4eCRIUxGj0tAo8HJ";
$clave_secreta = "6LfD6hcTAAAAALJdSU9xW9qZfDy0PkvcJLPs7HE4";
if ($_POST['accion'] == 'enviar') {
$recaptcha = new ReCaptcha($clave_secreta);
$respuesta = $recaptcha->verify($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);
if ($respuesta->isSuccess()) {
echo 'El formulario ha sido validado';
} else {
echo 'Se ha devuelto el siguiente error:';
foreach ($respuesta->getErrorCodes() as $error_code) {
echo '<tt>' . $error_code . '</tt> ';
}
}
}
include_once "database.php";
session_start();
?>
<!DOCTYPE html>
<html lang="es" xmlns="http://www.w3.org/1999/xhtml">
<head>
示例5: check_captcha
private function check_captcha()
{
if ($this->type == 'create' && $this->captcha) {
//check if capcha key is set
$captcha_key = get_option('ihc_recaptcha_public');
if (!$captcha_key) {
$captcha = ihc_array_value_exists($this->register_fields, 'recaptcha', 'name');
unset($this->register_fields[$captcha]);
return;
}
$captcha = ihc_array_value_exists($this->register_fields, 'recaptcha', 'name');
if ($captcha && $this->register_fields[$captcha]['display']) {
$captha_err = get_option('ihc_register_err_recaptcha');
unset($this->register_fields[$captcha]);
if (isset($_REQUEST['g-recaptcha-response'])) {
$secret = get_option('ihc_recaptcha_private');
if ($secret) {
include_once IHC_PATH . 'classes/ReCaptcha/ReCaptcha.php';
$recaptcha = new ReCaptcha($secret);
$resp = $recaptcha->verify($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);
if (!$resp->isSuccess()) {
$this->errors[] = $captha_err;
}
} else {
$this->errors[] = $captha_err;
}
} else {
$this->errors[] = $captha_err;
}
}
}
}