Actually make the HTTPD look nice

This commit is contained in:
Telesphoreo 2022-04-17 16:39:08 -05:00
parent e6e8439a72
commit 2ce0a1e698
14 changed files with 390 additions and 73 deletions

View File

@ -4,6 +4,7 @@ import dev.plex.config.ModuleConfig;
import dev.plex.module.PlexModule; import dev.plex.module.PlexModule;
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.ListEndpoint; import dev.plex.request.impl.ListEndpoint;
import dev.plex.request.impl.PunishmentsEndpoint; import dev.plex.request.impl.PunishmentsEndpoint;
import dev.plex.util.PlexLog; import dev.plex.util.PlexLog;
@ -63,6 +64,7 @@ public class HTTPDModule extends PlexModule
new AdminsEndpoint(); new AdminsEndpoint();
new IndefBansEndpoint(); new IndefBansEndpoint();
new IndexEndpoint();
new ListEndpoint(); new ListEndpoint();
new PunishmentsEndpoint(); new PunishmentsEndpoint();

View File

@ -4,7 +4,6 @@ import dev.plex.HTTPDModule;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
public class Log public class Log
{ {
public static void log(String message, Object... strings) public static void log(String message, Object... strings)

View File

@ -3,15 +3,18 @@ package dev.plex.request;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import dev.plex.HTTPDModule; import dev.plex.HTTPDModule;
import dev.plex.logging.Log; import dev.plex.logging.Log;
import jakarta.servlet.AsyncContext;
import jakarta.servlet.ServletException; import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.List; import java.util.List;
import java.util.Objects;
import lombok.Data; import lombok.Data;
import org.eclipse.jetty.servlet.ServletHolder; import org.eclipse.jetty.servlet.ServletHolder;
@ -79,14 +82,23 @@ public class AbstractServlet extends HttpServlet
}); });
} }
public String createBasicHTML(String title, String body) public String readFile(InputStream filename)
{ {
return "<!DOCTYPE html><html><head><title>" + title + "</title><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"></head><body>" + body + "</body></html>"; StringBuilder contentBuilder = new StringBuilder();
} try
{
public String createJSONHTML(String title, String json) BufferedReader in = new BufferedReader(new InputStreamReader(Objects.requireNonNull(filename)));
{ String str;
return "<!DOCTYPE html><html><head><title>" + title + "</title><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"></head><body><pre><code>" + json + "</code></pre></body></html>"; while ((str = in.readLine()) != null)
{
contentBuilder.append(str);
}
in.close();
}
catch (IOException ignored)
{
}
return contentBuilder.toString();
} }
@Data @Data

View File

@ -27,13 +27,13 @@ public class AdminsEndpoint extends AbstractServlet
String ipAddress = request.getRemoteAddr(); String ipAddress = request.getRemoteAddr();
if (ipAddress == null) if (ipAddress == null)
{ {
return createBasicHTML(TITLE, "An IP address could not be detected. Please ensure you are connecting using IPv4."); return adminsHTML("An IP address could not be detected. Please ensure you are connecting using IPv4.");
} }
final PlexPlayer player = DataUtils.getPlayerByIP(ipAddress); final PlexPlayer player = DataUtils.getPlayerByIP(ipAddress);
if (player == null) if (player == null)
{ {
// This likely means they've never joined the server before. That's okay. We can just not return IPs. // This likely means they've never joined the server before. That's okay. We can just not return IPs.
return createJSONHTML(TITLE, new GsonBuilder().registerTypeAdapter(LocalDateTime.class, new LocalDateTimeSerializer()).setPrettyPrinting().create().toJson(Plex.get().getAdminList().getAllAdminPlayers().stream().peek(plexPlayer -> plexPlayer.setIps(Lists.newArrayList())).peek(plexPlayer -> plexPlayer.setPunishments(Lists.newArrayList())).collect(Collectors.toList()))); return new GsonBuilder().registerTypeAdapter(LocalDateTime.class, new LocalDateTimeSerializer()).setPrettyPrinting().create().toJson(Plex.get().getAdminList().getAllAdminPlayers().stream().peek(plexPlayer -> plexPlayer.setIps(Lists.newArrayList())).peek(plexPlayer -> plexPlayer.setPunishments(Lists.newArrayList())).collect(Collectors.toList()));
} }
if (Plex.get().getSystem().equalsIgnoreCase("ranks")) if (Plex.get().getSystem().equalsIgnoreCase("ranks"))
{ {
@ -41,7 +41,7 @@ public class AdminsEndpoint extends AbstractServlet
if (!player.getRankFromString().isAtLeast(Rank.ADMIN)) if (!player.getRankFromString().isAtLeast(Rank.ADMIN))
{ {
// Don't return IPs either if the person is not an Admin or above. // Don't return IPs either if the person is not an Admin or above.
return createJSONHTML(TITLE, new GsonBuilder().registerTypeAdapter(LocalDateTime.class, new LocalDateTimeSerializer()).setPrettyPrinting().create().toJson(Plex.get().getAdminList().getAllAdminPlayers().stream().peek(plexPlayer -> plexPlayer.setIps(Lists.newArrayList())).peek(plexPlayer -> plexPlayer.setPunishments(Lists.newArrayList())).collect(Collectors.toList()))); return new GsonBuilder().registerTypeAdapter(LocalDateTime.class, new LocalDateTimeSerializer()).setPrettyPrinting().create().toJson(Plex.get().getAdminList().getAllAdminPlayers().stream().peek(plexPlayer -> plexPlayer.setIps(Lists.newArrayList())).peek(plexPlayer -> plexPlayer.setPunishments(Lists.newArrayList())).collect(Collectors.toList()));
} }
} }
else if (Plex.get().getSystem().equalsIgnoreCase("permissions")) else if (Plex.get().getSystem().equalsIgnoreCase("permissions"))
@ -51,9 +51,16 @@ public class AdminsEndpoint extends AbstractServlet
if (!HTTPDModule.getPermissions().playerHas(null, offlinePlayer, "plex.httpd.admins.access")) if (!HTTPDModule.getPermissions().playerHas(null, offlinePlayer, "plex.httpd.admins.access"))
{ {
// If the person doesn't have permission, don't return IPs // If the person doesn't have permission, don't return IPs
return createJSONHTML(TITLE, new GsonBuilder().registerTypeAdapter(LocalDateTime.class, new LocalDateTimeSerializer()).setPrettyPrinting().create().toJson(Plex.get().getAdminList().getAllAdminPlayers().stream().peek(plexPlayer -> plexPlayer.setIps(Lists.newArrayList())).peek(plexPlayer -> plexPlayer.setPunishments(Lists.newArrayList())).collect(Collectors.toList()))); return new GsonBuilder().registerTypeAdapter(LocalDateTime.class, new LocalDateTimeSerializer()).setPrettyPrinting().create().toJson(Plex.get().getAdminList().getAllAdminPlayers().stream().peek(plexPlayer -> plexPlayer.setIps(Lists.newArrayList())).peek(plexPlayer -> plexPlayer.setPunishments(Lists.newArrayList())).collect(Collectors.toList()));
} }
} }
return createJSONHTML(TITLE, new GsonBuilder().registerTypeAdapter(LocalDateTime.class, new LocalDateTimeSerializer()).setPrettyPrinting().create().toJson(Plex.get().getAdminList().getAllAdminPlayers())); return new GsonBuilder().registerTypeAdapter(LocalDateTime.class, new LocalDateTimeSerializer()).setPrettyPrinting().create().toJson(Plex.get().getAdminList().getAllAdminPlayers());
}
private String adminsHTML(String message)
{
String file = readFile(this.getClass().getResourceAsStream("/httpd/admins.html"));
file = file.replace("${MESSAGE}", message);
return file;
} }
} }

View File

@ -23,19 +23,19 @@ public class IndefBansEndpoint extends AbstractServlet
String ipAddress = request.getRemoteAddr(); String ipAddress = request.getRemoteAddr();
if (ipAddress == null) if (ipAddress == null)
{ {
return createBasicHTML(TITLE, "An IP address could not be detected. Please ensure you are connecting using IPv4."); return indefbansHTML("An IP address could not be detected. Please ensure you are connecting using IPv4.");
} }
final PlexPlayer player = DataUtils.getPlayerByIP(ipAddress); final PlexPlayer player = DataUtils.getPlayerByIP(ipAddress);
if (player == null) if (player == null)
{ {
return createBasicHTML(TITLE, "Couldn't load your IP Address: " + ipAddress + ". Have you joined the server before?"); return indefbansHTML("Couldn't load your IP Address: " + ipAddress + ". Have you joined the server before?");
} }
if (Plex.get().getSystem().equalsIgnoreCase("ranks")) if (Plex.get().getSystem().equalsIgnoreCase("ranks"))
{ {
PlexLog.debug("Plex-HTTPD using ranks check"); PlexLog.debug("Plex-HTTPD using ranks check");
if (!player.getRankFromString().isAtLeast(Rank.ADMIN)) if (!player.getRankFromString().isAtLeast(Rank.ADMIN))
{ {
return createBasicHTML(TITLE, "Not a high enough rank to view this page."); return indefbansHTML("Not a high enough rank to view this page.");
} }
} }
else if (Plex.get().getSystem().equalsIgnoreCase("permissions")) else if (Plex.get().getSystem().equalsIgnoreCase("permissions"))
@ -44,9 +44,16 @@ public class IndefBansEndpoint extends AbstractServlet
final OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(player.getUuid()); final OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(player.getUuid());
if (!HTTPDModule.getPermissions().playerHas(null, offlinePlayer, "plex.httpd.indefbans.access")) if (!HTTPDModule.getPermissions().playerHas(null, offlinePlayer, "plex.httpd.indefbans.access"))
{ {
return createBasicHTML(TITLE, "Not enough permissions to view this page."); return indefbansHTML("Not enough permissions to view this page.");
} }
} }
return createJSONHTML(TITLE, new GsonBuilder().setPrettyPrinting().create().toJson(Plex.get().getPunishmentManager().getIndefiniteBans().stream().toList())); return new GsonBuilder().setPrettyPrinting().create().toJson(Plex.get().getPunishmentManager().getIndefiniteBans().stream().toList());
}
private String indefbansHTML(String message)
{
String file = readFile(this.getClass().getResourceAsStream("/httpd/indefbans.html"));
file = file.replace("${MESSAGE}", message);
return file;
} }
} }

View File

@ -0,0 +1,33 @@
package dev.plex.request.impl;
import dev.plex.request.AbstractServlet;
import dev.plex.request.GetMapping;
import jakarta.servlet.http.HttpServletRequest;
import org.bukkit.Bukkit;
public class IndexEndpoint extends AbstractServlet
{
@GetMapping(endpoint = "//")
public String getIndex(HttpServletRequest request)
{
return indexHTML();
}
@GetMapping(endpoint = "/api/")
public String getAPI(HttpServletRequest request)
{
return indexHTML();
}
private String indexHTML()
{
String file = readFile(this.getClass().getResourceAsStream("/httpd/index.html"));
String isAre = Bukkit.getOnlinePlayers().size() == 1 ? " is " : " are ";
String pluralOnline = Bukkit.getOnlinePlayers().size() == 1 ? " player " : " players ";
String pluralMax = Bukkit.getMaxPlayers() == 1 ? " player " : " players ";
file = file.replace("${is_are}", isAre);
file = file.replace("${server_online_players}", Bukkit.getOnlinePlayers().size() + pluralOnline);
file = file.replace("${server_total_players}", Bukkit.getMaxPlayers() + pluralMax);
return file;
}
}

View File

@ -20,6 +20,6 @@ public class ListEndpoint extends AbstractServlet
{ {
players.add(player.getName()); players.add(player.getName());
} }
return createJSONHTML("List - Plex HTTPD", new GsonBuilder().setPrettyPrinting().create().toJson(players.stream().toList())); return new GsonBuilder().setPrettyPrinting().create().toJson(players.stream().toList());
} }
} }

View File

@ -11,44 +11,24 @@ import dev.plex.request.GetMapping;
import dev.plex.util.PlexLog; import dev.plex.util.PlexLog;
import dev.plex.util.adapter.LocalDateTimeSerializer; import dev.plex.util.adapter.LocalDateTimeSerializer;
import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Objects;
import java.util.UUID; import java.util.UUID;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
public class PunishmentsEndpoint extends AbstractServlet public class PunishmentsEndpoint extends AbstractServlet
{ {
private static final String TITLE = "Punishments - Plex HTTPD";
@GetMapping(endpoint = "/api/punishments/") @GetMapping(endpoint = "/api/punishments/")
public String getPunishments(HttpServletRequest request) public String getPunishments(HttpServletRequest request)
{ {
String ipAddress = request.getRemoteAddr(); String ipAddress = request.getRemoteAddr();
if (ipAddress == null) if (ipAddress == null)
{ {
return createBasicHTML(TITLE, "An IP address could not be detected. Please ensure you are connecting using IPv4."); return punishmentsHTML("An IP address could not be detected. Please ensure you are connecting using IPv4.");
} }
if (request.getPathInfo() == null) if (request.getPathInfo() == null || request.getPathInfo().equals("/"))
{ {
StringBuilder contentBuilder = new StringBuilder(); return readFile(this.getClass().getResourceAsStream("/httpd/punishments.html"));
try
{
BufferedReader in = new BufferedReader(new InputStreamReader(Objects.requireNonNull(this.getClass().getResourceAsStream("/httpd/punishments.html"))));
String str;
while ((str = in.readLine()) != null)
{
contentBuilder.append(str);
}
in.close();
}
catch (IOException ignored)
{
}
return contentBuilder.toString();
} }
UUID pathUUID; UUID pathUUID;
String pathPlexPlayer; String pathPlexPlayer;
@ -67,16 +47,16 @@ public class PunishmentsEndpoint extends AbstractServlet
final PlexPlayer player = DataUtils.getPlayerByIP(ipAddress); final PlexPlayer player = DataUtils.getPlayerByIP(ipAddress);
if (punishedPlayer == null) if (punishedPlayer == null)
{ {
return createBasicHTML(TITLE, "This player has never joined the server before."); return punishmentsHTML("This player has never joined the server before.");
} }
if (punishedPlayer.getPunishments().isEmpty()) if (punishedPlayer.getPunishments().isEmpty())
{ {
return createBasicHTML(TITLE, "This player has been a good boy. They have no punishments!"); return punishmentsGoodHTML("This player has been a good boy. They have no punishments!");
} }
if (player == null) if (player == null)
{ {
// If the player is null, give it to them without the IPs // If the player is null, give it to them without the IPs
return createJSONHTML(TITLE, new GsonBuilder().registerTypeAdapter(LocalDateTime.class, new LocalDateTimeSerializer()).setPrettyPrinting().create().toJson(punishedPlayer.getPunishments().stream().peek(punishment -> punishment.setIp("")).toList())); return new GsonBuilder().registerTypeAdapter(LocalDateTime.class, new LocalDateTimeSerializer()).setPrettyPrinting().create().toJson(punishedPlayer.getPunishments().stream().peek(punishment -> punishment.setIp("")).toList());
} }
if (Plex.get().getSystem().equalsIgnoreCase("ranks")) if (Plex.get().getSystem().equalsIgnoreCase("ranks"))
{ {
@ -84,7 +64,7 @@ public class PunishmentsEndpoint extends AbstractServlet
if (!player.getRankFromString().isAtLeast(Rank.ADMIN)) if (!player.getRankFromString().isAtLeast(Rank.ADMIN))
{ {
// Don't return IPs either if the person is not an Admin or above. // Don't return IPs either if the person is not an Admin or above.
return createJSONHTML(TITLE, new GsonBuilder().registerTypeAdapter(LocalDateTime.class, new LocalDateTimeSerializer()).setPrettyPrinting().create().toJson(punishedPlayer.getPunishments().stream().peek(punishment -> punishment.setIp("")).toList())); return new GsonBuilder().registerTypeAdapter(LocalDateTime.class, new LocalDateTimeSerializer()).setPrettyPrinting().create().toJson(punishedPlayer.getPunishments().stream().peek(punishment -> punishment.setIp("")).toList());
} }
} }
else if (Plex.get().getSystem().equalsIgnoreCase("permissions")) else if (Plex.get().getSystem().equalsIgnoreCase("permissions"))
@ -94,9 +74,23 @@ public class PunishmentsEndpoint extends AbstractServlet
if (!HTTPDModule.getPermissions().playerHas(null, offlinePlayer, "plex.httpd.punishments.access")) if (!HTTPDModule.getPermissions().playerHas(null, offlinePlayer, "plex.httpd.punishments.access"))
{ {
// If the person doesn't have permission, don't return IPs // If the person doesn't have permission, don't return IPs
return createJSONHTML(TITLE, new GsonBuilder().registerTypeAdapter(LocalDateTime.class, new LocalDateTimeSerializer()).setPrettyPrinting().create().toJson(punishedPlayer.getPunishments().stream().peek(punishment -> punishment.setIp("")).toList())); return new GsonBuilder().registerTypeAdapter(LocalDateTime.class, new LocalDateTimeSerializer()).setPrettyPrinting().create().toJson(punishedPlayer.getPunishments().stream().peek(punishment -> punishment.setIp("")).toList());
} }
} }
return createJSONHTML(TITLE, new GsonBuilder().registerTypeAdapter(LocalDateTime.class, new LocalDateTimeSerializer()).setPrettyPrinting().create().toJson(punishedPlayer.getPunishments().stream().toList())); return new GsonBuilder().registerTypeAdapter(LocalDateTime.class, new LocalDateTimeSerializer()).setPrettyPrinting().create().toJson(punishedPlayer.getPunishments().stream().toList());
}
private String punishmentsHTML(String message)
{
String file = readFile(this.getClass().getResourceAsStream("/httpd/punishments_error.html"));
file = file.replace("${MESSAGE}", message);
return file;
}
private String punishmentsGoodHTML(String message)
{
String file = readFile(this.getClass().getResourceAsStream("/httpd/punishments_good.html"));
file = file.replace("${MESSAGE}", message);
return file;
} }
} }

View File

@ -0,0 +1,46 @@
<!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>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="indefbans/">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>
</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

@ -0,0 +1,46 @@
<!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>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>
</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

@ -0,0 +1,47 @@
<!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>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>
</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,32 +1,64 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html lang="en">
<head> <head>
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <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>Punishments - Plex HTTPD</title> <title>Punishments - Plex HTTPD</title>
</head> </head>
<body> <body>
<div style="text-align: center;"> <nav class="navbar navbar-expand-lg navbar-light bg-light">
<h2 style="font-family:Helvetica,serif">Enter the UUID or username of the player you want to lookup</h2> <div class="container-fluid">
<input type="text" <a class="navbar-brand" href="/">Plex HTTPD</a>
id="uuid" <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav"
autofocus aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
autocomplete="off" <span class="navbar-toggler-icon"></span>
style="width: 250px;" </button>
onkeydown="if (event.keyCode === 13) <div class="collapse navbar-collapse" id="navbarNav">
document.getElementById('submit').click()"/> <ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="/">Home</a>
<input type="button" </li>
id="submit" <li class="nav-item">
value="Submit" <a class="nav-link" href="admins/">Admins</a>
onclick="redirect();"/> </li>
<li class="nav-item">
<script> <a class="nav-link" href="indefbans/">Indefinite Bans</a>
function redirect() { </li>
const url = document.getElementById('uuid').value; <li class="nav-item">
window.location = "punishments/" + url <a class="nav-link" href="list/">List</a>
} </li>
</script> <li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Punishments</a>
</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" onKeyUp="{this.onKeyUpValue.bind(this)"
onclick="redirect();">Submit
</button>
</div>
</div> </div>
<script>
function redirect() {
const url = document.getElementById('uuid').value;
window.location = "/api/punishments/" + url
}
</script>
<script>
document.getElementById('uuid').addEventListener('keypress', function (event) {
if (event.keyCode === 13) {
redirect();
}
});
</script>
</body> </body>
</html> </html>

View File

@ -0,0 +1,46 @@
<!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>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="../admins/">Admins</a>
</li>
<li class="nav-item">
<a class="nav-link" href="../indefbans/">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 active" aria-current="page" href="#">Punishments</a>
</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

@ -0,0 +1,46 @@
<!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>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="../admins/">Admins</a>
</li>
<li class="nav-item">
<a class="nav-link" href="../indefbans/">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 active" aria-current="page" href="#">Punishments</a>
</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>