Mineplex2018-withcommit/Plugins/Mineplex.ChatSnapManager/web/report.php

34 lines
742 B
PHP
Raw Normal View History

2015-12-07 18:05:58 +01:00
<?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"];
}