34 lines
742 B
PHP
34 lines
742 B
PHP
|
<?php
|
||
|
$dataDir = "data/";
|
||
|
|
||
|
// ID corresponds to the Report ID
|
||
|
if (!isset($_GET["id"]) || empty($_GET["id"])) {
|
||
|
echo "No token defined.";
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
$id = $_GET["id"];
|
||
|
$filePath = $dataDir . $id . ".json";
|
||
|
|
||
|
if (is_int($id) && file_exists($filePath)) {
|
||
|
displayMessages($filePath);
|
||
|
} else {
|
||
|
echo "Invalid token.";
|
||
|
}
|
||
|
|
||
|
function displayMessages($filePath) {
|
||
|
$messagesArray = getMessages($filePath);
|
||
|
|
||
|
foreach ($messagesArray as $messageData) {
|
||
|
echo getMessageLine($messageData);
|
||
|
echo "<br \>";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function getMessages($filename) {
|
||
|
return json_decode(file_get_contents($filename), true);
|
||
|
}
|
||
|
|
||
|
function getMessageLine($messageData) {
|
||
|
return $messageData["sender"] . ": " . $messageData["message"];
|
||
|
}
|