public function postAction(Request $request)
 {
     $repo = $this->get('tekstove.user.repository');
     /* @var $repo \Tekstove\ApiBundle\Model\User\UserRepository */
     $recaptchaSecret = $this->container->getParameter('tekstove_api.recaptcha.secret');
     $requestData = \json_decode($request->getContent(), true);
     $userData = $requestData['user'];
     $recaptchaData = $requestData['recaptcha'];
     $user = new User();
     try {
         $recaptcha = new \ReCaptcha\ReCaptcha($recaptchaSecret);
         $recaptchaResponse = $recaptcha->verify($recaptchaData['g-recaptcha-response']);
         if (!$recaptchaResponse->isSuccess()) {
             $recaptchaException = new UserHumanReadableException("Recaptcha validation failed");
             $recaptchaException->addError("recaptcha", "Validation failed");
             throw $recaptchaException;
         }
         $user->setUsername($userData['username']);
         $user->setMail($userData['mail']);
         $user->setPassword($this->hashPassword($userData['password']));
         $user->setapiKey(sha1(str_shuffle(uniqid())));
         $repo->save($user);
     } catch (UserHumanReadableException $e) {
         $view = $this->handleData($request, $e->getErrors());
         $view->setStatusCode(400);
         return $view;
     }
 }
 /**
  * check the validity of the recaptcha
  *
  * @return obj (@see ReCaptchaResponse)
  */
 function check()
 {
     // Check the recaptcha answer and only submit if correct
     $recaptcha = new \ReCaptcha\ReCaptcha($this->getConf('privatekey'));
     $resp = $recaptcha->verify($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);
     return $resp;
 }
Beispiel #3
0
 /**
  * @Route("/new", name="inquiry_new")
  * @Method({"GET", "POST"})
  * @Template
  */
 public function newAction(Request $request)
 {
     $session = $request->getSession();
     $inquiry = $session->get('inquiry');
     if (is_null($inquiry)) {
         $inquiry = new Inquiry();
     }
     $form = $this->createForm(new InquiryType(), $inquiry);
     if ($request->getMethod() === 'POST') {
         $form->handleRequest($request);
         $secret = '6Le7bQoTAAAAAEldbtTEZcpQbW4uYJMT4KlM4WTx';
         $recaptcha = new \ReCaptcha\ReCaptcha($secret);
         $resp = $recaptcha->verify($request->request->get('g-recaptcha-response'), $request->getClientIp());
         if ($resp->isSuccess()) {
             // verified!
             // Store data
             $this->get('InquiryService')->save($inquiry);
             // Send email to user
             $this->sendEmail($inquiry->getMail(), '[BGM555] お問い合わせ内容の控え', 'Bgm555AppBundle:Inquiry:thanks.mail.txt.twig', array('inquiry' => $inquiry));
             $this->sendEmail('*****@*****.**', '[BGM555] お問い合わせ内容の控え', 'Bgm555AppBundle:Inquiry:thanks.mail.txt.twig', array('inquiry' => $inquiry));
             $session->remove('inquiry');
             return $this->redirect($this->generateUrl('inquiry_thanks'));
         } else {
             // Failed!
             throw new \Exception('You are not allowed to post. Sorry, try from another IP.');
             // $errors = $resp->getErrorCodes();
         }
         // $session->set('inquiry', $inquiry);
         // return $this->redirect($this->generateUrl('inquiry_confirm'));
     }
     return array('form' => $form->createView());
 }
 public function postSend(Request $request)
 {
     if (Auth::check()) {
         $this->validate($request, ["message" => "required|min:5|max:1000"]);
         $email = Auth::user()->email;
     } else {
         $this->validate($request, ["email" => "required|email|max:255", "message" => "required|min:5|max:1000", 'g-recaptcha-response' => 'required']);
         $recaptcha = new \ReCaptcha\ReCaptcha(Config::get('site.recaptcha_secret'));
         $resp = $recaptcha->verify($request->input('g-recaptcha-response'));
         if (!$resp->isSuccess()) {
             return redirect()->back();
         }
         $email = $request->input('email');
     }
     $mess = $request->input('message');
     $admins = User::whereHas('permissions', function ($query) {
         $query->where('is_admin', true);
     })->get();
     $from = $email;
     foreach ($admins as $admin) {
         $to = $admin->email;
         Mail::send('emails.contact.send', ['mess' => $mess, 'from' => $from], function ($message) use($to) {
             $message->subject('Contact us')->to($to);
         });
     }
     notify()->flash('Thank you', 'success', ['text' => 'Your message sent to our inbox.']);
     return redirect()->route('contact');
 }
 public function login(Request $request)
 {
     $this->validateLogin($request);
     $recaptcha = new \ReCaptcha\ReCaptcha(config('recaptcha.secret_key'));
     $resp = $recaptcha->verify($request->request->get('g-recaptcha-response'), $request->REMOTE_ADDR);
     if (!$resp->isSuccess()) {
         return redirect('/login');
     }
     // If the class is using the ThrottlesLogins trait, we can automatically throttle
     // the login attempts for this application. We'll key this by the username and
     // the IP address of the client making these requests into this application.
     $throttles = $this->isUsingThrottlesLoginsTrait();
     if ($throttles && ($lockedOut = $this->hasTooManyLoginAttempts($request))) {
         $this->fireLockoutEvent($request);
         return $this->sendLockoutResponse($request);
     }
     $credentials = $this->getCredentials($request);
     if (Auth::guard($this->getGuard())->attempt($credentials, $request->has('remember'))) {
         return $this->handleUserWasAuthenticated($request, $throttles);
     }
     // If the login attempt was unsuccessful we will increment the number of attempts
     // to login and redirect the user back to the login form. Of course, when this
     // user surpasses their maximum number of attempts they will get locked out.
     if ($throttles && !$lockedOut) {
         $this->incrementLoginAttempts($request);
     }
     return $this->sendFailedLoginResponse($request);
 }
function validate()
{
    require 'recaptcha/src/autoload.php';
    $secret = '';
    $recaptcha = new \ReCaptcha\ReCaptcha($secret);
    header('Content-Type: text/html; charset=utf-8');
    $onlineip = $_SERVER['REMOTE_ADDR'];
    $username = $_POST['username'];
    $resp = $recaptcha->verify($_POST['g-recaptcha-response'], $onlineip);
    if ($resp->isSuccess()) {
        echo '<p style="color:RED;font-size:20px">驗證成功。</p>';
        $checktime = time();
        $conn = mysql_connect('localhost', '', '') or die('SQL error');
        mysql_select_db('', $conn);
        mysql_query("SET NAMES 'utf8'");
        $del = "DELETE FROM phpeb_ip_sec WHERE username='******'";
        $ins = "INSERT INTO phpeb_ip_sec (ipaddr, username, checktime) VALUES ('{$onlineip}', '{$username}', '{$checktime}')";
        mysql_query($del, $conn);
        mysql_query($ins, $conn);
        mysql_close($conn);
    } else {
        echo '<p style="color:RED;font-size:20px">未能通過驗證。</p>';
        echo '<p style="color:RED;font-size:20px">請重新驗證。</p>';
    }
}
 public function save()
 {
     $model = new Model_Message();
     $secret = '6LemgRATAAAAALr4NfdQTMIA8WeWaN-fof0NzI7z';
     $recaptcha = new \ReCaptcha\ReCaptcha($secret);
     $resp = $recaptcha->verify($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);
     if (!$resp->isSuccess()) {
         $errors[] = 'Вы неправильно ввели капчу!';
     }
     if (empty($_POST['name'])) {
         $errors[] = 'Вы не ввели имя!';
     }
     if (empty($_POST['email'])) {
         $errors[] = 'Вы не ввели email!';
     }
     if (empty($_POST['message'])) {
         $errors[] = 'Вы не ввели сообщение!';
     }
     if (!empty($_POST['name']) and (strlen($_POST['name']) < 2 or strlen($_POST['name']) > 32)) {
         $errors[] = 'Имя должно содержать от 2 до 32 символов!';
     }
     if (!empty($_POST['email']) and !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
         $errors[] = 'Введите валидный email!';
     }
     if (!empty($errors)) {
         $this->template->vars('errors', $errors);
         $this->template->view('index');
     }
     if (empty($errors)) {
         $data = ['name' => $_POST['name'], 'email' => $_POST['email'], 'message' => $_POST['message']];
         $model->save($data);
         $model->redirect('/message');
     }
 }
 /**
  * Register University
  * 
  * @return View
  */
 public function registerUniversity()
 {
     if (!is_null(Input::get('g-recaptcha-response'))) {
         $recaptcha = new \ReCaptcha\ReCaptcha(Config::get('recaptcha.private_key'));
         $resp = $recaptcha->verify(Input::get('g-recaptcha-response'), Request::server('REMOTE_ADDR'));
         if ($resp->isSuccess()) {
             $user = new User();
             $user->user = trim(strtolower(Input::get('university_email')));
             $user->password = Hash::make(Input::get('university_password'));
             $user->rank = "university";
             $user->last_activity = null;
             try {
                 $user->save();
             } catch (MongoDuplicateKeyException $e) {
                 return Redirect::back()->withErrors(array('error' => Lang::get('register_university.email_duplicated')));
             }
             $user = User::first(['user' => $user->user]);
             $university = new University();
             $university->_id = $user->_id;
             $university->name = trim(Input::get('university_name'));
             $university->email = trim(strtolower(Input::get('university_email')));
             $university->acronym = strtoupper(trim(Input::get('university_acronym')));
             $university->profile_image = null;
             $university->save();
             return Redirect::to('/')->with('message', Lang::get('register_university.register_true'));
         } else {
             $errors = $resp->getErrorCodes();
             return Redirect::back()->withErrors(array('error' => Lang::get('register_student.message_captcha') . ' [' . $errors[0] . ']'));
         }
     } else {
         return Redirect::back()->withErrors(array('error' => Lang::get('register_student.message_captcha') . ' [ 99 ]'));
     }
 }
Beispiel #9
0
 public function Post(Request $request)
 {
     $recaptcha = new \ReCaptcha\ReCaptcha('6LfWHfkSAAAAAMj0Kkhn1FJV6y-RiSZ_M9rasufn');
     $resp = $recaptcha->verify($request->input('g-recaptcha-response'), $request->ip());
     $msgValidation = trim(strip_tags(str_replace("&nbsp;", ' ', $request->input('message'))));
     $username = trim(strip_tags(str_replace("&nbsp;", ' ', $request->input('name'))));
     $errors = [];
     if (!Auth::check() && strlen($username) < 3) {
         array_push($errors, 'Veuillez saisir un nom d\'utilisateur d\'au moins 3 caractères svp !');
     }
     if (strlen($msgValidation) == 0) {
         array_push($errors, 'Le message est obligatoire !');
     }
     if (!$resp->isSuccess()) {
         array_push($errors, 'Veuillez renseigner le captcha svp !');
     }
     if (count($errors) == 0) {
         $msg = new Message();
         if (Auth::check()) {
             $msg->author_id = $request->user()->id;
         } else {
             $msg->username = $username;
         }
         $msg->message = $msgValidation;
         $msg->remote_addr = $request->ip();
         $msg->save();
         return redirect()->route('minichat');
     }
     Session::flash('errors', $errors);
     return redirect()->route('minichat')->withInput();
 }
Beispiel #10
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $v = Validator::make($request->all(), ['username' => 'required|unique:users|alpha_num', 'email' => 'required|unique:users|email', 'emailConfirmation' => 'required|same:email', 'password' => 'required', 'passwordConfirmation' => 'required|same:password', 'tos' => 'required']);
     //recaptcha implementation
     $recaptcha = new \ReCaptcha\ReCaptcha(Setting::getSetting('recaptchasecret'));
     $resp = $recaptcha->verify($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);
     //dd($resp);
     if ($v->fails() || $resp->isSuccess() == false) {
         if ($resp->isSuccess() == false) {
             $v->errors()->add('g-recaptcha', 'Би машин биш гэсэн чагтыг тэмдэглэнэ үү');
         }
         $errors = $v->errors();
         $return['status'] = false;
         $return['errors'] = $errors;
         //return redirect('/user/register')->back()->withErrors($v->errors())->withInput($request->except('password'));
     } else {
         $user = new User();
         $user->email = $request->input('email');
         $user->password = Hash::make($request->input('password'));
         $user->register_ip = $_SERVER['REMOTE_ADDR'];
         $user->registered_with = 'local';
         $user->public = 0;
         $user->status = 1;
         $user->role = 2;
         $user->save();
         $this->sendThankYouEmail($user);
         Auth::login($user, true);
         $return['status'] = true;
         $return['url'] = url('/user/profile/' . $user->usr_id);
     }
     return $return;
 }
Beispiel #11
0
function recaptcha_check_answer($privkey, $challenge)
{
    if ($privkey == null || $privkey == '') {
        die('To use reCAPTCHA you must get an API key from <a href="https://www.google.com/recaptcha/intro/index.html">https://www.google.com/recaptcha/intro/index.html</a>');
    }
    $recaptcha = new \ReCaptcha\ReCaptcha($privkey);
    $response = $recaptcha->verify($challenge);
    return $response->isSuccess();
}
 function validateRecaptcha($form)
 {
     $recaptcha = new \ReCaptcha\ReCaptcha($this->config['ReCaptcha']['secret']);
     $resp = $recaptcha->verify($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);
     if (!$resp->isSuccess()) {
         return new TimecapslError("Unable to verify ReCaptcha: " . join(', ', $resp->getErrorCodes()));
     }
     return new TimecapslSuccess($form);
 }
 public function sendmessageAction(Request $request)
 {
     $result = array('success' => 0);
     // false
     $request = $this->get('request');
     if ($request->getMethod() == 'POST') {
         $errors = array();
         $data = $request->request->all();
         $nom = $data["nom"];
         if (strlen(trim($nom)) == 0) {
             $errors["nom"] = "Veuillez compl&eacute;ter le champ nom.";
         }
         $mailfrom = $data["email"];
         if (strlen(trim($mailfrom)) == 0) {
             $errors["email"] = "Veuillez compl&eacute;ter le champ email.";
         } else {
             $emailConstraint = new EmailConstraint();
             $emailConstraint->message = 'Veuillez saisir une adresse mail valide.';
             $mailingerror = $this->get('validator')->validateValue($mailfrom, $emailConstraint);
             if (count($mailingerror) != 0) {
                 $errors["email"] = "Veuillez saisir une adresse mail valide.";
             }
         }
         $sujet = $data["sujet"];
         if (strlen(trim($sujet)) == 0) {
             $errors["sujet"] = "Veuillez compl&eacute;ter le champ sujet.";
         }
         $message = $data["message"];
         if (strlen(trim($message)) == 0) {
             $errors["message"] = "Veuillez compl&eacute;ter le champ message.";
         }
         // Vérification Captcha :
         //------------------------
         $this->siteKey = $this->getParameter('recaptcha_siteKey');
         $this->secret = $this->getParameter('recaptcha_secretKey');
         $recaptcha = new \ReCaptcha\ReCaptcha($this->secret);
         $resp = $recaptcha->verify($data['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);
         if (!$resp->isSuccess()) {
             // $msg = "";
             // foreach ($resp->getErrorCodes() as $code) $msg .= '<br>'.$code;
             $errors['g-recaptcha-response'] = "Vous n'avez pas complété correctement le Captcha.";
             //.$msg;
         }
         if (count($errors) > 0) {
             $result['errors'] = $errors;
         } else {
             $email = \Swift_Message::newInstance()->setSubject('[mail via Adenia.fr] : ' . $sujet)->setFrom('*****@*****.**')->setTo('*****@*****.**')->setBody('Adresse exp&eacute;diteur : ' . $mailfrom . '<br/>' . $nom . ' a &eacute;crit : <br/><br/>' . $message, 'text/html', 'UTF-8');
             // 0 si personne n'a reçu le mail, X personnes sinon
             $result['success'] = $this->get('mailer')->send($email);
         }
     }
     /*
             else {
                     //captcha
             }*/
     return new JsonResponse($result);
 }
Beispiel #14
0
 /**
  * Check Google ReCaptcha
  * @param $gReCaptchaResponse
  * @return bool
  */
 public static function checkRecaptcha($gReCaptchaResponse)
 {
     $recaptcha = new \ReCaptcha\ReCaptcha(Config::get('RECAPTCHA_SECRET'));
     $resp = $recaptcha->verify($gReCaptchaResponse, Request::server('REMOTE_ADDR'));
     if ($resp->isSuccess()) {
         return true;
     } else {
         return false;
     }
 }
 public function processEventData($context)
 {
     if (!in_array('recaptcha2', $context['event']->eParamFILTERS)) {
         return;
     }
     include_once EXTENSIONS . '/recaptcha2/lib/autoload.php';
     $recaptcha = new \ReCaptcha\ReCaptcha($this->getPrivateKey());
     $resp = $recaptcha->verify($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);
     $context['messages'][] = array('recaptcha2', $resp->isSuccess(), !$resp->isSuccess() ? 'Wrong captcha.' : NULL);
 }
Beispiel #16
0
function boinc_recaptcha_isValidated($privatekey)
{
    if ($privatekey) {
        // tells ReCaptcha to use fsockopen() instead of get_file_contents()
        $recaptcha = new \ReCaptcha\ReCaptcha($privatekey, new \ReCaptcha\RequestMethod\SocketPost());
        $resp = $recaptcha->verify($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);
        return $resp->isSuccess();
    }
    return true;
}
function validateReCaptcha()
{
    $recaptcha = new \ReCaptcha\ReCaptcha("6Le1dRYTAAAAAPJd80pAeiHWqd0TwZ1r4BdwBYBo");
    $resp = $recaptcha->verify($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);
    if ($resp->isSuccess()) {
        // verified!
        return true;
    } else {
        return false;
    }
}
 function recaptchaIsValid()
 {
     require APP . 'vendors' . DS . 'recaptcha/src/autoload.php';
     $recaptcha = new \ReCaptcha\ReCaptcha(Configure::read('recaptcha_private'));
     $captcha_response = $recaptcha->verify($_POST['g-recaptcha-response'], $this->RequestHandler->getClientIP());
     if ($captcha_response->isSuccess()) {
         return true;
     }
     $this->set('recaptcha_error', 'CAPTCHA response failed. Please try again.');
     return false;
 }
 /**
  * Verifies a reCAPTCHA code
  * @param string $token Token received from client
  * @param string|null $ip IP address of client, or leave blank for requesting IP
  * @return bool Is captcha valid?
  */
 public static function verify_captcha($token, $ip = null)
 {
     if ($ip === null) {
         $ip = $_SERVER['REMOTE_ADDR'];
     }
     // defaults to remote address
     $recaptcha = new \ReCaptcha\ReCaptcha(getenv('RECAPTCHA_PRIVATEKEY'));
     $resp = $recaptcha->verify($token, $ip);
     // verify recaptcha
     return $resp->isSuccess();
 }
 /**
  *	@function   verify
  * 	@author		Dung Nguyen - admin@saledream.com	
  *	@access		public	
  *	@params		
  *	@date		23-Sep-2015
  * 	@return		
  */
 public static function verify()
 {
     //check params
     if (isset($_POST['g-recaptcha-response']) === false) {
         return false;
     }
     //verify user
     $recaptcha = new \ReCaptcha\ReCaptcha(self::SECRET);
     $response = $recaptcha->verify($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);
     return $response->isSuccess();
 }
Beispiel #21
0
 public static function verify($gresponse)
 {
     new Xaptcha();
     $recaptcha = new \ReCaptcha\ReCaptcha(self::$secret);
     $resp = $recaptcha->verify($gresponse, $_SERVER['REMOTE_ADDR']);
     if ($resp->isSuccess()) {
         return true;
     } else {
         return false;
     }
 }
 /**
  * Checks if the given value is a valid response from google's recaptcha.
  *
  * @param mixed $value The value that should be validated
  * @return void
  * @throws \TYPO3\Flow\Validation\Exception\InvalidValidationOptionsException
  * @api
  */
 protected function isValid($value)
 {
     if (!is_string($value)) {
         $this->addError('The given value was not a valid string.', 1450180930);
         return;
     }
     $recaptcha = new \ReCaptcha\ReCaptcha($this->options['secretKey']);
     $resp = $recaptcha->verify($value, $_SERVER['REMOTE_ADDR']);
     if ($resp->isSuccess() === false) {
         $this->addError('The captcha was not answered correctly. Please try again.', 1450180934);
     }
 }
 public function verifyCaptcha($privatekey)
 {
     $gRecaptchaResponse = filter_input(INPUT_POST, 'g-recaptcha-response', FILTER_SANITIZE_SPECIAL_CHARS);
     $recaptcha = new ReCaptcha\ReCaptcha($privatekey);
     $resp = $recaptcha->verify($gRecaptchaResponse, $_SERVER["REMOTE_ADDR"]);
     if ($resp->isSuccess()) {
         $mesg = 'Ok';
     } else {
         $mesg = 'No';
     }
     return $mesg;
 }
Beispiel #24
0
function validate_captcha()
{
    try {
        $captcha = new \ReCaptcha\ReCaptcha(CONFIG_RECAPTCHA_PRIVATE_KEY, new \ReCaptcha\RequestMethod\CurlPost());
        $response = $captcha->verify($_POST['g-recaptcha-response'], get_ip());
        if (!$response->isSuccess()) {
            message_error("Captcha error: " . print_r($response->getErrorCodes(), true));
        }
    } catch (Exception $e) {
        log_exception($e);
        message_error('Caught exception processing captcha. Please contact ' . (CONFIG_EMAIL_REPLYTO_EMAIL ? CONFIG_EMAIL_REPLYTO_EMAIL : CONFIG_EMAIL_FROM_EMAIL));
    }
}
 function register_widget_recaptcha_login_errors($user)
 {
     if (isset($_POST['g-recaptcha-response'])) {
         global $google_recaptcha_secret_key;
         $recaptcha = new \ReCaptcha\ReCaptcha($google_recaptcha_secret_key);
         $resp = $recaptcha->verify($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);
         if (!$resp->isSuccess()) {
             $user = new WP_Error('g-recaptcha-response', sprintf(wp_kses(__('<strong>ERROR</strong>: Invalid ReCaptcha.', 'loginregisterwidget'), array('strong' => array()))));
             return $user;
         }
     }
     return $user;
 }
Beispiel #26
0
 function processRecaptchaField($form, $key, &$data)
 {
     // Declare the response var.
     $resp = null;
     // Sanatize the $_POST data.
     $gRecaptchaResponse = sanitizeHTML($_POST["g-recaptcha-response"]);
     // Check for reCaptcha.
     $recaptcha = new \ReCaptcha\ReCaptcha(C('plugin.reCAPTCHA.secretkey'));
     $resp = $recaptcha->verify($gRecaptchaResponse, $_SERVER["REMOTE_ADDR"]);
     // If no valid captcha is submitted, show them an error.
     if (!$resp->isSuccess()) {
         $form->error("recaptcha", T("message.invalidCAPTCHA"));
     }
 }
 protected function validateAttribute($object, $attribute)
 {
     $recaptcha = new \ReCaptcha\ReCaptcha($this->privateKey);
     $resp = $recaptcha->verify($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);
     if (!$resp->isSuccess()) {
         if (!$this->errorDetail) {
             $message = $this->message !== null ? $this->message : Yii::t('yii', 'The verification code is incorrect.');
         } else {
             foreach ($resp->getErrorCodes() as $error) {
                 $message = $this->message . $error . ' ';
             }
         }
         $this->addError($object, $attribute, $message);
     }
 }
 /**
  * Register any application authentication / authorization services.
  *
  * @param  \Illuminate\Contracts\Auth\Access\Gate  $gate
  * @return void
  */
 public function boot(GateContract $gate)
 {
     $this->registerPolicies($gate);
     Validator::extend('recaptcha', function ($attribute, $value, $parameters, $validator) {
         $recaptcha = new \ReCaptcha\ReCaptcha(env('RECAPTCHA_SECRET', ''));
         $resp = $recaptcha->verify($value);
         if ($resp->isSuccess()) {
             return true;
         } else {
             $errors = $resp->getErrorCodes();
             Log::info("Recaptcha Error: " . json_encode($errors));
             return false;
         }
     });
 }
Beispiel #29
0
 function sendMessage(Request $request)
 {
     $secret = '6LekghMTAAAAAO9LeK19tw3PkDTGcKv4n3KgURTS';
     $response = $request->input('gresponse');
     $recaptcha = new \ReCaptcha\ReCaptcha($secret);
     $resp = $recaptcha->verify($response, $_SERVER['REMOTE_ADDR']);
     //$resp=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$secret."&response=".$_POST['g-recaptcha-response']."&remoteip=".$_SERVER['REMOTE_ADDR']);
     if ($resp->isSuccess()) {
         $newMessage = new Message();
         $newMessage->email = $response = $request->input('email');
         $newMessage->message = $response = $request->input('message');
         $newMessage->save();
         return response()->json(['notice' => "success"]);
     } else {
         return response()->json(['notice' => "fail"]);
     }
 }
 public function postSuggestion($params)
 {
     if (isset($_POST['doSuggest'])) {
         $recaptcha = new \ReCaptcha\ReCaptcha(getenv('RECAPTCHA_SECRET'));
         $resp = $recaptcha->verify($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);
         if ($resp->isSuccess()) {
             $err = $this->checkForInputErrors($_POST);
             if ($err) {
                 getSystem()->render('suggest', array_merge($_POST, array('recaptchaSiteKey' => getenv('RECAPTCHA_SITE_KEY'), 'errors' => $err)));
             } else {
                 $this->cleanAndSave($_POST);
             }
         } else {
             getSystem()->getRender()->error(500, 'It appears that you are a Robot. No luck here!');
         }
     }
 }