true, 'httponly' => true, 'samesite' => 'Strict']); session_start(); $session_lifetime = 3 * 60; $correct_username = "admin"; $correct_password_hash = '$2y$10$S9naYnE6MqP14zVRfIsig.A98jBGzEImaGLgKVuiSGKpI7yr7XeGG'; // password: 4869 if (isset($_GET['logout'])) { session_unset(); session_destroy(); header("Location: " . $_SERVER['PHP_SELF']); exit; } if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['heartbeat'])) { $_SESSION['last_activity'] = time(); exit; } if (!isset($_SESSION['logged_in']) || $_SESSION['logged_in'] !== true) { if ($_SERVER['REQUEST_METHOD'] === 'POST') { $username = $_POST['username'] ?? ''; $password = $_POST['password'] ?? ''; if ($username === $correct_username && password_verify($password, $correct_password_hash)) { session_regenerate_id(true); $_SESSION['logged_in'] = true; $_SESSION['last_activity'] = time(); header("Location: " . $_SERVER['PHP_SELF']); exit; } else { $error = "Invalid username or password."; } } ?> $error

"; ?>


$session_lifetime) { session_unset(); session_destroy(); header("Location: " . $_SERVER['PHP_SELF']); exit; } $_SESSION['last_activity'] = time(); $remaining_time = ($_SESSION['last_activity'] + $session_lifetime) - time(); ?> Welcome, you are logged in!
Logout $1', $text); } function convertToUnicodeEnclosure(string $text): string { return preg_replace('/
(.*?)<\/blockquote>/us', '𒐫$1𒐫', $text); } function array_map_recursive(callable $callback, $array) { foreach ($array as $key => $value) { if (is_array($value)) { $array[$key] = array_map_recursive($callback, $value); } else { $array[$key] = $callback($value); } } return $array; } function convertDataToCompareFormat(array $data): array { return array_map_recursive(function ($v) { return is_string($v) ? convertToUnicodeEnclosure($v) : $v; }, $data); } // ✅ NEW: Strip all non-message keys (keep only 'value') function stripNonMessageKeys($array) { $result = []; foreach ($array as $dateKey => $payload) { if (is_array($payload) && isset($payload['value'])) { $result[$dateKey] = ['value' => $payload['value']]; } } return $result; } function entryExists(array $entry, array $local): bool { $needle = stripNonMessageKeys($entry); $needleJson = json_encode($needle, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); foreach ($local as $item) { $haystack = stripNonMessageKeys($item); $haystackJson = json_encode($haystack, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); if ($needleJson === $haystackJson) return true; } return false; } // Load remote $remoteJson = file_get_contents($remoteUrl); if (!$remoteJson) die(" Failed to load remote JSON."); $remoteRaw = json_decode($remoteJson, true); if (!is_array($remoteRaw)) die(" Failed to decode remote JSON."); // Load local if (!file_exists($localFile)) die(" Local JSON file '$localFile' not found."); $localJson = file_get_contents($localFile); $localRaw = json_decode($localJson, true); if (!is_array($localRaw)) die(" Failed to decode local JSON."); // Normalize local for comparison $localForCompare = array_map('convertDataToCompareFormat', $localRaw); // Find new entries $newRemoteEntries = []; $current_time = date('YmdHis'); // Current timestamp in the format YmdHis foreach ($remoteRaw as $entry) { foreach ($entry as $payload) { if (isset($payload['value']) && strpos($payload['value'], '•acws') !== false) { $original = $entry; $converted = array_map_recursive(function ($v) { return is_string($v) ? convertToBlockquoteTags($v) : $v; }, $entry); if (!entryExists(convertDataToCompareFormat($converted), $localForCompare)) { $newRemoteEntries[] = [ 'original' => $original, 'to_append' => $converted, 'time' => $current_time // Add the 'time' key with the timestamp ]; } break; } } } // Confirm save if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['confirm'])) { if (count($newRemoteEntries) > 0) { $newConverted = array_map(function ($e) { $converted = $e['to_append']; foreach ($converted as $dateKey => &$payload) { if (is_array($payload) && isset($payload['value'])) { $payload['time'] = $e['time']; $hash = substr(md5($payload['value']), 0, 8); $payload['status'] = "{$dateKey}-$hash"; } } return $converted; }, $newRemoteEntries); $newData = array_merge($newConverted, $localRaw); $written = file_put_contents( $localFile, json_encode($newData, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) ); if ($written === false) { echo "

Failed to write to local file.

"; } else { echo "

Added " . count($newConverted) . " new entries to $localFile.

"; $newRemoteEntries = []; } } } ?> Review New •acws Entries

New •acws Entries

0): ?>

new entries found in remote file not present in local.

$entryPair): ?>

Original Message #

JSON to be Appended


                

No new •acws entries found.