This commit is contained in:
Lee 2023-04-15 15:02:44 +01:00
parent 478518ee59
commit e621a7e5b8
4 changed files with 54 additions and 40 deletions

3
deleteOldMaps.sh Normal file

@ -0,0 +1,3 @@
# Get all the maps in /home/beatsaber-wip-uploader/maps/ and delete the ones that are older than 30 minutes
find /home/beatsaber-wip-uploader/maps/ -type f -mmin +30 -delete

@ -1,39 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>WIP Uploader</title>
<script src="https://cdn.fascinated.cc/assets/tailwindcss/3.2.4.js"></script>
</head>
<body>
<div class="flex items-center justify-center h-screen bg-gray-900">
<div class="w-1/2">
<div class="bg-gray-800 rounded-lg shadow-xl p-10">
<h2 class="text-4xl font-bold text-center text-white mb-10">
WIP Map Uploader
</h2>
<form action="upload.php" method="post" enctype="multipart/form-data">
<div class="flex items-center justify-center">
<input
type="file"
name="map"
class="bg-gray-700 text-white font-bold py-2 px-4 rounded"
/>
<div class="flex items-center justify-center ml-3">
<button
type="submit"
name="submit"
class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded"
>
Upload
</button>
</div>
</form>
</div>
</div>
</div>
</body>
</html>

48
index.php Normal file

@ -0,0 +1,48 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>WIP Uploader</title>
<script src="https://cdn.fascinated.cc/assets/tailwindcss/3.2.4.js"></script>
</head>
<body>
<div class="flex items-center justify-center h-screen bg-gray-900">
<div class="w-1/2">
<div class="bg-gray-800 rounded-lg shadow-xl p-10">
<h2 class="text-4xl font-bold text-white mb-10">
WIP Map Uploader
</h2>
<?php
// if the map parameter is set, display the map
if (isset($_GET["map"])) {
echo '<div class="mb-5">
<label for="map" class="block text-white text-sm font-bold mb-2">Successfully uploaded Map</label>
<span class="bg-gray-700 text-white rounded w-full py-2 px-3 focus:outline-none focus:shadow-outline">!wip ' . $_GET["map"] . '</span>
</div>
';
}
// if the map parameter is not set, display the upload form
else {
echo '<form action="upload.php" method="post" enctype="multipart/form-data">
<div class="mb-5">
<label for="map" class="block text-white text-sm font-bold mb-2">Map</label>
<input type="file" name="map" id="map" class="bg-gray-700 text-white rounded w-full py-2 px-3 focus:outline-none focus:shadow-outline">
</div>
<div class="mb-5">
<button type="submit" class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline">Upload</button>
</div>
</form>
';
}
?>
</div>
</div>
</body>
</html>

@ -40,4 +40,6 @@ if (!move_uploaded_file($file, $target_file)) {
echo "There was an error uploading the file";
die();
}
echo "The file https://wip.fascinated.cc/maps/" . $mapId . ".zip has been uploaded.";
// redirect to /?map=https://wip.fascinated.cc/maps/" . $mapId . ".zip
header("Location: /?map=https://wip.fascinated.cc/maps/" . $mapId . ".zip");