From c8f3e7059db143726150b4f649f399de865ff138 Mon Sep 17 00:00:00 2001 From: ssbg04 Date: Sat, 6 Jun 2026 09:17:54 +0800 Subject: [PATCH] meow --- index.php | 32 ++++++++++++++++++++++++++++---- send_contact.php | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 4 deletions(-) diff --git a/index.php b/index.php index 81c96c6..ba88e99 100755 --- a/index.php +++ b/index.php @@ -33,7 +33,7 @@ $contactEmail = $_ENV['CONTACT_EMAIL'] ?? getenv('CONTACT_EMAIL') Cris Charles Garcia | Software Developer - + @@ -208,14 +208,38 @@ $contactEmail = $_ENV['CONTACT_EMAIL'] ?? getenv('CONTACT_EMAIL')
+ - -
-
+ + + + + diff --git a/send_contact.php b/send_contact.php index 0418c33..abd454c 100644 --- a/send_contact.php +++ b/send_contact.php @@ -19,6 +19,41 @@ if ($_SERVER['REQUEST_METHOD'] !== 'POST') { exit(); } +// ------------------------------------------------------------- +// Verify Google reCAPTCHA +// ------------------------------------------------------------- +$recaptchaSecret = $_ENV['RECAPTCHA_SECRET_KEY'] ?? getenv('RECAPTCHA_SECRET_KEY'); +$recaptchaResponse = $_POST['g-recaptcha-response'] ?? ''; + +if (empty($recaptchaResponse)) { + header("Location: index.php?status=error&msg=Please complete the reCAPTCHA verification.#contact"); + exit(); +} + +// Use native PHP to verify the token (No Composer required!) +$verifyUrl = 'https://www.google.com/recaptcha/api/siteverify'; +$verifyData = [ + 'secret' => $recaptchaSecret, + 'response' => $recaptchaResponse, + 'remoteip' => getClientIp() +]; + +$options = [ + 'http' => [ + 'header' => "Content-type: application/x-www-form-urlencoded\r\n", + 'method' => 'POST', + 'content' => http_build_query($verifyData) + ] +]; +$context = stream_context_create($options); +$verifyResult = file_get_contents($verifyUrl, false, $context); +$responseData = json_decode($verifyResult); + +if (!$responseData || !$responseData->success) { + header("Location: index.php?status=error&msg=reCAPTCHA verification failed. Please try again.#contact"); + exit(); +} + $clientIp = getClientIp(); $rateLimit = intval($_ENV['RATE_LIMIT'] ?? getenv('RATE_LIMIT') ?? 10);