<?php
$callFile = "call_data.txt";  // Your existing file
$historyFile = "history.txt"; // File to store history

// Read the current number
$number = trim(file_get_contents($callFile));

// Read history
$history = file_exists($historyFile) ? file($historyFile, FILE_IGNORE_NEW_LINES) : [];

// Store only new numbers in history
if ($number !== "" && !in_array($number, $history)) {
    $history[] = $number;
    file_put_contents($historyFile, implode("\n", $history));
}

// Return history
echo json_encode(["history" => $history]);
?>
