Linux SRV-16 6.18.44-paas #1 SMP PREEMPT_DYNAMIC Thu Aug 13 10:08:12 UTC 2026 x86_64
/
srv
/
data
/
web
/
vhosts
/
www.shinegis.mu
/
htdocs
/
functions
/
/srv/data/web/vhosts/www.shinegis.mu/htdocs/functions/recaptcha.php
<?php /** * Google reCAPTCHA v3 Verification Functions * * This file contains functions for verifying Google reCAPTCHA v3 * Used by all forms on the website to prevent spam submissions */ // Your reCAPTCHA keys - replace with your actual keys $recaptcha_site_key = '6Lf4VgYrAAAAAI8VrB60hnyjNGlHbBdxkkJA3fiJ'; $recaptcha_secret_key = '6Lf4VgYrAAAAAPmWHkjKRTIPyCtYmklWoqS4dE-Z'; /** * Verifies a reCAPTCHA token * * @param string $token The reCAPTCHA token from the form submission * @param float $min_score The minimum score required (0.0 to 1.0, default 0.5) * @return bool True if verification successful and score meets minimum, false otherwise */ function verify_recaptcha($token, $min_score = 0.5) { global $recaptcha_secret_key; // Data to send to Google $data = array( 'secret' => $recaptcha_secret_key, 'response' => $token, 'remoteip' => $_SERVER['REMOTE_ADDR'] ); // Make the POST request $options = array( 'http' => array( 'header' => "Content-type: application/x-www-form-urlencoded\r\n", 'method' => 'POST', 'content' => http_build_query($data) ) ); $context = stream_context_create($options); $response = file_get_contents('https://www.google.com/recaptcha/api/siteverify', false, $context); $result = json_decode($response, true); // Check if verification was successful and score meets threshold if (isset($result['success']) && $result['success'] && isset($result['score']) && $result['score'] >= $min_score) { return true; } return false; } /** * Returns the HTML for the reCAPTCHA hidden input field * * @param string $action The form action name (e.g., 'contact', 'devis') * @return string HTML for the hidden input field */ function recaptcha_hidden_input($action) { return '<input type="hidden" name="g-recaptcha-response" id="g-recaptcha-response-' . $action . '">'; }