diff --git a/source/_partials/contact_form.blade.php b/source/_partials/contact_form.blade.php index 45224328..d8810fae 100644 --- a/source/_partials/contact_form.blade.php +++ b/source/_partials/contact_form.blade.php @@ -129,7 +129,7 @@ function loadImage(token) { if (this.readyState == 4) { if (this.status == 200) { - window.top.location.href = 'thank-you-contact' + window.top.location.href = '{{ locale_url($page, 'thank-you-contact') }}' } else { let message = document.getElementById('message') message.textContent = '{{ $page->t( 'Invalid Captcha') }}' diff --git a/suitecrm-form-middleware/audio_captcha.php b/suitecrm-form-middleware/audio_captcha.php index be6787a2..fae85c56 100644 --- a/suitecrm-form-middleware/audio_captcha.php +++ b/suitecrm-form-middleware/audio_captcha.php @@ -5,6 +5,7 @@ use Gregwar\Captcha\CaptchaBuilder; use Libresign\Espeak\Espeak; +\App\Support\Http\SessionCookie::configureCrossSite(); session_start(); header("Access-Control-Allow-Origin: {$_ENV['URL_SITE']}"); diff --git a/suitecrm-form-middleware/captcha.php b/suitecrm-form-middleware/captcha.php index 8a96d9d0..98f78103 100644 --- a/suitecrm-form-middleware/captcha.php +++ b/suitecrm-form-middleware/captcha.php @@ -7,6 +7,7 @@ $builder = new CaptchaBuilder(); $builder->build(); +\App\Support\Http\SessionCookie::configureCrossSite(); session_start(); header("Access-Control-Allow-Origin: {$_ENV['URL_SITE']}"); diff --git a/suitecrm-form-middleware/validate.php b/suitecrm-form-middleware/validate.php index 263e5453..ad44acf3 100644 --- a/suitecrm-form-middleware/validate.php +++ b/suitecrm-form-middleware/validate.php @@ -2,14 +2,17 @@ include "../vendor/autoload.php"; use Gregwar\Captcha\CaptchaBuilder; +\App\Support\Http\SessionCookie::configureCrossSite(); session_start(); header("Access-Control-Allow-Origin: {$_ENV['URL_SITE']}"); header("Access-Control-Allow-Credentials: true"); -$builder = new CaptchaBuilder($_SESSION['code']); +$builder = new CaptchaBuilder($_SESSION['code'] ?? null); $codeImg = filter_input(INPUT_POST, 'codeImg'); +session_write_close(); + if( !$builder->testPhrase($codeImg)){ http_response_code(404); return; @@ -29,6 +32,8 @@ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $formulario_data); +curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); +curl_setopt($ch, CURLOPT_TIMEOUT, 15); $resposta = curl_exec($ch); diff --git a/support/Http/SessionCookie.php b/support/Http/SessionCookie.php new file mode 100644 index 00000000..8995dc98 --- /dev/null +++ b/support/Http/SessionCookie.php @@ -0,0 +1,22 @@ + 0, + 'path' => '/', + 'secure' => $isHttps, + 'httponly' => true, + 'samesite' => $isHttps ? 'None' : 'Lax', + ]); + } +}