<?php
 
function checkIp($ip) {
    $apiKey = "745b2f5b36fd29"; // Remplacez par votre clé API.
    $url = "https://ipinfo.io/{$ip}/json?token={$apiKey}";

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    $response = curl_exec($ch);
    curl_close($ch);

    $data = json_decode($response, true);
    var_dump($data);
    if (isset($data['bogon']) || (isset($data['privacy']) && $data['privacy']['vpn'] === true)) {
        return "VPN detected for IP: {$ip}";
    }

    return "IP: {$ip} is real.";
}

// Example usage
$ip ='52.29.15.216'; // Capture l'adresse IP de l'utilisateur
echo checkIp($ip);
?>
