"); dashboard\primary\error("You banned too many accounts too frequently, your admin is removed"); return; } $un = misc\etc\sanitize($_POST['banacc']); $reason = misc\etc\sanitize($_POST['reason']); $query = misc\mysql\query("SELECT `admin`, `banned` FROM `accounts` WHERE `username` = ?", [$un]); if ($query->num_rows < 1) { echo ''; dashboard\primary\error("Account not found!"); return; } if (!is_null(mysqli_fetch_array($query->result)['banned'])) { echo ''; dashboard\primary\error("User is already banned!"); return; } if (mysqli_fetch_array($query->result)['admin']) { echo ''; dashboard\primary\error("User is an admin!"); return; } misc\mysql\query("UPDATE `accounts` SET `banned` = ? WHERE `username` = ?", [$reason, $un]); // set account to banned misc\mysql\query("UPDATE `apps` SET `banned` = '1' WHERE `owner` = ?", [$un]); // ban all apps owned by account dashboard\primary\wh_log($adminwebhook, "Admin `{$username}` has banned user `{$un}` for reason `{$reason}`", $adminwebhookun, "41db10", "No ping"); dashboard\primary\success("Account Banned!"); $query = misc\mysql\query("SELECT `name`, `ownerid` FROM `apps` WHERE `owner` = ?", [$un]); $rows = array(); while ($r = mysqli_fetch_assoc($query->result)) { $rows[] = $r; } foreach ($rows as $row) { misc\cache\purge('KeyAuthApp:' . $row['name'] . ':' . $row['ownerid']); } $query = misc\mysql\query("SELECT `role` FROM `accounts` WHERE `username` = ?", [$un]); $row = mysqli_fetch_array($query->result); if ($row['role'] == "seller") { $query = misc\mysql\query("SELECT `sellerkey` FROM `apps` WHERE `owner` = ?", [$un]); $rows = array(); while ($r = mysqli_fetch_assoc($query->result)) { $rows[] = $r; } foreach ($rows as $row) { misc\cache\purge('KeyAuthAppSeller:' . $row['sellerkey']); } } } if (isset($_POST['unbanacc'])) { $un = misc\etc\sanitize($_POST['unbanacc']); $query = misc\mysql\query("SELECT `admin`,`banned` FROM `accounts` WHERE `username` = ?", [$un]); if ($query->num_rows < 1) { echo ''; dashboard\primary\error("Account not found!"); return; } if (is_null(mysqli_fetch_array($query->result)['banned'])) { echo ''; dashboard\primary\error("User isn't banned!"); return; } if (mysqli_fetch_array($query->result)['admin']) { echo ''; dashboard\primary\error("User is an admin!"); return; } misc\mysql\query("UPDATE `accounts` SET `banned` = NULL WHERE `username` = ?", [$un]); // set account to not banned misc\mysql\query("UPDATE `apps` SET `banned` = '0' WHERE `owner` = ?", [$un]); // unban all apps owned by account dashboard\primary\wh_log($adminwebhook, "Admin `{$username}` has unbanned user `{$un}`", $adminwebhookun, "41db10", "No ping"); dashboard\primary\success("Account Unbanned!"); $query = misc\mysql\query("SELECT `name`, `ownerid` FROM `apps` WHERE `owner` = ?", [$un]); $rows = array(); while ($r = mysqli_fetch_assoc($query->result)) { $rows[] = $r; } foreach ($rows as $row) { misc\cache\purge('KeyAuthApp:' . $row['name'] . ':' . $row['ownerid']); } $query = misc\mysql\query("SELECT `role` FROM `accounts` WHERE `username` = ?", [$un]); $row = mysqli_fetch_array($query->result); if ($row['role'] == "seller") { $query = misc\mysql\query("SELECT `sellerkey` FROM `apps` WHERE `owner` = ?", [$un]); $rows = array(); while ($r = mysqli_fetch_assoc($query->result)) { $rows[] = $r; } foreach ($rows as $row) { misc\cache\purge('KeyAuthAppSeller:' . $row['sellerkey']); } } } if (isset($_POST['purgeRedis'])) { $redisKey = misc\etc\sanitize($_POST['redisKey']); if(str_contains(strtolower($redisKey), "keyauthadminbans")) { echo ''; dashboard\primary\error("You're not allowed to purge this key"); return; } if(str_contains(strtolower($redisKey), "keyauthadminedits")) { echo ''; dashboard\primary\error("You're not allowed to purge this key"); return; } misc\cache\purge($redisKey); dashboard\primary\success("Purged redis key"); dashboard\primary\wh_log($adminwebhook, "Admin `{$username}` has purged a redis key for `{$redisKey}`", $adminwebhookun, "41db10", "No ping"); } if (isset($_POST['purgeRedisPattern'])) { $redisKey = misc\etc\sanitize($_POST['redisKeyPattern']); if(str_contains(strtolower($redisKey), "keyauthadminbans")) { echo ''; dashboard\primary\error("You're not allowed to purge this key"); return; } if(str_contains(strtolower($redisKey), "keyauthadminedits")) { echo ''; dashboard\primary\error("You're not allowed to purge this key"); return; } misc\cache\purgePattern($redisKey); dashboard\primary\success("Purged redis key(s)"); dashboard\primary\wh_log($adminwebhook, "Admin `{$username}` has purged a redis pattern for `{$redisKey}`", $adminwebhookun, "41db10", "No ping"); } if(isset($_POST['searchOrder'])) { $orderID = misc\etc\sanitize($_POST['orderID']); $query = misc\mysql\query("SELECT `username` FROM `orders` WHERE `orderID` = ?", [$orderID]); if($query->num_rows < 1) { dashboard\primary\error("Order not found!"); } else { $row = mysqli_fetch_array($query->result); } } if (isset($_POST['saveacc'])) { if(misc\cache\rateLimit("KeyAuthAdminEdits:" . $_SESSION['username'], 1, 3600, 3)) { misc\mysql\query("UPDATE `accounts` SET `admin` = 0 WHERE `username` = ?", [$_SESSION['username']]); dashboard\primary\wh_log($adminwebhook, "the admin `{$username}` has been removed for editing too many people", $adminwebhookun, "db1010", "<@1268915723330392096> "); dashboard\primary\error("You edited too many accounts too frequently, your admin is removed"); return; } $un = misc\etc\sanitize($_POST['saveacc']); $email = misc\etc\sanitize($_POST['email']); $role = misc\etc\sanitize($_POST['role']); $secKey = misc\etc\sanitize($_POST['secKey']); $totp = misc\etc\sanitize($_POST['totp']); $staff = misc\etc\sanitize($_POST['staff']); $alertMsg = misc\etc\sanitize($_POST['alert']); $formBanned = misc\etc\sanitize($_POST['formBanned']); $query = misc\mysql\query("SELECT `role`,`admin` FROM `accounts` WHERE `username` = ?", [$un]); $row = mysqli_fetch_array($query->result); if ($row['admin']) { echo ''; dashboard\primary\error("User is an admin!"); return; } if ($row['role'] == "seller" || $role == "seller") { // purge cache for SellerAPI check if user was seller and getting downgraded, or was another plan and getting upgraded to seller. misc\cache\purge('KeyAuthSellerCheck:' . $un); } switch ($role) { case 'seller': $expires = time() + (int) $_POST['expiry']; break; case 'developer': $expires = time() + (int) $_POST['expiry']; break; case 'tester': $expires = NULL; break; case 'reseller': $expires = NULL; break; case 'manager': $expires = NULL; break; default: dashboard\primary\error("Invalid role!"); echo ""; return; } misc\mysql\query("UPDATE `accounts` SET `role` = ?, `securityKey` = ?, `twofactor` = ?, `alert` = ? WHERE `username` = ?", [$role, $secKey, $totp, $alertMsg, $un]); if (strlen($email) != 40) { misc\mysql\query("UPDATE `accounts` SET `email` = SHA1(?) WHERE `username` = ?", [$email, $un]); } if ($row['role'] != $role) { misc\mysql\query("UPDATE `accounts` SET `expires` = NULLIF(?, '') WHERE `username` = ?", [$expires, $un]); } if ($row['staff'] != $staff){ misc\mysql\query("UPDATE `accounts` SET `staff` = NULLIF(?, '') WHERE `username` = ?", [$staff, $un]); } if ($row['formBanned'] != $formBanned){ misc\mysql\query("UPDATE `accounts` SET `formBanned` = NULLIF(?, '') WHERE `username` = ?", [$formBanned, $un]); } if (isset($_POST['resetSecWordsCB'])){ misc\mysql\query("UPDATE `accounts` SET `secWords` = NULL WHERE `username` = ?", [$un]); } dashboard\primary\wh_log($adminwebhook, "Admin `{$username}` has updated user `{$un}` \n email to: `{$email}`, \n role to: `{$role}`, \n 2FA status to: `{$totp}`, \n staff status to: `{$staff}`, \n form banned status to: `{$formBanned}`, \n alert to: `{$alertMsg}`", $adminwebhookun, "41db10", "No ping"); dashboard\primary\success("Updated Account!"); } if (isset($_POST['editacc'])) { $un = misc\etc\sanitize($_POST['editacc']); $query = misc\mysql\query("SELECT * FROM `accounts` WHERE `username` = ?", [$un]); $row = mysqli_fetch_array($query->result); $role = $row['role']; $secKey = $row['securityKey']; $totp = $row['twofactor']; $formBanned = $row['formBanned']; $alertMsg = $row['alert']; $secWords = $row['secWords']; $staff = $row['staff']; $admin = $row['admin']; if ($admin) { echo ''; dashboard\primary\error("User is an admin!"); return; } ?>
Welcome = $username; ?> To The Admin Panel!
| Username | Owner ID | Role | Staff | Ban Status | Security Key | 2FA Status | Register IP | Last IP | Action | |
|---|---|---|---|---|---|---|---|---|---|---|
| = $un; ?> | = $row["ownerid"]; ?> | = $row["email"]; ?> | = $row["role"]; ?> | = $staff; ?> | = $ban; ?> | = $secKey; ?> | = $totp; ?> | = $row["registrationip"] ?? "None"; ?> | = $row["lastip"] ?? "None"; ?> |