ok

Mini Shell

Direktori : /home2/selectio/www/limpiar.in.net/app/Rules/
Upload File :
Current File : //home2/selectio/www/limpiar.in.net/app/Rules/Recaptcha.php

<?php

namespace App\Rules;

use Illuminate\Contracts\Validation\Rule;

class Recaptcha implements Rule
{
    /**
     * Create a new rule instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Determine if the validation rule passes.
     *
     * @param  string  $attribute
     * @param  mixed  $value
     * @return bool
     */
    public function passes($attribute, $value)
    {
        $data = array(
            'secret' => env('RECAPTCHA_SECRET_KEY'),
            'response' => $value
        );

        try {
            $verify = curl_init();
            curl_setopt(
                $verify,
                CURLOPT_URL,
                "https://www.google.com/recaptcha/api/siteverify"
            );
            curl_setopt($verify, CURLOPT_POST, true);
            curl_setopt(
                $verify,
                CURLOPT_POSTFIELDS,
                http_build_query($data)
            );
            curl_setopt($verify, CURLOPT_SSL_VERIFYPEER, false);
            curl_setopt($verify, CURLOPT_RETURNTRANSFER, true);
            $response = curl_exec($verify);

            return json_decode($response)->success;
        } catch (\Exception $e) {
            return false;
        }
    }

    /**
     * Get the validation error message.
     *
     * @return string
     */
    public function message()
    {
        return 'reCAPTCHA verification failed.';
    }
}

Zerion Mini Shell 1.0