HEX
Server: LiteSpeed
System: Linux my-kul-web2054.main-hosting.eu 5.14.0-611.13.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 11 04:57:59 EST 2025 x86_64
User: u665686179 (665686179)
PHP: 8.2.30
Disabled: system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail
Upload Files
File: /home/u665686179/domains/dealkr.com/public_html/app/Traits/RecaptchaTrait.php
<?php

namespace App\Traits;

use Gregwar\Captcha\PhraseBuilder;
use Gregwar\Captcha\CaptchaBuilder;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\Facades\Response;

trait RecaptchaTrait
{
    protected function isGoogleRecaptchaValid(string $reCaptchaValue): bool
    {
        $secret = getWebConfig(name: 'recaptcha')['secret_key'];
        $response = Http::asForm()->post('https://www.google.com/recaptcha/api/siteverify', [
            'secret' => $secret,
            'response' => $reCaptchaValue,
            'remoteip' => request()->ip(),
        ]);

        return $response->json('success') === true && $response->json('score') > 0.5;
    }

    public function generateDefaultReCaptcha(int $captureLength): CaptchaBuilder
    {
        $phrase = new PhraseBuilder;
        $code = $phrase->build($captureLength);
        $builder = new CaptchaBuilder($code, $phrase);
        $builder->setBackgroundColor(220, 210, 230);
        $builder->setMaxAngle(25);
        $builder->setMaxBehindLines(0);
        $builder->setMaxFrontLines(0);
        $builder->build($width = 100, $height = 40, $font = null);
        return $builder;
    }


    public function saveRecaptchaValueInSession(string $sessionKey, string $sessionValue):void{
        if (Session::has($sessionKey)) {
            Session::forget($sessionKey);
        }
        Session::put($sessionKey, $sessionValue);
    }
}