function __construct() { if ($_SERVER['REQUEST_METHOD'] == 'POST') { if (!self::$isLogged) { $params = array(); $params['secret'] = '6Lf3ZxMTAAAAANVc5p92ISpeXZp8oTTrOr5WS6iD'; // Secret key if (!empty($_POST) && isset($_POST['g-recaptcha-response'])) { $params['response'] = urlencode($_POST['g-recaptcha-response']); } $params['remoteip'] = $_SERVER['REMOTE_ADDR']; $params_string = http_build_query($params); $requestURL = 'https://www.google.com/recaptcha/api/siteverify?' . $params_string; $curl = curl_init(); curl_setopt_array($curl, array(CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => $requestURL)); $response = curl_exec($curl); curl_close($curl); $response = @json_decode($response, true); } if (isset($response) && $response["success"] != true) { self::$isCaptchaValid = false; echo '<h3 class="alert alert-danger">Captcha - bład w weryfikacji</h3>'; } else { if (isset($response["success"]) || self::$isLogged) { self::$isCaptchaValid = true; echo '<h3 class="alert alert-success">E-mail zostal wyslany</h3>'; } } include 'FormResults.php'; new FormResults($_POST); } }