9iron/minecraft/index.php

98 lines
3.2 KiB
PHP

<!DOCTYPE html>
<html>
<head>
<?php include $_SERVER['DOCUMENT_ROOT'].'/src/common-meta.php';?>
<link href="/styles/buttons.css" type="text/css" rel="stylesheet" />
<link href="/minecraft/styles/styles.css" type="text/css" rel="stylesheet" />
<link rel="shortcut icon" href="/favicon.ico" />
<title>9iron</title>
</head>
<body>
<?php include $_SERVER['DOCUMENT_ROOT'].'/src/common-header.php';?>
<div class="content">
<div class="section">
<h1>Modded Minecraft</h1>
<p>It's been a go-to of ours for a while. Ongoing and historical modpacks are listed here for your convenience and participation.</p>
<p>At-a-glance information is provided here for the various packs we play.</p>
<div class="iconbuttoncontainer">
<a href="/minecraft/setup" class="iconbutton">
<i class="fa fa-play"></i>
<h1>Setup</h1>
<p>Set up an entire modded Minecraft environment</p>
</a>
</div>
</div>
<?php
# Define a pack card generator function
function echo_pack($pack) {
# Add basic coloration to the element, if it exists
if (file_exists("packs/$pack/color")) {
$color = file_get_contents("packs/$pack/color");
echo "<div class=\"modpack\" style=\"background: $color; color: var(--background);\">";
} else {
echo '<div class="modpack">';
}
# Push an image if we've got one of those
if (file_exists("packs/$pack/icon.png")) {
echo "<img src=\"/minecraft/packs/$pack/icon.png\" class=\"packicon\"/>";
}
# Get the pack description
$desc = "<h2>$pack</h2><p>A modpack.</p>";
$descfile = "packs/$pack/desc.html";
if (file_exists($descfile)) {
$desc = file_get_contents($descfile);
}
echo "$desc";
# A small button to browse previous world downloads
if (file_exists("/files/packs/$pack/worlds")) {
echo "<p><a href=\"/files/packs/$pack/worlds\" class=\"worldsbutton\">Browse world backups</a></p>";
}
# And a bright big download button
echo "<a href=\"/files/packs/$pack/latest.zip\" class=\"downloadbutton\">Download</a>";
echo '</div>';
}
# Get list of modpacks
$dir = new DirectoryIterator("packs");
$packs = array();
foreach ($dir as $fileinfo) {
if (!$fileinfo->isDot() && $fileinfo->isDir()) {
array_push($packs, $fileinfo->getFilename());
}
}
# Parse through and provide their information
if (!empty($packs)) {
echo '<div class="section">';
# If we have a current pack, print that upfront
if (file_exists("packs/current") && readlink("packs/current")) {
# We have a valid current pack, remove it from the list and print it upfront
$currentpack = readlink("packs/current");
$packs = array_diff($packs, ["$currentpack", "current"]);
echo '<h1>Current Modpack</h1>';
echo_pack($currentpack);
# If there's a server IP name along with that, print that out too
if (file_exists("packs/currentip")) {
$ip = file_get_contents("packs/currentip");
echo "<p><code class=\"bigcode\">$ip</code></p>";
}
echo '</div><div class="section">';
}
# Sort the list of remaining packs
sort($packs);
# Print the rest of them
echo '<h1>Modpacks</h1><div class="packcontainer">';
foreach ($packs as $pack) {
echo_pack($pack);
}
echo '</div></div>';
}
?>
</div>
<?php include $_SERVER['DOCUMENT_ROOT'].'/src/common-footer.php';?>
</body>
</html>