<?php
    $req = file_get_contents("php://input");
    $request = json_decode($req, true);

    $remoteip = $_SERVER['HTTP_X_FORWARDED_FOR'];

    $data = [
        'secret' => '6LepzaIUAAAAAAuE6zbtP7xGMbvroLoXAzmv3GWA'
        ,'response' => $request['g-recaptcha-response']
        ,'remoteip' => $remoteip
    ];

    $ch = curl_init('https://www.google.com/recaptcha/api/siteverify');
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
    curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/x-www-form-urlencoded']);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $result = curl_exec($ch);
    curl_close($ch);
    $result = json_decode($result);
    
    echo json_encode($result, true);
?>