datein hinzufügen
This commit is contained in:
690
app/pages/manage-accs.php
Normal file
690
app/pages/manage-accs.php
Normal file
@@ -0,0 +1,690 @@
|
||||
<?php
|
||||
if ($_SESSION['role'] == "Reseller") {
|
||||
header("location: ./?page=reseller-licenses");
|
||||
die();
|
||||
}
|
||||
if ($_SESSION['role'] == "tester") {
|
||||
dashboard\primary\error("Must have developer or seller plan to create sub-accounts.");
|
||||
die();
|
||||
}
|
||||
|
||||
if (isset($_POST['createacc'])) {
|
||||
$resp = misc\account\addAccount($_POST['username'], $_POST['role'], $_POST['email'], $_POST['pw'], $_POST['keylevels'], $_SESSION['username'], $_POST['app'], $_POST['permissions']);
|
||||
match($resp){
|
||||
'invalid_perms' => dashboard\primary\error("Invalid permission value. You msut have at least one permission flag enabled"),
|
||||
'invalid_role' => dashboard\primary\error("Role options are Manager or Reseller"),
|
||||
'invalid_email' => dashboard\primary\error("No email defined"),
|
||||
'username_taken' => dashboard\primary\error("Username already taken!"),
|
||||
'email_taken' => dashboard\primary\error("Email already taken!"),
|
||||
'failure' => dashboard\primary\error("Failed to add account!"),
|
||||
'success' => dashboard\primary\success("Successfully added account"),
|
||||
default => dashboard\primary\error("Unhandled Error! Contact us if you need help")
|
||||
};
|
||||
}
|
||||
if (isset($_POST['deleteacc'])) {
|
||||
$query = misc\mysql\query("DELETE FROM `accounts` WHERE `owner` = ? AND `username` = ?", [$_SESSION['username'], $_POST['deleteacc']]);
|
||||
if ($query->affected_rows > 0) {
|
||||
dashboard\primary\success("Account Successfully Deleted!");
|
||||
} else {
|
||||
dashboard\primary\error("Failed To Delete Account!");
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_POST['deleteacckeys'])){
|
||||
$query = misc\mysql\query("DELETE FROM `keys` WHERE `genby` = ? AND `app` = ?", [$_POST['deleteacckeys'], $secret ?? $_SESSION['app']]);
|
||||
if ($query->affected_rows > 0) {
|
||||
dashboard\primary\success("Successfully deleted all keys generated by this user!");
|
||||
} else {
|
||||
dashboard\primary\error("Failed To Delete Their Generated Keys!");
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_POST['deleteaccusers'])){
|
||||
$query = misc\mysql\query("DELETE FROM `users` WHERE `owner` = ? AND `app` = ?", [$_POST['deleteaccusers'], $secret ?? $_SESSION['app']]);
|
||||
if ($query->affected_rows > 0) {
|
||||
dashboard\primary\success("Successfully deleted all users generated by this user!");
|
||||
} else {
|
||||
dashboard\primary\error("Failed To Delete Their Generated Users!");
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_POST['deleteresellers'])){
|
||||
$query = misc\mysql\query("DELETE FROM `accounts` WHERE `owner` = ? AND `role` = ?", [$_SESSION['username'], "Reseller"]);
|
||||
if ($query->affected_rows > 0){
|
||||
dashboard\primary\success("All Resellers deleted successfully!");
|
||||
} else {
|
||||
dashboard\primary\error("Failed to delete all Resellers!");
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_POST['deletemanagers'])){
|
||||
$query = misc\mysql\query("DELETE FROM `accounts` WHERE `owner` = ? AND `role` = ?", [$_SESSION['username'], "Manager"]);
|
||||
if ($query->affected_rows > 0){
|
||||
dashboard\primary\success("All Managers deleted successfully!");
|
||||
} else {
|
||||
dashboard\primary\error("Failed to delete all Managers!");
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_POST['editacc'])) {
|
||||
$account = misc\etc\sanitize($_POST['editacc']);
|
||||
|
||||
$query = misc\mysql\query("SELECT * FROM `accounts` WHERE `username` = ? AND `owner` = ?", [$_POST['editacc'], $_SESSION['username']]);
|
||||
if ($query->num_rows < 1) {
|
||||
dashboard\primary\error("Account not Found!");
|
||||
echo "<meta http-equiv='Refresh' Content='2'>";
|
||||
return;
|
||||
}
|
||||
|
||||
$row = mysqli_fetch_array($query->result);
|
||||
|
||||
$username = $row['username'];
|
||||
$keylevels = $row['keylevels'];
|
||||
$balance = $row["balance"];
|
||||
$balance = explode("|", $balance);
|
||||
|
||||
$day = $balance[0];
|
||||
$week = $balance[1];
|
||||
$month = $balance[2];
|
||||
$threemonth = $balance[3];
|
||||
$sixmonth = $balance[4];
|
||||
$life = $balance[5];
|
||||
$year = $balance[6];
|
||||
|
||||
echo '<!-- Edit Account Modal -->
|
||||
<div id="edit-account-modal" tabindex="-1" aria-hidden="true"
|
||||
class="fixed grid place-items-center h-screen bg-black bg-opacity-60 z-50 p-4 overflow-x-hidden overflow-y-auto md:inset-0 h-[calc(100%-1rem)] max-h-full">
|
||||
<div class="relative w-full max-w-md max-h-full">
|
||||
<!-- Modal content -->
|
||||
<div class="relative bg-[#0f0f17] rounded-lg border border-[#1d4ed8] shadow">
|
||||
<div class="px-6 py-6 lg:px-8">
|
||||
<h3 class="mb-4 text-xl font-medium text-white-900">Edit Account</h3>
|
||||
<hr class="h-px mb-4 mt-4 bg-gray-700 border-0">
|
||||
<form class="space-y-6" method="POST">
|
||||
<div>
|
||||
<div class="grid grid-cols-2 gap-1">
|
||||
<div class="relative mb-4">
|
||||
<input type="text" inputmode="numeric" id="daybalance" name="daybalance"
|
||||
class="block px-2.5 pb-2.5 pt-4 w-full text-sm text-white bg-transparent rounded-lg border-1 border-gray-700 appearance-none focus:ring-0 peer"
|
||||
placeholder=" " autocomplete="on" value="' . $day . '" maxlength="3"
|
||||
required>
|
||||
<input type="hidden" id="account" name="account"
|
||||
class="block px-2.5 pb-2.5 pt-4 w-full text-sm text-white bg-transparent rounded-lg border-1 border-gray-700 appearance-none focus:ring-0 peer"
|
||||
placeholder=" " autocomplete="on" value="' . $username . '">
|
||||
|
||||
<label for="daybalance"
|
||||
class="absolute text-sm text-gray-400 duration-300 transform -translate-y-4 scale-75 top-2 z-10 origin-[0] bg-[#0f0f17] px-2 peer-focus:px-2 peer-focus:text-blue-600 peer-placeholder-shown:scale-100 peer-placeholder-shown:-translate-y-1/2 peer-placeholder-shown:top-1/2 peer-focus:top-2 peer-focus:scale-75 peer-focus:-translate-y-4 left-1">Day
|
||||
Balance:</label>
|
||||
</div>
|
||||
|
||||
<div class="relative mb-4">
|
||||
<input type="text" inputmode="numeric" id="weekbalance" name="weekbalance"
|
||||
class="block px-2.5 pb-2.5 pt-4 w-full text-sm text-white bg-transparent rounded-lg border-1 border-gray-700 appearance-none focus:ring-0 peer"
|
||||
placeholder=" " autocomplete="on" value="' . $week . '" maxlength="3"
|
||||
required>
|
||||
<label for="weekbalance"
|
||||
class="absolute text-sm text-gray-400 duration-300 transform -translate-y-4 scale-75 top-2 z-10 origin-[0] bg-[#0f0f17] px-2 peer-focus:px-2 peer-focus:text-blue-600 peer-placeholder-shown:scale-100 peer-placeholder-shown:-translate-y-1/2 peer-placeholder-shown:top-1/2 peer-focus:top-2 peer-focus:scale-75 peer-focus:-translate-y-4 left-1">Week
|
||||
Balance:</label>
|
||||
</div>
|
||||
|
||||
<div class="relative mb-4">
|
||||
<input type="text" inputmode="numeric" id="monthbalance" name="monthbalance"
|
||||
class="block px-2.5 pb-2.5 pt-4 w-full text-sm text-white bg-transparent rounded-lg border-1 border-gray-700 appearance-none focus:ring-0 peer"
|
||||
placeholder=" " autocomplete="on" value="' . $month . '" maxlength="3"
|
||||
required>
|
||||
<label for="monthbalance"
|
||||
class="absolute text-sm text-gray-400 duration-300 transform -translate-y-4 scale-75 top-2 z-10 origin-[0] bg-[#0f0f17] px-2 peer-focus:px-2 peer-focus:text-blue-600 peer-placeholder-shown:scale-100 peer-placeholder-shown:-translate-y-1/2 peer-placeholder-shown:top-1/2 peer-focus:top-2 peer-focus:scale-75 peer-focus:-translate-y-4 left-1">Month
|
||||
Balance:</label>
|
||||
</div>
|
||||
|
||||
<div class="relative mb-4">
|
||||
<input type="text" inputmode="numeric" id="threemonthbalance"
|
||||
name="threemonthbalance"
|
||||
class="block px-2.5 pb-2.5 pt-4 w-full text-sm text-white bg-transparent rounded-lg border-1 border-gray-700 appearance-none focus:ring-0 peer"
|
||||
placeholder=" " autocomplete="on" value="' . $threemonth .'"
|
||||
maxlength="3" required>
|
||||
<label for="threemonthbalance"
|
||||
class="absolute text-sm text-gray-400 duration-300 transform -translate-y-4 scale-75 top-2 z-10 origin-[0] bg-[#0f0f17] px-2 peer-focus:px-2 peer-focus:text-blue-600 peer-placeholder-shown:scale-100 peer-placeholder-shown:-translate-y-1/2 peer-placeholder-shown:top-1/2 peer-focus:top-2 peer-focus:scale-75 peer-focus:-translate-y-4 left-1">Three
|
||||
Month Balance:</label>
|
||||
</div>
|
||||
|
||||
<div class="relative mb-4">
|
||||
<input type="text" inputmode="numeric" id="sixmonthbalance"
|
||||
name="sixmonthbalance"
|
||||
class="block px-2.5 pb-2.5 pt-4 w-full text-sm text-white bg-transparent rounded-lg border-1 border-gray-700 appearance-none focus:ring-0 peer"
|
||||
placeholder=" " autocomplete="on" value="' . $sixmonth .'"
|
||||
maxlength="3" required>
|
||||
<label for="sixmonthbalance"
|
||||
class="absolute text-sm text-gray-400 duration-300 transform -translate-y-4 scale-75 top-2 z-10 origin-[0] bg-[#0f0f17] px-2 peer-focus:px-2 peer-focus:text-blue-600 peer-placeholder-shown:scale-100 peer-placeholder-shown:-translate-y-1/2 peer-placeholder-shown:top-1/2 peer-focus:top-2 peer-focus:scale-75 peer-focus:-translate-y-4 left-1">Six
|
||||
Month Balance:</label>
|
||||
</div>
|
||||
|
||||
<div class="relative mb-4">
|
||||
<input type="text" inputmode="numeric" id="yearbalance"
|
||||
name="yearbalance"
|
||||
class="block px-2.5 pb-2.5 pt-4 w-full text-sm text-white bg-transparent rounded-lg border-1 border-gray-700 appearance-none focus:ring-0 peer"
|
||||
placeholder=" " autocomplete="on" value="' . $year .'"
|
||||
maxlength="3" required>
|
||||
<label for="yearbalance"
|
||||
class="absolute text-sm text-gray-400 duration-300 transform -translate-y-4 scale-75 top-2 z-10 origin-[0] bg-[#0f0f17] px-2 peer-focus:px-2 peer-focus:text-blue-600 peer-placeholder-shown:scale-100 peer-placeholder-shown:-translate-y-1/2 peer-placeholder-shown:top-1/2 peer-focus:top-2 peer-focus:scale-75 peer-focus:-translate-y-4 left-1">
|
||||
Year Balance:</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="relative mb-4">
|
||||
<input type="text" inputmode="numeric" id="lifebalance" name="lifebalance"
|
||||
class="block px-2.5 pb-2.5 pt-4 w-full text-sm text-white bg-transparent rounded-lg border-1 border-gray-700 appearance-none focus:ring-0 peer"
|
||||
placeholder=" " autocomplete="on" value="' . $life . '" maxlength="3"
|
||||
required>
|
||||
<label for="lifebalance"
|
||||
class="absolute text-sm text-gray-400 duration-300 transform -translate-y-4 scale-75 top-2 z-10 origin-[0] bg-[#0f0f17] px-2 peer-focus:px-2 peer-focus:text-blue-600 peer-placeholder-shown:scale-100 peer-placeholder-shown:-translate-y-1/2 peer-placeholder-shown:top-1/2 peer-focus:top-2 peer-focus:scale-75 peer-focus:-translate-y-4 left-1">Lifetime
|
||||
Balance:</label>
|
||||
</div>
|
||||
|
||||
<hr class="h-px mb-4 mt-4 bg-gray-700 border-0">
|
||||
|
||||
<div class="relative mb-4">
|
||||
<input type="text" inputmode="numeric" id="keylevels" name="keylevels"
|
||||
class="block px-2.5 pb-2.5 pt-4 w-full text-sm text-white bg-transparent rounded-lg border-1 border-gray-700 appearance-none focus:ring-0 peer"
|
||||
placeholder=" " autocomplete="on" value="' . $keylevels .'">
|
||||
<label for="keylevels"
|
||||
class="absolute text-sm text-gray-400 duration-300 transform -translate-y-4 scale-75 top-2 z-10 origin-[0] bg-[#0f0f17] px-2 peer-focus:px-2 peer-focus:text-blue-600 peer-placeholder-shown:scale-100 peer-placeholder-shown:-translate-y-1/2 peer-placeholder-shown:top-1/2 peer-focus:top-2 peer-focus:scale-75 peer-focus:-translate-y-4 left-1">Key
|
||||
Levels:</label>
|
||||
</div>
|
||||
|
||||
<hr class="h-px mb-4 mt-4 bg-gray-700 border-0">
|
||||
|
||||
<div class="relative mb-4">
|
||||
<input type="email" id="email" name="email"
|
||||
class="block px-2.5 pb-2.5 pt-4 w-full text-sm text-white bg-transparent rounded-lg border-1 border-gray-700 appearance-none focus:ring-0 peer"
|
||||
placeholder=" " autocomplete="on">
|
||||
<label for="email"
|
||||
class="absolute text-sm text-gray-400 duration-300 transform -translate-y-4 scale-75 top-2 z-10 origin-[0] bg-[#0f0f17] px-2 peer-focus:px-2 peer-focus:text-blue-600 peer-placeholder-shown:scale-100 peer-placeholder-shown:-translate-y-1/2 peer-placeholder-shown:top-1/2 peer-focus:top-2 peer-focus:scale-75 peer-focus:-translate-y-4 left-1">New
|
||||
Email:</label>
|
||||
</div>
|
||||
|
||||
<div class="relative mb-4">
|
||||
<input type="password" id="pw" name="pw"
|
||||
class="block px-2.5 pb-2.5 pt-4 w-full text-sm text-white bg-transparent rounded-lg border-1 border-gray-700 appearance-none focus:ring-0 peer"
|
||||
placeholder=" " autocomplete="on">
|
||||
<label for="pw"
|
||||
class="absolute text-sm text-gray-400 duration-300 transform -translate-y-4 scale-75 top-2 z-10 origin-[0] bg-[#0f0f17] px-2 peer-focus:px-2 peer-focus:text-blue-600 peer-placeholder-shown:scale-100 peer-placeholder-shown:-translate-y-1/2 peer-placeholder-shown:top-1/2 peer-focus:top-2 peer-focus:scale-75 peer-focus:-translate-y-4 left-1">New
|
||||
Password:</label>
|
||||
</div>
|
||||
</div>
|
||||
<button name="saveacc"
|
||||
class="w-full text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center">Save
|
||||
Changes</button>
|
||||
<button
|
||||
class="w-full text-white bg-red-700 hover:bg-red-800 focus:ring-4 focus:outline-none focus:ring-red-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center" onClick="window.location.href=window.location.href">Cancel
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- End Edit Account Modal -->';
|
||||
}
|
||||
|
||||
if (isset($_POST['saveacc'])) {
|
||||
$account = misc\etc\sanitize($_POST['account']);
|
||||
|
||||
$day = misc\etc\sanitize($_POST['daybalance']);
|
||||
$week = misc\etc\sanitize($_POST['weekbalance']);
|
||||
$month = misc\etc\sanitize($_POST['monthbalance']);
|
||||
$threemonth = misc\etc\sanitize($_POST['threemonthbalance']);
|
||||
$sixmonth = misc\etc\sanitize($_POST['sixmonthbalance']);
|
||||
$year = misc\etc\sanitize($_POST['yearbalance']);
|
||||
$lifetime = misc\etc\sanitize($_POST['lifebalance']);
|
||||
$keylevels = misc\etc\sanitize($_POST['keylevels']) ?? "N/A";
|
||||
|
||||
$email = misc\etc\sanitize($_POST['email']);
|
||||
$pw = misc\etc\sanitize($_POST['pw']);
|
||||
|
||||
if (!empty($email)) {
|
||||
$query = misc\mysql\query("SELECT `username` FROM `accounts` WHERE `email` = SHA1(?)", [$email]);
|
||||
if ($query->num_rows > 0) {
|
||||
dashboard\primary\error("Email already taken!");
|
||||
echo '<meta http-equiv="refresh" content="5">';
|
||||
return;
|
||||
}
|
||||
misc\mysql\query("UPDATE `accounts` SET `email` = SHA1(?) WHERE `username` = ? AND `owner` = ?", [$email, $account, $_SESSION['username']]);
|
||||
}
|
||||
if (!empty($pw)) {
|
||||
$pw = password_hash($pw, PASSWORD_BCRYPT);
|
||||
misc\mysql\query("UPDATE `accounts` SET `password` = ? WHERE `username` = ? AND `owner` = ?", [$pw, $account, $_SESSION['username']]);
|
||||
}
|
||||
|
||||
$balance = "$day|$week|$month|$threemonth|$sixmonth|$lifetime|$year";
|
||||
|
||||
$query = misc\mysql\query("UPDATE `accounts` SET `balance` = ?, `keylevels` = ? WHERE `username` = ? AND `owner` = ?", [$balance, $keylevels, $account, $_SESSION['username']]);
|
||||
if ($query->affected_rows > 0) {
|
||||
dashboard\primary\success("Successfully updated settings!");
|
||||
} else {
|
||||
dashboard\primary\error("Failed to update settings " . $life . $day . $week . $threemonth);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="p-4 bg-[#09090d] block sm:flex items-center justify-between lg:mt-1.5">
|
||||
<div class="mb-1 w-full bg-[#0f0f17] rounded-xl">
|
||||
<div class="mb-4 p-4">
|
||||
<?php require '../app/layout/breadcrumb.php'; ?>
|
||||
<h1 class="text-xl font-semibold text-white-900 sm:text-2xl ">Resellers & Managers</h1>
|
||||
<p class="text-xs text-gray-500">Access your Reseller and Manager accounts. <a
|
||||
href="https://keyauthdocs.apidog.io/sellerapi/reseller-manager/create-new-reseller-manager" target="_blank"
|
||||
class="text-blue-600 hover:underline">Learn More</a>.</p>
|
||||
<br>
|
||||
<div class="p-4 flex flex-col">
|
||||
<div class="overflow-x-auto">
|
||||
<!-- Alert Box -->
|
||||
<div id="alert" class="flex items-center p-4 mb-4 text-yellow-800 rounded-lg bg-[#09090d]"
|
||||
role="alert">
|
||||
<svg class="flex-shrink-0 w-4 h-4" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"
|
||||
fill="currentColor" viewBox="0 0 20 20">
|
||||
<path
|
||||
d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5ZM9.5 4a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3ZM12 15H8a1 1 0 0 1 0-2h1v-3H8a1 1 0 0 1 0-2h2a1 1 0 0 1 1 1v4h1a1 1 0 0 1 0 2Z" />
|
||||
</svg>
|
||||
<span class="sr-only">Info</span>
|
||||
<div class="ml-3 text-sm font-medium text-yellow-500">
|
||||
The balance is in Days|Weeks|Months|3Months|6Months|Lifetime|Years
|
||||
</div>
|
||||
</div>
|
||||
<!-- End Alert Box -->
|
||||
<!-- Subscripion Functions -->
|
||||
<button
|
||||
class="inline-flex text-white bg-blue-700 hover:opacity-60 focus:ring-0 font-medium rounded-lg text-sm px-5 py-2.5 mb-2 transition duration-200"
|
||||
data-modal-toggle="create-acc-modal" data-modal-target="create-acc-modal">
|
||||
<i class="lni lni-circle-plus mr-2 mt-1"></i>Create Account
|
||||
</button>
|
||||
<br>
|
||||
<button
|
||||
class="inline-flex text-white bg-red-700 hover:opacity-60 focus:ring-0 font-medium rounded-lg text-sm px-5 py-2.5 mb-2 transition duration-200"
|
||||
data-modal-toggle="delete-all-resellers-modal" data-modal-target="delete-all-resellers-modal">
|
||||
<i class="lni lni-trash-can mr-2 mt-1"></i>Delete All Resellers
|
||||
</button>
|
||||
|
||||
<button
|
||||
class="inline-flex text-white bg-red-700 hover:opacity-60 focus:ring-0 font-medium rounded-lg text-sm px-5 py-2.5 mb-2 transition duration-200"
|
||||
data-modal-toggle="delete-all-managers-modal" data-modal-target="delete-all-managers-modal">
|
||||
<i class="lni lni-trash-can mr-2 mt-1"></i>Delete All Managers
|
||||
</button>
|
||||
<!-- End Subscription Functions -->
|
||||
|
||||
<!-- Create Acc Modal -->
|
||||
<div id="create-acc-modal" tabindex="-1" aria-hidden="true"
|
||||
class="fixed top-0 left-0 right-0 z-50 hidden w-full p-4 overflow-x-hidden overflow-y-auto md:inset-0 h-[calc(100%-1rem)] max-h-full">
|
||||
<div class="relative w-full max-w-md max-h-full">
|
||||
<!-- Modal content -->
|
||||
<div class="relative bg-[#0f0f17] rounded-lg border border-[#1d4ed8] shadow">
|
||||
<div class="px-6 py-6 lg:px-8">
|
||||
<h3 class="mb-4 text-xl font-medium text-white-900">Create Reseller or Manager
|
||||
Account</h3>
|
||||
<hr class="h-px mb-4 mt-4 bg-gray-700 border-0">
|
||||
<form class="space-y-6" method="POST">
|
||||
<div>
|
||||
<div class="relative mb-4">
|
||||
<select id="role" name="role"
|
||||
class="bg-[#0f0f17] border border-gray-700 text-white-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5"
|
||||
onchange="handleSelectChange(this.value)">
|
||||
<option value="Reseller">
|
||||
Reseller
|
||||
</option>
|
||||
<option value="Manager">
|
||||
Manager
|
||||
</option>
|
||||
</select>
|
||||
<label for="role"
|
||||
class="absolute text-sm text-gray-400 duration-300 transform -translate-y-4 scale-75 top-2 z-10 origin-[0] bg-[#0f0f17] px-2 peer-focus:px-2 peer-focus:text-blue-600 peer-placeholder-shown:scale-100 peer-placeholder-shown:-translate-y-1/2 peer-placeholder-shown:top-1/2 peer-focus:top-2 peer-focus:scale-75 peer-focus:-translate-y-4 left-1">Account
|
||||
Type</label>
|
||||
</div>
|
||||
|
||||
<div class="relative mb-4">
|
||||
<select id="app" name="app"
|
||||
class="bg-[#0f0f17] border border-gray-700 text-white-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5">
|
||||
<?php
|
||||
$query = misc\mysql\query("SELECT * FROM `apps` WHERE `owner` = ? AND `ownerid` = ?",[$_SESSION['username'], $_SESSION['ownerid']]);
|
||||
if ($query->num_rows > 0) {
|
||||
while ($row = mysqli_fetch_array($query->result)) {
|
||||
echo " <option value=\"" . $row["name"] . "\">" . $row["name"] . "</option>";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
</select>
|
||||
<label for="app"
|
||||
class="absolute text-sm text-gray-400 duration-300 transform -translate-y-4 scale-75 top-2 z-10 origin-[0] bg-[#0f0f17] px-2 peer-focus:px-2 peer-focus:text-blue-600 peer-placeholder-shown:scale-100 peer-placeholder-shown:-translate-y-1/2 peer-placeholder-shown:top-1/2 peer-focus:top-2 peer-focus:scale-75 peer-focus:-translate-y-4 left-1">Assigned
|
||||
Application</label>
|
||||
</div>
|
||||
|
||||
<div class="relative mb-4">
|
||||
<input type="text" id="username" name="username"
|
||||
class="block px-2.5 pb-2.5 pt-4 w-full text-sm text-white bg-transparent rounded-lg border-1 border-gray-700 appearance-none focus:ring-0 peer"
|
||||
placeholder="" autocomplete="on" required>
|
||||
<label for="username"
|
||||
class="absolute text-sm text-gray-400 duration-300 transform -translate-y-4 scale-75 top-2 z-10 origin-[0] bg-[#0f0f17] px-2 peer-focus:px-2 peer-focus:text-blue-600 peer-placeholder-shown:scale-100 peer-placeholder-shown:-translate-y-1/2 peer-placeholder-shown:top-1/2 peer-focus:top-2 peer-focus:scale-75 peer-focus:-translate-y-4 left-1">Assign
|
||||
Username</label>
|
||||
</div>
|
||||
|
||||
<div class="relative mb-4">
|
||||
<input type="email" id="email" name="email"
|
||||
class="block px-2.5 pb-2.5 pt-4 w-full text-sm text-white bg-transparent rounded-lg border-1 border-gray-700 appearance-none focus:ring-0 peer"
|
||||
placeholder="" autocomplete="on" required>
|
||||
<label for="email"
|
||||
class="absolute text-sm text-gray-400 duration-300 transform -translate-y-4 scale-75 top-2 z-10 origin-[0] bg-[#0f0f17] px-2 peer-focus:px-2 peer-focus:text-blue-600 peer-placeholder-shown:scale-100 peer-placeholder-shown:-translate-y-1/2 peer-placeholder-shown:top-1/2 peer-focus:top-2 peer-focus:scale-75 peer-focus:-translate-y-4 left-1">Assign
|
||||
Email</label>
|
||||
</div>
|
||||
|
||||
<div class="relative mb-4">
|
||||
<input type="password" id="pw" name="pw"
|
||||
class="block px-2.5 pb-2.5 pt-4 w-full text-sm text-white bg-transparent rounded-lg border-1 border-gray-700 appearance-none focus:ring-0 peer"
|
||||
placeholder="" autocomplete="on" required>
|
||||
<label for="pw"
|
||||
class="absolute text-sm text-gray-400 duration-300 transform -translate-y-4 scale-75 top-2 z-10 origin-[0] bg-[#0f0f17] px-2 peer-focus:px-2 peer-focus:text-blue-600 peer-placeholder-shown:scale-100 peer-placeholder-shown:-translate-y-1/2 peer-placeholder-shown:top-1/2 peer-focus:top-2 peer-focus:scale-75 peer-focus:-translate-y-4 left-1">Assign
|
||||
Password</label>
|
||||
</div>
|
||||
|
||||
<div class="relative mb-4">
|
||||
<input type="text" id="keylevels" name="keylevels"
|
||||
class="block px-2.5 pb-2.5 pt-4 w-full text-sm text-white bg-transparent rounded-lg border-1 border-gray-700 appearance-none focus:ring-0 peer"
|
||||
placeholder=" " autocomplete="on">
|
||||
<label for="keylevels"
|
||||
class="absolute text-sm text-gray-400 duration-300 transform -translate-y-4 scale-75 top-2 z-10 origin-[0] bg-[#0f0f17] px-2 peer-focus:px-2 peer-focus:text-blue-600 peer-placeholder-shown:scale-100 peer-placeholder-shown:-translate-y-1/2 peer-placeholder-shown:top-1/2 peer-focus:top-2 peer-focus:scale-75 peer-focus:-translate-y-4 left-1">Assign
|
||||
License Levels</label>
|
||||
</div>
|
||||
|
||||
<div id="permDiv" hidden>
|
||||
<h3 class="mb-4 text-xl font-medium text-white-900">What pages can this
|
||||
Manager access?</h3>
|
||||
<div class="grid grid-cols-3 gap-4">
|
||||
<div class="flex items-center">
|
||||
<input id="licenses" name="licenses" type="checkbox"
|
||||
class="w-4 h-4 text-blue-600 bg-[#0f0f17] border-gray-300 rounded focus:ring-blue-500 focus:ring-2">
|
||||
<label for="licenses"
|
||||
class="ml-2 text-sm font-medium text-white-900">Licenses</label>
|
||||
</div>
|
||||
<div class="flex items-center">
|
||||
<input id="users" name="users" type="checkbox"
|
||||
class="w-4 h-4 text-blue-600 bg-[#0f0f17] border-gray-300 rounded focus:ring-blue-500 focus:ring-2">
|
||||
<label for="users"
|
||||
class="ml-2 text-sm font-medium text-white-900">Users</label>
|
||||
</div>
|
||||
<div class="flex items-center">
|
||||
<input id="tokens" name="tokens" type="checkbox"
|
||||
class="w-4 h-4 text-blue-600 bg-[#0f0f17] border-gray-300 rounded focus:ring-blue-500 focus:ring-2">
|
||||
<label for="tokens"
|
||||
class="ml-2 text-sm font-medium text-white-900">Tokens</label>
|
||||
</div>
|
||||
<div class="flex items-center">
|
||||
<input id="subscriptions" name="subscriptions" type="checkbox"
|
||||
class="w-4 h-4 text-blue-600 bg-[#0f0f17] border-gray-300 rounded focus:ring-blue-500 focus:ring-2">
|
||||
<label for="subscriptions"
|
||||
class="ml-2 text-sm font-medium text-white-900">Subscriptions</label>
|
||||
</div>
|
||||
<div class="flex items-center">
|
||||
<input id="chats" name="chats" type="checkbox"
|
||||
class="w-4 h-4 text-blue-600 bg-[#0f0f17] border-gray-300 rounded focus:ring-blue-500 focus:ring-2">
|
||||
<label for="chats"
|
||||
class="ml-2 text-sm font-medium text-white-900">Chats</label>
|
||||
</div>
|
||||
<div class="flex items-center">
|
||||
<input id="sessions" name="sessions" type="checkbox"
|
||||
class="w-4 h-4 text-blue-600 bg-[#0f0f17] border-gray-300 rounded focus:ring-blue-500 focus:ring-2">
|
||||
<label for="sessions"
|
||||
class="ml-2 text-sm font-medium text-white-900">Sessions</label>
|
||||
</div>
|
||||
<div class="flex items-center">
|
||||
<input id="files" name="files" type="checkbox"
|
||||
class="w-4 h-4 text-blue-600 bg-[#0f0f17] border-gray-300 rounded focus:ring-blue-500 focus:ring-2">
|
||||
<label for="files"
|
||||
class="ml-2 text-sm font-medium text-white-900">Files</label>
|
||||
</div>
|
||||
<div class="flex items-center">
|
||||
<input id="vars" name="vars" type="checkbox"
|
||||
class="w-4 h-4 text-blue-600 bg-[#0f0f17] border-gray-300 rounded focus:ring-blue-500 focus:ring-2">
|
||||
<label for="vars"
|
||||
class="ml-2 text-sm font-medium text-white-900">Variables</label>
|
||||
</div>
|
||||
<div class="flex items-center">
|
||||
<input id="logs" name="logs" type="checkbox"
|
||||
class="w-4 h-4 text-blue-600 bg-[#0f0f17] border-gray-300 rounded focus:ring-blue-500 focus:ring-2">
|
||||
<label for="logs"
|
||||
class="ml-2 text-sm font-medium text-white-900">Logs</label>
|
||||
</div>
|
||||
<div class="flex items-center">
|
||||
<input id="blacklists" name="blacklists" type="checkbox"
|
||||
class="w-4 h-4 text-blue-600 bg-[#0f0f17] border-gray-300 rounded focus:ring-blue-500 focus:ring-2">
|
||||
<label for="blacklists"
|
||||
class="ml-2 text-sm font-medium text-white-900">Blacklists</label>
|
||||
</div>
|
||||
<div class="flex items-center">
|
||||
<input id="whitelists" name="whitelists" type="checkbox"
|
||||
class="w-4 h-4 text-blue-600 bg-[#0f0f17] border-gray-300 rounded focus:ring-blue-500 focus:ring-2">
|
||||
<label for="whitelists"
|
||||
class="ml-2 text-sm font-medium text-white-900">Whitelists</label>
|
||||
</div>
|
||||
<div class="flex items-center">
|
||||
<input id="appSettings" name="appSettings" type="checkbox"
|
||||
class="w-4 h-4 text-blue-600 bg-[#0f0f17] border-gray-300 rounded focus:ring-blue-500 focus:ring-2">
|
||||
<label for="appSettings"
|
||||
class="ml-2 text-sm font-medium text-white-900">App
|
||||
Settings</label>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="permissionsLabel" class="mt-4 text-white-900 mb-2">Permissions
|
||||
Code For Seller API:
|
||||
<a class="mt-4 text-blue-900">0</a>
|
||||
</div>
|
||||
</div>
|
||||
<button name="createacc"
|
||||
class="w-full text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center">Create
|
||||
Account</button>
|
||||
<input type="hidden" id="permissions" name="permissions" value="2047">
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- End Create Reseller/Manager Modal -->
|
||||
|
||||
<!-- Delete All Resellers Modal -->
|
||||
<div id="delete-all-resellers-modal" tabindex="-1"
|
||||
class="fixed top-0 left-0 right-0 z-50 hidden p-4 overflow-x-hidden overflow-y-auto md:inset-0 h-[calc(100%-1rem)] max-h-full">
|
||||
<div class="relative w-full max-w-md max-h-full">
|
||||
<div class="relative bg-[#0f0f17] border border-red-700 rounded-lg shadow">
|
||||
<div class="p-6 text-center">
|
||||
<div class="flex items-center p-4 mb-4 text-sm text-white border border-yellow-500 rounded-lg bg-[#0f0f17]"
|
||||
role="alert">
|
||||
<span class="sr-only">Info</span>
|
||||
<div>
|
||||
<span class="font-medium">Notice!</span> You're about to delete all of your
|
||||
resellers! This can not be undone!
|
||||
</b>
|
||||
</div>
|
||||
</div>
|
||||
<h3 class="mb-5 text-lg font-normal text-gray-200">Are you sure you want to delete
|
||||
all of your resellers?</h3>
|
||||
<form method="POST">
|
||||
<button data-modal-hide="delete-all-resellers-modal" name="deleteresellers"
|
||||
class="text-white bg-red-600 hover:bg-red-800 focus:ring-4 focus:outline-none focus:ring-red-300 font-medium rounded-lg text-sm inline-flex items-center px-5 py-2.5 text-center mr-2">
|
||||
Yes, I'm sure
|
||||
</button>
|
||||
<button data-modal-hide="delete-all-resellers-modal" type="button"
|
||||
class="inline-flex text-white bg-gray-700 hover:opacity-60 focus:ring-0 font-medium rounded-lg text-sm px-5 py-2.5 mb-2 transition duration-200">No,
|
||||
cancel</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- End Delete All Resellers Modal -->
|
||||
|
||||
<!-- Delete All Managers Modal -->
|
||||
<div id="delete-all-managers-modal" tabindex="-1"
|
||||
class="fixed top-0 left-0 right-0 z-50 hidden p-4 overflow-x-hidden overflow-y-auto md:inset-0 h-[calc(100%-1rem)] max-h-full">
|
||||
<div class="relative w-full max-w-md max-h-full">
|
||||
<div class="relative bg-[#0f0f17] border border-red-700 rounded-lg shadow">
|
||||
<div class="p-6 text-center">
|
||||
<div class="flex items-center p-4 mb-4 text-sm text-white border border-yellow-500 rounded-lg bg-[#0f0f17]"
|
||||
role="alert">
|
||||
<span class="sr-only">Info</span>
|
||||
<div>
|
||||
<span class="font-medium">Notice!</span> You're about to delete all of your
|
||||
managers! This can not be undone!
|
||||
</b>
|
||||
</div>
|
||||
</div>
|
||||
<h3 class="mb-5 text-lg font-normal text-gray-200">Are you sure you want to delete
|
||||
all of your managers?</h3>
|
||||
<form method="POST">
|
||||
<button data-modal-hide="delete-all-managers-modal" name="deletemanagers"
|
||||
class="text-white bg-red-600 hover:bg-red-800 focus:ring-4 focus:outline-none focus:ring-red-300 font-medium rounded-lg text-sm inline-flex items-center px-5 py-2.5 text-center mr-2">
|
||||
Yes, I'm sure
|
||||
</button>
|
||||
<button data-modal-hide="delete-all-managers-modal" type="button"
|
||||
class="inline-flex text-white bg-gray-700 hover:opacity-60 focus:ring-0 font-medium rounded-lg text-sm px-5 py-2.5 mb-2 transition duration-200">No,
|
||||
cancel</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- End Delete All Managers Modal -->
|
||||
|
||||
|
||||
<!-- START TABLE -->
|
||||
<div class="relative overflow-x-auto shadow-md sm:rounded-lg pt-5">
|
||||
<table id="kt_datatable_manageaccs" class="w-full text-sm text-left text-white">
|
||||
<thead>
|
||||
<tr class="fw-bolder fs-6 text-blue-700 px-7">
|
||||
<th class="px-6 py-3">Username</th>
|
||||
<th class="px-6 py-3">Role</th>
|
||||
<th class="px-6 py-3">Application</th>
|
||||
<th class="px-6 py-3">Balance</th>
|
||||
<th class="px-6 py-3">Allowed Levels</th>
|
||||
<th class="px-6 py-3">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$query = misc\mysql\query("SELECT * FROM `accounts` WHERE `owner` = ?", [$_SESSION['username']]);
|
||||
if ($query->num_rows > 0){
|
||||
while ($row = mysqli_fetch_array($query->result)){
|
||||
echo "<tr>";
|
||||
echo "<td>" . $row["username"] . "</td>";
|
||||
echo "<td>" . $row["role"] . "</td>";
|
||||
echo "<td>" . $row["app"] . "</td>";
|
||||
|
||||
if ($row["roles"] == "Manager"){
|
||||
echo "<td>N/A</td>";
|
||||
} else {
|
||||
echo "<td>" . $row["balance"] . "</td>";
|
||||
}
|
||||
echo "<td>" . $row["keylevels"] . "</td>";
|
||||
|
||||
echo '<form method="POST">
|
||||
<td>
|
||||
<div x-data="{ open: false }" class="z-0">
|
||||
<button x-on:click="open = true" class="flex items-center border border-gray-700 rounded-lg focus:opacity-60 text-white focus:text-white font-semibold rounded focus:outline-none focus:shadow-inner py-2 px-4" type="button">
|
||||
<span class="mr-1">Actions</span>
|
||||
<svg class="fill-current h-4 w-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" style="margin-top:3px">
|
||||
<path d="M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z"/>
|
||||
</svg>
|
||||
</button>
|
||||
<ul x-show="open" x-on:click.away="open = false" class="bg-[#09090d] text-white rounded shadow-lg absolute py-2 mt-1" style="min-width:15rem">
|
||||
<li>
|
||||
<button name="deleteacc" class="block hover:opacity-60 whitespace-no-wrap py-2 px-4 hover:text-red-700"
|
||||
value="' . $row['username'] . '">
|
||||
Delete Account
|
||||
</button>
|
||||
</li>
|
||||
<li>
|
||||
<button name="deleteacckeys" class="block hover:opacity-60 whitespace-no-wrap py-2 px-4 hover:text-red-700"
|
||||
value="' . $row['username'] . '">
|
||||
Delete Their Created Keys
|
||||
</button>
|
||||
</li>
|
||||
<li>
|
||||
<button name="deleteaccusers" class="block hover:opacity-60 whitespace-no-wrap py-2 px-4 hover:text-red-700"
|
||||
value="' . $row['username'] . '">
|
||||
Delete Their Created Users
|
||||
</button>
|
||||
</li>
|
||||
<li>
|
||||
<button name="editacc" class="block hover:opacity-60 whitespace-no-wrap py-2 px-4 hover:text-blue-700"
|
||||
value="' . $row['username'] . '">
|
||||
Edit Account
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</td></tr></form>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<p class="text-xs text-red-600">Dropdown actions in <b>RED</b> do not show a confirmation!<a
|
||||
class="text-blue-700"> Dropdown actions in <b>BLUE</b> will show a confirmation!</a></p>
|
||||
|
||||
<!-- Include the jQuery library -->
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
function handleSelectChange(value) {
|
||||
let element = document.getElementById("permDiv");
|
||||
if (value == "Manager") {
|
||||
element.removeAttribute("hidden");
|
||||
} else {
|
||||
element.setAttribute("hidden", "hidden");
|
||||
}
|
||||
}
|
||||
// credits https://discordapi.com/permissions.html
|
||||
var perms = {
|
||||
licenses: 1,
|
||||
users: 2,
|
||||
subscriptions: 4,
|
||||
chats: 8,
|
||||
sessions: 16,
|
||||
webhooks: 32,
|
||||
files: 64,
|
||||
vars: 128,
|
||||
logs: 256,
|
||||
blacklists: 512,
|
||||
appSettings: 1024,
|
||||
tokens: 2048,
|
||||
whitelists: 4096
|
||||
}
|
||||
|
||||
// Function to recalculate and update permissions
|
||||
function recalculate() {
|
||||
var totalPermissions = 0;
|
||||
|
||||
for (var s in perms) {
|
||||
var checkbox = document.getElementById(s);
|
||||
if (checkbox && checkbox.checked) {
|
||||
totalPermissions += perms[s];
|
||||
}
|
||||
}
|
||||
|
||||
// Update the label with the calculated totalPermissions
|
||||
var permissionsLabel = document.getElementById("permissionsLabel");
|
||||
if (permissionsLabel) {
|
||||
permissionsLabel.textContent = "Permissions Code For Seller API: " + totalPermissions;
|
||||
}
|
||||
// Update other elements as needed
|
||||
document.getElementById("permissions").value = totalPermissions;
|
||||
document.getElementById("permissionsSeller").textContent = totalPermissions;
|
||||
console.log(totalPermissions);
|
||||
}
|
||||
|
||||
// Add event listeners to all checkboxes
|
||||
var checkboxes = document.querySelectorAll('input[type="checkbox"]');
|
||||
checkboxes.forEach(function(checkbox) {
|
||||
checkbox.addEventListener('change', recalculate);
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user