<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $data = json_decode(file_get_contents('php://input'), true);

    if (!empty($data['ip']) && !empty($data['country']) && !empty($data['city'])) {
        $logEntry = date("Y-m-d H:i:s") . " | IP: " . $data['ip'] . " | Country: " . $data['country'] . " | City: " . $data['city'] . PHP_EOL;

        // Append data to ips.txt
        file_put_contents("ips.txt", $logEntry, FILE_APPEND);
    }
}
?>
