Browse Source

Submission delete button and application uri change

Owen Diffey 4 years ago
parent
commit
3a3fc56681
2 changed files with 27 additions and 3 deletions
  1. 23 3
      index.php
  2. 4 0
      source/style.css

+ 23 - 3
index.php

@@ -275,6 +275,15 @@ function getDiscordUserGuilds($access_token)
 }
 
 if ($_SERVER["REQUEST_METHOD"] == "POST") {
+  if (isset($_POST["delete"])) {
+    print_r($_POST["delete"]);
+    $conn = new db();
+    if ($conn->query("DELETE FROM empyreanrealm WHERE id = ?", $conn->escapeString(cleanInput($_POST["delete"])))->affectedRows() === 1) {
+      $success = true;
+    } else {
+      $errors[] = "Error deleting application.";
+    }
+  }
   $nickname = verifyInput("username", $_POST["nickname"]);
   if ($nickname === false) {
       $errors[] = "Invalid nickname.";
@@ -341,7 +350,7 @@ $page = preg_replace("/\?.+/", "", $page);
     <link rel="stylesheet" href="/source/style.css">
   </head>
   <body>
-    <?php if ($success) { ?>
+    <?php if ($success && !isset($_POST["delete"])) { ?>
     <div>
       <img src="source/logo.png" alt="logo" id="logo">
       <h1>Bedrock Server Application</h1>
@@ -377,6 +386,7 @@ $page = preg_replace("/\?.+/", "", $page);
                 <td>Username</td>
                 <td>Birth Date</td>
                 <td>Submission Date</td>
+                <td>Delete</td>
               </tr>
           </thead>
           <tbody>
@@ -389,6 +399,14 @@ $page = preg_replace("/\?.+/", "", $page);
               <td><?= $player["username"] ?></td>
               <td><?= $player["birthdate"] ?></td>
               <td><?= $player["submittime"] ?></td>
+              <td>
+                <form action="" method="post" onsubmit="return confirm('Irreversible action! Are you sure you want to delete this application?');">
+                  <button class="delete" type="submit" name="form" value="delete" title="Irreversible action, take caution.">
+                    <i class="fas fa-exclamation-triangle"></i> Delete
+                  </button>
+                  <input type="hidden" name="delete" value="<?= $player["id"] ?>">
+                </form>
+              </td>
             </tr>
             <?php });
             $conn->close(); ?>
@@ -396,7 +414,7 @@ $page = preg_replace("/\?.+/", "", $page);
         </table>
       </div>
     </div>
-    <?php } else { ?>
+    <?php } else if ($page === "/bedrock") { ?>
     <div>
       <img src="source/logo.png" alt="logo" id="logo">
       <h1>Bedrock Server Application</h1>
@@ -429,6 +447,8 @@ $page = preg_replace("/\?.+/", "", $page);
       </div>
       <?php } ?>
     </div>
-    <?php } ?>
+    <?php } else { 
+      header("Location: https://discord.gg/yPbwmXM");
+     } ?>
   </body>
 </html>

+ 4 - 0
source/style.css

@@ -165,4 +165,8 @@ input:focus {
 .errors p {
   margin: 0;
   font-size: 16px;
+}
+
+.delete {
+  margin: 0;
 }