25 lines
496 B
PHP
25 lines
496 B
PHP
<?php namespace App\Traits;
|
|
|
|
use Input;
|
|
use ReCaptcha\ReCaptcha;
|
|
|
|
trait CaptchaTrait {
|
|
|
|
public function captchaCheck()
|
|
{
|
|
|
|
$response = Input::get('g-recaptcha-response');
|
|
$remoteip = $_SERVER['REMOTE_ADDR'];
|
|
$secret = env('CAPTCHA_SECRET_KEY');
|
|
|
|
$recaptcha = new ReCaptcha($secret);
|
|
$resp = $recaptcha->verify($response, $remoteip);
|
|
if ($resp->isSuccess()) {
|
|
return 1;
|
|
} else {
|
|
return 0;
|
|
}
|
|
|
|
}
|
|
|
|
} |