add schematic uploading + use template

This commit is contained in:
ayunami2000 2022-04-17 23:05:20 -04:00
parent 391e146d60
commit 16ee5378ad
18 changed files with 280 additions and 511 deletions

View File

@ -3,6 +3,8 @@ package dev.plex;
import dev.plex.cache.FileCache; import dev.plex.cache.FileCache;
import dev.plex.config.ModuleConfig; import dev.plex.config.ModuleConfig;
import dev.plex.module.PlexModule; import dev.plex.module.PlexModule;
import dev.plex.request.AbstractServlet;
import dev.plex.request.SchematicUploadServlet;
import dev.plex.request.impl.AdminsEndpoint; import dev.plex.request.impl.AdminsEndpoint;
import dev.plex.request.impl.IndefBansEndpoint; import dev.plex.request.impl.IndefBansEndpoint;
import dev.plex.request.impl.IndexEndpoint; import dev.plex.request.impl.IndexEndpoint;
@ -11,7 +13,11 @@ import dev.plex.request.impl.PunishmentsEndpoint;
import dev.plex.request.impl.SchematicDownloadEndpoint; import dev.plex.request.impl.SchematicDownloadEndpoint;
import dev.plex.request.impl.SchematicUploadEndpoint; import dev.plex.request.impl.SchematicUploadEndpoint;
import dev.plex.util.PlexLog; import dev.plex.util.PlexLog;
import java.io.File;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import jakarta.servlet.MultipartConfigElement;
import lombok.Getter; import lombok.Getter;
import net.milkbowl.vault.permission.Permission; import net.milkbowl.vault.permission.Permission;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -24,6 +30,7 @@ import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector; import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHandler; import org.eclipse.jetty.servlet.ServletHandler;
import org.eclipse.jetty.servlet.ServletHolder;
public class HTTPDModule extends PlexModule public class HTTPDModule extends PlexModule
{ {
@ -38,6 +45,8 @@ public class HTTPDModule extends PlexModule
public static final FileCache fileCache = new FileCache(); public static final FileCache fileCache = new FileCache();
public static final String template = AbstractServlet.readFileReal(HTTPDModule.class.getResourceAsStream("/httpd/template.html"));
@Override @Override
public void load() public void load()
{ {
@ -75,6 +84,12 @@ public class HTTPDModule extends PlexModule
new SchematicDownloadEndpoint(); new SchematicDownloadEndpoint();
new SchematicUploadEndpoint(); new SchematicUploadEndpoint();
ServletHolder uploadHolder = HTTPDModule.context.addServlet(SchematicUploadServlet.class, "/api/schematics/uploading");
File uploadLoc = new File(System.getProperty("java.io.tmpdir"), "schematic-temp-dir");
if (!uploadLoc.exists()) uploadLoc.mkdirs();
uploadHolder.getRegistration().setMultipartConfig(new MultipartConfigElement(uploadLoc.getAbsolutePath(), 1024 * 1024 * 5, 1024 * 1024 * 25, 1024 * 1024));
server.setConnectors(new Connector[]{connector}); server.setConnectors(new Connector[]{connector});
server.setHandler(context); server.setHandler(context);
@ -114,4 +129,34 @@ public class HTTPDModule extends PlexModule
permissions = rsp.getProvider(); permissions = rsp.getProvider();
return permissions != null; return permissions != null;
} }
public static File getWorldeditFolder()
{
if (Bukkit.getPluginManager().isPluginEnabled("WorldEdit"))
{
return new File(Bukkit.getPluginManager().getPlugin("WorldEdit").getDataFolder() + "/schematics/");
}
else if (Bukkit.getPluginManager().isPluginEnabled("FastAsyncWorldEdit"))
{
return new File(Bukkit.getPluginManager().getPlugin("FastAsyncWorldEdit").getDataFolder() + "/schematics/");
}
else
{
return null;
}
}
private static boolean isFileSystemCaseSensitive = !new File( "a" ).equals( new File( "A" ) );
public static boolean fileNameEquals(String filename1, String filename2)
{
if (isFileSystemCaseSensitive)
{
return filename1.equals(filename2);
}
else
{
return filename1.equalsIgnoreCase(filename2);
}
}
} }

View File

@ -13,7 +13,7 @@ public class CacheItem
public CacheItem(File f) throws IOException public CacheItem(File f) throws IOException
{ {
this.path = f.getPath(); this.path = f.getPath();
this.file = f.length() >= 1048576 ? null : Files.readAllBytes(f.toPath()); this.file = Files.readAllBytes(f.toPath());
this.timestamp = System.currentTimeMillis(); this.timestamp = System.currentTimeMillis();
} }
} }

View File

@ -1,9 +1,12 @@
package dev.plex.cache; package dev.plex.cache;
import com.google.common.collect.EvictingQueue; import com.google.common.collect.EvictingQueue;
import dev.plex.HTTPDModule;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Queue; import java.util.Queue;
public class FileCache public class FileCache
@ -17,17 +20,17 @@ public class FileCache
public byte[] getFile(String path) throws IOException public byte[] getFile(String path) throws IOException
{ {
CacheItem theItem = cache.stream().filter(cacheItem -> cacheItem.path.equals(path)).findFirst().orElse(null); CacheItem theItem = cache.stream().filter(cacheItem -> HTTPDModule.fileNameEquals(cacheItem.path, path)).findFirst().orElse(null);
if (theItem == null) if (theItem == null)
{ {
theItem = new CacheItem(new File(path)); theItem = new CacheItem(new File(path));
if (theItem.file != null) cache.add(theItem); if (theItem.file.length < 1048576) cache.add(theItem);
} }
if (System.currentTimeMillis() - theItem.timestamp > 3 * 60 * 1000) // 3 minutes if (System.currentTimeMillis() - theItem.timestamp > 3 * 60 * 1000) // 3 minutes
{ {
cache.remove(theItem); cache.remove(theItem);
theItem = new CacheItem(new File(path)); theItem = new CacheItem(new File(path));
if (theItem.file != null) cache.add(theItem); if (theItem.file.length < 1048576) cache.add(theItem);
} }
return theItem.file; return theItem.file;
} }

View File

@ -15,6 +15,7 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.text.CharacterIterator; import java.text.CharacterIterator;
import java.text.StringCharacterIterator; import java.text.StringCharacterIterator;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import lombok.Data; import lombok.Data;
@ -87,7 +88,25 @@ public class AbstractServlet extends HttpServlet
}); });
} }
public String readFile(InputStream filename) public static String readFile(InputStream filename)
{
String base = HTTPDModule.template;
String page = readFileReal(filename);
String[] info = page.split("\n", 3);
System.out.println(Arrays.toString(info));
base = base.replace("${TITLE}", info[0]);
base = base.replace("${ACTIVE_" + info[1] + "}", "active\" aria-current=\"page");
base = base.replace("${ACTIVE_HOME}", "");
base = base.replace("${ACTIVE_ADMINS}", "");
base = base.replace("${ACTIVE_INDEFBANS}", "");
base = base.replace("${ACTIVE_LIST}", "");
base = base.replace("${ACTIVE_PUNISHMENTS}", "");
base = base.replace("${ACTIVE_SCHEMATICS}", "");
base = base.replace("${CONTENT}", info[2]);
return base;
}
public static String readFileReal(InputStream filename)
{ {
StringBuilder contentBuilder = new StringBuilder(); StringBuilder contentBuilder = new StringBuilder();
try try
@ -96,7 +115,7 @@ public class AbstractServlet extends HttpServlet
String str; String str;
while ((str = in.readLine()) != null) while ((str = in.readLine()) != null)
{ {
contentBuilder.append(str); contentBuilder.append(str).append("\n");
} }
in.close(); in.close();
} }

View File

@ -0,0 +1,70 @@
package dev.plex.request;
import dev.plex.HTTPDModule;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.Part;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.util.Arrays;
import java.util.regex.Pattern;
public class SchematicUploadServlet extends HttpServlet
{
private static final Pattern schemNameMatcher = Pattern.compile("^[a-z0-9'!,_ -]{1,30}\\.schem(atic)?$", Pattern.CASE_INSENSITIVE);
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
File worldeditFolder = HTTPDModule.getWorldeditFolder();
if (worldeditFolder == null)
{
resp.getWriter().println(schematicUploadBadHTML("Worldedit is not installed!"));
return;
}
File[] schematics = worldeditFolder.listFiles();
Part uploadPart = null;
try
{
uploadPart = req.getPart("file");
}
catch (IllegalStateException e)
{
resp.getWriter().println(schematicUploadBadHTML("That schematic is too large!"));
return;
}
String filename = uploadPart.getSubmittedFileName().replaceAll("[^a-zA-Z0-9'!,_ .-]", "_");
if (schemNameMatcher.matcher(filename).matches())
{
boolean alreadyExists = schematics != null && Arrays.stream(schematics).anyMatch(file -> HTTPDModule.fileNameEquals(file.getName(), filename));
if (alreadyExists)
{
resp.getWriter().println(schematicUploadBadHTML("A schematic with the name <b>" + filename + "</b> already exists!"));
return;
}
InputStream inputStream = uploadPart.getInputStream();
Files.copy(inputStream, new File(worldeditFolder, filename).toPath(), StandardCopyOption.REPLACE_EXISTING);
inputStream.close();
resp.getWriter().println(schematicUploadGoodHTML("Successfully uploaded <b>" + filename + "."));
}
}
private String schematicUploadBadHTML(String message)
{
String file = AbstractServlet.readFile(this.getClass().getResourceAsStream("/httpd/schematic_upload_bad.html"));
file = file.replace("${MESSAGE}", message);
return file;
}
private String schematicUploadGoodHTML(String message)
{
String file = AbstractServlet.readFile(this.getClass().getResourceAsStream("/httpd/schematic_upload_good.html"));
file = file.replace("${MESSAGE}", message);
return file;
}
}

View File

@ -9,7 +9,6 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.Arrays; import java.util.Arrays;
import org.bukkit.Bukkit;
public class SchematicDownloadEndpoint extends AbstractServlet public class SchematicDownloadEndpoint extends AbstractServlet
{ {
@ -36,25 +35,9 @@ public class SchematicDownloadEndpoint extends AbstractServlet
} }
} }
private File getWorldeditFolder()
{
if (Bukkit.getPluginManager().isPluginEnabled("WorldEdit"))
{
return new File(Bukkit.getPluginManager().getPlugin("WorldEdit").getDataFolder() + "/schematics/");
}
else if (Bukkit.getPluginManager().isPluginEnabled("FastAsyncWorldEdit"))
{
return new File(Bukkit.getPluginManager().getPlugin("FastAsyncWorldEdit").getDataFolder() + "/schematics/");
}
else
{
return null;
}
}
private void schematicServe(String requestedSchematic, OutputStream outputStream) private void schematicServe(String requestedSchematic, OutputStream outputStream)
{ {
File worldeditFolder = getWorldeditFolder(); File worldeditFolder = HTTPDModule.getWorldeditFolder();
if (worldeditFolder == null) if (worldeditFolder == null)
{ {
return; return;
@ -83,7 +66,7 @@ public class SchematicDownloadEndpoint extends AbstractServlet
private String schematicHTML() private String schematicHTML()
{ {
String file = readFile(this.getClass().getResourceAsStream("/httpd/schematic_download.html")); String file = readFile(this.getClass().getResourceAsStream("/httpd/schematic_download.html"));
File worldeditFolder = getWorldeditFolder(); File worldeditFolder = HTTPDModule.getWorldeditFolder();
if (worldeditFolder == null) if (worldeditFolder == null)
{ {
return null; return null;

View File

@ -8,7 +8,7 @@ import jakarta.servlet.http.HttpServletResponse;
public class SchematicUploadEndpoint extends AbstractServlet public class SchematicUploadEndpoint extends AbstractServlet
{ {
@GetMapping(endpoint = "/api/schematics/upload/") @GetMapping(endpoint = "/api/schematics/upload/")
public String downloadSchematic(HttpServletRequest request, HttpServletResponse response) public String uploadSchematic(HttpServletRequest request, HttpServletResponse response)
{ {
return readFile(this.getClass().getResourceAsStream("/httpd/schematic_upload.html")); return readFile(this.getClass().getResourceAsStream("/httpd/schematic_upload.html"));
} }

View File

@ -1,56 +1,4 @@
<!DOCTYPE html> Admins
<html lang="en"> ADMINS
<head> <h2>Plex HTTPD</h2>
<meta name="viewport" content="width=device-width, initial-scale=1"> <h5 class="alert alert-danger mb-3 w-auto p-3" role="alert"><b>Error:</b> ${MESSAGE}</h5>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"
integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p"
crossorigin="anonymous"></script>
<title>Admins - Plex HTTPD</title>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="/">Plex HTTPD</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav"
aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="/">Home</a>
</li>
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Admins</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/api/indefbans/">Indefinite Bans</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/api/list/">List</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/api/punishments/">Punishments</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" id="navbarDropdownMenuLink" role="button"
data-bs-toggle="dropdown" aria-expanded="false">
Schematics
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<li><a class="dropdown-item" href="/api/schematics/download/">Download</a></li>
<li><a class="dropdown-item" href="/api/schematics/upload/">Upload</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<div style="text-align: center;" class="col-auto m-0 row justify-content-center p-4">
<h2>Plex HTTPD</h2>
<h5 class="alert alert-danger mb-3 w-auto p-3" role="alert"><b>Error:</b> ${MESSAGE}</h5>
</div>
</body>
</html>

View File

@ -1,56 +1,4 @@
<!DOCTYPE html> Indefinite Bans
<html lang="en"> INDEFBANS
<head> <h2>Plex HTTPD</h2>
<meta name="viewport" content="width=device-width, initial-scale=1"> <h5 class="alert alert-danger mb-3 w-auto p-3" role="alert"><b>Error:</b> ${MESSAGE}</h5>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"
integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p"
crossorigin="anonymous"></script>
<title>Indefinite Bans - Plex HTTPD</title>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="/">Plex HTTPD</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav"
aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="/">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="../admins/">Admins</a>
</li>
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Indefinite Bans</a>
</li>
<li class="nav-item">
<a class="nav-link" href="../list/">List</a>
</li>
<li class="nav-item">
<a class="nav-link" href="../punishments/">Punishments</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" id="navbarDropdownMenuLink" role="button"
data-bs-toggle="dropdown" aria-expanded="false">
Schematics
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<li><a class="dropdown-item" href="/api/schematics/download/">Download</a></li>
<li><a class="dropdown-item" href="/api/schematics/upload/">Upload</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<div style="text-align: center;" class="col-auto m-0 row justify-content-center p-4">
<h2>Plex HTTPD</h2>
<h5 class="alert alert-danger mb-3 w-auto p-3" role="alert"><b>Error:</b> ${MESSAGE}</h5>
</div>
</body>
</html>

View File

@ -1,57 +1,5 @@
<!DOCTYPE html> Home
<html lang="en"> HOME
<head> <h2>Welcome to the Plex HTTPD!</h2>
<meta name="viewport" content="width=device-width, initial-scale=1"> <h4>Use the sidebar to navigate the available pages.</h4>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" <h4><br>There ${is_are} currently ${server_online_players} online out of ${server_total_players} total.</h4>
integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"
integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p"
crossorigin="anonymous"></script>
<title>Home - Plex HTTPD</title>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="/">Plex HTTPD</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav"
aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/api/admins/">Admins</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/api/indefbans/">Indefinite Bans</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/api/list/">List</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/api/punishments/">Punishments</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" id="navbarDropdownMenuLink" role="button"
data-bs-toggle="dropdown" aria-expanded="false">
Schematics
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<li><a class="dropdown-item" href="/api/schematics/download/">Download</a></li>
<li><a class="dropdown-item" href="/api/schematics/upload/">Upload</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<div style="text-align: center;" class="col-auto m-0 row justify-content-center p-4">
<h2>Welcome to the Plex HTTPD!</h2>
<h4>Use the sidebar to navigate the available pages.</h4>
<h4><br>There ${is_are} currently ${server_online_players} online out of ${server_total_players} total.</h4>
</div>
</body>
</html>

View File

@ -1,61 +1,11 @@
<!DOCTYPE html> Punishments
<html lang="en"> PUNISHMENTS
<head> <h2>Enter the UUID or username of the player you want to lookup</h2>
<meta name="viewport" content="width=device-width, initial-scale=1"> <div class="input-group mb-3 w-75 p-3">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" <input id="uuid" type="text" autocomplete="off" class="form-control">
integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous"> <button class="btn btn-outline-primary" type="submit"
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" onclick="redirect();">Submit
integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" </button>
crossorigin="anonymous"></script>
<title>Punishments - Plex HTTPD</title>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="/">Plex HTTPD</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav"
aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="/">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/api/admins/">Admins</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/api/indefbans/">Indefinite Bans</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/api/list/">List</a>
</li>
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Punishments</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" id="navbarDropdownMenuLink" role="button"
data-bs-toggle="dropdown" aria-expanded="false">
Schematics
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<li><a class="dropdown-item" href="/api/schematics/download/">Download</a></li>
<li><a class="dropdown-item" href="/api/schematics/upload/">Upload</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<div style="text-align: center;" class="col-auto m-0 p-4 row justify-content-center">
<h2>Enter the UUID or username of the player you want to lookup</h2>
<div class="input-group mb-3 w-75 p-3">
<input id="uuid" type="text" autocomplete="off" class="form-control">
<button class="btn btn-outline-primary" type="submit"
onclick="redirect();">Submit
</button>
</div>
</div> </div>
<script> <script>
function redirect() { function redirect() {
@ -69,6 +19,4 @@
redirect(); redirect();
} }
}); });
</script> </script>
</body>
</html>

View File

@ -1,56 +1,4 @@
<!DOCTYPE html> Punishments
<html lang="en"> PUNISHMENTS
<head> <h2>Plex HTTPD</h2>
<meta name="viewport" content="width=device-width, initial-scale=1"> <h5 class="alert alert-danger mb-3 w-auto p-3" role="alert"><b>Error:</b> ${MESSAGE}</h5>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"
integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p"
crossorigin="anonymous"></script>
<title>Punishments - Plex HTTPD</title>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="/">Plex HTTPD</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav"
aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="/">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/api/admins/">Admins</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/api/indefbans/">Indefinite Bans</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/api/list/">List</a>
</li>
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Punishments</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" id="navbarDropdownMenuLink" role="button"
data-bs-toggle="dropdown" aria-expanded="false">
Schematics
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<li><a class="dropdown-item" href="/api/schematics/download/">Download</a></li>
<li><a class="dropdown-item" href="/api/schematics/upload/">Upload</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<div style="text-align: center;" class="col-auto m-0 row justify-content-center p-4">
<h2>Plex HTTPD</h2>
<h5 class="alert alert-danger mb-3 w-auto p-3" role="alert"><b>Error:</b> ${MESSAGE}</h5>
</div>
</body>
</html>

View File

@ -1,55 +1,4 @@
<!DOCTYPE html> Punishments
<html lang="en"> PUNISHMENTS
<head> <h2>Plex HTTPD</h2>
<meta name="viewport" content="width=device-width, initial-scale=1"> <h5 class="alert alert-success mb-3 w-auto p-3" role="alert">${MESSAGE}</h5>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"
integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p"
crossorigin="anonymous"></script>
<title>Punishments - Plex HTTPD</title>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="/">Plex HTTPD</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav"
aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="/">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/api/admins/">Admins</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/api/indefbans/">Indefinite Bans</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/api/list/">List</a>
</li>
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Punishments</a>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" id="navbarDropdownMenuLink" role="button"
data-bs-toggle="dropdown" aria-expanded="false">
Schematics
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<li><a class="dropdown-item" href="/api/schematics/download/">Download</a></li>
<li><a class="dropdown-item" href="/api/schematics/upload/">Upload</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<div style="text-align: center;" class="col-auto m-0 row justify-content-center p-4">
<h2>Plex HTTPD</h2>
<h5 class="alert alert-success mb-3 w-auto p-3" role="alert">${MESSAGE}</h5>
</div>
</body>
</html>

View File

@ -1,86 +1,34 @@
<!DOCTYPE html> Schematics
<html lang="en"> SCHEMATICS
<head> <h2>Plex HTTPD</h2>
<meta name="viewport" content="width=device-width, initial-scale=1"> <h5>A list of schematics is below. You can click on the schematic name to download it.</h5>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" <div class="input-group mb-3 w-75 p-3">
integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous"> <input type="text" autocomplete="off" class="form-control" oninput="filterTable(this.value)"
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" placeholder="Search for a schematic...">
integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" </div>
crossorigin="anonymous"></script> <table id="schemList" class="table table-striped table-bordered">
<title>Schematics - Plex HTTPD</title> <thead>
</head> <tr>
<body> <th scope="col">Name</th>
<nav class="navbar navbar-expand-lg navbar-light bg-light"> <th scope="col">Size</th>
<div class="container-fluid"> </tr>
<a class="navbar-brand" href="/">Plex HTTPD</a> </thead>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" <tbody>
aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation"> ${schematics}
<span class="navbar-toggler-icon"></span> </tbody>
</button> </table>
<div class="collapse navbar-collapse" id="navbarNav"> <script>
<ul class="navbar-nav"> let schemList = document.getElementById("schemList").getElementsByTagName("tbody")[0].getElementsByTagName("tr");
<li class="nav-item">
<a class="nav-link" href="/">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Admins</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/api/indefbans/">Indefinite Bans</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/api/list/">List</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/api/punishments/">Punishments</a>
<li class="nav-item dropdown">
<a class="nav-link active dropdown-toggle" aria-current="page" id="navbarDropdownMenuLink"
role="button"
data-bs-toggle="dropdown" aria-expanded="false">
Schematics
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<li><a class="dropdown-item" href="/api/schematics/download/">Download</a></li>
<li><a class="dropdown-item" href="/api/schematics/upload/">Upload</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<div style="text-align: center;" class="col-auto m-0 row justify-content-center p-4">
<h2>Plex HTTPD</h2>
<h5>A list of schematics is below. You can click on the schematic name to download it.</h5>
<div class="input-group mb-3 w-75 p-3">
<input type="text" autocomplete="off" class="form-control" oninput="filterTable(this.value)"
placeholder="Search for a schematic...">
</div>
<table id="schemList" class="table table-striped table-bordered">
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col">Size</th>
</tr>
</thead>
<tbody>
${schematics}
</tbody>
</table>
<script>
let schemList = document.getElementById("schemList").getElementsByTagName("tbody")[0].getElementsByTagName("tr");
function filterTable(query) { function filterTable(query) {
for (let i = 0; i < schemList.length; i++) { for (let i = 0; i < schemList.length; i++) {
let th = schemList[i].getElementsByTagName("th")[0]; let th = schemList[i].getElementsByTagName("th")[0];
let schemName = th.textContent || th.innerText; let schemName = th.textContent || th.innerText;
if (schemName.toLowerCase().includes(query.toLowerCase())) { if (schemName.toLowerCase().includes(query.toLowerCase())) {
schemList[i].style.display = ""; schemList[i].style.display = "";
} else { } else {
schemList[i].style.display = "none"; schemList[i].style.display = "none";
}
} }
} }
</script> }
</div> </script>
</body>
</html>

View File

@ -1,61 +1,10 @@
<!DOCTYPE html> Schematics
<html lang="en"> SCHEMATICS
<head> <h2>Plex HTTPD</h2>
<meta name="viewport" content="width=device-width, initial-scale=1"> <div class="mb-3 col-6">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" <label for="formFile" class="form-label">Please select a schematic file to upload.</label>
integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous"> <form class="input-group" enctype="multipart/form-data" method="post" action="/api/schematics/uploading">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" <input class="form-control" type="file" name="file" id="formFile">
integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" <input type="submit" class="btn btn-outline-primary" value="Upload">
crossorigin="anonymous"></script> </form>
<title>Schematics - Plex HTTPD</title> </div>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="/">Plex HTTPD</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav"
aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="/">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Admins</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/api/indefbans/">Indefinite Bans</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/api/list/">List</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/api/punishments/">Punishments</a>
<li class="nav-item dropdown">
<a class="nav-link active dropdown-toggle" aria-current="page" id="navbarDropdownMenuLink" role="button"
data-bs-toggle="dropdown" aria-expanded="false">
Schematics
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<li><a class="dropdown-item" href="/api/schematics/download/">Download</a></li>
<li><a class="dropdown-item" href="/api/schematics/upload/">Upload</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<div style="text-align: center;" class="col-auto m-0 row justify-content-center p-4">
<h2>Plex HTTPD</h2>
<div class="mb-3 col-6">
<label for="formFile" class="form-label">Please select a schematic file to upload.</label>
<div class="input-group">
<input class="form-control" type="file" id="formFile">
<button class="btn btn-outline-primary" type="button" id="upload">Upload</button>
</div>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,4 @@
Schematics
SCHEMATICS
<h2>Plex HTTPD</h2>
<h5 class="alert alert-danger mb-3 w-auto p-3" role="alert"><b>Error:</b> ${MESSAGE}</h5>

View File

@ -0,0 +1,4 @@
Schematics
SCHEMATICS
<h2>Plex HTTPD</h2>
<h5 class="alert alert-success mb-3 w-auto p-3" role="alert">${MESSAGE}</h5>

View File

@ -0,0 +1,55 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"
integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p"
crossorigin="anonymous"></script>
<title>${TITLE} - Plex HTTPD</title>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="/">Plex HTTPD</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav"
aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link ${ACTIVE_HOME}" href="/">Home</a>
</li>
<li class="nav-item">
<a class="nav-link ${ACTIVE_ADMINS}" href="/api/admins/">Admins</a>
</li>
<li class="nav-item">
<a class="nav-link ${ACTIVE_INDEFBANS}" href="/api/indefbans/">Indefinite Bans</a>
</li>
<li class="nav-item">
<a class="nav-link ${ACTIVE_LIST}" href="/api/list/">List</a>
</li>
<li class="nav-item">
<a class="nav-link ${ACTIVE_PUNISHMENTS}" href="/api/punishments/">Punishments</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle ${ACTIVE_SCHEMATICS}" id="navbarDropdownMenuLink" role="button"
data-bs-toggle="dropdown" aria-expanded="false">
Schematics
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<li><a class="dropdown-item" href="/api/schematics/download/">Download</a></li>
<li><a class="dropdown-item" href="/api/schematics/upload/">Upload</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<div style="text-align: center;" class="col-auto m-0 row justify-content-center p-4">
${CONTENT}
</div>
</body>
</html>