<?php
// File to save data
$logFile = __DIR__ . "/incoming_data.txt";

// Get current date/time
$timestamp = date("Y-m-d H:i:s");

// Capture request data
$rawInput = file_get_contents("php://input"); // catches JSON, XML, etc.
$data = [
    "GET"  => $_GET,
    "POST" => $_POST,
    "RAW"  => $rawInput
];

// Format nicely
$entry  = "============================\n";
$entry .= "Date: $timestamp\n";
$entry .= "============================\n";
$entry .= print_r($data, true);
$entry .= "\n\n\n"; // a few blank lines before next data

// Append to file
file_put_contents($logFile, $entry, FILE_APPEND | LOCK_EX);

// Optional: return a simple response
echo "OK";
