You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

86 lines
2.7 KiB

<?php
$q = $_GET['category'];
include "../components/navbar.php";
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Modpack - Archiv | KNKS</title>
<link rel="stylesheet" href="../css/base.css">
<link rel="stylesheet" href="/css/archive.css">
</head>
<body>
<div class="title-container">
<h1><span>M</span>odpack</h1>
</div>
<div class="content-container">
<h1>Archiv modpacků pro <?php echo $q;?></h1>
<div class="warning-block">
Pro hraní na serveru je nutné mít vždy nejnovější verzi modpacku!
</div>
<table>
<tr>
<th>Název</th>
<th>Poznámka</th>
<th>Datum</th>
<th></th>
</tr>
<?php
// Define the directory path
$directory = '../modpack/resources/' . $q ."/";
$notesFile = $directory . '/notes.json';
// Check if the directory exists
if (!is_dir($directory)) {
die("Cesta k archívu není validní.");
}
// Get all files in the directory
$allFiles = glob($directory . '/*');
// Filter out .json files
$filteredFiles = array_filter($allFiles, function($file) {
return pathinfo($file, PATHINFO_EXTENSION) !== 'json';
});
$fileTimes = [];
foreach ($filteredFiles as $file) {
$fileTimes[$file] = filectime($file);
}
$notes = [];
if (file_exists($notesFile)) {
$notesContent = file_get_contents($notesFile);
$notes = json_decode($notesContent, true);
}
// Sort the files by creation time in descending order
arsort($fileTimes);
$keys = array_keys($notes);
foreach ($fileTimes as $file => $creationTime) {
$creationTime = filectime($file);
$date = date('d.m.Y', $creationTime);
$name = basename($file);
$filepath = $directory . $name;
$note = isset($notes[$name]) ? $notes[$name] : 'žádná poznámka';
echo "<tr><td>" . $name . "</td><td>". $note."</td><td>" . $date . '</td><td><a href="' . $filepath . '" class="download-link">stáhnout</a></td></tr>';
}
?>
</table>
</div>
</section>
<?php
require "../components/footer.php"
?>
</body>
</html>