This commit is contained in:
Lanta 2023-11-08 19:59:47 +01:00
parent 607f422d9c
commit ed96c74a04
2 changed files with 41 additions and 41 deletions

View file

@ -11,6 +11,47 @@ $dataPoints = array(
);
?>
<?php
$dataPoints = array();
$directory = './data/killstats';
// Check if the directory exists
if (!is_dir($directory)) {
die("The directory $directory does not exist");
}
// Open the directory
if ($handle = opendir($directory)) {
// Loop through the directory
while (false !== ($entry = readdir($handle))) {
if ($entry !== '.' && $entry !== '..') {
// Read each file
$filepath = $directory . '/' . $entry;
$content = file_get_contents($filepath);
// Decode JSON data to PHP array
$jsonArray = json_decode($content, true);
// Process the date
$date = new DateTime($jsonArray['created']);
$label = $date->format('m-d'); // Month-Day format
// Add to dataPoints
$dataPoints[] = array(
"y" => $jsonArray['winplace'],
"label" => $label
);
}
}
closedir($handle);
}
// Output the array
print_r($dataPoints);
?>
<!DOCTYPE HTML>
<html>
<head>