datein hinzufügen
This commit is contained in:
7
panel/.htaccess
Normal file
7
panel/.htaccess
Normal file
@@ -0,0 +1,7 @@
|
||||
RewriteEngine On
|
||||
|
||||
#.htaccess - route all requests through index.php
|
||||
RewriteCond %{REQUEST_URI} !\.(png|jpe?g|gif|css|js|html)$ [NC]
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteRule ^.*$ index.php [L]
|
||||
92
panel/dashboard/index.php
Normal file
92
panel/dashboard/index.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
require '../../includes/misc/autoload.phtml';
|
||||
require '../../includes/dashboard/autoload.phtml';
|
||||
|
||||
if (session_status() === PHP_SESSION_NONE) {
|
||||
session_start();
|
||||
}
|
||||
|
||||
if (!isset($_SESSION['un'])) {
|
||||
die("Not logged in");
|
||||
}
|
||||
|
||||
set_exception_handler(function ($exception) {
|
||||
error_log("\n--------------------------------------------------------------\n");
|
||||
error_log($exception);
|
||||
error_log("\nRequest data:");
|
||||
error_log(print_r($_POST, true));
|
||||
error_log("\n--------------------------------------------------------------");
|
||||
http_response_code(500);
|
||||
global $databaseUsername;
|
||||
$errorMsg = str_replace($databaseUsername, "REDACTED", $exception->getMessage());
|
||||
\dashboard\primary\error($errorMsg);
|
||||
});
|
||||
|
||||
$query = misc\mysql\query("SELECT `name`, `download`, `webdownload`, `cooldown`, `customerPanelIcon` FROM `apps` WHERE `secret` = ?", [$_SESSION['panelapp']]);
|
||||
$row = mysqli_fetch_array($query->result);
|
||||
|
||||
$name = $row["name"];
|
||||
$download = $row["download"];
|
||||
$webdownload = $row["webdownload"];
|
||||
$appcooldown = $row["cooldown"];
|
||||
$customerPanelIcon = $row["customerPanelIcon"];
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" class="bg-[#09090d] text-white overflow-x-hidden dark">
|
||||
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<link rel="stylesheet" href="https://cdn.keyauth.cc/v3/github-dark.min.css">
|
||||
<script src="https://cdn.keyauth.cc/v3/highlight.min.js"></script>
|
||||
<script src="https://cdn.keyauth.cc/dashboard/unixtolocal.js"></script>
|
||||
|
||||
<link href="https://cdn.lineicons.com/4.0/lineicons.css" rel="stylesheet" />
|
||||
<link rel="shortcut icon" href="<?= $customerPanelIcon ?>" />
|
||||
<title><?= $name; ?> Panel</title>
|
||||
|
||||
<script>
|
||||
if (window.history.replaceState) {
|
||||
window.history.replaceState(null, null, window.location.href);
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#loader {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100vh;
|
||||
background-color: black;
|
||||
/* Black background color for the loader */
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
z-index: 9999;
|
||||
}
|
||||
</style>
|
||||
|
||||
<link rel="stylesheet" href="https://unpkg.com/flowbite@1.8.1/dist/flowbite.min.css" />
|
||||
<link rel="stylesheet"
|
||||
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0" />
|
||||
<script src="https://cdn.tailwindcss.com/3.3.3"></script>
|
||||
|
||||
<script src="https://unpkg.com/flowbite@1.8.1/dist/flowbite.js"></script>
|
||||
|
||||
<link href="https://cdn.lineicons.com/4.0/lineicons.css" rel="stylesheet" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<?php include 'layout/master.php' ?>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
20
panel/dashboard/layout/customeraside.php
Normal file
20
panel/dashboard/layout/customeraside.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<style>
|
||||
/* Hide vertical scrollbar for Webkit-based browsers (e.g., Chrome, Safari) */
|
||||
*::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
|
||||
<aside id="sidebar"
|
||||
class="flex hidden fixed top-0 left-0 z-20 flex-col flex-shrink-0 pt-16 w-64 h-full duration-200 lg:flex transition-width"
|
||||
aria-label="Sidebar">
|
||||
<div class="flex relative flex-col flex-1 pt-0 min-h-0 bg-[#0f0f17] border-r border-[#0f0f17]">
|
||||
<div class="flex overflow-y-auto flex-col flex-1 pt-5 pb-4">
|
||||
<div class="flex-1 px-3 space-y-1 bg-[#0f0f17]">
|
||||
<div class="mb-4 border-b border-[#0f0f17]">
|
||||
<?php require '../dashboard/layout/profile.php';?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
41
panel/dashboard/layout/master.php
Normal file
41
panel/dashboard/layout/master.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
$page = isset($_GET['page']) ? $_GET['page'] : "customer-actions";
|
||||
require '../../app/layout/topbar.php';
|
||||
?>
|
||||
|
||||
<div class="flex overflow-hidden pt-16 bg-[#09090d]">
|
||||
|
||||
<?php
|
||||
include '/var/www/vhosts/tbs-server.de/lizenz.tbs-server.de/panel/dashboard/layout/customeraside.php';
|
||||
?>
|
||||
|
||||
<div class="hidden fixed inset-0 z-10" id="sidebarBackdrop"></div>
|
||||
|
||||
<div id="main-content" class="overflow-y-auto relative w-full h-full lg:ml-64">
|
||||
<main>
|
||||
<?php
|
||||
try {
|
||||
if (str_contains($page, ".")) {
|
||||
throw new ErrorException('');
|
||||
}
|
||||
else {
|
||||
$filePath = __DIR__ . "/../pages/{$page}.php";
|
||||
|
||||
if (file_exists($filePath)) {
|
||||
require $filePath;
|
||||
}
|
||||
else {
|
||||
throw new ErrorException('');
|
||||
}
|
||||
}
|
||||
} catch (ErrorException $ex) {
|
||||
require '../../404_error.html';
|
||||
}
|
||||
?>
|
||||
</main>
|
||||
|
||||
<?php
|
||||
require '../../app/layout/footer.php';
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
48
panel/dashboard/layout/profile.php
Normal file
48
panel/dashboard/layout/profile.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<script src="https://cdn.keyauth.cc/dashboard/unixtolocal.js"></script>
|
||||
|
||||
<div class="w-full max-w-sm border border-gray-700 rounded-lg shadow">
|
||||
<div class="flex justify-end px-4 pt-2">
|
||||
<button id="dropdownButton" data-dropdown-toggle="dropdown"
|
||||
class="inline-block text-gray-500 hover:opacity-60 focus:ring-0 p-1.5" type="button">
|
||||
<span class="sr-only">Open dropdown</span>
|
||||
<svg class="w-5 h-5" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor"
|
||||
viewBox="0 0 16 3">
|
||||
<path
|
||||
d="M2 0a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3Zm6.041 0a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3ZM14 0a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3Z" />
|
||||
</svg>
|
||||
</button>
|
||||
<!-- Dropdown menu -->
|
||||
<form method="post">
|
||||
<div id="dropdown" class="z-10 hidden text-base list-none bg-[#09090d] rounded-lg shadow w-44">
|
||||
<ul class="py-2" aria-labelledby="dropdownButton">
|
||||
<li>
|
||||
<a href="?page=logout" class="block px-4 py-2 text-sm text-white hover:bg-blue-700">Log Out</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="flex flex-col items-center pb-4">
|
||||
<?php
|
||||
$query = misc\mysql\query("SELECT * FROM `subs` WHERE `app` = ? AND `user` = ? AND `expiry` > ? LIMIT 1", [$_SESSION['panelapp'], $_SESSION['un'], time()]);
|
||||
$row = mysqli_fetch_array($query->result);
|
||||
$subName = $row["subscription"];
|
||||
$subExpiry = $row["expiry"];
|
||||
?>
|
||||
<h5 class="mb-1 text-xl font-medium text-blue-700 stars"><?= $_SESSION["un"]; ?></h5>
|
||||
|
||||
<?php
|
||||
$cssClasses = "text-transparent bg-clip-text bg-gradient-to-r to-blue-600 from-sky-400 text-xs font-black mr-2 px-1.5 py-0.5 rounded border mb-2 mt-2";
|
||||
$cssClasses .= " border-white-400";
|
||||
|
||||
// Finally, output the HTML with the calculated classes
|
||||
echo "<p class=\"$cssClasses\">" . $subName . "</p>";
|
||||
|
||||
?>
|
||||
<label class="text-sm text-gray-400"><b>Expires:</b>
|
||||
<script>
|
||||
document.write(convertTimestamp(<?= $subExpiry; ?>));
|
||||
</script>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
214
panel/dashboard/pages/customer-actions.php
Normal file
214
panel/dashboard/pages/customer-actions.php
Normal file
@@ -0,0 +1,214 @@
|
||||
<?php
|
||||
if (isset($_POST['resethwid'])) {
|
||||
$today = time();
|
||||
$cooldown = $today + $appcooldown;
|
||||
|
||||
misc\mysql\query("UPDATE `users` SET `hwid` = NULL, `cooldown` = ? WHERE `app` = ? AND `username` = ?", [$cooldown, $_SESSION['panelapp'], $_SESSION['un']]);
|
||||
|
||||
dashboard\primary\success("Reset HWID!");
|
||||
misc\cache\purge('KeyAuthUser:' . $_SESSION['panelapp'] . ':' . $_SESSION['un']);
|
||||
echo "<meta http-equiv='Refresh' Content='2;'>";
|
||||
}
|
||||
if (isset($_POST['saveUser'])) {
|
||||
if (!empty($_POST['username'])) {
|
||||
$resp = misc\user\changeUsername($_SESSION['un'], $_POST['username'], $_SESSION['panelapp']);
|
||||
match($resp){
|
||||
'already_used' => dashboard\primary\error("Username already used!"),
|
||||
'failure' => dashboard\primary\error("Failed to change username!"),
|
||||
'success' => dashboard\primary\success("Successfully changed username!"),
|
||||
default => dashboard\primary\error("Unhandled Error! Contact us if you need help")
|
||||
};
|
||||
}
|
||||
if (!empty($_POST['password'])) {
|
||||
$resp = misc\user\changePassword($_SESSION['un'], $_POST['password'], $_SESSION['panelapp']);
|
||||
match($resp){
|
||||
'failure' => dashboard\primary\error("Failed to change password!"),
|
||||
'success' => dashboard\primary\success("Successfully changed password!"),
|
||||
default => dashboard\primary\error("Unhandled Error! Contact us if you need help")
|
||||
};
|
||||
}
|
||||
if (empty($_POST['username']) && empty($_POST['password'])) {
|
||||
dashboard\primary\error("You must enter new username or password!");
|
||||
}
|
||||
}
|
||||
?>
|
||||
<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">
|
||||
<h1 class="text-xl font-semibold text-white-900 sm:text-2xl">Customer Actions</h1>
|
||||
<p class="text-xs text-gray-500">View and Modify your account on <?= ucwords($page); ?></p>
|
||||
<div class="pt-5">
|
||||
<form method="POST">
|
||||
<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-border-gray-300 appearance-none focus:ring-0 peer"
|
||||
placeholder=" " autocomplete="on">
|
||||
<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">New
|
||||
Username:</label>
|
||||
</div>
|
||||
<div class="relative">
|
||||
<input type="password" id="password" name="password"
|
||||
class="block px-2.5 pb-2.5 pt-4 w-full text-sm text-white bg-transparent rounded-lg border-1 border-border-gray-300 appearance-none focus:ring-0 peer"
|
||||
placeholder=" " autocomplete="on">
|
||||
<label for="password"
|
||||
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>
|
||||
<button name="saveUser"
|
||||
class="text-white border-2 hover:bg-white hover:text-black focus:ring-0 focus:outline-none transition duration-200 font-medium rounded-lg text-sm px-5 py-2.5 text-center items-center mb-3 w-full mt-5">
|
||||
<span class="inline-flex">
|
||||
Update Changes
|
||||
<svg class="w-3.5 h-3.5 ml-2 mt-1" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"
|
||||
fill="none" viewBox="0 0 14 10">
|
||||
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"
|
||||
stroke-width="2" d="M1 5h12m0 0L9 1m4 4L9 9"></path>
|
||||
</svg></span>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bg-[#09090d] block sm:flex items-center justify-between lg:mt-5">
|
||||
<div class="mb-1 w-full bg-[#0f0f17] mt-4 md:mt-2 rounded-xl">
|
||||
<div class="mb-4 p-4">
|
||||
<h1 class="text-xl font-semibold text-white-900 sm:text-2xl">HWID Reset</h1>
|
||||
<p class="text-xs text-gray-500">Reset your hwid</p>
|
||||
<div class="pt-5">
|
||||
<?php
|
||||
$query = misc\mysql\query("SELECT * FROM `users` WHERE `app` = ? AND `username` = ?", [$_SESSION['panelapp'], $_SESSION['un']]);
|
||||
$row = mysqli_fetch_array($query->result);
|
||||
$today = time();
|
||||
$cooldown = $row["cooldown"];
|
||||
|
||||
if (is_null($cooldown)){
|
||||
echo '<form method="post"><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"
|
||||
name="resethwid">
|
||||
<i class="lni lni-reload mr-2 mt-1"></i>Reset HWID
|
||||
</button></form>';
|
||||
} else {
|
||||
if ($today > $cooldown) {
|
||||
echo '<form method="post"><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"
|
||||
name="resethwid">
|
||||
<i class="lni lni-reload mr-2 mt-1"></i>Reset HWID
|
||||
</button></form>';
|
||||
} else {
|
||||
echo '<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">
|
||||
<i class="lni lni-reload mr-2 mt-1"></i>HWID cooldown until <script>document.write(convertTimestamp(' . $cooldown . '));</script>
|
||||
</button>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
if (!is_null($webdownload)) {
|
||||
$query = misc\mysql\query("SELECT `password` FROM `users` WHERE `username` = ? AND `app` = ?", [$_SESSION['un'], $_SESSION['panelapp']]);
|
||||
$row = mysqli_fetch_array($query->result);
|
||||
|
||||
$token = md5(substr($row["password"], -5));
|
||||
?>
|
||||
<div class="bg-[#09090d] block sm:flex items-center justify-between lg:mt-5">
|
||||
<div class="mb-1 w-full bg-[#0f0f17] mt-4 md:mt-2 rounded-xl">
|
||||
<div class="mb-4 p-4">
|
||||
<h1 class="text-xl font-semibold text-white-900 sm:text-2xl">Web Loader</h1>
|
||||
<p class="text-xs text-gray-500">Control your application from the website</p>
|
||||
<div class="pt-5" id="buttons">
|
||||
<?php
|
||||
$query = misc\mysql\query("SELECT * FROM `buttons` WHERE `app` = ?", [$_SESSION['panelapp']]);
|
||||
$rows = array();
|
||||
while ($r = mysqli_fetch_assoc($query->result)) {
|
||||
$rows[] = $r;
|
||||
}
|
||||
|
||||
foreach ($rows as $row) {
|
||||
?>
|
||||
<button
|
||||
class="inline-flex text-white bg-green-700 hover:opacity-60 focus:ring-0 font-medium rounded-lg text-sm px-5 py-2.5 mb-2 transition duration-200"
|
||||
onclick="doButton(this.value)"
|
||||
value="<?= $row['value']; ?>"><?= $row['text']; ?></button>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<a href="<?= $webdownload; ?>" class="text-blue-700">
|
||||
<button onclick="handshake()"
|
||||
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">
|
||||
<i class="lni lni-download mr-2 mt-1"></i>Download
|
||||
</button>
|
||||
</a>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<div class="bg-[#09090d] block sm:flex items-center justify-between lg:mt-5">
|
||||
<div class="mb-1 w-full bg-[#0f0f17] mt-4 md:mt-2 rounded-xl">
|
||||
<div class="mb-4 p-4">
|
||||
<h1 class="text-xl font-semibold text-white-900 sm:text-2xl">Stay Updated!
|
||||
</h1>
|
||||
<p class="text-xs text-gray-500">If there is a link visible, there is a new version
|
||||
of the app
|
||||
<?= $name; ?></p>
|
||||
<div class="pt-5">
|
||||
<?php
|
||||
if (!is_null($download)){ ?>
|
||||
<a href="<?= $download; ?>" class="text-blue-700" target="appdownload">
|
||||
<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">
|
||||
<i class="lni lni-download mr-2 mt-1"></i>Download new version of
|
||||
<?= $name; ?>
|
||||
</button>
|
||||
</a>
|
||||
<?php } else {?>
|
||||
<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">
|
||||
<i class="lni lni-checkmark mr-2 mt-1"></i>You're on the current version!
|
||||
</button>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var going = 1;
|
||||
|
||||
function handshake() {
|
||||
if (navigator.userAgent.includes("Chrome/98")) {
|
||||
going = 0;
|
||||
alert(
|
||||
"Currently Chrome 98 does not work with the web loader. Please use an older chrome version such as Chrome 97 or use another browser such as Firefox"
|
||||
);
|
||||
}
|
||||
setTimeout(function() {
|
||||
var xmlHttp = new XMLHttpRequest();
|
||||
xmlHttp.open("GET",
|
||||
"http://localhost:1337/handshake?user=<?= $_SESSION['un']; ?>&token=<?= $token; ?>"
|
||||
);
|
||||
xmlHttp.onload = function() {
|
||||
going = 0;
|
||||
switch (xmlHttp.status) {
|
||||
case 420:
|
||||
console.log("returned handshake :)");
|
||||
$("#handshake").fadeOut(100);
|
||||
$("#buttons").fadeIn(1900);
|
||||
break;
|
||||
default:
|
||||
alert(xmlHttp.statusText);
|
||||
break;
|
||||
}
|
||||
};
|
||||
xmlHttp.send();
|
||||
if (going == 1) {
|
||||
handshake();
|
||||
}
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
function doButton(value) {
|
||||
var xmlHttp = new XMLHttpRequest();
|
||||
xmlHttp.open("GET", "http://localhost:1337/" + value);
|
||||
xmlHttp.send();
|
||||
}
|
||||
</script>
|
||||
|
||||
<script src="https://cdn.keyauth.cc/dashboard/unixtolocal.js"></script>
|
||||
5
panel/dashboard/pages/customer-logout.php
Normal file
5
panel/dashboard/pages/customer-logout.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
session_start();
|
||||
echo "<meta http-equiv='Refresh' Content='0; url=../../../login/'>";
|
||||
session_destroy();
|
||||
exit();
|
||||
12
panel/dashboard/pages/logout.php
Normal file
12
panel/dashboard/pages/logout.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
if (session_status() === PHP_SESSION_NONE) {
|
||||
session_start();
|
||||
}
|
||||
unset($_SESSION['un']);
|
||||
unset($_SESSION['panelapp']);
|
||||
|
||||
$oldUrl = $_SESSION['oldUrlPanel'];
|
||||
if(isset($oldUrl))
|
||||
echo "<meta http-equiv='Refresh' Content='0; url=$oldUrl'>";
|
||||
else
|
||||
die('<br><p style="font-size:25px">Logged Out!</p>');
|
||||
206
panel/index.php
Normal file
206
panel/index.php
Normal file
@@ -0,0 +1,206 @@
|
||||
<?php
|
||||
ob_start();
|
||||
|
||||
require '../includes/misc/autoload.phtml';
|
||||
require '../includes/api/1.0/autoload.phtml';
|
||||
require '../includes/api/shared/autoload.phtml';
|
||||
require '../includes/dashboard/autoload.phtml';
|
||||
|
||||
if (session_status() === PHP_SESSION_NONE) {
|
||||
session_start();
|
||||
}
|
||||
|
||||
$_SESSION['oldUrlPanel'] = $_SERVER['REQUEST_URI'];
|
||||
|
||||
if (isset($_SESSION['un'])) {
|
||||
header("Location: ../dashboard/");
|
||||
exit();
|
||||
}
|
||||
|
||||
set_exception_handler(function ($exception) {
|
||||
error_log("\n--------------------------------------------------------------\n");
|
||||
error_log($exception);
|
||||
error_log("\nRequest data:");
|
||||
error_log(print_r($_POST, true));
|
||||
error_log("\n--------------------------------------------------------------");
|
||||
http_response_code(500);
|
||||
global $databaseUsername;
|
||||
$errorMsg = str_replace($databaseUsername, "REDACTED", $exception->getMessage());
|
||||
\dashboard\primary\error($errorMsg);
|
||||
});
|
||||
|
||||
$hostname = ($_SERVER['HTTP_HOST'] ?? $_SERVER['SERVER_NAME']);
|
||||
if ($hostname == "lizenz.tbs-server.de") { // custom domain
|
||||
|
||||
$requrl = $_SERVER['REQUEST_URI'];
|
||||
|
||||
$uri = trim($_SERVER['REQUEST_URI'], '/');
|
||||
$pieces = explode('/', $uri);
|
||||
$owner = urldecode(misc\etc\sanitize($pieces[1]));
|
||||
$name = urldecode(misc\etc\sanitize($pieces[2]));
|
||||
|
||||
if (substr_count($requrl, '/') >= 4) {
|
||||
header("location: https://lizenz.tbs-server.de/panel/{$owner}/{$name}");
|
||||
}
|
||||
|
||||
$query = misc\mysql\query("SELECT `secret`, `panelstatus`, `paused`, `owner`, `name`, `customerPanelIcon` FROM `apps` WHERE `name` = ? AND `owner` = ?", [$name, $owner]);
|
||||
} else {
|
||||
$query = misc\mysql\query("SELECT `secret`, `panelstatus`, `paused`, `owner`, `name`, `customerPanelIcon` FROM `apps` WHERE `customDomain` = ?",[$hostname]);
|
||||
}
|
||||
|
||||
if ($query->num_rows < 1) {
|
||||
die("Panel does not exist.");
|
||||
}
|
||||
|
||||
while ($row = mysqli_fetch_array($query->result)) {
|
||||
$secret = $row['secret'];
|
||||
$_SESSION['panelapp'] = $secret;
|
||||
$panelStatus = $row['panelstatus'];
|
||||
$paused = $row['paused'];
|
||||
$owner = $row['owner']; // in the cases where custom domain is used
|
||||
$name = $row['name']; // in the cases where custom domain is used
|
||||
$customerPanelIcon = $row['customerPanelIcon'];
|
||||
}
|
||||
|
||||
if (!$panelStatus) {
|
||||
die("Panel was disabled by the application owner");
|
||||
}
|
||||
|
||||
if($paused) {
|
||||
die("Program has been paused by the program developer, likely to undergo maintenance updates. Please wait until later.");
|
||||
}
|
||||
|
||||
|
||||
$query = misc\mysql\query("SELECT 1 FROM `accounts` WHERE `username` = ? AND `role` = 'seller'",[$owner]);
|
||||
|
||||
if ($query->num_rows < 1) {
|
||||
die("Tell the application owner they need to upgrade to seller to utilize customer panel!");
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" class="bg-[#09090d] text-white overflow-x-hidden">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<base href="">
|
||||
<title>Login to <?= $name; ?> panel</title>
|
||||
<link rel="shortcut icon" href="<?= $customerPanelIcon ?>" />
|
||||
<!--Custom Styles-->
|
||||
<link rel="stylesheet" type="text/css" href="https://cdn.keyauth.cc/v3/dist/output.css" />
|
||||
|
||||
<script>
|
||||
if (window.history.replaceState) {
|
||||
window.history.replaceState(null, null, window.location.href);
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!--Navbar-->
|
||||
<header>
|
||||
<nav class="border-gray-200 px-4 lg:px-6 py-2.5 mb-14">
|
||||
<div class="flex flex-wrap justify-between items-center mx-auto max-w-screen-xl">
|
||||
<a href="../" class="flex items-center">
|
||||
<img src="https://cdn.keyauth.cc/v2/assets/media/logos/logo-1-dark.png" class="mr-3 h-12 mt-2"
|
||||
alt="KeyAuth Logo" />
|
||||
</a>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<section>
|
||||
<div class="py-8 px-4 mx-auto max-w-screen-xl lg:py-16 grid lg:grid-cols-2 gap-8 lg:gap-16">
|
||||
<div class="flex flex-col justify-center">
|
||||
<h1
|
||||
class="mb-4 text-4xl font-extrabold tracking-tight leading-none text-white-900 md:text-5xl lg:text-6xl">
|
||||
<?= $name; ?> Customer Panel</h1>
|
||||
<p class="mb-6 text-lg font-normal text-gray-500 lg:text-xl">To access <a
|
||||
class="text-blue-600"><?= $name; ?> customer panel</a>,
|
||||
you must login, or register. This information is provided to you by the owner of the application. Do
|
||||
not contact KeyAuth support if
|
||||
you can not access the customer panel.
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<div class="w-full lg:max-w-xl p-6 space-y-8 sm:p-8 bg-[#09090d] rounded-lg shadow-xl">
|
||||
<form class="mt-8 space-y-6" method="post">
|
||||
<div class="relative">
|
||||
<input type="text" name="username"
|
||||
class="block px-2.5 pb-2.5 pt-4 w-full text-sm text-white-900 bg-transparent rounded-lg border-1 border-gray-700 appearance-none focus:outline-none focus:ring-0 focus:border-blue-600 peer"
|
||||
placeholder=" " autocomplete="on" required />
|
||||
<label for="username"
|
||||
class="absolute text-sm text-gray-500 duration-300 transform -translate-y-4 scale-75 top-2 z-10 origin-[0] bg-[#09090d] px-2 peer-focus:px-2 peer-focus:text-blue-600 peer-focus:text-blue-500 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">Username</label>
|
||||
</div>
|
||||
<div class="relative">
|
||||
<input type="password" name="password"
|
||||
class="block px-2.5 pb-2.5 pt-4 w-full text-sm text-white-900 bg-transparent rounded-lg border-1 border-gray-700 appearance-none focus:outline-none focus:ring-0 focus:border-blue-600 peer"
|
||||
placeholder=" " autocomplete="on" required />
|
||||
<label for="password"
|
||||
class="absolute text-sm text-gray-500 duration-300 transform -translate-y-4 scale-75 top-2 z-10 origin-[0] bg-[#09090d] px-2 peer-focus:px-2 peer-focus:text-blue-600 peer-focus:text-blue-500 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">Password</label>
|
||||
</div>
|
||||
<button name="login"
|
||||
class="w-full px-5 py-3 text-base font-medium text-center text-white bg-blue-700 rounded-lg hover:bg-blue-800 focus:ring-4 focus:ring-blue-300 sm:w-full">Login
|
||||
To <?= $name; ?> Customer Panel</button>
|
||||
<div class="text-sm font-medium text-white-900">
|
||||
New to the panel? <a href="../register/" class="text-blue-600 hover:underline">Register Now</a>.
|
||||
</div>
|
||||
<div class="text-sm font-medium text-white-900">
|
||||
Need to to upgrade your account? <a href="../upgrade/" class="text-blue-600 hover:underline">Upgrade
|
||||
Now</a>.
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!--Flowbite JS-->
|
||||
<script src="https://cdn.keyauth.cc/v3/dist/flowbite.js"></script>
|
||||
|
||||
<?php
|
||||
if (isset($_POST['login'])) {
|
||||
if (empty($_POST['username']) || empty($_POST['password'])) {
|
||||
dashboard\primary\error("You must fill in all the fields!");
|
||||
return;
|
||||
}
|
||||
|
||||
$un = misc\etc\sanitize($_POST['username']);
|
||||
$password = misc\etc\sanitize($_POST['password']);
|
||||
|
||||
$resp = api\v1_0\login($un, $password, NULL, $secret, 0);
|
||||
switch ($resp) {
|
||||
case 'un_not_found':
|
||||
dashboard\primary\error("User not found!");
|
||||
break;
|
||||
case 'pw_mismatch':
|
||||
dashboard\primary\error("Password is invalid!");
|
||||
break;
|
||||
case 'user_banned':
|
||||
if (strpos($userbanned, '{reason}') !== false) {
|
||||
$query = misc\mysql\query("SELECT `banned` FROM `users` WHERE `app` = ? AND `username` = ?", [$secret, $un]);
|
||||
$row = mysqli_fetch_array($query->result);
|
||||
$reason = $row['banned'];
|
||||
}
|
||||
dashboard\primary\error("Banned: Reason: " . misc\etc\sanitize($reason));
|
||||
break;
|
||||
case 'sub_paused':
|
||||
dashboard\primary\error("Your subscription is paused! Wait for the developer to unpause it");
|
||||
break;
|
||||
case 'no_active_subs':
|
||||
dashboard\primary\error("You have no active subscriptions! You you change this by clicking upgrade");
|
||||
break;
|
||||
default:
|
||||
$_SESSION['un'] = $un;
|
||||
header("location: ../dashboard/");
|
||||
break;
|
||||
}
|
||||
}
|
||||
?>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
148
panel/register/index.php
Normal file
148
panel/register/index.php
Normal file
@@ -0,0 +1,148 @@
|
||||
<?php
|
||||
require '../../includes/misc/autoload.phtml';
|
||||
|
||||
ob_start();
|
||||
|
||||
require '../../includes/dashboard/autoload.phtml';
|
||||
require '../../includes/api/1.0/autoload.phtml';
|
||||
require '../../includes/api/shared/autoload.phtml';
|
||||
|
||||
if (session_status() === PHP_SESSION_NONE) {
|
||||
session_start();
|
||||
}
|
||||
|
||||
if (!isset($_SESSION['panelapp'])) {
|
||||
die("You must go to your panel login first then visit this page");
|
||||
}
|
||||
|
||||
set_exception_handler(function ($exception) {
|
||||
error_log("\n--------------------------------------------------------------\n");
|
||||
error_log($exception);
|
||||
error_log("\nRequest data:");
|
||||
error_log(print_r($_POST, true));
|
||||
error_log("\n--------------------------------------------------------------");
|
||||
http_response_code(500);
|
||||
global $databaseUsername;
|
||||
$errorMsg = str_replace($databaseUsername, "REDACTED", $exception->getMessage());
|
||||
\dashboard\primary\error($errorMsg);
|
||||
});
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" class="bg-[#09090d] text-white overflow-x-hidden">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<base href="">
|
||||
<title>Register</title>
|
||||
<link rel="shortcut icon" href="<?= $customerPanelIcon ?>" />
|
||||
<!--Custom Styles-->
|
||||
<link rel="stylesheet" type="text/css" href="https://cdn.keyauth.cc/v3/dist/output.css" />
|
||||
|
||||
<script>
|
||||
if (window.history.replaceState) {
|
||||
window.history.replaceState(null, null, window.location.href);
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!--Navbar-->
|
||||
<header>
|
||||
<nav class="border-gray-200 px-4 lg:px-6 py-2.5 mb-14">
|
||||
<div class="flex flex-wrap justify-between items-center mx-auto max-w-screen-xl">
|
||||
<a href="../" class="flex items-center">
|
||||
<img src="https://cdn.keyauth.cc/v2/assets/media/logos/logo-1-dark.png" class="mr-3 h-12 mt-2"
|
||||
alt="KeyAuth Logo" />
|
||||
</a>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<section>
|
||||
<div class="py-8 px-4 mx-auto max-w-screen-xl lg:py-16 grid lg:grid-cols-2 gap-8 lg:gap-16">
|
||||
<div class="flex flex-col justify-center">
|
||||
<h1
|
||||
class="mb-4 text-4xl font-extrabold tracking-tight leading-none text-white-900 md:text-5xl lg:text-6xl">
|
||||
Register</h1>
|
||||
<p class="mb-6 text-lg font-normal text-gray-500 lg:text-xl">Please register an account for the panel you are trying to access.
|
||||
This page is <b>NOT</b> the KeyAuth register page. If you do not know how you got here, or if you were not given permission to access
|
||||
this panel, please exit the page now.
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<div class="w-full lg:max-w-xl p-6 space-y-8 sm:p-8 bg-[#09090d] rounded-lg shadow-xl">
|
||||
<form class="mt-8 space-y-6" method="post">
|
||||
<div class="relative">
|
||||
<input type="text" name="username"
|
||||
class="block px-2.5 pb-2.5 pt-4 w-full text-sm text-white-900 bg-transparent rounded-lg border-1 border-gray-700 appearance-none focus:outline-none focus:ring-0 focus:border-blue-600 peer"
|
||||
placeholder=" " autocomplete="on" required />
|
||||
<label for="username"
|
||||
class="absolute text-sm text-gray-500 duration-300 transform -translate-y-4 scale-75 top-2 z-10 origin-[0] bg-[#09090d] px-2 peer-focus:px-2 peer-focus:text-blue-600 peer-focus:text-blue-500 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">Username</label>
|
||||
</div>
|
||||
<div class="relative">
|
||||
<input type="password" name="password"
|
||||
class="block px-2.5 pb-2.5 pt-4 w-full text-sm text-white-900 bg-transparent rounded-lg border-1 border-gray-700 appearance-none focus:outline-none focus:ring-0 focus:border-blue-600 peer"
|
||||
placeholder=" " autocomplete="on" required />
|
||||
<label for="password"
|
||||
class="absolute text-sm text-gray-500 duration-300 transform -translate-y-4 scale-75 top-2 z-10 origin-[0] bg-[#09090d] px-2 peer-focus:px-2 peer-focus:text-blue-600 peer-focus:text-blue-500 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">Password</label>
|
||||
</div>
|
||||
<div class="relative">
|
||||
<input type="text" name="license"
|
||||
class="block px-2.5 pb-2.5 pt-4 w-full text-sm text-white-900 bg-transparent rounded-lg border-1 border-gray-700 appearance-none focus:outline-none focus:ring-0 focus:border-blue-600 peer"
|
||||
placeholder=" " autocomplete="on" required />
|
||||
<label for="license"
|
||||
class="absolute text-sm text-gray-500 duration-300 transform -translate-y-4 scale-75 top-2 z-10 origin-[0] bg-[#09090d] px-2 peer-focus:px-2 peer-focus:text-blue-600 peer-focus:text-blue-500 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">License</label>
|
||||
</div>
|
||||
<button name="register"
|
||||
class="w-full px-5 py-3 text-base font-medium text-center text-white bg-blue-700 rounded-lg hover:bg-blue-800 focus:ring-4 focus:ring-blue-300 sm:w-full">Register
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!--Flowbite JS-->
|
||||
<script src="https://cdn.keyauth.cc/v3/dist/flowbite.js"></script>
|
||||
|
||||
<?php
|
||||
if (isset($_POST['register'])) {
|
||||
$username = misc\etc\sanitize($_POST['username']);
|
||||
$password = misc\etc\sanitize($_POST['password']);
|
||||
$license = misc\etc\sanitize($_POST['license']);
|
||||
|
||||
// first NULL is email, second NULL is hwid
|
||||
$resp = api\v1_0\register($username, $license, $password, NULL, NULL, $_SESSION['panelapp']);
|
||||
switch ($resp) {
|
||||
case 'username_taken':
|
||||
dashboard\primary\error("Username taken!");
|
||||
break;
|
||||
case 'key_not_found':
|
||||
dashboard\primary\error("License doesn't exist!");
|
||||
break;
|
||||
case 'un_too_short':
|
||||
dashboard\primary\error("Username too short, try longer one.");
|
||||
break;
|
||||
case 'key_already_used':
|
||||
dashboard\primary\error("License already used!");
|
||||
break;
|
||||
case 'pw_leaked':
|
||||
dashboard\primary\error("This password has been leaked in a data breach (not from us), please use a different one.");
|
||||
break;
|
||||
case 'key_banned':
|
||||
dashboard\primary\error("License is banned!");
|
||||
break;
|
||||
default:
|
||||
$_SESSION['un'] = $username;
|
||||
header("location: ../dashboard/");
|
||||
break;
|
||||
}
|
||||
}
|
||||
?>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
163
panel/upgrade/index.php
Normal file
163
panel/upgrade/index.php
Normal file
@@ -0,0 +1,163 @@
|
||||
<?php
|
||||
require '../../includes/misc/autoload.phtml';
|
||||
require '../../includes/dashboard/autoload.phtml';
|
||||
|
||||
if (session_status() === PHP_SESSION_NONE) {
|
||||
session_start();
|
||||
}
|
||||
|
||||
if (!isset($_SESSION['panelapp'])) {
|
||||
die("You must go to your panel login first then visit this page");
|
||||
}
|
||||
|
||||
set_exception_handler(function ($exception) {
|
||||
error_log("\n--------------------------------------------------------------\n");
|
||||
error_log($exception);
|
||||
error_log("\nRequest data:");
|
||||
error_log(print_r($_POST, true));
|
||||
error_log("\n--------------------------------------------------------------");
|
||||
http_response_code(500);
|
||||
global $databaseUsername;
|
||||
$errorMsg = str_replace($databaseUsername, "REDACTED", $exception->getMessage());
|
||||
\dashboard\primary\error($errorMsg);
|
||||
});
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" class="bg-[#09090d] text-white overflow-x-hidden">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<base href="">
|
||||
<title>Upgrade</title>
|
||||
<link rel="shortcut icon" href="<?= $customerPanelIcon ?>" />
|
||||
<!--Custom Styles-->
|
||||
<link rel="stylesheet" type="text/css" href="https://cdn.keyauth.cc/v3/dist/output.css" />
|
||||
|
||||
<script>
|
||||
if (window.history.replaceState) {
|
||||
window.history.replaceState(null, null, window.location.href);
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!--Navbar-->
|
||||
<header>
|
||||
<nav class="border-gray-200 px-4 lg:px-6 py-2.5 mb-14">
|
||||
<div class="flex flex-wrap justify-between items-center mx-auto max-w-screen-xl">
|
||||
<a href="../" class="flex items-center">
|
||||
<img src="https://cdn.keyauth.cc/v2/assets/media/logos/logo-1-dark.png" class="mr-3 h-12 mt-2"
|
||||
alt="KeyAuth Logo" />
|
||||
</a>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<section>
|
||||
<div class="py-8 px-4 mx-auto max-w-screen-xl lg:py-16 grid lg:grid-cols-2 gap-8 lg:gap-16">
|
||||
<div class="flex flex-col justify-center">
|
||||
<h1
|
||||
class="mb-4 text-4xl font-extrabold tracking-tight leading-none text-white-900 md:text-5xl lg:text-6xl">
|
||||
<?= $name; ?> Customer Panel</h1>
|
||||
<p class="mb-6 text-lg font-normal text-gray-500 lg:text-xl">To access <a
|
||||
class="text-blue-600"><?= $name; ?> customer panel</a>,
|
||||
you must login, or register. This information is provided to you by the owner of the application. Do
|
||||
not contact KeyAuth support if
|
||||
you can not access the customer panel.
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<div class="w-full lg:max-w-xl p-6 space-y-8 sm:p-8 bg-[#09090d] rounded-lg shadow-xl">
|
||||
<form class="mt-8 space-y-6" method="post">
|
||||
<div class="relative">
|
||||
<input type="text" name="username"
|
||||
class="block px-2.5 pb-2.5 pt-4 w-full text-sm text-white-900 bg-transparent rounded-lg border-1 border-gray-70 appearance-none focus:outline-none focus:ring-0 focus:border-blue-600 peer"
|
||||
placeholder=" " autocomplete="on" required />
|
||||
<label for="username"
|
||||
class="absolute text-sm text-gray-500 duration-300 transform -translate-y-4 scale-75 top-2 z-10 origin-[0] bg-[#09090d] px-2 peer-focus:px-2 peer-focus:text-blue-600 peer-focus:text-blue-500 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">Username</label>
|
||||
</div>
|
||||
<div class="relative">
|
||||
<input type="text" name="license"
|
||||
class="block px-2.5 pb-2.5 pt-4 w-full text-sm text-white-900 bg-transparent rounded-lg border-1 border-gray-700 appearance-none focus:outline-none focus:ring-0 focus:border-blue-600 peer"
|
||||
placeholder=" " autocomplete="on" required />
|
||||
<label for="license"
|
||||
class="absolute text-sm text-gray-500 duration-300 transform -translate-y-4 scale-75 top-2 z-10 origin-[0] bg-[#09090d] px-2 peer-focus:px-2 peer-focus:text-blue-600 peer-focus:text-blue-500 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">License</label>
|
||||
</div>
|
||||
<button name="upgrade"
|
||||
class="w-full px-5 py-3 text-base font-medium text-center text-white bg-blue-700 rounded-lg hover:bg-blue-800 focus:ring-4 focus:ring-blue-300 sm:w-full">Upgrade
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!--Flowbite JS-->
|
||||
<script src="https://cdn.keyauth.cc/v3/dist/flowbite.js"></script>
|
||||
|
||||
<?php
|
||||
if (isset($_POST['upgrade'])) {
|
||||
$username = misc\etc\sanitize($_POST['username']);
|
||||
$license = misc\etc\sanitize($_POST['license']);
|
||||
|
||||
|
||||
// search for key
|
||||
$query = misc\mysql\query("SELECT `expires`, `status`, `level` FROM `keys` WHERE `key` = ? AND `app` = ?", [$license, $_SESSION['panelapp']]);
|
||||
|
||||
// check if key exists
|
||||
if ($query->num_rows < 1) {
|
||||
dashboard\primary\error("License doesn't exist!");
|
||||
return;
|
||||
}
|
||||
// if key does exist
|
||||
elseif ($query->num_rows > 0) {
|
||||
// get key info
|
||||
while ($row = mysqli_fetch_array($query->result)) {
|
||||
$expires = $row['expires'];
|
||||
$status = $row['status'];
|
||||
$level = $row['level'];
|
||||
}
|
||||
|
||||
// check if used
|
||||
if ($status == "Used") {
|
||||
dashboard\primary\error("License already used!");
|
||||
return;
|
||||
}
|
||||
|
||||
// add current time to key time
|
||||
$expiry = $expires + time();
|
||||
|
||||
$query = misc\mysql\query("SELECT `name` FROM `subscriptions` WHERE `app` = ? AND `level` = ?", [$_SESSION['panelapp'], $level]);
|
||||
$subName = mysqli_fetch_array($query->result)['name'];
|
||||
|
||||
$resp = misc\user\extend($username, $subName, $expiry, 0, $_SESSION['panelapp']);
|
||||
switch ($resp) {
|
||||
case 'missing':
|
||||
dashboard\primary\error("User not found!");
|
||||
break;
|
||||
case 'sub_missing':
|
||||
dashboard\primary\error("Subscription not found for that license level!");
|
||||
break;
|
||||
case 'failure':
|
||||
dashboard\primary\error("Unknown upgrade error! Please contact support.");
|
||||
break;
|
||||
case 'success':
|
||||
// set key to used, and set usedby
|
||||
misc\mysql\query("UPDATE `keys` SET `status` = 'Used', `usedon` = ?, `usedby` = ? WHERE `key` = ? AND `app` = ?", [time(), $username, $license, $_SESSION['panelapp']]);
|
||||
misc\cache\purge('KeyAuthKeys:' . $_SESSION['panelapp']);
|
||||
dashboard\primary\success("Successfully Upgraded!");
|
||||
break;
|
||||
default:
|
||||
dashboard\primary\error("Unknown upgrade error! Please contact support.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user