From 938d485253305a065513527cd4c0461d0eee8b03 Mon Sep 17 00:00:00 2001 From: tbS Date: Sat, 2 Aug 2025 22:24:03 +0200 Subject: [PATCH] =?UTF-8?q?datein=20hinzuf=C3=BCgen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/.gitignore | 8 + .idea/keyauth.iml | 8 + .idea/modules.xml | 8 + .idea/php.xml | 22 + .idea/vcs.xml | 6 + Favicon-Logo-306x310.ico | Bin 0 -> 16892 bytes api-php/dashboard/webauthn.php | 196 ++ api/1.0/index.php | 1283 ++++++++++++ api/1.1/index.php | 1268 ++++++++++++ api/1.2/index.php | 2071 +++++++++++++++++++ api/dashboard/webauthn.php | 191 ++ api/index.php | 3 + api/reseller/index.php | 304 +++ api/seller/index.php | 1717 ++++++++++++++++ app/black-fetch.php | 96 + app/download-types.php | 343 ++++ app/index.php | 208 ++ app/layout/aside.php | 289 +++ app/layout/breadcrumb.php | 34 + app/layout/footer.php | 20 + app/layout/master.php | 47 + app/layout/profile.php | 99 + app/layout/reselleraside.php | 59 + app/layout/topbar.php | 106 + app/license-fetch.php | 156 ++ app/log-fetch.php | 92 + app/pages/account-logs.php | 71 + app/pages/account-settings.php | 607 ++++++ app/pages/admin-panel.php | 806 ++++++++ app/pages/app-settings.php | 2087 ++++++++++++++++++++ app/pages/audit-logs.php | 120 ++ app/pages/blacklists.php | 239 +++ app/pages/chats.php | 631 ++++++ app/pages/files.php | 474 +++++ app/pages/forms.php | 641 ++++++ app/pages/licenses.php | 974 +++++++++ app/pages/logout.php | 8 + app/pages/logs.php | 119 ++ app/pages/manage-accs.php | 690 +++++++ app/pages/manage-apps.php | 1245 ++++++++++++ app/pages/reseller-balance.php | 268 +++ app/pages/reseller-licenses.php | 430 ++++ app/pages/reseller-users.php | 394 ++++ app/pages/seller-logs.php | 103 + app/pages/seller-settings.php | 1685 ++++++++++++++++ app/pages/sessions.php | 102 + app/pages/staff-panel.php | 146 ++ app/pages/subscriptions.php | 369 ++++ app/pages/support.php | 23 + app/pages/tokens.php | 43 + app/pages/upgrade.php | 839 ++++++++ app/pages/user-vars.php | 312 +++ app/pages/users.php | 1210 ++++++++++++ app/pages/vars.php | 279 +++ app/pages/webhooks.php | 407 ++++ app/pages/webloader.php | 219 ++ app/pages/whitelists.php | 144 ++ app/reseller-license-fetch.php | 127 ++ app/reseller-user-fetch.php | 143 ++ app/session-fetch.php | 118 ++ app/token-fetch.php | 119 ++ app/user-fetch.php | 177 ++ app/user-var-fetch.php | 120 ++ app/var-fetch.php | 132 ++ app/white-fetch.php | 110 ++ auth/GoogleAuthenticator.php | 174 ++ discord/index.html | 449 +++++ docs/index.php | 3 + favicon.ico | Bin 0 -> 193196 bytes free-trial/index.html | 469 +++++ gdpr/index.html | 487 +++++ includes/.htaccess | 5 + includes/VerifyEmail.class.php | 366 ++++ includes/api/1.0/autoload.phtml | 7 + includes/api/1.0/index.php | 217 ++ includes/api/shared/autoload.phtml | 7 + includes/api/shared/primary.php | 63 + includes/credentials.php | 34 + includes/dashboard/autoload.phtml | 7 + includes/dashboard/primary.php | 166 ++ includes/misc/account.php | 51 + includes/misc/app.php | 55 + includes/misc/auditLog.php | 28 + includes/misc/autoload.phtml | 7 + includes/misc/blacklist.php | 94 + includes/misc/button.php | 40 + includes/misc/cache.php | 137 ++ includes/misc/chat.php | 112 ++ includes/misc/email.php | 479 +++++ includes/misc/etc.php | 199 ++ includes/misc/license.php | 410 ++++ includes/misc/log.php | 16 + includes/misc/mysql.php | 74 + includes/misc/session.php | 53 + includes/misc/sub.php | 84 + includes/misc/token.php | 182 ++ includes/misc/upload.php | 161 ++ includes/misc/user.php | 524 +++++ includes/misc/variable.php | 101 + includes/misc/webhook.php | 51 + includes/misc/whitelist.php | 50 + includes/redis.php | 15 + index.html | 1646 +++++++++++++++ login/index.php | 635 ++++++ login/renders/twofactor.php | 21 + login/securityKey.html | 139 ++ panel/.htaccess | 7 + panel/dashboard/index.php | 92 + panel/dashboard/layout/customeraside.php | 20 + panel/dashboard/layout/master.php | 41 + panel/dashboard/layout/profile.php | 48 + panel/dashboard/pages/customer-actions.php | 214 ++ panel/dashboard/pages/customer-logout.php | 5 + panel/dashboard/pages/logout.php | 12 + panel/index.php | 206 ++ panel/register/index.php | 148 ++ panel/upgrade/index.php | 163 ++ privacy/index.html | 668 +++++++ register/index.php | 563 ++++++ safe-harbot.txt | 14 + scripts/datatables.js | 642 ++++++ setup-script/etc.php | 130 ++ setup-script/nginx.conf | 120 ++ setup-script/test.php | 2 + setup-script/www.conf | 438 ++++ stats.php | 19 + tbs.png | Bin 0 -> 12793 bytes telegram/index.php | 4 + terms/index.html | 793 ++++++++ 129 files changed, 37532 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/keyauth.iml create mode 100644 .idea/modules.xml create mode 100644 .idea/php.xml create mode 100644 .idea/vcs.xml create mode 100644 Favicon-Logo-306x310.ico create mode 100644 api-php/dashboard/webauthn.php create mode 100644 api/1.0/index.php create mode 100644 api/1.1/index.php create mode 100644 api/1.2/index.php create mode 100644 api/dashboard/webauthn.php create mode 100644 api/index.php create mode 100644 api/reseller/index.php create mode 100644 api/seller/index.php create mode 100644 app/black-fetch.php create mode 100644 app/download-types.php create mode 100644 app/index.php create mode 100644 app/layout/aside.php create mode 100644 app/layout/breadcrumb.php create mode 100644 app/layout/footer.php create mode 100644 app/layout/master.php create mode 100644 app/layout/profile.php create mode 100644 app/layout/reselleraside.php create mode 100644 app/layout/topbar.php create mode 100644 app/license-fetch.php create mode 100644 app/log-fetch.php create mode 100644 app/pages/account-logs.php create mode 100644 app/pages/account-settings.php create mode 100644 app/pages/admin-panel.php create mode 100644 app/pages/app-settings.php create mode 100644 app/pages/audit-logs.php create mode 100644 app/pages/blacklists.php create mode 100644 app/pages/chats.php create mode 100644 app/pages/files.php create mode 100644 app/pages/forms.php create mode 100644 app/pages/licenses.php create mode 100644 app/pages/logout.php create mode 100644 app/pages/logs.php create mode 100644 app/pages/manage-accs.php create mode 100644 app/pages/manage-apps.php create mode 100644 app/pages/reseller-balance.php create mode 100644 app/pages/reseller-licenses.php create mode 100644 app/pages/reseller-users.php create mode 100644 app/pages/seller-logs.php create mode 100644 app/pages/seller-settings.php create mode 100644 app/pages/sessions.php create mode 100644 app/pages/staff-panel.php create mode 100644 app/pages/subscriptions.php create mode 100644 app/pages/support.php create mode 100644 app/pages/tokens.php create mode 100644 app/pages/upgrade.php create mode 100644 app/pages/user-vars.php create mode 100644 app/pages/users.php create mode 100644 app/pages/vars.php create mode 100644 app/pages/webhooks.php create mode 100644 app/pages/webloader.php create mode 100644 app/pages/whitelists.php create mode 100644 app/reseller-license-fetch.php create mode 100644 app/reseller-user-fetch.php create mode 100644 app/session-fetch.php create mode 100644 app/token-fetch.php create mode 100644 app/user-fetch.php create mode 100644 app/user-var-fetch.php create mode 100644 app/var-fetch.php create mode 100644 app/white-fetch.php create mode 100644 auth/GoogleAuthenticator.php create mode 100644 discord/index.html create mode 100644 docs/index.php create mode 100644 favicon.ico create mode 100644 free-trial/index.html create mode 100644 gdpr/index.html create mode 100644 includes/.htaccess create mode 100644 includes/VerifyEmail.class.php create mode 100644 includes/api/1.0/autoload.phtml create mode 100644 includes/api/1.0/index.php create mode 100644 includes/api/shared/autoload.phtml create mode 100644 includes/api/shared/primary.php create mode 100644 includes/credentials.php create mode 100644 includes/dashboard/autoload.phtml create mode 100644 includes/dashboard/primary.php create mode 100644 includes/misc/account.php create mode 100644 includes/misc/app.php create mode 100644 includes/misc/auditLog.php create mode 100644 includes/misc/autoload.phtml create mode 100644 includes/misc/blacklist.php create mode 100644 includes/misc/button.php create mode 100644 includes/misc/cache.php create mode 100644 includes/misc/chat.php create mode 100644 includes/misc/email.php create mode 100644 includes/misc/etc.php create mode 100644 includes/misc/license.php create mode 100644 includes/misc/log.php create mode 100644 includes/misc/mysql.php create mode 100644 includes/misc/session.php create mode 100644 includes/misc/sub.php create mode 100644 includes/misc/token.php create mode 100644 includes/misc/upload.php create mode 100644 includes/misc/user.php create mode 100644 includes/misc/variable.php create mode 100644 includes/misc/webhook.php create mode 100644 includes/misc/whitelist.php create mode 100644 includes/redis.php create mode 100644 index.html create mode 100644 login/index.php create mode 100644 login/renders/twofactor.php create mode 100644 login/securityKey.html create mode 100644 panel/.htaccess create mode 100644 panel/dashboard/index.php create mode 100644 panel/dashboard/layout/customeraside.php create mode 100644 panel/dashboard/layout/master.php create mode 100644 panel/dashboard/layout/profile.php create mode 100644 panel/dashboard/pages/customer-actions.php create mode 100644 panel/dashboard/pages/customer-logout.php create mode 100644 panel/dashboard/pages/logout.php create mode 100644 panel/index.php create mode 100644 panel/register/index.php create mode 100644 panel/upgrade/index.php create mode 100644 privacy/index.html create mode 100644 register/index.php create mode 100644 safe-harbot.txt create mode 100644 scripts/datatables.js create mode 100644 setup-script/etc.php create mode 100644 setup-script/nginx.conf create mode 100644 setup-script/test.php create mode 100644 setup-script/www.conf create mode 100644 stats.php create mode 100644 tbs.png create mode 100644 telegram/index.php create mode 100644 terms/index.html diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/keyauth.iml b/.idea/keyauth.iml new file mode 100644 index 0000000..c956989 --- /dev/null +++ b/.idea/keyauth.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..3338fea --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/php.xml b/.idea/php.xml new file mode 100644 index 0000000..29059d0 --- /dev/null +++ b/.idea/php.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Favicon-Logo-306x310.ico b/Favicon-Logo-306x310.ico new file mode 100644 index 0000000000000000000000000000000000000000..401b40dbecd4bcebb5479f0344be9d31932c7412 GIT binary patch literal 16892 zcmaL9WmKD8(>C0TVg(9qac`00PH`#j?p`23aSsj!3KVZ}3ogYWIKe3p+}+(FxWk*? z&-(s;u*k{^v+dY>&Y3x8c3!>u5Apl&=f77UU+sv!dPRVEAFiq_^A>{y1M&8)oUEie z;=i1TKOS^c#3vg%6qBzI!g7*gnw}ZQ%N`lH+Y7yCt6;l&HVeHZW0YbfbxGv+?^OST zw*8{O#0bJLbKL8U@O~AWZPphYfni1{nNO%DhLRtAIig;lOyk-f(9so?z#{j#Uu1Q( z&-G*fh@s$oYf9>nQ0yPZP&Lih^)}IoO`3ys`Of?~8`wDROm8f3Jo%Y)v`PeN_!n~z z#MqP-0;yk$-EUuTLk#Kc<`1VY7qHLlTo2D_!t#$VAQh%R9ex1^?nf7@hIbq%(chaz z4Do@(fVSHOUK8Rh`T)HJzQwpg*6G4jM%I2dI+U{RN*&=x(cBY)u{<6iI6}U4C4E=SfCi~%HFxT0nLK0z3KSO74(|{ zqP|mr#k3P29vOgt;h$_7oV?KJUes{B#9vi)t(D8Z!hH6OZwauF6d$LQ>* zV>UEuF=ZpoRL3F7D}kJ8bmD?nZKclPTgF4z+x0v_VGI!VF~Pxz#qtL*WyI}uDxA+?u%izv&N+TlBYv5*wy7u2SB+7NKX)THN>BFJ|*dk3XB zKGpQ%G>{9zmG8kzRf)vHG!zF)(NX6bwFo_+LL#0kh=CkZ1b~yOU-KBR)f4H2HvEOfo4{DOU6OhTZooLZ6u}>=!BHLB zAYNQ^ukZSfH68>t)mfhviiYcBQ#FkF}QHKsRzO4r6Op4 zPyO;SW-oV{3KyRw^9*xn#I@tt#nmCyU`K~kK?zzzRAd=3gsPMCMKCw3up^h5uYK$- z?enlj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t!@4RU5o}kzHs1MGTlr|QEaKU!P5MXZ@2lIlO2k5pPuPKEBs#5cz{NgyA(uAcetLsupb!U|f0ZJrzFJ;gc_V>lDlN|omEa4ZzJ?9~0 z8OP*mJy%LgJ_q8ZVse&B!QFrEk#hN@6Gw>u%kF7M6RI&u-wG|4+9PQJoY|o+Km7@a zJFP?wS*!zJD&CqP2#~oGXlqhSquPn^9;k@9AgD5uS$rG=+miC~e3&-e_e-Jeep6s; zExVK@a&%z8?<&r)#dBr{!L=M()iNqv%nh=#Xu_R*A2;tCmm!L2siE)(cEr_dba|a; z`Dh_taD9_CE;YAKBnCx+f0_<8`OJE2ojf)K*rb=Z_mOLPu(^iHO{snW;?UoG8LqvP gRynct^513G`y1g~A_~O!H@uRQQkJX`{}%NB0ILwxEC2ui literal 0 HcmV?d00001 diff --git a/api-php/dashboard/webauthn.php b/api-php/dashboard/webauthn.php new file mode 100644 index 0000000..59cf55e --- /dev/null +++ b/api-php/dashboard/webauthn.php @@ -0,0 +1,196 @@ + getCreateArgs + * | + * navigator.credentials.create <-------------' + * | + * '-------------------------> processCreate + * | + * alert ok or fail <----------------' + * + * ------------------------------------------------------------ + * + * VALIDATION + * + * window.fetch ------------------> getGetArgs + * | + * navigator.credentials.get <----------------' + * | + * '-------------------------> processGet + * | + * alert ok or fail <----------------' + * + * ------------------------------------------------------------ + */ +include '../../includes/misc/autoload.phtml'; +require_once '../../vendor/lbuchs/webauthn/src/WebAuthn.php'; +try { + // read get argument and post body + $fn = filter_input(INPUT_GET, 'fn'); + if(empty($fn)) { + die("Can't access directly"); + } + $post = trim(file_get_contents('php://input')); + $userId = bin2hex(openssl_random_pseudo_bytes(10)); + if ($post) { + $post = json_decode($post); + } + + session_start(); + + if($_SESSION['discordLogin']) { + throw new Exception('You can\'t use security keys when you sign-in with different website! Use security keys on that website instead, Discord supports security keys'); + } + + // Formats + $formats = array(); + $formats[] = 'none'; + + $rpId = $_SERVER['HTTP_HOST']; + + // cross-platform: true, if type internal is not allowed + // false, if only internal is allowed + // null, if internal and cross-platform is allowed + $crossPlatformAttachment = null; + + + // new Instance of the server library. + // make sure that $rpId is the domain name. + $WebAuthn = new lbuchs\WebAuthn\WebAuthn('KeyAuth', $rpId, $formats); + + // ------------------------------------ + // request for create arguments + // ------------------------------------ + + if ($fn === 'getCreateArgs') { + $createArgs = $WebAuthn->getCreateArgs($userId, $_SESSION['username'], "", 20, 0, "discouraged", $crossPlatformAttachment); + + header('Content-Type: application/json'); + print(json_encode($createArgs)); + + // save challange to session. you have to deliver it to processGet later. + $_SESSION['challenge'] = $WebAuthn->getChallenge(); + + + + // ------------------------------------ + // request for get arguments + // ------------------------------------ + + } else if ($fn === 'getGetArgs') { + $ids = array(); + + // load registrations from session stored there by processCreate. + + $query = misc\mysql\query("SELECT * FROM `securityKeys` WHERE `username` = ?", [$_SESSION['pendingUsername']]); + if ($query->num_rows > 0) { + while ($row = mysqli_fetch_array($query->result)) { + $ids[] = base64_decode($row["credentialId"]); + } + } + + if (count($ids) === 0) { + throw new Exception('No security key registrations found for this user!'); + } + + $getArgs = $WebAuthn->getGetArgs($ids, 20, 1, 1, 1, 1, 0); + + header('Content-Type: application/json'); + print(json_encode($getArgs)); + + // save challange to session. you have to deliver it to processGet later. + $_SESSION['challenge'] = $WebAuthn->getChallenge(); + + + + // ------------------------------------ + // process create + // ------------------------------------ + + } else if ($fn === 'processCreate') { + $clientDataJSON = base64_decode($post->clientDataJSON); + $attestationObject = base64_decode($post->attestationObject); + $challenge = $_SESSION['challenge']; + + // processCreate returns data to be stored for future logins. + $data = $WebAuthn->processCreate($clientDataJSON, $attestationObject, $challenge, 0, false, false); + + unset($_SESSION['challenge']); // disgard challenge array from session file, no longer needed + + $name = misc\etc\sanitize($_GET['name']); + + misc\mysql\query("INSERT INTO `securityKeys` (`username`, `name`, `credentialId`, `credentialPublicKey`) VALUES (?, ?, ?, ?)", [$_SESSION['username'], $name, base64_encode($data->credentialId), $data->credentialPublicKey]); + misc\mysql\query("UPDATE `accounts` SET `securityKey` = 1 WHERE `username` = ?", [$_SESSION['username']]); + + $return = new stdClass(); + $return->success = true; + $return->msg = 'registration success.'; + + header('Content-Type: application/json'); + print(json_encode($return)); + + + + // ------------------------------------ + // proccess get + // ------------------------------------ + + } else if ($fn === 'processGet') { + $clientDataJSON = base64_decode($post->clientDataJSON); + $authenticatorData = base64_decode($post->authenticatorData); + $signature = base64_decode($post->signature); + $userHandle = base64_decode($post->userHandle); + $id = base64_decode($post->id); + $challenge = $_SESSION['challenge']; + $credentialPublicKey = null; + + // looking up correspondending public key of the credential id + // you should also validate that only ids of the given user name + // are taken for the login. + + $query = misc\mysql\query("SELECT * FROM `securityKeys` WHERE `username` = ?", [$_SESSION['pendingUsername']]); + if ($query->num_rows > 0) { + while ($row = mysqli_fetch_array($query->result)) { + if(base64_decode($row["credentialId"]) === $id) { + $credentialPublicKey = $row["credentialPublicKey"]; + break; + } + } + } + + if ($credentialPublicKey === null) { + throw new Exception('This security key wasn\'t found!'); + } + + // process the get request. throws WebAuthnException if it fails + $WebAuthn->processGet($clientDataJSON, $authenticatorData, $signature, $credentialPublicKey, $challenge, null, 0); + + unset($_SESSION['challenge']); // disgard challenge array from session file, no longer needed + $_SESSION['username'] = $_SESSION['pendingUsername']; + unset($_SESSION['pendingUsername']); + + $return = new stdClass(); + $return->success = true; + + header('Content-Type: application/json'); + print(json_encode($return)); + } + +} catch (Throwable $ex) { + $return = new stdClass(); + $return->success = false; + $return->msg = $ex->getMessage(); + + header('Content-Type: application/json'); + print(json_encode($return)); +} \ No newline at end of file diff --git a/api/1.0/index.php b/api/1.0/index.php new file mode 100644 index 0000000..64402c9 --- /dev/null +++ b/api/1.0/index.php @@ -0,0 +1,1283 @@ +getMessage()); + die(json_encode(array("success" => false, "message" => "Error: " . $errorMsg))); +}); + +if(empty($_POST['ownerid'])) { + die(json_encode(array("success" => false, "message" => "No OwnerID specified. Select app & copy code snippet from https://keyauth.cc/app/"))); +} + +if(empty($_POST['name'])) { + die(json_encode(array("success" => false, "message" => "No app name specified. Select app & copy code snippet from https://keyauth.cc/app/"))); +} + +if(strlen(hex2bin($_POST['ownerid'])) != 10) { + die(json_encode(array("success" => false, "message" => "OwnerID should be 10 characters long. Select app & copy code snippet from https://keyauth.cc/app/"))); +} + +$ownerid = misc\etc\sanitize(hex2bin($_POST['ownerid'])); // ownerid of account that owns application +$name = misc\etc\sanitize(hex2bin($_POST['name'])); // application name +$row = misc\cache\fetch('KeyAuthApp:' . $name . ':' . $ownerid, "SELECT * FROM `apps` WHERE `ownerid` = ? AND `name` = ?", [$ownerid, $name], 0); + +if ($row == "not_found") { + die("KeyAuth_Invalid"); +} + +// app settings +$secret = $row['secret']; +$hwidenabled = $row['hwidcheck']; +$vpnblock = $row['vpnblock']; +$status = $row['enabled']; +$paused = $row['paused']; +$currentver = $row['ver']; +$download = $row['download']; +$webhook = $row['webhook']; +$appdisabled = $row['appdisabled']; +$hashcheck = $row['hashcheck']; +$serverhash = $row['hash']; +$sessionexpiry = $row['session']; +$forceHwid = $row['forceHwid']; + +$banned = $row['banned']; +$owner = $row['owner']; +$name = $row['name']; + +// custom error messages +$usernametaken = $row['usernametaken']; +$keynotfound = $row['keynotfound']; +$keyused = $row['keyused']; +$nosublevel = $row['nosublevel']; +$usernamenotfound = $row['usernamenotfound']; +$passmismatch = $row['passmismatch']; +$hwidmismatch = $row['hwidmismatch']; +$noactivesubs = $row['noactivesubs']; +$hwidblacked = $row['hwidblacked']; +$pausedsub = $row['pausedsub']; +$vpnblocked = $row['vpnblocked']; +$keybanned = $row['keybanned']; +$userbanned = $row['userbanned']; +$sessionunauthed = $row['sessionunauthed']; +$hashcheckfail = $row['hashcheckfail']; + +// why using null coalescing operators? because if I add a field and it's not in redis cache, it'll be NULL +$loggedInMsg = $row['loggedInMsg'] ?? "Logged in!"; +$pausedApp = $row['pausedApp'] ?? "Application is currently paused, please wait for the developer to say otherwise."; +$unTooShort = $row['unTooShort'] ?? "Username too short, try longer one."; +$pwLeaked = $row['pwLeaked'] ?? "This password has been leaked in a data breach (not from us), please use a different one."; +$chatHitDelay = $row['chatHitDelay'] ?? "Chat slower, you've hit the delay limit"; +$minHwid = $row['minHwid'] ?? 20; + +$enabledFunctions = (int)$row['enabledFunctions']; + + +if ($banned) { + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "This application has been banned from KeyAuth.cc for violating terms." // yes we self promote to customers of those who break ToS. Should've followed terms :shrug: + )), $secret)); +} + +if ($_GET['host'] == "keyauth.business") { + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "Please tell the developer of this program to use latest API domain. This domain is old, it will expire in a month." + )), $secret)); +} + +switch (hex2bin($_POST['type'])) { + case 'init': + $ip = api\shared\primary\getIp(); + if ($vpnblock) { + if (api\shared\primary\vpnCheck($ip)) { + $row = misc\cache\fetch('KeyAuthWhitelist:' . $secret . ':' . $ip, "SELECT 1 FROM `whitelist` WHERE `ip` = ? AND `app` = ?", [$ip, $secret], 0); + if ($row == "not_found") { + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "$vpnblocked" + )), $secret)); + } + } + } + + if (!$status) { + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "$appdisabled" + )), $secret)); + } + + if ($paused) { + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "$pausedApp" + )), $secret)); + } + + $ver = misc\etc\sanitize(api\v1_0\Decrypt($_POST['ver'], $secret)); + + if ($ver != $currentver) { + // auto-update system + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "invalidver", + "download" => "$download" + ), JSON_UNESCAPED_SLASHES), $secret)); + } + + $hash = misc\etc\sanitize($_POST['hash']); + + if ($hashcheck) { + if (strpos($serverhash, $hash) === false) { + if (is_null($serverhash)) { + misc\mysql\query("UPDATE `apps` SET `hash` = ? WHERE `secret` = ?", [$hash, $secret]); + misc\cache\purge('KeyAuthApp:' . $name . ':' . $ownerid); // flush cache for application so new hash takes precedent + } else { + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "$hashcheckfail" + )), $secret)); + } + } + } + + $enckey = misc\etc\sanitize(api\v1_0\Decrypt($_POST['enckey'], $secret)); + + $newSession = false; + $duplicateSession = misc\cache\select("KeyAuthSessionDupe:$secret:$ip"); + if($duplicateSession) { + $sessionid = $duplicateSession; + $updateSession = misc\cache\update('KeyAuthState:'.$secret.':'.$sessionid.'', array("enckey" => $enckey)); + if(!$updateSession) { + $sessionid = misc\etc\generateRandomString(); + $newSession = true; + } + } + else { + $sessionid = misc\etc\generateRandomString(); + $newSession = true; + } + + // $row = misc\cache\fetch('KeyAuthAppStats:' . $secret, "SELECT (SELECT COUNT(1) FROM `users` WHERE `app` = ?) AS 'numUsers', (SELECT COUNT(1) FROM `sessions` WHERE `app` = ? AND `validated` = 1 AND `expiry` > ?) AS 'numOnlineUsers', (SELECT COUNT(1) FROM `keys` WHERE `app` = ?) AS 'numKeys' FROM dual", [$secret, $secret, time(), $secret], 0, 3600); + + $numUsers = "N/A - Use fetchStats() function in latest example"; + $numOnlineUsers = "N/A - Use fetchStats() function in latest example"; + $numKeys = "N/A - Use fetchStats() function in latest example"; + + echo api\v1_0\Encrypt(json_encode(array( + "success" => true, + "message" => "Initialized", + "sessionid" => $sessionid, + "appinfo" => array( + "numUsers" => "$numUsers", + "numOnlineUsers" => "$numOnlineUsers", + "numKeys" => "$numKeys", + "version" => "$currentver", + "customerPanelLink" => "https://keyauth.cc/panel/$owner/$name/" + ) + )), $secret); + + fastcgi_finish_request(); + + if($newSession) { + misc\cache\insert("KeyAuthState:$secret:$sessionid", serialize(array("credential" => NULL, "enckey" => $enckey, "validated" => 0)), $sessionexpiry); + $time = time() + $sessionexpiry; + misc\mysql\query("REPLACE INTO `sessions` (`id`, `app`, `expiry`, `created_at`, `enckey`,`ip`) VALUES (?, ?, ?, ?, ?, ?)", [$sessionid, $secret, $time, time(), $enckey, $ip]); + $session = api\shared\primary\getSession($sessionid, $secret); + $enckey = $session["enckey"]; + misc\cache\insert("KeyAuthSessionDupe:$secret:$ip", $sessionid, $sessionexpiry); + } + + if($duplicateSession) { + misc\mysql\query("update `sessions` set `enckey` = ? where `id` = ?", [$enckey, $sessionid]); + } + + case 'register': + if (!($enabledFunctions & 2)) { + + die(json_encode(array( + "success" => false, + "message" => "This function has been disabled by app owner, it can be enabled in Function Management on https://keyauth.cc/app/?page=app-settings." + ))); + } + // retrieve session info + $sessionid = misc\etc\sanitize(hex2bin($_POST['sessionid'])); + $session = api\shared\primary\getSession($sessionid, $secret); + $enckey = $session["enckey"]; + + // Read in username + $username = misc\etc\sanitize(api\v1_0\Decrypt($_POST['username'], $enckey)); + + if(strlen($username) > 70) { + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "Username must be shorter than 70 characters" + )), $enckey)); + } + + // Read in license key + $checkkey = misc\etc\sanitize(api\v1_0\Decrypt($_POST['key'], $enckey)); + + if(strlen($checkkey) > 70) { + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "Key must be shorter than 70 characters" + )), $enckey)); + } + + // Read in password + $password = misc\etc\sanitize(api\v1_0\Decrypt($_POST['pass'], $enckey)); + + // Read in email + $email = misc\etc\sanitize(api\v1_0\Decrypt($_POST['email'], $enckey)); + + // Read in hwid + $hwid = misc\etc\sanitize(api\v1_0\Decrypt($_POST['hwid'], $enckey)); + + $resp = api\v1_0\register($username, $checkkey, $password, $email, $hwid, $secret); + switch ($resp) { + case 'username_taken': + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "$usernametaken" + )), $enckey)); + case 'key_not_found': + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "$keynotfound" + )), $enckey)); + case 'un_too_short': + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "$unTooShort" + )), $enckey)); + case 'pw_leaked': + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "$pwLeaked" + )), $enckey)); + case 'key_already_used': + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "$keyused" + )), $enckey)); + case 'key_banned': + if (strpos($keybanned, '{reason}') !== false) { + $query = misc\mysql\query("SELECT `banned` FROM `keys` WHERE `app` = ? AND `key` = ?", [$secret, $checkkey]); + $row = mysqli_fetch_array($query->result); + $reason = $row['banned']; + $keybanned = str_replace("{reason}", $reason, $keybanned); + } + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "$keybanned" + )), $enckey)); + case 'hwid_blacked': + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "$hwidblacked" + )), $enckey)); + case 'no_subs_for_level': + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "$nosublevel" + )), $enckey)); + default: + misc\mysql\query("UPDATE `sessions` SET `credential` = ?,`validated` = 1 WHERE `id` = ? AND `app` = ?", [$username, $sessionid, $secret]); + misc\cache\update('KeyAuthState:'.$secret.':'.$sessionid.'', array("validated" => 1, "credential" => $username)); + die(api\v1_0\Encrypt(json_encode(array( + "success" => true, + "message" => "$loggedInMsg", + "info" => $resp + )), $enckey)); + } + case 'upgrade': + if (!($enabledFunctions & 262144)) { + + die(json_encode(array( + "success" => false, + "message" => "This function has been disabled by app owner, it can be enabled in Function Management on https://keyauth.cc/app/?page=app-settings." + ))); + } + // retrieve session info + $sessionid = misc\etc\sanitize(hex2bin($_POST['sessionid'])); + $session = api\shared\primary\getSession($sessionid, $secret); + $enckey = $session["enckey"]; + + // Read in username + $username = misc\etc\sanitize(api\v1_0\Decrypt($_POST['username'], $enckey)); + + // Read in key + $checkkey = misc\etc\sanitize(api\v1_0\Decrypt($_POST['key'], $enckey)); + + + // search for key + $query = misc\mysql\query("SELECT `banned`, `expires`, `status`, `level` FROM `keys` WHERE `key` = ? AND `app` = ?", [$checkkey, $secret]); + + // check if key exists + if ($query->num_rows < 1) { + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "$keynotfound" + )), $enckey)); + } + // 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']; + $banned = $row['banned']; + } + + // check if used + if ($status == "Used") { + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "$keyused" + )), $enckey)); + } + + if (!is_null($banned)) { + if (strpos($keybanned, '{reason}') !== false) { + $keybanned = str_replace("{reason}", $banned, $keybanned); + } + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "$keybanned" + )), $enckey)); + } + + // add current time to key time + $expiry = $expires + time(); + + $query = misc\mysql\query("SELECT `name` FROM `subscriptions` WHERE `app` = ? AND `level` = ?", [$secret, $level]); + $subName = mysqli_fetch_array($query->result)['name']; + + $resp = misc\user\extend($username, $subName, $expiry, 0, $secret); + switch ($resp) { + case 'missing': + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "$usernamenotfound" + )), $enckey)); + case 'sub_missing': + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "$nosublevel" + )), $enckey)); + case 'failure': + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "Failed to upgrade for some reason." + )), $enckey)); + 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, $checkkey, $secret]); + misc\cache\purge('KeyAuthKeys:' . $secret . ':' . $checkkey); + misc\cache\purge('KeyAuthSubs:' . $secret . ':' . $username); + die(api\v1_0\Encrypt(json_encode(array( + "success" => true, + "message" => "Upgraded successfully" + )), $enckey)); + default: + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "Unhandled Error! Contact us if you need help" + )), $enckey)); + } + } + + case 'login': + if (!($enabledFunctions & 1)) { + + die(json_encode(array( + "success" => false, + "message" => "This function has been disabled by app owner, it can be enabled in Function Management on https://keyauth.cc/app/?page=app-settings." + ))); + } + // retrieve session info + $sessionid = misc\etc\sanitize(hex2bin($_POST['sessionid'])); + $session = api\shared\primary\getSession($sessionid, $secret); + $enckey = $session["enckey"]; + + // Read in username + $username = misc\etc\sanitize(api\v1_0\Decrypt($_POST['username'], $enckey)); + + // Read in HWID + $hwid = misc\etc\sanitize(api\v1_0\Decrypt($_POST['hwid'], $enckey)); + + // Read in password + $password = misc\etc\sanitize(api\v1_0\Decrypt($_POST['pass'], $enckey)); + + if(strlen($hwid) < $minHwid && !is_null($hwid)) { + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "HWID must be {$minHwid} or more characters, change this in app settings." + )), $enckey)); + } + + if($forceHwid && is_null($hwid)) { + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "Force HWID is enabled, disable in app settings if you want to use blank HWIDs" + )), $enckey)); + } + + $resp = api\v1_0\login($username, $password, $hwid, $secret, $hwidenabled); + switch ($resp) { + case 'un_not_found': + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "$usernamenotfound" + )), $enckey)); + case 'pw_mismatch': + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "$passmismatch" + )), $enckey)); + case 'user_banned': + if (strpos($userbanned, '{reason}') !== false) { + $query = misc\mysql\query("SELECT `banned` FROM `users` WHERE `app` = ? AND `username` = ?", [$secret, $username]); + $row = mysqli_fetch_array($query->result); + $reason = $row['banned']; + $userbanned = str_replace("{reason}", $reason, $userbanned); + } + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "$userbanned" + )), $enckey)); + case 'hwid_mismatch': + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "$hwidmismatch" + )), $enckey)); + case 'hwid_blacked': + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "$hwidblacked" + )), $enckey)); + case 'sub_paused': + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "$pausedsub" + )), $enckey)); + case 'no_active_subs': + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "$noactivesubs" + )), $enckey)); + default: + misc\mysql\query("UPDATE `sessions` SET `validated` = 1,`credential` = ? WHERE `id` = ? AND `app` = ?", [$username, $sessionid, $secret]); + misc\cache\update('KeyAuthState:'.$secret.':'.$sessionid.'', array("validated" => 1, "credential" => $username)); + die(api\v1_0\Encrypt(json_encode(array( + "success" => true, + "message" => "$loggedInMsg", + "info" => $resp + )), $enckey)); + } + + case 'license': + if (!($enabledFunctions & 4)) { + + die(json_encode(array( + "success" => false, + "message" => "This function has been disabled by app owner, it can be enabled in Function Management on https://keyauth.cc/app/?page=app-settings." + ))); + } + // retrieve session info + $sessionid = misc\etc\sanitize(hex2bin($_POST['sessionid'])); + $session = api\shared\primary\getSession($sessionid, $secret); + $enckey = $session["enckey"]; + $checkkey = misc\etc\sanitize(api\v1_0\Decrypt($_POST['key'], $enckey)); + + if(strlen($checkkey) > 70) { + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "Key must be shorter than 70 characters" + )), $enckey)); + } + + $hwid = misc\etc\sanitize(api\v1_0\Decrypt($_POST['hwid'], $enckey)); + + if(strlen($hwid) < $minHwid && !is_null($hwid)) { + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "HWID must be {$minHwid} or more characters, change this in app settings." + )), $enckey)); + } + + if($forceHwid && is_null($hwid)) { + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "Force HWID is enabled, disable in app settings if you want to use blank HWIDs" + )), $enckey)); + } + + $resp = api\v1_0\login($checkkey, $checkkey, $hwid, $secret, $hwidenabled); + switch ($resp) { + case 'un_not_found': + break; // user not registered yet or user was deleted + case 'hwid_mismatch': + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "$hwidmismatch" + )), $enckey)); + case 'user_banned': + if (strpos($userbanned, '{reason}') !== false) { + $query = misc\mysql\query("SELECT `banned` FROM `users` WHERE `app` = ? AND `username` = ?", [$secret, $checkkey]); + $row = mysqli_fetch_array($query->result); + $reason = $row['banned']; + $userbanned = str_replace("{reason}", $reason, $userbanned); + } + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "$userbanned" + )), $enckey)); + case 'pw_mismatch': + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "$passmismatch" + )), $enckey)); + case 'sub_paused': + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "$pausedsub" + )), $enckey)); + case 'hwid_blacked': + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "$hwidblacked" + )), $enckey)); + case 'no_active_subs': + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "$noactivesubs" + )), $enckey)); + default: + misc\mysql\query("UPDATE `sessions` SET `validated` = 1,`credential` = ? WHERE `id` = ?", [$checkkey, $sessionid]); + misc\cache\update('KeyAuthState:'.$secret.':'.$sessionid.'', array("validated" => 1, "credential" => $checkkey)); + die(api\v1_0\Encrypt(json_encode(array( + "success" => true, + "message" => "$loggedInMsg", + "info" => $resp + )), $enckey)); + } + + // if login didn't work, attempt to register + $resp = api\v1_0\register($checkkey, $checkkey, $checkkey, NULL, $hwid, $secret); + switch ($resp) { + case 'username_taken': + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "$usernametaken" + )), $enckey)); + case 'key_not_found': + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "$keynotfound" + )), $enckey)); + case 'un_too_short': + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "Username too short, try longer one." + )), $enckey)); + case 'pw_leaked': + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "$pwLeaked" + )), $enckey)); + case 'key_already_used': + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "$keyused" + )), $enckey)); + case 'key_banned': + if (strpos($keybanned, '{reason}') !== false) { + $query = misc\mysql\query("SELECT `banned` FROM `keys` WHERE `app` = ? AND `key` = ?", [$secret, $checkkey]); + $row = mysqli_fetch_array($query->result); + $reason = $row['banned']; + $keybanned = str_replace("{reason}", $reason, $keybanned); + } + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "$keybanned" + )), $enckey)); + case 'hwid_blacked': + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "$hwidblacked" + )), $enckey)); + case 'no_subs_for_level': + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "$nosublevel" + )), $enckey)); + default: + misc\mysql\query("UPDATE `sessions` SET `validated` = 1,`credential` = ? WHERE `id` = ?", [$checkkey, $sessionid]); + misc\cache\update('KeyAuthState:'.$secret.':'.$sessionid.'', array("validated" => 1, "credential" => $checkkey)); + die(api\v1_0\Encrypt(json_encode(array( + "success" => true, + "message" => "$loggedInMsg", + "info" => $resp + )), $enckey)); + } + case 'fetchOnline': + if (!($enabledFunctions & 4096)) { + + die(json_encode(array( + "success" => false, + "message" => "This function has been disabled by app owner, it can be enabled in Function Management on https://keyauth.cc/app/?page=app-settings." + ))); + } + $sessionid = misc\etc\sanitize(hex2bin($_POST['sessionid'])); + $session = api\shared\primary\getSession($sessionid, $secret); + $enckey = $session["enckey"]; + + $rows = misc\cache\fetch('KeyAuthOnlineUsers:' . $secret, "SELECT DISTINCT CONCAT(LEFT(`credential`, 10), IF(LENGTH(`credential`) > 10, REPEAT('*', LENGTH(`credential`) - 10), '')) AS `credential` FROM `sessions` WHERE `validated` = 1 AND `app` = ?", [$secret], 1, 1800); + + if ($rows == "not_found") { + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "No online users found!" + )), $enckey)); + } + + die(api\v1_0\Encrypt(json_encode(array( + "success" => true, + "message" => "Successfully fetched online users.", + "users" => $rows + )), $enckey)); + case 'setvar': + if (!($enabledFunctions & 64)) { + + die(json_encode(array( + "success" => false, + "message" => "This function has been disabled by app owner, it can be enabled in Function Management on https://keyauth.cc/app/?page=app-settings." + ))); + } + $sessionid = misc\etc\sanitize(hex2bin($_POST['sessionid'])); + $session = api\shared\primary\getSession($sessionid, $secret); + $enckey = $session["enckey"]; + if (!$session["validated"]) { + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "$sessionunauthed" + )), $enckey)); + } + + $var = misc\etc\sanitize(api\v1_0\Decrypt($_POST['var'], $enckey)); + $data = misc\etc\sanitize(api\v1_0\Decrypt($_POST['data'], $enckey)); + + if(is_null($var)) { + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "No variable name provided" + )), $enckey)); + } + + if(is_null($data)) { + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "No variable data provided" + )), $enckey)); + } + + if(strlen($data) > 500) { + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "Variable data must be 500 characters or less" + )), $enckey)); + } + + $row = misc\cache\fetch('KeyAuthUserVar:' . $secret . ':' . $var . ':' . $session["credential"], "SELECT `data`, `readOnly` FROM `uservars` WHERE `name` = ? AND `user` = ? AND `app` = ?", [$var, $session["credential"], $secret], 0); + + if ($row != "not_found") { + $readOnly = $row["readOnly"]; + if ($readOnly) { + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "Variable is read only" + )), $enckey)); + } + } + + $query = misc\mysql\query("REPLACE INTO `uservars` (`name`, `data`, `user`, `app`) VALUES (?, ?, ?, ?)", [$var, $data, $session["credential"], $secret]); + + if ($query->affected_rows != 0) { + misc\cache\purge('KeyAuthUserVar:' . $secret . ':' . $var . ':' . $session["credential"]); + die(api\v1_0\Encrypt(json_encode(array( + "success" => true, + "message" => "Successfully set variable" + )), $enckey)); + } else { + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "Failed to set variable" + )), $enckey)); + } + case 'getvar': + if (!($enabledFunctions & 32)) { + + die(json_encode(array( + "success" => false, + "message" => "This function has been disabled by app owner, it can be enabled in Function Management on https://keyauth.cc/app/?page=app-settings." + ))); + } + $sessionid = misc\etc\sanitize(hex2bin($_POST['sessionid'])); + $session = api\shared\primary\getSession($sessionid, $secret); + $enckey = $session["enckey"]; + if (!$session["validated"]) { + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "$sessionunauthed" + )), $enckey)); + } + + $var = misc\etc\sanitize(api\v1_0\Decrypt($_POST['var'], $enckey)); + + $row = misc\cache\fetch('KeyAuthUserVar:' . $secret . ':' . $var . ':' . $session["credential"], "SELECT `data`, `readOnly` FROM `uservars` WHERE `name` = ? AND `user` = ? AND `app` = ?", [$var, $session["credential"], $secret], 0); + + if ($row == "not_found") { + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "Variable not found for user" + )), $enckey)); + } + + $data = $row['data']; + die(api\v1_0\Encrypt(json_encode(array( + "success" => true, + "message" => "Successfully retrieved variable", + "response" => $data + )), $enckey)); + case 'var': + if (!($enabledFunctions & 131072)) { + + die(json_encode(array( + "success" => false, + "message" => "This function has been disabled by app owner, it can be enabled in Function Management on https://keyauth.cc/app/?page=app-settings." + ))); + } + // retrieve session info + $sessionid = misc\etc\sanitize(hex2bin($_POST['sessionid'])); + $session = api\shared\primary\getSession($sessionid, $secret); + $enckey = $session["enckey"]; + + $varid = misc\etc\sanitize(api\v1_0\Decrypt($_POST['varid'], $enckey)); + $row = misc\cache\fetch('KeyAuthVar:' . $secret . ':' . $varid, "SELECT `msg`, `authed` FROM `vars` WHERE `varid` = ? AND `app` = ?", [$varid, $secret], 0); + if ($row == "not_found") { + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "Variable not found." + )), $enckey)); + } + + $msg = $row['msg']; + $authed = $row['authed']; + + if ($authed) // if variable requires user to be authenticated + + { + if (!$session["validated"]) { + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "$sessionunauthed" + )), $enckey)); + } + } + die(api\v1_0\Encrypt(json_encode(array( + "success" => true, + "message" => "$msg" + )), $enckey)); + case 'checkblacklist': + // retrieve session info + $sessionid = misc\etc\sanitize(hex2bin($_POST['sessionid'])); + $session = api\shared\primary\getSession($sessionid, $secret); + $enckey = $session["enckey"]; + + $hwid = misc\etc\sanitize(api\v1_0\Decrypt($_POST['hwid'], $enckey)); + $ip = api\shared\primary\getIp(); + $row = misc\cache\fetch('KeyAuthBlacklist:' . $secret . ':' . $ip . ':' . $hwid, "SELECT 1 FROM `bans` WHERE (`hwid` = ? OR `ip` = ?) AND `app` = ?", [$hwid, $ip, $secret], 0); + + if ($row != "not_found") { + die(api\v1_0\Encrypt(json_encode(array( + "success" => true, + "message" => "Client is blacklisted" + )), $enckey)); + } else { + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "Client is not blacklisted" + )), $enckey)); + } + case 'chatget': + if (!($enabledFunctions & 8)) { + + die(json_encode(array( + "success" => false, + "message" => "This function has been disabled by app owner, it can be enabled in Function Management on https://keyauth.cc/app/?page=app-settings." + ))); + } + // retrieve session info + $sessionid = misc\etc\sanitize(hex2bin($_POST['sessionid'])); + $session = api\shared\primary\getSession($sessionid, $secret); + $enckey = $session["enckey"]; + if (!$session["validated"]) { + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "$sessionunauthed" + )), $enckey)); + } + + $channel = misc\etc\sanitize(api\v1_0\Decrypt($_POST['channel'], $enckey)); + $rows = misc\cache\fetch('KeyAuthChatMsgs:' . $secret . ':' . $channel, "SELECT `author`, `message`, `timestamp` FROM `chatmsgs` WHERE `channel` = ? AND `app` = ?", [$channel, $secret], 1); + + if ($rows == "not_found") { + $rows = []; + } + + die(api\v1_0\Encrypt(json_encode(array( + "success" => true, + "message" => "Successfully retrieved chat messages", + "messages" => $rows + )), $enckey)); + case 'chatsend': + if (!($enabledFunctions & 16)) { + + die(json_encode(array( + "success" => false, + "message" => "This function has been disabled by app owner, it can be enabled in Function Management on https://keyauth.cc/app/?page=app-settings." + ))); + } + // retrieve session info + $sessionid = misc\etc\sanitize(hex2bin($_POST['sessionid'])); + $session = api\shared\primary\getSession($sessionid, $secret); + $enckey = $session["enckey"]; + if (!$session["validated"]) { + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "$sessionunauthed" + )), $enckey)); + } + + $channel = misc\etc\sanitize(api\v1_0\Decrypt($_POST['channel'], $enckey)); + $query = misc\mysql\query("SELECT `delay` FROM `chats` WHERE `name` = ? AND `app` = ?", [$channel, $secret]); + + if ($query->num_rows < 1) { + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "Chat channel not found" + )), $enckey)); + } + + $row = mysqli_fetch_array($query->result); + $delay = $row['delay']; + $credential = $session["credential"]; + $query = misc\mysql\query("SELECT `timestamp` FROM `chatmsgs` WHERE `author` = ? AND `channel` = ? AND `app` = ? ORDER BY `id` DESC LIMIT 1", [$credential, $channel, $secret]); + + $row = mysqli_fetch_array($query->result); + $time = $row['timestamp']; + + if (time() - $time < $delay) { + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "$chatHitDelay" + )), $enckey)); + } + + $query = misc\mysql\query("SELECT `time` FROM `chatmutes` WHERE `user` = ? AND `app` = ?", [$credential, $secret]); + if ($query->num_rows != 0) { + $row = mysqli_fetch_array($query->result); + $unmuted = $row["time"]; + $unmuted = date("F j, Y, g:i a", $unmuted); + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "You're muted from chat until $unmuted" + )), $enckey)); + } + + $message = misc\etc\sanitize(api\v1_0\Decrypt($_POST['message'], $enckey)); + + if (is_null($message)) { + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "Message can't be blank" + )), $enckey)); + } + + if(strlen($message) > 2000) { + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "Message too long!" + )), $enckey)); + } + + misc\mysql\query("INSERT INTO `chatmsgs` (`author`, `message`, `timestamp`, `channel`,`app`) VALUES (?, ?, ?, ?, ?)", [$credential, $message, time(), $channel, $secret]); + misc\mysql\query("DELETE FROM `chatmsgs` WHERE `app` = ? AND `channel` = ? AND `id` NOT IN ( SELECT `id` FROM ( SELECT `id` FROM `chatmsgs` WHERE `channel` = ? AND `app` = ? ORDER BY `id` DESC LIMIT 50) foo );", [$secret, $channel, $channel, $secret]); + misc\cache\purge('KeyAuthChatMsgs:' . $secret . ':' . $channel); + die(api\v1_0\Encrypt(json_encode(array( + "success" => true, + "message" => "Successfully sent chat message" + )), $enckey)); + case 'log': + if (!($enabledFunctions & 32768)) { + + die(json_encode(array( + "success" => false, + "message" => "This function has been disabled by app owner, it can be enabled in Function Management on https://keyauth.cc/app/?page=app-settings." + ))); + } + // client isn't expecting a response body, just flush output right away so program can move on to rest of the code quicker + fastcgi_finish_request(); + + // retrieve session info + $sessionid = misc\etc\sanitize(hex2bin($_POST['sessionid'])); + $session = api\shared\primary\getSession($sessionid, $secret); + $enckey = $session["enckey"]; + + $credential = $session["credential"]; + + $currtime = time(); + + $msg = misc\etc\sanitize(api\v1_0\Decrypt($_POST['message'], $enckey)); + + if(is_null($msg)) { + die(); + } + + if(strlen($msg) > 275) { + die("Log data too long"); + } + + $pcuser = misc\etc\sanitize(api\v1_0\Decrypt($_POST['pcuser'], $enckey)); + + if (is_null($webhook)) { + $roleCheck = misc\cache\fetch('KeyAuthSellerCheck:' . $owner, "SELECT `role`,`expires` FROM `accounts` WHERE `username` = ?", [$owner], 0); + if($roleCheck['role'] == "tester") { + $query = misc\mysql\query("SELECT count(*) AS 'numLogs' FROM `logs` WHERE `logapp` = ?",[$secret]); + $row = mysqli_fetch_array($query->result); + $numLogs = $row["numLogs"]; + if($numLogs >= 20) { + die(); + } + } + + misc\mysql\query("INSERT INTO `logs` (`logdate`, `logdata`, `credential`, `pcuser`,`logapp`) VALUES (?, ?, NULLIF(?, ''), NULLIF(?, ''), ?)", [$currtime, $msg, $credential, $pcuser, $secret]); + die(); + } + + $credential = $session["credential"] ?? "N/A"; + + $msg = "📜 Log: " . $msg; + + $ip = api\shared\primary\getIp(); + + $json_data = json_encode([ + // Embeds Array + "embeds" => [ + [ + // Embed Title + "title" => $msg, + + // Embed left border color in HEX + "color" => hexdec("00ffe1"), + + // Additional Fields array + "fields" => [["name" => "🔐 Credential:", "value" => "```" . $credential . "```"], ["name" => "💻 PC Name:", "value" => "```" . $pcuser . "```", "inline" => true], ["name" => "🌎 Client IP:", "value" => "```" . $ip . "```", "inline" => true]] + ] + ] + + ], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); + + $ch = curl_init($webhook); + + curl_setopt($ch, CURLOPT_HTTPHEADER, array( + 'Content-type: application/json' + )); + + curl_setopt($ch, CURLOPT_POST, 1); + + curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data); + + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); + + curl_setopt($ch, CURLOPT_HEADER, 0); + + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + + $response = curl_exec($ch); + + curl_close($ch); + die(); + + case 'webhook': + if (!($enabledFunctions & 65536)) { + + die(json_encode(array( + "success" => false, + "message" => "This function has been disabled by app owner, it can be enabled in Function Management on https://keyauth.cc/app/?page=app-settings." + ))); + } + // retrieve session info + $sessionid = misc\etc\sanitize(hex2bin($_POST['sessionid'])); + $session = api\shared\primary\getSession($sessionid, $secret); + $enckey = $session["enckey"]; + + $webid = misc\etc\sanitize(api\v1_0\Decrypt($_POST['webid'], $enckey)); + + $row = misc\cache\fetch('KeyAuthWebhook:' . $secret . ':' . $webid, "SELECT `baselink`, `useragent`, `authed` FROM `webhooks` WHERE `webid` = ? AND `app` = ?", [$webid, $secret], 0); + if ($row == "not_found") { + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "Webhook Not Found." + )), $enckey)); + } + + $baselink = $row['baselink']; + + $useragent = $row['useragent']; + + $authed = $row['authed']; + + if ($authed) // if variable requires user to be authenticated + + { + if (!$session["validated"]) { + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "$sessionunauthed" + )), $enckey)); + } + } + + $params = misc\etc\sanitize(api\v1_0\Decrypt($_POST['params'], $enckey)); + $body = api\v1_0\Decrypt($_POST['body'], $enckey); + $contType = misc\etc\sanitize(api\v1_0\Decrypt($_POST['conttype'], $enckey)); + + $url = $baselink .= urldecode($params); + + $ch = curl_init($url); + + curl_setopt($ch, CURLOPT_USERAGENT, $useragent); + + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + + if (!is_null($body)) curl_setopt($ch, CURLOPT_POSTFIELDS, $body); + + if (!is_null($contType)) curl_setopt($ch, CURLOPT_HTTPHEADER, array( + 'Content-Type: ' . $contType + )); + + $response = curl_exec($ch); + die(api\v1_0\Encrypt(json_encode(array( + "success" => true, + "message" => "Webhook request successful", + "response" => "$response" + )), $enckey)); + case 'file': + if (!($enabledFunctions & 2048)) { + + die(json_encode(array( + "success" => false, + "message" => "This function has been disabled by app owner, it can be enabled in Function Management on https://keyauth.cc/app/?page=app-settings." + ))); + } + // retrieve session info + $sessionid = misc\etc\sanitize(hex2bin($_POST['sessionid'])); + $session = api\shared\primary\getSession($sessionid, $secret); + $enckey = $session["enckey"]; + + $fileid = misc\etc\sanitize(api\v1_0\Decrypt($_POST['fileid'], $enckey)); + + $row = misc\cache\fetch('KeyAuthFile:' . $secret . ':' . $fileid, "SELECT `name`, `url`, `authed` FROM `files` WHERE `app` = ? AND `id` = ?", [$secret, $fileid], 0); + + if ($row == "not_found") { + http_response_code(201); // putting a number above 200 so cloudflare worker won't cache + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "File not Found" + )), $enckey)); + } + + $filename = $row['name']; + $url = $row['url']; + $authed = $row['authed']; + + if ($authed) // if file requires user to be authenticated + + { + if (!$session["validated"]) { + http_response_code(202); // putting a number above 200 so cloudflare worker won't cache + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "$sessionunauthed" + )), $enckey)); + } + } + + ini_set('memory_limit', '-1'); + + $ch = curl_init($url); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla KeyAuth'); + $data = curl_exec($ch); + $statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); + + if ($statusCode == 403 || $statusCode == 404) { + http_response_code(203); // putting a number above 200 so cloudflare worker won't cache + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "File no longer works, please notify the application developer." + )), $enckey)); + } + $contents = bin2hex($data); + die(api\v1_0\Encrypt(json_encode(array( + "success" => true, + "message" => "File download successful", + "contents" => "$contents" + )), $enckey)); + + case 'ban': + if (!($enabledFunctions & 128)) { + + die(json_encode(array( + "success" => false, + "message" => "This function has been disabled by app owner, it can be enabled in Function Management on https://keyauth.cc/app/?page=app-settings." + ))); + } + // retrieve session info + $sessionid = misc\etc\sanitize(hex2bin($_POST['sessionid'])); + $session = api\shared\primary\getSession($sessionid, $secret); + $enckey = $session["enckey"]; + + $credential = $session["credential"]; + if (!$session["validated"]) { + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "$sessionunauthed" + )), $enckey)); + } + + $reason = misc\etc\sanitize($_POST['reason']) ?? "User banned from triggering ban function in the client"; + + if(strlen($reason) > 99) { + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "Reason must be 99 characters or less" + )), $enckey)); + } + + $hwid = misc\etc\sanitize(api\v1_0\Decrypt($_POST['hwid'], $enckey)); + if (!empty($hwid)) { + misc\blacklist\add($hwid, "Hardware ID", $secret); + } + $ip = api\shared\primary\getIp(); + misc\blacklist\add($ip, "IP Address", $secret); + + $query = misc\mysql\query("UPDATE `users` SET `banned` = ? WHERE `username` = ? AND `app` = ?", [$reason, $credential, $secret]); + + if ($query->affected_rows != 0) { + misc\cache\purge('KeyAuthUser:' . $secret . ':' . $credential); + die(api\v1_0\Encrypt(json_encode(array( + "success" => true, + "message" => "Successfully Banned User" + )), $enckey)); + } else { + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "Failed to ban user." + )), $enckey)); + } + case 'check': + if (!($enabledFunctions & 512)) { + + die(json_encode(array( + "success" => false, + "message" => "This function has been disabled by app owner, it can be enabled in Function Management on https://keyauth.cc/app/?page=app-settings." + ))); + } + // retrieve session info + $sessionid = misc\etc\sanitize(hex2bin($_POST['sessionid'])); + $session = api\shared\primary\getSession($sessionid, $secret); + $enckey = $session["enckey"]; + + $credential = $session["credential"]; + if (!$session["validated"]) { + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "$sessionunauthed" + )), $enckey)); + } else { + die(api\v1_0\Encrypt(json_encode(array( + "success" => true, + "message" => "Session is validated." + )), $enckey)); + } + case 'changeUsername': + if (!($enabledFunctions & 1024)) { + + die(json_encode(array( + "success" => false, + "message" => "This function has been disabled by app owner, it can be enabled in Function Management on https://keyauth.cc/app/?page=app-settings." + ))); + } + // retrieve session info + $sessionid = misc\etc\sanitize(hex2bin($_POST['sessionid'])); + $session = api\shared\primary\getSession($sessionid, $secret); + $enckey = $session["enckey"]; + + if (!$session["validated"]) { + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "$sessionunauthed" + )), $enckey)); + } + + $credential = $session["credential"]; + + $resp = misc\user\changeUsername($credential, $_POST['newUsername'], $secret); + switch ($resp) { + case 'already_used': + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "Username already used!" + )), $enckey)); + case 'failure': + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "Failed to change username!" + )), $enckey)); + case 'success': + misc\session\killSingular($sessionid, $secret); + die(api\v1_0\Encrypt(json_encode(array( + "success" => true, + "message" => "Successfully changed username, user logged out." + )), $enckey)); + default: + die(api\v1_0\Encrypt(json_encode(array( + "success" => false, + "message" => "Unhandled Error! Contact us if you need help" + )), $enckey)); + } + default: + die(json_encode(array( + "success" => false, + "message" => "Unhandled Type" + ))); +} diff --git a/api/1.1/index.php b/api/1.1/index.php new file mode 100644 index 0000000..6c2ed65 --- /dev/null +++ b/api/1.1/index.php @@ -0,0 +1,1268 @@ +getMessage()); + die(json_encode(array("success" => false, "message" => "Error: " . $errorMsg))); +}); + +if(empty(($_POST['ownerid'] ?? $_GET['ownerid']))) { + die(json_encode(array("success" => false, "message" => "No OwnerID specified. Select app & copy code snippet from https://keyauth.cc/app/"))); +} + +if(empty(($_POST['name'] ?? $_GET['name']))) { + die(json_encode(array("success" => false, "message" => "No app name specified. Select app & copy code snippet from https://keyauth.cc/app/"))); +} + +if(strlen(($_POST['ownerid'] ?? $_GET['ownerid'])) != 10) { + die(json_encode(array("success" => false, "message" => "OwnerID should be 10 characters long. Select app & copy code snippet from https://keyauth.cc/app/"))); +} + +$ownerid = misc\etc\sanitize($_POST['ownerid'] ?? $_GET['ownerid']); // ownerid of account that owns application +$name = misc\etc\sanitize($_POST['name'] ?? $_GET['name']); // application name +$row = misc\cache\fetch('KeyAuthApp:' . $name . ':' . $ownerid, "SELECT * FROM `apps` WHERE `ownerid` = ? AND `name` = ?", [$ownerid, $name], 0); + +if ($row == "not_found") { + die("KeyAuth_Invalid"); +} + +// app settings +$secret = $row['secret']; +$hwidenabled = $row['hwidcheck']; +$vpnblock = $row['vpnblock']; +$status = $row['enabled']; +$paused = $row['paused']; +$currentver = $row['ver']; +$download = $row['download']; +$webhook = $row['webhook']; +$appdisabled = $row['appdisabled']; +$hashcheck = $row['hashcheck']; +$serverhash = $row['hash']; +$sessionexpiry = $row['session']; +$forceHwid = $row['forceHwid']; + +$banned = $row['banned']; +$owner = $row['owner']; +$name = $row['name']; + +// custom error messages +$usernametaken = $row['usernametaken']; +$keynotfound = $row['keynotfound']; +$keyused = $row['keyused']; +$nosublevel = $row['nosublevel']; +$usernamenotfound = $row['usernamenotfound']; +$passmismatch = $row['passmismatch']; +$hwidmismatch = $row['hwidmismatch']; +$noactivesubs = $row['noactivesubs']; +$hwidblacked = $row['hwidblacked']; +$pausedsub = $row['pausedsub']; +$vpnblocked = $row['vpnblocked']; +$keybanned = $row['keybanned']; +$userbanned = $row['userbanned']; +$sessionunauthed = $row['sessionunauthed']; +$hashcheckfail = $row['hashcheckfail']; + +// why using null coalescing operators? because if I add a field and it's not in redis cache, it'll be NULL +$loggedInMsg = $row['loggedInMsg'] ?? "Logged in!"; +$pausedApp = $row['pausedApp'] ?? "Application is currently paused, please wait for the developer to say otherwise."; +$unTooShort = $row['unTooShort'] ?? "Username too short, try longer one."; +$pwLeaked = $row['pwLeaked'] ?? "This password has been leaked in a data breach (not from us), please use a different one."; +$chatHitDelay = $row['chatHitDelay'] ?? "Chat slower, you've hit the delay limit"; +$minHwid = $row['minHwid'] ?? 20; + +if ($banned) { + die(json_encode(array( + "success" => false, + "message" => "This application has been banned from KeyAuth.cc for violating terms." // yes we self promote to customers of those who break ToS. Should've followed terms :shrug: + ))); +} + + +$enabledFunctions = (int)$row['enabledFunctions']; + +switch ($_POST['type'] ?? $_GET['type']) { + case 'init': + $ip = api\shared\primary\getIp(); + if ($vpnblock) { + if (api\shared\primary\vpnCheck($ip)) { + $row = misc\cache\fetch('KeyAuthWhitelist:' . $secret . ':' . $ip, "SELECT 1 FROM `whitelist` WHERE `ip` = ? AND `app` = ?", [$ip, $secret], 0); + if ($row == "not_found") { + die(json_encode(array( + "success" => false, + "message" => "$vpnblocked" + ))); + } + } + } + + if (!$status) { + die(json_encode(array( + "success" => false, + "message" => "$appdisabled" + ))); + } + + if ($paused) { + die(json_encode(array( + "success" => false, + "message" => "$pausedApp" + ))); + } + + $ver = misc\etc\sanitize($_POST['ver'] ?? $_GET['ver']); + if (!empty($ver)) { + if ($ver != $currentver) { + // auto-update system + die(json_encode(array( + "success" => false, + "message" => "invalidver", + "download" => "$download" + ), JSON_UNESCAPED_SLASHES)); + } + } + + $hash = misc\etc\sanitize($_POST['hash'] ?? $_GET['hash']); + + if ($hashcheck) { + if (strpos($serverhash, $hash) === false) { + if (is_null($serverhash)) { + misc\mysql\query("UPDATE `apps` SET `hash` = ? WHERE `secret` = ?", [$hash, $secret]); + misc\cache\purge('KeyAuthApp:' . $name . ':' . $ownerid); // flush cache for application so new hash takes precedent + } else { + die(json_encode(array( + "success" => false, + "message" => "$hashcheckfail" + ))); + } + } + } + + $newSession = false; + $duplicateSession = misc\cache\select("KeyAuthSessionDupe:$secret:$ip"); + if($duplicateSession) { + $sessionid = $duplicateSession; + $updateSession = misc\cache\update('KeyAuthState:'.$secret.':'.$sessionid.'', array("validated" => 0)); + if(!$updateSession) { + $sessionid = misc\etc\generateRandomString(); + $newSession = true; + } + } + else { + $sessionid = misc\etc\generateRandomString(); + $newSession = true; + } + + // $row = misc\cache\fetch('KeyAuthAppStats:' . $secret, "SELECT (SELECT COUNT(1) FROM `users` WHERE `app` = ?) AS 'numUsers', (SELECT COUNT(1) FROM `sessions` WHERE `app` = ? AND `validated` = 1 AND `expiry` > ?) AS 'numOnlineUsers', (SELECT COUNT(1) FROM `keys` WHERE `app` = ?) AS 'numKeys' FROM dual", [$secret, $secret, time(), $secret], 0, 3600); + + $numUsers = "N/A - Use fetchStats() function in latest example"; + $numOnlineUsers = "N/A - Use fetchStats() function in latest example"; + $numKeys = "N/A - Use fetchStats() function in latest example"; + + echo json_encode(array( + "success" => true, + "message" => "Initialized", + "sessionid" => $sessionid, + "appinfo" => array( + "numUsers" => "$numUsers", + "numOnlineUsers" => "$numOnlineUsers", + "numKeys" => "$numKeys", + "version" => "$currentver", + "customerPanelLink" => "https://keyauth.cc/panel/$owner/$name/" + ) + )); + + fastcgi_finish_request(); + + if($newSession) { + misc\cache\insert("KeyAuthState:$secret:$sessionid", serialize(array("credential" => NULL, "enckey" => NULL, "validated" => 0)), $sessionexpiry); + $time = time() + $sessionexpiry; + misc\mysql\query("REPLACE INTO `sessions` (`id`, `app`, `expiry`, `created_at`, `ip`) VALUES (?, ?, ?, ?, ?)", [$sessionid, $secret, $time, time(), $ip]); + misc\cache\insert("KeyAuthSessionDupe:$secret:$ip", $sessionid, $sessionexpiry); + } + + case 'register': + if (!($enabledFunctions & 1)) { + + die(json_encode(array( + "success" => false, + "message" => "This function has been disabled by app owner, it can be enabled in Function Management on https://keyauth.cc/app/?page=app-settings." + ))); + } + // retrieve session info + $sessionid = misc\etc\sanitize($_POST['sessionid'] ?? $_GET['sessionid']); + $session = api\shared\primary\getSession($sessionid, $secret); + + // Read in username + $username = misc\etc\sanitize($_POST['username'] ?? $_GET['username']); + + if(strlen($username) > 70) { + die(json_encode(array( + "success" => false, + "message" => "Username must be shorter than 70 characters" + ))); + } + + // Read in license key + $checkkey = misc\etc\sanitize($_POST['key'] ?? $_GET['key']); + + if(strlen($checkkey) > 70) { + die(json_encode(array( + "success" => false, + "message" => "Key must be shorter than 70 characters" + ))); + } + + // Read in password + $password = misc\etc\sanitize($_POST['pass'] ?? $_GET['pass']); + + // Read in email + $email = misc\etc\sanitize($_POST['email'] ?? $_GET['email']); + + // Read in hwid + $hwid = misc\etc\sanitize($_POST['hwid'] ?? $_GET['hwid']); + + $resp = api\v1_0\register($username, $checkkey, $password, $email, $hwid, $secret); + switch ($resp) { + case 'username_taken': + die(json_encode(array( + "success" => false, + "message" => "$usernametaken" + ))); + case 'key_not_found': + die(json_encode(array( + "success" => false, + "message" => "$keynotfound" + ))); + case 'un_too_short': + die(json_encode(array( + "success" => false, + "message" => "$unTooShort" + ))); + case 'pw_leaked': + die(json_encode(array( + "success" => false, + "message" => "$pwLeaked" + ))); + case 'key_already_used': + die(json_encode(array( + "success" => false, + "message" => "$keyused" + ))); + case 'key_banned': + if (strpos($keybanned, '{reason}') !== false) { + $query = misc\mysql\query("SELECT `banned` FROM `keys` WHERE `app` = ? AND `key` = ?", [$secret, $checkkey]); + $row = mysqli_fetch_array($query->result); + $reason = $row['banned']; + $keybanned = str_replace("{reason}", $reason, $keybanned); + } + die(json_encode(array( + "success" => false, + "message" => "$keybanned" + ))); + case 'hwid_blacked': + die(json_encode(array( + "success" => false, + "message" => "$hwidblacked" + ))); + case 'no_subs_for_level': + die(json_encode(array( + "success" => false, + "message" => "$nosublevel" + ))); + default: + misc\mysql\query("UPDATE `sessions` SET `credential` = ?,`validated` = 1 WHERE `id` = ?", [$username, $sessionid]); + misc\cache\update('KeyAuthState:'.$secret.':'.$sessionid.'', array("validated" => 1, "credential" => $username)); + + $ip = api\shared\primary\getIp(); + die(json_encode(array( + "success" => true, + "message" => "$loggedInMsg", + "info" => $resp + ))); + } + case 'upgrade': + if (!($enabledFunctions & 262144)) { + + die(json_encode(array( + "success" => false, + "message" => "This function has been disabled by app owner, it can be enabled in Function Management on https://keyauth.cc/app/?page=app-settings." + ))); + } + // retrieve session info + $sessionid = misc\etc\sanitize($_POST['sessionid'] ?? $_GET['sessionid']); + $session = api\shared\primary\getSession($sessionid, $secret); + + // Read in username + $username = misc\etc\sanitize($_POST['username'] ?? $_GET['username']); + + // Read in key + $checkkey = misc\etc\sanitize($_POST['key'] ?? $_GET['key']); + + + // search for key + $query = misc\mysql\query("SELECT `banned`, `expires`, `status`, `level` FROM `keys` WHERE `key` = ? AND `app` = ?", [$checkkey, $secret]); + + // check if key exists + if ($query->num_rows < 1) { + die(json_encode(array( + "success" => false, + "message" => "$keynotfound" + ))); + } + + // 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']; + $banned = $row['banned']; + } + + // check if used + if ($status == "Used") { + die(json_encode(array( + "success" => false, + "message" => "$keyused" + ))); + } + + if (!is_null($banned)) { + if (strpos($keybanned, '{reason}') !== false) { + $keybanned = str_replace("{reason}", $banned, $keybanned); + } + die(json_encode(array( + "success" => false, + "message" => "$keybanned" + ))); + } + + // add current time to key time + $expiry = $expires + time(); + + $query = misc\mysql\query("SELECT `name` FROM `subscriptions` WHERE `app` = ? AND `level` = ?", [$secret, $level]); + $subName = mysqli_fetch_array($query->result)['name']; + + $resp = misc\user\extend($username, $subName, $expiry, 0, $secret); + switch ($resp) { + case 'missing': + die(json_encode(array( + "success" => false, + "message" => "$usernamenotfound" + ))); + case 'sub_missing': + die(json_encode(array( + "success" => false, + "message" => "$nosublevel" + ))); + case 'failure': + die(json_encode(array( + "success" => false, + "message" => "Failed to upgrade for some reason." + ))); + 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, $checkkey, $secret]); + misc\cache\purge('KeyAuthKeys:' . $secret . ':' . $checkkey); + misc\cache\purge('KeyAuthSubs:' . $secret . ':' . $username); + die(json_encode(array( + "success" => true, + "message" => "Upgraded successfully" + ))); + default: + die(json_encode(array( + "success" => false, + "message" => "Unhandled Error! Contact us if you need help" + ))); + } + } + + case 'login': + if (!($enabledFunctions & 1)) { + + die(json_encode(array( + "success" => false, + "message" => "This function has been disabled by app owner, it can be enabled in Function Management on https://keyauth.cc/app/?page=app-settings." + ))); + } + // retrieve session info + $sessionid = misc\etc\sanitize($_POST['sessionid'] ?? $_GET['sessionid']); + $session = api\shared\primary\getSession($sessionid, $secret); + + // Read in username + $username = misc\etc\sanitize($_POST['username'] ?? $_GET['username']); + + // Read in HWID + $hwid = misc\etc\sanitize($_POST['hwid'] ?? $_GET['hwid']); + + // Read in password + $password = misc\etc\sanitize($_POST['pass'] ?? $_GET['pass']); + + // optional param for web loader + $token = misc\etc\sanitize($_POST['token'] ?? $_GET['token']); + + if(strlen($hwid) < $minHwid && !is_null($hwid)) { + die(json_encode(array( + "success" => false, + "message" => "HWID must be {$minHwid} or more characters, change this in app settings." + ))); + } + + if($forceHwid && is_null($hwid)) { + die(json_encode(array( + "success" => false, + "message" => "Force HWID is enabled, disable in app settings if you want to use blank HWIDs" + ))); + } + + $resp = api\v1_0\login($username, $password, $hwid, $secret, $hwidenabled, $token); + switch ($resp) { + case 'un_not_found': + die(json_encode(array( + "success" => false, + "message" => "$usernamenotfound" + ))); + case 'pw_mismatch': + die(json_encode(array( + "success" => false, + "message" => "$passmismatch" + ))); + case 'user_banned': + if (strpos($userbanned, '{reason}') !== false) { + $query = misc\mysql\query("SELECT `banned` FROM `users` WHERE `app` = ? AND `username` = ?", [$secret, $username]); + $row = mysqli_fetch_array($query->result); + $reason = $row['banned']; + $userbanned = str_replace("{reason}", $reason, $userbanned); + } + die(json_encode(array( + "success" => false, + "message" => "$userbanned" + ))); + case 'hwid_mismatch': + die(json_encode(array( + "success" => false, + "message" => "$hwidmismatch" + ))); + case 'hwid_blacked': + die(json_encode(array( + "success" => false, + "message" => "$hwidblacked" + ))); + case 'sub_paused': + die(json_encode(array( + "success" => false, + "message" => "$pausedsub" + ))); + case 'no_active_subs': + die(json_encode(array( + "success" => false, + "message" => "$noactivesubs" + ))); + default: + misc\mysql\query("UPDATE `sessions` SET `validated` = 1,`credential` = ? WHERE `id` = ?", [$username, $sessionid]); + misc\cache\update('KeyAuthState:'.$secret.':'.$sessionid.'', array("validated" => 1, "credential" => $username)); + + $ip = api\shared\primary\getIp(); + die(json_encode(array( + "success" => true, + "message" => "$loggedInMsg", + "info" => $resp + ))); + } + + case 'license': + if (!($enabledFunctions & 4)) { + + die(json_encode(array( + "success" => false, + "message" => "This function has been disabled by app owner, it can be enabled in Function Management on https://keyauth.cc/app/?page=app-settings." + ))); + } + // retrieve session info + $sessionid = misc\etc\sanitize($_POST['sessionid'] ?? $_GET['sessionid']); + $session = api\shared\primary\getSession($sessionid, $secret); + $checkkey = misc\etc\sanitize($_POST['key'] ?? $_GET['key']); + + if(strlen($checkkey) > 70) { + die(json_encode(array( + "success" => false, + "message" => "Key must be shorter than 70 characters" + ))); + } + + $hwid = misc\etc\sanitize($_POST['hwid'] ?? $_GET['hwid']); + + if(strlen($hwid) < $minHwid && !is_null($hwid)) { + die(json_encode(array( + "success" => false, + "message" => "HWID must be {$minHwid} or more characters, change this in app settings." + ))); + } + + if($forceHwid && is_null($hwid)) { + die(json_encode(array( + "success" => false, + "message" => "Force HWID is enabled, disable in app settings if you want to use blank HWIDs" + ))); + } + + $resp = api\v1_0\login($checkkey, $checkkey, $hwid, $secret, $hwidenabled); + switch ($resp) { + case 'un_not_found': + break; // user not registered yet or user was deleted + case 'hwid_mismatch': + die(json_encode(array( + "success" => false, + "message" => "$hwidmismatch" + ))); + case 'user_banned': + if (strpos($userbanned, '{reason}') !== false) { + $query = misc\mysql\query("SELECT `banned` FROM `users` WHERE `app` = ? AND `username` = ?", [$secret, $checkkey]); + $row = mysqli_fetch_array($query->result); + $reason = $row['banned']; + $userbanned = str_replace("{reason}", $reason, $userbanned); + } + die(json_encode(array( + "success" => false, + "message" => "$userbanned" + ))); + case 'pw_mismatch': + die(json_encode(array( + "success" => false, + "message" => "$passmismatch" + ))); + case 'sub_paused': + die(json_encode(array( + "success" => false, + "message" => "$pausedsub" + ))); + case 'hwid_blacked': + die(json_encode(array( + "success" => false, + "message" => "$hwidblacked" + ))); + case 'no_active_subs': + die(json_encode(array( + "success" => false, + "message" => "$noactivesubs" + ))); + default: + misc\mysql\query("UPDATE `sessions` SET `validated` = 1,`credential` = ? WHERE `id` = ?", [$checkkey, $sessionid]); + misc\cache\update('KeyAuthState:'.$secret.':'.$sessionid.'', array("validated" => 1, "credential" => $checkkey)); + + $ip = api\shared\primary\getIp(); + die(json_encode(array( + "success" => true, + "message" => "$loggedInMsg", + "info" => $resp + ))); + } + + // if login didn't work, attempt to register + $resp = api\v1_0\register($checkkey, $checkkey, $checkkey, NULL, $hwid, $secret); + switch ($resp) { + case 'username_taken': + die(json_encode(array( + "success" => false, + "message" => "$usernametaken" + ))); + case 'key_not_found': + die(json_encode(array( + "success" => false, + "message" => "$keynotfound" + ))); + case 'un_too_short': + die(json_encode(array( + "success" => false, + "message" => "$unTooShort" + ))); + case 'pw_leaked': + die(json_encode(array( + "success" => false, + "message" => "$pwLeaked" + ))); + case 'key_already_used': + die(json_encode(array( + "success" => false, + "message" => "$keyused" + ))); + case 'key_banned': + if (strpos($keybanned, '{reason}') !== false) { + $query = misc\mysql\query("SELECT `banned` FROM `keys` WHERE `app` = ? AND `key` = ?", [$secret, $checkkey]); + $row = mysqli_fetch_array($query->result); + $reason = $row['banned']; + $keybanned = str_replace("{reason}", $reason, $keybanned); + } + die(json_encode(array( + "success" => false, + "message" => "$keybanned" + ))); + case 'hwid_blacked': + die(json_encode(array( + "success" => false, + "message" => "$hwidblacked" + ))); + case 'no_subs_for_level': + die(json_encode(array( + "success" => false, + "message" => "$nosublevel" + ))); + default: + misc\mysql\query("UPDATE `sessions` SET `validated` = 1,`credential` = ? WHERE `id` = ?", [$checkkey, $sessionid]); + misc\cache\update('KeyAuthState:'.$secret.':'.$sessionid.'', array("validated" => 1, "credential" => $checkkey)); + + $ip = api\shared\primary\getIp(); + die(json_encode(array( + "success" => true, + "message" => "$loggedInMsg", + "info" => $resp + ))); + } + case 'fetchOnline': + if (!($enabledFunctions & 4096)) { + + die(json_encode(array( + "success" => false, + "message" => "This function has been disabled by app owner, it can be enabled in Function Management on https://keyauth.cc/app/?page=app-settings." + ))); + } + $sessionid = misc\etc\sanitize($_POST['sessionid'] ?? $_GET['sessionid']); + $session = api\shared\primary\getSession($sessionid, $secret); + + $rows = misc\cache\fetch('KeyAuthOnlineUsers:' . $secret, "SELECT DISTINCT CONCAT(LEFT(`credential`, 10), IF(LENGTH(`credential`) > 10, REPEAT('*', LENGTH(`credential`) - 10), '')) AS `credential` FROM `sessions` WHERE `validated` = 1 AND `app` = ?", [$secret], 1, 1800); + + if ($rows == "not_found") { + die(json_encode(array( + "success" => false, + "message" => "No online users found!" + ))); + } + + die(json_encode(array( + "success" => true, + "message" => "Successfully fetched online users.", + "users" => $rows + ))); + case 'setvar': + if (!($enabledFunctions & 64)) { + + die(json_encode(array( + "success" => false, + "message" => "This function has been disabled by app owner, it can be enabled in Function Management on https://keyauth.cc/app/?page=app-settings." + ))); + } + $sessionid = misc\etc\sanitize($_POST['sessionid'] ?? $_GET['sessionid']); + $session = api\shared\primary\getSession($sessionid, $secret); + if (!$session["validated"]) { + die(json_encode(array( + "success" => false, + "message" => "$sessionunauthed" + ))); + } + + $var = misc\etc\sanitize($_POST['var'] ?? $_GET['var']); + $data = misc\etc\sanitize($_POST['data'] ?? $_GET['data']); + + if(is_null($var)) { + die(json_encode(array( + "success" => true, + "message" => "No variable name provided" + ))); + } + + if(is_null($data)) { + die(json_encode(array( + "success" => true, + "message" => "No variable data provided" + ))); + } + + if(strlen($data) > 500) { + die(json_encode(array( + "success" => true, + "message" => "Variable data must be 500 characters or less" + ))); + } + + $row = misc\cache\fetch('KeyAuthUserVar:' . $secret . ':' . $var . ':' . $session["credential"], "SELECT `data`, `readOnly` FROM `uservars` WHERE `name` = ? AND `user` = ? AND `app` = ?", [$var, $session["credential"], $secret], 0); + + if ($row != "not_found") { + $readOnly = $row["readOnly"]; + if ($readOnly) { + die(json_encode(array( + "success" => true, + "message" => "Variable is read only" + ))); + } + } + + $query = misc\mysql\query("REPLACE INTO `uservars` (`name`, `data`, `user`, `app`) VALUES (?, ?, ?, ?)", [$var, $data, $session["credential"], $secret]); + + if ($query->affected_rows != 0) { + misc\cache\purge('KeyAuthUserVar:' . $secret . ':' . $var . ':' . $session["credential"]); + die(json_encode(array( + "success" => true, + "message" => "Successfully set variable" + ))); + } else { + die(json_encode(array( + "success" => false, + "message" => "Failed to set variable" + ))); + } + case 'getvar': + if (!($enabledFunctions & 32)) { + + die(json_encode(array( + "success" => false, + "message" => "This function has been disabled by app owner, it can be enabled in Function Management on https://keyauth.cc/app/?page=app-settings." + ))); + } + $sessionid = misc\etc\sanitize($_POST['sessionid'] ?? $_GET['sessionid']); + $session = api\shared\primary\getSession($sessionid, $secret); + if (!$session["validated"]) { + die(json_encode(array( + "success" => false, + "message" => "$sessionunauthed" + ))); + } + + $var = misc\etc\sanitize($_POST['var'] ?? $_GET['var']); + + $row = misc\cache\fetch('KeyAuthUserVar:' . $secret . ':' . $var . ':' . $session["credential"], "SELECT `data`, `readOnly` FROM `uservars` WHERE `name` = ? AND `user` = ? AND `app` = ?", [$var, $session["credential"], $secret], 0); + + if ($row == "not_found") { + die(json_encode(array( + "success" => false, + "message" => "Variable not found for user" + ))); + } + + $data = $row['data']; + die(json_encode(array( + "success" => true, + "message" => "Successfully retrieved variable", + "response" => $data + ))); + case 'var': + if (!($enabledFunctions & 131072)) { + + die(json_encode(array( + "success" => false, + "message" => "This function has been disabled by app owner, it can be enabled in Function Management on https://keyauth.cc/app/?page=app-settings." + ))); + } + // retrieve session info + $sessionid = misc\etc\sanitize($_POST['sessionid'] ?? $_GET['sessionid']); + $session = api\shared\primary\getSession($sessionid, $secret); + + $varid = misc\etc\sanitize($_POST['varid'] ?? $_GET['varid']); + + $row = misc\cache\fetch('KeyAuthVar:' . $secret . ':' . $varid, "SELECT `msg`, `authed` FROM `vars` WHERE `varid` = ? AND `app` = ?", [$varid, $secret], 0); + + if ($row == "not_found") { + die(json_encode(array( + "success" => false, + "message" => "Variable not found." + ))); + } + + $msg = $row['msg']; + $authed = $row['authed']; + + if ($authed) // if variable requires user to be authenticated + + { + if (!$session["validated"]) { + die(json_encode(array( + "success" => false, + "message" => "$sessionunauthed" + ))); + } + } + die(json_encode(array( + "success" => true, + "message" => "$msg" + ))); + case 'checkblacklist': + // retrieve session info + $sessionid = misc\etc\sanitize($_POST['sessionid'] ?? $_GET['sessionid']); + $session = api\shared\primary\getSession($sessionid, $secret); + + $hwid = misc\etc\sanitize($_POST['hwid'] ?? $_GET['hwid']); + $ip = api\shared\primary\getIp(); + + $row = misc\cache\fetch('KeyAuthBlacklist:' . $secret . ':' . $ip . ':' . $hwid, "SELECT 1 FROM `bans` WHERE (`hwid` = ? OR `ip` = ?) AND `app` = ?", [$hwid, $ip, $secret], 0); + + if ($row != "not_found") { + die(json_encode(array( + "success" => true, + "message" => "Client is blacklisted" + ))); + } else { + die(json_encode(array( + "success" => false, + "message" => "Client is not blacklisted" + ))); + } + case 'chatget': + if (!($enabledFunctions & 8)) { + + die(json_encode(array( + "success" => false, + "message" => "This function has been disabled by app owner, it can be enabled in Function Management on https://keyauth.cc/app/?page=app-settings." + ))); + } + // retrieve session info + $sessionid = misc\etc\sanitize($_POST['sessionid'] ?? $_GET['sessionid']); + $session = api\shared\primary\getSession($sessionid, $secret); + if (!$session["validated"]) { + die(json_encode(array( + "success" => false, + "message" => "$sessionunauthed" + ))); + } + + $channel = misc\etc\sanitize($_POST['channel'] ?? $_GET['channel']); + $rows = misc\cache\fetch('KeyAuthChatMsgs:' . $secret . ':' . $channel, "SELECT `author`, `message`, `timestamp` FROM `chatmsgs` WHERE `channel` = ? AND `app` = ?", [$channel, $secret], 1); + + if ($rows == "not_found") { + $rows = []; + } + + die(json_encode(array( + "success" => true, + "message" => "Successfully retrieved chat messages", + "messages" => $rows + ))); + case 'chatsend': + if (!($enabledFunctions & 16)) { + + die(json_encode(array( + "success" => false, + "message" => "This function has been disabled by app owner, it can be enabled in Function Management on https://keyauth.cc/app/?page=app-settings." + ))); + } + // retrieve session info + $sessionid = misc\etc\sanitize($_POST['sessionid'] ?? $_GET['sessionid']); + $session = api\shared\primary\getSession($sessionid, $secret); + if (!$session["validated"]) { + die(json_encode(array( + "success" => false, + "message" => "$sessionunauthed" + ))); + } + + $channel = misc\etc\sanitize($_POST['channel'] ?? $_GET['channel']); + $query = misc\mysql\query("SELECT `delay` FROM `chats` WHERE `name` = ? AND `app` = ?", [$channel, $secret]); + + if ($query->num_rows < 1) { + die(json_encode(array( + "success" => false, + "message" => "Chat channel not found" + ))); + } + + $row = mysqli_fetch_array($query->result); + $delay = $row['delay']; + $credential = $session["credential"]; + $query = misc\mysql\query("SELECT `timestamp` FROM `chatmsgs` WHERE `author` = ? AND `channel` = ? AND `app` = ? ORDER BY `id` DESC LIMIT 1", [$credential, $channel, $secret]); + + $row = mysqli_fetch_array($query->result); + $time = $row['timestamp']; + + if (time() - $time < $delay) { + die(json_encode(array( + "success" => false, + "message" => "$chatHitDelay" + ))); + } + + $query = misc\mysql\query("SELECT `time` FROM `chatmutes` WHERE `user` = ? AND `app` = ?", [$credential, $secret]); + if ($query->num_rows != 0) { + $row = mysqli_fetch_array($query->result); + $unmuted = $row["time"]; + $unmuted = date("F j, Y, g:i a", $unmuted); + die(json_encode(array( + "success" => false, + "message" => "You're muted from chat until $unmuted" + ))); + } + + $message = misc\etc\sanitize($_POST['message'] ?? $_GET['message']); + + if (is_null($message)) { + die(json_encode(array( + "success" => false, + "message" => "Message can't be blank" + ))); + } + + if(strlen($message) > 2000) { + die(json_encode(array( + "success" => false, + "message" => "Message too long!" + ))); + } + + misc\mysql\query("INSERT INTO `chatmsgs` (`author`, `message`, `timestamp`, `channel`,`app`) VALUES (?, ?, ?, ?, ?)", [$credential, $message, time(), $channel, $secret]); + misc\mysql\query("DELETE FROM `chatmsgs` WHERE `app` = ? AND `channel` = ? AND `id` NOT IN ( SELECT `id` FROM ( SELECT `id` FROM `chatmsgs` WHERE `channel` = ? AND `app` = ? ORDER BY `id` DESC LIMIT 50) foo );", [$secret, $channel, $channel, $secret]); + misc\cache\purge('KeyAuthChatMsgs:' . $secret . ':' . $channel); + die(json_encode(array( + "success" => true, + "message" => "Successfully sent chat message" + ))); + case 'log': + if (!($enabledFunctions & 32768)) { + + die(json_encode(array( + "success" => false, + "message" => "This function has been disabled by app owner, it can be enabled in Function Management on https://keyauth.cc/app/?page=app-settings." + ))); + } + // client isn't expecting a response body, just flush output right away so program can move on to rest of the code quicker + fastcgi_finish_request(); + + // retrieve session info + $sessionid = misc\etc\sanitize($_POST['sessionid'] ?? $_GET['sessionid']); + $session = api\shared\primary\getSession($sessionid, $secret); + + $credential = $session["credential"]; + + $currtime = time(); + + $msg = misc\etc\sanitize($_POST['message'] ?? $_GET['message']); + + if(is_null($msg)) { + die(); + } + + if(strlen($msg) > 275) { + die("Log data too long"); + } + + $pcuser = misc\etc\sanitize($_POST['pcuser'] ?? $_GET['pcuser']); + + if (is_null($webhook)) { + $roleCheck = misc\cache\fetch('KeyAuthSellerCheck:' . $owner, "SELECT `role`,`expires` FROM `accounts` WHERE `username` = ?", [$owner], 0); + if($roleCheck['role'] == "tester") { + $query = misc\mysql\query("SELECT count(*) AS 'numLogs' FROM `logs` WHERE `logapp` = ?",[$secret]); + $row = mysqli_fetch_array($query->result); + $numLogs = $row["numLogs"]; + if($numLogs >= 20) { + die(); + } + } + + misc\mysql\query("INSERT INTO `logs` (`logdate`, `logdata`, `credential`, `pcuser`,`logapp`) VALUES (?, ?, NULLIF(?, ''), NULLIF(?, ''), ?)", [$currtime, $msg, $credential, $pcuser, $secret]); + die(); + } + + $credential = $session["credential"] ?? "N/A"; + + $msg = "📜 Log: " . $msg; + + $ip = api\shared\primary\getIp(); + + $json_data = json_encode([ + // Embeds Array + "embeds" => [ + [ + // Embed Title + "title" => $msg, + + // Embed left border color in HEX + "color" => hexdec("00ffe1"), + + // Additional Fields array + "fields" => [["name" => "🔐 Credential:", "value" => "```" . $credential . "```"], ["name" => "💻 PC Name:", "value" => "```" . $pcuser . "```", "inline" => true], ["name" => "🌎 Client IP:", "value" => "```" . $ip . "```", "inline" => true]] + ] + ] + + ], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); + + $ch = curl_init($webhook); + + curl_setopt($ch, CURLOPT_HTTPHEADER, array( + 'Content-type: application/json' + )); + + curl_setopt($ch, CURLOPT_POST, 1); + + curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data); + + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); + + curl_setopt($ch, CURLOPT_HEADER, 0); + + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + + $response = curl_exec($ch); + + // If you need to debug, or find out why you can't send message uncomment line below, and execute script. + // echo $response; + curl_close($ch); + die(); + + case 'webhook': + if (!($enabledFunctions & 65536)) { + + die(json_encode(array( + "success" => false, + "message" => "This function has been disabled by app owner, it can be enabled in Function Management on https://keyauth.cc/app/?page=app-settings." + ))); + } + // retrieve session info + $sessionid = misc\etc\sanitize($_POST['sessionid'] ?? $_GET['sessionid']); + $session = api\shared\primary\getSession($sessionid, $secret); + + $webid = misc\etc\sanitize($_POST['webid'] ?? $_GET['webid']); + $row = misc\cache\fetch('KeyAuthWebhook:' . $secret . ':' . $webid, "SELECT `baselink`, `useragent`, `authed` FROM `webhooks` WHERE `webid` = ? AND `app` = ?", [$webid, $secret], 0); + if ($row == "not_found") { + die(json_encode(array( + "success" => false, + "message" => "Webhook Not Found." + ))); + } + + $baselink = $row['baselink']; + $useragent = $row['useragent']; + $authed = $row['authed']; + + if ($authed) // if variable requires user to be authenticated + + { + if (!$session["validated"]) { + die(json_encode(array( + "success" => false, + "message" => "$sessionunauthed" + ))); + } + } + + $params = misc\etc\sanitize($_POST['params'] ?? $_GET['params']); + $body = $_POST['body'] ?? $_GET['body']; + $contType = misc\etc\sanitize($_POST['conttype'] ?? $_GET['conttype']); + + $url = $baselink .= urldecode($params); + + $ch = curl_init($url); + + curl_setopt($ch, CURLOPT_USERAGENT, $useragent); + + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + + if (!is_null($body) && !empty($body)) + curl_setopt($ch, CURLOPT_POSTFIELDS, $body); + + if (!is_null($contType)) + curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: ' . $contType)); + + $response = curl_exec($ch); + + die(json_encode(array( + "success" => true, + "message" => "Webhook request successful", + "response" => "$response" + ))); + case 'file': + if (!($enabledFunctions & 2048)) { + + die(json_encode(array( + "success" => false, + "message" => "This function has been disabled by app owner, it can be enabled in Function Management on https://keyauth.cc/app/?page=app-settings." + ))); + } + // retrieve session info + $sessionid = misc\etc\sanitize($_POST['sessionid'] ?? $_GET['sessionid']); + $session = api\shared\primary\getSession($sessionid, $secret); + + $fileid = misc\etc\sanitize($_POST['fileid'] ?? $_GET['fileid']); + + $row = misc\cache\fetch('KeyAuthFile:' . $secret . ':' . $fileid, "SELECT `name`, `url`, `authed` FROM `files` WHERE `app` = ? AND `id` = ?", [$secret, $fileid], 0); + + if ($row == "not_found") { + http_response_code(201); // putting a number above 200 so cloudflare worker won't cache + die(json_encode(array( + "success" => false, + "message" => "File not Found" + ))); + } + + $filename = $row['name']; + $url = $row['url']; + $authed = $row['authed']; + + if ($authed) // if file requires user to be authenticated + + { + if (!$session["validated"]) { + http_response_code(202); // putting a number above 200 so cloudflare worker won't cache + die(json_encode(array( + "success" => false, + "message" => "$sessionunauthed" + ))); + } + } + + ini_set('memory_limit', '-1'); + + $ch = curl_init($url); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla KeyAuth'); + $data = curl_exec($ch); + $statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); + + if ($statusCode == 403 || $statusCode == 404) { + http_response_code(203); // putting a number above 200 so cloudflare worker won't cache + die(json_encode(array( + "success" => false, + "message" => "File no longer works, please notify the application developer." + ))); + } + $contents = bin2hex($data); + + die(json_encode(array( + "success" => true, + "message" => "File download successful", + "contents" => "$contents" + ))); + + case 'ban': + if (!($enabledFunctions & 128)) { + + die(json_encode(array( + "success" => false, + "message" => "This function has been disabled by app owner, it can be enabled in Function Management on https://keyauth.cc/app/?page=app-settings." + ))); + } + // retrieve session info + $sessionid = misc\etc\sanitize($_POST['sessionid'] ?? $_GET['sessionid']); + $session = api\shared\primary\getSession($sessionid, $secret); + + $credential = $session["credential"]; + if (!$session["validated"]) { + die(json_encode(array( + "success" => false, + "message" => "$sessionunauthed" + ))); + } + + $reason = misc\etc\sanitize($_POST['reason'] ?? $_GET['reason']) ?? "User banned from triggering ban function in the client"; + + if(strlen($reason) > 99) { + die(json_encode(array( + "success" => false, + "message" => "Reason must be 99 characters or less" + ))); + } + + $hwid = misc\etc\sanitize($_POST['hwid'] ?? $_GET['hwid']); + if (!empty($hwid)) { + misc\blacklist\add($hwid, "Hardware ID", $secret); + } + $ip = api\shared\primary\getIp(); + misc\blacklist\add($ip, "IP Address", $secret); + + $query = misc\mysql\query("UPDATE `users` SET `banned` = ? WHERE `username` = ? AND `app` = ?", [$reason, $credential, $secret]); + if ($query->affected_rows != 0) { + misc\cache\purge('KeyAuthUser:' . $secret . ':' . $credential); + die(json_encode(array( + "success" => true, + "message" => "Successfully Banned User" + ))); + } else { + die(json_encode(array( + "success" => false, + "message" => "Failed to ban user." + ))); + } + case 'check': + if (!($enabledFunctions & 512)) { + + die(json_encode(array( + "success" => false, + "message" => "This function has been disabled by app owner, it can be enabled in Function Management on https://keyauth.cc/app/?page=app-settings." + ))); + } + // retrieve session info + $sessionid = misc\etc\sanitize($_POST['sessionid'] ?? $_GET['sessionid']); + $session = api\shared\primary\getSession($sessionid, $secret); + + $credential = $session["credential"]; + if (!$session["validated"]) { + die(json_encode(array( + "success" => false, + "message" => "$sessionunauthed" + ))); + } else { + die(json_encode(array( + "success" => true, + "message" => "Session is validated." + ))); + } + case 'changeUsername': + if (!($enabledFunctions & 1024)) { + + die(json_encode(array( + "success" => false, + "message" => "This function has been disabled by app owner, it can be enabled in Function Management on https://keyauth.cc/app/?page=app-settings." + ))); + } + $sessionid = misc\etc\sanitize($_POST['sessionid'] ?? $_GET['sessionid']); + $session = api\shared\primary\getSession($sessionid, $secret); + + if (!$session["validated"]) { + die(json_encode(array( + "success" => false, + "message" => "$sessionunauthed" + ))); + } + + $credential = $session["credential"]; + + $resp = misc\user\changeUsername($credential, $_POST['newUsername'] ?? $_GET['newUsername'], $secret); + switch ($resp) { + case 'already_used': + die(json_encode(array( + "success" => false, + "message" => "Username already used!" + ))); + case 'failure': + die(json_encode(array( + "success" => false, + "message" => "Failed to change username!" + ))); + case 'success': + misc\session\killSingular($sessionid, $secret); + die(json_encode(array( + "success" => true, + "message" => "Successfully changed username, user logged out." + ))); + default: + die(json_encode(array( + "success" => false, + "message" => "Unhandled Error! Contact us if you need help" + ))); + } + default: + die(json_encode(array( + "success" => false, + "message" => "The value inputted for type paramater was not found" + ))); +} diff --git a/api/1.2/index.php b/api/1.2/index.php new file mode 100644 index 0000000..4da24f5 --- /dev/null +++ b/api/1.2/index.php @@ -0,0 +1,2071 @@ + false, "message" => "Error: " . $exception->getMessage()))); +}); + +if(empty(($_POST['ownerid'] ?? $_GET['ownerid']))) { + die(json_encode(array("success" => false, "message" => "No OwnerID specified. Select app & copy code snippet from https://keyauth.cc/app/"))); +} + +if(empty(($_POST['name'] ?? $_GET['name']))) { + die(json_encode(array("success" => false, "message" => "No app name specified. Select app & copy code snippet from https://keyauth.cc/app/"))); +} + +if(strlen(($_POST['ownerid'] ?? $_GET['ownerid'])) != 10) { + die(json_encode(array("success" => false, "message" => "OwnerID should be 10 characters long. Select app & copy code snippet from https://keyauth.cc/app/"))); +} + +include '../../includes/misc/autoload.phtml'; +include '../../includes/api/shared/autoload.phtml'; +include '../../includes/api/1.0/autoload.phtml'; + +if($_POST['ownerid'] != "OEYrdeqNme"){ + $rateLimit = ($_POST['ownerid'] != "OEYrdeqNme") ? 850 : 350; + + if (misc\cache\rateLimit("KeyAuthAppLimit:" . ($_POST['ownerid'] ?? $_GET['ownerid']), 1, 60, $rateLimit)){ + die(json_encode(array("success" => false, "message" => "This application has sent too many requests. Try again later."))); + } +} + +$ownerid = misc\etc\sanitize($_POST['ownerid'] ?? $_GET['ownerid']); // ownerid of account that owns application +$name = misc\etc\sanitize($_POST['name'] ?? $_GET['name']); // application name +$row = misc\cache\fetch('KeyAuthApp:' . $name . ':' . $ownerid, "SELECT * FROM `apps` WHERE `ownerid` = ? AND `name` = ?", [$ownerid, $name], 0); + +if ($row == "not_found") { + die("KeyAuth_Invalid"); +} + +// app settings +$secret = $row['secret']; +$hwidenabled = $row['hwidcheck']; +$vpnblock = $row['vpnblock']; +$status = $row['enabled']; +$paused = $row['paused']; +$currentver = $row['ver']; +$download = $row['download']; +$webhook = $row['webhook']; +$appdisabled = $row['appdisabled']; +$hashcheck = $row['hashcheck']; +$serverhash = $row['hash']; +$sessionexpiry = $row['session']; +$forceEncryption = $row['forceEncryption']; +$forceHwid = $row['forceHwid']; +$tokensystem = $row['tokensystem']; + +$banned = $row['banned']; +$owner = $row['owner']; +$name = $row['name']; + +// custom error messages +$usernametaken = $row['usernametaken']; +$keynotfound = $row['keynotfound']; +$keyused = $row['keyused']; +$nosublevel = $row['nosublevel']; +$usernamenotfound = $row['usernamenotfound']; +$passmismatch = $row['passmismatch']; +$hwidmismatch = $row['hwidmismatch']; +$noactivesubs = $row['noactivesubs']; +$hwidblacked = $row['hwidblacked']; +$pausedsub = $row['pausedsub']; +$vpnblocked = $row['vpnblocked']; +$keybanned = $row['keybanned']; +$userbanned = $row['userbanned']; +$sessionunauthed = $row['sessionunauthed']; +$hashcheckfail = $row['hashcheckfail']; +$invalid_token = $row['tokeninvalid']; + +// why using null coalescing operators? because if I add a field and it's not in redis cache, it'll be NULL +$loggedInMsg = $row['loggedInMsg'] ?? "Logged in!"; +$pausedApp = $row['pausedApp'] ?? "Application is currently paused, please wait for the developer to say otherwise."; +$unTooShort = $row['unTooShort'] ?? "Username too short, try longer one."; +$pwLeaked = $row['pwLeaked'] ?? "This password has been leaked in a data breach (not from us), please use a different one."; +$chatHitDelay = $row['chatHitDelay'] ?? "Chat slower, you've hit the delay limit"; +$minHwid = $row['minHwid'] ?? 20; + +if ($banned) { + die(json_encode(array( + "success" => false, + "message" => "This application has been banned from KeyAuth.cc for violating terms." // yes we self promote to customers of those who break ToS. Should've followed terms :shrug: + ))); +} + +$enabledFunctions = (int)$row['enabledFunctions']; + +switch ($_POST['type'] ?? $_GET['type']) { + case 'init': + if(strlen($_POST['enckey']) > 35) { + $response = json_encode(array( + "success" => false, + "message" => "The paramater \"enckey\" is too long. Must be 35 characters or less." + )); + + $sig = hash_hmac('sha256', $response, $secret); + header("signature: {$sig}"); + + die($response); + } + + if ($forceEncryption) { + if (!isset($_POST['enckey']) && !isset($_GET['enckey'])) { + $response = json_encode(array( + "success" => false, + "message" => "No encryption key supplied, encryption is forced." + )); + + $sig = hash_hmac('sha256', $response, $secret); + header("signature: {$sig}"); + + die($response); + } + } + $ip = api\shared\primary\getIp(); + if ($vpnblock) { + if (api\shared\primary\vpnCheck($ip)) { + $row = misc\cache\fetch('KeyAuthWhitelist:' . $secret . ':' . $ip, "SELECT 1 FROM `whitelist` WHERE `ip` = ? AND `app` = ?", [$ip, $secret], 0); + if ($row == "not_found") { + $response = json_encode(array( + "success" => false, + "message" => "$vpnblocked" + )); + + $sig = hash_hmac('sha256', $response, $secret); + header("signature: {$sig}"); + + die($response); + } + } + } + + if (!$status) { + $response = json_encode(array( + "success" => false, + "message" => "$appdisabled" + )); + + $sig = hash_hmac('sha256', $response, $secret); + header("signature: {$sig}"); + + die($response); + } + + if ($paused) { + $response = json_encode(array( + "success" => false, + "message" => "$pausedApp" + )); + + $sig = hash_hmac('sha256', $response, $secret); + header("signature: {$sig}"); + + die($response); + } + + if ($tokensystem) { + + list($token, $thash) = [misc\etc\sanitize($_POST["token"] ?? $_GET["token"]) , misc\etc\sanitize($_POST["thash"] ?? $_GET["thash"])]; + + if (!isset($token)) { + + $response = json_encode(array( + "success" => false, + "message" => "Token Must Be Provided" + )); + + $sig = hash_hmac('sha256', $response, $secret); + header("signature: {$sig}"); + + die($response); + } + + if (!isset($thash)) { + $response = json_encode(array( + "success" => false, + "message" => "Hash Must Be Provided" + )); + + $sig = hash_hmac('sha256', $response, $secret); + header("signature: {$sig}"); + + die($response); + } + + $verification = misc\token\checktoken("check_data", $token, $secret, null, $thash); + + switch ($verification) { + case str_contains($verification, 'token_blacklisted'): + $reason = str_ireplace("token_blacklisted, ", "", $verification); + $response = json_encode(array( + "success" => false, + "message" => "The Token Has Been Blacklisted For The Following Reason: " . $reason . " Contact Application Developer If This Is A Mistake" + )); + + $sig = hash_hmac('sha256', $response, $secret); + header("signature: {$sig}"); + + die($response); + case 'invalid_token': + + $response = json_encode(array( + "success" => false, + "message" => $invalid_token + )); + + $sig = hash_hmac('sha256', $response, $secret); + header("signature: {$sig}"); + + die($response); + + case 'hash_mismatch': + + $response = json_encode(array( + "success" => false, + "message" => "Token File Hashes Must Be The Same" + )); + + $sig = hash_hmac('sha256', $response, $secret); + header("signature: {$sig}"); + + die($response); + + case 'success': + break; + + default: + + $response = json_encode(array( + "success" => false, + "message" => "Unknown Error Occured" + )); + + $sig = hash_hmac('sha256', $response, $secret); + header("signature: {$sig}"); + + die($response); + + } + } + + $ver = misc\etc\sanitize($_POST['ver'] ?? $_GET['ver']); + if (!empty($ver)) { + if ($ver != $currentver) { + // auto-update system + $response = json_encode(array( + "success" => false, + "message" => "invalidver", + "download" => "$download" + ), JSON_UNESCAPED_SLASHES); + + $sig = hash_hmac('sha256', $response, $secret); + header("signature: {$sig}"); + + die($response); + } + } + + $hash = misc\etc\sanitize($_POST['hash'] ?? $_GET['hash']); + + if ($hashcheck) { + if (strpos($serverhash, $hash) === false) { + if (is_null($serverhash)) { + misc\mysql\query("UPDATE `apps` SET `hash` = ? WHERE `secret` = ?", [$hash, $secret]); + misc\cache\purge('KeyAuthApp:' . $name . ':' . $ownerid); // flush cache for application so new hash takes precedent + } else { + $response = json_encode(array( + "success" => false, + "message" => "$hashcheckfail" + )); + + $sig = hash_hmac('sha256', $response, $secret); + header("signature: {$sig}"); + + die($response); + } + } + } + + $enckey = !is_null($_POST['enckey'] ?? $_GET['enckey']) ? misc\etc\sanitize($_POST['enckey'] ?? $_GET['enckey']) . "-" . $secret : NULL; + $newSession = false; + $duplicateSession = misc\cache\select("KeyAuthSessionDupe:$secret:$ip"); + if($duplicateSession) { + $sessionid = $duplicateSession; + + $updateSession = misc\cache\update('KeyAuthState:'.$secret.':'.$sessionid.'', array("validated" => 0, "enckey" => $enckey)); + if(!$updateSession) { + $sessionid = misc\etc\generateRandomString(); + $newSession = true; + } + } + else { + $sessionid = misc\etc\generateRandomString(); + $newSession = true; + } + + // $row = misc\cache\fetch('KeyAuthAppStats:' . $secret, "SELECT (SELECT COUNT(1) FROM `users` WHERE `app` = ?) AS 'numUsers', (SELECT COUNT(1) FROM `sessions` WHERE `app` = ? AND `validated` = 1 AND `expiry` > ?) AS 'numOnlineUsers', (SELECT COUNT(1) FROM `keys` WHERE `app` = ?) AS 'numKeys' FROM dual", [$secret, $secret, time(), $secret], 0, 3600); + + $numUsers = "N/A - Use fetchStats() function in latest example"; + $numOnlineUsers = "N/A - Use fetchStats() function in latest example"; + $numKeys = "N/A - Use fetchStats() function in latest example"; + + $resp = json_encode(array( + "success" => true, + "message" => "Initialized", + "sessionid" => $sessionid, + "ownerid" => $ownerid, + "appinfo" => array( + "numUsers" => "$numUsers", + "numOnlineUsers" => "$numOnlineUsers", + "numKeys" => "$numKeys", + "version" => "$currentver", + "customerPanelLink" => "https://keyauth.cc/panel/$owner/$name/" + ), + "newSession" => $newSession, + "nonce" => misc\etc\generateRandomString(32) + )); + + $sig = !is_null($enckey) ? hash_hmac('sha256', $resp, $secret) : 'No encryption key supplied'; + header("signature: {$sig}"); + + echo $resp; + + fastcgi_finish_request(); + + if($newSession) { + misc\cache\insert("KeyAuthState:$secret:$sessionid", serialize(array("credential" => NULL, "enckey" => $enckey, "validated" => 0)), $sessionexpiry); + $time = time() + $sessionexpiry; + misc\mysql\query("REPLACE INTO `sessions` (`id`, `app`, `expiry`, `created_at`, `enckey`, `ip`) VALUES (?, ?, ?, ?, NULLIF(?, ''), ?)", [$sessionid, $secret, $time, time(), $enckey, $ip]); + misc\cache\insert("KeyAuthSessionDupe:$secret:$ip", $sessionid, $sessionexpiry); + } + + if($duplicateSession) { + misc\mysql\query("update `sessions` set `enckey` = ? where `id` = ?", [$enckey, $sessionid]); + } + + case 'register': + if (!($enabledFunctions & 2)) { + + die(json_encode(array( + "success" => false, + "message" => "This function has been disabled by app owner, it can be enabled in Function Management on https://keyauth.cc/app/?page=app-settings." + ))); + } + // retrieve session info + $sessionid = misc\etc\sanitize($_POST['sessionid'] ?? $_GET['sessionid']); + $session = api\shared\primary\getSession($sessionid, $secret); + $enckey = $session["enckey"]; + + // Read in username + $username = misc\etc\sanitize($_POST['username'] ?? $_GET['username']); + + if(strlen($username) > 70) { + $response = json_encode(array( + "success" => false, + "message" => "Username must be shorter than 70 characters" + )); + + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : NULL; + header("signature: {$sig}"); + + die($response); + } + + // Read in license key + $checkkey = misc\etc\sanitize($_POST['key'] ?? $_GET['key']); + + if(strlen($checkkey) > 70) { + $response = json_encode(array( + "success" => false, + "message" => "Key must be shorter than 70 characters" + )); + + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : NULL; + header("signature: {$sig}"); + + die($response); + } + + // Read in password + $password = misc\etc\sanitize($_POST['pass'] ?? $_GET['pass']); + + // Read in email + $email = misc\etc\sanitize($_POST['email'] ?? $_GET['email']); + + // Read in hwid + $hwid = misc\etc\sanitize($_POST['hwid'] ?? $_GET['hwid']); + + $registerSuccess = false; + + $resp = api\v1_0\register($username, $checkkey, $password, $email, $hwid, $secret); + switch ($resp) { + case 'username_taken': + $response = json_encode(array( + "success" => false, + "message" => "$usernametaken" + )); + break; + case 'key_not_found': + $response = json_encode(array( + "success" => false, + "message" => "$keynotfound" + )); + break; + case 'un_too_short': + $response = json_encode(array( + "success" => false, + "message" => "$unTooShort" + )); + break; + case 'pw_leaked': + $response = json_encode(array( + "success" => false, + "message" => "$pwLeaked" + )); + break; + case 'key_already_used': + $response = json_encode(array( + "success" => false, + "message" => "$keyused" + )); + break; + case 'key_banned': + if (strpos($keybanned, '{reason}') !== false) { + $query = misc\mysql\query("SELECT `banned` FROM `keys` WHERE `app` = ? AND `key` = ?", [$secret, $checkkey]); + $row = mysqli_fetch_array($query->result); + $reason = $row['banned']; + $keybanned = str_replace("{reason}", $reason, $keybanned); + } + $response = json_encode(array( + "success" => false, + "message" => "$keybanned" + )); + break; + case 'hwid_blacked': + $response = json_encode(array( + "success" => false, + "message" => "$hwidblacked" + )); + break; + case 'no_subs_for_level': + $response = json_encode(array( + "success" => false, + "message" => "$nosublevel" + )); + break; + default: + $registerSuccess = true; + + $response = json_encode(array( + "success" => true, + "message" => "$loggedInMsg", + "info" => $resp, + "nonce" => misc\etc\generateRandomString(32) + )); + break; + } + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : NULL; + header("signature: {$sig}"); + + echo $response; + + fastcgi_finish_request(); + + if ($registerSuccess) { + misc\cache\update('KeyAuthState:'.$secret.':'.$sessionid.'', array("validated" => 1, "credential" => $username)); + misc\mysql\query("UPDATE `sessions` SET `credential` = ?,`validated` = 1 WHERE `id` = ?", [$username, $sessionid]); + } + die(); + case 'upgrade': + if (!($enabledFunctions & 262144)) { + + die(json_encode(array( + "success" => false, + "message" => "This function has been disabled by app owner, it can be enabled in Function Management on https://keyauth.cc/app/?page=app-settings." + ))); + } + // retrieve session info + $sessionid = misc\etc\sanitize($_POST['sessionid'] ?? $_GET['sessionid']); + $session = api\shared\primary\getSession($sessionid, $secret); + $enckey = $session["enckey"]; + + // Read in username + $username = misc\etc\sanitize($_POST['username'] ?? $_GET['username']); + + // Read in key + $checkkey = misc\etc\sanitize($_POST['key'] ?? $_GET['key']); + + + // search for key + $query = misc\mysql\query("SELECT `banned`, `expires`, `status`, `level` FROM `keys` WHERE `key` = ? AND `app` = ?", [$checkkey, $secret]); + + // check if key exists + if ($query->num_rows < 1) { + $response = json_encode(array( + "success" => false, + "message" => "$keynotfound" + )); + + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : NULL; + header("signature: {$sig}"); + + die($response); + } + + // 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']; + $banned = $row['banned']; + } + + // check if used + if ($status == "Used") { + $response = json_encode(array( + "success" => false, + "message" => "$keyused" + )); + + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : NULL; + header("signature: {$sig}"); + + die($response); + } + + if (!is_null($banned)) { + if (strpos($keybanned, '{reason}') !== false) { + $keybanned = str_replace("{reason}", $banned, $keybanned); + } + $response = json_encode(array( + "success" => false, + "message" => "$keybanned" + )); + + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : NULL; + header("signature: {$sig}"); + + die($response); + } + + // add current time to key time + $expiry = $expires + time(); + + $query = misc\mysql\query("SELECT `name` FROM `subscriptions` WHERE `app` = ? AND `level` = ?", [$secret, $level]); + $subName = mysqli_fetch_array($query->result)['name']; + + $resp = misc\user\extend($username, $subName, $expiry, 0, $secret); + switch ($resp) { + case 'missing': + $response = json_encode(array( + "success" => false, + "message" => "$usernamenotfound" + )); + break; + case 'sub_missing': + $response = json_encode(array( + "success" => false, + "message" => "$nosublevel" + )); + break; + case 'failure': + $response = json_encode(array( + "success" => false, + "message" => "Failed to upgrade for some reason." + )); + 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, $checkkey, $secret]); + misc\cache\purge('KeyAuthKeys:' . $secret . ':' . $checkkey); + misc\cache\purge('KeyAuthSubs:' . $secret . ':' . $username); + $response = json_encode(array( + "success" => true, + "message" => "Upgraded successfully", + "nonce" => misc\etc\generateRandomString(32) + )); + break; + default: + $response = json_encode(array( + "success" => false, + "message" => "Unhandled Error! Contact us if you need help" + )); + break; + } + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + + die($response); + } + case 'login': + if (!($enabledFunctions & 1)) { + + die(json_encode(array( + "success" => false, + "message" => "This function has been disabled by app owner, it can be enabled in Function Management on https://keyauth.cc/app/?page=app-settings." + ))); + } + // retrieve session info + $sessionid = misc\etc\sanitize($_POST['sessionid'] ?? $_GET['sessionid']); + $session = api\shared\primary\getSession($sessionid, $secret); + $enckey = $session["enckey"]; + + // Read in username + $username = misc\etc\sanitize($_POST['username'] ?? $_GET['username']); + + // Read in HWID + $hwid = misc\etc\sanitize($_POST['hwid'] ?? $_GET['hwid']); + + // Read in password + $password = misc\etc\sanitize($_POST['pass'] ?? $_GET['pass']); + + // optional param for web loader + $token = misc\etc\sanitize($_POST['token'] ?? $_GET['token']); + + if(strlen($hwid) < $minHwid && !is_null($hwid)) { + $response = json_encode(array( + "success" => false, + "message" => "HWID must be {$minHwid} or more characters, change this in app settings." + )); + + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : NULL; + header("signature: {$sig}"); + + die($response); + } + + if($forceHwid && is_null($hwid)) { + $response = json_encode(array( + "success" => false, + "message" => "Force HWID is enabled, disable in app settings if you want to use blank HWIDs" + )); + + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : NULL; + header("signature: {$sig}"); + + die($response); + } + + $resp = api\v1_0\login($username, $password, $hwid, $secret, $hwidenabled, $token); + switch ($resp) { + case 'un_not_found': + $response = json_encode(array( + "success" => false, + "message" => "$usernamenotfound" + )); + break; + case 'pw_mismatch': + $response = json_encode(array( + "success" => false, + "message" => "$passmismatch" + )); + break; + case 'user_banned': + if (strpos($userbanned, '{reason}') !== false) { + $query = misc\mysql\query("SELECT `banned` FROM `users` WHERE `app` = ? AND `username` = ?", [$secret, $username]); + $row = mysqli_fetch_array($query->result); + $reason = $row['banned']; + $userbanned = str_replace("{reason}", $reason, $userbanned); + } + $response = json_encode(array( + "success" => false, + "message" => "$userbanned" + )); + break; + case 'hwid_mismatch': + $response = json_encode(array( + "success" => false, + "message" => "$hwidmismatch" + )); + break; + case 'hwid_blacked': + $response = json_encode(array( + "success" => false, + "message" => "$hwidblacked" + )); + break; + case 'sub_paused': + $response = json_encode(array( + "success" => false, + "message" => "$pausedsub" + )); + break; + case 'no_active_subs': + $response = json_encode(array( + "success" => false, + "message" => "$noactivesubs" + )); + break; + case 'invalid_2fa': + $response = json_encode(array( + "success" => false, + "message" => "Invalid 2fa code." + )); + break; + case 'missing_2fa_code': + $response = json_encode(array( + "success" => false, + "message" => "2fa code required." + )); + break; + default: + misc\mysql\query("UPDATE `sessions` SET `validated` = 1,`credential` = ? WHERE `id` = ?", [$username, $sessionid]); + misc\cache\update('KeyAuthState:'.$secret.':'.$sessionid.'', array("validated" => 1, "credential" => $username)); + + $ip = api\shared\primary\getIp(); + $response = json_encode(array( + "success" => true, + "message" => "$loggedInMsg", + "info" => $resp, + "nonce" => misc\etc\generateRandomString(32) + )); + break; + } + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + + die($response); + case 'license': + if (!($enabledFunctions & 4)) { + + die(json_encode(array( + "success" => false, + "message" => "This function has been disabled by app owner, it can be enabled in Function Management on https://keyauth.cc/app/?page=app-settings." + ))); + } + // retrieve session info + $sessionid = misc\etc\sanitize($_POST['sessionid'] ?? $_GET['sessionid']); + $session = api\shared\primary\getSession($sessionid, $secret); + $enckey = $session["enckey"]; + $checkkey = misc\etc\sanitize($_POST['key'] ?? $_GET['key']); + + if(strlen($checkkey) > 70) { + $response = json_encode(array( + "success" => false, + "message" => "Key must be shorter than 70 characters" + )); + + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : NULL; + header("signature: {$sig}"); + + die($response); + } + + $hwid = misc\etc\sanitize($_POST['hwid'] ?? $_GET['hwid']); + + if(strlen($hwid) < $minHwid && !is_null($hwid)) { + $response = json_encode(array( + "success" => false, + "message" => "HWID must be {$minHwid} or more characters, change this in app settings." + )); + + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : NULL; + header("signature: {$sig}"); + + die($response); + } + + if($forceHwid && is_null($hwid)) { + $response = json_encode(array( + "success" => false, + "message" => "Force HWID is enabled, disable in app settings if you want to use blank HWIDs" + )); + + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : NULL; + header("signature: {$sig}"); + + die($response); + } + + $resp = api\v1_0\login($checkkey, $checkkey, $hwid, $secret, $hwidenabled); + + switch ($resp) { + case 'un_not_found': + break; // user not registered yet or user was deleted + + case 'hwid_mismatch': + $response = json_encode(array( + "success" => false, + "message" => "$hwidmismatch" + )); + break; + case 'user_banned': + if (strpos($userbanned, '{reason}') !== false) { + $query = misc\mysql\query("SELECT `banned` FROM `users` WHERE `app` = ? AND `username` = ?", [$secret, $checkkey]); + $row = mysqli_fetch_array($query->result); + $reason = $row['banned']; + $userbanned = str_replace("{reason}", $reason, $userbanned); + } + $response = json_encode(array( + "success" => false, + "message" => "$userbanned" + )); + break; + case 'pw_mismatch': + $response = json_encode(array( + "success" => false, + "message" => "$passmismatch" + )); + break; + case 'sub_paused': + $response = json_encode(array( + "success" => false, + "message" => "$pausedsub" + )); + break; + case 'hwid_blacked': + $response = json_encode(array( + "success" => false, + "message" => "$hwidblacked" + )); + break; + case 'no_active_subs': + $response = json_encode(array( + "success" => false, + "message" => "$noactivesubs" + )); + break; + default: + misc\mysql\query("UPDATE `sessions` SET `validated` = 1,`credential` = ? WHERE `id` = ?", [$checkkey, $sessionid]); + misc\cache\update('KeyAuthState:'.$secret.':'.$sessionid.'', array("validated" => 1, "credential" => $checkkey)); + + $ip = api\shared\primary\getIp(); + $response = json_encode(array( + "success" => true, + "message" => "$loggedInMsg", + "ownerid" => $ownerid, + "info" => $resp, + "nonce" => misc\etc\generateRandomString(32) + )); + break; + } + if (isset($response)) { + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + + die($response); + } + + // if login didn't work, attempt to register + $resp = api\v1_0\register($checkkey, $checkkey, $checkkey, NULL, $hwid, $secret); + switch ($resp) { + case 'username_taken': + $response = json_encode(array( + "success" => false, + "message" => "$usernametaken" + )); + break; + case 'key_not_found': + $response = json_encode(array( + "success" => false, + "message" => "$keynotfound" + )); + break; + case 'un_too_short': + $response = json_encode(array( + "success" => false, + "message" => "$unTooShort" + )); + break; + case 'pw_leaked': + $response = json_encode(array( + "success" => false, + "message" => "$pwLeaked" + )); + break; + case 'key_already_used': + $response = json_encode(array( + "success" => false, + "message" => "$keyused" + )); + break; + case 'key_banned': + if (strpos($keybanned, '{reason}') !== false) { + $query = misc\mysql\query("SELECT `banned` FROM `keys` WHERE `app` = ? AND `key` = ?", [$secret, $checkkey]); + $row = mysqli_fetch_array($query->result); + $reason = $row['banned']; + $keybanned = str_replace("{reason}", $reason, $keybanned); + } + $response = json_encode(array( + "success" => false, + "message" => "$keybanned" + )); + break; + case 'hwid_blacked': + $response = json_encode(array( + "success" => false, + "message" => "$hwidblacked" + )); + break; + case 'no_subs_for_level': + $response = json_encode(array( + "success" => false, + "message" => "$nosublevel" + )); + break; + default: + misc\mysql\query("UPDATE `sessions` SET `validated` = 1,`credential` = ? WHERE `id` = ?", [$checkkey, $sessionid]); + misc\cache\update('KeyAuthState:'.$secret.':'.$sessionid.'', array("validated" => 1, "credential" => $checkkey)); + $response = json_encode(array( + "success" => true, + "message" => "$loggedInMsg", + "ownerid" => $ownerid, + "info" => $resp, + "nonce" => misc\etc\generateRandomString(32) + )); + } + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + + die($response); + case 'forgot': + if (!($enabledFunctions & 8192)) { + + die(json_encode(array( + "success" => false, + "message" => "This function has been disabled by app owner, it can be enabled in Function Management on https://keyauth.cc/app/?page=app-settings." + ))); + } + $sessionid = misc\etc\sanitize($_POST['sessionid'] ?? $_GET['sessionid']); + $session = api\shared\primary\getSession($sessionid, $secret); + $enckey = $session["enckey"]; + + $un = misc\etc\sanitize($_POST['username'] ?? $_GET['username']); + $email = strtolower(misc\etc\sanitize($_POST['email'] ?? $_GET['email'])); + + $row = misc\cache\fetch('KeyAuthUser:' . $secret . ':' . $un, "SELECT * FROM `users` WHERE `username` = ? AND `app` = ?", [$un, $secret], 0); + if ($row == "not_found") { + $response = json_encode(array( + "success" => false, + "message" => "No user found with that username!" + )); + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + + die($response); + } + + $emailHashed = $row['email']; + + if (sha1($email) != $emailHashed) { + $response = json_encode(array( + "success" => false, + "message" => "Email address do not match!" + )); + } else { + $algos = array( + 'ripemd128', + 'md5', + 'md4', + 'tiger128,4', + 'haval128,3', + 'haval128,4', + 'haval128,5' + ); + $emailSecret = hash($algos[array_rand($algos)], misc\etc\generateRandomString()); + + misc\mysql\query("INSERT INTO `resetUsers` (`secret`, `email`, `username`, `app`, `time`) VALUES (?, SHA1(?), ?, ?, ?)", [$emailSecret, $email, $un, $secret, time()]); + $htmlContent = " + +

You requested a password reset through the app {$name}

+

Please go to https://keyauth.cc/resetUser/?secret={$emailSecret}

+

Also, in case you forgot, your username is: {$un}

+

Thanks,
KeyAuth.

+ + "; + misc\email\send($un, $email, $htmlContent, "KeyAuth - Password Reset for {$name}"); + $response = json_encode(array( + "success" => true, + "message" => "Successfully sent email to change password.", + "nonce" => misc\etc\generateRandomString(32) + )); + } + + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + + die($response); + case 'fetchOnline': + if (!($enabledFunctions & 4096)) { + + die(json_encode(array( + "success" => false, + "message" => "This function has been disabled by app owner, it can be enabled in Function Management on https://keyauth.cc/app/?page=app-settings." + ))); + } + $sessionid = misc\etc\sanitize($_POST['sessionid'] ?? $_GET['sessionid']); + $session = api\shared\primary\getSession($sessionid, $secret); + $enckey = $session["enckey"]; + + $rows = misc\cache\fetch('KeyAuthOnlineUsers:' . $secret, "SELECT DISTINCT CONCAT(LEFT(`credential`, 10), IF(LENGTH(`credential`) > 10, REPEAT('*', LENGTH(`credential`) - 10), '')) AS `credential` FROM `sessions` WHERE `validated` = 1 AND `app` = ?", [$secret], 1, 1800); + + if ($rows == "not_found") { + $response = json_encode(array( + "success" => false, + "message" => "No online users found!" + )); + } + else { + $response = json_encode(array( + "success" => true, + "message" => "Successfully fetched online users.", + "users" => $rows, + "nonce" => misc\etc\generateRandomString(32) + )); + } + + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + + die($response); + case 'fetchStats': + if (!($enabledFunctions & 16384)) { + + die(json_encode(array( + "success" => false, + "message" => "This function has been disabled by app owner, it can be enabled in Function Management on https://keyauth.cc/app/?page=app-settings." + ))); + } + $sessionid = misc\etc\sanitize($_POST['sessionid'] ?? $_GET['sessionid']); + $session = api\shared\primary\getSession($sessionid, $secret); + $enckey = $session["enckey"]; + + $row = misc\cache\fetch('KeyAuthAppStats:' . $secret, "SELECT (SELECT COUNT(1) FROM `users` WHERE `app` = ?) AS 'numUsers', (SELECT COUNT(1) FROM `sessions` WHERE `app` = ? AND `validated` = 1 AND `expiry` > ?) AS 'numOnlineUsers', (SELECT COUNT(1) FROM `keys` WHERE `app` = ?) AS 'numKeys' FROM dual", [$secret, $secret, time(), $secret], 0, 3600); + + $numUsers = $row['numUsers']; + $numOnlineUsers = $row['numOnlineUsers']; + $numKeys = $row['numKeys']; + + $response = json_encode(array( + "success" => true, + "message" => "Successfully fetched stats", + "appinfo" => array( + "numUsers" => "$numUsers", + "numOnlineUsers" => "$numOnlineUsers", + "numKeys" => "$numKeys", + "version" => "$currentver", + "customerPanelLink" => "https://keyauth.cc/panel/$owner/$name/" + ), + "nonce" => misc\etc\generateRandomString(32) + )); + + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + + die($response); + case 'setvar': + if (!($enabledFunctions & 64)) { + + die(json_encode(array( + "success" => false, + "message" => "This function has been disabled by app owner, it can be enabled in Function Management on https://keyauth.cc/app/?page=app-settings." + ))); + } + $sessionid = misc\etc\sanitize($_POST['sessionid'] ?? $_GET['sessionid']); + $session = api\shared\primary\getSession($sessionid, $secret); + $enckey = $session["enckey"]; + if (!$session["validated"]) { + $response = json_encode(array( + "success" => false, + "message" => "$sessionunauthed" + )); + + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + + die($response); + } + + $var = misc\etc\sanitize($_POST['var'] ?? $_GET['var']); + $data = misc\etc\sanitize($_POST['data'] ?? $_GET['data']); + + if(is_null($var)) { + $response = json_encode(array( + "success" => true, + "message" => "No variable name provided" + )); + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + die($response); + } + + if(is_null($data)) { + $response = json_encode(array( + "success" => true, + "message" => "No variable data provided" + )); + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + die($response); + } + + if(strlen($data) > 500) { + $response = json_encode(array( + "success" => true, + "message" => "Variable data must be 500 characters or less" + )); + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + die($response); + } + + $row = misc\cache\fetch('KeyAuthUserVar:' . $secret . ':' . $var . ':' . $session["credential"], "SELECT `data`, `readOnly` FROM `uservars` WHERE `name` = ? AND `user` = ? AND `app` = ?", [$var, $session["credential"], $secret], 0); + + if ($row != "not_found") { + $readOnly = $row["readOnly"]; + if ($readOnly) { + $response = json_encode(array( + "success" => false, + "message" => "Variable is read only" + )); + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + die($response); + } + } + + $query = misc\mysql\query("REPLACE INTO `uservars` (`name`, `data`, `user`, `app`) VALUES (?, ?, ?, ?)", [$var, $data, $session["credential"], $secret]); + + if ($query->affected_rows != 0) { + misc\cache\purge('KeyAuthUserVar:' . $secret . ':' . $var . ':' . $session["credential"]); + $response = json_encode(array( + "success" => true, + "message" => "Successfully set variable", + "nonce" => misc\etc\generateRandomString(32) + )); + + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + + die($response); + } else { + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + + $response = json_encode(array( + "success" => false, + "message" => "Failed to set variable" + )); + die($response); + } + case 'getvar': + if (!($enabledFunctions & 32)) { + + die(json_encode(array( + "success" => false, + "message" => "This function has been disabled by app owner, it can be enabled in Function Management on https://keyauth.cc/app/?page=app-settings." + ))); + } + $sessionid = misc\etc\sanitize($_POST['sessionid'] ?? $_GET['sessionid']); + $session = api\shared\primary\getSession($sessionid, $secret); + $enckey = $session["enckey"]; + if (!$session["validated"]) { + $response = json_encode(array( + "success" => false, + "message" => "$sessionunauthed" + )); + + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + + die($response); + } + + $var = misc\etc\sanitize($_POST['var'] ?? $_GET['var']); + + $row = misc\cache\fetch('KeyAuthUserVar:' . $secret . ':' . $var . ':' . $session["credential"], "SELECT `data`, `readOnly` FROM `uservars` WHERE `name` = ? AND `user` = ? AND `app` = ?", [$var, $session["credential"], $secret], 0); + + if ($row == "not_found") { + $response = json_encode(array( + "success" => false, + "message" => "Variable not found for user" + )); + + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + + die($response); + } + + $data = $row['data']; + $response = json_encode(array( + "success" => true, + "message" => "Successfully retrieved variable", + "response" => $data, + "nonce" => misc\etc\generateRandomString(32) + )); + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + + die($response); + case 'var': + if (!($enabledFunctions & 131072)) { + + die(json_encode(array( + "success" => false, + "message" => "This function has been disabled by app owner, it can be enabled in Function Management on https://keyauth.cc/app/?page=app-settings." + ))); + } + // retrieve session info + $sessionid = misc\etc\sanitize($_POST['sessionid'] ?? $_GET['sessionid']); + $session = api\shared\primary\getSession($sessionid, $secret); + $enckey = $session["enckey"]; + + $varid = misc\etc\sanitize($_POST['varid'] ?? $_GET['varid']); + + $row = misc\cache\fetch('KeyAuthVar:' . $secret . ':' . $varid, "SELECT `msg`, `authed` FROM `vars` WHERE `varid` = ? AND `app` = ?", [$varid, $secret], 0); + + if ($row == "not_found") { + $response = json_encode(array( + "success" => false, + "message" => "Variable not found." + )); + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + + die($response); + } + + $msg = $row['msg']; + $authed = $row['authed']; + + if ($authed) // if variable requires user to be authenticated + + { + if (!$session["validated"]) { + $response = json_encode(array( + "success" => false, + "message" => "$sessionunauthed" + )); + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + + die($response); + } + } + $response = json_encode(array( + "success" => true, + "message" => "$msg", + "nonce" => misc\etc\generateRandomString(32) + )); + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + + die($response); + case 'checkblacklist': + // retrieve session info + $sessionid = misc\etc\sanitize($_POST['sessionid'] ?? $_GET['sessionid']); + $session = api\shared\primary\getSession($sessionid, $secret); + $enckey = $session["enckey"]; + + $hwid = misc\etc\sanitize($_POST['hwid'] ?? $_GET['hwid']); + $ip = api\shared\primary\getIp(); + + $row = misc\cache\fetch('KeyAuthBlacklist:' . $secret . ':' . $ip . ':' . $hwid, "SELECT 1 FROM `bans` WHERE (`hwid` = ? OR `ip` = ?) AND `app` = ?", [$hwid, $ip, $secret], 0); + + if ($row != "not_found") { + $response = json_encode(array( + "success" => true, + "message" => "Client is blacklisted", + "nonce" => misc\etc\generateRandomString(32) + )); + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + + die($response); + } else { + $response = json_encode(array( + "success" => false, + "message" => "Client is not blacklisted" + )); + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + + die($response); + } + case 'chatget': + if (!($enabledFunctions & 8)) { + + die(json_encode(array( + "success" => false, + "message" => "This function has been disabled by app owner, it can be enabled in Function Management on https://keyauth.cc/app/?page=app-settings." + ))); + } + // retrieve session info + $sessionid = misc\etc\sanitize($_POST['sessionid'] ?? $_GET['sessionid']); + $session = api\shared\primary\getSession($sessionid, $secret); + $enckey = $session["enckey"]; + if (!$session["validated"]) { + $response = json_encode(array( + "success" => false, + "message" => "$sessionunauthed" + )); + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + + die($response); + } + + $channel = misc\etc\sanitize($_POST['channel'] ?? $_GET['channel']); + $rows = misc\cache\fetch('KeyAuthChatMsgs:' . $secret . ':' . $channel, "SELECT `author`, `message`, `timestamp` FROM `chatmsgs` WHERE `channel` = ? AND `app` = ?", [$channel, $secret], 1); + + if ($rows == "not_found") { + $rows = []; + } + + $response = json_encode(array( + "success" => true, + "message" => "Successfully retrieved chat messages", + "messages" => $rows, + "nonce" => misc\etc\generateRandomString(32) + )); + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + + die($response); + case 'chatsend': + if (!($enabledFunctions & 16)) { + + die(json_encode(array( + "success" => false, + "message" => "This function has been disabled by app owner, it can be enabled in Function Management on https://keyauth.cc/app/?page=app-settings." + ))); + } + // retrieve session info + $sessionid = misc\etc\sanitize($_POST['sessionid'] ?? $_GET['sessionid']); + $session = api\shared\primary\getSession($sessionid, $secret); + $enckey = $session["enckey"]; + if (!$session["validated"]) { + $response = json_encode(array( + "success" => false, + "message" => "$sessionunauthed" + )); + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + + die($response); + } + + $channel = misc\etc\sanitize($_POST['channel'] ?? $_GET['channel']); + $query = misc\mysql\query("SELECT `delay` FROM `chats` WHERE `name` = ? AND `app` = ?", [$channel, $secret]); + + if ($query->num_rows < 1) { + $response = json_encode(array( + "success" => false, + "message" => "Chat channel not found" + )); + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + + die($response); + } + + $row = mysqli_fetch_array($query->result); + $delay = $row['delay']; + $credential = $session["credential"]; + $query = misc\mysql\query("SELECT `timestamp` FROM `chatmsgs` WHERE `author` = ? AND `channel` = ? AND `app` = ? ORDER BY `id` DESC LIMIT 1", [$credential, $channel, $secret]); + + $row = mysqli_fetch_array($query->result); + $time = $row['timestamp']; + + if (time() - $time < $delay) { + $response = json_encode(array( + "success" => false, + "message" => "$chatHitDelay" + )); + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + + die($response); + } + + $query = misc\mysql\query("SELECT `time` FROM `chatmutes` WHERE `user` = ? AND `app` = ?", [$credential, $secret]); + if ($query->num_rows != 0) { + $row = mysqli_fetch_array($query->result); + $unmuted = $row["time"]; + $unmuted = date("F j, Y, g:i a", $unmuted); + $response = json_encode(array( + "success" => false, + "message" => "You're muted from chat until $unmuted" + )); + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + + die($response); + } + + $message = misc\etc\sanitize($_POST['message'] ?? $_GET['message']); + + if (is_null($message)) { + $response = json_encode(array( + "success" => false, + "message" => "Message can't be blank" + )); + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + + die($response); + } + + if(strlen($message) > 2000) { + $response = json_encode(array( + "success" => false, + "message" => "Message too long!" + )); + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + + die($response); + } + + misc\mysql\query("INSERT INTO `chatmsgs` (`author`, `message`, `timestamp`, `channel`,`app`) VALUES (?, ?, ?, ?, ?)", [$credential, $message, time(), $channel, $secret]); + misc\mysql\query("DELETE FROM `chatmsgs` WHERE `app` = ? AND `channel` = ? AND `id` NOT IN ( SELECT `id` FROM ( SELECT `id` FROM `chatmsgs` WHERE `channel` = ? AND `app` = ? ORDER BY `id` DESC LIMIT 50) foo );", [$secret, $channel, $channel, $secret]); + misc\cache\purge('KeyAuthChatMsgs:' . $secret . ':' . $channel); + $response = json_encode(array( + "success" => true, + "message" => "Successfully sent chat message", + "nonce" => misc\etc\generateRandomString(32) + )); + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + + die($response); + case 'log': + if (!($enabledFunctions & 32768)) { + + die(json_encode(array( + "success" => false, + "message" => "This function has been disabled by app owner, it can be enabled in Function Management on https://keyauth.cc/app/?page=app-settings." + ))); + } + // client isn't expecting a response body, just flush output right away so program can move on to rest of the code quicker + fastcgi_finish_request(); + + // retrieve session info + $sessionid = misc\etc\sanitize($_POST['sessionid'] ?? $_GET['sessionid']); + $session = api\shared\primary\getSession($sessionid, $secret); + $enckey = $session["enckey"]; + + $credential = $session["credential"]; + + $currtime = time(); + + $msg = misc\etc\sanitize($_POST['message'] ?? $_GET['message']); + + if(is_null($msg)) { + die("No log data specified"); + } + + if(strlen($msg) > 275) { + die("Log data too long"); + } + + $pcuser = misc\etc\sanitize($_POST['pcuser'] ?? $_GET['pcuser']); + + if (is_null($webhook)) { + $roleCheck = misc\cache\fetch('KeyAuthSellerCheck:' . $owner, "SELECT `role`,`expires` FROM `accounts` WHERE `username` = ?", [$owner], 0); + if($roleCheck['role'] == "tester") { + $query = misc\mysql\query("SELECT count(*) AS 'numLogs' FROM `logs` WHERE `logapp` = ?",[$secret]); + $row = mysqli_fetch_array($query->result); + $numLogs = $row["numLogs"]; + if($numLogs >= 20) { + die(); + } + } + + misc\mysql\query("INSERT INTO `logs` (`logdate`, `logdata`, `credential`, `pcuser`,`logapp`) VALUES (?, ?, NULLIF(?, ''), NULLIF(?, ''), ?)", [$currtime, $msg, $credential, $pcuser, $secret]); + die(); + } + + $credential = $session["credential"] ?? "N/A"; + + $msg = "📜 Log: " . $msg; + + $ip = api\shared\primary\getIp(); + + $json_data = json_encode([ + // Embeds Array + "embeds" => [ + [ + // Embed Title + "title" => $msg, + + // Embed left border color in HEX + "color" => hexdec("00ffe1"), + + // Additional Fields array + "fields" => [["name" => "🔐 Credential:", "value" => "```" . $credential . "```"], ["name" => "💻 PC Name:", "value" => "```" . $pcuser . "```", "inline" => true], ["name" => "🌎 Client IP:", "value" => "```" . $ip . "```", "inline" => true]] + ] + ] + + ], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); + + $ch = curl_init($webhook); + + curl_setopt($ch, CURLOPT_HTTPHEADER, array( + 'Content-type: application/json' + )); + + curl_setopt($ch, CURLOPT_POST, 1); + + curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data); + + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); + + curl_setopt($ch, CURLOPT_HEADER, 0); + + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + + $response = curl_exec($ch); + + // If you need to debug, or find out why you can't send message uncomment line below, and execute script. + // echo $response; + curl_close($ch); + die(); + + case 'webhook': + if (!($enabledFunctions & 65536)) { + + die(json_encode(array( + "success" => false, + "message" => "This function has been disabled by app owner, it can be enabled in Function Management on https://keyauth.cc/app/?page=app-settings." + ))); + } + // retrieve session info + $sessionid = misc\etc\sanitize($_POST['sessionid'] ?? $_GET['sessionid']); + $session = api\shared\primary\getSession($sessionid, $secret); + $enckey = $session["enckey"]; + + $webid = misc\etc\sanitize($_POST['webid'] ?? $_GET['webid']); + $row = misc\cache\fetch('KeyAuthWebhook:' . $secret . ':' . $webid, "SELECT `baselink`, `useragent`, `authed` FROM `webhooks` WHERE `webid` = ? AND `app` = ?", [$webid, $secret], 0); + if ($row == "not_found") { + $response = json_encode(array( + "success" => false, + "message" => "Webhook Not Found." + )); + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + + die($response); + } + + $baselink = $row['baselink']; + $useragent = $row['useragent']; + $authed = $row['authed']; + + if ($authed) // if variable requires user to be authenticated + + { + if (!$session["validated"]) { + $response = json_encode(array( + "success" => false, + "message" => "$sessionunauthed" + )); + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + + die($response); + } + } + + $params = misc\etc\sanitize($_POST['params'] ?? $_GET['params']); + $body = $_POST['body'] ?? $_GET['body']; + $contType = misc\etc\sanitize($_POST['conttype'] ?? $_GET['conttype']); + + $url = $baselink .= urldecode($params); + + $ch = curl_init($url); + + curl_setopt($ch, CURLOPT_USERAGENT, $useragent); + + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + + if (!is_null($body) && !empty($body)) + curl_setopt($ch, CURLOPT_POSTFIELDS, $body); + + if (!is_null($contType)) + curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: ' . $contType)); + + $response = curl_exec($ch); + + $resp = json_encode(array( + "success" => true, + "message" => "Webhook request successful", + "ownerid" => $ownerid, + "response" => "$response", + "nonce" => misc\etc\generateRandomString(32) + )); + $sig = !is_null($enckey) ? hash_hmac('sha256', $resp, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + + die($resp); + case 'file': + if (!($enabledFunctions & 2048)) { + + die(json_encode(array( + "success" => false, + "message" => "This function has been disabled by app owner, it can be enabled in Function Management on https://keyauth.cc/app/?page=app-settings." + ))); + } + // retrieve session info + $sessionid = misc\etc\sanitize($_POST['sessionid'] ?? $_GET['sessionid']); + $session = api\shared\primary\getSession($sessionid, $secret); + $enckey = $session["enckey"]; + + $fileid = misc\etc\sanitize($_POST['fileid'] ?? $_GET['fileid']); + + $row = misc\cache\fetch('KeyAuthFile:' . $secret . ':' . $fileid, "SELECT `name`, `url`, `authed` FROM `files` WHERE `app` = ? AND `id` = ?", [$secret, $fileid], 0); + + if ($row == "not_found") { + $response = json_encode(array( + "success" => false, + "message" => "File not Found" + )); + + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + http_response_code(201); // putting a number above 200 so cloudflare worker won't cache + + die($response); + } + + $filename = $row['name']; + $url = $row['url']; + $authed = $row['authed']; + + if ($authed) // if file requires user to be authenticated + + { + if (!$session["validated"]) { + $response = json_encode(array( + "success" => false, + "message" => "$sessionunauthed" + )); + + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + http_response_code(202); // putting a number above 200 so cloudflare worker won't cache + die($response); + } + } + + ini_set('memory_limit', '-1'); + + $ch = curl_init($url); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla KeyAuth'); + $data = curl_exec($ch); + $statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); + + if ($statusCode == 403 || $statusCode == 404) { + $response = json_encode(array( + "success" => false, + "message" => "File no longer works, please notify the application developer." + )); + + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + http_response_code(203); // putting a number above 200 so cloudflare worker won't cache + die($response); + } + $contents = bin2hex($data); + + $response = json_encode(array( + "success" => true, + "message" => "File download successful", + "contents" => "$contents", + "nonce" => misc\etc\generateRandomString(32) + )); + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + + die($response); + + case 'ban': + if (!($enabledFunctions & 128)) { + + die(json_encode(array( + "success" => false, + "message" => "This function has been disabled by app owner, it can be enabled in Function Management on https://keyauth.cc/app/?page=app-settings." + ))); + } + // retrieve session info + $sessionid = misc\etc\sanitize($_POST['sessionid'] ?? $_GET['sessionid']); + $session = api\shared\primary\getSession($sessionid, $secret); + $enckey = $session["enckey"]; + + $credential = $session["credential"]; + if (!$session["validated"]) { + $response = json_encode(array( + "success" => false, + "message" => "$sessionunauthed" + )); + + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + + die($response); + } + + $reason = misc\etc\sanitize($_POST['reason'] ?? $_GET['reason']) ?? "User banned from triggering ban function in the client"; + + if(strlen($reason) > 99) { + $response = json_encode(array( + "success" => false, + "message" => "Reason must be 99 characters or less" + )); + + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + + die($response); + } + + $hwid = misc\etc\sanitize($_POST['hwid'] ?? $_GET['hwid']); + if (!empty($hwid)) { + misc\blacklist\add($hwid, "Hardware ID", $secret); + } + $ip = api\shared\primary\getIp(); + misc\blacklist\add($ip, "IP Address", $secret); + + misc\mysql\query("UPDATE `users` SET `banned` = ? WHERE `username` = ? AND `app` = ?", [$reason, $credential, $secret]); + if ($query->affected_rows != 0) { + misc\cache\purge('KeyAuthUser:' . $secret . ':' . $credential); + $response = json_encode(array( + "success" => true, + "message" => "Successfully Banned User", + "nonce" => misc\etc\generateRandomString(32) + )); + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + + die($response); + } else { + $response = json_encode(array( + "success" => false, + "message" => "Failed to ban user." + )); + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + + die($response); + } + case 'check': + if (!($enabledFunctions & 512)) { + + die(json_encode(array( + "success" => false, + "message" => "This function has been disabled by app owner, it can be enabled in Function Management on https://keyauth.cc/app/?page=app-settings." + ))); + } + // retrieve session info + $sessionid = misc\etc\sanitize($_POST['sessionid'] ?? $_GET['sessionid']); + $session = api\shared\primary\getSession($sessionid, $secret); + $enckey = $session["enckey"]; + + $credential = $session["credential"]; + if (!$session["validated"]) { + $response = json_encode(array( + "success" => false, + "message" => "$sessionunauthed" + )); + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + + die($response); + } else { + $response = json_encode(array( + "success" => true, + "message" => "Session is validated.", + "nonce" => misc\etc\generateRandomString(32) + )); + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + + die($response); + } + case 'changeUsername': + if (!($enabledFunctions & 1024)) { + + die(json_encode(array( + "success" => false, + "message" => "This function has been disabled by app owner, it can be enabled in Function Management on https://keyauth.cc/app/?page=app-settings." + ))); + } + $sessionid = misc\etc\sanitize($_POST['sessionid'] ?? $_GET['sessionid']); + $session = api\shared\primary\getSession($sessionid, $secret); + $enckey = $session["enckey"]; + + if (!$session["validated"]) { + $response = json_encode(array( + "success" => false, + "message" => "$sessionunauthed" + )); + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + + die($response); + } + + $credential = $session["credential"]; + + $resp = misc\user\changeUsername($credential, $_POST['newUsername'] ?? $_GET['newUsername'], $secret); + switch ($resp) { + case 'already_used': + $response = json_encode(array( + "success" => false, + "message" => "Username already used!" + )); + break; + case 'failure': + $response = json_encode(array( + "success" => false, + "message" => "Failed to change username!" + )); + break; + case 'success': + misc\session\killSingular($sessionid, $secret); + $response = json_encode(array( + "success" => true, + "message" => "Successfully changed username, user logged out.", + "nonce" => misc\etc\generateRandomString(32) + )); + break; + default: + $response = json_encode(array( + "success" => false, + "message" => "Unhandled Error! Contact us if you need help" + )); + break; + } + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + + die($response); + case 'logout': + $sessionid = misc\etc\sanitize($_POST['sessionid'] ?? $_GET['sessionid']); + $session = api\shared\primary\getSession($sessionid, $secret); + $enckey = $session["enckey"]; + misc\session\killSingular($sessionid, $secret); + $response = json_encode(array( + "success" => true, + "message" => "Successfully logged out.", + "nonce" => misc\etc\generateRandomString(32) + )); + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + + die($response); + case '2faenable': + + list($sessionid, $code) = [misc\etc\sanitize($_POST['sessionid'] ?? $_GET['sessionid']), misc\etc\sanitize($_POST["code"] ?? $_GET["code"])]; + $session = api\shared\primary\getSession($sessionid, $secret); + $enckey = $session["enckey"]; + + if (!$session["validated"]) { + $response = json_encode(array( + "success" => false, + "message" => "$sessionunauthed" + )); + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + + die($response); + } + + $row = misc\cache\fetch('KeyAuthUser:' . $secret . ':' . $session["credential"], "SELECT * FROM `users` WHERE `username` = ? AND `app` = ?", [$session["credential"], $secret], 0); + + if ($row["2fa"]) { + + $response = json_encode(array( + "success" => false, + "message" => "2fa is already enabled on this account" + )); + + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + + die($response); + + } + + include_once '../../auth/GoogleAuthenticator.php'; + + $_2fa = new GoogleAuthenticator(); + + if (empty($code) || is_null($code)) { + + $secret_code = $_2fa->createSecret(); + + misc\cache\insert('KeyAuthTwoFactorAuthentication:' . $session["credential"], $secret_code, 300); + + $qrcode = str_replace(urlencode("https://chart.googleapis.com/chart?chs=200x200&chld=M|0&cht=qr&chl="), " ", $_2fa->getQRCodeGoogleUrl($session["credential"], $secret_code, 'KeyAuth')); + + $response = json_encode(array( + "success" => true, + "2fa" => array( + "secret_code" => $secret_code, + "QRCode" => "otpauth://totp/" . $session["credential"] . "?secret=" . $secret_code . "&issuer=KeyAuth" + ) + )); + + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + + die($response); + + } + else { + + $secret_code = misc\cache\select('KeyAuthTwoFactorAuthentication:' . $session["credential"]); + + if (!$secret_code) { + + $response = json_encode(array( + "success" => true, + "message" => "2fa session has expired" + )); + + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + + die($response); + + } + + if ($_2fa->verifyCode($secret_code, $code, 2)) { + + misc\mysql\query("UPDATE `users` SET `2fa` = ?, `googleAuthCode` = ? WHERE `app` = ? AND `username` = ?", [1, $secret_code, $secret, $session["credential"]]); + misc\cache\purge('KeyAuthUser:' . $secret . ':' . $session["credential"]); + misc\cache\purge('KeyAuthTwoFactorAuthentication: ' . $session["credential"]); + + $response = json_encode(array( + "success" => true, + "message" => "2fa successfully activated" + )); + + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + + die($response); + + } + else { + + $response = json_encode(array( + "success" => true, + "message" => "Invalid code please try again" + )); + + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + + die($response); + + } + + } + case '2fadisable': + + list($sessionid, $code) = [misc\etc\sanitize($_POST['sessionid'] ?? $_GET['sessionid']), misc\etc\sanitize($_POST["code"] ?? $_GET["code"])]; + + if (empty($code) || is_null($code)) { + + $response = json_encode(array( + "success" => false, + "message" => "Please provide the 2fa code to disable 2fa" + )); + + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + + die($response); + + } + + $session = api\shared\primary\getSession($sessionid, $secret); + $enckey = $session["enckey"]; + + if (!$session["validated"]) { + $response = json_encode(array( + "success" => false, + "message" => "$sessionunauthed" + )); + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + + die($response); + } + + $row = misc\cache\fetch('KeyAuthUser:' . $secret . ':' . $session["credential"], "SELECT * FROM `users` WHERE `username` = ? AND `app` = ?", [$session["credential"], $secret], 0); + + if (!$row["2fa"]) { + + $response = json_encode(array( + "success" => false, + "message" => "2fa is not enabled on this account" + )); + + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + + die($response); + + } + + include_once '../../auth/GoogleAuthenticator.php'; + + $_2fa = new GoogleAuthenticator(); + + $secret_code = $row["googleAuthCode"]; + + if ($_2fa->verifyCode($secret_code, $code, 2)) { + + misc\mysql\query("UPDATE `users` SET `2fa` = ?, `googleAuthCode` = ? WHERE `app` = ? AND `username` = ?", [0, NULL, $secret, $row["username"]]); + misc\cache\purge('KeyAuthUser:' . $secret . ':' . $session["credential"]); + + $response = json_encode(array( + "success" => true, + "message" => "2fa successfully activated" + )); + + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + + die($response); + + } + else { + + $response = json_encode(array( + "success" => true, + "message" => "Invalid code please try again" + )); + + $sig = !is_null($enckey) ? hash_hmac('sha256', $response, $enckey) : 'No encryption key supplied'; + header("signature: {$sig}"); + + die($response); + + } + + default: + die(json_encode(array( + "success" => false, + "message" => "The value inputted for type paramater was not found" + ))); + + + } \ No newline at end of file diff --git a/api/dashboard/webauthn.php b/api/dashboard/webauthn.php new file mode 100644 index 0000000..161e7be --- /dev/null +++ b/api/dashboard/webauthn.php @@ -0,0 +1,191 @@ + getCreateArgs + * | + * navigator.credentials.create <-------------' + * | + * '-------------------------> processCreate + * | + * alert ok or fail <----------------' + * + * ------------------------------------------------------------ + * + * VALIDATION + * + * window.fetch ------------------> getGetArgs + * | + * navigator.credentials.get <----------------' + * | + * '-------------------------> processGet + * | + * alert ok or fail <----------------' + * + * ------------------------------------------------------------ + */ +include '../../includes/misc/autoload.phtml'; +require_once '../../vendor/lbuchs/webauthn/src/WebAuthn.php'; +try { + // read get argument and post body + $fn = filter_input(INPUT_GET, 'fn'); + if(empty($fn)) { + die("Can't access directly"); + } + $post = trim(file_get_contents('php://input')); + $userId = bin2hex(openssl_random_pseudo_bytes(10)); + if ($post) { + $post = json_decode($post); + } + + session_start(); + // Formats + $formats = array(); + $formats[] = 'none'; + + $rpId = $_SERVER['HTTP_HOST']; + + // cross-platform: true, if type internal is not allowed + // false, if only internal is allowed + // null, if internal and cross-platform is allowed + $crossPlatformAttachment = null; + + + // new Instance of the server library. + // make sure that $rpId is the domain name. + $WebAuthn = new lbuchs\WebAuthn\WebAuthn('KeyAuth', $rpId, $formats); + + // ------------------------------------ + // request for create arguments + // ------------------------------------ + + if ($fn === 'getCreateArgs') { + $createArgs = $WebAuthn->getCreateArgs($userId, $_SESSION['username'], "", 20, 0, "discouraged", $crossPlatformAttachment); + + header('Content-Type: application/json'); + print(json_encode($createArgs)); + + // save challange to session. you have to deliver it to processGet later. + $_SESSION['challenge'] = $WebAuthn->getChallenge(); + + + + // ------------------------------------ + // request for get arguments + // ------------------------------------ + + } else if ($fn === 'getGetArgs') { + $ids = array(); + + // load registrations from session stored there by processCreate. + + $query = misc\mysql\query("SELECT * FROM `securityKeys` WHERE `username` = ?", [$_SESSION['pendingUsername']]); + if ($query->num_rows > 0) { + while ($row = mysqli_fetch_array($query->result)) { + $ids[] = base64_decode($row["credentialId"]); + } + } + + if (count($ids) === 0) { + throw new Exception('No security key registrations found for this user!'); + } + + $getArgs = $WebAuthn->getGetArgs($ids, 20, 1, 1, 1, 1, 0); + + header('Content-Type: application/json'); + print(json_encode($getArgs)); + + // save challange to session. you have to deliver it to processGet later. + $_SESSION['challenge'] = $WebAuthn->getChallenge(); + + + + // ------------------------------------ + // process create + // ------------------------------------ + + } else if ($fn === 'processCreate') { + $clientDataJSON = base64_decode($post->clientDataJSON); + $attestationObject = base64_decode($post->attestationObject); + $challenge = $_SESSION['challenge']; + + // processCreate returns data to be stored for future logins. + $data = $WebAuthn->processCreate($clientDataJSON, $attestationObject, $challenge, 0, false, false); + + unset($_SESSION['challenge']); // disgard challenge array from session file, no longer needed + + $name = misc\etc\sanitize($_GET['name']); + + misc\mysql\query("INSERT INTO `securityKeys` (`username`, `name`, `credentialId`, `credentialPublicKey`) VALUES (?, ?, ?, ?)", [$_SESSION['username'], $name, base64_encode($data->credentialId), $data->credentialPublicKey]); + misc\mysql\query("UPDATE `accounts` SET `securityKey` = 1 WHERE `username` = ?", [$_SESSION['username']]); + + $return = new stdClass(); + $return->success = true; + $return->msg = 'registration success.'; + + header('Content-Type: application/json'); + print(json_encode($return)); + + + + // ------------------------------------ + // proccess get + // ------------------------------------ + + } else if ($fn === 'processGet') { + $clientDataJSON = base64_decode($post->clientDataJSON); + $authenticatorData = base64_decode($post->authenticatorData); + $signature = base64_decode($post->signature); + $userHandle = base64_decode($post->userHandle); + $id = base64_decode($post->id); + $challenge = $_SESSION['challenge']; + $credentialPublicKey = null; + + // looking up correspondending public key of the credential id + // you should also validate that only ids of the given user name + // are taken for the login. + + $query = misc\mysql\query("SELECT * FROM `securityKeys` WHERE `username` = ?", [$_SESSION['pendingUsername']]); + if ($query->num_rows > 0) { + while ($row = mysqli_fetch_array($query->result)) { + if(base64_decode($row["credentialId"]) === $id) { + $credentialPublicKey = $row["credentialPublicKey"]; + break; + } + } + } + + if ($credentialPublicKey === null) { + throw new Exception('This security key wasn\'t found!'); + } + + // process the get request. throws WebAuthnException if it fails + $WebAuthn->processGet($clientDataJSON, $authenticatorData, $signature, $credentialPublicKey, $challenge, null, 0); + + unset($_SESSION['challenge']); // disgard challenge array from session file, no longer needed + $_SESSION['username'] = $_SESSION['pendingUsername']; + unset($_SESSION['pendingUsername']); + + $return = new stdClass(); + $return->success = true; + + header('Content-Type: application/json'); + print(json_encode($return)); + } + +} catch (Throwable $ex) { + $return = new stdClass(); + $return->success = false; + $return->msg = $ex->getMessage(); + + header('Content-Type: application/json'); + print(json_encode($return)); +} \ No newline at end of file diff --git a/api/index.php b/api/index.php new file mode 100644 index 0000000..9d0b6dc --- /dev/null +++ b/api/index.php @@ -0,0 +1,3 @@ +num_rows < 1) + { // if no application was found with the supplied secret as the 'app' paramater + die("Failure: application not found"); + } + $row = mysqli_fetch_array($query->result); + $name = $row["name"]; + $secret = $row["sellixsecret"]; + $dayproduct = $row["sellixdayproduct"]; + $weekproduct = $row["sellixweekproduct"]; + $monthproduct = $row["sellixmonthproduct"]; + $lifetimeproduct = $row["sellixlifetimeproduct"]; + + $payload = file_get_contents('php://input'); + $header_signature = misc\etc\sanitize($_SERVER["HTTP_X_SELLIX_SIGNATURE"]); + $signature = hash_hmac('sha512', $payload, $secret); + if (!hash_equals($signature, $header_signature)) + { // if the sellix webhook secret the request was sent from didn't match the one set in the database + die("Failure: authentication with sellix secret failed"); + } + + $json = json_decode($payload); + $data = $json->data; + $custom = $data->custom_fields; // getting custom fields, the hidden fields on KeyAuth sellix embed which provide sellix the KeyAuth username + $un = misc\etc\sanitize($custom->username); + + $query = misc\mysql\query("SELECT `balance` FROM `accounts` WHERE `username` = ? AND `app` = ?", [$un, $name]); + + if ($query->num_rows < 1) + { // if reseller not found + die("Failure: No account with the supplied username under this application found"); + } + // getting the balance of each key length for the specified reseller account + $row = mysqli_fetch_array($query->result); + $balance = $row["balance"]; + $balance = explode("|", $balance); + $day = $balance[0]; + $week = $balance[1]; + $month = $balance[2]; + $threemonth = $balance[3]; + $sixmonth = $balance[4]; + $lifetime = $balance[5]; + $year = $balance[6]; + + $amount = misc\etc\sanitize($data->quantity); // find quantity of keys purchased + // then given the duration of keys they purchased, add to their balance + + if(isset($_GET['expiry'])) { + $expiry = misc\etc\sanitize($_GET['expiry']); + $level = misc\etc\sanitize($_GET['level']); + + $key = misc\license\createLicense($amount, "******-******-******-******-******-******", $expiry, $level, NULL, 86400, $app, $un); + + $keys = NULL; + for ($i = 0; $i < count($key); $i++) { + $keys .= "" . $key[$i] . "\n"; + } + $keys = preg_replace( + + '~[\r\n]+~', + + "\r\n", + + trim($keys) + ); + die($keys); + } + + switch (misc\etc\sanitize($data->product_id)) + { + case $dayproduct: + $day = $day + $amount; + break; + case $weekproduct: + $week = $week + $amount; + break; + case $monthproduct: + $month = $month + $amount; + break; + case $lifetimeproduct: + $lifetime = $lifetime + $amount; + break; + default: + die("You didn't set product id in app settings."); + } + + $balance = $day . '|' . $week . '|' . $month . '|' . $threemonth . '|' . $sixmonth . '|' . $lifetime . '|' . $year; + // set balance + misc\mysql\query("UPDATE `accounts` SET `balance` = ? WHERE `username` = ?", [$balance, $un]); + die("Success: Reseller Balance Increased"); +} + +if (isset($_SERVER["HTTP_X_SHOPPY_SIGNATURE"])) +{ + $app = misc\etc\sanitize($_GET['app']); + $query = misc\mysql\query("SELECT * FROM `apps` WHERE `secret` = ?", [$app]); + + if ($query->num_rows < 1) + { // if no application was found with the supplied secret as the 'app' paramater + die("Failure: application not found"); + } + + $row = mysqli_fetch_array($query->result); + $name = $row["name"]; + $secret = $row["shoppysecret"]; + $dayproduct = $row["shoppydayproduct"]; + $weekproduct = $row["shoppyweekproduct"]; + $monthproduct = $row["shoppymonthproduct"]; + $lifetimeproduct = $row["shoppylifetimeproduct"]; + + $payload = file_get_contents('php://input'); + $header_signature = misc\etc\sanitize($_SERVER["HTTP_X_SHOPPY_SIGNATURE"]); + $signature = hash_hmac('sha512', $payload, $secret); + if (!hash_equals($signature, $header_signature)) + { + // if the shoppy webhook secret the request was sent from didn't match the one set in the database + die("Failure: authentication with shoppy secret failed"); + } + $json = json_decode($payload); + $un = misc\etc\sanitize($json->data->order->custom_fields[0]->value); + + $productid = misc\etc\sanitize($json->data->order->product_id); + + $query = misc\mysql\query("SELECT `balance` FROM `accounts` WHERE `username` = ? AND `app` = ?", [$un, $name]); + + if ($query->num_rows < 1) + { + // if reseller not found + die("Failure: No account with the supplied username under this application found"); + } + // getting the balance of each key length for the specified reseller account + $row = mysqli_fetch_array($query->result); + $balance = $row["balance"]; + $balance = explode("|", $balance); + $day = $balance[0]; + $week = $balance[1]; + $month = $balance[2]; + $threemonth = $balance[3]; + $sixmonth = $balance[4]; + $lifetime = $balance[5]; + $year = $balance[6]; + + $amount = misc\etc\sanitize($json->data->order->quantity); // find quantity of keys purchased + // then given the duration of keys they purchased, add to their balance + + if(isset($_GET['expiry'])) { + $expiry = misc\etc\sanitize($_GET['expiry']); + $level = misc\etc\sanitize($_GET['level']); + + $key = misc\license\createLicense($amount, "******-******-******-******-******-******", $expiry, $level, NULL, 86400, $app, $un); + + $keys = NULL; + for ($i = 0; $i < count($key); $i++) { + $keys .= "" . $key[$i] . "\n"; + } + $keys = preg_replace( + + '~[\r\n]+~', + + "\r\n", + + trim($keys) + ); + die($keys); + } + + switch ($productid) + { + case $dayproduct: + $day = $day + $amount; + break; + case $weekproduct: + $week = $week + $amount; + break; + case $monthproduct: + $month = $month + $amount; + break; + case $lifetimeproduct: + $lifetime = $lifetime + $amount; + break; + default: + die("You didn't set product id in app settings."); + } + + $balance = $day . '|' . $week . '|' . $month . '|' . $threemonth . '|' . $sixmonth . '|' . $lifetime . '|' . $year; + // set balance + misc\mysql\query("UPDATE `accounts` SET `balance` = ? WHERE `username` = ?", [$balance, $un]); + die("Success: Reseller Balance Increased"); +} + +if (isset($_SERVER["HTTP_SIGNATURE"])) +{ + $app = misc\etc\sanitize($_GET['app']); + $query = misc\mysql\query("SELECT * FROM `apps` WHERE `secret` = ?", [$app]); + + if ($query->num_rows < 1) + { + // if no application was found with the supplied secret as the 'app' paramater + die("Failure: application not found"); + } + + $row = mysqli_fetch_array($query->result); + $name = $row["name"]; + $secret = $row["sellappsecret"]; + $dayproduct = $row["sellappdayproduct"]; + $weekproduct = $row["sellappweekproduct"]; + $monthproduct = $row["sellappmonthproduct"]; + $lifetimeproduct = $row["sellapplifetimeproduct"]; + + $payload = file_get_contents('php://input'); + + $header_signature = misc\etc\sanitize($_SERVER["HTTP_SIGNATURE"]); + $signature = hash_hmac('sha256', $payload, $secret); + if (!hash_equals($signature, $header_signature)) + { + // if the SellApp webhook secret the request was sent from didn't match the one set in the database + die("Failure: authentication with SellApp secret failed"); + } + $json = json_decode($payload); + $un = misc\etc\sanitize($json->additional_information[0]->value); + + $product = misc\etc\sanitize($json->listing->slug); + + $query = misc\mysql\query("SELECT `balance` FROM `accounts` WHERE `username` = ? AND `app` = ?", [$un, $name]); + + if ($query->num_rows < 1) + { + // if reseller not found + die("Failure: No account with the supplied username under this application found"); + } + // getting the balance of each key length for the specified reseller account + $row = mysqli_fetch_array($query->result); + $balance = $row["balance"]; + $balance = explode("|", $balance); + $day = $balance[0]; + $week = $balance[1]; + $month = $balance[2]; + $threemonth = $balance[3]; + $sixmonth = $balance[4]; + $lifetime = $balance[5]; + $year = $balance[6]; + + $amount = misc\etc\sanitize($json->quantity); // find quantity of keys purchased + // then given the duration of keys they purchased, add to their balance + + if(isset($_GET['expiry'])) { + $expiry = misc\etc\sanitize($_GET['expiry']); + $level = misc\etc\sanitize($_GET['level']); + + $key = misc\license\createLicense($amount, "******-******-******-******-******-******", $expiry, $level, NULL, 86400, $app, $un); + + $keys = NULL; + for ($i = 0; $i < count($key); $i++) { + $keys .= "" . $key[$i] . "\n"; + } + $keys = preg_replace( + + '~[\r\n]+~', + + "\r\n", + + trim($keys) + ); + die($keys); + } + + switch(true) { + case stristr($dayproduct, $product): + $day = $day + $amount; + break; + case stristr($weekproduct, $product): + $week = $week + $amount; + break; + case stristr($monthproduct, $product): + $month = $month + $amount; + break; + case stristr($lifetimeproduct, $product): + $lifetime = $lifetime + $amount; + break; + default: + die("You didn't set product URL in app settings."); + } + + $balance = $day . '|' . $week . '|' . $month . '|' . $threemonth . '|' . $sixmonth . '|' . $lifetime . '|' . $year; + // set balance + misc\mysql\query("UPDATE `accounts` SET `balance` = ? WHERE `username` = ?", [$balance, $un]); + die("Success: Reseller Balance Increased"); +} + +?> \ No newline at end of file diff --git a/api/seller/index.php b/api/seller/index.php new file mode 100644 index 0000000..ea83b1c --- /dev/null +++ b/api/seller/index.php @@ -0,0 +1,1717 @@ +getMessage()); + die(json_encode(array("success" => false, "message" => "Error: " . $errorMsg))); +}); + +if(strlen($_GET['sellerkey']) != 32) { + header('Content-Type: application/json; charset=utf-8'); + die(json_encode(array("success" => false, "message" => "Seller key should be 32 characters long. Copy it from https://keyauth.cc/app/?page=seller-settings"))); +} + +// sincey paid Networking for rate limit whitelist +$whitelistLimit = array("ec86c456645336e1db99654eac015600", "ddfb1eb55de62a4ce8f7d54715d7d5aa"); +if (!in_array($_GET['sellerkey'], $whitelistLimit)) { + if (misc\cache\rateLimit("KeyAuthSellerLimit:" . $_GET['sellerkey'], 1, 60, 120)) { + header('Content-Type: application/json; charset=utf-8'); + die(json_encode(array("success" => false, "message" => "Seller key used too frequently! Try again in 1 minute. Keep seller key private, use webhook function. Also, store data after fetching first time."))); + } +} + +$typeCount = substr_count($_SERVER['REQUEST_URI'], '?type=') + substr_count($_SERVER['REQUEST_URI'], '&type='); +// Check if 'type' appears more than once +if ($typeCount > 1) { + die(json_encode(array("success" => false, "message" => "You have \"type\" defined more than 1 time. Remove 1 of the types and keep only 1"))); +} + +$key = misc\etc\sanitize($_GET['key']); +$user = misc\etc\sanitize($_GET['user']); +$format = misc\etc\sanitize($_GET['format']); + +function success($message){ + global $format; + if ($format == "text") { + die($message); + } else { + header('Content-Type: application/json; charset=utf-8'); + die(json_encode(array( + "success" => true, + "message" => "$message" + ))); + } +} +function error($message){ + global $format; + if ($format == "text") { + die($message); + } else { + header('Content-Type: application/json; charset=utf-8'); + die(json_encode(array( + "success" => false, + "message" => "$message" + ))); + } +} + +$type = misc\etc\sanitize($_GET['type']); +if (!$type) { + error("Type not specified"); +} + +$sellerkey = misc\etc\sanitize($_GET['sellerkey']); +$row = misc\cache\fetch('KeyAuthAppSeller:' . $sellerkey, "SELECT `secret`, `owner`, `banned`, `name`, `ownerid`, `sellerLogs`, `sellerApiWhitelist` FROM `apps` WHERE `sellerkey` = ?", [$sellerkey], 0); // using a different redis key name than normal API because seller API doesn't take name and ownerid + +if ($row == "not_found") { + http_response_code(404); + error("No application found"); +} + +$secret = $row['secret']; +$owner = $row['owner']; +$name = $row['name']; +$banned = $row['banned']; +$ownerid = $row['ownerid']; +$logsEnabled = $row['sellerLogs']; +$sellerApiWhitelist = $row['sellerApiWhitelist']; +$sellerApiWhitelistPermissions = $row['sellerApiWhitelistRestrictions']; + +if ($banned) { + http_response_code(403); + error("This application has been banned from KeyAuth.cc for violating terms"); +} + +if (!is_null($sellerApiWhitelist) && $sellerApiWhitelist != api\shared\primary\getIp()) { + http_response_code(423); + error("Restricted. Only authorized IPs may use this seller key!"); +} + +if(!isset($_GET['oauth2WhitelistAPI'])) { + $sellrow = misc\cache\fetch('KeyAuthSellerCheck:' . $owner, "SELECT `role`,`expires` FROM `accounts` WHERE `username` = ?", [$owner], 0); // check if user who owns app is still has seller plan + $role = $sellrow["role"]; + + if ($role !== "seller") { + http_response_code(403); + error("Not authorized to use SellerAPI, please upgrade"); + } +} + +if (strlen($_SERVER['REQUEST_URI']) <= 900 && $logsEnabled) { + misc\mysql\query("INSERT INTO `sellerLogs` (`ip`, `path`, `date`, `app`) VALUES (?, ?, ?, ?)", [api\shared\primary\getIp(), misc\etc\sanitize('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']), time(), $secret]); + misc\mysql\query("DELETE FROM `sellerLogs` WHERE `app` = ? AND `id` NOT IN ( SELECT `id` FROM ( SELECT `id` FROM `sellerLogs` WHERE `app` = ? ORDER BY `id` DESC LIMIT 20) foo );", [$secret, $secret]); +} + +switch ($type) { + case 'add': + $expiry = misc\etc\sanitize($_GET['expiry']); + $level = misc\etc\sanitize($_GET['level']); + $owner = misc\etc\sanitize($_GET['owner']); + $letters = misc\etc\sanitize($_GET['character']); + $note = misc\etc\sanitize($_GET['note']); + + $payload = file_get_contents('php://input'); // get JSON payload from e-commerce systems that could be contacting SellerAPI. the quanity those e-commerce systems supply supersedes the quanity supplied in query paramater + /* + Known e-commerce systems that automatically prioritize their quanity supplied than the ?amount=1 paramater: + - Sell.app + - Sellix.io + - Shoppy.gg + */ + $json = json_decode($payload); + $data = $json->data; + $amount = misc\etc\sanitize($data->quantity) ?? misc\etc\sanitize($data->order->quantity) ?? misc\etc\sanitize($data->Quantity) ?? misc\etc\sanitize($_GET['amount']); + + if (is_null($expiry)) { + http_response_code(406); + error("Expiry not set"); + } + if (!is_numeric($expiry)){ + http_response_code(400); + error("Expiry must a number of days"); + } + + if (!isset($amount)) { + $amount = "1"; + } + if (!is_numeric($amount)){ + $amount = "1"; + } + + if (!isset($level)) { + $level = "1"; + } + if (!is_numeric($level)) { + $level = "1"; + } + if(strlen($level) > 12) { + error("Level too long"); + } + + if (is_null($owner)) { + $owner = "SellerAPI"; + } + + if(is_null($letters)){ + $letters = "1"; + } + + if (\misc\cache\rateLimit("SellerAPIKeyAdds:" . $secret, $amount, 86400, 5000)) { + http_response_code(429); + error("You can only generate 5000 keys per 24 hours with SellerAPI."); + } + + $mask = misc\etc\sanitize($_GET['mask']); + + if($mask == "XXXXXX-XXXXXX-XXXXXX-XXXXXX-XXXXXX-XXXXXX"){ + $mask = "******-******-******-******-******-******"; + } + + if (empty($mask)) { + $mask = "******-******-******-******-******-******"; + } + + $key = misc\license\createLicense($amount, $mask, $expiry, $level, $note, 86400, $secret, $owner, $letters); + switch ($key) { + case 'max_keys': + error("You can only generate 100 licenses at a time"); + break; + case 'dupe_custom_key': + error("Can't do custom key with amount greater than one"); + break; + default: + if ($amount > 1) { + if ($format == "text") { + $keys = NULL; + for ($i = 0; $i < count($key); $i++){ + $keys .= "" . $key[$i] . "\n"; + } + $keys = preg_replace( + + '~[\r\n]+~', + + "\r\n", + + trim($keys) + ); + success($keys); + } else { + http_response_code(302); + header('Content-Type: application/json; charset=utf-8'); + die(json_encode(array( + "success" => true, + "message" => "Licenses successfully generated", + "keys" => $key + ))); + } + } else { + if ($format == "text") { + success(array_values($key)[0]); + } else { + header('Content-Type: application/json; charset=utf-8'); + die(json_encode(array( + "success" => true, + "message" => "License Successfully Generated", + "key" => array_values($key)[0] + ))); + } + } + } + case 'addtime': + $resp = misc\license\addTime($_GET['time'], 86400, $secret); + switch ($resp) { + case 'failure': + http_response_code(500); + error("Failed to add time! Key must not be used."); + break; + case 'success': + success("Added time to unused licenses!"); + break; + default: + http_response_code(400); + error("Unhandled Error! Contact us if you need help"); + break; + } + case 'setvar': + if(empty( $_GET['var'])) { + error("Must specify variable name"); + } + if(empty( $_GET['data'])) { + error("Must specify variable data"); + } + $resp = misc\user\setVariable($user, $_GET['var'], $_GET['data'], $secret, $_GET['readOnly']); + match($resp){ + 'missing' => error("No users found!"), + 'failure' => error("Failed to set variable!"), + 'success' => success("Successfully set variable!"), + default => error("Unhandled Error! Contact support if you need help") + }; + case 'getvar': + $var = misc\etc\sanitize($_GET['var']); + + $row = misc\cache\fetch('KeyAuthUserVar:' . $secret . ':' . $var . ':' . $user, "SELECT `data`, `readOnly` FROM `uservars` WHERE `name` = ? AND `user` = ? AND `app` = ?", [$var, $user, $secret], 0); + + if ($row == "not_found") { + http_response_code(404); + error("Variable not found for user"); + } + + $data = $row['data']; + + if ($format == "text") { + success($data); + } else { + header('Content-Type: application/json; charset=utf-8'); + die(json_encode(array( + "success" => true, + "message" => "Successfully retrieved variable", + "response" => $data + ))); + } + case 'assignkey': + $query = misc\mysql\query("SELECT `banned`, `expires`, `status`, `level` FROM `keys` WHERE `key` = ? AND `app` = ?", [$key, $secret]); + + if ($query->affected_rows === 0) { + error("License not found!"); + } elseif ($query->num_rows > 0){ + while ($row = mysqli_fetch_array($query->result)){ + $expires = $row['expires']; + $status = $row['status']; + $level = $row['level']; + $banned = $row['banned']; + } + + if ($status == "Used"){ + error("Key is already assigned to a user!"); + } + + if (!is_null($banned)){ + error("Key is banned, and can not be assigned!"); + } + + $expiry = $expires + time(); + + $query = misc\mysql\query("SELECT `name` FROM `subscriptions` WHERE `app` = ? AND `level` = ?", [$secret, $level]); + $subName = mysqli_fetch_array($query->result)['name']; + + $resp = misc\user\extend($user, $subName, $expiry, 0, $secret); + switch ($resp){ + case 'missing': + error("Username not found!"); + break; + case 'sub_missing': + error("Subscription not found!"); + break; + case 'failure': + error("Failed to upgrade!(aka assign key)"); + break; + case 'success': + misc\mysql\query("UPDATE `keys` SET `status` = 'Used', `usedon` = ?, `usedby` = ? WHERE `key` = ? AND `app` = ?", [time(), $user, $key, $secret]); + misc\cache\purge('KeyAuthKeys:' . $secret . ':' . $key); + misc\cache\purge('KeyAuthSubs:' . $secret . ':' . $user); + success("Successfully Assigned Key To User!"); + break; + default: + error("Unhandled Error! Contact support if you need help!"); + break; + } + } + case 'massUserVarDelete': + $name = misc\etc\sanitize($_GET['name']); + + $query = misc\mysql\query("DELETE FROM `uservars` WHERE `name` = ? AND `app` = ?", [$name, $secret]); + if ($query->affected_rows > 0) { + misc\cache\purgePattern('KeyAuthUserVar:' . $secret); + success("Successfully deleted user variables with that name!"); + } else { + error("Failed to delete user variables with that name!"); + } + case 'addAccount': + /* + Create Manager or Reseller accounts through SellerAPI + + This is highly recommended instead of sharing your account with someone. + + Sharing your account is against our ToS plus often leads to the person you're sharing with doing something malicious (if they turn on you) + */ + $resp = misc\account\addAccount($user, $_GET['role'], $_GET['email'], $_GET['pass'], $_GET['keylevels'], $owner, $name, $_GET['perms'] ?? 2047); + match($resp){ + 'invalid_perms' => error("Invalid permission value. You must have at least one permission flag enabled!"), + 'invalid_role' => error("Role options are Manager or Reseller!"), + 'username_taken' => error("Username already taken!"), + 'email_taken' => error("Email already taken!"), + 'failure' => error("Failed to add account!"), + 'success' => success("Successfully added account!"), + default => error("Unhandled Error! Contact support if you need help") + }; + case 'deleteAccount': + $query = misc\mysql\query("DELETE FROM `accounts` WHERE `owner` = ? AND `app` = ? AND `username` = ?", [$owner, $name, $user]); + if ($query->affected_rows > 0) { + success("Successfully deleted account!"); + } else { + error("Failed to delete account!"); + } + case 'fetchallblacks': + $rows = misc\cache\fetch('KeyAuthBlacks:' . $secret, "SELECT `hwid`, `ip`, `type` FROM `bans` WHERE `app` = ?", [$secret], 1, 1800); + + if ($rows == "not_found") { + http_response_code(406); + error("No blacklists found"); + } + + header('Content-Type: application/json; charset=utf-8'); + die(json_encode(array( + "success" => true, + "message" => "Successfully retrieved blacklists", + "blacklists" => $rows + ))); + case 'fetchallsubs': + $rows = misc\cache\fetch('KeyAuthSubscriptions:' . $secret, "SELECT `name`, `level` FROM `subscriptions` WHERE `app` = ?", [$secret], 1, 1800); + + if ($rows == "not_found") { + http_response_code(406); + error("No subscriptions found"); + } + + header('Content-Type: application/json; charset=utf-8'); + die(json_encode(array( + "success" => true, + "message" => "Successfully retrieved subscriptions", + "subs" => $rows + ))); + case 'fetchalluservars': + $rows = misc\cache\fetch('KeyAuthUserVars:' . $secret, "SELECT `name`, `data`, `user` FROM `uservars` WHERE `app` = ?", [$secret], 1, 1800); + + if ($rows == "not_found") { + http_response_code(406); + error("No user variables Found"); + } + + header('Content-Type: application/json; charset=utf-8'); + die(json_encode(array( + "success" => true, + "message" => "Successfully retrieved user variables", + "vars" => $rows + ))); + case 'fetchallfiles': + $rows = misc\cache\fetch('KeyAuthFiles:' . $secret, "SELECT `id`, `url` FROM `files` WHERE `app` = ?", [$secret], 1, 1800); + + if ($rows == "not_found") { + http_response_code(406); + error("No files Found"); + } + + header('Content-Type: application/json; charset=utf-8'); + die(json_encode(array( + "success" => true, + "message" => "Successfully retrieved files", + "files" => $rows + ))); + case 'fetchallvars': + $rows = misc\cache\fetch('KeyAuthVars:' . $secret, "SELECT `varid`, `msg`,`authed` FROM `vars` WHERE `app` = ?", [$secret], 1, 1800); + + if ($rows == "not_found") { + http_response_code(406); + error("No variables Found"); + } + + header('Content-Type: application/json; charset=utf-8'); + die(json_encode(array( + "success" => true, + "message" => "Successfully retrieved variables", + "vars" => $rows + ))); + case 'addvar': + if(strlen($_GET['data']) > 1000) error("Data is too long. Must be less than 1000 characters. Use files for larger data"); + + if (!is_numeric($_GET['authed'])) error("Authed paramater must be 1 if you want to require login first, or 0 if you don't want to."); + + $resp = misc\variable\add($_GET['name'], $_GET['data'], $_GET['authed'], $secret); + match($resp){ + 'exists' => error("Varialbe name already exists!"), + 'too_long' => error("Variable too long! Must be 1000 characters or less!"), + 'failure' => error("Failed to create variable!"), + 'success' => success("Successfully created variable!"), + default => error("Unhandled Error! Contact support if you need help") + }; + case 'addsub': + if(strlen($_GET['level']) > 12) { + error("Level too long"); + } + if(!is_numeric($_GET['level'])) { + error("Level must be a number"); + } + + $resp = misc\sub\add($_GET['name'], $_GET['level'], $secret); + match($resp){ + 'failure' => error("Failed to create subscription!"), + 'success' => success("Successfully created subscription!"), + default => error("Unhandled Error! Contact support if you need help") + }; + case 'delappsub': + $resp = misc\sub\deleteSingular($_GET['name'], $secret); + match($resp){ + 'failure' => error("Failed to delete subscription!"), + 'success' => success("Successfully deleted subscription!"), + default => error("Unhandled Error! Contact support if you need help") + }; + case 'pauseuser': + $resp = misc\user\pauseUser($_GET['username'], $secret); + match($resp){ + 'failure' => error("Failed to pause user!"), + 'success' => success("Successfully paused user!"), + default => error("Unhandled Error! Contact support if you need help") + }; + case 'unpauseuser': + $resp = misc\user\unpauseUser($_GET['username'], $secret); + match($resp){ + 'failure' => error("Failed to unpause user!"), + 'success' => success("Successfully unpaused user!"), + default => error("Unhandled Error! Contact support if you need help") + }; + case 'addchannel': + if(is_null($_GET['name'])) { + error("Channel name not specified"); + } + + $resp = misc\chat\createChannel($_GET['name'], $_GET['delay'], $secret); + match($resp){ + 'failure' => error("Failed to create channel!"), + 'success' => success("Successfully created channel!"), + default => error("Unhandled Error! Contact support if you need help") + }; + case 'delchannel': + $resp = misc\chat\deleteChannel($_GET['name'], $secret); + match($resp){ + 'failure' => error("Failed to delete channel!"), + 'success' => success("Successfully deleted channel!"), + default => error("Unhandled Error! Contact support if you need help") + }; + case 'clearchannel': + $resp = misc\chat\clearChannel($_GET['name'], $secret); + match($resp){ + 'failure' => error("Failed to clear channel!"), + 'success' => success("Successfully cleared channel!"), + default => error("Unhandled Error! Contact support if you need help") + }; + case 'muteuser': + if (!is_numeric($_GET['time'])) error("Invalid time paramater, must be number"); + + $timeout = $_GET['time'] + time(); + $resp = misc\chat\muteUser($_GET['user'], $timeout, $secret); + match($resp){ + 'missing' => error("User doesn't exist!"), + 'failure' => error("Failed to mute user!"), + 'success' => success("Successfully muted user!"), + default => error("Unhandled Error! Contact support if you need help") + }; + case 'unmuteuser': + $resp = misc\chat\unMuteUser($_GET['user'], $secret); + match($resp){ + 'failure' => error("Failed to unmute user!"), + 'success' => success("Successfully unmuted user!"), + default => error("Unhandled Error! Contact support if you need help") + }; + case 'kill': + $resp = misc\session\killSingular($_GET['sessid'], $secret); + match($resp){ + 'failure' => error("Failed to kill session!"), + 'success' => success("Successfully killed session!"), + default => error("Unhandled Error! Contact support if you need help") + }; + case 'killall': + $resp = misc\session\killAll($secret); + match($resp){ + 'failure' => error("Failed to kill all sessions!"), + 'success' => success("Successfully killed all sessions!"), + default => error("Unhandled Error! Contact support if you need help") + }; + case 'addwebhook': + if (!is_numeric($_GET['authed'])) error("Authed paramater must be 1 if you want to require login first, or 0 if you don't want to."); + + $resp = misc\webhook\add($_GET['webid'], $_GET['baseurl'], $_GET['ua'], $_GET['authed'], $secret); + match($resp){ + 'invalid_url' => error("URL isn't a valid URL!"), + 'no_local' => error("URL can't be a local path! Must be a remote URL accessible by the open internet!"), + 'failure' => error("Failed to add webhook!"), + 'success' => success("Successfully added webhook!"), + default => error("Unhandled Error! Contact support if you need help") + }; + + case 'delallwebhooks': + $resp = misc\webhook\deleteAll($secret); + match($resp){ + 'failure' => error("Failed to find any webhooks!"), + 'success' => success("Successfully deleted all webhooks!"), + default => error("Unhandled Error! Contact support if you need help!") + }; + case 'black': + $ipaddr = misc\etc\sanitize($_GET['ip']); + $hwid = misc\etc\sanitize($_GET['hwid']); + + if (!empty($hwid)) { + misc\blacklist\add($hwid, "Hardware ID", $secret); + } + + if (!empty($ipaddr)) { + misc\blacklist\add($ipaddr, "IP Address", $secret); + } + + success("Blacklist Addition Successful"); + case 'delblack': + $resp = misc\blacklist\deleteSingular($_GET['data'], $_GET['blacktype'], $secret); + match($resp){ + 'invalid' => error("Invalid blacklist type!"), + 'failure' => error("Failed to delete blacklist!"), + 'success' => success("Successfully deleted blacklist!"), + default => error("Unhandled Error! Contact support if you need help") + }; + case 'appdetails': + $row = misc\cache\fetch('KeyAuthApp:' . $name . ':' . $owner, "SELECT * FROM `apps` WHERE `ownerid` = ? AND `name` = ?",[$ownerid, $name], 0); + $ver = $row["ver"]; + + header('Content-Type: application/json; charset=utf-8'); + die (json_encode(array( + "success" => true, + "message" => "Fetched Application Details Successfully", + "appdetails" => array( + "name" => "$name", + "ownerid" => "$ownerid", + "secret" => "$secret", + "version" => "$ver" + ) + ))); + case 'delblacks': + $resp = misc\blacklist\deleteAll($secret); + match($resp){ + 'failure' => error("Failed to delete all blacklists!"), + 'success' => success("Successfully deleted all blacklists!"), + default => error("Unhandled Error! Contact support if you need help") + }; + case 'addWhite': + $resp = misc\whitelist\addWhite($_GET['ip'], $secret); + match($resp){ + 'failure' => error("Failed to add whitelist!"), + 'success' => success("Successfully added whitelist!"), + default => error("Unhandled Error! Contact support if you need help") + }; + case 'delWhite': + $resp = misc\whitelist\deleteWhite($_GET['ip'], $secret); + match($resp){ + 'failure' => error("Failed to delete whitelist!"), + 'success' => success("Successfully deleted whitelist!"), + default => error("Unhandled Error! Contact support if you need help") + }; + case 'activate': + $pass = misc\etc\sanitize($_GET['pass']); + $hwid = misc\etc\sanitize($_GET['hwid']); + + $resp = api\v1_0\register($user, $key, $pass, NULL, $hwid, $secret); + switch ($resp) { + case 'username_taken': + error("Username Already Exists."); + case 'key_not_found': + error("Key Not Found."); + case 'key_already_used': + error("Key Already Used."); + case 'key_banned': + error("Your license is banned."); + case 'hwid_blacked': + error("HWID is blacklisted"); + case 'no_subs_for_level': + error("No active subscriptions found."); + default: + header('Content-Type: application/json; charset=utf-8'); + die(json_encode(array( + "success" => true, + "message" => "Logged in!", + "info" => array( + "username" => "$user", + "subscriptions" => $resp, + "ip" => $_SERVER["HTTP_X_FORWARDED_FOR"] + ) + ))); + } + case 'resetpw': + $passwd = misc\etc\sanitize($_GET['passwd']); + if (!is_null($passwd)) $passwd = password_hash($passwd, PASSWORD_BCRYPT); + $query = misc\mysql\query("UPDATE `users` SET `password` = NULLIF(?,'') WHERE `username` = ? AND `app` = ?", [$passwd, $user, $secret]); + + if ($query->affected_rows > 0) { + misc\cache\purge('KeyAuthUser:' . $secret . ':' . $user); + success("Password reset successful"); + } else { + http_response_code(500); + error("Failed To reset password"); + } + case 'editemail': + $email = misc\etc\sanitize($_GET['email']); + $resp = misc\user\changeEmail($user, $email, $secret); + match($resp){ + 'failure' => error("Failed to change email!"), + 'success' => success("Successfully changed email!"), + default => error("Unhandled Error! Contact support if you need help") + }; + case 'editusername': + $currentUsername = misc\etc\sanitize($_GET['currentUsername']); + $newUsername = misc\etc\sanitize($_GET['newUsername']); + $sessionID = misc\etc\sanitize($_GET['sessionID']); + + $resp = misc\user\changeUsername($currentUsername, $newUsername, $secret); + switch($resp){ + case 'already_used': + error("Username already used!"); + break; + case 'failure': + error("Failed to change username!"); + break; + case 'success': + misc\session\killSingular($sessionID, $secret); + success("Successfully changed username, user logged out!"); + break; + default: + error("Unhandled Error! Contact support if you need assistance!"); + break; + } + case 'editsub': + $sub = misc\etc\sanitize($_GET['sub']); + $level = misc\etc\sanitize($_GET['level']); + $query = misc\mysql\query("UPDATE `subscriptions` SET `level` = ? WHERE `name` = ? AND `app` = ?", [$level, $sub, $secret]); + + if ($query->affected_rows > 0) { + success("Subscription successfully edited"); + } else { + error("Failed to edit subscription"); + } + case 'setnote': + $note = misc\etc\sanitize($_GET['note']); + if(strlen($note) > 69) { + error("Note must be less than 69 characters"); + } + + $query = misc\mysql\query("UPDATE `keys` SET `note` = ? WHERE `key` = ? AND `app` = ?", [$note, $key, $secret]); + + if ($query->affected_rows > 0) { + misc\cache\purge('KeyAuthKey:' . ($secret ?? $_SESSION['app']) . ':' . $key); + misc\cache\purge('KeyAuthKeys:' . ($secret ?? $_SESSION['app'])); + success("Successfully set note"); + } else { + error("Failed to set note"); + } + case 'fetchnote': + $row = misc\cache\fetch('KeyauthKey:' . $secret . ':' . $key, "SELECT `note` FROM `keys` WHERE `app` = ? AND `key` = ?",[$secret, $key], 0); + + if ($row == "not_found"){ + die(json_encode(array( + "success" => false, + 'message' => "Key not found" + ))); + } + + $note = $row["note"]; + die(json_encode(array( + "note" => $note, + ))); + case 'countsubs': + $name = misc\etc\sanitize($_GET['name']); + + if (is_null($name)) { + error("Paramater with name \"name\" missing"); + } + + $row = misc\cache\fetch('KeyAuthSubStats:' . $secret . ':' . $name, "SELECT COUNT(*) AS 'numSubs' FROM `subs` WHERE `app` = ? AND `subscription` = ? AND `expiry` > ?", [$secret, $name, time()], 0, 1800, "ssi"); + $numSubs = $row['numSubs']; + + header('Content-Type: application/json; charset=utf-8'); + die(json_encode(array( + "success" => true, + "message" => "Subscription count found successfully", + "count" => $numSubs + ))); + case 'editvar': + if(strlen($_GET['data']) > 1000) error("Data is too long. Must be less than 1000 characters. Use files for larger data"); + + $varid = misc\etc\sanitize($_GET['varid']); + $data = misc\etc\sanitize($_GET['data']); + misc\mysql\query("UPDATE `vars` SET `msg` = ? WHERE `varid` = ? AND `app` = ?", [$data, $varid, $secret]); + misc\cache\purge('KeyAuthVar:' . $secret . ':' . $varid); + success("Variable Edit Successful"); + case 'retrvvar': + $name = misc\etc\sanitize($_GET['name']); + $row = misc\cache\fetch('KeyAuthVar:' . $secret . ':' . $name, "SELECT `msg`, `authed` FROM `vars` WHERE `varid` = ? AND `app` = ?", [$name, $secret], 0); // API uses `authed` column so it's best to use it here too to not have two different redis keys + + if ($row == "not_found") { + error("Variable not found"); + } + + $authed = $row["authed"]; + $data = $row["msg"]; + + header('Content-Type: application/json; charset=utf-8'); + die(json_encode(array( + "success" => true, + "message" => $data, + "authed" => $authed ? "true" : "false" + ))); + case 'delvar': + $resp = misc\variable\deleteSingular($_GET['name'], $secret); + match($resp){ + 'failure' => error("Failed to delete variable!"), + 'success' => success("Successfully deleted variable!"), + default => error("Unhandled Error! Contact support if you need help") + }; + case 'pauseapp': + $query = misc\mysql\query("SELECT `expiry` FROM `subs` WHERE `app` = ? AND `expiry` > ?", [$secret, time()]); + while ($row = mysqli_fetch_array($query->result)) { + $expires = $row['expiry']; + $exp = $expires - time(); + misc\mysql\query("UPDATE `subs` SET `paused` = 1, `expiry` = ? WHERE `app` = ? AND `id` = ?", [$exp, $secret, $row['id']]); + } + $query = misc\mysql\query("UPDATE `apps` SET `paused` = 1 WHERE `secret` = ?", [$secret]); + + misc\cache\purge('KeyAuthApp:' . $name . ':' . $ownerid); + misc\cache\purgePattern('KeyAuthSubs:' . $secret); + + if ($query->affected_rows > 0) { + success("Successfully paused application"); + } else { + error("Failed to pause application"); + } + case 'pausesub': + $subscription = misc\etc\sanitize($_GET['subscription']); + $resp = misc\sub\pause($subscription, $secret); + match($resp){ + 'success' => success("Successfully paused subscription!"), + 'failure' => error("Failed to pause subscription!"), + default => error("Unhandled Error! Contact support for further assistance!") + }; + case 'unpausesub': + $subscription = misc\etc\sanitize($_GET['subscription']); + $resp = misc\sub\unpause($subscription, $secret); + match($resp){ + 'success' => success("Successfully unpaused subscription!"), + 'failure' => error("Failed to unpause subscription!"), + default => error("Unhandled Error! Contact support for further assistance!") + }; + case 'unpauseapp': + $query = misc\mysql\query("SELECT `expiry` FROM `subs` WHERE `app` = ? AND `paused` = 1", [$secret]); + while ($row = mysqli_fetch_array($query->result)) { + $expires = $row['expiry']; + $exp = $expires + time(); + misc\mysql\query("UPDATE `subs` SET `paused` = 0, `expiry` = ? WHERE `app` = ? AND `id` = ?", [$exp, $secret, $row['id']]); + } + $query = misc\mysql\query("UPDATE `apps` SET `paused` = 0 WHERE `secret` = ?", [$secret]); + + misc\cache\purge('KeyAuthApp:' . $name . ':' . $ownerid); + misc\cache\purgePattern('KeyAuthSubs:' . $secret); + + if ($query->affected_rows > 0) { + success("Successfully unpaused application"); + } else { + error("Failed to unpause application"); + } + case 'stats': + $row = misc\cache\fetch('KeyAuthAppStatsSeller:' . $secret, "SELECT (SELECT COUNT(1) FROM `keys` WHERE `app` = ? AND `status` = 'Not Used') AS `unused`, (SELECT COUNT(1) FROM `keys` WHERE `app` = ? AND `status` = 'Used') AS `used`, (SELECT COUNT(1) FROM `keys` WHERE `app` = ? AND `status` = 'Paused') AS `paused`, (SELECT COUNT(1) FROM `keys` WHERE `app` = ? AND `status` = 'Banned') AS `banned`, (SELECT COUNT(1) FROM `webhooks` WHERE `app` = ?) AS `webhooks`, (SELECT COUNT(1) FROM `files` WHERE `app` = ?) AS `files`, (SELECT COUNT(1) FROM `vars` WHERE `app` = ?) AS `vars`, (SELECT COUNT(1) FROM `accounts` WHERE `owner` = ? AND `app` = ? AND `role` = 'Reseller') AS `resellers`, (SELECT COUNT(1) FROM `accounts` WHERE `owner` = ? AND `app` = ? AND `role` = 'Manager') AS `managers`;", [$secret, $secret, $secret, $secret, $secret, $secret, $secret, $owner, $secret, $owner, $secret], 0, 1800); + $unused = $row["unused"]; + $used = $row["used"]; + $paused = $row["paused"]; + $banned = $row["banned"]; + $totalkeys = $unused + $used + $paused + $banned; + $webhooks = $row["webhooks"]; + $files = $row["files"]; + $vars = $row["vars"]; + $resellers = $row["resellers"]; + $managers = $row["managers"]; + $totalaccs = $resellers + $managers; + + header('Content-Type: application/json; charset=utf-8'); + die(json_encode(array( + "success" => true, + "unused" => "$unused", + "used" => "$used", + "paused" => "$paused", + "banned" => "$banned", + "totalkeys" => "$totalkeys", + "webhooks" => "$webhooks", + "files" => "$files", + "vars" => "$vars", + "resellers" => "$resellers", + "managers" => "$managers", + "totalaccs" => "$totalaccs" + ))); + case 'addhwiduser': + $hwid = misc\etc\sanitize($_GET['hwid']); + $query = misc\mysql\query("SELECT `hwid` FROM `users` WHERE `username` = ? AND `app` = ?", [$user, $secret]); + $row = mysqli_fetch_array($query->result); + $newHwid = $row["hwid"]; + + $newHwid = $newHwid .= $hwid; + + misc\mysql\query("UPDATE `users` SET `hwid` = ? WHERE `username` = ? AND `app` = ?", [$newHwid, $user, $secret]); + + misc\cache\purge('KeyAuthUser:' . $secret . ':' . $user); + + success("Added HWID"); + case 'addhash': + $resp = misc\app\addHash($_GET['hash'], $secret); + match($resp){ + 'failure' => error("Failed to add hash!"), + 'success' => success("Successfully added hash!"), + default => error("Unhandled Error! Contact support if you need help!") + }; + case 'getkey': + $row = misc\cache\fetch('KeyAuthKeyFromUser:' . $secret . ':' . $user, "SELECT `key` FROM `keys` WHERE `usedby` = ? AND `app` = ?", [$user, $secret], 0); + if ($row == "not_found") { + error("License not found"); + } + $key = $row["key"]; + + header('Content-Type: application/json; charset=utf-8'); + die(json_encode(array( + "success" => true, + "key" => $key + ))); + case 'userdata': + $query = misc\mysql\query("SELECT * FROM users WHERE username = ? AND app = ?", [$user, $secret]); + if ($query->num_rows < 1) { + error("User not found"); + } + + $row = mysqli_fetch_array($query->result); + + $hwid = $row['hwid']; + $ip = $row['ip']; + $createdate = $row['createdate']; + $lastlogin = $row['lastlogin']; + $cooldown = $row["cooldown"]; + $password = $row['password']; + $token = md5(substr($row["password"], -5)); + $banned = $row["banned"]; + + $query = misc\mysql\query("SELECT `subscription`, `key`, `expiry` FROM `subs` WHERE `user` = ? AND `app` = ? AND `expiry` > ?", [$user, $secret, time()]); + while ($r = mysqli_fetch_assoc($query->result)) { + $subData[] = $r; + } + $subscriptions = ($query->num_rows < 1) ? [] : $subData; + + $query = misc\mysql\query("SELECT `name`, `data` FROM `uservars` WHERE `user` = ? AND `app` = ?", [$user, $secret]); + while ($r = mysqli_fetch_assoc($query->result)) { + $varData[] = $r; + } + $userVars = ($query->num_rows < 1) ? [] : $varData; + + header('Content-Type: application/json; charset=utf-8'); + // success + die(json_encode(array( + "success" => true, + "username" => $user, + "subscriptions" => $subscriptions, + "uservars" => $userVars, + "ip" => $ip, + "hwid" => $hwid, + "createdate" => $createdate, + "lastlogin" => $lastlogin, + "cooldown" => $cooldown, + "password" => $password, + "token" => $token, + "banned" => $banned + ))); + case 'extend': + if (!is_numeric($_GET['expiry'])) error("Expiry not set correctly, must be number of days"); + + $expiry = $_GET['expiry'] * 86400 + time(); // 86400 is the number of seconds in a day since we're using unix time + $resp = misc\user\extend($user, $_GET['sub'], $expiry, $_GET['activeOnly'], $secret); + match($resp){ + 'missing' => error("User(s) not found!"), + 'sub_missing' => error("Subscription not found!"), + 'date_past' => error("Subscription expiry must be set in the future!"), + 'failure' => error("Failed to extend user(s)"), + 'success' => success("Successfully extended user(s)!"), + default => error("Unhandled Error! Contact support if you need help") + }; + case 'subtract': + $resp = misc\user\subtract($user, $_GET['sub'], $_GET['seconds'], $secret); + match($resp){ + 'invalid_seconds' => error("Seconds specified must be greater than zero!"), + 'failure' => error("Failed to subtract from susbcriptions!"), + 'success' => success("Successfully subtracted time from subscription!"), + default => error("Unhandled Error! Contact support if you need help") + }; + case 'verify': + $query = misc\mysql\query("SELECT 1 FROM `keys` WHERE `app` = ? AND `key` = ?", [$secret, $key]); + + if ($query->num_rows > 0) { + success("Key Successfully Verified"); + } else { + http_response_code(406); + error("Key Not Found"); + } + case 'verifyuser': + $query = misc\mysql\query("SELECT 1 FROM `users` WHERE `app` = ? AND `username` = ?", [$secret, $user]); + + if ($query->num_rows > 0) { + success("User Successfully Verified"); + } else { + http_response_code(406); + error("User Not Found"); + } + case 'del': + $resp = misc\license\deleteSingular($key, $_GET['userToo'], $secret); + match($resp){ + 'failure' => error("Failed to delete license!"), + 'success' => success("Successfully deleted license!"), + default => error("Unhandled Error! Contact support if you need help") + }; + case 'delmultiple': + $resp = misc\license\deleteMultiple($_GET['key'], $_GET['userToo'], $secret); + match ($resp){ + 'failure' => error("Failed to delete license(s)"), + 'success' => success("Successfully deleted license(s)"), + default => error("Unhandled Error! Contact support if you need help!") + }; + case 'ban': + $resp = misc\license\ban($key, $_GET['reason'], $_GET['userToo'], $secret); + match($resp){ + 'failure' => error("Failed to ban license!"), + 'success' => success("Successfully banned license!"), + default => error("Unhandled Error! Contact support if you need help") + }; + case 'unban': + $resp = misc\license\unban($key, $secret); + match($resp){ + 'failure' => error("Failed to unban license!"), + 'success' => success("Successfully unbanned license!"), + default => error("Unhandled Error! Contact support if you need help") + }; + case 'banuser': + if(empty($_GET['reason'])) { + error("Ban reason is missing"); + } + + $resp = misc\user\ban($user, $_GET['reason'], $secret); + match($resp){ + 'missing' => error("User not found!"), + 'failure' => error("Failed to ban user!"), + 'success' => success("Successfully banned user!"), + default => error("Unhandled Error! Contact support if you need help") + }; + case 'unbanuser': + $resp = misc\user\unban($user, $secret); + match($resp){ + 'missing' => error("User not found!"), + 'failure' => error("Failed to unban user!"), + 'success' => success("Successfully unbanned user!"), + default => error("Unhandled Error! Contact support if you need help") + }; + case 'deluservar': + $resp = misc\user\deleteVar($user, $_GET['var'], $secret); + match($resp){ + 'failure' => error("Failed to delete variable"), + 'success' => success("Successfully deleted variable"), + default => error("Unhandled Error! Contact support if you need help") + }; + case 'delsub': + $resp = misc\user\deleteSub($user, $_GET['sub'], $secret); + match($resp){ + 'failure' => error("Failed to delete subscription!"), + 'success' => success("Successfully deleted subscription!"), + default => error("Unhandled Error! Contact support if you need help") + }; + case 'delunused': + $resp = misc\license\deleteAllUnused($secret); + match($resp){ + 'failure' => error("Didn't find any unused keys!"), + 'success' => success("Successfully deleted all unused keys!"), + default => error("Unhandled Error! Contact support if you need help") + }; + case 'delused': + $resp = misc\license\deleteAllUsed($secret); + match($resp){ + 'failure' => error("Didn't find any used keys!"), + 'success' => success("Successfully deleted all used keys!"), + default => error("Unhandled Error! Contact support if you need help") + }; + case 'adduser': + if (!is_numeric($_GET['expiry'])) error("Expiry not set correctly, must be number of days"); + + if(empty($_GET['user'])) error("You must specify username."); + + $expiry = $_GET['expiry'] * 86400 + time(); // 86400 is the number of seconds in a day since we're using unix time + $resp = misc\user\add($user, $_GET['sub'], $expiry, $secret, $_GET['pass']); + match($resp){ + 'already_exist' => error("Username already exists!"), + 'username_not_allowed' => error("Username not allowed!"), + 'sub_paused' => error("Unable to create user while subscription is paused!"), + 'sub_missing' => error("Subscription not found!"), + 'date_past' => error("Subscription expiry must be set in the future!"), + 'failure' => error("Failed to create user!"), + 'success' => success("Successfully created user!"), + default => error("Unhandled Error! Contact support if you need help") + }; + case 'delexpusers': + $resp = misc\user\deleteExpiredUsers($secret); + match($resp){ + 'missing' => error("You have no users!"), + 'failure' => error("No users are expired!"), + 'success' => success("Successfully deleted expired users!"), + default => error("Unhandled Error! Contact support if you need help") + }; + case 'delallusers': + $resp = misc\user\deleteAll($secret); + match($resp){ + 'failure' => error("Failed to delete all users!"), + 'success' => success("Successfully deleted all users!"), + default => error("Unhandled Error! Contact us if you need help") + }; + case 'deluser': + $resp = misc\user\deleteSingular($user, $secret); + match($resp){ + 'failure' => error("Failed to delete user!"), + 'success' => success("Successfully deleted user!"), + default => error("Unhandled Error! Contact support if you need help") + }; + case 'delalllicenses': + $resp = misc\license\deleteAll($secret); + match($resp){ + 'failure' => error("Didn't find any keys!"), + 'success' => success("Deleted all keys!"), + default => error("Unhandled Error! Contact support if you need help") + }; + case 'delallvars': + $resp = misc\variable\deleteAll($secret); + match($resp){ + 'failure' => error("Failed to delete all variables!"), + 'success' => success("Successfully deleted all variables!"), + default => error("Unhandled Error! Contact support if you need help") + }; + case 'reset': + die("Endpoint Deprecated, you can no longer use keys directly. A user is created from the key, and that user has a HWID and IP associated with it."); + case 'resethash': + $resp = misc\app\resetHash($secret, $name, $ownerid); + match($resp){ + 'failure' => error("Failed to reset hash!"), + 'success' => success("Successfully reset hash!"), + default => error("Unhandled Error! Contact support if you need help") + }; + case 'setcooldown': + $cooldown = misc\etc\sanitize($_GET['cooldown']); + + $query = misc\mysql\query("UPDATE `users` SET `cooldown` = ? WHERE `app` = ? AND `username` = ?", [$cooldown, $secret, $user]); + + if ($query->affected_rows > 0) { + misc\cache\purge('KeyAuthUserData:' . $secret . ':' . $user); + success("Cooldown set successfully!"); + } + + error("Failed to set cooldown!"); + case 'resetuser': + $resp = misc\user\resetSingular($user, $secret); + match($resp){ + 'failure' => error("Failed to reset user!"), + 'success' => success("Successfully reset user!"), + default => error("Unhandled Error! Contact support if you need help") + }; + case 'resetalluser': + $resp = misc\user\resetAll($secret); + match($resp){ + 'failure' => error("Failed to reset all users!"), + 'success' => success("Successfully reset all users!"), + default => error("Unhandled Error! Contact support if you need help") + }; + case 'upload': + $url = misc\etc\sanitize($_GET['url']); + + if (!filter_var($url, FILTER_VALIDATE_URL)) { + error("URL is invalid"); + } + + if (str_contains($url, "discord")) { + error("Discord's developers made files expire after 24 hours, use catbox.moe or pages.dev instead!"); + } + + if(str_contains($url, "localhost") || str_contains($url, "127.0.0.1") || str_contains($url, "file:/")) { + error("URL can't be a local path! Must be a remote URL accessible by the open internet"); + } + + $file = file_get_contents($url); + + $filesize = strlen($file); + + if ($filesize > 75000000) { + error("File size limit is 75 MB."); + } + + $id = misc\etc\generateRandomNum(); + $fn = basename($url); + $fs = misc\etc\formatBytes($filesize); + + misc\mysql\query("INSERT INTO `files` (name, id, url, size, uploaddate, app) VALUES (?, ?, ?, ?, ?, ?)", [$fn, $id, $url, $fs, time(), $secret]); + + if ($format == "text") { + die("File ID " . $id . " Uploaded Successfully"); + } else { + header('Content-Type: application/json; charset=utf-8'); + die(json_encode(array( + "success" => true, + "message" => "File ID " . $id . " Uploaded Successfully", + "id" => $id + ))); + } + case 'fetchfile': + $fileid = misc\etc\sanitize($_GET['id']); + + $result = misc\mysql\query("SELECT `id`, `url`, `name`, `size`, `authed` FROM `files` WHERE `id` = ? AND `app` = ?", [$fileid, $secret]); + $response = mysqli_fetch_assoc($result->result); + + if (!$response) { + http_response_code(406); + error("No file Found with ID: $fileid"); + } + + header('Content-Type: application/json; charset=utf-8'); + die(json_encode(array( + "success" => true, + "message" => "Successfully retrieved file", + "file" => $response + ))); + case 'editfile': + $fileUrl = misc\etc\sanitize($_GET['url']); + $fileAuthed = misc\etc\sanitize($_GET['authed']); + $fileid = misc\etc\sanitize($_GET['id']); + + // Initialize cURL session + $ch = curl_init($fileUrl); + + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Fetch the entire content + curl_setopt($ch, CURLOPT_HEADER, true); // Include headers in the response + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // Follow redirects + curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla KeyAuth'); + + $response = curl_exec($ch); + + $httpStatusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); + + if ($httpStatusCode != 200) { + error("Failed to fetch file. HTTP Status: $httpStatusCode"); + } + + $contentLength = curl_getinfo($ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD); + + if ($contentLength <= 0) { + $body = substr($response, curl_getinfo($ch, CURLINFO_HEADER_SIZE)); + $fileSizeActual = misc\etc\formatBytes(strlen($body)); + } else { + $fileSizeActual = misc\etc\formatBytes($contentLength); + } + + $fileName = basename(parse_url($fileUrl, PHP_URL_PATH)); + + curl_close($ch); + + $result = misc\mysql\query("UPDATE `files` SET `name` = ?, `size` = ?, `url` = ?, `authed` = ? WHERE `id` = ? AND `app` = ?", [$fileName, $fileSizeActual, $fileUrl, $fileAuthed, $fileid, $secret]); + + if ($result->affected_rows > 0) { + success("Successfully updated file"); + } else { + error("Failed to update file"); + } + case 'delfile': + $resp = misc\upload\deleteSingular($_GET['fileid'], $secret); + match($resp){ + 'failure' => error("Failed to delete all files!"), + 'success' => success("Successfully deleted files!"), + default => error("Unhandled Error! Contact support if you need help") + }; + case 'delallfiles': + $resp = misc\upload\deleteAll($secret); + match($resp){ + 'failure' => error("Failed to delete all files!"), + 'success' => success("Successfully deleted all files!"), + default => error("Unhandled Error! Contact us if you need help") + }; + case 'fetchallchats': + $rows = misc\cache\fetch('KeyAuthChats:' . $secret, "SELECT `name`, `delay` FROM `chats` WHERE `app` = ?", [$secret], 1, 1800); + + if ($rows == "not_found") { + http_response_code(406); + error("No chats found"); + } + + header('Content-Type: application/json; charset=utf-8'); + die(json_encode(array( + "success" => true, + "message" => "Successfully retrieved chats", + "chats" => $rows + ))); + case 'fetchallwebhooks': + $rows = misc\cache\fetch('KeyAuthWebhook:' . $secret, "SELECT `webid`, LEFT(`baselink`, 21) AS `short_baselink`, `useragent`, `app`, `authed` FROM `webhooks` WHERE `app` = ?", [$secret], 1, 1800); + + if ($rows == "not_found"){ + http_response_code(406); + error("No webhooks found"); + } + + header('Content-Type: application/json; charset=utf-8'); + die(json_encode(array( + "success" => true, + "message" => "Successfully retrieved all webhooks", + "webhooks" => $rows + ))); + case 'fetchallsessions': + $rows = misc\cache\fetch('KeyAuthSessions:' . $secret, "SELECT `id`, `credential`, `expiry`, `validated`, `ip` FROM `sessions` WHERE `app` = ?", [$secret], 1, 1800); + + if ($rows == "not_found") { + http_response_code(406); + error("No sessions found"); + } + + header('Content-Type: application/json; charset=utf-8'); + die(json_encode(array( + "success" => true, + "message" => "Successfully retrieved sessions", + "sessions" => $rows + ))); + case 'fetchallbuttons': + $rows = misc\cache\fetch('KeyAuthButtons:' . $secret, "SELECT `text`, `value` FROM `buttons` WHERE `app` = ?", [$secret], 1, 1800); + + if ($rows == "not_found") { + http_response_code(406); + error("No buttons found"); + } + + header('Content-Type: application/json; charset=utf-8'); + die(json_encode(array( + "success" => true, + "message" => "Successfully retrieved buttons", + "buttons" => $rows + ))); + case 'fetchallmutes': + $rows = misc\cache\fetch('KeyAuthMutes:' . $secret, "SELECT `user`, `time` FROM `chatmutes` WHERE `app` = ?", [$secret], 1, 1800); + + if ($rows == "not_found") { + http_response_code(406); + error("No mutes found"); + } + + header('Content-Type: application/json; charset=utf-8'); + die(json_encode(array( + "success" => true, + "message" => "Successfully retrieved mutes", + "mutes" => $rows + ))); + case 'editchan': + $name = misc\etc\sanitize($_GET['name']); + $delay = misc\etc\sanitize($_GET['delay']); + $delay = $delay * 60; // making it such that the delay is in the unit of minutes + $query = misc\mysql\query("UPDATE `chats` SET `delay` = ? WHERE `app` = ? AND `name` = ?", [$delay, $secret, $name]); + if ($query->affected_rows > 0) { + success("Successfully updated channel!"); + } else { + error("Failed To update channel!"); + } + case 'fetchallusernames': + $rows = misc\cache\fetch('KeyAuthUsernames:' . $secret, "SELECT `username` FROM `users` WHERE `app` = ?", [$secret], 1, 1800); + + if ($rows == "not_found") { + http_response_code(406); + error("No users found"); + } + + header('Content-Type: application/json; charset=utf-8'); + die(json_encode(array( + "success" => true, + "message" => "Successfully Retrieved Usernames", + "usernames" => $rows + ))); + case 'fetchallusers': + $rows = misc\cache\fetch('KeyAuthUsers:' . $secret, "SELECT * FROM `users` WHERE `app` = ? LIMIT 520", [$secret], 1, 1800); + + if ($rows == "not_found") { + http_response_code(406); + error("No users found"); + } + + header('Content-Type: application/json; charset=utf-8'); + die(json_encode(array( + "success" => true, + "message" => "Successfully Retrieved Users", + "users" => $rows + ))); + case 'setseller': + success("Seller Key Successfully Found"); + case 'setbalance': + $username = misc\etc\sanitize($_GET['username']); + if (empty($username)) { + error("Username Not Set"); + } + + $query = misc\mysql\query("SELECT 1 FROM `accounts` WHERE `app` = ? AND `username` = ?", [$name, $username]); + if ($query->num_rows < 1) { + error("You don't own account you were attemping to modify balance for"); + } + + $dayamount = misc\etc\sanitize($_GET['day']); + $weekamount = misc\etc\sanitize($_GET['week']); + $monthamount = misc\etc\sanitize($_GET['month']); + $threemonthamount = misc\etc\sanitize($_GET['threemonth']); + $sixmonthamount = misc\etc\sanitize($_GET['sixmonth']); + $lifetimeamount = misc\etc\sanitize($_GET['lifetime']); + $yearamount = misc\etc\sanitize($_GET['year']); + + if (!isset($dayamount)) { + $dayamount = "0"; + } + if (!isset($weekamount)) { + $weekamount = "0"; + } + if (!isset($monthamount)) { + $monthamount = "0"; + } + if (!isset($threemonthamount)) { + $threemonthamount = "0"; + } + if (!isset($sixmonthamount)) { + $sixmonthamount = "0"; + } + if (!isset($lifetimeamount)) { + $lifetimeamount = "0"; + } + if (!isset($year)){ + $yearamount = "0"; + } + + $query = misc\mysql\query("SELECT `balance` FROM `accounts` WHERE `username` = ?", [$username]); + + $row = mysqli_fetch_array($query->result); + + $balance = $row["balance"]; + + $balance = explode("|", $balance); + + $day = $balance[0]; + $week = $balance[1]; + $month = $balance[2]; + $threemonth = $balance[3]; + $sixmonth = $balance[4]; + $lifetime = $balance[5]; + $year = $balance[6]; + + $day = $day + $dayamount; + + $week = $week + $weekamount; + + $month = $month + $monthamount; + + $threemonth = $threemonth + $threemonthamount; + + $sixmonth = $sixmonth + $sixmonthamount; + + $lifetime = $lifetime + $lifetimeamount; + + $year = $year + $yearamount; + + $balance = $day . '|' . $week . '|' . $month . '|' . $threemonth . '|' . $sixmonth . '|' . $lifetime . '|' . $year; + + misc\mysql\query("UPDATE `accounts` SET `balance` = ? WHERE `username` = ?", [$balance, $username]); + + success("Balance Successfully Added"); + case 'getbalance': + $resellerusername = misc\etc\sanitize($_GET['username']); + $appname = misc\etc\sanitize($_GET["appname"]); + + $reseller = misc\mysql\query("SELECT * FROM `accounts` WHERE `username` = ? AND `app` = ? AND `owner` = ?", [$resellerusername, $appname, $owner]); + + if ($reseller->num_rows < 1) { + error("Reseller Account Doesn't Exist Or It Doesn't Belong To You"); + } + + $balance = mysqli_fetch_array($reseller->result); + + [$day, $week, $month, $threemonth, $sixmonth, $lifetime, $year] = explode("|", $balance["balance"]); + + header('Content-Type: application/json; charset=utf-8'); + die(json_encode(array("success" => true,"balance" => array( + "day" => $day, + "week" => $week, + "month" => $month, + "three_month" => $three_month, + "six_month" => $six_month, + "lifetime" => $lifetime, + "year" => $year, + "total_keys" => $day+$week+$month+$three_month+$six_month+$lifetime+$year)))); + case 'usersub': + $rows = misc\cache\fetch('KeyAuthUserSubs:' . $secret, "SELECT * FROM `subs` WHERE `app` = ? AND `user` = ?", [$secret, $user], 1); + + header('Content-Type: application/json; charset=utf-8'); + die(json_encode(array( + "success" => true, + "message" => "Successfully Retrieved User Subscription", + "subs" => $rows + ))); + case 'getsettings': + $row = misc\cache\fetch('KeyAuthApp:' . $name . ':' . $ownerid, "SELECT * FROM `apps` WHERE `ownerid` = ? AND `name` = ?", [$ownerid, $name], 0); + if ($row["enabled"] == 0) { + $enabled = false; + } else { + $enabled = true; + } + + if ($row["hwidcheck"] == 0) { + $hwidcheck = false; + } else { + $hwidcheck = true; + } + + $ver = $row["ver"]; + $download = $row["download"]; + $webdownload = $row["webdownload"]; + $webhook = $row["webhook"]; + $resellerstore = $row["resellerstore"]; + $appdisabled = $row["appdisabled"]; + $usernametaken = $row["usernametaken"]; + $keynotfound = $row["keynotfound"]; + $keyused = $row["keyused"]; + $nosublevel = $row["nosublevel"]; + $usernamenotfound = $row["usernamenotfound"]; + $passmismatch = $row["passmismatch"]; + $hwidmismatch = $row["hwidmismatch"]; + $noactivesubs = $row["noactivesubs"]; + $hwidblacked = $row["hwidblacked"]; + $sellixsecret = $row["sellixsecret"]; + $cooldown = $row["cooldown"]; + + if ($format == "text") { + echo $enabled ? 'true' : 'false'; + echo "\n"; + echo $hwidcheck ? 'true' : 'false' . "\n"; + echo $ver . "\n"; + echo $download . "\n"; + echo $webdownload . "\n"; + echo $webhook . "\n"; + echo $resellerstore . "\n"; + echo $appdisabled . "\n"; + echo $usernametaken . "\n"; + echo $keynotfound . "\n"; + echo $keyused . "\n"; + echo $nosublevel . "\n"; + echo $usernamenotfound . "\n"; + echo $passmismatch . "\n"; + echo $hwidmismatch . "\n"; + echo $noactivesubs . "\n"; + echo $hwidblacked . "\n"; + echo $sellixsecret . "\n"; + echo $cooldown; + break; + } else { + header('Content-Type: application/json; charset=utf-8'); + die(json_encode(array( + "success" => true, + "message" => "Retrieved Settings Successfully", + "enabled" => $enabled, + "hwid-lock" => $hwidcheck, + "version" => "$ver", + "download" => "$download", + "webdownload" => "$webdownload", + "webhook" => "$webhook", + "resellerstore" => "$resellerstore", + "disabledmsg" => "$appdisabled", + "usernametakenmsg" => "$usernametaken", + "licenseinvalidmsg" => "$keynotfound", + "keytakenmsg" => "$keyused", + "nosubmsg" => "$nosublevel", + "userinvalidmsg" => "$usernamenotfound", + "passinvalidmsg" => "$passmismatch", + "hwidmismatchmsg" => "$hwidmismatch", + "noactivesubmsg" => "$noactivesubs", + "blackedmsg" => "$hwidblacked", + "sellixsecret" => "$sellixsecret", + "cooldown" => "$cooldown" + ))); + } + case 'fetchallkeys': + $rows = misc\cache\fetch('KeyAuthKeys:' . $secret, "SELECT * FROM `keys` WHERE `app` = ?", [$secret], 1, 1800); + + if ($rows == "not_found") { + http_response_code(406); + error("No keys found"); + } + + header('Content-Type: application/json; charset=utf-8'); + die(json_encode(array( + "success" => true, + "message" => "Successfully Retrieved Licenses", + "keys" => $rows + ))); + case 'info': + $row = misc\cache\fetch('KeyAuthKey:' . $secret . ':' . $key, "SELECT * FROM `keys` WHERE `app` = ? AND `key` = ?", [$secret, $key], 0); + + if ($row == "not_found") { + error("Key Not Found"); + } + + $expiry = $row["expires"]; + $status = $row["status"]; + $note = $row["note"]; + $level = $row["level"]; + $genby = $row["genby"]; + $usedby = $row["usedby"]; + $usedon = $row["usedon"]; + $gendate = $row["gendate"]; + header('Content-Type: application/json; charset=utf-8'); + die(json_encode(array( + "success" => true, + "duration" => "$expiry", + "note" => "$note", + "status" => "$status", + "level" => "$level", + "createdby" => "$genby", + "usedby" => "$usedby", + "usedon" => "$usedon", + "creationdate" => "$gendate" + ))); + case 'updatesettings': + $enabled = misc\etc\sanitize($_GET['enabled']); + $hwidcheck = misc\etc\sanitize($_GET['hwidcheck']); + $ver = misc\etc\sanitize($_GET['ver']); + $download = misc\etc\sanitize($_GET['download']); + $webhook = misc\etc\sanitize($_GET['webhook']); + $resellerstore = misc\etc\sanitize($_GET['resellerstore']); + $appdisabled = misc\etc\sanitize($_GET['appdisabled']); + $usernametaken = misc\etc\sanitize($_GET['usernametaken']); + $keynotfound = misc\etc\sanitize($_GET['keynotfound']); + $keyused = misc\etc\sanitize($_GET['keyused']); + $nosublevel = misc\etc\sanitize($_GET['nosublevel']); + $usernamenotfound = misc\etc\sanitize($_GET['usernamenotfound']); + $passmismatch = misc\etc\sanitize($_GET['passmismatch']); + $hwidmismatch = misc\etc\sanitize($_GET['hwidmismatch']); + $noactivesubs = misc\etc\sanitize($_GET['noactivesubs']); + $hwidblacked = misc\etc\sanitize($_GET['hwidblacked']); + $sellixsecret = misc\etc\sanitize($_GET['sellixsecret']); + + if (!empty($enabled)) { + if ($enabled == "true") { + $enabled = 1; + } else if ($enabled == "false") { + $enabled = 0; + } + misc\mysql\query("UPDATE `apps` SET `enabled` = ? WHERE `sellerkey` = ?", [$enabled, $sellerkey]); + } + if (!empty($hwidcheck)) { + if ($hwidcheck == "true") { + $hwidcheck = 1; + } else if ($hwidcheck == "false") { + $hwidcheck = 0; + } else { + error("The hwidcheck value must be \"true\" or \"false\""); + } + + misc\mysql\query("UPDATE `apps` SET `hwidcheck` = ? WHERE `sellerkey` = ?", [$hwidcheck, $sellerkey]); + } + if (!empty($ver)) { + misc\mysql\query("UPDATE `apps` SET `ver` = ? WHERE `sellerkey` = ?", [$ver, $sellerkey]); + } + if (!empty($download)) { + misc\mysql\query("UPDATE `apps` SET `download` = ? WHERE `sellerkey` = ?", [$download, $sellerkey]); + } + if (!empty($webhook)) { + misc\mysql\query("UPDATE `apps` SET `webhook` = ? WHERE `sellerkey` = ?", [$webhook, $sellerkey]); + } + if (!empty($resellerstore)) { + misc\mysql\query("UPDATE `apps` SET `resellerstore` = ? WHERE `sellerkey` = ?", [$resellerstore, $sellerkey]); + } + if (!empty($appdisabled)) { + misc\mysql\query("UPDATE `apps` SET `appdisabled` = ? WHERE `sellerkey` = ?", [$appdisabled, $sellerkey]); + } + if (!empty($usernametaken)) { + misc\mysql\query("UPDATE `apps` SET `usernametaken` = ? WHERE `sellerkey` = ?", [$usernametaken, $sellerkey]); + } + if (!empty($keynotfound)) { + misc\mysql\query("UPDATE `apps` SET `keynotfound` = ? WHERE `sellerkey` = ?", [$keynotfound, $sellerkey]); + } + if (!empty($keyused)) { + misc\mysql\query("UPDATE `apps` SET `keyused` = ? WHERE `sellerkey` = ?", [$keyused, $sellerkey]); + } + if (!empty($nosublevel)) { + misc\mysql\query("UPDATE `apps` SET `nosublevel` = ? WHERE `sellerkey` = ?", [$nosublevel, $sellerkey]); + } + if (!empty($usernamenotfound)){ + misc\mysql\query("UPDATE `apps` SET `usernamenotfound` = ? WHERE `sellerkey` = ?", [$usernamenotfound, $sellerkey]); + } + if (!empty($passmismatch)) { + misc\mysql\query("UPDATE `apps` SET `passmismatch` = ? WHERE `sellerkey` = ?", [$passmismatch, $sellerkey]); + } + if (!empty($hwidmismatch)) { + misc\mysql\query("UPDATE `apps` SET `hwidmismatch` = ? WHERE `sellerkey` = ?", [$hwidmismatch, $sellerkey]); + } + if (!empty($noactivesubs)) { + misc\mysql\query("UPDATE `apps` SET `noactivesubs` = ? WHERE `sellerkey` = ?", [$noactivesubs, $sellerkey]); + } + if (!empty($hwidblacked)) { + misc\mysql\query("UPDATE `apps` SET `hwidblacked` = ? WHERE `sellerkey` = ?", [$hwidblacked, $sellerkey]); + } + if (!empty($sellixsecret)) { + misc\mysql\query("UPDATE `apps` SET `sellixsecret` = ? WHERE `sellerkey` = ?", [$sellixsecret, $sellerkey]); + } + + misc\cache\purge('KeyAuthApp:' . $name . ':' . $ownerid); + + success("Settings Update Successful"); + case 'edit': + $expiry = misc\etc\sanitize($_GET['expiry']); + + if(is_null($expiry)) { + error("You must set expiry value"); + } + + misc\mysql\query("UPDATE `keys` SET `expires` = ? WHERE `app` = ? AND `key` = ?", [$expiry, $secret, $key]); + + success("License Edit Successful"); + case 'addbutton': + $resp = misc\button\addButton($_GET['text'], $_GET['value'], $secret); + match($resp){ + 'success' => success("Succesfully added button!"), + 'failure' => error("Failed to add button! You can't have two button with the same value."), + default => error("Unhandled Error! Contact support if you need help") + }; + case 'delbutton': + $resp = misc\button\deleteButton($_GET['value'], $secret); + match($resp){ + 'success' => success("Successfully deleted button!"), + 'failure' => error("Failed to delete button!"), + default => error("Unhandled Error! Contact support if you need help!") + }; + case 'fetchalllogs': + $rows = misc\cache\fetch('KeyAuthLogs:' . $secret, "SELECT * FROM `logs` WHERE `logapp` = ?", [$secret], 1, 1800); + + if ($rows == "not_found") { + http_response_code(406); + error("No logs found"); + } + + header('Content-Type: application/json; charset=utf-8'); + die(json_encode(array( + "success" => true, + "message" => "Successfully retrieved logs", + "logs" => $rows + ))); + case 'dellogs': + $resp = misc\logging\deleteAll($secret); + match($resp){ + 'success' => success("Successfully deleted all logs!"), + 'failure' => error("Failed to delete all logs!"), + default => error("Unhandled Error! Contact support if you need help!") + }; + default: + error("Type doesn't exist"); + } \ No newline at end of file diff --git a/app/black-fetch.php b/app/black-fetch.php new file mode 100644 index 0000000..d3e4e54 --- /dev/null +++ b/app/black-fetch.php @@ -0,0 +1,96 @@ +getMessage()); + die("Error: " . $errorMsg); +}); + +if (session_status() === PHP_SESSION_NONE) { + session_start(); +} + +if ($_SESSION['role'] == "Reseller") { + die("Resellers can't access this."); +} + +if (!isset($_SESSION['app'])) { + die("Application not selected."); +} + +if (isset($_POST['draw'])) { + + // credits to https://makitweb.com/datatables-ajax-pagination-with-search-and-sort-php/ + + $draw = intval($_POST['draw']); + $row = intval($_POST['start']); + $rowperpage = intval($_POST['length']); // Rows display per page + $columnIndex = misc\etc\sanitize($_POST['order'][0]['column']) +1; // Column index + $columnName = misc\etc\sanitize($_POST['columns'][$columnIndex]['data']); // Column name + $columnSortOrder = misc\etc\sanitize($_POST['order'][0]['dir']); // asc or desc + $searchValue = misc\etc\sanitize($_POST['search']['value']); // Search value + + // whitelist certain column names and sort orders to prevent SQL injection + if (!in_array($columnName, array("type"))) { + die("Column name is not whitelisted."); + } + + if (!in_array($columnSortOrder, array("desc", "asc"))) { + die("Column sort order is not whitelisted."); + } + + if (!is_null($searchValue)) { + $query = misc\mysql\query("select * from `bans` WHERE (`ip` like ? or `hwid` like ? or `type` like ? ) and app = ? order by `" . $columnName . "` " . $columnSortOrder . " limit " . $row . "," . $rowperpage, ["%" . $searchValue . "%", "%" . $searchValue . "%", "%" . $searchValue . "%", $_SESSION['app']]); + } + else { + $query = misc\mysql\query("select * from `bans` WHERE app = ? order by `" . $columnName . "` " . $columnSortOrder . " limit " . $row . "," . $rowperpage, [$_SESSION['app']]); + } + + $data = array(); + + while ($row = mysqli_fetch_assoc($query->result)) { + $data[] = array( + "data" => '' . ($row["hwid"] ?? $row["ip"]) . '', + "type" => $row["type"], + "actions" => + '
+ +
+ +
    +
  • + +
+ + + + + +
', + ); + } + + ## Response + $response = array( + "draw" => intval($draw), + "aaData" => $data + ); + + die(json_encode($response)); +} + +die("Request not from datatables, aborted."); diff --git a/app/download-types.php b/app/download-types.php new file mode 100644 index 0000000..99eae94 --- /dev/null +++ b/app/download-types.php @@ -0,0 +1,343 @@ + array(), + "keys" => array(), + "subscriptions" => array(), + "tokens" => array(), + "users" => array(), + "uservars" => array(), + "vars" => array(), + "webhooks" => array() + ) + ); + + $jsondata = json_decode($jsonarray); + + $filesquery = misc\mysql\query("SELECT * FROM `files` WHERE `app` = ?", [$_SESSION['app']]); + while ($row = mysqli_fetch_array($filesquery->result)){ + $filesjson = array( + "name" => $row["name"], + "id" => $row["id"], + "url" => $row["url"] + ); + array_push($jsondata->files, $filesjson); + } + + $keyquery = misc\mysql\query("SELECT * FROM `keys` WHERE `app` = ?", [$_SESSION['app']]); + while ($row = mysqli_fetch_array($keyquery->result)){ + $keyjson = array( + "key" => $row["key"], + "note" => $row["note"], + "level" => $row["level"], + "genby" => $row["genby"], + "usedby" => $row["usedby"] + ); + array_push($jsondata->keys, $keyjson); + } + + $subscriptionsquery = misc\mysql\query("SELECT * FROM `subscriptions` WHERE `app` = ?", [$_SESSION['app']]); + while ($row = mysqli_fetch_array($subscriptionsquery->result)){ + $subscriptionjson = array( + "name" => $row["name"], + "level" => $row["level"] + ); + array_push($jsondata->subscriptions, $subscriptionjson); + } + + $tokensquery = misc\mysql\query("SELECT * FROM `tokens` WHERE `app` = ?", [$_SESSION['app']]); + while ($row = mysqli_fetch_array($tokensquery->result)){ + $tokenjson = array( + "token" => $row["token"], + "assigned" => $row["assigned"], + "hash" => $row["hash"], + "type" => $row["type"], + "status" => $row["status"] + ); + array_push($jsondata->tokens, $tokenjson); + } + + $usersquery = misc\mysql\query("SELECT * FROM `users` WHERE `app` = ?", [$_SESSION['app']]); + while ($row = mysqli_fetch_array($usersquery->result)){ + $usersjson = array( + "username" => $row["username"], + "email" => $row["email"], + "password" => $row["password"], + "hwid" => $row["hwid"], + "owner" => $row["owner"], + "ip" => $row["ip"] + ); + array_push($jsondata->users, $usersjson); + } + + $uservarsquery = misc\mysql\query("SELECT * FROM `uservars` WHERE `app` = ?", [$_SESSION['app']]); + while ($row = mysqli_fetch_array($uservarsquery->result)){ + $uservarsjson = array( + "name" => $row["name"], + "data" => $row["data"], + "user" => $row["user"] + ); + array_push($jsondata->uservars, $uservarsjson); + } + + $varsquery = misc\mysql\query("SELECT * FROM `vars` WHERE `app` = ?", [$_SESSION['app']]); + while ($row = mysqli_fetch_array($varsquery->result)){ + $varsjson = array( + "varid" => $row["varid"], + "msg" => $row["msg"] + ); + array_push($jsondata->vars, $varsjson); + } + + $webhooksquery = misc\mysql\query("SELECT * FROM `webhooks` WHERE `app` = ?", [$_SESSION['app']]); + while ($row = mysqli_fetch_array($webhooksquery->result)){ + $webhooksjson = array( + "webid" => $row["webid"], + "baselink" => $row["baselink"], + "useragent" => $row["useragent"] + ); + array_push($jsondata->webhooks, $webhooksjson); + } + + $newjson = json_encode($jsondata); + + header('Content-Description: File Transfer'); + header('Content-Type: application/octet-stream'); + header('Content-Disposition: attachment; filename="KeyAuthAccExport.json"'); + header('Expires: 0'); + header('Cache-Control: must-revalidate'); + header('Pragma: public'); + header('Content-Length: ' . strlen($newjson)); + + + die($newjson); + case 'users': + $jsonarray = json_encode( + array( + "users" => array(), + "subscription" => array(), + "tokens" => array() + ) + ); + + $jsondata = json_decode($jsonarray); + + $userquery = misc\mysql\query("SELECT * FROM `users` WHERE `app` = ?", [$_SESSION['app']]); + + while ($row = mysqli_fetch_array($userquery->result)) { + + $userjson = array( + "username" => $row["username"], + "email" => $row["email"], + "password" => $row["password"], + "hwid" => $row["hwid"], + "owner" => $row["owner"], + "createdate" => $row["createdate"], + "lastlogin" => $row["lastlogin"], + "banned" => $row["banned"], + "ip" => $row["ip"], + "cooldown" => $row["cooldown"] + ); + + array_push($jsondata->users, $userjson); + } + + $subscriptionquery = misc\mysql\query("SELECT * FROM `subs` WHERE `app` = ? ", [$_SESSION['app']]); + + while ($row = mysqli_fetch_array($subscriptionquery->result)) { + + $subjson = array( + "user" => $row["user"], + "subscription" => $row["subscription"], + "expiry" => $row["expiry"], + "key" => $row["key"], + "paused" => $row["paused"] + ); + + array_push($jsondata->subscription, $subjson); + } + + $tokensquery = misc\mysql\query("SELECT * FROM `tokens` WHERE `type` = ? AND `app` = ?", ["user", $_SESSION['app']]); + + while ($row = mysqli_fetch_array($tokensquery->result)){ + + $tokenjson = array( + "token" => $row["token"], + "assigned" => $row["assigned"], + "banned" => $row["banned"], + "reason" => $row["reason"], + "hash" => $row["hash"], + "type" => $row["type"], + "status" => $row["status"] + ); + + array_push($jsondata->tokens, $tokenjson); + } + + $newjson = json_encode($jsondata); + + header('Content-Description: File Transfer'); + header('Content-Type: application/octet-stream'); + header('Content-Disposition: attachment; filename="KeyAuthUsers.json"'); + header('Expires: 0'); + header('Cache-Control: must-revalidate'); + header('Pragma: public'); + header('Content-Length: ' . strlen($newjson)); + + + die($newjson); + case 'licenses': + $jsonarray = json_encode( + array( + "keys" => array(), + "tokens" => array() + ) + ); + + $jsondata = json_decode($jsonarray); + + $query = misc\mysql\query("SELECT * FROM `keys` WHERE `app` = ?",[$_SESSION['app']]); + + // Create an array to hold the keys + $keysArray = array(); + + while ($row = mysqli_fetch_array($query->result)) { + // Add each key to the array + $keysArray[] = array( + "key" => $row['key'], + "note" => $row['note'], + "expiry" => $row['expires'], // Export keys is in SECONDS, because that works better than fractions of a day. + // so, tell people to convert seconds to hours or days.. + "status" => $row['status'], + "level" => $row['level'], + "genby" => $row['genby'], + "gendate" => $row['gendate'], + "usedon" => $row['usedon'], + "banned" => $row['banned'] + ); + } + + $tokensquery = misc\mysql\query("SELECT * FROM `tokens` WHERE `type` = ? AND `app` = ?", ["license", $_SESSION['app']]); + + while ($row = mysqli_fetch_array($tokensquery->result)){ + + $tokenjson = array( + "token" => $row["token"], + "assigned" => $row["assigned"], + "banned" => $row["banned"], + "reason" => $row["reason"], + "hash" => $row["hash"], + "type" => $row["type"], + "status" => $row["status"] + ); + + array_push($jsondata->tokens, $tokenjson); + } + + // Assign keys array to jsondata + $jsondata->keys = $keysArray; + + // Convert the array to a JSON string + $jsonData = json_encode($jsondata); + + header('Content-Description: File Transfer'); + header('Content-Type: application/json'); // Set the content type to JSON + header('Content-Disposition: attachment; filename="KeyAuthKeys.json"'); + header('Expires: 0'); + header('Cache-Control: must-revalidate'); + header('Pragma: public'); + header('Content-Length: ' . strlen($jsonData)); + + echo $jsonData; + + die($stringData); + + case 'logs': + $jsonarray = json_encode( + array( + "logs" => array() + ) + ); + + $jsondata = json_decode($jsonarray); + + $userlogquery = misc\mysql\query("SELECT * FROM `logs` WHERE `logapp` = ?", [$_SESSION['app']]); + + while ($row = mysqli_fetch_array($userlogquery->result)) { + + $userlogjson = array( + "logdate" => $row["logdate"], + "logdata" => $row["logdata"], + "credential" => $row["credential"], + "pcuser" => $row["pcuser"] + ); + + array_push($jsondata->logs, $userlogjson); + } + + + $newjson = json_encode($jsondata); + + header('Content-Description: File Transfer'); + header('Content-Type: application/octet-stream'); + header('Content-Disposition: attachment; filename="KeyAuthUserLogs.json"'); + header('Expires: 0'); + header('Cache-Control: must-revalidate'); + header('Pragma: public'); + header('Content-Length: ' . strlen($newjson)); + + die($newjson); + case 'auditLog': + $jsonarray = json_encode( + array( + "auditLog" => array() + ) + ); + + $jsondata = json_decode($jsonarray); + + $userquery = misc\mysql\query("SELECT * FROM `auditLog` WHERE `app` = ?", [$_SESSION['app']]); + + while ($row = mysqli_fetch_array($userquery->result)) { + + $userjson = array( + "id" => $row["id"], + "user" => $row["user"], + "event" => $row["event"], + "time" => $row["time"], + ); + + array_push($jsondata->auditLog, $userjson); + } + + + $newjson = json_encode($jsondata); + + header('Content-Description: File Transfer'); + header('Content-Type: application/octet-stream'); + header('Content-Disposition: attachment; filename="KeyAuthAuditLogs.json"'); + header('Expires: 0'); + header('Cache-Control: must-revalidate'); + header('Pragma: public'); + header('Content-Length: ' . strlen($newjson)); + + die($newjson); + default: + echo 'Invalid Type or Type does not Exist'; +} \ No newline at end of file diff --git a/app/index.php b/app/index.php new file mode 100644 index 0000000..d9d0fd3 --- /dev/null +++ b/app/index.php @@ -0,0 +1,208 @@ +getMessage()); + \dashboard\primary\error($errorMsg); +}); + +$username = $_SESSION['username']; +$query = misc\mysql\query("SELECT * FROM `accounts` WHERE `username` = ?",[$username]); +$row = mysqli_fetch_array($query->result); + +$banned = $row['banned']; +$lastreset = $row['lastreset']; +if (!is_null($banned) || $_SESSION['logindate'] < $lastreset || $query->num_rows < 1) { + echo ""; + session_destroy(); + exit(); +} +$role = $row['role']; +$permissions = $row['permissions']; +$admin = $row['admin']; +$staff = $row['staff']; +$formBanned = $row['formBanned']; +$twofactor = $row['twofactor']; +$alertMsg = $row['alert']; +$secwords = $row['secWords']; +$_SESSION['role'] = $role; + +$expires = $row['expires']; +if (in_array($role, array("developer", "seller"))) { + dashboard\primary\expireCheck($username, $expires); +} + + +if (!$_SESSION['app']) // no app selected yet +{ + $query = misc\mysql\query("SELECT `secret`, `name`, `banned`, `sellerkey` FROM `apps` WHERE `owner` = ? AND `ownerid` = ?",[$_SESSION['username'], $_SESSION['ownerid']]); // select all apps where owner is current user + if ($query->num_rows == 1) // if the user only owns one app, load that app (they can still change app after it's loaded) + { + $row = mysqli_fetch_array($query->result); + $_SESSION['name'] = $row["name"]; + $_SESSION['app'] = $row["secret"]; + $_SESSION['sellerkey'] = $row["sellerkey"]; + } +} +?> + + + + + + + + + + + + + + + + + + + + KeyAuth - Open Source Auth + + + + + + + + + + + + + + + + +
+
+
+ +
+
+ + Loading taking a while? Please + feel free to return. + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/layout/aside.php b/app/layout/aside.php new file mode 100644 index 0000000..932d8eb --- /dev/null +++ b/app/layout/aside.php @@ -0,0 +1,289 @@ + + + + + \ No newline at end of file diff --git a/app/layout/breadcrumb.php b/app/layout/breadcrumb.php new file mode 100644 index 0000000..fb90387 --- /dev/null +++ b/app/layout/breadcrumb.php @@ -0,0 +1,34 @@ + \ No newline at end of file diff --git a/app/layout/footer.php b/app/layout/footer.php new file mode 100644 index 0000000..4ef0fde --- /dev/null +++ b/app/layout/footer.php @@ -0,0 +1,20 @@ + diff --git a/app/layout/master.php b/app/layout/master.php new file mode 100644 index 0000000..76bdac2 --- /dev/null +++ b/app/layout/master.php @@ -0,0 +1,47 @@ + + +
+ + + + +
+
+ +
+ + +
+
diff --git a/app/layout/profile.php b/app/layout/profile.php new file mode 100644 index 0000000..e527cab --- /dev/null +++ b/app/layout/profile.php @@ -0,0 +1,99 @@ +num_rows > 0) { + while ($row_ = mysqli_fetch_array($query->result)) { + $acclogs = $row_['acclogs']; + $expiry = $row_["expires"]; + $emailVerify = $row_["emailVerify"]; + } +} + +if ($_SERVER['REQUEST_METHOD'] === 'POST') { + if (isset($_POST['logout'])) { + session_destroy(); + header('Location: /login'); + exit; + } +} + +?> + +
+
+ + +
+ +
+
+ +
+ " alt="profile image" /> + +
+ +
+ +
+ + + '', + 'developer' => '', + 'seller' => '', + 'Reseller' => '', + 'Manager' => '', + 'default' => '' + }; + echo $display; + + if ($role === 'developer' || $role === 'seller') { + echo ''; + } + ?> +
+
+ +
+ " . strtoupper($role) . " PLAN

"; + ?> +
+
+
diff --git a/app/layout/reselleraside.php b/app/layout/reselleraside.php new file mode 100644 index 0000000..d287765 --- /dev/null +++ b/app/layout/reselleraside.php @@ -0,0 +1,59 @@ + + + + diff --git a/app/layout/topbar.php b/app/layout/topbar.php new file mode 100644 index 0000000..745a5e2 --- /dev/null +++ b/app/layout/topbar.php @@ -0,0 +1,106 @@ + \ No newline at end of file diff --git a/app/license-fetch.php b/app/license-fetch.php new file mode 100644 index 0000000..6ae6708 --- /dev/null +++ b/app/license-fetch.php @@ -0,0 +1,156 @@ +getMessage()); + die("Error: " . $errorMsg); +}); + +if (session_status() === PHP_SESSION_NONE) { + session_start(); +} + +if ($_SESSION['role'] == "Reseller") { + die("Resellers can't access this."); +} + +if (!isset($_SESSION['app'])) { + dashboard\primary\error("Application not selected"); + die("Application not selected."); +} + +if (isset($_POST['draw'])) { + + // credits to https://makitweb.com/datatables-ajax-pagination-with-search-and-sort-php/ + + $draw = intval($_POST['draw']); + $row = intval($_POST['start']); + $rowperpage = intval($_POST['length']); // Rows display per page + $columnIndex = misc\etc\sanitize($_POST['order'][0]['column']); // Column index + $columnName = misc\etc\sanitize($_POST['columns'][$columnIndex]['data']); // Column name + $columnSortOrder = misc\etc\sanitize($_POST['order'][0]['dir']); // asc or desc + $searchValue = misc\etc\sanitize($_POST['search']['value']); // Search value + + ## Total number of records without filtering + $sel = misc\mysql\query("select count(1) as allcount from `keys` where app = ?", [$_SESSION['app']]); + $records = mysqli_fetch_assoc($sel->result); + $totalRecords = $records['allcount']; + + $totalRecordwithFilter = $totalRecords; + if (!is_null($searchValue)) { // don't double query if no search value was provided + ## Total number of record with filtering + $sel = misc\mysql\query("select count(1) as allcount from `keys` WHERE 1 and (`key` like ? or `user` like ? or `note` like ? or `genby` like ? or `usedby` like ? ) and app = ?", ["%" . $searchValue . "%", "%" . $searchValue . "%", "%" . $searchValue . "%", "%" . $searchValue . "%", "%" . $searchValue . "%", $_SESSION['app']]); + $records = mysqli_fetch_assoc($sel->result); + $totalRecordwithFilter = $records['allcount']; + } + + // whitelist certain column names and sort orders to prevent SQL injection + if (!in_array($columnName, array("key", 'user', "gendate", "genby", "expires", "note", "usedon", "usedby", "status"))) { + die("Column name is not whitelisted."); + } + + if (!in_array($columnSortOrder, array("desc", "asc"))) { + die("Column sort order is not whitelisted."); + } + + if (!is_null($searchValue)) { + $query = misc\mysql\query("select * from `keys` WHERE (`key` like ? or `user` like ? or `note` like ? or `genby` like ? or `usedby` like ? ) and app = ? order by `" . $columnName . "` " . $columnSortOrder . " limit " . $row . "," . $rowperpage, ["%" . $searchValue . "%", "%" . $searchValue . "%", "%" . $searchValue . "%", "%" . $searchValue . "%", "%" . $searchValue . "%", $_SESSION['app']]); + } + else { + $query = misc\mysql\query("select * from `keys` WHERE app = ? order by `" . $columnName . "` " . $columnSortOrder . " limit " . $row . "," . $rowperpage, [$_SESSION['app']]); + } + + $data = array(); + + while ($row = mysqli_fetch_assoc($query->result)) { + + ## If only one or two keys exists then we will use custom margin to fix the bugging menu + $banBtns = ""; + if ($row['status'] == "Banned") { + $banBtns = ''; + } else { + $banBtns = ''; + } + + $MarginManager = ""; + if ($query->num_rows < 2) { + $MarginManager = "margin-bottom: 20px;"; + } else { + $MarginManager = "margin-bottom: 0px;"; + } + + match ($row['status']) { + 'Not Used' => $statusColor = "border-white text-white", + 'Banned' => $statusColor = "border-red-700 text-red-600", + default => $statusColor = "border-blue-700 text-blue-800" + }; + + $data[] = array( + "checkbox" => '', + "key" => $row['key'], + "user" => $row['user'], + "gendate" => '
', + "genby" => $row['genby'], + "expires" => timeconversion($row["expires"]), + "note" => $row['note'] ?? 'N/A', + "usedon" => (!is_null($row["usedon"])) ? '
' : 'N/A', + "usedby" => ($row["usedby"] == $row['key']) ? 'Same as key' : $row["usedby"] ?? 'N/A', + "status" => '' . $row['status'] . '', + + "actions" => ' +
+ +
+ +
    +
  • + +
  • +
  • + ' . $banBtns . ' +
  • +
  • + +
  • +
+
+ + +
+ ', + ); + } + + ## Response + $response = array( + "draw" => intval($draw), + "iTotalRecords" => $totalRecords, + "iTotalDisplayRecords" => $totalRecordwithFilter, + "aaData" => $data + ); + + die(json_encode($response)); +} + +die("Request not from datatables, aborted."); \ No newline at end of file diff --git a/app/log-fetch.php b/app/log-fetch.php new file mode 100644 index 0000000..eff949a --- /dev/null +++ b/app/log-fetch.php @@ -0,0 +1,92 @@ +getMessage()); + die("Error: " . $errorMsg); +}); + +if (session_status() === PHP_SESSION_NONE) { + session_start(); +} + +if ($_SESSION['role'] == "Reseller") { + die("Resellers can't access this."); +} + +if (!isset($_SESSION['app'])) { + dashboard\primary\error("Application not selected"); + die("Application not selected."); +} + +if (isset($_POST['draw'])) { + + // credits to https://makitweb.com/datatables-ajax-pagination-with-search-and-sort-php/ + + $draw = intval($_POST['draw']); + $row = intval($_POST['start']); + $rowperpage = intval($_POST['length']); // Rows display per page + $columnIndex = misc\etc\sanitize($_POST['order'][0]['column']); // Column index + $columnName = misc\etc\sanitize($_POST['columns'][$columnIndex]['data']); // Column name + $columnSortOrder = misc\etc\sanitize($_POST['order'][0]['dir']); // asc or desc + $searchValue = misc\etc\sanitize($_POST['search']['value']); // Search value + + ## Total number of records without filtering + $sel = misc\mysql\query("select count(1) as allcount from `logs` where logapp = ?", [$_SESSION['app']]); + $records = mysqli_fetch_assoc($sel->result); + $totalRecords = $records['allcount']; + + $totalRecordwithFilter = $totalRecords; + if (!is_null($searchValue)) { // don't double query if no search value was provided + ## Total number of record with filtering + $sel = misc\mysql\query("select count(1) as allcount from `logs` WHERE 1 and (`logdata` like ? or `credential` like ? or `pcuser` like ? ) and logapp = ?", ["%" . $searchValue . "%", "%" . $searchValue . "%", "%" . $searchValue . "%", $_SESSION['app']]); + $records = mysqli_fetch_assoc($sel->result); + $totalRecordwithFilter = $records['allcount']; + } + + // whitelist certain column names and sort orders to prevent SQL injection + if (!in_array($columnName, array("logdate", "logdata", "credential", "pcuser"))) { + die("Column name is not whitelisted."); + } + + if (!in_array($columnSortOrder, array("desc", "asc"))) { + die("Column sort order is not whitelisted."); + } + + if (!is_null($searchValue)) { + $query = misc\mysql\query("select * from `logs` WHERE (`logdata` like ? or `credential` like ? or `pcuser` like ? ) and logapp = ? order by `" . $columnName . "` " . $columnSortOrder . " limit " . $row . "," . $rowperpage, ["%" . $searchValue . "%", "%" . $searchValue . "%", "%" . $searchValue . "%", $_SESSION['app']]); + } + else { + $query = misc\mysql\query("select * from `logs` WHERE logapp = ? order by `" . $columnName . "` " . $columnSortOrder . " limit " . $row . "," . $rowperpage, [$_SESSION['app']]); + } + + $data = array(); + + while ($row = mysqli_fetch_assoc($query->result)) { + $data[] = array( + "logdate" => '
', + "logdata" => $row['logdata'], + "credential" => $row['credential'] ?? 'N/A', + "pcuser" => $row['pcuser'] ?? 'N/A', + ); + } + + ## Response + $response = array( + "draw" => intval($draw), + "iTotalRecords" => $totalRecords, + "iTotalDisplayRecords" => $totalRecordwithFilter, + "aaData" => $data + ); + + die(json_encode($response)); +} + +die("Request not from datatables, aborted."); diff --git a/app/pages/account-logs.php b/app/pages/account-logs.php new file mode 100644 index 0000000..512062b --- /dev/null +++ b/app/pages/account-logs.php @@ -0,0 +1,71 @@ + +
+
+
+ +

Account Logs

+

View the event history of your account.

+
+
+ + + + + +
+ + + + + + + + + + result)) + { + $rows[] = $r; + } + + foreach ($rows as $row) + { + ?> + + + + + + + + +
DateIPUser-Agent
+ +
\ No newline at end of file diff --git a/app/pages/account-settings.php b/app/pages/account-settings.php new file mode 100644 index 0000000..a5a2d8a --- /dev/null +++ b/app/pages/account-settings.php @@ -0,0 +1,607 @@ +createSecret(); + misc\mysql\query("UPDATE `accounts` SET `googleAuthCode` = ? WHERE `username` = ?", [$code_2factor, $_SESSION['username']]); +} else { + $code_2factor = $row["googleAuthCode"]; +} + +$google_QR_Code = $gauth->getQRCodeGoogleUrl($_SESSION['username'], $code_2factor, 'KeyAuth'); + +$query = misc\mysql\query("SELECT * FROM `accounts` WHERE `username` = ?", [$_SESSION['username']]); + +if ($query->num_rows > 0) { + while ($row = mysqli_fetch_array($query->result)) { + $acclogs = $row['acclogs']; + $expiry = $row["expires"]; + $emailVerify = $row["emailVerify"]; + } +} + +if (isset($_POST['updatesettings'])) { + $pfp = misc\etc\sanitize($_POST['pfp']); + $acclogs = misc\etc\sanitize($_POST['acclogs']); + $emailVerify = misc\etc\sanitize($_POST['emailVerify']); + misc\mysql\query("UPDATE `accounts` SET `acclogs` = ? WHERE `username` = ?", [$acclogs, $_SESSION['username']]); + + if ($acclogs == 0) { + misc\mysql\query("DELETE FROM `acclogs` WHERE `username` = ?", [$_SESSION['username']]); // delete all account logs + } + + misc\mysql\query("UPDATE `accounts` SET `emailVerify` = ? WHERE `username` = ?", [$emailVerify, $_SESSION['username']]); + if (isset($_POST['pfp']) && trim($_POST['pfp']) != '') { + if (!filter_var($pfp, FILTER_VALIDATE_URL)) { + dashboard\primary\error("Invalid Url For Profile Image!"); + echo ""; + return; + } + if (strpos($pfp, "file:///") !== false) { + dashboard\primary\error("Url must start with https://"); + echo ""; + return; + } + + $_SESSION['img'] = $pfp; + misc\mysql\query("UPDATE `accounts` SET `img` = ? WHERE `username` = ?", [$pfp, $_SESSION['username']]); + } + + dashboard\primary\success("Updated Account Settings!"); + } + + if (isset($_POST['dlacc'])) { + echo ""; + } + + if (isset($_POST['submit_code'])) { + if($_SESSION['discordLogin']) { + echo ""; + dashboard\primary\error("You can't use 2FA when you sign-in with different website! Use 2FA on that website instead"); + return; + } + + $code = misc\etc\sanitize($_POST['scan_code1'] . ($_POST['scan_code2']) . ($_POST['scan_code3']) . ($_POST['scan_code4']) . ($_POST['scan_code5']) . ($_POST['scan_code6'])); + + $query = misc\mysql\query("SELECT `googleAuthCode` from `accounts` WHERE `username` = ?", [$_SESSION['username']]); + + while ($row = mysqli_fetch_array($query->result)) { + $secret_code = $row['googleAuthCode']; + } + + $checkResult = $gauth->verifyCode($secret_code, $code, 2); + + if ($checkResult) { + $query = misc\mysql\query("UPDATE `accounts` SET `twofactor` = '1' WHERE `username` = ?", [$_SESSION['username']]); + if ($query->affected_rows > 0) { + echo ""; + dashboard\primary\success("Two-factor security has been successfully activated on your account!"); + dashboard\primary\wh_log($logwebhook, "{$username} has enabled 2FA", $webhookun, "3586ee", "No ping"); + } else { + echo ""; + dashboard\primary\wh_log($logwebhook, "{$username} has disabled 2FA", $webhookun, "3586ee", "No ping");; + dashboard\primary\success("Two-factor security has been successfully disabled on your account!"); + } + } else { + dashboard\primary\error("Invalid 2FA code! Make sure your device time settings are synced."); + } + } + + if (isset($_POST['downloadSecWords'])){ + if ($secwords == NULL){ + + function getRandomWords($count = 10) { + $url = "https://random-word-api.herokuapp.com/word?number={$count}"; + $ch = curl_init($url); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + $response = curl_exec($ch); + curl_close($ch); + + if ($response) { + return json_decode($response); + } else { + return false; + } + } + + // Get 10 random words + $randomWords = getRandomWords(10); + + if ($randomWords) { + // Format the words into a comma-separated string + $wordString = implode(', ', $randomWords); + $query = misc\mysql\query("UPDATE `accounts` SET `secwords` =? WHERE `username` = ?", [$wordString, $_SESSION['username']]); + if ($query->affected_rows > 0){ + dashboard\primary\success("Successfully generated new security words!"); + } else { + dashboard\primary\error("Failed to generate new security words!"); + } + } + + } else { + dashboard\primary\error("Security words already generated. Contact staff if you need to reset them."); + } + } + + if (isset($_POST['submit_code_disable'])) + { + $code = misc\etc\sanitize($_POST['scan_code']); + + $query = misc\mysql\query("SELECT `googleAuthCode` from `accounts` WHERE `username` = ?", [$_SESSION['username']]); + + while ($row = mysqli_fetch_array($query->result)) { + $secret_code = $row['googleAuthCode']; + } + + $checkResult = $gauth->verifyCode($secret_code, $code, 2); + + if ($checkResult) + { + $query = misc\mysql\query("UPDATE `accounts` SET `twofactor` = '0', `googleAuthCode` = NULL WHERE `username` = ?", [$_SESSION['username']]); + + if ($query->affected_rows > 0) { + dashboard\primary\success("Successfully disabled 2FA!"); + } else { + dashboard\primary\error("Failed to disable 2FA!"); + } + } else { + dashboard\primary\error("Invalid 2FA code! Make sure your device time settings are synced."); + } + } + + if (isset($_POST['deleteWebauthn'])) + { + $name = misc\etc\sanitize($_POST['deleteWebauthn']); + + $query = misc\mysql\query("DELETE FROM `securityKeys` WHERE `name` = ? AND `username` = ?", [$name, $_SESSION['username']]); + + if ($query->affected_rows > 0) { + $query = misc\mysql\query("SELECT 1 FROM `securityKeys` WHERE `username` = ?", [$_SESSION['username']]); + if ($query->num_rows == 0) { + misc\mysql\query("UPDATE `accounts` SET `securityKey` = 0 WHERE `username` = ?", [$_SESSION['username']]); + } + dashboard\primary\success("Successfully deleted security key"); + } else { + dashboard\primary\error("Failed to delete security key!"); + } + } + +?> + +
+
+
+ +

Account Settings

+

Manage your account. Tip: You can press Ctrl + S to save settings!

+
+
+ + + + +
+
+
+ + +
+ +
+ + +
+
+ +
+ + +
+ + +
+ " + readonly> + +
+ + +
+ Never " + autocomplete="on" readonly> + + + + +
+ + + +
+ + +
+ +

Security Words

+ + +

Security Words: 10 random words + that you can use to regain access to your account if you forget your order ID, email, + password, and have no other way to verify the account belongs to you!

+
+
    +
  • Can only be generated 1 TIME! (unless you get a new list from an admin)
  • +
  • Should be stored in 2 locations! (USB and PC for example)
  • +
  • Should NOT be called something obvious like "KeyAuthSecurityWords.txt". Prevent + theft! Be smart!
  • +
  • Should never be shared!
  • +
  • Only admins can give you new words
  • +
  • Remember, your words will appear below once generated. Once you refresh the page, + the words will disappear.
  • +
+ +

+ +

+ +
+ + + +

+ You already generated your security words. Please contact support if you forgot + them. +

+ +
+
+ + + + + + + + + Enable 2FA'; + } else { + echo 'Disable 2FA'; + } + ?> + + + + + + + Change Password + + + Change Email + + + Change Username + + + Delete Account + +
+ + + + + + + + + + + + + +
+ +
+ + + \ No newline at end of file diff --git a/app/pages/admin-panel.php b/app/pages/admin-panel.php new file mode 100644 index 0000000..a6fd67d --- /dev/null +++ b/app/pages/admin-panel.php @@ -0,0 +1,806 @@ +"); + 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; + } +?> + + + + + +
+
+
+ +

Admin Panel

+

Welcome To The Admin Panel! +

+
+
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + result)){ + $rows[] = $r; + } + foreach ($rows as $row){ + $un = $row['username']; + $ban = $row['banned'] == NULL ? 'False' : 'True'; + $secKey = (($row['securityKey'] ? 1 : 0) ? 'True' : 'False'); + $totp = (($row['twofactor'] ? 1 : 0) ? 'True' : 'False'); + $staff = (($row['staff'] ? 1 : 0) ? 'True' : 'False'); + ?> + + + + + + + + + + + + + + + + + + +
UsernameOwner IDEmailRoleStaffBan StatusSecurity Key2FA StatusRegister IPLast IPAction
+
+ +
+ +
    +
  • + +
  • +
  • + +
  • +
  • + +
  • +
+
+
+ + + + + \ No newline at end of file diff --git a/app/pages/app-settings.php b/app/pages/app-settings.php new file mode 100644 index 0000000..1c49563 --- /dev/null +++ b/app/pages/app-settings.php @@ -0,0 +1,2087 @@ +result->status == "active") { + dashboard\primary\success("Custom domain setup successfully!"); + misc\mysql\query("UPDATE `apps` SET `apiCustomDomainId` = ? WHERE `secret` = ?", [$custom_domain_id, $_SESSION['app']]); + } + else { + if($statusCode > 399) { + dashboard\primary\error($json->errors[0]->message); + } + else { + if($json->verification_errors) { + dashboard\primary\error("You need to set CNAME to api-worker.keyauth.win then try again!"); + } + else { + dashboard\primary\error("Failed to setup custom domain! Please try again"); + } + } + ?> +
+
+ +
+
+

Try again after waiting 1 minute

+
+ +
+
+
+
+
+ dashboard\primary\error("Hash is too short!"), + 'failure' => dashboard\primary\error("Failed to add hash!"), + 'success' => dashboard\primary\success("Added hash successfully!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; +} + +if (isset($_POST['resethash'])) { + $resp = misc\app\resetHash(); + match ($resp) { + 'failure' => dashboard\primary\error("Failed to reset hash!"), + 'success' => dashboard\primary\success("Successfully reset hash!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; +} + +if ($_SESSION['app']) { + $query = misc\mysql\query("SELECT * FROM `apps` WHERE `secret` = ?", [$_SESSION['app']]); + if ($query->num_rows > 0) { + while ($row = mysqli_fetch_array($query->result)) { + $enabled = $row['enabled']; + $owner = $row['owner']; + $hwidcheck = $row['hwidcheck']; + $forceHwid = $row['forceHwid']; + $minHwid = $row['minHwid']; + $vpnblock = $row['vpnblock']; + $panelstatus = $row['panelstatus']; + $customDomain = $row['customDomain']; + $hashcheck = $row['hashcheck']; + $tokenvalidation = $row["tokensystem"]; + $cooldown = $row['cooldown']; + $session = $row['session']; + $cooldownUnit = $row['cooldownUnit']; + $sessionUnit = $row['sessionUnit']; + $verr = $row['ver']; + $dll = $row['download']; + $webdll = $row['webdownload']; + $wh = $row['webhook']; + $ipLogging = $row['ipLogging']; + $rs = $row['resellerstore']; + $sellappwhsecret = $row['sellappsecret']; + $sellappdayproduct = $row['sellappdayproduct']; + $sellappweekproduct = $row['sellappweekproduct']; + $sellappmonthproduct = $row['sellappmonthproduct']; + $sellapplifetimeproduct = $row['sellapplifetimeproduct']; + $sellixwhsecret = $row['sellixsecret']; + $sellixdayproduct = $row['sellixdayproduct']; + $sellixweekproduct = $row['sellixweekproduct']; + $sellixmonthproduct = $row['sellixmonthproduct']; + $sellixlifetimeproduct = $row['sellixlifetimeproduct']; + $shoppywhsecret = $row['shoppysecret']; + $shoppydayproduct = $row['shoppydayproduct']; + $shoppyweekproduct = $row['shoppyweekproduct']; + $shoppymonthproduct = $row['shoppymonthproduct']; + $shoppylifetimeproduct = $row['shoppylifetimeproduct']; + $appdisabled = $row['appdisabled']; + $tokeninvalid = $row["tokeninvalid"]; + $usernametaken = $row['usernametaken']; + $keynotfound = $row['keynotfound']; + $keyused = $row['keyused']; + $nosublevel = $row['nosublevel']; + $usernamenotfound = $row['usernamenotfound']; + $passmismatch = $row['passmismatch']; + $hwidmismatch = $row['hwidmismatch']; + $noactivesubs = $row['noactivesubs']; + $hwidblacked = $row['hwidblacked']; + $pausedsub = $row['pausedsub']; + $vpnblocked = $row['vpnblocked']; + $keybanned = $row['keybanned']; + $userbanned = $row['userbanned']; + $sessionunauthed = $row['sessionunauthed']; + $hashcheckfail = $row['hashcheckfail']; + $minUsernameLength = $row['minUsernameLength']; + $blockLeakedPasswords = $row['blockLeakedPasswords']; + $customerPanelIcon = $row['customerPanelIcon']; + $loggedInMsg = $row['loggedInMsg']; + $pausedApp = $row['pausedApp']; + $unTooShort = $row['unTooShort']; + $pwLeaked = $row['pwLeaked']; + $chatHitDelay = $row['chatHitDelay']; + $enabledFunctions = $row['enabledFunctions']; + $apiCustomDomainId = $row['apiCustomDomainId']; + } + } +} + +if (isset($_POST['updatesettings'])) { + $status = misc\etc\sanitize($_POST['statusinput']); + $hwid = misc\etc\sanitize($_POST['hwidinput']); + $tokenvalidation = misc\etc\sanitize($_POST["tokeninput"]); + $forceHwid = misc\etc\sanitize($_POST['forceHwid']); + $minHwid = misc\etc\sanitize($_POST['minHwid']); + $vpn = misc\etc\sanitize($_POST['vpninput']); + $hashstatus = misc\etc\sanitize($_POST['hashinput']); + $ver = misc\etc\sanitize($_POST['version']); + $dl = misc\etc\sanitize($_POST['download']); + $webdl = misc\etc\sanitize($_POST['webdownload']); + $webhook = misc\etc\sanitize($_POST['webhook']); + $ipLogging = misc\etc\sanitize($_POST['ipLogging']); + $resellerstorelink = misc\etc\sanitize($_POST['resellerstore']); + $panelstatus = misc\etc\sanitize($_POST['panelstatus']); + $customDomain = misc\etc\sanitize($_POST['customDomain']); + $cooldownexpiry = misc\etc\sanitize($_POST['cooldownexpiry']); + $cooldownduration = misc\etc\sanitize($_POST['cooldownduration']) * $cooldownexpiry; + $sessionexpiry = misc\etc\sanitize($_POST['sessionexpiry']); + $sessionduration = misc\etc\sanitize($_POST['sessionduration']) * $sessionexpiry; + $minUsernameLength = misc\etc\sanitize($_POST['minUsernameLength']); + $blockLeakedPasswords = misc\etc\sanitize($_POST['blockLeakedPasswords']); + $appdisabledpost = misc\etc\sanitize($_POST['appdisabled']); + $tokeninvalid = misc\etc\sanitize($_POST['tokeninvalid']); + $usernametakenpost = misc\etc\sanitize($_POST['usernametaken']); + $keynotfoundpost = misc\etc\sanitize($_POST['keynotfound']); + $keyusedpost = misc\etc\sanitize($_POST['keyused']); + $nosublevelpost = misc\etc\sanitize($_POST['nosublevel']); + $usernamenotfoundpost = misc\etc\sanitize($_POST['usernamenotfound']); + $passmismatchpost = misc\etc\sanitize($_POST['passmismatch']); + $hwidmismatchpost = misc\etc\sanitize($_POST['hwidmismatch']); + $noactivesubspost = misc\etc\sanitize($_POST['noactivesubs']); + $hwidblackedpost = misc\etc\sanitize($_POST['hwidblacked']); + $pausedsubpost = misc\etc\sanitize($_POST['pausedsub']); + $vpnblockedpost = misc\etc\sanitize($_POST['vpnblocked']); + $keybannedpost = misc\etc\sanitize($_POST['keybanned']); + $userbannedpost = misc\etc\sanitize($_POST['userbanned']); + $sessionunauthedpost = misc\etc\sanitize($_POST['sessionunauthed']); + $hashcheckfailpost = misc\etc\sanitize($_POST['hashcheckfail']); + $shoppywebhooksecret = misc\etc\sanitize($_POST['shoppywebhooksecret']); + $shoppyday = misc\etc\sanitize($_POST['shoppydayproduct']); + $shoppyweek = misc\etc\sanitize($_POST['shoppyweekproduct']); + $shoppymonth = misc\etc\sanitize($_POST['shoppymonthproduct']); + $shoppylife = misc\etc\sanitize($_POST['shoppylifetimeproduct']); + $sellixwebhooksecret = misc\etc\sanitize($_POST['sellixwebhooksecret']); + $sellixday = misc\etc\sanitize($_POST['sellixdayproduct']); + $sellixweek = misc\etc\sanitize($_POST['sellixweekproduct']); + $sellixmonth = misc\etc\sanitize($_POST['sellixmonthproduct']); + $sellixlife = misc\etc\sanitize($_POST['sellixlifetimeproduct']); + $sellappwebhooksecret = misc\etc\sanitize($_POST['sellappwebhooksecret']); + $sellappday = misc\etc\sanitize($_POST['sellappdayproduct']); + $sellappweek = misc\etc\sanitize($_POST['sellappweekproduct']); + $sellappmonth = misc\etc\sanitize($_POST['sellappmonthproduct']); + $sellapplife = misc\etc\sanitize($_POST['sellapplifetimeproduct']); + $customerPanelIcon = misc\etc\sanitize($_POST['customerPanelIcon']); + $loggedInMsg = misc\etc\sanitize($_POST['loggedInMsg']); + $pausedApp = misc\etc\sanitize($_POST['pausedApp']); + $unTooShort = misc\etc\sanitize($_POST['unTooShort']); + $pwLeaked = misc\etc\sanitize($_POST['pwLeaked']); + $chatHitDelay = misc\etc\sanitize($_POST['chatHitDelay']); + $enabledFunctions = misc\etc\sanitize($_POST['functionValue']) ?? $enabledFunctions; + + if (!is_null($customDomain) && ($_SESSION['role'] == "seller" || $_SESSION['role'] == "Manager")) { + if (strpos($customDomain, "http") === 0) { + dashboard\primary\error("Do not include protocol. Your custom domain should be entered as panel.example.com not https://panel.example.com or http://panel.example.com"); + echo ""; + return; + } + $query = misc\mysql\query("SELECT `name`, `owner` FROM `apps` WHERE `customDomain` = ? AND `secret` != ?", [$customDomain, $_SESSION['app']]); + if ($query->num_rows > 0) { + $row = mysqli_fetch_array($query->result); + $name = $row["name"]; + $owner = $row["owner"]; + dashboard\primary\error("The domain {$customDomain} is already being used on app named \"{$name}\" owned by {$owner}. Use a different domain or subdomain please."); + echo ""; + return; + } + } else if (!empty($customDomain)) { + dashboard\primary\error("You must have seller plan to utilize customer panel"); + echo ""; + return; + } + + if($_SESSION['role'] == "tester" && !is_null($webhook)) { + dashboard\primary\error("You must upgrade to developer or seller to use Discord webhook!"); + echo ""; + return; + } + + if((!is_null($webhook) && !str_contains($webhook, "discord")) || (!is_null($webhook) && str_contains($webhook, "localhost")) || (!is_null($webhook) && str_contains($webhook, "127.0.0.1"))) { + dashboard\primary\error("Webhook URL is supposed to be a Discord webhook!"); + echo ""; + return; + } + + if($_SESSION['role'] == "tester" && $vpn) { + dashboard\primary\error("You must upgrade to developer or seller to use VPN block!"); + echo ""; + return; + } + + if (!empty($shoppywebhooksecret) && !empty($sellixwebhooksecret)) { + dashboard\primary\error("You cannot utilize Sellix and Shoppy simultaneously due to conflicting JavaScript code"); + echo ""; + return; + } + + if ($sessionduration > 604800) { + dashboard\primary\error("Session duration can be at most 7 days/1 week"); + echo ""; + return; + } + + $query = misc\mysql\query( + "UPDATE `apps` SET + `cooldown` = ?, + `customDomain` = NULLIF(?, ''), + `session` = ?, + `tokensystem` = ?, + `cooldownUnit` = ?, + `sessionUnit` = ?, + `appdisabled` = ?, + `tokeninvalid` = ?, + `hashcheckfail` = ?, + `sessionunauthed` = ?, + `userbanned` = ?, + `vpnblocked` = ?, + `keybanned` = ?, + `usernametaken` = ?, + `keynotfound` = ?, + `keyused` = ?, + `nosublevel` = ?, + `usernamenotfound` = ?, + `passmismatch` = ?, + `hwidmismatch` = ?, + `noactivesubs` = ?, + `hwidblacked` = ?, + `pausedsub` = ?, + `enabled` = ?, + `minUsernameLength` = ?, + `blockLeakedPasswords` = ?, + `hashcheck` = ?, + `hwidcheck` = ?, + `forceHwid` = ?, + `minHwid` = ?, + `vpnblock` = ?, + `ver` = ?, + `download` = NULLIF(?, ''), + `webdownload` = NULLIF(?, ''), + `webhook` = NULLIF(?, ''), + `ipLogging` = ?, + `resellerstore` = NULLIF(?, ''), + `sellixsecret` = NULLIF(?, ''), + `sellixdayproduct` = NULLIF(?, ''), + `sellixweekproduct` = NULLIF(?, ''), + `sellixmonthproduct` = NULLIF(?, ''), + `sellixlifetimeproduct` = NULLIF(?, ''), + `sellappsecret` = NULLIF(?, ''), + `sellappdayproduct` = NULLIF(?, ''), + `sellappweekproduct` = NULLIF(?, ''), + `sellappmonthproduct` = NULLIF(?, ''), + `sellapplifetimeproduct` = NULLIF(?, ''), + `shoppysecret` = NULLIF(?, ''), + `shoppydayproduct` = NULLIF(?, ''), + `shoppyweekproduct` = NULLIF(?, ''), + `shoppymonthproduct` = NULLIF(?, ''), + `shoppylifetimeproduct` = NULLIF(?, ''), + `customerPanelIcon` = ?, + `panelstatus` = ?, + `loggedInMsg` = ?, + `pausedApp` = ?, + `unTooShort` = ?, + `pwLeaked` = ?, + `chatHitDelay` = ?, + `enabledFunctions` = ? + WHERE `secret` = ?", + [ + $cooldownduration, + $customDomain, + $sessionduration, + $tokenvalidation, + $cooldownexpiry, + $sessionexpiry, + $appdisabledpost, + $tokeninvalid, + $hashcheckfailpost, + $sessionunauthedpost, + $userbannedpost, + $vpnblockedpost, + $keybannedpost, + $usernametakenpost, + $keynotfoundpost, + $keyusedpost, + $nosublevelpost, + $usernamenotfoundpost, + $passmismatchpost, + $hwidmismatchpost, + $noactivesubspost, + $hwidblackedpost, + $pausedsubpost, + $status, + $minUsernameLength, + $blockLeakedPasswords, + $hashstatus, + $hwid, + $forceHwid, + $minHwid, + $vpn, + $ver, + $dl, + $webdl, + $webhook, + $ipLogging, + $resellerstorelink, + $sellixwebhooksecret, + $sellixday, + $sellixweek, + $sellixmonth, + $sellixlife, + $sellappwebhooksecret, + $sellappday, + $sellappweek, + $sellappmonth, + $sellapplife, + $shoppywebhooksecret, + $shoppyday, + $shoppyweek, + $shoppymonth, + $shoppylife, + $customerPanelIcon, + $panelstatus, + $loggedInMsg, + $pausedApp, + $unTooShort, + $pwLeaked, + $chatHitDelay, + $enabledFunctions, + $_SESSION['app'] + ] + ); + + if ($query->affected_rows > 0) { + $appName = strtolower($_SESSION["name"]); + $ownerid = strtolower($_SESSION['ownerid']); + + $url = "https://api.cloudflare.com/client/v4/zones/{$cfZoneIdCache}/purge_cache"; + + $curl = curl_init($url); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); + curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode(array("files" => ["https://keyauth.win/api/KeyAuthApp-{$appName}-{$ownerid}"]))); + + $headers = array( + "Authorization: Bearer {$cfApiKeyCache}", + "Content-Type: application/json", + ); + curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); + + curl_exec($curl); + + misc\cache\purge('KeyAuthApp:' . $_SESSION["name"] . ':' . $_SESSION['ownerid']); + dashboard\primary\success("Successfully set settings!"); + } else { + dashboard\primary\error("Failed to set settings!"); + } +} + +if (isset($_POST['deleteHash'])){ + $hashToDelete = $_POST['deleteHash']; + + $query = misc\mysql\query("UPDATE `apps` SET `hash` = REPLACE(`hash`,? , '') WHERE `secret` = ?", [$hashToDelete, $_SESSION['app']]); + if ($query->affected_rows > 0) { + dashboard\primary\success("Successfully deleted hash!"); + } else { + dashboard\primary\error("Failed to delete hash!"); + } +} +?> + +
+
+
+ +

Application Settings

+

Control your application here. Learn More. Tip: You can press Ctrl + S to save settings!

+
+ +
+
    + + + + + + +
+
+ +
+
+
+
+ + + + + + + +
+
+ + +
+
+ + result->hostname; + } + ?> + + + + "; + return; + } + + $domainInput = $_POST['domain']; + + $url = "https://api.cloudflare.com/client/v4/zones/{$cfZoneIdCache}/custom_hostnames"; + + $curl = curl_init($url); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); + curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode(array("hostname" => $domainInput))); + + $headers = array( + "Authorization: Bearer {$cfApiKeyCache}", + "Content-Type: application/json", + ); + curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); + + $resp = curl_exec($curl); + $statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); + + $json = json_decode($resp); + + if($statusCode > 399) { + dashboard\primary\error($json->errors[0]->message); + echo " + "; + return; + } + + $ownership_verification = $json->result->ownership_verification; + $custom_domain_id = $json->result->id; + // must keep the $ownership_verification and $custom_domain_id variables + // ABOVE the dns.google request, to obtain the correct values + + $url = "https://dns.google/resolve?type=txt&name=_domainconnect.$domainInput"; + + $curl = curl_init($url); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); + + $resp = curl_exec($curl); + + $json = json_decode($resp); + + if($json->Answer && $json->Answer[0]->data == "api.cloudflare.com/client/v4/dns/domainconnect") { + $domainConnect = true; + } + ?> + +
+
+ +
+
+

Custom + domain

+
+ value; + + $data = "domain=$rootDomain&cnamehost=$domainInput&verifytxt=$verifyTxt"; + + // Sign the data using the private key and SHA-256 algorithm + $signature = ''; + openssl_sign($data, $signature, $privateKey, OPENSSL_ALGO_SHA256); + + $signature = urlencode(base64_encode($signature)); + openssl_free_key($privateKey); + ?> + + +
+ +
+
+

DNS Type:

+ TXT +
+

DNS Name:

+ name ?> +
+

DNS Content:

+ value ?> +
+
+ +
+
+

DNS Type:

+ CNAME +
+

DNS Name:

+ +
+

DNS Target:

+ api-worker.keyauth.win +
+ + +
+
+
+
+
+ + + + + + + + + + + \ No newline at end of file diff --git a/app/pages/audit-logs.php b/app/pages/audit-logs.php new file mode 100644 index 0000000..90bee5d --- /dev/null +++ b/app/pages/audit-logs.php @@ -0,0 +1,120 @@ + dashboard\primary\error("Failed to delete all audit logs"), + 'success' => dashboard\primary\success("Successfully deleted all audit logs!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; +} +if (isset($_POST['exportAuditLogs'])) { + echo ""; + // get all rows, put in text file, download text file, delete text file. +} +?> + +
+
+
+ +

Audit Logs

+
+
+
+
+ + + +
+ + + +
+ + + + + + +
+ + + + + + + + + + num_rows > 0) { + while ($row = mysqli_fetch_array($query->result)) { + + echo ""; + + echo " "; + + echo " "; + + echo " "; + + echo ""; + } + } + } + ?> + +
UserEventTime
" . $row["user"] . "" . $row["event"] . "
+
+ \ No newline at end of file diff --git a/app/pages/blacklists.php b/app/pages/blacklists.php new file mode 100644 index 0000000..2520dff --- /dev/null +++ b/app/pages/blacklists.php @@ -0,0 +1,239 @@ + dashboard\primary\error("Invalid blacklist type!"), + 'failure' => dashboard\primary\error("Failed to add blacklists!"), + 'success' => dashboard\primary\success("Successfully added blacklists!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; +} +if (isset($_POST['delblacks'])) { + $resp = misc\blacklist\deleteAll(); + match($resp){ + 'failure' => dashboard\primary\error("Failed to delete all whitelists!"), + 'success' => dashboard\primary\success("Successfully deleted all whitelists!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; +} + +if (isset($_POST['deleteblack'])) { + $resp = misc\blacklist\deleteSingular($_POST['deleteblack'], $_POST['type']); + match($resp){ + 'invalid' => dashboard\primary\error("Invalid blacklist type!"), + 'failure' => dashboard\primary\error("Failed to delete blacklist!"), + 'success' => dashboard\primary\success("Successfully deleted blacklist!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; +} + +if (isset($_POST["selected"]) && isset($_POST["action"])) { + if ($_POST["action"] == "delete") { + $data = json_decode($_POST["selected"], true); + + $array = array_map('urldecode', $data); + + foreach ($array as $item) { + $decoded = json_decode($item, true); + $resp = misc\blacklist\deleteSingular($decoded['value'], $decoded['type']); + match($resp){ + 'invalid' => dashboard\primary\error("Invalid blacklist type!"), + 'failure' => dashboard\primary\error("Failed to delete blacklist!"), + 'success' => dashboard\primary\success("Successfully deleted blacklist!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; + } + }else { + dashboard\primary\error("Unhandled Error! Contact us if you need help - Action:BLPxDB"); + } +} +?> + +
+
+
+ +

Blacklists

+

Block access from certain IPs/HWIDs Learn More.

+
+
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + +
SelectionBlacklist DataBlacklist TypeActions
+
+

Dropdown actions in RED do not show a confirmation! Dropdown actions in BLUE will show a confirmation!

+ \ No newline at end of file diff --git a/app/pages/chats.php b/app/pages/chats.php new file mode 100644 index 0000000..416096f --- /dev/null +++ b/app/pages/chats.php @@ -0,0 +1,631 @@ + dashboard\primary\error("Failed to delete message!"), + 'success' => dashboard\primary\success("Successfully deleted message!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; +} +if (isset($_POST['muteuser'])) { + $muted = misc\etc\sanitize($_POST['muted']); + $time = misc\etc\sanitize($_POST['time']); + $time = $time * $muted + time(); + + $resp = misc\chat\muteUser($_POST['user'], $time); + match($resp){ + 'missing' => dashboard\primary\error("User doesn't exist!"), + 'failure' => dashboard\primary\error("Failed to mute user!"), + 'success' => dashboard\primary\success("Successfully muted user!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; +} +if (isset($_POST['unmuteuser'])) { + $resp = misc\chat\unMuteUser($_POST['user']); + match($resp){ + 'failure' => dashboard\primary\error("Failed to unmute user!"), + 'success' => dashboard\primary\success("Successfully unmuted user!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; +} +if (isset($_POST['clearchannel'])) { + $resp = misc\chat\clearChannel($_POST['channel']); + match($resp){ + 'failure' => dashboard\primary\error("Failed to clear channel!"), + 'success' => dashboard\primary\success("Successfully cleared channel!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; +} + +if (isset($_POST['deleteallchatchannels'])){ + $resp = misc\chat\deleteAllChannels(); + match($resp){ + 'failure' => dashboard\primary\error("Failed to delete all chat channels!"), + 'success' => dashboard\primary\success("Successfully deleted all chat channels!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; +} + +if (isset($_POST['editchan'])) { + $chan = misc\etc\sanitize($_POST['editchan']); + $query = misc\mysql\query("SELECT * FROM `chats` WHERE `name` = ? AND `app` = ?", [$chan, $_SESSION['app']]); + if ($query->num_rows < 1) { + dashboard\primary\error("Channel not found!"); + echo ""; + return; + } +?> + + + + + +affected_rows > 0) { // check query impacted something, else show error + dashboard\primary\success("Successfully updated channel!"); + } else { + dashboard\primary\error("Failed To update channel!"); + } +} +if (isset($_POST['deletechan'])) { + $resp = misc\chat\deleteChannel($_POST['deletechan']); + match($resp){ + 'failure' => dashboard\primary\error("Failed to delete channel!"), + 'success' => dashboard\primary\success("Successfully deleted channel!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; +} + +if (isset($_POST['addchannel'])) { + if ($_SESSION['role'] != "seller") { + dashboard\primary\error("You must upgrade to seller to create chat channels"); + } else { + $unit = misc\etc\sanitize($_POST['unit']); + $delay = misc\etc\sanitize($_POST['delay']); + $delay = $delay * $unit; + $resp = misc\chat\createChannel($_POST['name'], $delay); + match($resp){ + 'failure' => dashboard\primary\error("Failed to create channel!"), + 'success' => dashboard\primary\success("Successfully created channel!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; + } +} +?> + + +
+
+
+ +

Chats

+

Allow your users to chat with each other. Learn More. +

+
+
+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + result)) { + $rows[] = $r; + } + foreach ($rows as $row) { + $chan = $row['name']; + ?> + + + + + + + + + + + + + + + + + + + + + +
Chat NameMessage DelayActions
+
+ +
    +
  • + +
  • +
  • + +
  • +
+
+
+
+ +

Dropdown actions in RED do not show a confirmation! Dropdown actions in BLUE will show a confirmation!

+ +
+ + +
+ + + + + + + + + + + + + result)) { + $rows[] = $r; + } + foreach ($rows as $row) { + $user = $row['author']; + ?> + + + + + + + + + + + + + + + +
AuthorMessageTime SentChannelActions
+ +
+ +
+ +
    +
  • + +
  • +
  • + +
  • +
+
+
+
+ +

Dropdown actions in RED do not show a confirmation! Dropdown actions in BLUE will show a confirmation!

+ + \ No newline at end of file diff --git a/app/pages/files.php b/app/pages/files.php new file mode 100644 index 0000000..44485ef --- /dev/null +++ b/app/pages/files.php @@ -0,0 +1,474 @@ + dashboard\primary\error("URL not valid!"), + 'no_local' => dashboard\primary\error("URL can't be a local path! Must be a remote URL accessible by the open internet!"), + 'failure' => dashboard\primary\error("Failed to add file!"), + 'success' => dashboard\primary\success("Successfully added file!"), + 'tester_file_exceed' => dashboard\primary\error("Tester plan may only upload files up to 10MB. Upgrade for larger file size!"), + 'dev_file_exceed' => dashboard\primary\error("File size limit is 50MB. Please upgrade for larger file size!"), + 'seller_file_exceed' => dashboard\primary\error("File size limit is 75MB. This is the MAX"), + 'name_too_large' => dashboard\primary\error("File name is too large. Rename it to something shorter"), + 'invalid_extension' => dashboard\primary\error("No HTML files. You must get the DIRECT URL which downloads INSTANTLY. No download page, direct file."), + 'bad_response' => dashboard\primary\error("File either not found or URL not allowed by the file host!"), + 'discord_cdn' => dashboard\primary\error("Discord's developers made files expire after 24 hours, use catbox.moe or pages.dev instead!"), + 'github_no_raw' => dashboard\primary\error("Click the \"Raw\" button on GitHub file. Only use raw.githubusercontent.com URLs"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; +} + +if (isset($_POST['delfiles'])) { + $resp = misc\upload\deleteAll(); + match($resp){ + 'failure' => dashboard\primary\error("Failed to delete all files!"), + 'success' => dashboard\primary\success("Successfully deleted all files!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; +} + +if (isset($_POST['deletefile'])) { + $resp = misc\upload\deleteSingular($_POST['deletefile']); + match($resp){ + 'failure' => dashboard\primary\error("Failed to delete all files!"), + 'success' => dashboard\primary\success("Successfully deleted all files!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; +} + +if (isset($_POST['editfile'])) { + $file = misc\etc\sanitize($_POST['editfile']); + + $result = misc\mysql\query("SELECT `url` FROM `files` WHERE `id` = ? AND `app` = ?", [$file, $_SESSION['app']]); + $fileUrl = mysqli_fetch_array($result->result); + + echo ' + + '; +} + +if (isset($_POST['savefile'])) { + $fileid = misc\etc\sanitize($_POST['savefile']); + $url = misc\etc\sanitize($_POST['url']); + + if (!filter_var($url, FILTER_VALIDATE_URL)) { + dashboard\primary\error("Invalid Url!"); + echo ""; + return; + } + + if (str_contains($url, "discord")) { + dashboard\primary\error("Discord's developers made files expire after 24 hours, use catbox.moe or pages.dev instead!"); + echo ""; + return; + } + + if (str_contains($url, "github.com")) { + dashboard\primary\error("Click the \"Raw\" button on GitHub file. Only use raw.githubusercontent.com URLs"); + echo ""; + return; + } + + if (str_contains($url, "localhost") || str_contains($url, "127.0.0.1") || str_contains($url, "file:/")) { + dashboard\primary\error("URL can't be a local path! Must be a remote URL accessible by the open internet"); + echo ""; + return; + } + + // Initialize cURL session + $ch = curl_init($url); + + // Set options + curl_setopt($ch, CURLOPT_NOBODY, true); // Only fetch headers, no body + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Return the transfer as a string + curl_setopt($ch, CURLOPT_HEADER, true); // Include the header in the output + curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla KeyAuth'); + + $response = curl_exec($ch); + + $httpStatusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); + + if ($httpStatusCode == 403 || $httpStatusCode == 404) { + dashboard\primary\error("File either not found or URL not allowed by the file host!"); + echo ""; + return; + } + + // Get content length + $filesize = curl_getinfo($ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD); + $contType = curl_getinfo($ch, CURLINFO_CONTENT_TYPE); + + if(str_contains($contType, "html")) { + dashboard\primary\error("No HTML files. You must get the DIRECT URL which downloads INSTANTLY. No download page, direct file."); + echo ""; + return; + } + + if ($filesize > 10000000 && $role == "tester") { + dashboard\primary\error("Users with tester plan may only upload files up to 10MB. Paid plans may upload up to 75MB."); + echo ""; + return; + } else if ($filesize > 50000000 && ($role == "developer" || $role == "Manager")) { + dashboard\primary\error("File size limit is 50 MB. Upgrade your account to gain a total of 75mb."); + echo ""; + return; + } else if ($filesize > 75000000) { + dashboard\primary\error("File size limit is 75 MB."); + echo ""; + return; + } + + $fn = basename(parse_url($url, PHP_URL_PATH)); + $fs = misc\etc\formatBytes($filesize); + + if(strlen($fn) > 49) { + dashboard\primary\error("File name is too large! Rename it to have a shorter name."); + echo ""; + return; + } + + $authed = misc\etc\sanitize($_POST['authed']) == NULL ? 0 : 1; + + $query = misc\mysql\query("UPDATE `files` SET `name` = ?,`size` = ?,`url` = ?, `uploaddate` = ?, `authed` = ? WHERE `app` = ? AND `id` = ?", [$fn, $fs, $url, time(), $authed, $_SESSION['app'], $fileid]); + + if ($query->affected_rows != 0) { + misc\cache\purge('KeyAuthFile:' . ($secret ?? $_SESSION['app']) . ':' . $fileid); + dashboard\primary\success("Successfully Updated File!"); + } else { + dashboard\primary\error("Failed to update file"); + } +} + +if (isset($_POST["selected"]) && isset($_POST["action"])) { + $selected = json_decode($_POST['selected'], true); + if ($_POST["action"] == "delete") { + foreach ($selected as $value) { + $resp = misc\upload\deleteSingular($value); + match($resp){ + 'failure' => dashboard\primary\error("Failed to delete file!"), + 'success' => dashboard\primary\success("Successfully deleted file!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; + } + } + else if ($_POST["action"] == "authEnable") { + foreach ($selected as $value) { + $query = misc\mysql\query("UPDATE `files` SET `authed` = 1 WHERE `app` = ? AND `id` = ?", [$_SESSION['app'], $value]); + + if ($query->affected_rows != 0) { + misc\cache\purge('KeyAuthFile:' . ($secret ?? $_SESSION['app']) . ':' . $fileid); + dashboard\primary\success("Successfully updated files!"); + } else { + dashboard\primary\error("Failed to update files"); + } + } + } + else if ($_POST["action"] == "authDisable") { + foreach ($selected as $value) { + $query = misc\mysql\query("UPDATE `files` SET `authed` = 0 WHERE `app` = ? AND `id` = ?", [$_SESSION['app'], $value]); + + if ($query->affected_rows != 0) { + misc\cache\purge('KeyAuthFile:' . ($secret ?? $_SESSION['app']) . ':' . $fileid); + dashboard\primary\success("Successfully updated files!"); + } else { + dashboard\primary\error("Failed to update files"); + } + } + } + else { + dashboard\primary\error("Invalid action"); + } +} +?> + +
+
+
+ +

Files

+

Let your users download files you upload here. Learn More.

+
+
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + num_rows > 0) { + while ($row = mysqli_fetch_array($query->result)){ + echo ""; + + echo ''; + + echo " "; + + echo " "; + + echo " "; + + echo " "; + + echo ""; + + echo ' + + + + '; + } + } + } + ?> + +
SelectFilenameIDSizeUpload DateAuthenticatedActions
' . '" . $row["name"] . "" . $row["id"] . "" . $row["size"] . "" . ($row["authed"] ? 'True' : 'False') . "
+ +
+ + +
+
+
+

Dropdown actions in RED do not show a confirmation! Dropdown actions in BLUE will show a confirmation!

+ + \ No newline at end of file diff --git a/app/pages/forms.php b/app/pages/forms.php new file mode 100644 index 0000000..d05da52 --- /dev/null +++ b/app/pages/forms.php @@ -0,0 +1,641 @@ + $suggestionTag = "Website", + "Telegram Bot" => $suggestionTag = "Telegram Bot", + "Discord Bot" => $suggestionTag = "Discord Bot", + "Documentation" => $suggestionTag = "Documentation", + "Examples" => $suggestionTag = "Examples", + "Telegram Server" => $suggestionTag = "Telegram Server", + "API" => $suggestionTag = "API", + "Seller API" => $suggestionTag = "Seller API", + default => $suggestionTag = "Unhandled Error!" + }; + MakeSuggestion($_POST['suggestionDescription'], "Videos/Images \n" . $_POST['suggestionLinks'] . "\n\nContact Information: \n" . $_POST['suggestionContactName'], $suggestionTag); +} + +if (isset($_POST['reportBug'])){ + $bugTag = isset($_POST['bugType']) ? $_POST['bugType'] : ''; + match($bugTag){ + "Website" => $bugTag = "Website", + "Telegram Bot" => $bugTag = "Telegram Bot", + "Discord Bot" => $bugTag = "Discord Bot", + "Documentation" => $bugTag = "Documentation", + "Examples" => $bugTag = "Examples", + "API" => $bugTag = "API", + "Seller API" => $bugTag = "Seller API", + default => $bugTag = "Unhandled Error!" + }; + ReportBug($_POST['bugDescription'], "Videos/Images \n" . $_POST['bugLinks'] . "\n\nContact Information: \n" . $_POST['bugContactName'], $bugTag); +} + +if (isset($_POST['submitReport'])){ + if (!isset($_POST['reportHonesty'])){ + dashboard\primary\error("You must be honest on your report!"); + } + + if (!isset($_POST['reportUnderstanding'])){ + dashboard\primary\error("You must fully understand you being banned if you fail to be truthful to submit your report!"); + } + + $color = 880808; + $message = + "\n **KeyAuth Username:** \n" . $_SESSION['username'] . + "\n\n **Contact Method:** \n" . $_POST['reportcontactName'] . + "\n\n **Staff or Member:** \n" . $_POST['reportType'] . + "\n\n **Report Reason:** \n" . $_POST['reportReason'] . + "\n\n **Users (Reported) Contact:** \n" . $_POST['usersContact']; + sendReport($color, $_SESSION['username'], $message); +} + +if (isset($_POST['fileDmca'])){ + if (!isset($_POST["dmcaHonesty"])){ + dashboard\primary\error("You must be honest on your report!"); + } + + if (!isset($_POST["dmcaalerted"])){ + dashboard\primary\error("You must attempt to reach out to the user before submitting a DMCA request!"); + } + + if (isset($_POST['reachoutFailure'])) { + $reachoutFailureValue = "Yes"; + } else { + $reachoutFailureValue = "No"; + } + + $color = 880808; + $message = + "\n **KeyAuth Username:** \n" . $_SESSION['username'] . + "\n\n **Contact Method:** \n" . $_POST['dmcaContactName'] . + "\n\n **DMCA Type:** \n" . $_POST['dmcaType'] . + "\n\n **Report Reason:** \n" . $_POST['dmcaDescription'] . + "\n\n **Proof:** \n" . $_POST['dmcaProof'] . + "\n\n **User failed to respond to reach out?** \n" . $reachoutFailureValue; + submitDMCA($color, $_SESSION['username'], $message); +} +?> + +
+
+
+ +

Forms

+

Just about any form you need.

+
+
+
+ + + + + + +
+ + + + + + + + + Report A Vulnerability + + + + + +
+
+
+
+ +
+
+
+ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/pages/licenses.php b/app/pages/licenses.php new file mode 100644 index 0000000..3826e26 --- /dev/null +++ b/app/pages/licenses.php @@ -0,0 +1,974 @@ + dashboard\primary\error("Failed to unban license!"), + 'success' => dashboard\primary\success("Successfully unbanned license!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; +} + +if (isset($_POST['genkeys'])) { + if (empty(trim($_POST['mask']))) { + dashboard\primary\error("You must specify a key mask."); + } else { + $key = misc\license\createLicense($_POST['amount'], $_POST['mask'], $_POST['duration'], $_POST['level'], $_POST['note'], $_POST['user'], $_POST['expiry']); + switch ($key) { + case 'max_keys': + dashboard\primary\error("You can only generate 100 licenses at a time"); + break; + case 'tester_limit': + dashboard\primary\error("Tester plan only allows for 10 licenses, please upgrade!"); + break; + case 'dupe_custom_key': + dashboard\primary\error("Can't do custom key with amount greater than one"); + break; + default: + $mask = misc\etc\sanitize($_POST['mask']); + $amount = intval($_POST['amount']); + $level = misc\etc\sanitize($_POST['level']); + $note = misc\etc\sanitize($_POST['note']); + $user = misc\etc\sanitize($_POST['user']); + $duration = misc\etc\sanitize($_POST['duration']); + $expiry = misc\etc\sanitize($_POST['expiry']); + + misc\mysql\query("UPDATE `apps` SET `format` = ?,`amount` = ?,`lvl` = ?,`note` = ?,`user` = ?,`duration` = ?,`unit` = ? WHERE `secret` = ?", [$mask, $amount, $level, $note, $user, $duration, $expiry, $_SESSION['app']]); + $_SESSION['keys_array'] = $key; + dashboard\primary\success("License(s) Created And Displayed Above!"); + break; + } + } +} + +if (isset($_POST["action"]) && isset($_POST["selected"])) { + $selected = json_decode($_POST['selected'], true); + if ($_POST["action"] == "delete") { + if ($_SESSION['role'] == "tester") { + dashboard\primary\error("Free tester accounts can't delete keys, upgrade your account to delete keys!"); + echo ""; + return; + } + foreach ($selected as $value) { + $resp = misc\license\deleteSingular($value, false, $_SESSION['app']); + match ($resp) { + 'failure' => dashboard\primary\error("Failed to delete license!"), + 'success' => dashboard\primary\success("Successfully deleted license!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; + } + } + else if ($_POST["action"] == "banKeyMulti") { + foreach ($selected as $value) { + $resp = misc\license\ban($value, "You selected to ban multiple keys", 0); + match ($resp) { + 'failure' => dashboard\primary\error("Failed to ban keys!"), + 'success' => dashboard\primary\success("Successfully banned keys!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; + } + } + else { + dashboard\primary\error("Invalid action"); + } +} + +if (isset($_POST['editkey'])) { + $key = misc\etc\sanitize($_POST['editkey']); + $query = misc\mysql\query("SELECT * FROM `keys` WHERE `key` = ? AND `app` = ?",[$key, $_SESSION['app']]); + if ($query->num_rows < 1) { + dashboard\primary\error("Key not Found!"); + echo ""; + return; + } + $row = mysqli_fetch_array($query->result); +?> + + + + + +
+
+
+ +

Licenses

+

Licenses allow your users to register on your application.

+
+
+
+
+ + + + + + + + + +
+ + + + + + + + + + + + + "; + } + echo "
$keys

"; + echo ""; + unset($_SESSION['keys_array']); + } + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +
SelectKeyUserCreation DateGenerated ByDurationNoteUsed OnUsed ByStatusActions
+
+

Dropdown actions in RED do not show a confirmation! Dropdown actions in BLUE will show a confirmation!

+ + + + + + + +
+ + "; + return; + } + $resp = misc\license\deleteAll(); + match ($resp) { + 'failure' => dashboard\primary\error("Didn't find any keys!"), + 'success' => dashboard\primary\success("Deleted All Keys!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; + } + + if (isset($_POST['addtime'])) { + $resp = misc\license\addTime($_POST['time'], $_POST['expiry']); + match ($resp) { + 'failure' => dashboard\primary\error("Failed to add time!"), + 'success' => dashboard\primary\success("Added time to unused licenses!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; + } + + if (isset($_POST['deleteallunused'])) { + if ($_SESSION['role'] == "tester") { + dashboard\primary\error("Free tester accounts can't delete keys, upgrade your account to delete keys!"); + echo ""; + return; + } + $resp = misc\license\deleteAllUnused(); + match ($resp) { + 'failure' => dashboard\primary\error("Didn't find any unused keys!"), + 'success' => dashboard\primary\success("Deleted all unused keys!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; + } + + if (isset($_POST['deleteallused'])) { + if ($_SESSION['role'] == "tester") { + dashboard\primary\error("Free tester accounts can't delete keys, upgrade your account to delete keys!"); + echo ""; + return; + } + $resp = misc\license\deleteAllUsed(); + match ($resp) { + 'failure' => dashboard\primary\error("Didn't find any used keys!"), + 'success' => dashboard\primary\success("Deleted all used keys!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; + } + + if (isset($_POST['savekey'])) { + $key = misc\etc\sanitize($_POST['savekey']); + $level = misc\etc\sanitize($_POST['level']); + $duration = misc\etc\sanitize($_POST['duration']); + $note = misc\etc\sanitize($_POST['editNote']); + if (!empty($duration)) { + $expiry = misc\etc\sanitize($_POST['expiry']); + $duration = $duration * $expiry; + misc\mysql\query("UPDATE `keys` SET `expires` = ? WHERE `key` = ? AND `app` = ?",[$duration, $key, $_SESSION['app']]); + } + misc\mysql\query("UPDATE `keys` SET `note` = ?, `level` = ? WHERE `key` = ? AND `app` = ?",[$note, $level, $key, $_SESSION['app']]); + misc\cache\purge('KeyAuthKey:' . $_SESSION['app'] . ':' . $key); + misc\cache\purge('KeyAuthKeys:' . $_SESSION['app']); + dashboard\primary\success("Successfully Updated Settings!"); + } + + if (isset($_POST['importkeysFile'])) { + if ($_FILES['file_input']['error'] == UPLOAD_ERR_OK) { + $fileContent = file_get_contents($_FILES['file_input']['tmp_name']); + $jsonArray = json_decode($fileContent, true); + + if ($jsonArray === null) { + dashboard\primary\error("Invalid JSON format!"); + echo ""; + return; + } + + if (!isset($jsonArray['keys'])) { + dashboard\primary\error("Missing 'keys' array in JSON!"); + echo ""; + return; + } + + if (!isset($jsonArray['tokens'])) { + dashboard\primary\error("Missing 'tokens' array in JSON!"); + echo ""; + return; + } + + foreach ($jsonArray['keys'] as $keyData) { + $key_format = $keyData['key']; + $user_format = $keyData['user']; + $note_format = $keyData['note']; + $expiry_format = $keyData['expiry']; + $status_format = $keyData['status']; + $level_format = $keyData['level']; + $genby_format = $keyData['genby']; + $gendate_format = $keyData['gendate']; + $usedon_format = $keyData['usedon']; + $banned_format = $keyData['banned']; + + /*if (!isset($key_format) || $key_format == '' || !isset($level_format) || $level_format == '' || !isset($expiry_format) || $expiry_format == '') { + dashboard\primary\error("Invalid Format!"); + echo ""; + return; + }*/ + + misc\mysql\query("INSERT INTO `keys` (`key`, `user`, `note`, `expires`, `status`, `level`, `genby`, `gendate`, `usedon`, `app`, `banned`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", [$key_format, $note_format, $expiry_format, $status_format, $level_format, $genby_format, $gendate_format, $usedon_format, $_SESSION['app'], $bannned_format]);; + } + + foreach ($jsonArray['tokens'] as $tokenData){ + $token = $tokenData['token']; + $assigned = $tokenData['assigned']; + $banned = $tokenData['banned']; + $reason = $tokenData['reason']; + $hash = $tokenData['hash']; + $type = $tokenData['type']; + $status = $tokenData['status']; + + misc\mysql\query("INSERT INTO `tokens` (`token`, `assigned`, `banned`, `reason`, `hash`, `type`, `status`, `app`) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", [$token, $assigned, $banned, $reason, $hash, $type, $status, $_SESSION['app']]); + } + + dashboard\primary\success("Successfully imported licenses!"); + } else { + dashboard\primary\error("File upload failed!"); + echo ""; + return; + } + } + + if (isset($_POST['deletekey'])) { + if ($_SESSION['role'] == "tester") { + dashboard\primary\error("Free tester accounts can't delete keys, upgrade your account to delete keys!"); + echo ""; + return; + } + $userToo = ($_POST['delUserToo'] == "on") ? 1 : 0; + $resp = misc\license\deleteSingular($_POST['deletekey'], $userToo); + match ($resp) { + 'failure' => dashboard\primary\error("Failed to delete license!"), + 'success' => dashboard\primary\success("Successfully deleted license!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; + } + + if (isset($_POST['dlkeys'])) { + echo ""; + // get all rows, put in text file, download text file, delete text file. + } + + if (isset($_POST['bankey'])) { + $userToo = ($_POST['banUserToo'] == "on") ? 1 : 0; + $resp = misc\license\ban($_POST['bankey'], $_POST['reason'], $userToo); + match ($resp) { + 'failure' => dashboard\primary\error("Failed to ban license!"), + 'success' => dashboard\primary\success("Successfully banned license!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; + } \ No newline at end of file diff --git a/app/pages/logout.php b/app/pages/logout.php new file mode 100644 index 0000000..60975bb --- /dev/null +++ b/app/pages/logout.php @@ -0,0 +1,8 @@ +"; +session_destroy(); +exit(); diff --git a/app/pages/logs.php b/app/pages/logs.php new file mode 100644 index 0000000..d66ae62 --- /dev/null +++ b/app/pages/logs.php @@ -0,0 +1,119 @@ + dashboard\primary\error("Failed to delete all logs!"), + 'success' => dashboard\primary\success("Successfully deleted all logs!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; +} +if (isset($_POST['dllogs'])){ + echo ""; +} + +if($_SESSION['role'] == "tester") { + $query = misc\mysql\query("SELECT count(*) AS 'numLogs' FROM `logs` WHERE `logapp` = ?",[$_SESSION['app']]); + $row = mysqli_fetch_array($query->result); + $numLogs = $row["numLogs"]; + if($numLogs >= 20) { + ?> + +
+
+
+ +

Logs

+
+ +
+
+
+ + + + +
+ + + + +
+ + + + + +
+ + + + + + + + + +
Log DateLog DataCredentialDevice Name
+
\ No newline at end of file diff --git a/app/pages/manage-accs.php b/app/pages/manage-accs.php new file mode 100644 index 0000000..cde76a7 --- /dev/null +++ b/app/pages/manage-accs.php @@ -0,0 +1,690 @@ + 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 ""; + 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 ' + + '; +} + +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 ''; + 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); + } +} +?> + +
+
+
+ +

Resellers & Managers

+

Access your Reseller and Manager accounts. Learn More.

+
+
+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + num_rows > 0){ + while ($row = mysqli_fetch_array($query->result)){ + echo ""; + echo ""; + echo ""; + echo ""; + + if ($row["roles"] == "Manager"){ + echo ""; + } else { + echo ""; + } + echo ""; + + echo ' + '; + } + } + ?> + +
UsernameRoleApplicationBalanceAllowed LevelsActions
" . $row["username"] . "" . $row["role"] . "" . $row["app"] . "N/A" . $row["balance"] . "" . $row["keylevels"] . "
+
+ +
    +
  • + +
  • +
  • + +
  • +
  • + +
  • +
  • + +
  • +
+
+
+
+

Dropdown actions in RED do not show a confirmation! Dropdown actions in BLUE will show a confirmation!

+ + + + + \ No newline at end of file diff --git a/app/pages/manage-apps.php b/app/pages/manage-apps.php new file mode 100644 index 0000000..f722184 --- /dev/null +++ b/app/pages/manage-apps.php @@ -0,0 +1,1245 @@ +num_rows < 1) { + dashboard\primary\error("Application not found!"); + } else { + $row = mysqli_fetch_array($query->result); + $banned = $row["banned"]; + + if ($banned) { + dashboard\primary\error("Application is banned!"); + } else { + $_SESSION['app'] = $row["secret"]; + $_SESSION['name'] = $row["name"]; + $_SESSION['sellerkey'] = $row["sellerkey"]; + + echo ''; // needed to refresh nav sidebar + dashboard\primary\success("Successfully Selected the App!"); + } + } +} + +if (isset($_POST['create_app'])) { + + $appname = misc\etc\sanitize($_POST['appname']); + if ($appname == "") { + dashboard\primary\error("Input a valid name"); + echo ''; + return; + } + + $query = misc\mysql\query("SELECT 1 FROM `apps` WHERE name = ? AND owner = ?", [$appname, $_SESSION['username']]); + if ($query->num_rows > 0) { + dashboard\primary\error("You already own application with this name!"); + echo ''; + return; + } + + $owner = $_SESSION['username']; + + if ($role == "tester") { + $num_rows = misc\mysql\query("SELECT * FROM `apps` WHERE `owner` = ? AND `ownerid` = ?", [$_SESSION['username'], $_SESSION['ownerid']])->num_rows; + + if ($num_rows > 0) { + dashboard\primary\error("Tester plan only supports one application!"); + echo ''; + return; + } + } + + if ($role == "Manager") { + dashboard\primary\error("Manager Accounts Are Not Allowed To Create Applications"); + echo ''; + return; + } + + $clientsecret = hash('sha256', misc\etc\generateRandomString()); + $algos = array( + 'ripemd128', + 'md5', + 'md4', + 'tiger128,4', + 'haval128,3', + 'haval128,4', + 'haval128,5' + ); + $sellerkey = hash($algos[array_rand($algos)], misc\etc\generateRandomString()); + misc\mysql\query("INSERT INTO `subscriptions` (`name`, `level`, `app`) VALUES ('default', '1', ?)", [$clientsecret]); + $query = misc\mysql\query("INSERT INTO `apps` (`owner`, `name`, `secret`, `ownerid`, `enabled`, `hwidcheck`, `sellerkey`) VALUES (?, ?, ?, ?, '1', '1', ?)", [$_SESSION['username'], $appname, $clientsecret, $_SESSION['ownerid'], $sellerkey]); + + if ($query->affected_rows != 0) { + dashboard\primary\success("Successfully Created App!"); + $_SESSION['app'] = $clientsecret; + $_SESSION['name'] = $appname; + $_SESSION['sellerkey'] = $sellerkey; + } else { + dashboard\primary\error("Failed to create application!"); + } +} + +if (isset($_POST['rename_app'])) { + $appname = misc\etc\sanitize($_POST['appname']); + if ($appname == "") { + dashboard\primary\error("Input a valid name"); + echo ''; + return; + } + if ($role == "Manager") { + dashboard\primary\error("Manager Accounts Aren't Allowed To Rename Applications"); + echo ''; + return; + } + $query = misc\mysql\query("SELECT 1 FROM `apps` WHERE `owner` = ? AND `name` = ?", [$_SESSION['username'], $appname]); + if ($query->num_rows > 0) { + dashboard\primary\error("You already have an application with this name!"); + echo ''; + return; + } + misc\mysql\query("UPDATE `accounts` SET `app` = ? WHERE `app` = ? AND `owner` = ?", [$appname, $_SESSION['name'], $_SESSION['username']]); + $query = misc\mysql\query("UPDATE `apps` SET `name` = ? WHERE `secret` = ? AND `owner` = ?", [$appname, $_SESSION['app'], $_SESSION['username']]); + + if ($query->affected_rows != 0) { + $oldName = $_SESSION['name']; + $_SESSION['name'] = $appname; + dashboard\primary\success("Successfully Renamed App!"); + misc\cache\purge('KeyAuthApp:' . $oldName . ':' . $_SESSION['ownerid']); + if ($_SESSION['role'] == "seller") { + $query = misc\mysql\query("SELECT `customDomain`, `sellerkey`, `customDomainAPI` FROM `apps` WHERE `owner` = ? AND `name` = ?", [$_SESSION['username'], $appname]); + $row = mysqli_fetch_array($query->result); + misc\cache\purge('KeyAuthAppPanel:' . $row['customDomain']); + misc\cache\purge('KeyAuthAppSeller:' . $row['sellerkey']); + } + } else { + dashboard\primary\error("Application Renamed Failed!"); + } +} + +if (isset($_POST['pauseapp'])) { + if ($role == "Manager") { + dashboard\primary\error("Manager accounts aren't allowed to pause applications"); + echo ''; + return; + } + misc\cache\purgePattern('KeyAuthSubs:' . $_SESSION["app"]); + misc\app\pause(); + dashboard\primary\success("Paused application and any active subscriptions!"); +} +if (isset($_POST['unpauseapp'])) { + if ($role == "Manager") { + dashboard\primary\error("Manager accounts aren't allowed to unpause applications"); + echo ''; + return; + } + misc\cache\purgePattern('KeyAuthSubs:' . $_SESSION["app"]); + misc\app\unpause(); + dashboard\primary\success("Unpaused application and any paused subscriptions!"); +} + +if (isset($_POST['refreshapp'])) { + if ($role == "Manager") { + dashboard\primary\error("Manager Accounts Aren't Allowed To Refresh Applications"); + echo ''; + return; + } + $gen = misc\etc\generateRandomString(); + $new_secret = hash('sha256', $gen); + $query = misc\mysql\query("UPDATE `apps` SET `secret` = ? WHERE `secret` = ? AND `owner` = ?", [$new_secret, $_SESSION['app'], $_SESSION['username']]); + if ($query->affected_rows != 0) { + misc\mysql\query("UPDATE `bans` SET `app` = ? WHERE `app` = ?", [$new_secret, $_SESSION['app']]); + misc\mysql\query("UPDATE `buttons` SET `app` = ? WHERE `app` = ?", [$new_secret, $_SESSION['app']]); + misc\mysql\query("UPDATE `chatmsgs` SET `app` = ? WHERE `app` = ?", [$new_secret, $_SESSION['app']]); + misc\mysql\query("UPDATE `chatmutes` SET `app` = ? WHERE `app` = ?", [$new_secret, $_SESSION['app']]); + misc\mysql\query("UPDATE `chats` SET `app` = ? WHERE `app` = ?", [$new_secret, $_SESSION['app']]); + misc\mysql\query("UPDATE `files` SET `app` = ? WHERE `app` = ?", [$new_secret, $_SESSION['app']]); + misc\mysql\query("UPDATE `keys` SET `app` = ? WHERE `app` = ?", [$new_secret, $_SESSION['app']]); + misc\mysql\query("UPDATE `logs` SET `logapp` = ? WHERE `logapp` = ?", [$new_secret, $_SESSION['app']]); + misc\mysql\query("UPDATE `sessions` SET `app` = ? WHERE `app` = ?", [$new_secret, $_SESSION['app']]); + misc\mysql\query("UPDATE `subs` SET `app` = ? WHERE `app` = ?", [$new_secret, $_SESSION['app']]); + misc\mysql\query("UPDATE `subscriptions` SET `app` = ? WHERE `app` = ?", [$new_secret, $_SESSION['app']]); + misc\mysql\query("UPDATE `users` SET `app` = ? WHERE `app` = ?", [$new_secret, $_SESSION['app']]); + misc\mysql\query("UPDATE `uservars` SET `app` = ? WHERE `app` = ?", [$new_secret, $_SESSION['app']]); + misc\mysql\query("UPDATE `vars` SET `app` = ? WHERE `app` = ?", [$new_secret, $_SESSION['app']]); + misc\mysql\query("UPDATE `webhooks` SET `app` = ? WHERE `app` = ?", [$new_secret, $_SESSION['app']]); + misc\mysql\query("UPDATE `tokens` SET `app` = ? WHERE `app` = ?", [$new_secret, $_SESSION['app']]); + $_SESSION['app'] = $new_secret; + misc\cache\purge('KeyAuthApp:' . $_SESSION['name'] . ':' . $_SESSION['ownerid']); + if ($_SESSION['role'] == "seller" || $_SESSION['role'] == "developer") { + $query = misc\mysql\query("SELECT `sellerkey`,`customDomainAPI` FROM `apps` WHERE `owner` = ? AND `name` = ?", [$_SESSION['username'], $_SESSION['name']]); + $row = mysqli_fetch_array($query->result); + misc\cache\purge('KeyAuthAppSeller:' . $row['sellerkey']); + misc\cache\purge('KeyAuthApp:' . $row['customDomainAPI']); + } + dashboard\primary\success("Successfully Refreshed App!"); + } else { + dashboard\primary\error("Application Refresh Failed!"); + } +} + +if (isset($_POST['deleteapp'])) { + if ($role == "Manager") { + dashboard\primary\error("Manager Accounts Aren't Allowed To Delete Applications"); + echo ''; + return; + } + + if ($_POST['confirmappname'] !== "Confirm Deletion"){ + dashboard\primary\error("Failed!"); + echo ''; + return; + } + + $app = $_SESSION['app']; + $query = misc\mysql\query("DELETE FROM `apps` WHERE `secret` = ?", [$app]); + if ($query->affected_rows != 0) { + misc\mysql\query("DELETE FROM `bans` WHERE `app` = ?", [$app]); + misc\mysql\query("DELETE FROM `buttons` WHERE `app` = ?", [$app]); + misc\mysql\query("DELETE FROM `chatmsgs` WHERE `app` = ?", [$app]); + misc\mysql\query("DELETE FROM `chatmutes` WHERE `app` = ?", [$app]); + misc\mysql\query("DELETE FROM `chats` WHERE `app` = ?", [$app]); + misc\mysql\query("DELETE FROM `files` WHERE `app` = ?", [$app]); + misc\mysql\query("DELETE FROM `keys` WHERE `app` = ?", [$app]); + misc\mysql\query("DELETE FROM `logs` WHERE `logapp` = ?", [$app]); + misc\mysql\query("DELETE FROM `sessions` WHERE `app` = ?", [$app]); + misc\mysql\query("DELETE FROM `subs` WHERE `app` = ?", [$app]); + misc\mysql\query("DELETE FROM `subscriptions` WHERE `app` = ?", [$app]); + misc\mysql\query("DELETE FROM `users` WHERE `app` = ?", [$app]); + misc\mysql\query("DELETE FROM `uservars` WHERE `app` = ?", [$app]); + misc\mysql\query("DELETE FROM `vars` WHERE `app` = ?", [$app]); + misc\mysql\query("DELETE FROM `webhooks` WHERE `app` = ?", [$app]); + misc\mysql\query("DELETE FROM `auditLog` WHERE `app` = ?", [$app]); + misc\mysql\query("DELETE FROM `sellerLogs` WHERE `app` = ?", [$app]); + misc\mysql\query("DELETE FROM `whitelist` WHERE `app` = ?", [$app]); + misc\mysql\query("DELETE FROM `tokens` WHERE `app` = ?", [$app]); + misc\mysql\query("DELETE FROM `accounts` WHERE `app` = ? AND `owner` = ?", [$_SESSION['name'], $_SESSION['username']]); + + misc\cache\purge('KeyAuthApp:' . $_SESSION['name'] . ':' . $_SESSION['ownerid']); + if ($_SESSION['role'] == "seller" || $_SESSION['role'] == "developer") { + $query = misc\mysql\query("SELECT `sellerkey`,`customDomainAPI` FROM `apps` WHERE `owner` = ? AND `name` = ?", [$_SESSION['username'], $_SESSION['name']]); + $row = mysqli_fetch_array($query->result); + misc\cache\purge('KeyAuthAppSeller:' . $row['sellerkey']); + misc\cache\purge('KeyAuthApp:' . $row['customDomainAPI']); + } + + $_SESSION['app'] = NULL; + dashboard\primary\success("Successfully deleted App!"); + $query = misc\mysql\query("SELECT * FROM `apps` WHERE `owner` = ? AND `ownerid` = ?", [$_SESSION['username'], $_SESSION['ownerid']]); // select all apps where owner is current user + if ($query->num_rows == 1) // if the user only owns one app, select that app, otherwise select no app + { + $row = mysqli_fetch_array($query->result); + $_SESSION['name'] = $row["name"]; + $_SESSION['app'] = $row["secret"]; + } else { + $_SESSION['name'] = NULL; + } + } else { + dashboard\primary\error("Application Deletion Failed!"); + } +} + +if (isset($_SESSION["app"])) { + $appsecret = $_SESSION["app"]; + $query = misc\mysql\query("SELECT * FROM `apps` WHERE `secret` = ?", [$appsecret]); + + $row = mysqli_fetch_array($query->result); + $appname = $row["name"]; + $secret = $row["secret"]; + $version = $row["ver"]; + $ownerid = $row["ownerid"]; + $paused = $row["paused"]; +} + +if (isset($_POST["closeAlert"])) { + $query = misc\mysql\query("UPDATE `accounts` SET `alert` = ? WHERE `username` = ?", [NULL, $_SESSION["username"]]); + + if ($query->affected_rows != 0) { + dashboard\primary\success("Successfully closed staff alert."); + $alertMsg = NULL; + } else { + dashboard\primary\error("This alert can not be closed. Please contact staff."); + } +} +?> + + + + + + + +
+
+
+ +

+ + + Manage Applications - + + Manage Applications + +

+

This is where it all begins. Learn More.

+
+ +
+
+ +

Application Credentials

+

Simply replace the placeholder code in the + example with these

+
+
    + + + +
  • + +
  • +
  • + +
  • +
  • + +
  • +
  • + +
  • +
  • + +
  • +
  • + +
  • +
  • + +
  • +
  • + +
  • +
  • + +
  • +
+
+
+
+
+public static api KeyAuthApp = new api(
+    name: "", // App name - VaultCord.com FREE Discord backup bot for members & your entire server saved from terms and nukes!
+    ownerid: "", // Account ID
+    version: "" // Application version. Used for automatic downloads see video here https://www.youtube.com/watch?v=kW195PLCBKs
+    //path: @"Your_Path_Here" // (OPTIONAL) see tutorial here https://www.youtube.com/watch?v=I9rxt821gMk&t=1s
+);
+
+ + + + + + + + + + View + C# Example + + + + + + + + + View + Unity Example + + + + + + View + Tutorial Video +
+
+
+std::string name = skCrypt("").decrypt(); // App name - VaultCord.com FREE Discord backup bot for members & your entire server saved from terms and nukes!
+std::string ownerid = skCrypt("").decrypt(); // Account ID
+std::string secret = skCrypt("").decrypt(); // Application secret (not used in latest C++ example)
+std::string version = skCrypt("").decrypt(); // Application version. Used for automatic downloads see video here https://www.youtube.com/watch?v=kW195PLCBKs
+std::string url = skCrypt("https://keyauth.win/api/1.3/").decrypt(); // change if using KeyAuth custom domains feature
+std::string path = skCrypt("").decrypt(); // (OPTIONAL) see tutorial here https://www.youtube.com/watch?v=I9rxt821gMk&t=1s
+
+
+ + + + + + + + + + View + C++ Example + + + + + + View + Tutorial Video +
+
+
+keyauthapp = api(
+    name = "", # App name - VaultCord.com FREE Discord backup bot for members & your entire server saved from terms and nukes!
+    ownerid = "", # Account ID
+    version = "", # Application version. Used for automatic downloads see video here https://www.youtube.com/watch?v=kW195PLCBKs
+    hash_to_check = getchecksum()
+)
+
+ + + + + + + + + + View + Py Example +
+
+
+$name = ""; // App name - VaultCord.com FREE Discord backup bot for members & your entire server saved from terms and nukes!
+$ownerid = ""; // Account ID 
+
+ + + + + + + + + + View + PHP Example +
+
+
+const KeyAuthApp = new KeyAuth(
+    "", // App name - VaultCord.com FREE Discord backup bot for members & your entire server saved from terms and nukes!
+    "", // Account ID
+    "", // Encryption key, keep hidden and and protect this string in your code!
+    "", // Application version. Used for automatic downloads see video here https://www.youtube.com/watch?v=kW195PLCBKs
+);
+
+ + + + + + + + + + View + JS Example +
+
+
+private static String ownerid = "", // Account ID
+private static String appname = "", // App name - VaultCord.com FREE Discord backup bot for members & your entire server saved from terms and nukes!
+private static String version = "" // Application version. Used for automatic downloads see video here https://www.youtube.com/watch?v=kW195PLCBKs
+
+ + + + + + + + + + View + Java Example +
+
+
+Private Shared name As String = "" ' App name - VaultCord.com FREE Discord backup bot for members & your entire server saved from terms and nukes!
+Private Shared ownerid As String = "" ' Account ID
+Private Shared secret As String = "" ' Encryption key, keep hidden and and protect this string in your code!
+Private Shared version As String = "" ' Application version. Used for automatic downloads see video here https://www.youtube.com/watch?v=kW195PLCBKs
+
+ + + + + + + + + + View + VB Example +
+
+
+let mut keyauthapp = keyauth::v1_2::KeyauthApi::new(
+    "", // App name - VaultCord.com FREE Discord backup bot for members & your entire server saved from terms and nukes!
+    "", // Account ID
+    "",  // Encryption key, keep hidden and and protect this string in your code!
+    "", // Application version. Used for automatic downloads see video here https://www.youtube.com/watch?v=kW195PLCBKs
+    "https://keyauth.win/api/1.2/", // This is the API URL, change this to your custom domain if you have it enabled
+);
+
+ + + + + + + + + + View + Rust Example +
+
+
+KeyAuthApp.Api(
+    "", // App name - VaultCord.com FREE Discord backup bot for members & your entire server saved from terms and nukes!
+    "", // Account ID
+    "",  // Encryption key, keep hidden and and protect this string in your code!
+    "", // Application version. Used for automatic downloads see video here https://www.youtube.com/watch?v=kW195PLCBKs
+    "", // Token Path (PUT NULL OR LEAVE BLANK IF YOU DO NOT WANT TO USE THE TOKEN VALIDATION SYSTEM! MUST DISABLE VIA APP SETTINGS)
+)
+
+
+ + + + + + + + + + View + Go Example +
+
+
+local name = ""; -- App name - VaultCord.com FREE Discord backup bot for members & your entire server saved from terms and nukes!
+local ownerid = ""; -- Account ID
+local version = ""; -- Application version. Used for automatic downloads see video here https://www.youtube.com/watch?v=kW195PLCBKs
+
+ + + + + + + + + + View + Lua Example +
+
+
+KeyAuth.new.Api(
+    "", # App name - VaultCord.com FREE Discord backup bot for members & your entire server saved from terms and nukes!
+    "", # Account ID
+    "", # Encryption key, keep hidden and and protect this string in your code!
+    "" # Application version. Used for automatic downloads see video here https://www.youtube.com/watch?v=kW195PLCBKs
+)
+
+ + + + + + + + + + View + Ruby Example +
+
+
+KeyAuth::Api(
+    "", # App name - VaultCord.com FREE Discord backup bot for members & your entire server saved from terms and nukes!
+    "", # Account ID
+    "", # Encryption key, keep hidden and and protect this string in your code!
+    "" # Application version. Used for automatic downloads see video here https://www.youtube.com/watch?v=kW195PLCBKs
+);
+
+ + + + + + + + + + View + Perl Example +
+
+ + +
+ + + + + + + + + + + + + + + + + + + + + +
+
+
+
+ +
+
+ +
+ + + + + + + + + + result)) { + $rows[] = $r; + } + + foreach ($rows as $row) { + $appName = $row['name']; + $paused = $row['paused']; + + + if (isset($_SESSION["name"])) { + $appSelected = ($_SESSION["name"] == $appName); + } else { + $appSelected = 0; + } + ?> + + + + + + + +
Application NameStatusAction
+ + + + + + +
+ +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/pages/reseller-balance.php b/app/pages/reseller-balance.php new file mode 100644 index 0000000..94021a5 --- /dev/null +++ b/app/pages/reseller-balance.php @@ -0,0 +1,268 @@ + + + + + + + +
+
+
+ +

Reseller Balance

+

Check your balance here.

+
+
+
+ result); + + if ($row["sellappsecret"] != NULL) { + + if ($row["sellappdayproduct"] != NULL) { + $dayproduct_holder = ' +

+ Purchase Day Keys (SellApp) +

+
'; + } else { $dayproduct_holder = "N/A"; } + + if ($row["sellappweekproduct"] != NULL) { + $weekproduct_holder = ' +

+ Purchase Week Keys (SellApp) +

+
'; + } else { $weekproduct_holder = "N/A"; } + + if ($row["sellappmonthproduct"] != NULL) { + $monthproduct_holder = ' +

+ Purchase Month Keys (SellApp) +

+
'; + } else { $monthproduct_holder = "N/A"; } + + if ($row["sellapplifetimeproduct"] != NULL) { + $lifetimeproduct_holder = ' +

+ Purchase Lifetime Keys (SellApp) +

+
'; + } else { $lifetimeproduct_holder = "N/A"; } + } + + if ($row["sellixsecret"] != NULL) { + + if ($row["sellixdayproduct"] != NULL) { + $dayproduct_holder = ' +

+ Purchase Day Keys (Sellix) +

+
'; + } else { $dayproduct_holder = "N/A"; } + + if ($row["sellixweekproduct"] != NULL) { + $weekproduct_holder = ' +

+ Purchase Week Keys (Sellix) +

+
'; + } else { $weekproduct_holder = "N/A"; } + + if ($row["sellixmonthproduct"] != NULL) { + $monthproduct_holder = ' +

+ Purchase Month Keys (Sellix) +

+
'; + } else { $monthproduct_holder = "N/A"; } + + if ($row["sellixlifetimeproduct"] != NULL) { + $lifetimeproduct_holder = ' +

+ Purchase Lifetime Keys (Sellix) +

+
'; + } else { $lifetimeproduct_holder = "N/A"; } + } + + if ($row["shoppysecret"] != NULL) { + + if ($row["shoppydayproduct"] != NULL) { + $dayproduct_holder = ' +

+ Purchase Day Keys (Shoppy) +

+
'; + } else { $dayproduct_holder = "N/A"; } + + if ($row["shoppyweekproduct"] != NULL) { + $weekproduct_holder = ' +

+ Purchase Week Keys (Shoppy) +

+
'; + } else { $weekproduct_holder = "N/A"; } + + if ($row["shoppymonthproduct"] != NULL) { + $monthproduct_holder = ' +

+ Purchase Month Keys (Shoppy) +

+
'; + } else { $monthproduct_holder = "N/A"; } + + if ($row["shoppylifetimeproduct"] != NULL) { + $lifetimeproduct_holder = ' +

+ Purchase Lifetime Keys (Shoppy) +

+
'; + } else { $lifetimeproduct_holder = "N/A"; } + } + + + if ($row["resellerstore"] != NULL) { + echo ' + + '; + + } + ?> + result); + + +$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 '

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Duration + + Amount + + Restock +
+ Day + + ' . $day . ' + +

' . $dayproduct_holder . '

+
+ Week + + ' . $week . ' + +

' . $weekproduct_holder . '

+
+ Month + + ' . $month . ' + +

' . $monthproduct_holder . '

+
+ Three Month + + ' . $threemonth . ' + +

N/A

+
+ Six Month + + ' . $sixmonth . ' + +

N/A

+
+ Year + + ' . $year . ' + +

N/A

+
+ Lifetime + + ' . $life . ' + +

' . $lifetimeproduct_holder . '

+
+
+'; + ?> \ No newline at end of file diff --git a/app/pages/reseller-licenses.php b/app/pages/reseller-licenses.php new file mode 100644 index 0000000..af3fccc --- /dev/null +++ b/app/pages/reseller-licenses.php @@ -0,0 +1,430 @@ +result); +$keylevels = $row['keylevels']; + +if (isset($_SESSION['keys_array'])) { + $list = $_SESSION['keys_array']; + $keys = NULL; + for ($i = 0; $i < count($list); $i++) { + $keys .= "" . $list[$i] . "
"; + } + echo "
$keys

"; + echo ""; + unset($_SESSION['keys_array']); +} + if (isset($_POST['genkeys'])) { + $key = misc\license\createLicense($_POST['amount'], $_POST['mask'], 1, $_POST['level'], $_POST['note'], $_POST['expiry']); + switch ($key) { + case 'max_keys': + dashboard\primary\error("You can only generate 100 licenses at a time"); + break; + case 'no_negative': + dashboard\primary\error("Amount can't be negative!"); + break; + case 'unauthed_level': + dashboard\primary\error("Not authorized to make licenses with that level!"); + break; + case 'invalid_exp': + dashboard\primary\error("Invalid expiry!"); + break; + case 'insufficient_balance': + dashboard\primary\error("Not enough balance to create license(s)"); + break; + case 'dupe_custom_key': + dashboard\primary\error("Can't do custom key with amount greater than one"); + break; + default: + if (misc\etc\sanitize($_POST['amount']) > 1) { + $_SESSION['keys_array'] = $key; + echo ""; + } else { + echo ""; + dashboard\primary\success("License Created And Copied To Clipboard!"); + misc\auditLog\send("Created a new license"); + } + break; + } + } + + if (isset($_POST['deletekey'])) { + $userToo = ($_POST['delUserToo'] == "on") ? 1 : 0; + $resp = misc\license\deleteSingular($_POST['deletekey'], $userToo); + switch ($resp) { + case 'failure': + dashboard\primary\error("Failed to delete license!"); + break; + case 'nope': + misc\auditLog\send("Attempted (and failed) to delete license he doesn't own " . $_POST['deletekey']); + dashboard\primary\error("Nope, nice try!"); + break; + case 'success': + misc\auditLog\send("Deleted license key " . $_POST['deletekey']); + dashboard\primary\success("Successfully deleted license!"); + break; + default: + dashboard\primary\error("Unhandled Error! Contact us if you need help"); + break; + } + } + if (isset($_POST['bankey'])) { + $userToo = ($_POST['banUserToo'] == "on") ? 1 : 0; + $resp = misc\license\ban($_POST['bankey'], $_POST['reason'], $userToo); + switch ($resp) { + case 'failure': + dashboard\primary\error("Failed to ban license!"); + break; + case 'nope': + misc\auditLog\send("Attempted (and failed) to ban license he doesn't own " . $_POST['bankey']); + dashboard\primary\error("Nope, nice try!"); + break; + case 'success': + misc\auditLog\send("Banned license key " . $_POST['bankey']); + dashboard\primary\success("Successfully banned license!"); + break; + default: + dashboard\primary\error("Unhandled Error! Contact us if you need help"); + break; + } + } + if (isset($_POST['unbankey'])) { + $resp = misc\license\unban($_POST['unbankey']); + switch ($resp) { + case 'failure': + dashboard\primary\error("Failed to unban license!"); + break; + case 'nope': + misc\auditLog\send("Attempted (and failed) to unban license he doesn't own " . $_POST['unbankey']); + dashboard\primary\error("Nope, nice try!"); + break; + case 'success': + misc\auditLog\send("Unbanned license key " . $_POST['unbankey']); + dashboard\primary\success("Successfully unbanned license!"); + break; + default: + dashboard\primary\error("Unhandled Error! Contact us if you need help"); + break; + } + } + ?> + +
+
+
+ +

Reseller Licenses

+

Manage your licenses here.

+
+
+
+ + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
KeyCreation DateDurationNoteUsed OnUsed ByStatusActions
+
+

Dropdown actions in RED do not show a confirmation! Dropdown actions in BLUE will show a confirmation!

+ \ No newline at end of file diff --git a/app/pages/reseller-users.php b/app/pages/reseller-users.php new file mode 100644 index 0000000..bb41eb3 --- /dev/null +++ b/app/pages/reseller-users.php @@ -0,0 +1,394 @@ +num_rows < 1) { + dashboard\primary\error("User not Found!"); + echo ""; + return; + } + + $row = mysqli_fetch_array($query->result); +?> + + + +result); + $oldHwid = $row["hwid"]; + + $oldHwid = $oldHwid .= $hwid; + + misc\mysql\query("UPDATE `users` SET `hwid` = ? WHERE `username` = ? AND `app` = ? AND `owner` = ?",[$oldHwid, $un, $_SESSION['app'], $_SESSION['username']]); + } + + if (isset($pass) && trim($pass) != '') { + misc\mysql\query("UPDATE `users` SET `password` = ? WHERE `username` = ? AND `app` = ? AND `owner` = ?",[password_hash($pass, PASSWORD_BCRYPT), $un, $_SESSION['app'], $_SESSION['username']]); + } + + dashboard\primary\success("Successfully Updated User"); + misc\auditLog\send("Successfully Updated User $un"); + misc\cache\purge('KeyAuthUser:'.$_SESSION['app'].':'.$un); +} + +if (isset($_POST['deletesub'])) { + $un = misc\etc\sanitize($_POST['deletesub']); + + $query = misc\mysql\query("SELECT * FROM `users` WHERE `username` = ? AND `app` = ? AND `owner` = ?",[$un, $_SESSION['app'], $_SESSION['username']]); + if ($query->num_rows < 1) { + dashboard\primary\error("User not Found!"); + echo ""; + return; + } + + $sub = misc\etc\sanitize($_POST['sub']); + + function get_string_between($string, $start, $end) + { + $string = ' ' . $string; + $ini = strpos($string, $start); + if ($ini < 1) return ''; + $ini += strlen($start); + $len = strpos($string, $end, $ini) - $ini; + return substr($string, $ini, $len); + } + + $sub = get_string_between($sub, '[', ']'); + + $query = misc\mysql\query("DELETE FROM `subs` WHERE `app` = ? AND `user` = ? AND `subscription` = ?",[$_SESSION['app'], $un, $sub]); + if ($query->affected_rows != 0) { + misc\auditLog\send("Deleted the subscription \"{$sub}\" from $un"); + dashboard\primary\success("Successfully Deleted User's Subscription"); + } else { + dashboard\primary\error("Failed To Delete User's Subscription!"); + } +} + +if (isset($_POST['delusers'])) { + $query = misc\mysql\query("DELETE FROM `users` WHERE `app` = ? AND `owner` = ?",[$_SESSION['app'], $_SESSION['username']]); + if ($query->affected_rows != 0) { + misc\auditLog\send("Deleted all users"); + dashboard\primary\success("Users Successfully Deleted!"); + misc\cache\purgePattern('KeyAuthUser:' . $_SESSION['app']); + misc\cache\purge('KeyAuthUsernames:' . $_SESSION['app']); + misc\cache\purge('KeyAuthUsers:' . $_SESSION['app']); + } else { + dashboard\primary\error("Failed To Delete Users!"); + } +} + +if (isset($_POST['resetall'])) { + $query = misc\mysql\query("UPDATE `users` SET `hwid` = '' WHERE `app` = ? AND `owner` = ?",[$_SESSION['app'], $_SESSION['username']]); + if ($query->affected_rows != 0) { + misc\auditLog\send("Reset all users' HWIDs"); + dashboard\primary\success("Users Successfully Reset!"); + misc\cache\purgePattern('KeyAuthUser:' . $_SESSION['app']); + misc\cache\purge('KeyAuthUsernames:' . $_SESSION['app']); + misc\cache\purge('KeyAuthUsers:' . $_SESSION['app']); + } else { + dashboard\primary\error("Failed To Reset Users!"); + } +} +?> + +
+
+
+ +

Reseller Users

+

Manage your users here.

+
+
+
+ + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + +
UsernameHWIDIPCreation DateLast Login DateStatusActions
+
+

Dropdown actions in RED do not show a confirmation! Dropdown actions in BLUE will show a confirmation!

+ + + + + \ No newline at end of file diff --git a/app/pages/seller-logs.php b/app/pages/seller-logs.php new file mode 100644 index 0000000..bf4894e --- /dev/null +++ b/app/pages/seller-logs.php @@ -0,0 +1,103 @@ +affected_rows > 0) { + misc\cache\purge('KeyAuthAppSeller:' . $_SESSION['sellerkey']); + dashboard\primary\success("Successfully enabled seller logs!"); + } + else { + dashboard\primary\success("Failed to enable seller logs."); + } +} + +if (isset($_POST['disableLogs'])) { + $query = misc\mysql\query("UPDATE `apps` SET `sellerLogs` = 0 WHERE `secret` = ?",[$_SESSION['app']]); + if ($query->affected_rows > 0) { + misc\cache\purge('KeyAuthAppSeller:' . $_SESSION['sellerkey']); + dashboard\primary\success("Successfully disabled seller logs!"); + } + else { + dashboard\primary\success("Failed to disable seller logs."); + } +} +?> + +
+
+
+ +

Seller Logs

+

View seller key activity. Learn More.

+
+
+
+
+ result); + $enabled = $row['sellerLogs']; + + if (!$enabled){ + ?> + + + + + +
+ + + +
+ + + + + + + + + + num_rows > 0) { + while ($row = mysqli_fetch_array($query->result)) { + + echo ""; + + echo " "; + + echo " "; + + echo " "; + + echo ""; + } + } + } + ?> + +
IP AddressURLDate
" . $row["ip"] . "". urldecode($row["path"]) . "
+
\ No newline at end of file diff --git a/app/pages/seller-settings.php b/app/pages/seller-settings.php new file mode 100644 index 0000000..662c9a9 --- /dev/null +++ b/app/pages/seller-settings.php @@ -0,0 +1,1685 @@ + 'add-blacklist', + 'type' => 1, + 'description' => 'Add blacklist', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'ip', + 'description' => 'IP Address you want to blacklist', + 'type' => 3, + ], + [ + 'name' => 'hwid', + 'description' => 'Hardware-ID you want to blacklist', + 'type' => 3, + ], + ], + ], + [ + 'name' => 'delete-all-blacklists', + 'type' => 1, + 'description' => 'Delete All Blacklists', + 'default_member_permissions' => 0, + ], + [ + 'name' => 'add-channel', + 'type' => 1, + 'description' => 'Add chat channel', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'name', + 'description' => 'Chat channel name', + 'type' => 3, + 'required' => true, + ], + [ + 'name' => 'delay', + 'description' => 'Chat channel delay (how often user can send messages in seconds)', + 'type' => 3, + 'required' => true, + ], + ], + ], + [ + 'name' => 'delete-channel', + 'type' => 1, + 'description' => 'Delete chat channel', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'name', + 'description' => 'Chat channel name', + 'type' => 3, + 'required' => true, + ], + ], + ], + [ + 'name' => 'edit-channel', + 'type' => 1, + 'description' => 'Edit Channel', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'name', + 'description' => 'The name of the channel you would like to edit.', + 'type' => 3, + 'required' => true, + ], + [ + 'name' => 'delay', + 'description' => 'The delay between messages.', + 'type' => 4, + 'required' => true, + ], + ], + ], + [ + 'name' => 'mute-user', + 'type' => 1, + 'description' => 'Mute user from sending messages in chat channels', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'user', + 'description' => 'The user\'s username', + 'type' => 3, + 'required' => true, + ], + [ + 'name' => 'time', + 'description' => 'Time in seconds user is muted for', + 'type' => 3, + 'required' => true, + ], + ], + ], + [ + 'name' => 'purge-chat', + 'type' => 1, + 'description' => 'Purge chat channel\'s messages', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'name', + 'description' => 'Chat channel name', + 'type' => 3, + 'required' => true, + ], + ], + ], + [ + 'name' => 'set-user-cooldown', + 'type' => 1, + 'description' => 'Set User\'s Cooldown', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'user', + 'description' => 'The username of the user you would like to apply the cooldown for.', + 'type' => 3, + 'required' => true, + ], + [ + 'name' => 'cooldown', + 'description' => 'The duration of the cooldown in seconds. Default 120 seconds.', + 'type' => 4, + 'required' => true, + ], + ], + ], + [ + 'name' => 'unmute-user', + 'type' => 1, + 'description' => 'Unmute user from chat channel', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'user', + 'description' => 'The user\'s username', + 'type' => 3, + 'required' => true, + ], + ], + ], + [ + 'name' => 'delete-file', + 'type' => 1, + 'description' => 'Delete Existing File', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'fileid', + 'description' => 'The file id of the file you would like to delete.', + 'type' => 3, + 'required' => true, + ], + ], + ], + [ + 'name' => 'delete-files', + 'type' => 1, + 'description' => 'Delete All Files', + 'default_member_permissions' => 0, + ], + [ + 'name' => 'upload-file', + 'type' => 1, + 'description' => 'Upload a file', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'url', + 'description' => 'The direct download link of the file you would like to upload.', + 'type' => 3, + 'required' => true, + ], + ], + ], + [ + 'name' => 'add-license', + 'type' => 1, + 'description' => 'Add a license key', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'expiry', + 'description' => 'How many days?', + 'type' => 3, + ], + [ + 'name' => 'level', + 'description' => 'What level?', + 'type' => 3, + ], + [ + 'name' => 'amount', + 'description' => 'What amount?', + 'type' => 3, + ], + [ + 'name' => 'character', + 'description' => '1 = Random, 2 = Uppercase, 3 = Lowercase', + 'type' => 3, + ], + [ + 'name' => 'note', + 'description' => 'Note, Default is "Added by KeyAuth Discord Bot"', + 'type' => 3, + ], + ], + ], + [ + 'name' => 'add-time', + 'type' => 1, + 'description' => 'Add time to unused keys(use extend for used keys aka users)', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'time', + 'description' => 'Number of days', + 'type' => 3, + 'required' => true, + ], + ], + ], + [ + 'name' => 'ban-license', + 'type' => 1, + 'description' => 'Ban license key', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'key', + 'description' => 'Key you wish to ban', + 'type' => 3, + 'required' => true, + ], + [ + 'name' => 'reason', + 'description' => 'Reason for the ban', + 'type' => 3, + 'required' => true, + ], + [ + 'name' => 'usertoo', + 'description' => 'Ban user too?', + 'type' => 5, + ], + ], + ], + [ + 'name' => 'delete-all-licenses', + 'type' => 1, + 'description' => 'Delete All Licenses', + 'default_member_permissions' => 0, + ], + [ + 'name' => 'delete-license', + 'type' => 1, + 'description' => 'Delete a key', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'license', + 'description' => 'Specify key you would like deleted', + 'type' => 3, + 'required' => true, + ], + [ + 'name' => 'usertoo', + 'description' => 'Delete from user too?', + 'type' => 5, + ], + ], + ], + [ + 'name' => 'delete-multiple-licenses', + 'type' => 1, + 'description' => 'Delete multiple licenses', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'licenses', + 'description' => 'Specify key you would like deleted (seperate with comma and space)', + 'type' => 3, + 'required' => true, + ], + [ + 'name' => 'usertoo', + 'description' => 'Delete from user too?', + 'type' => 5, + ], + ], + ], + [ + 'name' => 'delete-unused-licenses', + 'type' => 1, + 'description' => 'Delete Unused Licenses', + 'default_member_permissions' => 0, + ], + [ + 'name' => 'delete-used-licenses', + 'type' => 1, + 'description' => 'Delete Used Licenses', + 'default_member_permissions' => 0, + ], + [ + 'name' => 'license-info', + 'type' => 1, + 'description' => 'Info On key', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'license', + 'description' => 'Specify key', + 'type' => 3, + 'required' => true, + ], + ], + ], + [ + 'name' => 'set-license-note', + 'type' => 1, + 'description' => 'Set a note for a key', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'note', + 'description' => 'Note to set', + 'type' => 3, + 'required' => true, + ], + [ + 'name' => 'license', + 'description' => 'License to set note of', + 'type' => 3, + 'required' => true, + ], + ], + ], + [ + 'name' => 'unban-license', + 'type' => 1, + 'description' => 'Unban license key', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'key', + 'description' => 'Key you wish to unban', + 'type' => 3, + 'required' => true, + ], + ], + ], + [ + 'name' => 'verify-license', + 'type' => 1, + 'description' => 'Verify license exists', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'license', + 'description' => 'License key you would like to check the existence of', + 'type' => 3, + 'required' => true, + ], + ], + ], + [ + 'name' => 'add-reseller-balance', + 'type' => 1, + 'description' => 'Add balance to reseller accounts.', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'username', + 'description' => 'Username of the account', + 'type' => 3, + 'required' => true, + ], + [ + 'name' => 'days', + 'description' => 'Number of days', + 'type' => 3, + 'required' => true, + ], + [ + 'name' => 'weeks', + 'description' => 'Number of weeks', + 'type' => 3, + 'required' => true, + ], + [ + 'name' => 'months', + 'description' => 'Number of months', + 'type' => 3, + 'required' => true, + ], + [ + 'name' => 'threemonths', + 'description' => 'Number of threemonths', + 'type' => 3, + 'required' => true, + ], + [ + 'name' => 'sixmonths', + 'description' => 'Number of sixmonths', + 'type' => 3, + 'required' => true, + ], + [ + 'name' => 'lifetimes', + 'description' => 'Number of lifetimes', + 'type' => 3, + 'required' => true, + ], + ], + ], + [ + 'name' => 'kill-all-sessions', + 'type' => 1, + 'description' => 'Kill All Existing Sessions', + 'default_member_permissions' => 0, + ], + [ + 'name' => 'kill-session', + 'type' => 1, + 'description' => 'End Selected Session', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'sessid', + 'description' => 'The session id you would like to end.', + 'type' => 3, + 'required' => true, + ], + ], + ], + [ + 'name' => 'add-application', + 'type' => 1, + 'description' => 'Add an application / seller key to the database.', + 'default_member_permissions' => 0, + ], + [ + 'name' => 'set-seller', + 'type' => 1, + 'description' => 'Add an application / seller key to the database.', + 'default_member_permissions' => 0, + ], + [ + 'name' => 'del-application', + 'type' => 1, + 'description' => 'Delete an application or seller key from the bot.', + 'default_member_permissions' => 0, + ], + [ + 'name' => 'fetch-application-settings', + 'type' => 1, + 'description' => 'Get Current Settings', + 'default_member_permissions' => 0, + ], + [ + 'name' => 'pause-application', + 'type' => 1, + 'description' => 'Pause Application', + 'default_member_permissions' => 0, + ], + [ + 'name' => 'select-application', + 'type' => 1, + 'description' => 'Select an application / seller key to use.', + 'default_member_permissions' => 0, + ], + [ + 'name' => 'unpause-application', + 'type' => 1, + 'description' => 'Unpause Application', + 'default_member_permissions' => 0, + ], + [ + 'name' => 'add-subscription', + 'type' => 1, + 'description' => 'Add Subscription', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'name', + 'description' => 'Subscription Name?', + 'type' => 3, + 'required' => true, + ], + [ + 'name' => 'level', + 'description' => 'Subscription Level?', + 'type' => 3, + 'required' => true, + ], + ], + ], + [ + 'name' => 'count-subscriptions', + 'type' => 1, + 'description' => 'Retrieve user variable', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'name', + 'description' => 'The subscription name', + 'type' => 3, + 'required' => true, + ], + ], + ], + [ + 'name' => 'delete-application-subscriptions', + 'type' => 1, + 'description' => 'Delete Exisiting Subscription from application', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'name', + 'description' => 'The name of the subscription you would like to delete.', + 'type' => 3, + 'required' => true, + ], + ], + ], + [ + 'name' => 'edit-application-subscriptions', + 'type' => 1, + 'description' => 'Edit Subscription', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'sub', + 'description' => 'The subscription you would like to edit.', + 'type' => 3, + 'required' => true, + ], + [ + 'name' => 'level', + 'description' => 'The new level for the subscription.', + 'type' => 3, + 'required' => true, + ], + ], + ], + [ + 'name' => 'pause-application-subscriptions', + 'type' => 1, + 'description' => 'Pause Subscription(s)', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'subscription', + 'description' => 'Default \'subscription\'', + 'type' => 3, + 'required' => true, + ], + ], + ], + [ + 'name' => 'unpause-subscription', + 'type' => 1, + 'description' => 'Unpause Subscription(s)', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'subscription', + 'description' => 'Default \'subscription\'', + 'type' => 3, + 'required' => true, + ], + ], + ], + [ + 'name' => 'activate', + 'type' => 1, + 'description' => 'Activate License Key', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'username', + 'description' => 'Enter username to register', + 'type' => 3, + 'required' => true, + ], + [ + 'name' => 'license', + 'description' => 'Enter Valid License', + 'type' => 3, + 'required' => true, + ], + [ + 'name' => 'password', + 'description' => 'Enter Password', + 'type' => 3, + 'required' => true, + ], + ], + ], + [ + 'name' => 'add-user', + 'type' => 1, + 'description' => 'Add user to application', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'user', + 'description' => 'Username of user you\'re creating', + 'type' => 3, + 'required' => true, + ], + [ + 'name' => 'sub', + 'description' => 'Name of subscription you want to assign user upon creation', + 'type' => 3, + 'required' => true, + ], + [ + 'name' => 'expires', + 'description' => 'Number in days until subscription assigned upon creation expires', + 'type' => 3, + 'required' => true, + ], + [ + 'name' => 'pass', + 'description' => 'Password for user (optional) if not set, will be set later on login', + 'type' => 3, + ], + ], + ], + [ + 'name' => 'assign-user-variable', + 'type' => 1, + 'description' => 'Assign variable to user(s)', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'name', + 'description' => 'User variable name', + 'type' => 3, + 'required' => true, + ], + [ + 'name' => 'data', + 'description' => 'User variable data', + 'type' => 3, + 'required' => true, + ], + [ + 'name' => 'user', + 'description' => 'User to set variable of. If you leave blank, all users will be assigned user variable', + 'type' => 3, + 'required' => true, + ], + [ + 'name' => 'readonly', + 'description' => 'Whether user var can be changed from program (0 = no, 1 = yes)', + 'type' => 4, + ], + ], + ], + [ + 'name' => 'ban-user', + 'type' => 1, + 'description' => 'Ban user', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'user', + 'description' => 'User you wish to ban', + 'type' => 3, + 'required' => true, + ], + [ + 'name' => 'reason', + 'description' => 'Reason for the ban', + 'type' => 3, + 'required' => true, + ], + ], + ], + [ + 'name' => 'delete-all-users', + 'type' => 1, + 'description' => 'Delete All Users', + 'default_member_permissions' => 0, + ], + [ + 'name' => 'delete-blacklist', + 'type' => 1, + 'description' => 'Delete blacklist', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'data', + 'description' => 'Blacklist data here.', + 'type' => 3, + 'required' => true, + ], + [ + 'name' => 'blacktype', + 'description' => 'IP or HWID.', + 'type' => 3, + 'required' => true, + ], + ], + ], + [ + 'name' => 'delete-expired-users', + 'type' => 1, + 'description' => 'Delete users with no active subscriptions', + 'default_member_permissions' => 0, + ], + [ + 'name' => 'delete-user', + 'type' => 1, + 'description' => 'Delete user', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'username', + 'description' => 'Enter Username', + 'type' => 3, + 'required' => true, + ], + ], + ], + [ + 'name' => 'delete-user-subscription', + 'type' => 1, + 'description' => 'Delete user\'s subscription', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'user', + 'description' => 'Username of user you\'re deleting subscription from', + 'type' => 3, + 'required' => true, + ], + [ + 'name' => 'name', + 'description' => 'Name of subscription you\'re deleting from user', + 'type' => 3, + 'required' => true, + ], + ], + ], + [ + 'name' => 'delete-user-variable', + 'type' => 1, + 'description' => 'Delete user variable', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'user', + 'description' => 'Username of user variable you wish to delete', + 'type' => 3, + 'required' => true, + ], + [ + 'name' => 'name', + 'description' => 'Name of user variable you wish to delete', + 'type' => 3, + 'required' => true, + ], + ], + ], + [ + 'name' => 'edit-email', + 'type' => 1, + 'description' => 'Change User\'s Email Address', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'user', + 'description' => 'The username of the user you would like to change email for.', + 'type' => 3, + 'required' => true, + ], + [ + 'name' => 'email', + 'description' => 'New email address for the user to use in forgot() function', + 'type' => 3, + 'required' => true, + ], + ], + ], + [ + 'name' => 'edit-username', + 'type' => 1, + 'description' => 'Change User\'s Username', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'currentusername', + 'description' => 'The username of the user you would like to change username for.', + 'type' => 3, + 'required' => true, + ], + [ + 'name' => 'newusername', + 'description' => 'Default \'newusername\'', + 'type' => 3, + 'required' => true, + ], + [ + 'name' => 'sessionid', + 'description' => 'Default \'sessionid\'', + 'type' => 3, + 'required' => true, + ], + ], + ], + [ + 'name' => 'extend-users', + 'type' => 1, + 'description' => 'Extend Users', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'username', + 'description' => 'Enter username to extend', + 'type' => 3, + 'required' => true, + ], + [ + 'name' => 'subname', + 'description' => 'Enter Subscription Name', + 'type' => 3, + 'required' => true, + ], + [ + 'name' => 'expiry', + 'description' => 'Enter Days Subscription Should Last', + 'type' => 3, + 'required' => true, + ], + [ + 'name' => 'activeonly', + 'description' => 'Extend only active subscribers with matching subscriptions: 1 for yes, 0 or omit parameter for no.', + 'type' => 4, + 'required' => true, + ], + ], + ], + [ + 'name' => 'get-license-from-user', + 'type' => 1, + 'description' => 'Get License from user', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'username', + 'description' => 'Username where you want the license', + 'type' => 3, + 'required' => true, + ], + ], + ], + [ + 'name' => 'pause-user', + 'type' => 1, + 'description' => 'Pause User', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'user', + 'description' => 'The username of the user you would like to pause.', + 'type' => 3, + 'required' => true, + ], + ], + ], + [ + 'name' => 'reset-all-users', + 'type' => 1, + 'description' => 'Reset All User\'s HWID', + 'default_member_permissions' => 0, + ], + [ + 'name' => 'reset-password', + 'type' => 1, + 'description' => 'Reset password of user', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'user', + 'description' => 'Username of user you\'re resetting password of', + 'type' => 3, + 'required' => true, + ], + [ + 'name' => 'pass', + 'description' => 'Password for user (optional) if not set, will be set later on login - (default = passwd)', + 'type' => 3, + ], + ], + ], + [ + 'name' => 'reset-user', + 'type' => 1, + 'description' => 'Reset a user', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'username', + 'description' => 'Username of the user your are resetting HWID for.', + 'type' => 3, + 'required' => true, + ], + ], + ], + [ + 'name' => 'subtract', + 'type' => 1, + 'description' => 'Subtract From User Subscription', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'user', + 'description' => 'The username of the user you are subtracting time form.', + 'type' => 3, + 'required' => true, + ], + [ + 'name' => 'sub', + 'description' => 'Their subscription name', + 'type' => 3, + 'required' => true, + ], + [ + 'name' => 'seconds', + 'description' => 'Time to subtract from their subscription', + 'type' => 4, + 'required' => true, + ], + ], + ], + [ + 'name' => 'unpause-user', + 'type' => 1, + 'description' => 'Unpause User', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'username', + 'description' => 'The username of the user you would like to unpause.', + 'type' => 3, + 'required' => true, + ], + ], + ], + [ + 'name' => 'unban-user', + 'type' => 1, + 'description' => 'Unban User', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'username', + 'description' => 'The username of the user you would like to unban.', + 'type' => 3, + 'required' => true, + ], + ], + ], + [ + 'name' => 'retrieve-user-data', + 'type' => 1, + 'description' => 'Retrieve info from a user', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'user', + 'description' => 'Specify user to lookup', + 'type' => 3, + 'required' => true, + ], + ], + ], + [ + 'name' => 'verify-user', + 'type' => 1, + 'description' => 'Verify user exists', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'user', + 'description' => 'Username of user you would like to check the existence of', + 'type' => 3, + 'required' => true, + ], + ], + ], + [ + 'name' => 'add-application-hash', + 'type' => 1, + 'description' => 'Add Additional Hash to your Application', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'hash', + 'description' => 'MD5 hash you want to add', + 'type' => 3, + 'required' => true, + ], + ], + ], + [ + 'name' => 'add-hardwareid', + 'type' => 1, + 'description' => 'Add HWID', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'username', + 'description' => 'Enter Username', + 'type' => 3, + 'required' => true, + ], + [ + 'name' => 'hwid', + 'description' => 'Enter Additional HWID', + 'type' => 3, + 'required' => true, + ], + ], + ], + [ + 'name' => 'fetch', + 'type' => 1, + 'description' => 'Fetch * All Things', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'licenses', + 'description' => 'Fetch All Licenses', + 'type' => 1, + ], + [ + 'name' => 'users', + 'description' => 'Fetch All Users', + 'type' => 1, + ], + [ + 'name' => 'user-vars', + 'description' => 'Fetch All User\'s Variables', + 'type' => 1, + ], + [ + 'name' => 'usernames', + 'description' => 'Fetch All Usernames', + 'type' => 1, + ], + [ + 'name' => 'subs', + 'description' => 'Fetch All Subs', + 'type' => 1, + ], + [ + 'name' => 'chats', + 'description' => 'Fetch All Chats', + 'type' => 1, + ], + [ + 'name' => 'sessions', + 'description' => 'Fetch All Sessions', + 'type' => 1, + ], + [ + 'name' => 'files', + 'description' => 'Fetch All Files', + 'type' => 1, + ], + [ + 'name' => 'vars', + 'description' => 'Fetch All Vars', + 'type' => 1, + ], + [ + 'name' => 'blacklists', + 'description' => 'Fetch All Blacklists', + 'type' => 1, + ], + [ + 'name' => 'webhooks', + 'description' => 'Fetch All Webhooks', + 'type' => 1, + ], + [ + 'name' => 'buttons', + 'description' => 'Fetch All Buttons', + 'type' => 1, + ], + [ + 'name' => 'mutes', + 'description' => 'Fetch All Mutes', + 'type' => 1, + ], + [ + 'name' => 'channels', + 'description' => 'Fetch All Channels', + 'type' => 1, + ], + [ + 'name' => 'appdetails', + 'description' => 'Fetch Application Details', + 'type' => 1, + ], + ], + ], + [ + 'name' => 'fetch-application-stats', + 'type' => 1, + 'description' => 'Application Statistics', + 'default_member_permissions' => 0, + ], + [ + 'name' => 'help', + 'type' => 1, + 'description' => 'Help command for bot', + 'default_member_permissions' => 0, + ], + [ + 'name' => 'reset-application-hash', + 'type' => 1, + 'description' => 'Reset app hash', + 'default_member_permissions' => 0, + ], + [ + 'name' => 'add-variable', + 'type' => 1, + 'description' => 'Add application variable', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'name', + 'description' => 'Variable Name?', + 'type' => 3, + 'required' => true, + ], + [ + 'name' => 'value', + 'description' => 'Variable Value?', + 'type' => 3, + 'required' => true, + ], + [ + 'name' => 'authed', + 'description' => 'Determines whether user needs to be logged in (1) or not (0)', + 'type' => 3, + 'required' => true, + ], + ], + ], + [ + 'name' => 'delete-all-variables', + 'type' => 1, + 'description' => 'Delete All Variables', + 'default_member_permissions' => 0, + ], + [ + 'name' => 'delete-variable', + 'type' => 1, + 'description' => 'Delete Variable', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'name', + 'description' => 'The var name you would like to delete.', + 'type' => 3, + 'required' => true, + ], + ], + ], + [ + 'name' => 'edit-variable', + 'type' => 1, + 'description' => 'Edit Variable', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'name', + 'description' => 'Variable Name?', + 'type' => 3, + 'required' => true, + ], + [ + 'name' => 'value', + 'description' => 'Variable Value?', + 'type' => 3, + 'required' => true, + ], + ], + ], + [ + 'name' => 'mass-delete-user-variables', + 'type' => 1, + 'description' => 'Delete All User Variables With Name', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'name', + 'description' => 'The name of the subscription.', + 'type' => 3, + 'required' => true, + ], + ], + ], + [ + 'name' => 'retrieve-user-variable', + 'type' => 1, + 'description' => 'Retrieve user variable', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'user', + 'description' => 'Username of user you want to retrieve user variable from', + 'type' => 3, + 'required' => true, + ], + [ + 'name' => 'name', + 'description' => 'Name of user variable you want to retrieve', + 'type' => 3, + 'required' => true, + ], + ], + ], + [ + 'name' => 'retrieve-variable', + 'type' => 1, + 'description' => 'Retrieve Variable', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'name', + 'description' => 'The var name you would like to retrieve.', + 'type' => 3, + 'required' => true, + ], + ], + ], + [ + 'name' => 'add-webloader-button', + 'type' => 1, + 'description' => 'Create New Web Loader Button', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'value', + 'description' => 'Value of the web loader button', + 'type' => 3, + 'required' => true, + ], + [ + 'name' => 'text', + 'description' => 'The text for the web loader button.', + 'type' => 3, + 'required' => true, + ], + ], + ], + [ + 'name' => 'del-webloader-button', + 'type' => 1, + 'description' => 'Delete Web Loader Button', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'value', + 'description' => 'The value of the web loader button', + 'type' => 3, + ], + ], + ], + [ + 'name' => 'create-webhook', + 'type' => 1, + 'description' => 'Add webhook to application', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'baseurl', + 'description' => 'URL that\'s hidden on keyauth server', + 'type' => 3, + 'required' => true, + ], + [ + 'name' => 'useragent', + 'description' => 'User agent, optional. If not set, it will default to keyauth ', + 'type' => 3, + 'required' => true, + ], + [ + 'name' => 'authed', + 'description' => 'Determines whether user needs to be logged in (1) or not (0)', + 'type' => 3, + 'required' => true, + ], + ], + ], + [ + 'name' => 'delete-all-webhooks', + 'type' => 1, + 'description' => 'Delete All Webhooks', + 'default_member_permissions' => 0, + ], + [ + 'name' => 'add-whitelist', + 'type' => 1, + 'description' => 'Delete Existing Whitelist', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'ip', + 'description' => 'The IP you would like to delete from whitelist.', + 'type' => 3, + 'required' => true, + ], + ], + ], + [ + 'name' => 'delete-whitelist', + 'type' => 1, + 'description' => 'Delete Existing Whitelist', + 'default_member_permissions' => 0, + 'options' => [ + [ + 'name' => 'ip', + 'description' => 'The IP you would like to delete from whitelist.', + 'type' => 3, + 'required' => true, + ], + ], + ], + ]; + + $curl = curl_init($url); + curl_setopt($curl, CURLOPT_URL, $url); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); + + $headers = array( + "Authorization: Bot $botToken", + "user-agent: KeyAuth" + ); + curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); + $resp = curl_exec($curl); + $httpcode = curl_getinfo($curl, CURLINFO_HTTP_CODE); + $json = json_decode($resp); + + if ($httpcode > 399) { + dashboard\primary\error("Discord API error fetching application. Code: $httpcode"); + } else { + $clientId = $json->id; + $pubKey = $json->verify_key; + + $query = misc\mysql\query("INSERT INTO `customBots` (`clientId`, `token`, `pubKey`, `app`) VALUES (?, ?, ?, ?)", [$clientId, $botToken, $pubKey, $_SESSION['app']]); + if ($query->affected_rows > 0) { + $url = "https://discord.com/api/applications/@me"; + + $curl = curl_init($url); + curl_setopt($curl, CURLOPT_URL, $url); + curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PATCH"); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); + curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode(array("interactions_endpoint_url" => "https://keyauth.win/api/discord-interactions"))); + + $headers = array( + "Authorization: Bot $botToken", + "user-agent: KeyAuth", + "Content-Type: application/json" + ); + curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); + + $resp = curl_exec($curl); + $httpcode = curl_getinfo($curl, CURLINFO_HTTP_CODE); + if ($httpcode < 399) { + $url = "https://discord.com/api/applications/$clientId/commands"; + + $curl = curl_init($url); + curl_setopt($curl, CURLOPT_URL, $url); + curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT"); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); + curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($commands)); + + $headers = array( + "Authorization: Bot $botToken", + "user-agent: KeyAuth", + "Content-Type: application/json" + ); + curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); + + $resp = curl_exec($curl); + $httpcode = curl_getinfo($curl, CURLINFO_HTTP_CODE); + } + } else { + dashboard\primary\error("Unable to insert custom bot, please try again."); + } + } +} +?> + +num_rows > 0) { + while ($row = mysqli_fetch_array($query->result)) { + $sellerkey = $row['sellerkey']; + $whitelistedIp = $row['sellerApiWhitelist']; + } + } +?> + +
+
+
+ +

Seller Settings

+

Manage your seller settings here. Learn More.

+ + + + +
+
    + + +
+
+ +
+
+ + +
+
+ + + + + + + + + \ No newline at end of file diff --git a/app/pages/sessions.php b/app/pages/sessions.php new file mode 100644 index 0000000..ebd8c9b --- /dev/null +++ b/app/pages/sessions.php @@ -0,0 +1,102 @@ + dashboard\primary\error("Failed to kill all sessions!"), + 'success' => dashboard\primary\success("Successfully killed all sessions!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; +} +if (isset($_POST['kill'])) { + $resp = misc\session\killSingular($_POST['kill']); + match($resp){ + 'failure' => dashboard\primary\error("Failed to kill session!"), + 'success' => dashboard\primary\success("Successfully killed session!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; +} +?> + +
+
+
+ +

Sessions

+

All of your active sessions. (Active Users) Learn More.

+
+
+
+ + + + + + + + + +
+ + + + + + + + + + + +
IDCredentialsExpiresAuthenticatedIP AddressAction
+
+

Dropdown actions in RED do not show a confirmation! Dropdown actions in BLUE will show a confirmation!

+ \ No newline at end of file diff --git a/app/pages/staff-panel.php b/app/pages/staff-panel.php new file mode 100644 index 0000000..6b3c72b --- /dev/null +++ b/app/pages/staff-panel.php @@ -0,0 +1,146 @@ +num_rows < 1) { + dashboard\primary\error("Order ID not found. Should be from shoppy, sellapp, sellix, or orders.keyauth.cc. NOT PayPal etc. Contact us https://chatting.page/gjqkqirygnfslvce2m5eycuo7tfxrhxl"); + return; + } + $username = mysqli_fetch_array($query->result)['username']; + + $query = misc\mysql\query("SELECT `username` FROM `accounts` WHERE `email` = SHA(?)", [$newEmail]); + if ($query->num_rows < 1) { + $query = misc\mysql\query("UPDATE `accounts` SET `email` = SHA1(?) WHERE `username` = ?", [$newEmail, $username]); + if ($query->affected_rows > 0) { + dashboard\primary\success("Successfully changed email."); + return; + } else { + dashboard\primary\error("Failed to change email. Perhaps the user changed their username after purchasing. Contact us https://chatting.page/gjqkqirygnfslvce2m5eycuo7tfxrhxl"); + return; + } + } else { + dashboard\primary\error("Email already used by username " . mysqli_fetch_array($query->result)['username'] . ""); + return; + } + } + + $query = misc\mysql\query("SELECT 1 FROM `accounts` WHERE `email` = SHA1(?)", [$newEmail]); + if ($query->num_rows > 0) { + dashboard\primary\error("Email already used! You must specify another email"); + return; + } +} +if (isset($_POST['checkExistence'])){ + $username = misc\etc\sanitize($_POST['username']); + + $query = misc\mysql\query("SELECT `username` FROM `accounts` WHERE `username` = ?",[$username]); + if ($query->num_rows > 0){ + dashboard\primary\success("User exists"); + } else{ + dashboard\primary\error("User does not exist!"); + } +} +?> + +
+
+
+ +

Staff Panel

+

Welcome Staff! If you need help, or don't understand something, please + contact an Admin. Thank You!

+
+
+
+ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/pages/subscriptions.php b/app/pages/subscriptions.php new file mode 100644 index 0000000..e9433ee --- /dev/null +++ b/app/pages/subscriptions.php @@ -0,0 +1,369 @@ + dashboard\primary\error("This subscription already exists!"), + 'failure' => dashboard\primary\error("Failed to create subscription!"), + 'success' => dashboard\primary\success("Successfully created subscription!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; + } +} + +if (isset($_POST['deletesub'])) { + $resp = misc\sub\deleteSingular($_POST['deletesub']); + match($resp){ + 'failure' => dashboard\primary\error("Failed to delete subscription"), + 'success' => dashboard\primary\success("Successfully deleted subscription"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; +} + +if (isset($_POST['delallsubs'])){ + $resp = misc\sub\deleteall(); + match($resp){ + 'failure' => dashboard\primary\error("Failed to delete subscriptions!"), + 'success' => dashboard\primary\success("Successfully deleted all subscriptions!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; +} + +if (isset($_POST['pausesub'])){ + $resp = misc\sub\pause($_POST['pausesub']); + match($resp){ + 'failure' => dashboard\primary\error("Failed to pause subscription!"), + 'success' => dashboard\primary\success("Successfully paused subscription!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; +} + +if (isset($_POST['unpausesub'])){ + $resp = misc\sub\unpause($_POST['unpausesub']); + match($resp){ + 'failure' => dashboard\primary\error("Failed to unpause subscription!"), + 'success' => dashboard\primary\success("Successfully unpaused subscription!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; +} + +if (isset($_POST['editsub'])) { + $subscription = misc\etc\sanitize($_POST['editsub']); + $query = misc\mysql\query("SELECT * FROM `subscriptions` WHERE `name` = ? AND `app` = ?", [$subscription, $_SESSION['app']]); + if ($query->num_rows < 1) { + dashboard\primary\error("Subscription not Found!"); + echo ""; + return; + } + $row = mysqli_fetch_array($query->result); + $level = $row["level"]; + echo ' + + '; +} +if (isset($_POST['savesub'])) { + $subscription = misc\etc\sanitize($_POST['subscription']); + $level = misc\etc\sanitize($_POST['level']); + + if (!is_numeric($_POST['level'])) { + dashboard\primary\error("Level must be a number!"); + } else { + misc\mysql\query("UPDATE `subscriptions` SET `level` = ? WHERE `name` = ? AND `app` = ?", [$level, $subscription, $_SESSION['app']]); + if ($_SESSION['role'] == "seller") { + misc\cache\purge('KeyAuthSubscriptions:' . $_SESSION['app']); + } + dashboard\primary\success("Successfully Updated Subscription!"); + echo ""; + } +} + +if (isset($_POST["selected"]) && isset($_POST["action"])) { + $selected = json_decode($_POST["selected"]); + + if ($_POST["action"] == "delete") { + foreach ($selected as $sub) { + $resp = misc\sub\deleteSingular($sub); + match($resp){ + 'failure' => dashboard\primary\error("Failed to delete subscription"), + 'success' => dashboard\primary\success("Successfully deleted subscription"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; + } + } + else if ($_POST["action"] == "pauseMulti") { + foreach ($selected as $value) { + $resp = misc\sub\pause($value); + match($resp){ + 'failure' => dashboard\primary\error("Failed to pause subscriptions!"), + 'success' => dashboard\primary\success("Successfully paused subscriptions!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; + } + } + else if ($_POST["action"] == "unpauseMulti") { + foreach ($selected as $value) { + $resp = misc\sub\unpause($value); + match($resp){ + 'failure' => dashboard\primary\error("Failed to unpause subscriptions!"), + 'success' => dashboard\primary\success("Successfully unpaused subscriptions!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; + } + } + else { + dashboard\primary\error("Invalid action!"); + } +} +?> + +
+
+
+ +

Subscriptions

+

Subscriptions act as levels/tiers. Learn More.

+
+
+
+ + + + +
+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + num_rows > 0){ + while ($row = mysqli_fetch_array($query->result)){ + echo ""; + echo ''; + echo ""; + echo ""; + + echo ' + + + '; + } + } + } + ?> + + +
SelectSubscription NameLicense LevelActions
' . '" . $row["name"] . "" . $row["level"] . "
+
+ +
    +
  • + +
  • +
  • + +
  • +
  • + +
  • +
  • + +
  • +
+
+
+
+

Dropdown actions in RED do not show a confirmation! Dropdown actions in BLUE will show a confirmation!

\ No newline at end of file diff --git a/app/pages/support.php b/app/pages/support.php new file mode 100644 index 0000000..9a5e8e8 --- /dev/null +++ b/app/pages/support.php @@ -0,0 +1,23 @@ + + + + +
+
+
+

+ Support Chat +

+
+
+ Web tickets have been discontinued - Please use the chat box on the bottom right of the website. +
+
+
\ No newline at end of file diff --git a/app/pages/tokens.php b/app/pages/tokens.php new file mode 100644 index 0000000..8584634 --- /dev/null +++ b/app/pages/tokens.php @@ -0,0 +1,43 @@ + + +
+
+
+ +

Tokens

+

Given to users to manage blacklists.

+
+
+
+ + +
+ + + + + + + + + + + + + +
AppTokenAssignedBannedReasonHashTypeStatus
+
\ No newline at end of file diff --git a/app/pages/upgrade.php b/app/pages/upgrade.php new file mode 100644 index 0000000..7ac9d8d --- /dev/null +++ b/app/pages/upgrade.php @@ -0,0 +1,839 @@ +"; + die(); + } + + if ($_SESSION['username'] == "demoseller" || $_SESSION['username'] == "demodeveloper"){ + dashboard\primary\error("You can not upgrade a demo account!"); + echo ""; + die(); + } + + if (str_contains($ua, 'iPhone') || str_contains($ua, 'Mac OS') || str_contains($ua, 'Mobile')){ + dashboard\primary\error("Like Spotify, you can't uprade in the app. We know, it's not ideal."); + echo ""; + die(); + } +?> +KeyAuth - Upgrade + + + +
+
+
+ +

Upgrade

+

Upgrade your account today!

+
+
+ + + + + + + + + + + + +
+
+
+
+ +
+
+
+
+
+
+
+

Tester

+
+
+

+ $ +

+

+ Limited Access for those looking to experiment implementing KeyAuth +

+
+
+
    +
  • + + + + +

    + Users: 10 +

    +
  • +
  • + + + + +

    + Upload Files: (10 MB) +

    +
  • +
  • + + + + +

    + Global Variables: 5 +

    +
  • +
  • + + + + +

    + User Variables +

    +
  • +
  • + + + + +

    + Logs (includes Discord logs): 20 +

    +
  • +
  • + + + + +

    + Hardware/IP Blacklist/Whitelist +

    +
  • +
  • + + + + +

    + Web Loader +

    +
  • +
  • + + + + +

    + Create Webhooks +

    +
  • +
  • + + + + +

    + Reseller & Manager Access +

    +
  • +
  • + + + + +

    + Chatrooms +

    +
  • +
  • + + + + +

    + SellerAPI Access +

    +
  • +
  • + + + + +

    + Discord Bot +

    +
  • +
+ + +

+ This is the default subsription. But you have the + subscription. +

+ +

+ This is the default subsription, and your current one. +

+ +
+
+ +
+
+
+
+

Developer

+
+
+

+ $ +

+

+ Ample limits plus full access to reseller system. Most folks start + here. +

+
+
+
    +
  • + + + + +

    + Users: Unlimited +

    +
  • +
  • + + + + +

    + Upload Files: (50 MB) +

    +
  • +
  • + + + + +

    + Global Variables: Unlimited +

    +
  • +
  • + + + + +

    + User Variables +

    +
  • +
  • + + + + +

    + Logs (includes Discord logs): Unlimited +

    +
  • +
  • + + + + +

    + Hardware/IP Blacklist/Whitelist +

    +
  • +
  • + + + + +

    + Web Loader +

    +
  • +
  • + + + + +

    + Create Webhooks +

    +
  • +
  • + + + + +

    + Reseller & Manager Access +

    +
  • +
  • + + + + +

    + Chatrooms +

    +
  • +
  • + + + + +

    + SellerAPI Access +

    +
  • +
  • + + + + +

    + Discord Bot +

    +
  • +
+ + +

+ You already have this or a higher subscription. +

+ + + + + + +
+
+ +
+
+
+
+

Seller

+
+
+

+ $ +

+

+ Full-fledged supporter, we appreciate you for keeping our servers + running! +

+
+
+
    +
  • + + + + +

    + Users: Unlimited +

    +
  • +
  • + + + + +

    + Upload Files: (75 MB) +

    +
  • +
  • + + + + +

    + Global Variables: Unlimited +

    +
  • +
  • + + + + +

    + User Variables +

    +
  • +
  • + + + + +

    + Logs (includes Discord logs): Unlimited +

    +
  • +
  • + + + + +

    + Hardware/IP Blacklist/Whitelist +

    +
  • +
  • + + + + +

    + Web Loader +

    +
  • +
  • + + + + +

    + Create Webhooks +

    +
  • +
  • + + + + +

    + Reseller & Manager Access +

    +
  • +
  • + + + + +

    + Chatrooms +

    +
  • +
  • + + + + +

    + SellerAPI Access +

    +
  • +
  • + + + + +

    + Discord Bot +

    +
  • +
+ + +

+ You already have this or a higher subscription. +

+ + + + + + +
+
+ +
+
+
+
+

Enterprise (Source + Code)

+
+
+

+ $79.99 / One-Time +

+

+ Opt for large-scale projects at $79.99 one-time cost.
Access + paid KeyAuth + features' source code, one-on-one setup support, and more. +

+
+
+
    +
  • + + + + +

    + Cloud Hosted Subscription (KeyAuth Servers) +

    +
  • +
  • + + + + +

    + Source code of paid KeyAuth features +

    +
  • +
  • + + + + +

    + One-on-one setup support +

    +
  • +
  • + + + + +

    + Tutorial video showing how to host KeyAuth for 100% free +

    +
  • +
+ + + Purchase Enterprise Now + + + + + '; + ?> +
+
+
+
+
+ + + + + + + + + + + + \ No newline at end of file diff --git a/app/pages/user-vars.php b/app/pages/user-vars.php new file mode 100644 index 0000000..a4f5cc6 --- /dev/null +++ b/app/pages/user-vars.php @@ -0,0 +1,312 @@ + 500) { + dashboard\primary\error("Variable data must be 500 characters or less!"); + } + else { + $readOnly = misc\etc\sanitize($_POST['readOnly']) == NULL ? 0 : 1; + $resp = misc\user\setVariable(urldecode($_POST['user']), $_POST['var'], $_POST['data'], null, $readOnly); + match($resp){ + 'missing' => dashboard\primary\error("No users found!"), + 'failure' => dashboard\primary\error("Failed to set variable!"), + 'success' => dashboard\primary\success("Successfully set variable!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; + } +} + +if (isset($_POST['delvars'])) { + $query = misc\mysql\query("DELETE FROM `uservars` WHERE `app` = ?",[$_SESSION['app']]); + if ($query->affected_rows > 0) { + dashboard\primary\success("Successfully deleted all variables"); + } else { + dashboard\primary\error("Failed to delete all variables"); + } +} + +if (isset($_POST['deletevar'])) { + $varId = misc\etc\sanitize($_POST['deletevar']); + + $query = misc\mysql\query("DELETE FROM `uservars` WHERE `app` = ? AND `id` = ?", [$_SESSION['app'], $varId]); + + if ($query->affected_rows > 0) { + dashboard\primary\success("Successfully deleted variable"); + } + else { + dashboard\primary\error("Failed to delete variable"); + } +} + +// edit modal +if (isset($_POST['editvar'])) { + $varId = misc\etc\sanitize($_POST['editvar']); + + $query = misc\mysql\query("SELECT * FROM `uservars` WHERE `id` = ? AND `app` = ?",[$varId, $_SESSION['app']]); + if ($query->num_rows < 1) { + dashboard\primary\error("Variable not Found!"); + echo ""; + return; + } + + $row = mysqli_fetch_array($query->result); + + $data = $row["data"]; + $readOnly = $row["readOnly"]; + + echo ' + + '; +} + +if (isset($_POST['savevar'])) { + + $readOnly = misc\etc\sanitize($_POST['readOnly']) == NULL ? 0 : 1; + $varData = misc\etc\sanitize($_POST['data']); + $varId = misc\etc\sanitize($_POST['savevar']); + + if(strlen($varData) > 500) { + dashboard\primary\error("Variable too long! Must be 500 characters or less"); + echo ""; + return; + } + + misc\mysql\query("UPDATE `uservars` SET `data` = ?, `readOnly` = ? WHERE `id` = ? AND `app` = ?", [$varData, $readOnly, $varId, $_SESSION['app']]); + + if ($query->affected_rows > 0) { + dashboard\primary\success("Successfully edited variable"); + } + else { + dashboard\primary\error("Failed to edit variable"); + } +} +?> + +
+
+
+ +

User Variables

+

Pass, assign, obtain data uniquely for each user. Learn More.

+
+
+ + + + + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + +
Variable NameVariable DataUsernameRead OnlyActions
+
+

Dropdown actions in RED do not show a confirmation! Dropdown actions in BLUE will show a confirmation!

+ + + + diff --git a/app/pages/users.php b/app/pages/users.php new file mode 100644 index 0000000..db67da2 --- /dev/null +++ b/app/pages/users.php @@ -0,0 +1,1210 @@ +result); + $oldHwid = $row["hwid"]; + $oldHwid = $oldHwid .= $hwid; + $query = misc\mysql\query("UPDATE `users` SET `hwid` = ? WHERE `username` = ? AND `app` = ?", [$oldHwid, $un, $_SESSION['app']]); + if ($query->affected_rows) { + dashboard\primary\success("Successfully updated user!"); + misc\cache\purge('KeyAuthUser:' . $_SESSION['app'] . ':' . $un); + misc\cache\purge('KeyAuthUserData:' . $_SESSION['app'] . ':' . $un); + } else { + dashboard\primary\error("Failed to update user!"); + } + } + if (isset($username) && trim($username) != '') { + $resp = misc\user\changeUsername($un, $username, $_SESSION['app']); + 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 (isset($pass) && trim($pass) != '') { + $resp = misc\user\changePassword($un, $pass, $_SESSION['app']); + 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 (isset($email) && trim($email) != '') { + $resp = misc\user\changeEmail($un, $email, $_SESSION['app']); + match($resp){ + 'failure' => dashboard\primary\error("Failed to change email!"), + 'success' => dashboard\primary\success("Successfully changed email!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; + } + /*if (isset($client2fa)){ + $resp = misc\user\disable2fa($un, $_SESSION['app']); + match($resp){ + 'failure' => dashboard\primary\error("Failed to disabled 2fa"), + 'success' => dashboard\primary\success("Successfully disabled 2fa"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; + }*/ +} + +if (isset($_POST['deletevar'])) { + $resp = misc\user\deleteVar(urldecode($_POST['deletevar']), $_POST['var']); + match($resp){ + 'failure' => dashboard\primary\error("Failed to delete variable"), + 'success' => dashboard\primary\success("Successfully deleted variable"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; +} +if (isset($_POST['deletesub'])) { + $sub = misc\etc\sanitize($_POST['sub']); + + $resp = misc\user\deleteSub(urldecode($_POST['deletesub']), $sub); + match($resp){ + 'failure' => dashboard\primary\error("Failed to delete subscription"), + 'success' => dashboard\primary\success("Successfully deleted subscription"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; +} +if (isset($_POST['dlusers'])) { + echo ""; +} +if (isset($_POST['importusersFile'])) { + if ($_FILES['file_input']['error'] === UPLOAD_ERR_OK){ + $fileContent = file_get_contents($_FILES['file_input']['tmp_name']); + $json = json_decode($fileContent); + + if ($json === null){ + dashboard\primary\error("Invalid JSON file. Double check the format you're selecting."); + echo ""; + return; + } + + if (!isset($json->users)){ + dashboard\primary\error("Missing 'users' section in import file."); + echo ""; + return; + } + + if (!isset($json->subscription)){ + dashboard\primary\error("Missing 'subscription' section in import file."); + echo ""; + return; + } + + if (!isset($json->tokens)){ + dashboard\primary\error("Missing 'tokens' section in import file."); + echo ""; + return; + } + + if (isset($json->users) && isset($json->subscription) && isset($json->tokens)){ + foreach ($json->users as $user){ + $username = $user->username; + $email = $user->email; + $password = $user->password; + $hwid = $user->hwid; + $createdate = $user->createdate; + $lastlogin = $user->lastlogin; + $banned = $user->banned; + $ip = $user->ip; + $cooldown = $user->cooldown; + + $users = misc\mysql\query("SELECT * FROM `users` WHERE `app` = ?", [$_SESSION["app"]]); + + $userrows = mysqli_fetch_all($users->result, MYSQLI_ASSOC); + + foreach ($userrows as $user) { + if ($user["username"] === $username) { + dashboard\primary\error("User $username Already Exists"); + return; + } + } + + misc\mysql\query("INSERT INTO `users` (`username`, `email`, `password`, `hwid`, `createdate`, `lastlogin`, `banned`, `ip`, `cooldown`, `app`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", [$username, $email, $password, $hwid, $createdate, $lastlogin, $banned, $ip, $cooldown, $_SESSION['app']]); + } + + foreach ($json->subscription as $sub){ + $username = $sub->user; + $subscription = $sub->subscription; + $expiry = $sub->expiry; + $paused = $sub->paused; + + misc\mysql\query("INSERT INTO `subs` (`user`, `subscription`, `expiry`, `paused`, `app`) VALUES (?, ?, ?, ?, ?)", [$username, $subscription, $expiry, $paused, $_SESSION['app']]); + } + + foreach ($json->tokens as $tokenData){ + $token = $tokenData->token; + $assigned = $tokenData->assigned; + $banned = $tokenData->banned; + $reason = $tokenData->reason; + $hash = $tokenData->hash; + $type = $tokenData->type; + $status = $tokenData->status; + + misc\mysql\query("INSERT INTO `tokens` (`token`, `assigned`, `banned`, `reason`, `hash`, `type`, `status`, `app`) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", [$token, $assigned, $banned, $reason, $hash, $type, $status, $_SESSION['app']]); + } + + dashboard\primary\success("Successfully imported user!"); + } else { + dashboard\primary\error("Invalid JSON file. Double check the format you're selecting."); + } + } else { + dashboard\primary\error("Unhandled Error! Contact support if you need help!"); + } +} +if (isset($_POST['extenduser'])) { + $activeOnly = ($_POST['activeOnly'] == "on") ? 1 : 0; + $expiry = time() + $_POST['time'] * $_POST['expiry']; + $resp = misc\user\extend(urldecode($_POST['user']), $_POST['sub'], $expiry, $activeOnly); + match($resp){ + 'missing' => dashboard\primary\error("User(s) not found!"), + 'sub_missing' => dashboard\primary\error("Subscription not found!"), + 'date_past' => dashboard\primary\error("Subscription expiry must be set in the future!"), + 'failure' => dashboard\primary\error("Failed to extend user(s)"), + 'success' => dashboard\primary\success("Successfully exteneded user(s)!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; +} +if (isset($_POST['subtractuser'])) { + $expiry = $_POST['time'] * $_POST['expiry']; + $resp = misc\user\subtract(urldecode($_POST['user']), $_POST['sub'], $expiry, $secret); + match($resp){ + 'invalid_seconds' => dashboard\primary\error("Seconds specified must be greater than zero"), + 'failure' => dashboard\primary\error("Failed to subtract time from subscription"), + 'success' => dashboard\primary\success("Successfully subtracted time from subscription"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; +} +if (isset($_POST['adduser'])) { + $resp = misc\user\add(urldecode($_POST['username']), $_POST['sub'], strtotime($_POST['expiry']), NULL, $_POST['password']); + match($resp){ + 'already_exist' => dashboard\primary\error("Username already exists!"), + 'sub_missing' => dashboard\primary\error("Subscription not found!"), + 'date_past' => dashboard\primary\error("Subscription expiry must be set in the future!"), + 'username_not_allowed' => dashboard\primary\error("This username is not allowed!"), + 'sub_paused' => dashboard\primary\error("Unable to create user while subscription is paused!"), + 'failure' => dashboard\primary\error("Failed to create user!"), + 'success' => dashboard\primary\success("Successfully created user!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; +} +if (isset($_POST['delexpusers'])) { + $resp = misc\user\deleteExpiredUsers(); + match($resp){ + 'missing' => dashboard\primary\error("You do not have users!"), + 'failure' => dashboard\primary\error("No users are expired!"), + 'success' => dashboard\primary\success("Successfully deleted expired users!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; +} +if (isset($_POST['delusers'])) { + $resp = misc\user\deleteAll(); + match($resp){ + 'failure' => dashboard\primary\error("Failed to delete all users!"), + 'success' => dashboard\primary\success("Successfully deleted all users!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; +} +if (isset($_POST['resetall'])) { + $resp = misc\user\resetAll(); + match($resp){ + 'failure' => dashboard\primary\error("Failed to reset all users!"), + 'success' => dashboard\primary\success("Successfully reset all users!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; +} +if (isset($_POST['unbanall'])) { + $resp = misc\user\unbanAll(); + match($resp){ + 'failure' => dashboard\primary\error("Failed to unban all users!"), + 'success' => dashboard\primary\success("Successfully unbanned all users!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; +} +if (isset($_POST['deleteuser'])) { + $resp = misc\user\deleteSingular(urldecode($_POST['deleteuser'])); + match ($resp){ + 'failure' => dashboard\primary\error("Failed to delete user!"), + 'success' => dashboard\primary\success("Successfully deleted user!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; +} +if (isset($_POST['resetuser'])) { + $resp = misc\user\resetSingular(urldecode($_POST['resetuser'])); + match ($resp){ + 'failure' => dashboard\primary\error("Failed to reset user!"), + 'success' => dashboard\primary\success("Successfully reset user!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; +} +if (isset($_POST['setvar'])) { + if(strlen($_POST['data']) > 500) { + dashboard\primary\error("Variable data must be 500 characters or less!"); + } + else { + $readOnly = misc\etc\sanitize($_POST['readOnly']) == NULL ? 0 : 1; + $resp = misc\user\setVariable(urldecode($_POST['user']), $_POST['var'], $_POST['data'], null, $readOnly); + match($resp){ + 'missing' => dashboard\primary\error("No users found!"), + 'failure' => dashboard\primary\error("Failed to set variable!"), + 'success' => dashboard\primary\success("Successfully set variable!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; + } +} +if (isset($_POST['banuser'])) { + $resp = misc\user\ban(urldecode($_POST['un']), $_POST['reason']); + match($resp){ + 'missing' => dashboard\primary\error("User not found!"), + 'failure' => dashboard\primary\error("Failed to ban user!"), + 'success' => dashboard\primary\success("Successfully banned user!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; +} +if (isset($_POST['unbanuser'])) { + $resp = misc\user\unban(urldecode($_POST['unbanuser'])); + match($resp){ + 'missing' => dashboard\primary\error("User not found!"), + 'failure' => dashboard\primary\error("Failed to unban user!"), + 'success' => dashboard\primary\success("Successfully unbanned user!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; +} +if (isset($_POST['pauseuser'])) { + $resp = misc\user\pauseUser(urldecode($_POST['pauseuser'])); + match($resp){ + 'failure' => dashboard\primary\error("Failed to pause user!"), + 'success' => dashboard\primary\success("Successfully paused user!"), + default => dashboard\primary\error("Unhandled Error! Contact support if you need help") + }; +} +if (isset($_POST['unpauseuser'])) { + $resp = misc\user\unpauseUser(urldecode($_POST['unpauseuser'])); + match($resp){ + 'failure' => dashboard\primary\error("Failed to unpause user!"), + 'success' => dashboard\primary\success("Successfully unpaused user!"), + default => dashboard\primary\error("Unhandled Error! Contact support if you need help") + }; +} + +if (isset($_POST["selected"]) && isset($_POST["action"])) { + $selected = json_decode($_POST["selected"], true); + if ($_POST["action"] == "delete") { + foreach ($selected as $value) { + $resp = misc\user\deleteSingular($value); + match($resp){ + 'failure' => dashboard\primary\error("Failed to delete user!"), + 'success' => dashboard\primary\success("Successfully deleted user!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; + } + } elseif ($_POST["action"] == "unban") { + foreach ($selected as $value) { + $resp = misc\user\unban($value); + match($resp){ + 'missing' => dashboard\primary\error("User not found!"), + 'failure' => dashboard\primary\error("Failed to unban user!"), + 'success' => dashboard\primary\success("Successfully unbanned user!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; + } + } elseif ($_POST["action"] == "pause") { + foreach ($selected as $value) { + $resp = misc\user\pauseUser($value); + match($resp){ + 'failure' => dashboard\primary\error("Failed to pause user!"), + 'success' => dashboard\primary\success("Successfully paused user!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; + } + } elseif ($_POST["action"] == "unpause") { + foreach ($selected as $value) { + $resp = misc\user\unpauseUser($value); + match($resp){ + 'failure' => dashboard\primary\error("Failed to unpause user!"), + 'success' => dashboard\primary\success("Successfully unpaused user!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; + } + } elseif ($_POST["action"] == "resethwid") { + foreach ($selected as $value) { + $resp = misc\user\resetSingular($value); + match($resp){ + 'failure' => dashboard\primary\error("Failed to reset user!"), + 'success' => dashboard\primary\success("Successfully reset user!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; + } + } else { + dashboard\primary\error("Invalid action"); + } +} + +if (isset($_POST['edituser'])) { + $un = misc\etc\sanitize(urldecode($_POST['edituser'])); + $query = misc\mysql\query("SELECT * FROM `users` WHERE `username` = ? AND `app` = ?", [$un, $_SESSION['app']]); + if ($query->num_rows == 0) { + dashboard\primary\error("User not Found!"); + echo ""; + return; + } + $row = mysqli_fetch_array($query->result); +?> + + + + + + +
+
+
+ +

Users

+

After someone registers for your app with a license, they will appear here. + Learn More. +

+
+
+
+
+ + + + User Variables + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
SelectUsernameHWIDIPCreation DateLast Login DateBanned?Actions
+
+

Dropdown actions in RED do not show a confirmation! Dropdown actions in BLUE will show a confirmation!

+ + + + + + + + + + + \ No newline at end of file diff --git a/app/pages/vars.php b/app/pages/vars.php new file mode 100644 index 0000000..d09b731 --- /dev/null +++ b/app/pages/vars.php @@ -0,0 +1,279 @@ + 100) { + dashboard\primary\error("Must upgrade to developer or seller to create variables longer than 100 characters!"); + echo ""; + return; + } + + $query = misc\mysql\query("SELECT count(*) AS 'numVars' FROM `vars` WHERE `app` = ?",[$_SESSION['app']]); + $row = mysqli_fetch_array($query->result); + $numVars = $row["numVars"]; + if($numVars >= 5) { + dashboard\primary\error("Must upgrade to developer or seller to create more than 5 variables!"); + echo ""; + return; + } + } + $authed = misc\etc\sanitize($_POST['authed']) == NULL ? 0 : 1; + $resp = misc\variable\add($_POST['varname'], $_POST['vardata'], $authed); + match($resp){ + 'exists' => dashboard\primary\error("Variable name already exists!"), + 'too_long' => dashboard\primary\error("Variable too long! Must be 1000 characters or less"), + 'failure' => dashboard\primary\error("Failed to create variable"), + 'success' => dashboard\primary\success("Successfully created variable"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; +} + +if (isset($_POST['delvars'])) { + $resp = misc\variable\deleteAll(); + match($resp){ + 'failure' => dashboard\primary\error("Failed to delete all variables"), + 'success' => dashboard\primary\success("Successfully deleted all variables"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; +} + +if (isset($_POST['deletevar'])) { + $resp = misc\variable\deleteSingular($_POST['deletevar']); + match($resp){ + 'failure' => dashboard\primary\error("Failed to delete variable"), + 'success' => dashboard\primary\success("Successfully deleted variable"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; +} + +// edit modal +if (isset($_POST['editvar'])) { + $variable = misc\etc\sanitize($_POST['editvar']); + + $query = misc\mysql\query("SELECT * FROM `vars` WHERE `varid` = ? AND `app` = ?",[$variable, $_SESSION['app']]); + if ($query->num_rows < 1) { + dashboard\primary\error("Variable not Found!"); + echo ""; + return; + } + + $row = mysqli_fetch_array($query->result); + + $data = $row["msg"]; + $authed = $row["authed"]; + + echo ' + + '; +} + +if (isset($_POST['savevar'])) { + $authed = misc\etc\sanitize($_POST['authed']) == NULL ? 0 : 1; + $resp = misc\variable\edit($_POST['variable'], $_POST['msg'], $authed); + switch ($resp) { + case 'success': + misc\cache\purge('KeyAuthVar:' . $_SESSION['app'] . ':' . $_POST['variable']); + dashboard\primary\success("Successfully edited variable!"); + break; + } + match($resp){ + 'failure' => dashboard\primary\error("Failed to edit variable!"), + 'too_long' => dashboard\primary\error("Variable too long! Must be 1000 characters or less"), + 'success' => dashboard\primary\success("Successfully edited variable!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; +} +?> + +
+
+
+ +

Global Variables

+

Pass, assign, obtain data globally. Learn More.

+
+
+ + + + + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + + +
Variable NameVariable DataAuthenticatedActions
+
+

Dropdown actions in RED do not show a confirmation! Dropdown actions in BLUE will show a confirmation!

\ No newline at end of file diff --git a/app/pages/webhooks.php b/app/pages/webhooks.php new file mode 100644 index 0000000..6c48ae6 --- /dev/null +++ b/app/pages/webhooks.php @@ -0,0 +1,407 @@ + dashboard\primary\error("URL isn't a valid URL"), + 'no_local' => dashboard\primary\error("URL can't be a local path! Must be a remote URL accessible by the open internet!"), + 'failure' => dashboard\primary\error("Failed to add webhook!"), + 'success' => dashboard\primary\success("Successfully added webhook!"), + 'empty_webhookname' => dashboard\primary\error("Wehbook name can not be empty!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; + } +} + +if (isset($_POST['deletewebhook'])) { + $resp = misc\webhook\deleteSingular($_POST['deletewebhook']); + match($resp){ + 'failure' => dashboard\primary\error("Failed to delete webhook!"), + 'success' => dashboard\primary\success("Successfully deleted webhook!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; +} + +if (isset($_POST['delallwebhooks'])){ + $resp = misc\webhook\deleteAll(); + match($resp){ + 'failure' => dashboard\primary\error("Failed to delete all webhooks!"), + 'success' => dashboard\primary\success("Successfully deleted all webhooks!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; +} + +if (isset($_POST['editwebhook'])) { + $webhook = misc\etc\sanitize($_POST['editwebhook']); + + $query = misc\mysql\query("SELECT * FROM `webhooks` WHERE `webid` = ? AND `app` = ?",[$webhook, $_SESSION['app']]); + if ($query->num_rows < 1) { + dashboard\primary\error("Webhook not Found!"); + echo ""; + return; + } + + $row = mysqli_fetch_array($query->result); + + $baselink = $row["baselink"]; + $useragent = $row["useragent"]; + + echo ' + + '; +} + +if (isset($_POST['savewebhook'])) { + $webhook = misc\etc\sanitize($_POST['webhook']); + + $baselink = misc\etc\sanitize($_POST['baselink']); + $useragent = misc\etc\sanitize($_POST['useragent']); + + if (!filter_var($baselink, FILTER_VALIDATE_URL)) { + dashboard\primary\error("URL isn't a valid URL"); + echo ""; + return; + } + + if(str_contains($baselink, "localhost") || str_contains($baselink, "127.0.0.1")) { + dashboard\primary\error("URL can't be a local path! Must be a remote URL accessible by the open internet"); + echo ""; + return; + } + + misc\mysql\query("UPDATE `webhooks` SET `baselink` = ?,`useragent` = ? WHERE `webid` = ? AND `app` = ?",[$baselink, $useragent, $webhook, $_SESSION['app']]); + + dashboard\primary\success("Successfully Updated Settings!"); + misc\cache\purge('KeyAuthWebhook:' . $_SESSION['app'] . ':' . $webhook); +} + +if (isset($_POST["selected"]) && isset($_POST["action"])) { + $selected = json_decode($_POST["selected"]); + if ($_POST["action"] == "delete") { + foreach ($selected as $webhook) { + $resp = misc\webhook\deleteSingular($webhook); + match($resp){ + 'failure' => dashboard\primary\error("Failed to delete webhook!"), + 'success' => dashboard\primary\success("Successfully deleted webhook!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; + } + } + else if ($_POST["action"] == "authEnable") { + foreach ($selected as $value) { + $query = misc\mysql\query("UPDATE `webhooks` SET `authed` = 1 WHERE `app` = ? AND `webid` = ?", [$_SESSION['app'], $value]); + + if ($query->affected_rows != 0) { + misc\cache\purge('KeyAuthFile:' . ($secret ?? $_SESSION['app']) . ':' . $fileid); + dashboard\primary\success("Successfully updated webhooks!"); + } else { + dashboard\primary\error("Failed to update webhooks"); + } + } + } + else if ($_POST["action"] == "authDisable") { + foreach ($selected as $value) { + $query = misc\mysql\query("UPDATE `webhooks` SET `authed` = 0 WHERE `app` = ? AND `webid` = ?", [$_SESSION['app'], $value]); + + if ($query->affected_rows != 0) { + misc\cache\purge('KeyAuthFile:' . ($secret ?? $_SESSION['app']) . ':' . $fileid); + dashboard\primary\success("Successfully updated webhooks!"); + } else { + dashboard\primary\error("Failed to update webhooks"); + } + } + } + else { + dashboard\primary\error("Invalid action"); + } +} +?> + +
+
+
+ +

Webhooks

+

Send and receive secure requests. Learn More.

+
+
+
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + num_rows > 0) { + while ($row = mysqli_fetch_array($query->result)) { + + echo ""; + + echo ''; + + echo " "; + + echo " "; + + echo " "; + + echo " "; + + echo ' + + + '; + } + } + } + + ?> + +
SelectIDEndpointUser-AgentAuthenticatedActions
' . '" . $row["webid"] . "" . $row["baselink"] . "" . $row["useragent"] . "" . (($row["authed"] ? 1 : 0) ? 'True' : 'False') . "
+ +
+ +
    +
  • + +
  • +
  • + +
  • +
+
+
+
+

Dropdown actions in RED do not show a confirmation! Dropdown actions in BLUE will show a confirmation!

\ No newline at end of file diff --git a/app/pages/webloader.php b/app/pages/webloader.php new file mode 100644 index 0000000..3ac1986 --- /dev/null +++ b/app/pages/webloader.php @@ -0,0 +1,219 @@ + dashboard\primary\success("Successfully added button!"), + 'failure' => dashboard\primary\error("Failed to add button!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; +} + +if (isset($_POST['delButton'])) { + $resp = misc\button\deleteButton($_POST['delButton']); + match($resp){ + 'success' => dashboard\primary\success("Successfully deleted button!"), + 'failure' => dashboard\primary\error("Failed to delete button!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; +} + +if (isset($_POST["selected"]) && isset($_POST["action"])) { + $selected = json_decode($_POST["selected"]); + + if ($_POST["action"] == "delete"){ + foreach ($selected as $buttons){ + $resp = misc\button\deleteButton($buttons); + match($resp){ + 'success' => dashboard\primary\success("Successfully deleted button!"), + 'failure' => dashboard\primary\error("Failed to delete button!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; + } + } else { + dashboard\primary\error("Invalid action!"); + } +} +?> +
+
+
+ +

Web Loader

+
+
+
+ + +
+ + + + + + + + + + + + + + + + +
+ + + + + + + + + + + num_rows > 0) { + while ($row = mysqli_fetch_array($query->result)) { + + echo ""; + + echo ''; + + echo " "; + + echo " "; + + echo ' + '; + } + } + } + + ?> + +
SelectButton TextButton ValueActions
' . '" . $row["text"] . "" . $row["value"] . "
+
+ +
    +
  • + +
  • +
+
+
+
+

Dropdown actions in RED do not show a confirmation! Dropdown actions in BLUE will show a confirmation!

diff --git a/app/pages/whitelists.php b/app/pages/whitelists.php new file mode 100644 index 0000000..f4ca4a4 --- /dev/null +++ b/app/pages/whitelists.php @@ -0,0 +1,144 @@ + dashboard\primary\error("Failed to add whitelist"), + 'success' => dashboard\primary\success("Successfully added whitelist"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; +} +if (isset($_POST['deletewhite'])){ + $resp = misc\whitelist\deleteWhite($_POST['deletewhite']); + match($resp){ + 'failure' => dashboard\primary\error("Failed to delete whitelist"), + 'success' => dashboard\primary\success("Successfully deleted whitelist"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; +} +if (isset($_POST['delallwhites'])) { + $resp = misc\whitelist\deleteAll(); + match($resp){ + 'failure' => dashboard\primary\error("Failed to delete all whitelists!"), + 'success' => dashboard\primary\success("Successfully deleted all whitelists!"), + default => dashboard\primary\error("Unhandled Error! Contact us if you need help") + }; +} +?> + +
+
+
+ +

Whitelists

+

Allow access from certain IPs Learn More.

+
+
+
+ + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + +
IPActions
+
+

Dropdown actions in RED do not show a confirmation! Dropdown actions in BLUE will show a confirmation!

+ \ No newline at end of file diff --git a/app/reseller-license-fetch.php b/app/reseller-license-fetch.php new file mode 100644 index 0000000..7ea424c --- /dev/null +++ b/app/reseller-license-fetch.php @@ -0,0 +1,127 @@ +getMessage()); + die("Error: " . $errorMsg); +}); + +if (session_status() === PHP_SESSION_NONE) { + session_start(); +} + +if (!isset($_SESSION['app'])) { + dashboard\primary\error("Application not selected"); + die("Application not selected."); +} + +if (isset($_POST['draw'])) { + + // credits to https://makitweb.com/datatables-ajax-pagination-with-search-and-sort-php/ + + $draw = intval($_POST['draw']); + $row = intval($_POST['start']); + $rowperpage = intval($_POST['length']); // Rows display per page + $columnIndex = misc\etc\sanitize($_POST['order'][0]['column']); // Column index + $columnName = misc\etc\sanitize($_POST['columns'][$columnIndex]['data']); // Column name + $columnSortOrder = misc\etc\sanitize($_POST['order'][0]['dir']); // asc or desc + $searchValue = misc\etc\sanitize($_POST['search']['value']); // Search value + + ## Total number of records without filtering + $sel = misc\mysql\query("select count(1) as allcount from `keys` where app = ? and genby = ?", [$_SESSION['app'], $_SESSION['username']]); + $records = mysqli_fetch_assoc($sel->result); + $totalRecords = $records['allcount']; + + $totalRecordwithFilter = $totalRecords; + if (!is_null($searchValue)) { // don't double query if no search value was provided + ## Total number of record with filtering + $sel = misc\mysql\query("select count(1) as allcount from `keys` WHERE 1 and (`key` like ? or `note` like ? or `usedby` like ? ) and app = ? and genby = ?", ["%" . $searchValue . "%", "%" . $searchValue . "%", "%" . $searchValue . "%", $_SESSION['app'], $_SESSION['username']]); + $records = mysqli_fetch_assoc($sel->result); + $totalRecordwithFilter = $records['allcount']; + } + + // whitelist certain column names and sort orders to prevent SQL injection + if (!in_array($columnName, array("key", "gendate", "expires", "note", "usedon", "usedby", "status"))) { + die("Column name is not whitelisted."); + } + + if (!in_array($columnSortOrder, array("desc", "asc"))) { + die("Column sort order is not whitelisted."); + } + + if (!is_null($searchValue)) { + $query = misc\mysql\query("select * from `keys` WHERE (`key` like ? or `note` like ? or `usedby` like ? ) and app = ? and genby = ? order by `" . $columnName . "` " . $columnSortOrder . " limit " . $row . "," . $rowperpage, ["%" . $searchValue . "%", "%" . $searchValue . "%", "%" . $searchValue . "%", $_SESSION['app'], $_SESSION['username']]); + } + else { + $query = misc\mysql\query("select * from `keys` WHERE app = ? and genby = ? order by `" . $columnName . "` " . $columnSortOrder . " limit " . $row . "," . $rowperpage, [$_SESSION['app'], $_SESSION['username']]); + } + + $data = array(); + + while ($row = mysqli_fetch_assoc($query->result)) { + $data[] = array( + "key" => $row['key'], + "gendate" => '
', + "expires" => ($row["expires"] / 86400) . ' Day(s)', + "note" => $row['note'] ?? 'N/A', + "usedon" => (!is_null($row["usedon"])) ? '
' : 'N/A', + "usedby" => ($row["usedby"] == $row['key']) ? 'Same as key' : $row["usedby"] ?? 'N/A', + "status" => '', + "actions" => ' +
+ +
+ +
    +
  • + +
  • +
  • + +
  • +
  • + +
  • +
+
+ + + + +
', + ); + } + + ## Response + $response = array( + "draw" => intval($draw), + "iTotalRecords" => $totalRecords, + "iTotalDisplayRecords" => $totalRecordwithFilter, + "aaData" => $data + ); + + die(json_encode($response)); +} + +die("Request not from datatables, aborted."); diff --git a/app/reseller-user-fetch.php b/app/reseller-user-fetch.php new file mode 100644 index 0000000..9fee0a4 --- /dev/null +++ b/app/reseller-user-fetch.php @@ -0,0 +1,143 @@ +getMessage()); + die("Error: " . $errorMsg); +}); + +if (session_status() === PHP_SESSION_NONE) { + session_start(); +} + +if (!isset($_SESSION['app'])) { + dashboard\primary\error("Application not selected"); + die("Application not selected."); +} + +if (isset($_POST['draw'])) { + + // credits to https://makitweb.com/datatables-ajax-pagination-with-search-and-sort-php/ + + $draw = intval($_POST['draw']); + $row = intval($_POST['start']); + $rowperpage = intval($_POST['length']); // Rows display per page + $columnIndex = misc\etc\sanitize($_POST['order'][0]['column']); // Column index + $columnName = misc\etc\sanitize($_POST['columns'][$columnIndex]['data']); // Column name + $columnSortOrder = misc\etc\sanitize($_POST['order'][0]['dir']); // asc or desc + $searchValue = misc\etc\sanitize($_POST['search']['value']); // Search value + + ## Total number of records without filtering + $sel = misc\mysql\query("select count(1) as allcount from `users` where app = ? and owner = ?", [$_SESSION['app'], $_SESSION['username']]); + $records = mysqli_fetch_assoc($sel->result); + $totalRecords = $records['allcount']; + + $totalRecordwithFilter = $totalRecords; + if (!is_null($searchValue)) { // don't double query if no search value was provided + ## Total number of record with filtering + $sel = misc\mysql\query("select count(1) as allcount from `users` WHERE 1 and (`username` like ? or `hwid` like ? or `ip` like ? or `banned` like ? ) and app = ? and owner = ?", ["%" . $searchValue . "%", "%" . $searchValue . "%", "%" . $searchValue . "%", "%" . $searchValue . "%", $_SESSION['app'], $_SESSION['username']]); + $records = mysqli_fetch_assoc($sel->result); + $totalRecordwithFilter = $records['allcount']; + } + + // whitelist certain column names and sort orders to prevent SQL injection + if (!in_array($columnName, array("username", "hwid", "ip", "createdate", "lastlogin", "banned"))) { + die("Column name is not whitelisted."); + } + + if (!in_array($columnSortOrder, array("desc", "asc"))) { + die("Column sort order is not whitelisted."); + } + + if (!is_null($searchValue)) { + $query = misc\mysql\query("select * from `users` WHERE (`username` like ? or `hwid` like ? or `ip` like ? or `banned` like ? ) and app = ? and owner = ? order by `" . $columnName . "` " . $columnSortOrder . " limit " . $row . "," . $rowperpage, ["%" . $searchValue . "%", "%" . $searchValue . "%", "%" . $searchValue . "%", "%" . $searchValue . "%", $_SESSION['app'], $_SESSION['username']]); + } + else { + $query = misc\mysql\query("select * from `users` WHERE app = ? and owner = ? order by `" . $columnName . "` " . $columnSortOrder . " limit " . $row . "," . $rowperpage, [$_SESSION['app'], $_SESSION['username']]); + } + + $data = array(); + + while ($row = mysqli_fetch_assoc($query->result)) { + + ## Add Extra Margin to buttons if value is 1 or 2, because datatables with ajax breaks it. + $MarginManager = ""; + if ($query->num_rows < 2) { + $MarginManager = "margin-bottom: 80;"; + } else { + $MarginManager = "margin-bottom: 0px;"; + } + + $data[] = array( + "username" => $row['username'], + "hwid" => $_SESSION['role'] == "Reseller" ? "REDACTED" : '' . ($row['hwid'] ?? 'N/A') . '', + "ip" => $_SESSION['role'] == "Reseller" ? "REDACTED" : '' . ($row['ip'] ?? 'N/A') . '', + "createdate" => '
', + "lastlogin" => '
', + "banned" => $row['banned'] ?? 'N/A', + "actions" => ' +
+ +
+ +
    +
  • + +
  • +
  • + +
  • +
  • + +
  • +
  • + +
  • +
+
+ + + + + + +
', + ); + } + + ## Response + $response = array( + "draw" => intval($draw), + "iTotalRecords" => $totalRecords, + "iTotalDisplayRecords" => $totalRecordwithFilter, + "aaData" => $data + ); + + die(json_encode($response)); +} + +die("Request not from datatables, aborted."); diff --git a/app/session-fetch.php b/app/session-fetch.php new file mode 100644 index 0000000..40966ba --- /dev/null +++ b/app/session-fetch.php @@ -0,0 +1,118 @@ +getMessage()); + die("Error: " . $errorMsg); +}); + +if (session_status() === PHP_SESSION_NONE) { + session_start(); +} + +if ($_SESSION['role'] == "Reseller") { + die("Resellers can't access this."); +} + +if (!isset($_SESSION['app'])) { + dashboard\primary\error("Application not selected"); + die("Application not selected."); +} + +if (isset($_POST['draw'])) { + + // credits to https://makitweb.com/datatables-ajax-pagination-with-search-and-sort-php/ + + $draw = intval($_POST['draw']); + $row = intval($_POST['start']); + $rowperpage = intval($_POST['length']); // Rows display per page + $columnIndex = misc\etc\sanitize($_POST['order'][0]['column']); // Column index + $columnName = misc\etc\sanitize($_POST['columns'][$columnIndex]['data']); // Column name + $columnSortOrder = misc\etc\sanitize($_POST['order'][0]['dir']); // asc or desc + $searchValue = misc\etc\sanitize($_POST['search']['value']); // Search value + + ## Total number of records without filtering + $sel = misc\mysql\query("select count(1) as allcount from `sessions` where app = ?", [$_SESSION['app']]); + $records = mysqli_fetch_assoc($sel->result); + $totalRecords = $records['allcount']; + + $totalRecordwithFilter = $totalRecords; + if (!is_null($searchValue)) { // don't double query if no search value was provided + ## Total number of record with filtering + $sel = misc\mysql\query("select count(1) as allcount from `sessions` WHERE 1 and (`id` like ? or `credential` like ? or `ip` like ? ) and app = ?", ["%" . $searchValue . "%", "%" . $searchValue . "%", "%" . $searchValue . "%", $_SESSION['app']]); + $records = mysqli_fetch_assoc($sel->result); + $totalRecordwithFilter = $records['allcount']; + } + + // whitelist certain column names and sort orders to prevent SQL injection + if (!in_array($columnName, array("id", "credential", "expiry", "validated", "ip"))) { + die("Column name is not whitelisted."); + } + + if (!in_array($columnSortOrder, array("desc", "asc"))) { + die("Column sort order is not whitelisted."); + } + + if (!is_null($searchValue)) { + $query = misc\mysql\query("select * from `sessions` WHERE (`id` like ? or `credential` like ? or `ip` like ? ) and app = ? order by `" . $columnName . "` " . $columnSortOrder . " limit " . $row . "," . $rowperpage, ["%" . $searchValue . "%", "%" . $searchValue . "%", "%" . $searchValue . "%", $_SESSION['app']]); + } + else { + $query = misc\mysql\query("select * from `sessions` WHERE app = ? order by `" . $columnName . "` " . $columnSortOrder . " limit " . $row . "," . $rowperpage, [$_SESSION['app']]); + } + + $data = array(); + + while ($row = mysqli_fetch_assoc($query->result)) { + $data[] = array( + "id" => $row['id'], + "credential" => $row["credential"] ?? 'N/A', + "expiry" => '
', + "validated" => ($row['validated'] ? 1 : 0) ? 'true' : 'false', + "ip" => ($_SESSION['role'] == "Manager") ? 'REDACTED' : '' . ($row['ip'] ?? 'N/A') . '', + "actions" => + '
+ + + +
+ +
    +
  • + +
  • +
+
+ + + +
', + ); + } + + ## Response + $response = array( + "draw" => intval($draw), + "iTotalRecords" => $totalRecords, + "iTotalDisplayRecords" => $totalRecordwithFilter, + "aaData" => $data + ); + + die(json_encode($response)); +} + +die("Request not from datatables, aborted."); \ No newline at end of file diff --git a/app/token-fetch.php b/app/token-fetch.php new file mode 100644 index 0000000..72decb1 --- /dev/null +++ b/app/token-fetch.php @@ -0,0 +1,119 @@ +getMessage()); + die("Error: " . $errorMsg); +}); + +if (session_status() === PHP_SESSION_NONE) { + session_start(); +} + +if ($_SESSION['role'] == "Reseller") { + die("Resellers can't access this."); +} + +if ($_SESSION['role'] == "Manager") { + die("Managers can't access this."); +} + +if (!isset($_SESSION['app'])) { + dashboard\primary\error("Application not selected"); + die("Application not selected."); +} + +if (isset($_POST['draw'])) { + + // credits to https://makitweb.com/datatables-ajax-pagination-with-search-and-sort-php/ + + $draw = intval($_POST['draw']); + $row = intval($_POST['start']); + $rowperpage = intval($_POST['length']); // Rows display per page + $columnIndex = misc\etc\sanitize($_POST['order'][0]['column']); // Column index + $columnName = misc\etc\sanitize($_POST['columns'][$columnIndex]['data']); // Column name + $columnSortOrder = misc\etc\sanitize($_POST['order'][0]['dir']); // asc or desc + $searchValue = misc\etc\sanitize($_POST['search']['value']); // Search value + + ## Total number of records without filtering + $sel = misc\mysql\query("SELECT count(1) AS allcount FROM `tokens` WHERE app = ?", [$_SESSION['app']]); + $records = mysqli_fetch_assoc($sel->result); + $totalRecords = $records['allcount']; + + $totalRecordwithFilter = $totalRecords; + if (!is_null($searchValue)) { // don't double query if no search value was provided + ## Total number of record with filtering + $sel = misc\mysql\query("SELECT count(1) AS allcount FROM `tokens` WHERE 1 AND (`token` LIKE ? OR `assigned` LIKE ? OR `status` LIKE ? OR `reason` LIKE ? ) AND app = ?", ["%" . $searchValue . "%", "%" . $searchValue . "%", "%" . $searchValue . "%", "%" . $searchValue . "%", $_SESSION['app']]); + $records = mysqli_fetch_assoc($sel->result); + $totalRecordwithFilter = $records['allcount']; + } + + // whitelist certain column names and sort orders to prevent SQL injection + if (!in_array($columnName, array("app", "token", "assigned", "banned", "reason", "hash", "type", "status"))) { + die("Column name is not whitelisted."); + } + + if (!in_array($columnSortOrder, array("desc", "asc"))) { + die("Column sort order is not whitelisted."); + } + + ## Fetch records + if (!is_null($searchValue)){ + $query = misc\mysql\query("SELECT * FROM `tokens` WHERE (`token` LIKE ? OR `assigned` LIKE ? OR `status` LIKE ? or `reason` LIKE ?) AND `app` = ? order by `" . $columnName . "` " . $columnSortOrder . " limit " . $row . "," . $rowperpage, ["%" . $searchValue . "%", "%" . $searchValue . "%", "%" . $searchValue . "%", $_SESSION['app']]); + } else { + $query = misc\mysql\query("SELECT * FROM `tokens` WHERE `app` = ? order by `" . $columnName . "` " . $columnSortOrder . " limit " . $row . "," . $rowperpage, [$_SESSION['app']]); + } + + $data = array(); + + while ($row = mysqli_fetch_assoc($query->result)) { + + ## If only one or two keys exists then we will use custom margin to fix the bugging menu + $banBtns = ""; + if ($row['banned']) { + $banBtns = ''; + } else { + $banBtns = 'Ban'; + } + + $MarginManager = ""; + if ($totalRecordwithFilter < 2) { + $MarginManager = "margin-bottom: 20px;"; + } else { + $MarginManager = "margin-bottom: 0px;"; + } + + $data[] = array( + "app" => $_SESSION['name'], + "token" => $row['token'], + "assigned" => $row['assigned'] ?? "N\A", + "banned" => '', + "reason" => is_null($row['reason']) ? 'N/A' : $row['reason'], + "hash" => is_null($row['hash']) ? 'N/A' : $row['reason'], + "type" => $row['type'], + "status" => $row['status'], + ); + } + + ## Response + $response = array( + "draw" => intval($draw), + "iTotalRecords" => $totalRecords, + "iTotalDisplayRecords" => $totalRecordwithFilter, + "aaData" => $data + ); + die(json_encode($response)); +} + +die("Request not from datatables, aborted."); + + +?> \ No newline at end of file diff --git a/app/user-fetch.php b/app/user-fetch.php new file mode 100644 index 0000000..62cdf92 --- /dev/null +++ b/app/user-fetch.php @@ -0,0 +1,177 @@ +getMessage()); + die("Error: " . $errorMsg); +}); + +if (session_status() === PHP_SESSION_NONE) { + session_start(); +} + +if ($_SESSION['role'] == "Reseller") { + die("Resellers can't access this."); +} + +if (!isset($_SESSION['app'])) { + dashboard\primary\error("Application not selected"); + die("Application not selected."); +} + +if (isset($_POST['draw'])) { + + // credits to https://makitweb.com/datatables-ajax-pagination-with-search-and-sort-php/ + + $draw = intval($_POST['draw']); + $row = intval($_POST['start']); + $rowperpage = intval($_POST['length']); // Rows display per page + $columnIndex = misc\etc\sanitize($_POST['order'][0]['column']); // Column index + $columnName = misc\etc\sanitize($_POST['columns'][$columnIndex]['data']); // Column name + $columnSortOrder = misc\etc\sanitize($_POST['order'][0]['dir']); // asc or desc + $searchValue = misc\etc\sanitize($_POST['search']['value']); // Search value + + ## Total number of records without filtering + $sel = misc\mysql\query("select count(1) as allcount from `sessions` where app = ?", [$_SESSION['app']]); + $records = mysqli_fetch_assoc($sel->result); + $totalRecords = $records['allcount']; + + $totalRecordwithFilter = $totalRecords; + if (!is_null($searchValue)) { // don't double query if no search value was provided + ## Total number of record with filtering + $sel = misc\mysql\query("select count(1) as allcount from `sessions` WHERE 1 and (`id` like ? or `credential` like ? or `ip` like ? ) and app = ?", ["%" . $searchValue . "%", "%" . $searchValue . "%", "%" . $searchValue . "%", $_SESSION['app']]); + $records = mysqli_fetch_assoc($sel->result); + $totalRecordwithFilter = $records['allcount']; + } + + ## Total number of records without filtering + $sel = misc\mysql\query("select count(1) as allcount from `users` where app = ?", [$_SESSION['app']]); + $records = mysqli_fetch_assoc($sel->result); + $totalRecords = $records['allcount']; + + $totalRecordwithFilter = $totalRecords; + if (!is_null($searchValue)) { // don't double query if no search value was provided + ## Total number of record with filtering + $sel = misc\mysql\query("select count(1) as allcount from `users` WHERE 1 and (`username` like ? or `hwid` like ? or `ip` like ? or `banned` like ? ) and app = ?", ["%" . $searchValue . "%", "%" . $searchValue . "%", "%" . $searchValue . "%", "%" . $searchValue . "%", $_SESSION['app']]); + $records = mysqli_fetch_assoc($sel->result); + $totalRecordwithFilter = $records['allcount']; + } + + // whitelist certain column names and sort orders to prevent SQL injection + if (!in_array($columnName, array("username", "hwid", "ip", "createdate", "lastlogin", "banned"))) { + die("Column name is not whitelisted."); + } + + if (!in_array($columnSortOrder, array("desc", "asc"))) { + die("Column sort order is not whitelisted."); + } + + if (!is_null($searchValue)) { + $query = misc\mysql\query("select * from `users` WHERE (`username` like ? or `hwid` like ? or `ip` like ? or `banned` like ? ) and app = ? order by `" . $columnName . "` " . $columnSortOrder . " limit " . $row . "," . $rowperpage, ["%" . $searchValue . "%", "%" . $searchValue . "%", "%" . $searchValue . "%", "%" . $searchValue . "%", $_SESSION['app']]); + } + else { + $query = misc\mysql\query("select * from `users` WHERE app = ? order by `" . $columnName . "` " . $columnSortOrder . " limit " . $row . "," . $rowperpage, [$_SESSION['app']]); + } + + $data = array(); + + while ($row = mysqli_fetch_assoc($query->result)) { + + ## If User is banned show only unban and if not show only ban. + $banBtns = ""; + if ($row['banned'] ? true : false) { + $banned = $row['banned']; + $banBtns = ''; + } else { + $banned = "N/A"; + $banBtns = ''; + + } + + ## Add Extra Margin to buttons if value is 1 or 2, because datatables with ajax breaks it. + $MarginManager = ""; + if ($query->num_rows < 2) { + $MarginManager = "margin-bottom: 120px;"; + } else { + $MarginManager = "margin-bottom: 0px;"; + } + + $data[] = array( + "checkbox" => '', + "username" => $row['username'], + "hwid" => ($_SESSION['role'] == "Manager" || $_SESSION['role'] == "Reseller") ? 'REDACTED' : '' . ($row['hwid'] ?? 'N/A') . '', + "ip" => ($_SESSION['role'] == "Manager" || $_SESSION['role'] == "Reseller") ? 'REDACTED' : '' . ($row['ip'] ?? 'N/A') . '', + "createdate" => '
', + "lastlogin" => '
', + "banned" => $banned, + "actions" => '
+ + +
+ +
    +
  • + +
  • +
  • + +
  • +
  • + ' . $banBtns . ' +
  • +
  • + +
  • +
  • + +
  • +
  • + +
  • +
+
+ + +
' + ); + } + + ## Response + $response = array( + "draw" => $draw, + "iTotalRecords" => $totalRecords, + "iTotalDisplayRecords" => $totalRecordwithFilter, + "aaData" => $data + ); + + die(json_encode($response)); +} + +die("Request not from datatables, aborted."); \ No newline at end of file diff --git a/app/user-var-fetch.php b/app/user-var-fetch.php new file mode 100644 index 0000000..b8fe4f5 --- /dev/null +++ b/app/user-var-fetch.php @@ -0,0 +1,120 @@ +getMessage()); + die("Error: " . $errorMsg); +}); + +if (session_status() === PHP_SESSION_NONE) { + session_start(); +} + +if ($_SESSION['role'] == "Reseller") { + die("Resellers can't access this."); +} + +if (!isset($_SESSION['app'])) { + dashboard\primary\error("Application not selected"); + die("Application not selected."); +} + +if (isset($_POST['draw'])) { + + // credits to https://makitweb.com/datatables-ajax-pagination-with-search-and-sort-php/ + + $draw = intval($_POST['draw']); + $row = intval($_POST['start']); + $rowperpage = intval($_POST['length']); // Rows display per page + $columnIndex = misc\etc\sanitize($_POST['order'][0]['column']); // Column index + $columnName = misc\etc\sanitize($_POST['columns'][$columnIndex]['data']); // Column name + $columnSortOrder = misc\etc\sanitize($_POST['order'][0]['dir']); // asc or desc + $searchValue = misc\etc\sanitize($_POST['search']['value']); // Search value + + ## Total number of records without filtering + $sel = misc\mysql\query("select count(1) as allcount from `uservars` where app = ?", [$_SESSION['app']]); + $records = mysqli_fetch_assoc($sel->result); + $totalRecords = $records['allcount']; + + $totalRecordwithFilter = $totalRecords; + if (!is_null($searchValue)) { // don't double query if no search value was provided + ## Total number of record with filtering + $sel = misc\mysql\query("select count(1) as allcount from `uservars` WHERE 1 and (`name` like ? or `user` like ? ) and app = ?", ["%" . $searchValue . "%", "%" . $searchValue . "%", $_SESSION['app']]); + $records = mysqli_fetch_assoc($sel->result); + $totalRecordwithFilter = $records['allcount']; + } + + // whitelist certain column names and sort orders to prevent SQL injection + if (!in_array($columnName, array("name", "data", "user", "readOnly"))) { + die("Column name is not whitelisted."); + } + + if (!in_array($columnSortOrder, array("desc", "asc"))) { + die("Column sort order is not whitelisted."); + } + + if (!is_null($searchValue)) { + $query = misc\mysql\query("select * from `uservars` WHERE (`name` like ? or `user` like ? ) and app = ? order by `" . $columnName . "` " . $columnSortOrder . " limit " . $row . "," . $rowperpage, ["%" . $searchValue . "%", "%" . $searchValue . "%", $_SESSION['app']]); + } + else { + $query = misc\mysql\query("select * from `uservars` WHERE app = ? order by `" . $columnName . "` " . $columnSortOrder . " limit " . $row . "," . $rowperpage, [$_SESSION['app']]); + } + + $data = array(); + + while ($row = mysqli_fetch_assoc($query->result)) { + $data[] = array( + "name" => $row["name"], + "data" => $row["data"], + "user" => $row["user"], + "readOnly" => $row["readOnly"] ? "True" : "False", + "actions" => + '
+ +
+ +
    +
  • + +
  • +
  • + +
  • +
+
+ + +
', + ); + } + + ## Response + $response = array( + "draw" => intval($draw), + "iTotalRecords" => $totalRecords, + "iTotalDisplayRecords" => $totalRecordwithFilter, + "aaData" => $data + ); + + die(json_encode($response)); +} + +die("Request not from datatables, aborted."); diff --git a/app/var-fetch.php b/app/var-fetch.php new file mode 100644 index 0000000..afe19d5 --- /dev/null +++ b/app/var-fetch.php @@ -0,0 +1,132 @@ +getMessage()); + die("Error: " . $errorMsg); +}); + +if (session_status() === PHP_SESSION_NONE) { + session_start(); +} + +if ($_SESSION['role'] == "Reseller") { + die("Resellers can't access this."); +} + +if (!isset($_SESSION['app'])) { + dashboard\primary\error("Application not selected"); + die("Application not selected."); +} + +if (isset($_POST['draw'])) { + + // credits to https://makitweb.com/datatables-ajax-pagination-with-search-and-sort-php/ + + $draw = intval($_POST['draw']); + $row = intval($_POST['start']); + $rowperpage = intval($_POST['length']); // Rows display per page + $columnIndex = misc\etc\sanitize($_POST['order'][0]['column']); // Column index + $columnName = misc\etc\sanitize($_POST['columns'][$columnIndex]['data']); // Column name + $columnSortOrder = misc\etc\sanitize($_POST['order'][0]['dir']); // asc or desc + $searchValue = misc\etc\sanitize($_POST['search']['value']); // Search value + + ## Total number of records without filtering + $sel = misc\mysql\query("select count(1) as allcount from `vars` where app = ?", [$_SESSION['app']]); + $records = mysqli_fetch_assoc($sel->result); + $totalRecords = $records['allcount']; + + $totalRecordwithFilter = $totalRecords; + if (!is_null($searchValue)) { // don't double query if no search value was provided + ## Total number of record with filtering + $sel = misc\mysql\query("select count(1) as allcount from `vars` WHERE 1 and (`varid` like ? or `msg` like ? ) and app = ?", ["%" . $searchValue . "%", "%" . $searchValue . "%", $_SESSION['app']]); + $records = mysqli_fetch_assoc($sel->result); + $totalRecordwithFilter = $records['allcount']; + } + + ## Total number of records without filtering + $sel = misc\mysql\query("select count(1) as allcount from `vars` where app = ?", [$_SESSION['app']]); + $records = mysqli_fetch_assoc($sel->result); + $totalRecords = $records['allcount']; + + $totalRecordwithFilter = $totalRecords; + if (!is_null($searchValue)) { // don't double query if no search value was provided + ## Total number of record with filtering + $sel = misc\mysql\query("select count(1) as allcount from `vars` WHERE 1 and (`varid` like ? or `msg` like ? ) and app = ?", ["%" . $searchValue . "%", "%" . $searchValue . "%", $_SESSION['app']]); + $records = mysqli_fetch_assoc($sel->result); + $totalRecordwithFilter = $records['allcount']; + } + + // whitelist certain column names and sort orders to prevent SQL injection + if (!in_array($columnName, array("varid", "msg", "authed"))) { + die("Column name is not whitelisted."); + } + + if (!in_array($columnSortOrder, array("desc", "asc"))) { + die("Column sort order is not whitelisted."); + } + + if (!is_null($searchValue)) { + $query = misc\mysql\query("select * from `vars` WHERE (`varid` like ? or `msg` like ? ) and app = ? order by `" . $columnName . "` " . $columnSortOrder . " limit " . $row . "," . $rowperpage, ["%" . $searchValue . "%", "%" . $searchValue . "%", $_SESSION['app']]); + } + else { + $query = misc\mysql\query("select * from `vars` WHERE app = ? order by `" . $columnName . "` " . $columnSortOrder . " limit " . $row . "," . $rowperpage, [$_SESSION['app']]); + } + + $data = array(); + + while ($row = mysqli_fetch_assoc($query->result)) { + $data[] = array( + "varid" => $row["varid"], + "msg" => substr($row["msg"], 0, 150), + "authed" => $row["authed"] ? "True" : "False", + "actions" => + '
+ +
+ +
    +
  • + +
  • +
  • + +
  • +
+
+ + +
', + ); + } + + ## Response + $response = array( + "draw" => intval($draw), + "iTotalRecords" => $totalRecords, + "iTotalDisplayRecords" => $totalRecordwithFilter, + "aaData" => $data + ); + + die(json_encode($response)); +} + +die("Request not from datatables, aborted."); diff --git a/app/white-fetch.php b/app/white-fetch.php new file mode 100644 index 0000000..1d3c48b --- /dev/null +++ b/app/white-fetch.php @@ -0,0 +1,110 @@ +getMessage()); + die("Error: " . $errorMsg); +}); + +if (session_status() === PHP_SESSION_NONE) { + session_start(); +} + +if ($_SESSION['role'] == "Reseller") { + die("Resellers can't access this."); +} + +if (!isset($_SESSION['app'])) { + die("Application not selected."); +} + +if (isset($_POST['draw'])) { + + // credits to https://makitweb.com/datatables-ajax-pagination-with-search-and-sort-php/ + + $draw = intval($_POST['draw']); + $row = intval($_POST['start']); + $rowperpage = intval($_POST['length']); // Rows display per page + $columnIndex = misc\etc\sanitize($_POST['order'][0]['column']) -1; // Column index + $columnName = misc\etc\sanitize($_POST['columns'][$columnIndex]['data']); // Column name + $columnSortOrder = misc\etc\sanitize($_POST['order'][0]['dir']); // asc or desc + $searchValue = misc\etc\sanitize($_POST['search']['value']); // Search value + + ## Total number of records without filtering + $sel = misc\mysql\query("select count(1) as allcount from `whitelist` where app = ?", [$_SESSION['app']]); + $records = mysqli_fetch_assoc($sel->result); + $totalRecords = $records['allcount']; + + $totalRecordwithFilter = $totalRecords; + if (!is_null($searchValue)) { // don't double query if no search value was provided + ## Total number of record with filtering + $sel = misc\mysql\query("select count(1) as allcount from `whitelist` WHERE 1 and (`ip` like ?) and app = ?", ["%" . $searchValue . "%", $_SESSION['app']]); + $records = mysqli_fetch_assoc($sel->result); + $totalRecordwithFilter = $records['allcount']; + } + + // whitelist certain column names and sort orders to prevent SQL injection + if (!in_array($columnName, array("ip"))) { + die("Column name is not whitelisted."); + } + + if (!in_array($columnSortOrder, array("desc", "asc"))) { + die("Column sort order is not whitelisted."); + } + + + if (!is_null($searchValue)) { + $query = misc\mysql\query("select * from `whitelist` WHERE (`ip` like ?) and app = ? order by `" . $columnName . "` " . $columnSortOrder . " limit " . $row . "," . $rowperpage, ["%" . $searchValue . "%", "%" . $searchValue . "%", "%" . $searchValue . "%", $_SESSION['app']]); + } + else { + $query = misc\mysql\query("select * from `whitelist` WHERE app = ? order by `" . $columnName . "` " . $columnSortOrder . " limit " . $row . "," . $rowperpage, [$_SESSION['app']]); + } + + $data = array(); + + while ($row = mysqli_fetch_assoc($query->result)) { + $data[] = array( + "ip" => '' . ($row["ip"]) . '', + "actions" => + '
+ +
+ +
    +
  • + +
  • +
+
+ +
', + ); + } + + + ## Response + $response = array( + "draw" => intval($draw), + "iTotalRecords" => $totalRecords, + "iTotalDisplayRecords" => $totalRecordwithFilter, + "aaData" => $data + ); + + die(json_encode($response)); +} + +die("Request not from datatables, aborted."); diff --git a/auth/GoogleAuthenticator.php b/auth/GoogleAuthenticator.php new file mode 100644 index 0000000..1296c65 --- /dev/null +++ b/auth/GoogleAuthenticator.php @@ -0,0 +1,174 @@ +_getBase32LookupTable(); + unset($validChars[32]); + + $secret = ''; + for ($i = 0; $i < $secretLength; $i++) { + $secret .= $validChars[array_rand($validChars)]; + } + return $secret; + } + + /** + * Calculate the code, with given secret and point in time + * + * @param string $secret + * @param int|null $timeSlice + * @return string + */ + public function getCode($secret, $timeSlice = null) + { + if ($timeSlice === null) { + $timeSlice = floor(time() / 30); + } + + $secretkey = $this->_base32Decode($secret); + + // Pack time into binary string + $time = chr(0).chr(0).chr(0).chr(0).pack('N*', $timeSlice); + // Hash it with users secret key + $hm = hash_hmac('SHA1', $time, $secretkey, true); + // Use last nipple of result as index/offset + $offset = ord(substr($hm, -1)) & 0x0F; + // grab 4 bytes of the result + $hashpart = substr($hm, $offset, 4); + + // Unpak binary value + $value = unpack('N', $hashpart); + $value = $value[1]; + // Only 32 bits + $value = $value & 0x7FFFFFFF; + + $modulo = pow(10, $this->_codeLength); + return str_pad($value % $modulo, $this->_codeLength, '0', STR_PAD_LEFT); + } + + /** + * Get QR-Code URL for image, from google charts + * + * @param string $name + * @param string $secret + * @param string $title + * @return string + */ + public function getQRCodeGoogleUrl($name, $secret, $title = null) { + $urlencoded = urlencode('otpauth://totp/'.$name.'?secret='.$secret.''); + if(isset($title)) { + $urlencoded .= urlencode('&issuer='.urlencode($title)); + } + return 'https://quickchart.io/qr?text='.$urlencoded.'&size=200¢erImageUrl=https%3A%2F%2Fcdn.keyauth.cc%2Fassets%2Fimg%2Ffavicon.png'; + } + + /** + * Check if the code is correct. This will accept codes starting from $discrepancy*30sec ago to $discrepancy*30sec from now + * + * @param string $secret + * @param string $code + * @param int $discrepancy This is the allowed time drift in 30 second units (8 means 4 minutes before or after) + * @param int|null $currentTimeSlice time slice if we want use other that time() + * @return bool + */ + public function verifyCode($secret, $code, $discrepancy = 1, $currentTimeSlice = null) + { + if ($currentTimeSlice === null) { + $currentTimeSlice = floor(time() / 30); + } + + for ($i = -$discrepancy; $i <= $discrepancy; $i++) { + $calculatedCode = $this->getCode($secret, $currentTimeSlice + $i); + if ($calculatedCode == $code ) { + return true; + } + } + + return false; + } + + /** + * Set the code length, should be >=6 + * + * @param int $length + * @return GoogleAuthenticator + */ + public function setCodeLength($length) + { + $this->_codeLength = $length; + return $this; + } + + /** + * Helper class to decode base32 + * + * @param $secret + * @return bool|string + */ + protected function _base32Decode($secret) + { + if (empty($secret)) return ''; + + $base32chars = $this->_getBase32LookupTable(); + $base32charsFlipped = array_flip($base32chars); + + $paddingCharCount = substr_count($secret, $base32chars[32]); + $allowedValues = array(6, 4, 3, 1, 0); + if (!in_array($paddingCharCount, $allowedValues)) return false; + for ($i = 0; $i < 4; $i++){ + if ($paddingCharCount == $allowedValues[$i] && + substr($secret, -($allowedValues[$i])) != str_repeat($base32chars[32], $allowedValues[$i])) return false; + } + $secret = str_replace('=','', $secret); + $secret = str_split($secret); + $binaryString = ""; + for ($i = 0; $i < count($secret); $i = $i+8) { + $x = ""; + if (!in_array($secret[$i], $base32chars)) return false; + for ($j = 0; $j < 8; $j++) { + $x .= str_pad(base_convert(@$base32charsFlipped[@$secret[$i + $j]], 10, 2), 5, '0', STR_PAD_LEFT); + } + $eightBits = str_split($x, 8); + for ($z = 0; $z < count($eightBits); $z++) { + $binaryString .= ( ($y = chr(base_convert($eightBits[$z], 2, 10))) || ord($y) == 48 ) ? $y:""; + } + } + return $binaryString; + } + + /** + * Get array with all 32 characters for decoding from/encoding to base32 + * + * @return array + */ + protected function _getBase32LookupTable() + { + return array( + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', // 7 + 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', // 15 + 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', // 23 + 'Y', 'Z', '2', '3', '4', '5', '6', '7', // 31 + '=' // padding char + ); + } +} diff --git a/discord/index.html b/discord/index.html new file mode 100644 index 0000000..5c1c80c --- /dev/null +++ b/discord/index.html @@ -0,0 +1,449 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + KeyAuth - Discord Support + + + + + + + + + + + + + + + +
+ +
+ +
+
+

Please click Message our Support below.

+
+

After your message, we will help you ASAP 🙂 patience, we are not awake all the time..

+
+

You can chat and see announcements here on Telegram.

+
+ + + + + Message our Support + +
+
+ + + + + + + + + + + diff --git a/docs/index.php b/docs/index.php new file mode 100644 index 0000000..6496a2e --- /dev/null +++ b/docs/index.php @@ -0,0 +1,3 @@ +6tg9Q37G_e&;{uwBDQ13*FV#)z#Hiw+y3_al28int`Lg z(d|~lh%*es)6@Ju@pi-b4Zr#Oo8L2VU2qk{xc6S$_r`|Ns-9sy^_2O&=|2tQ__K!b z;)}NX-^TsHhS9O3?fO{UpJNyS0k-S^TFGeDuadzJ-~aA#!+3Y-pNyvXj#uFq^LHE! z1NCtIY#rlgkDTZ(LjTnz7;2+Qz04UiaeOHMsZZ75!_=qCT}`UQd)BwPgFq zI(!Dp&$xF@PN?s_rzd(Emp8s|Y#i!oY#Q!$5AHp@W>9Te-oK748Q?3KeSKw4FCUrK z%}1tp_m*v={cyjx`J52%!+6F$tVi|;uj*N!)>*-Om-VeF>&E|Gwj{KZb>Xkcs?gVD z*~C|6;rLf%_2jmallX+3o@lE}i1&(|Fu&^SKlSXjdQhF8mi4PGnZ0Vrx{&8((Xjhv zM$fu3t#=bi?a^3bKk}8NUiZk!l>c+wKgs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(W^j*#sW` z$)$7M?0HQc0GI|{_VFh`W(n@-C|>e|Tj|LMcX!Dqwz#gm)u}b^Ac+@&Xss{N1t}?K z94wLqbg>L)>m*@Ve&I<%5xDn?o@F4jazUkjog=Ys51#>$AeaVC5X%!}(9`9r^*z%t z9ze<3yXl8lPVV}reO$FlfB>HTuZ!of&iSSe08Ep%{O|9AZ;8}U3RB34k{o(1X1aO=vfY!CGZ7V`@@|E5IA&lO5B+# z+`1!4hB!-xaZJG5VU_L21pLQJw%EIL#j>G;-{0$t^%e9E^n*qvK#V8ev*rS{eQ{C; z0A`ICPcq@HfAC%SFfchXfz|6*8-qh*{Z_TS(Q}&DI8Fbxp5xv`WUTi+uLLO-@n1cR zG+keTX@UR%Ds=^6yv*`>V*Y$T)F;tieRSoyVTy);JZ_h*Cryj~-71xy^?c{Zs^wzn zp@$Comt49I<#G=m`^j+Mo;p)^HmEa-vrJd~!TlJjY(jtY7~nBHr-@Q`7r5Iq$_x48~5oYVJ3LeAcqe=a+3*b@JezqrMSD;6=GqMSb}=D#v^9$WM2Sdb3F# z065RI>8^X>)*N)N?uA#A7&>|o*S_Q$adu>^%WYz{Z2B90;%fzqo4ls8$(OvG$XF?T z+3k6L;Wl9&1XLg>mISEW4eD7I9O*qzQh#)|AUaZPnu3LaNn)HaiB5~M*e{5lGKiin zciV@AWu2g|^2G6f-{CL6eg#T>-PpWx35LgkufMJ{Mb9VwfA}d+Fo3OoD*ylh07*qo IM6N<$f-Y!3n*aa+ literal 0 HcmV?d00001 diff --git a/free-trial/index.html b/free-trial/index.html new file mode 100644 index 0000000..2592396 --- /dev/null +++ b/free-trial/index.html @@ -0,0 +1,469 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + KeyAuth - Free Trial + + + + + + + + + + +

+ +
+ +
+
+
+

Free trial - demo + accounts

+

+ You can use these demo accounts to try out paid features before purchase.

The data on these + accounts are wiped after 7 days automatically. Don't store anything important on + them.

Account logs for these accounts have been turned off, and account settings is disabled + as well. These accounts are safe to login to. +

+ +

Seller account

+

Username: demoseller
Password: Ge24V@fe234


+

Developer account

+

Username: demodeveloper
Password: Ge54o@bt844

+ +
+
+
+ + + + + + + + + + + + \ No newline at end of file diff --git a/gdpr/index.html b/gdpr/index.html new file mode 100644 index 0000000..8b854b3 --- /dev/null +++ b/gdpr/index.html @@ -0,0 +1,487 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + KeyAuth - GDPR + + + + + + + + + + + + + +
+ +
+ + + + +
+
+
+

GDPR - How to delete + KeyAuth Account?

+

While we're not beholden to the GDPR laws, we do + believe privacy should be a fundamental human + right.

You can delete your account at https://keyauth.cc/deleteAccount/. It does not require any intervention from + us. Just + enter your email (which we only stored hashed with SHA1😊) and you'll be emailed a link to confirm + the + deletion of your account.

+ +

As soon as you click the confirmation link, all of your data is wiped from our database. If you wish + to come + back, you should make a new account.

If your account was stolen and then deleted, you should + contact + support https://chatting.page/gjqkqirygnfslvce2m5eycuo7tfxrhxl. We may be able to recover your account + if it still exists in a recent database backup file.

We don't provide a way to + fully export your data currently. This may come in the future. We do offer the ability + to + export certain application data to users who have purchased the Seller Plan https://keyauthdocs.apidog.io/sellerapi/users/retrieve-all-users +

+ +
+
+
+ + + + + + + + + + + + \ No newline at end of file diff --git a/includes/.htaccess b/includes/.htaccess new file mode 100644 index 0000000..ad1275c --- /dev/null +++ b/includes/.htaccess @@ -0,0 +1,5 @@ +RewriteEngine On +RewriteRule ^ - [L,R=404] +order deny,allow +deny from all +allow from 127.0.0.1 diff --git a/includes/VerifyEmail.class.php b/includes/VerifyEmail.class.php new file mode 100644 index 0000000..1266ab4 --- /dev/null +++ b/includes/VerifyEmail.class.php @@ -0,0 +1,366 @@ + + * @copyright Copyright (c) 2018, CodexWorld.com + * @url https://www.codexworld.com + */ +class VerifyEmail { + + protected $stream = false; + + /** + * SMTP port number + * @var int + */ + protected $port = 25; + + /** + * Email address for request + * @var string + */ + protected $from = 'noreply@keyauth.com'; + + /** + * The connection timeout, in seconds. + * @var int + */ + protected $max_connection_timeout = 1; + + /** + * Timeout value on stream, in seconds. + * @var int + */ + protected $stream_timeout = 1; + + /** + * Wait timeout on stream, in seconds. + * * 0 - not wait + * @var int + */ + protected $stream_timeout_wait = 0; + + /** + * Whether to throw exceptions for errors. + * @type boolean + * @access protected + */ + protected $exceptions = false; + + /** + * The number of errors encountered. + * @type integer + * @access protected + */ + protected $error_count = 0; + + /** + * class debug output mode. + * @type boolean + */ + public $Debug = false; + + /** + * How to handle debug output. + * Options: + * * `echo` Output plain-text as-is, appropriate for CLI + * * `html` Output escaped, line breaks converted to `
`, appropriate for browser output + * * `log` Output to error log as configured in php.ini + * @type string + */ + public $Debugoutput = 'html'; + + /** + * SMTP RFC standard line ending. + */ + const CRLF = "\r\n"; + + /** + * Holds the most recent error message. + * @type string + */ + public $ErrorInfo = ''; + + /** + * Constructor. + * @param boolean $exceptions Should we throw external exceptions? + */ + public function __construct($exceptions = false) { + $this->exceptions = (boolean) $exceptions; + } + + /** + * Get array of MX records for host. Sort by weight information. + * @param string $hostname The Internet host name. + * @return array Array of the MX records found. + */ + public function getMXrecords($hostname) { + $mxhosts = array(); + $mxweights = array(); + if (getmxrr($hostname, $mxhosts, $mxweights) === FALSE) { + $this->set_error('MX records not found or an error occurred'); + $this->edebug($this->ErrorInfo); + } else { + array_multisort($mxweights, $mxhosts); + } + /** + * Add A-record as last chance (e.g. if no MX record is there). + * Thanks Nicht Lieb. + * @link http://www.faqs.org/rfcs/rfc2821.html RFC 2821 - Simple Mail Transfer Protocol + */ + if (empty($mxhosts)) { + $mxhosts[] = $hostname; + } + return $mxhosts; + } + + /** + * Parses input string to array(0=>user, 1=>domain) + * @param string $email + * @param boolean $only_domain + * @return string|array + * @access private + */ + public static function parse_email($email, $only_domain = TRUE) { + sscanf($email, "%[^@]@%s", $user, $domain); + return ($only_domain) ? $domain : array($user, $domain); + } + + /** + * Add an error message to the error container. + * @access protected + * @param string $msg + * @return void + */ + protected function set_error($msg) { + $this->error_count++; + $this->ErrorInfo = $msg; + } + + /** + * Check if an error occurred. + * @access public + * @return boolean True if an error did occur. + */ + public function isError() { + return ($this->error_count > 0); + } + + /** + * Output debugging info + * Only generates output if debug output is enabled + * @see verifyEmail::$Debugoutput + * @see verifyEmail::$Debug + * @param string $str + */ + protected function edebug($str) { + if (!$this->Debug) { + return; + } + switch ($this->Debugoutput) { + case 'log': + //Don't output, just log + error_log($str); + break; + case 'html': + //Cleans up output a bit for a better looking, HTML-safe output + echo htmlentities( + preg_replace('/[\r\n]+/', '', $str), ENT_QUOTES, 'UTF-8' + ) + . "
\n"; + break; + case 'echo': + default: + //Normalize line breaks + $str = preg_replace('/(\r\n|\r|\n)/ms', "\n", $str); + echo gmdate('Y-m-d H:i:s') . "\t" . str_replace( + "\n", "\n \t ", trim($str) + ) . "\n"; + } + } + + /** + * Validate email + * @param string $email Email address + * @return boolean True if the valid email also exist + */ + public function check($email) { + $result = FALSE; + + $this->error_count = 0; // Reset errors + $this->stream = FALSE; + + $mxs = $this->getMXrecords(self::parse_email($email)); + $timeout = ceil($this->max_connection_timeout / count($mxs)); + $i = 0; + foreach ($mxs as $host) { + $i++; + if($i == 1) { // only check first MX record + /** + * suppress error output from stream socket client... + * Thanks Michael. + */ + $this->stream = @stream_socket_client("tcp://" . $host . ":" . $this->port, $errno, $errstr, $timeout); + if ($this->stream === FALSE) { + if ($errno == 0) { + $this->set_error("Problem initializing the socket"); + $this->edebug($this->ErrorInfo); + if ($this->exceptions) { + throw new verifyEmailException($this->ErrorInfo); + } + return FALSE; + } else { + $this->edebug($host . ":" . $errstr); + } + } else { + stream_set_timeout($this->stream, $this->stream_timeout); + stream_set_blocking($this->stream, 1); + + if ($this->_streamCode($this->_streamResponse()) == '220') { + $this->edebug("Connection success {$host}"); + break; + } else { + fclose($this->stream); + $this->stream = FALSE; + } + } + } + } + + if ($this->stream === FALSE) { + $this->set_error("All connection fails"); + $this->edebug($this->ErrorInfo); + if ($this->exceptions) { + throw new verifyEmailException($this->ErrorInfo); + } + return FALSE; + } + + $this->_streamQuery("HELO " . self::parse_email($this->from)); + $this->_streamResponse(); + $this->_streamQuery("MAIL FROM: <{$this->from}>"); + $this->_streamResponse(); + $this->_streamQuery("RCPT TO: <{$email}>"); + $resp = $this->_streamResponse(); + $code = $this->_streamCode($resp); + if (strpos($resp, "Client host rejected") !== false) { + $this->edebug("The email server doesn't like us :("); + return TRUE; + // server is blocking our server. AWS is far less likely to have these issues, so allow it + } + if (strpos($resp, "Protocol error") !== false) { + $this->edebug("Allowing exception for protonmail"); + return TRUE; + // protonmail returning this + } + + //$this->_streamResponse(); + $this->_streamQuery("RSET"); + //$this->_streamResponse(); + $this->_streamQuery("QUIT"); + fclose($this->stream); + + switch ($code) { + case '250': + /** + * http://www.ietf.org/rfc/rfc0821.txt + * 250 Requested mail action okay, completed + * email address was accepted + */ + return TRUE; + case '450': + return FALSE; + case '451': + return FALSE; + case '452': + /** + * http://www.ietf.org/rfc/rfc0821.txt + * 450 Requested action not taken: the remote mail server + * does not want to accept mail from your server for + * some reason (IP address, blacklisting, etc..) + * Thanks Nicht Lieb. + * 451 Requested action aborted: local error in processing + * 452 Requested action not taken: insufficient system storage + * email address was greylisted (or some temporary error occured on the MTA) + * i believe that e-mail exists + */ + return FALSE; + case '550': + return FALSE; + default : + return FALSE; + } + } + + /** + * writes the contents of string to the file stream pointed to by handle + * If an error occurs, returns FALSE. + * @access protected + * @param string $string The string that is to be written + * @return string Returns a result code, as an integer. + */ + protected function _streamQuery($query) { + $this->edebug($query); + return stream_socket_sendto($this->stream, $query . self::CRLF); + } + + /** + * Reads all the line long the answer and analyze it. + * If an error occurs, returns FALSE + * @access protected + * @return string Response + */ + protected function _streamResponse($timed = 0) { + $reply = stream_get_line($this->stream, 1); + $status = stream_get_meta_data($this->stream); + + if (!empty($status['timed_out'])) { + $this->edebug("Timed out while waiting for data! (timeout {$this->stream_timeout} seconds)"); + } + + if ($reply === FALSE && $status['timed_out'] && $timed < $this->stream_timeout_wait) { + return $this->_streamResponse($timed + $this->stream_timeout); + } + + + if ($reply !== FALSE && $status['unread_bytes'] > 0) { + $reply .= stream_get_line($this->stream, $status['unread_bytes'], self::CRLF); + } + $this->edebug($reply); + return $reply; + } + + /** + * Get Response code from Response + * @param string $str + * @return string + */ + protected function _streamCode($str) { + preg_match('/^(?[0-9]{3})(\s|-)(.*)$/ims', $str, $matches); + $code = isset($matches['code']) ? $matches['code'] : false; + return $code; + } + +} + +/** + * verifyEmail exception handler + */ +class verifyEmailException extends Exception { + + /** + * Prettify error message output + * @return string + */ + public function errorMessage() { + $errorMsg = $this->getMessage(); + return $errorMsg; + } + +} + +$mail = new VerifyEmail(); + +?> \ No newline at end of file diff --git a/includes/api/1.0/autoload.phtml b/includes/api/1.0/autoload.phtml new file mode 100644 index 0000000..316b1d2 --- /dev/null +++ b/includes/api/1.0/autoload.phtml @@ -0,0 +1,7 @@ +result); + $minUsernameLength = $row['minUsernameLength']; + $blockLeakedPasswords = $row['blockLeakedPasswords']; + + if (strlen($un) < $minUsernameLength) { + return 'un_too_short'; + } + + if ($blockLeakedPasswords && etc\isBreached($pw)) { + return 'pw_leaked'; + } + + // search username + $query = mysql\query("SELECT 1 FROM `users` WHERE `username` = ? AND `app` = ?",[$un, $secret]); + // if username already in existence + if ($query->num_rows >= 1) { + return 'username_taken'; + } + // search for key + $query = mysql\query("SELECT `expires`, `status`, `level`, `genby` FROM `keys` WHERE `key` = ? AND `app` = ?",[$key, $secret]); + // check if key exists + if ($query->num_rows < 1) { + return 'key_not_found'; + } + // if key does exist + elseif ($query->num_rows > 0) { + // gather key info + while ($row = mysqli_fetch_array($query->result)) { + $expires = $row['expires']; + $status = $row['status']; + $level = $row['level']; + $genby = $row['genby']; + } + // check license status + switch ($status) { + case 'Used': + return 'key_already_used'; + case 'Banned': + return 'key_banned'; + } + $ip = primary\getIp(); + $hwidBlackCheck = mysql\query("SELECT 1 FROM `bans` WHERE (`hwid` = ? OR `ip` = ?) AND `app` = ?",[$hwid, $ip, $secret]); + if ($hwidBlackCheck->num_rows > 0) { + $query = mysql\query("UPDATE `keys` SET `status` = 'Banned',`banned` = 'This key has been banned as the client was blacklisted.' WHERE `key` = ? AND `app` = ?",[$un, $secret]); + cache\purge('KeyAuthKeys:' . $secret); + return 'hwid_blacked'; + } + // add current time to key time + $expiry = $expires + time(); + $query = mysql\query("SELECT `name` FROM `subscriptions` WHERE `app` = ? AND `level` = ?", [$secret, $level]); + if ($query->num_rows == 0) { + return 'no_subs_for_level'; + } + // update key to used + mysql\query("UPDATE `keys` SET `status` = 'Used',`usedon` = ?,`usedby` = ? WHERE `key` = ? AND `app` = ?",[time(), $un, $key, $secret]); + + cache\purge('KeyAuthKeys:' . $secret); + while ($row = mysqli_fetch_array($query->result)) { + // add each subscription that user's key applies to + $subname = $row['name']; + mysql\query("INSERT INTO `subs` (`user`, `subscription`, `expiry`, `app`, `key`) VALUES (?, ?, ?, ?, ?)",[$un, $subname, $expiry, $secret, $key]); + + } + $password = password_hash($pw, PASSWORD_BCRYPT); + // create user + mysql\query("INSERT INTO `users` (`username`, `email`, `password`, `hwid`, `app`,`owner`,`createdate`, `lastlogin`, `ip`) VALUES (?, SHA(LOWER(NULLIF(?, ''))), ?, NULLIF(?, ''), ?, ?, ?, ?, ?)",[$un, $email, $password, $hwid, $secret, $genby, time(), time(), $ip]); + $query = mysql\query("SELECT `subscription`, `key`, `expiry` FROM `subs` WHERE `user` = ? AND `app` = ? AND `expiry` > " . time() . "",[$un, $secret]); + $rows = array(); + if($query->num_rows > 0) { + while ($r = mysqli_fetch_assoc($query->result)) { + $timeleft = $expiry - time(); + $r += ["timeleft" => $timeleft]; + $rows[] = $r; + } + } + else { + $timeleft = $expiry - time(); + $rows = array("subscription" => "$subname", "key" => "$key", "expiry" => "$expiry", "timeleft" => "$timeleft"); + } + + cache\purge('KeyAuthUser:' . $secret . ':' . $un); + cache\purge('KeyAuthSubs:' . $secret . ':' . $un); + // success + return array( + "username" => "$un", + "subscriptions" => $rows, + "ip" => $ip, + "hwid" => $hwid, + "createdate" => "". time() ."", + "lastlogin" => "" . time() . "" + ); + } +} +#endregion +#region login region +function login($un, $pw, $hwid, $secret, $hwidenabled, $token = null, $_2fa = null) +{ + $row = cache\fetch('KeyAuthUser:' . $secret . ':' . $un, "SELECT * FROM `users` WHERE `username` = ? AND `app` = ?", [$un, $secret], 0); + + if ($row == "not_found") { + return 'un_not_found'; + } + + $pass = $row['password']; + $serverHwid = $row['hwid']; + $banned = $row['banned']; + $createdate = $row['createdate']; + if ($banned != NULL) { + return 'user_banned'; + } + $ip = primary\getIp(); + + if (!is_null($token)) { + $validToken = md5(substr($pass, -5)); + if ($validToken != $token) { + return 'pw_mismatch'; + } + } else if (!is_null($pass)) { + // check if pass matches + if (!password_verify($pw, $pass)) { + return 'pw_mismatch'; + } + } else { + $pass_encrypted = password_hash($pw, PASSWORD_BCRYPT); + $query = mysql\query("UPDATE `users` SET `password` = ? WHERE `username` = ? AND `app` = ?",[$pass_encrypted, $un, $secret]); + + cache\purge('KeyAuthUser:' . $secret . ':' . $un); + } + // check if hwid enabled for application + if ($hwidenabled == "1") { + // check if hwid in db contains hwid recieved + if (!is_null($hwid) && !str_contains($serverHwid, $hwid) && !is_null($serverHwid)) { + return 'hwid_mismatch'; + } else if (is_null($serverHwid) && !is_null($hwid)) { + $query = mysql\query("UPDATE `users` SET `hwid` = NULLIF(?, '') WHERE `username` = ? AND `app` = ?",[$hwid, $un, $secret]); + + cache\purge('KeyAuthUser:' . $secret . ':' . $un); + } + } + $rows = cache\fetch('KeyAuthSubs:' . $secret . ':' . $un, "SELECT `subscription`, `key`, `expiry` FROM `subs` WHERE `user` = ? AND `app` = ? AND `expiry` > ?", [$un, $secret, time()], 1, null, "ssi"); + if($_SERVER['HTTP_USER_AGENT'] == "PostmanRuntime/7.31.3") { + var_dump($rows); + } + + if ($rows == "not_found") { + return 'no_active_subs'; + } + + $query = mysql\query("SELECT `paused` FROM `subs` WHERE `user` = ? AND `app` = ? AND `paused` = 1",[$un, $secret]); + if ($query->num_rows >= 1) { + return 'sub_paused'; + } + + if ($_2fa) { + + if (is_null($_2fa) || empty($_2fa)) { + return 'missing_2fa_code'; } + + else { + require "../../auth/GoogleAuthenticator.php"; + + $auth = new \GoogleAuthenticator(); + + if (!$auth->verifyCode($google_secret, $_2fa, 5)) { + return 'invalid_2fa'; + } + } + } + + $rowsFinal = array(); + foreach ($rows as $row) { + $timeleft = $row["expiry"] - time(); + + $levelquery = mysql\query("SELECT `level` FROM `subscriptions` WHERE `name` = ? AND `app` = ?", [$row["subscription"], $secret]); + $level = mysqli_fetch_array($levelquery->result); + + + $row += ["timeleft" => $timeleft, "level" => $level["level"]]; + $rowsFinal[] = $row; + } + + $ip = primary\getIp(); + + $query = mysql\query("UPDATE `users` SET `ip` = NULLIF(?, ''),`lastlogin` = " . time() . " WHERE `username` = ? AND `app` = ?",[$ip, $un, $secret]); + + return array( + "username" => "$un", + "subscriptions" => $rowsFinal, + "ip" => $ip, + "hwid" => $serverHwid, + "createdate" => "$createdate", + "lastlogin" => "" . time() . "" + ); +} +#endregion diff --git a/includes/api/shared/autoload.phtml b/includes/api/shared/autoload.phtml new file mode 100644 index 0000000..316b1d2 --- /dev/null +++ b/includes/api/shared/autoload.phtml @@ -0,0 +1,7 @@ + "<@1268915723330392096> IP checking is rate limited", + // Username + "username" => "KeyAuth Logs", + ], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); + $ch = curl_init($logwebhook); + curl_setopt($ch, CURLOPT_HTTPHEADER, array( + 'Content-type: application/json' + )); + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); + curl_setopt($ch, CURLOPT_HEADER, 0); + curl_exec($ch); + curl_close($ch); + return false; + } + if($json->proxy || $json->hosting) { + return true; + } + return false; +} +function getIp() +{ + return etc\sanitize($_SERVER['HTTP_CF_CONNECTING_IP'] ?? $_SERVER['HTTP_X_FORWARDED_FOR'] ?? $_SERVER['REMOTE_ADDR']); +} +function getSession($sessionid, $secret) +{ + // had to name it 'state' instead of 'session' because Redis wouldn't save key with 'session' in it + $row = cache\fetch('KeyAuthState:' . $secret . ':' . $sessionid, "SELECT * FROM `sessions` WHERE `id` = ? AND `app` = ? AND `expiry` > ?", [$sessionid, $secret, time()], 0, NULL, "ssi"); + if ($row == "not_found") { + die(json_encode(array( + "success" => false, + "message" => "Session not found. Use latest code. You can only have app opened 1 at a time." + ))); + } + return array( + "credential" => $row["credential"], + "enckey" => $row["enckey"], + "validated" => $row["validated"] + ); +} diff --git a/includes/credentials.php b/includes/credentials.php new file mode 100644 index 0000000..46abf99 --- /dev/null +++ b/includes/credentials.php @@ -0,0 +1,34 @@ + 1 ? '%s seconds' : 'second', $diff); + } + $diff = floor($diff / 60); + if ($diff < 60) { + return sprintf($diff > 1 ? '%s minutes' : 'minute', $diff); + } + $diff = floor($diff / 60); + if ($diff < 24) { + return sprintf($diff > 1 ? '%s hours' : 'hour', $diff); + } + $diff = floor($diff / 24); + if ($diff < 7) { + return sprintf($diff > 1 ? '%s days' : 'day', $diff); + } + if ($diff < 30) { + $diff = floor($diff / 7); + return sprintf($diff > 1 ? '%s weeks' : 'week', $diff); + } + $diff = floor($diff / 30); + if ($diff < 12) { + return sprintf($diff > 1 ? '%s months' : 'month', $diff); + } + $diff = date('Y', $now) - date('Y', $date); + return sprintf($diff > 1 ? '%s years' : 'year', $diff); +} +function expireCheck($username, $expires) +{ + if ($expires < time()) { + $_SESSION['role'] = "tester"; + $query = mysql\query("UPDATE `accounts` SET `role` = 'tester' WHERE `username` = ?",[$username]); + } + if ($expires - time() < 2629743) // check if account expires in month or less + { + return true; + } else { + return false; + } +} +function wh_log($webhook_url, $msg, $un, $color, $pingList) +{ + $json_data = json_encode([ + "content" => $pingList . "\n" . $un . " > " . $msg + ], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); + $ch = curl_init($webhook_url); + curl_setopt($ch, CURLOPT_HTTPHEADER, array( + 'Content-type: application/json' + )); + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); + curl_setopt($ch, CURLOPT_HEADER, 0); + curl_exec($ch); + curl_close($ch); +} + +function error($msg){ + $msg = addslashes($msg); + + echo ' + + '; +} + +function success($msg) { + $msg = addslashes($msg); + + echo ' + + '; +} + +/*function error($msg) +{ + echo ''; +} +function success($msg) +{ + echo ''; +}*/ + +function popover($id, $title, $msg){ + echo ''; +} diff --git a/includes/misc/account.php b/includes/misc/account.php new file mode 100644 index 0000000..b1f0cc3 --- /dev/null +++ b/includes/misc/account.php @@ -0,0 +1,51 @@ +num_rows > 0) { + return 'username_taken'; + } + $email_check = mysql\query("SELECT `username` FROM `accounts` WHERE `email` = SHA1(?)", [$email]); + + if ($email_check->num_rows > 0) { + return 'email_taken'; + } + + if ($permissions <= 0 || !is_numeric($permissions)) { // Manager users must have access to at least one page + return 'invalid_perms'; + } + $permissions = decbin($permissions); + + $query = mysql\query("INSERT INTO `accounts` (`username`, `email`, `password`, `role`, `app`, `owner`, `balance`, `keylevels`, `permissions`) VALUES (?, SHA1(?), ?, ?, ?, ?, '0|0|0|0|0|0|0', ?, b'$permissions')", [$username, $email, $pass_encrypted, $role, $name, $owner, $keyLevels]); + if ($query->affected_rows > 0) { + return 'success'; + } else { + return 'failure'; + } +} diff --git a/includes/misc/app.php b/includes/misc/app.php new file mode 100644 index 0000000..5b2e907 --- /dev/null +++ b/includes/misc/app.php @@ -0,0 +1,55 @@ + ?",[time(), $secret ?? $_SESSION['app'], time()], "isi"); + mysql\query("UPDATE `apps` SET `paused` = 1 WHERE `secret` = ?",[$secret ?? $_SESSION['app']]); + $query = mysql\query("SELECT `ownerid`,`name`,`customDomainAPI` FROM `apps` WHERE `secret` = ?", [$secret ?? $_SESSION['app']]); + $row = mysqli_fetch_array($query->result); + cache\purge('KeyAuthApp:' . $row['customDomainAPI']); + cache\purge('KeyAuthApp:' . $row['name'] . ':' . $row['ownerid']); +} +function unpause($secret = null){ + mysql\query("UPDATE `subs` SET `paused` = 0, `expiry` = `expiry`+? WHERE `app` = ? AND `paused` = 1", [time(), $secret ?? $_SESSION['app']], "is"); + mysql\query("UPDATE `apps` SET `paused` = 0 WHERE `secret` = ?",[$secret ?? $_SESSION['app']]); + $query = mysql\query("SELECT `ownerid`,`name`,`customDomainAPI` FROM `apps` WHERE `secret` = ?",[$secret ?? $_SESSION['app']]); + $row = mysqli_fetch_array($query->result); + cache\purge('KeyAuthApp:' . $row['customDomainAPI']); + cache\purge('KeyAuthApp:' . $row['name'] . ':' . $row['ownerid']); +} +function addHash($hash, $secret = null){ + $hash = etc\sanitize($hash); + $query = mysql\query("SELECT `hash`, `name`, `ownerid` FROM `apps` WHERE `secret` = ?",[$secret ?? $_SESSION['app']]); + $row = mysqli_fetch_array($query->result); + $oldHash = $row["hash"]; + $name = $row["hash"]; + $ownerid = $row["ownerid"]; + + $newHash = $oldHash .= $hash; + + $query = mysql\query("UPDATE `apps` SET `hash` = ? WHERE `secret` = ?",[$newHash, $secret ?? $_SESSION['app']]); + + if ($query->affected_rows > 0) { + cache\purge("KeyAuthApp:{$name}:{$ownerid}"); + return 'success'; + } + return 'failure'; +} +function resetHash($secret = null, $name = null, $ownerid = null){ + $name = $name ?? $_SESSION['name']; + $ownerid = $ownerid ?? $_SESSION['ownerid']; + + $query = mysql\query("UPDATE `apps` SET `hash` = NULL WHERE `secret` = ?",[$secret ?? $_SESSION['app']]); + + if ($query->affected_rows > 0) { + cache\purge("KeyAuthApp:{$name}:{$ownerid}"); + return 'success'; + } + return 'failure'; +} diff --git a/includes/misc/auditLog.php b/includes/misc/auditLog.php new file mode 100644 index 0000000..681a7cc --- /dev/null +++ b/includes/misc/auditLog.php @@ -0,0 +1,28 @@ +result); + if(!is_null($row['auditLogWebhook'])) { + primary\wh_log($row['auditLogWebhook'], "**User:** " . $_SESSION['username'] . "**Event:** $event", "", "3586ee"); + } + else { + $query = mysql\query("INSERT INTO `auditLog` (`user`, `event`, `time`, `app`) VALUES (?, ?, ?, ?)",[$_SESSION['username'], $event, time(), $_SESSION['app']]); + } +} +function deleteAll($secret = null){ + $query = mysql\query("DELETE FROM `auditLog` WHERE `app` = ?",[$secret ?? $_SESSION['app']]); + if ($query->affected_rows > 0){ + if ($_SESSION['role'] == "seller" || !is_null($secret)){ + cache\purge('KeyAuthAuditLogs:' . ($secret ?? $_SESSION['app'])); + } return 'success'; + } else { + return 'failure'; + } +} \ No newline at end of file diff --git a/includes/misc/autoload.phtml b/includes/misc/autoload.phtml new file mode 100644 index 0000000..316b1d2 --- /dev/null +++ b/includes/misc/autoload.phtml @@ -0,0 +1,7 @@ +affected_rows > 0) { + if ($_SESSION['role'] == "seller" || !is_null($secret)) { + cache\purge('KeyAuthBlacks:' . ($secret ?? $_SESSION['app'])); + } + return 'success'; + } else { + return 'failure'; + } +} +function deleteAll($secret = null) +{ + $query = mysql\query("DELETE FROM `bans` WHERE `app` = ?",[$secret ?? $_SESSION['app']]); + + if ($query->affected_rows > 0) { + cache\purgePattern('KeyAuthBlacklist:' . ($secret ?? $_SESSION['app'])); + if ($_SESSION['role'] == "seller" || !is_null($secret)) { + cache\purge('KeyAuthBlacks:' . ($secret ?? $_SESSION['app'])); + } + return 'success'; + } else { + return 'failure'; + } +} +function deleteSingular($blacklist, $type, $secret = null) +{ + $blacklist = etc\sanitize($blacklist); + $type = etc\sanitize($type); + + switch ($type) { + case 'ip': + $query = mysql\query("DELETE FROM `bans` WHERE `app` = ? AND `ip` = ?",[$secret ?? $_SESSION['app'], $blacklist]); + cache\purgePattern('KeyAuthBlacklist:' . ($secret ?? $_SESSION['app']) . ':' . $blacklist); + break; + case 'hwid': + $query = mysql\query("DELETE FROM `bans` WHERE `app` = ? AND `hwid` = ?",[$secret ?? $_SESSION['app'], $blacklist]); + cache\purgePattern('KeyAuthBlacklist:' . ($secret ?? $_SESSION['app']) . ':*:' . $blacklist); + break; + case 'region': + $query = mysql\query("DELETE FROM `bans` WHERE `app` = ? AND `region` = ?",[$secret ?? $_SESSION['app'], $blacklist]); + break; + case 'country': + $query = mysql\query("DELETE FROM `bans` WHERE `app` = ? AND `country` = ?",[$secret ?? $_SESSION['app'], $blacklist]); + break; + case 'asn': + $query = mysql\query("DELETE FROM `bans` WHERE `app` = ? AND `asn` = ?",[$secret ?? $_SESSION['app'], $blacklist]); + break; + default: + return 'invalid'; + } + if ($query->affected_rows > 0) { + if ($_SESSION['role'] == "seller" || !is_null($secret)) { + cache\purge('KeyAuthBlacks:' . ($secret ?? $_SESSION['app'])); + } + return 'success'; + } else { + return 'failure'; + } +} + diff --git a/includes/misc/button.php b/includes/misc/button.php new file mode 100644 index 0000000..601968d --- /dev/null +++ b/includes/misc/button.php @@ -0,0 +1,40 @@ +affected_rows > 0) { + if ($_SESSION['role'] == "seller" || !is_null($secret)) { + cache\purge('KeyAuthButtons:' . ($secret ?? $_SESSION['app'])); + } + return 'success'; + } else { + return 'failure'; + } +} + +function deleteButton($value, $secret = null) +{ + + $value = etc\sanitize($value); + $query = mysql\query("DELETE FROM `buttons` WHERE `value` = ? AND `app` = ?",[$value, $secret ?? $_SESSION['app']]); + + if ($query->affected_rows > 0) { + if ($_SESSION['role'] == "seller" || !is_null($secret)) { + cache\purge('KeyAuthButtons:' . ($secret ?? $_SESSION['app'])); + } + return 'success'; + } else { + return 'failure'; + } +} diff --git a/includes/misc/cache.php b/includes/misc/cache.php new file mode 100644 index 0000000..d0293e0 --- /dev/null +++ b/includes/misc/cache.php @@ -0,0 +1,137 @@ +get($redisKey); + if (!$data) { + $query = mysql\query($sqlQuery,$args, $types); + if ($query->num_rows < 1) // check if MySQL found any rows + { + $redis->set($redisKey, 'not_found'); // save redis key indicating record not found + $redis->expire($redisKey, 300); // if the data doesn't exist, only keep Redis key for 5 minutes to mitigate against spam + return 'not_found'; + } + if ($multiRowed) { // return multi-rowed response for applications such as chat channels where multiple rows containing messages + while ($r = mysqli_fetch_assoc($query->result)) { + $data[] = $r; + } + } else { + $data = mysqli_fetch_array($query->result); + } + + $redis->set($redisKey, serialize($data)); // save data to redis key so next time it's retrieved much quicker from cache + + if(str_contains($redisKey, "keyauthsubs")) { // ensure no users can login for longer than they're supposed to + $expiries = array(); + foreach ($data as $row) { + $expiries[] = $row['expiry']; + } + $ttl = intval(min($expiries) - time()); + $redis->expire($redisKey, $ttl); + } + + if(str_contains($redisKey, "keyauthsellercheck")) { // ensure no customers can use SellerAPI for longer than the period they have seller plan + $ttl = intval($data["expires"] - time()); + $redis->expire($redisKey, $ttl); + } + + if(str_contains($redisKey, "keyauthstate")) { // ensure no users stay logged in for longer than they're supposed to + $ttl = intval($data["expiry"] - time()); + $redis->expire($redisKey, $ttl); + } + + if (!is_null($expiry)) { + $redis->expire($redisKey, intval($expiry)); // set TTL if specified + } + } else { + if ($data == "not_found") { + return 'not_found'; + } + $data = unserialize($data); + } + return $data; // return data from either MySQL or Redis +} +function purge($redisKey) // delete key from Redis cache (typically called when MySQL row(s) updated or deleted) +{ + $redisKey = strtolower($redisKey); // redis is case-insensitive, and key must be encoded for HTTP request used in production + + global $redis; + include_once (($_SERVER['DOCUMENT_ROOT'] == "/usr/share/nginx/html/panel" || $_SERVER['DOCUMENT_ROOT'] == "/usr/share/nginx/html/api") ? "/usr/share/nginx/html" : $_SERVER['DOCUMENT_ROOT']) . '/includes/redis.php'; // create connection with Redis + $redis->del($redisKey); +} + +function purgePattern($redisKey) // purge all data starting with, ending with, or both and unknown text in between +{ + if($redisKey == "*" || empty($redisKey)) { + die("Invalid redis key purge value. Must specify some text."); + } + $redisKey = strtolower($redisKey); // redis is case-insensitive, and key must be encoded for HTTP request used in production + + global $redis; + include_once (($_SERVER['DOCUMENT_ROOT'] == "/usr/share/nginx/html/panel" || $_SERVER['DOCUMENT_ROOT'] == "/usr/share/nginx/html/api") ? "/usr/share/nginx/html" : $_SERVER['DOCUMENT_ROOT']) . '/includes/redis.php'; // create connection with Redis + $redis->delete($redis->keys($redisKey . '*')); +} + +function rateLimit($redisKey, $amount, $expiry, $limit) // rate limiting with Redis, prevent spam/DDoS attack(s) +{ + global $redis; + include_once (($_SERVER['DOCUMENT_ROOT'] == "/usr/share/nginx/html/panel" || $_SERVER['DOCUMENT_ROOT'] == "/usr/share/nginx/html/api") ? "/usr/share/nginx/html" : $_SERVER['DOCUMENT_ROOT']) . '/includes/redis.php'; // create connection with Redis + $redisKey = strtolower($redisKey); // redis is case-insensitive + $data = $redis->get($redisKey); + if (!$data) { + $redis->set($redisKey, $amount, $expiry); + return false; + } else { + if (intval($data) >= $limit) { + $ttl = $redis->ttl($redisKey); + if($ttl > $expiry || $ttl < 0) { + purge($redisKey); + return false; + } + return true; + } + $redis->incr($redisKey, $amount); + return false; + } +} + +function select($redisKey) { + global $redis; + include_once (($_SERVER['DOCUMENT_ROOT'] == "/usr/share/nginx/html/panel" || $_SERVER['DOCUMENT_ROOT'] == "/usr/share/nginx/html/api") ? "/usr/share/nginx/html" : $_SERVER['DOCUMENT_ROOT']) . '/includes/redis.php'; // create connection with Redis + $redisKey = strtolower($redisKey); // redis is case-insensitive + return $redis->get($redisKey); +} + +function insert($redisKey, $value, $expiry) { + $redisKey = strtolower($redisKey); // redis is case-insensitive + + global $redis; + include_once (($_SERVER['DOCUMENT_ROOT'] == "/usr/share/nginx/html/panel" || $_SERVER['DOCUMENT_ROOT'] == "/usr/share/nginx/html/api") ? "/usr/share/nginx/html" : $_SERVER['DOCUMENT_ROOT']) . '/includes/redis.php'; // create connection with Redis + $redis->set($redisKey, $value, $expiry); +} + +function update($redisKey, ...$replacements) { + global $redis; + include_once (($_SERVER['DOCUMENT_ROOT'] == "/usr/share/nginx/html/panel" || $_SERVER['DOCUMENT_ROOT'] == "/usr/share/nginx/html/api") ? "/usr/share/nginx/html" : $_SERVER['DOCUMENT_ROOT']) . '/includes/redis.php'; // create connection with Redis + $redisKey = strtolower($redisKey); // redis is case-insensitive + + $data = unserialize($redis->get($redisKey)); + + if(!$data) { + return false; + } + + $new = serialize(array_replace($data, ...$replacements)); + + $redis->set($redisKey, $new, ['KEEPTTL']); + + return true; +} diff --git a/includes/misc/chat.php b/includes/misc/chat.php new file mode 100644 index 0000000..c379a1a --- /dev/null +++ b/includes/misc/chat.php @@ -0,0 +1,112 @@ +result); + cache\purge('KeyAuthChatMsgs:' . ($secret ?? $_SESSION['app']) . ':' . $row['channel']); + + $query = mysql\query("DELETE FROM `chatmsgs` WHERE `app` = ? AND `id` = ?",[$secret ?? $_SESSION['app'], $id]); + if ($query->affected_rows > 0) { + return 'success'; + } else { + return 'failure'; + } +} +function muteUser($user, $time, $secret = null){ + $user = etc\sanitize($user); + $time = etc\sanitize($time); + + $query = mysql\query("SELECT 1 FROM `users` WHERE `app` = ? AND `username` = ?",[$secret ?? $_SESSION['app'], $user]); + if ($query->num_rows == 0) { + return 'missing'; + } + $query = mysql\query("INSERT INTO `chatmutes` (`user`, `time`, `app`) VALUES (?, ?, ?)",[$user, $time, $secret ?? $_SESSION['app']]); + if ($query->affected_rows > 0) { + if ($_SESSION['role'] == "seller" || !is_null($secret)) { + cache\purge('KeyAuthMutes:' . ($secret ?? $_SESSION['app'])); + } + return 'success'; + } else { + return 'failure'; + } +} +function unMuteUser($user, $secret = null){ + $user = etc\sanitize($user); + + $query = mysql\query("DELETE FROM `chatmutes` WHERE `app` = ? AND `user` = ?",[$secret ?? $_SESSION['app'], $user]); + + if ($query->affected_rows > 0) { + if ($_SESSION['role'] == "seller" || !is_null($secret)) { + cache\purge('KeyAuthMutes:' . ($secret ?? $_SESSION['app'])); + } + return 'success'; + } else { + return 'failure'; + } +} +function clearChannel($channel, $secret = null){ + $channel = etc\sanitize($channel); + + $query = mysql\query("DELETE FROM `chatmsgs` WHERE `app` = ? AND `channel` = ?",[$secret ?? $_SESSION['app'], $channel]); + + if ($query->affected_rows > 0) { + cache\purge('KeyAuthChatMsgs:' . ($secret ?? $_SESSION['app']) . ':' . $channel); + return 'success'; + } else { + return 'failure'; + } +} +function createChannel($name, $delay, $secret = null){ + $name = etc\sanitize($name); + $delay = etc\sanitize($delay); + + $query = mysql\query("INSERT INTO `chats` (`name`, `delay`, `app`) VALUES (?, ?, ?)",[$name, $delay, $secret ?? $_SESSION['app']]); + + if ($query->affected_rows > 0) { + if ($_SESSION['role'] == "seller" || !is_null($secret)) { + cache\purge('KeyAuthChats:' . ($secret ?? $_SESSION['app'])); + } + return 'success'; + } else { + return 'failure'; + } +} +function deleteChannel($name, $secret = null){ + $name = etc\sanitize($name); + + $query = mysql\query("DELETE FROM `chats` WHERE `app` = ? AND `name` = ?",[$secret ?? $_SESSION['app'], $name]); + + if ($query->affected_rows > 0) { + $query = mysql\query("DELETE FROM `chatmsgs` WHERE `app` = ? AND `channel` = ?",[$secret ?? $_SESSION['app'], $name]); + cache\purge('KeyAuthChatMsgs:' . ($secret ?? $_SESSION['app']) . ':' . $name); + if ($_SESSION['role'] == "seller" || !is_null($secret)) { + cache\purge('KeyAuthChats:' . ($secret ?? $_SESSION['app'])); + } + return 'success'; + } else { + return 'failure'; + } +} + +function deleteAllChannels($secret = null){ + $query = mysql\query("DELETE FROM `chats` WHERE `app` = ?",[$secret ?? $_SESSION['app']]); + + if ($query->affected_rows > 0) { + $query = mysql\query("DELETE FROM `chatmsgs` WHERE `app` = ?",[$secret ?? $_SESSION['app']]); + cache\purge('KeyAuthChatMsgs:' . ($secret ?? $_SESSION['app'])); + if ($_SESSION['role'] == "seller" || !is_null($secret)){ + cache\purge('KeyAuthChats:' . ($secret ?? $_SESSION['app'])); + } + return 'success'; + } else { + return 'failure'; + } +} \ No newline at end of file diff --git a/includes/misc/email.php b/includes/misc/email.php new file mode 100644 index 0000000..90938da --- /dev/null +++ b/includes/misc/email.php @@ -0,0 +1,479 @@ + + + + + + + + + + + + + + + + + '; + + $m = new \SimpleEmailServiceMessage(); + $m->addTo("{$username} <{$email}>"); + $m->setFrom('KeyAuth '); + $m->setSubject("{$subject}"); + $m->setMessageFromString($content, $content); + + $region_endpoint = \SimpleEmailService::AWS_US_EAST_1; + $ses = new \SimpleEmailService($awsAccessKey, $awsSecretKey, $region_endpoint); + $ses->sendEmail($m); +} diff --git a/includes/misc/etc.php b/includes/misc/etc.php new file mode 100644 index 0000000..3ada628 --- /dev/null +++ b/includes/misc/etc.php @@ -0,0 +1,199 @@ +disposable) + { + return true; + } + + if (strpos($email, ".ru") !== false) + { + return false; + // russian email services either have a lot of downtime or heavy rate limits, because every other time I make SMTP connection with an .ru email it fails + } + + if (strpos($email, "proton") !== false) + { + return false; + // protonmail is also giving us issues + } + + ini_set("default_socket_timeout", 1); + $connection = @fsockopen("gmail-smtp-in.l.google.com", 25); + + // check if port 25 is open (many hosts have it closed inherently) + if (is_resource($connection)) + { + global $mail; + require_once (($_SERVER['DOCUMENT_ROOT'] == "/usr/share/nginx/html/panel" || $_SERVER['DOCUMENT_ROOT'] == "/usr/share/nginx/html/api") ? "/usr/share/nginx/html" : $_SERVER['DOCUMENT_ROOT']) . '/includes/VerifyEmail.class.php'; + + return (!$mail->check($email)); + } + else + { + return false; + } +} + +function timeconversion($expires) { + $value = ""; + $unit = ""; + + if ($expires >= 31536000) { + $value = floor($expires / 31536000); + $unit = 'Year(s)'; + } + elseif ($expires >= 2419200) { + $value = floor($expires / 2592000); + $unit = 'Month(s)'; + } + elseif ($expires >= 604800) { + $value = floor($expires / 604800); + $unit = 'Weeks(s)'; + } + elseif ($expires >= 86400) { + $value = floor($expires / 86400); + $unit = 'Day(s)'; + } elseif ($expires >= 3600) { + $value = floor($expires / 3600); + $unit = 'Hour(s)'; + } elseif ($expires >= 60) { + $value = floor($expires / 60); + $unit = 'Minute(s)'; + } else { + $value = $expires; + $unit = 'Second(s)'; + } + + return "$value $unit"; +} + +function isDisabled($enabledFunctions, $type) { + $perms = array( + `loginToggle` => 1, + `registerToggle` => 2, + `licenseToggle` => 4, + `chatGetToggle` => 8, + `chatSendToggle` => 16, + `getVarToggle` => 32, + `setVarToggle` => 64, + `banToggle` => 128, + `checkBlackToggle` => 256, + `sessionToggle` => 512, + `changeUsernameToggle` => 1024, + `fileToggle` => 2048, + `fetchOnlineToggle` => 4096, + `forgotPasswordToggle` => 8192, + `fetchStatsToggle` => 16384, + `logToggle` => 32768, + `webhookToggle` => 65536, + `varToggle` => 131072, + `upgradeToggle` => 262144 + ); + + if (array_key_exists($type, $perms)) { + if (($enabledFunctions & $perms[$type]) != $perms[$type]) { + return true; + } + } + + return false; +} \ No newline at end of file diff --git a/includes/misc/license.php b/includes/misc/license.php new file mode 100644 index 0000000..51e248c --- /dev/null +++ b/includes/misc/license.php @@ -0,0 +1,410 @@ + 100) { + return 'max_keys'; + } + if (!isset($amount)) { + $amount = 1; + } + if (!is_numeric($level)) { + $level = 1; + } + if (is_null($expiry)) { + $expiry = 86400; // set unit to day(s) if license expiry unit isn't specified (as it isn't with SellerAPI) + } + $duration = $duration * $expiry; + if ($amount > 1 && strpos($mask, '*') === false) { + return 'dupe_custom_key'; + } + + switch ($_SESSION['role']) + { + case 'tester': + $query = mysql\query("SELECT 1 FROM `keys` WHERE `genby` = ? AND `app` = ?",[$_SESSION['username'], $_SESSION['app']]); + $currkeys = $query->num_rows; + if ($currkeys + $amount > 10) { + return 'tester_limit'; + } + + $mask = "VAULTCORD-" . $mask; + break; + case 'Reseller': + if ($amount < 0) { + return 'no_negative'; + } + $query = mysql\query("SELECT `keylevels`, `balance` FROM `accounts` WHERE `username` = ?",[$_SESSION['username']]); + $row = mysqli_fetch_array($query->result); + $keylevels = explode("|", $row['keylevels']); + $balance = explode("|", $row['balance']); + if ($row['keylevels'] != "N/A" && !in_array($level, $keylevels)) { + return 'unauthed_level'; + } + $day = $balance[0]; + $week = $balance[1]; + $month = $balance[2]; + $threemonth = $balance[3]; + $sixmonth = $balance[4]; + $lifetime = $balance[5]; + $year = $balance[6]; + switch ($expiry) { + case '1 Day': + $duration = 86400; + $day = $day - $amount; + break; + case '1 Week': + $duration = 604800; + $week = $week - $amount; + break; + case '1 Month': + $duration = 2.592e+6; + $month = $month - $amount; + break; + case '3 Month': + $duration = 7.862e+6; + $threemonth = $threemonth - $amount; + break; + case '6 Month': + $duration = 1.572e+7; + $sixmonth = $sixmonth - $amount; + break; + case '1 Lifetime': + $duration = 8.6391e+8; + $lifetime = $lifetime - $amount; + break; + case '1 Year': + $duration = 3.1536e+7; + $year = $year - $amount; + break; + default: + return 'invalid_exp'; + } + if ($day < 0 || $month < 0 || $week < 0 || $threemonth < 0 || $sixmonth < 0 || $lifetime < 0 || $year < 0) { + return 'insufficient_balance'; + } + $balance = $day . '|' . $week . '|' . $month . '|' . $threemonth . '|' . $sixmonth . '|' . $lifetime . '|' . $year; + $query = mysql\query("UPDATE `accounts` SET `balance` = ? WHERE `username` = ?",[$balance, $_SESSION['username']]); + break; + case 'seller': + cache\purge('KeyAuthKeys:' . ($secret ?? $_SESSION['app'])); + break; + } + + if(!is_null($secret)) { + cache\purge('KeyAuthKeys:' . ($secret ?? $_SESSION['app'])); + } + + $licenses = array(); + + for ($i = 0; $i < $amount; $i++) { + $license = license_masking($mask, $letters); + + if (token\ModifyUserToken($license, "License") === "failed") { + return "failure"; + } + $query = mysql\query("INSERT INTO `keys` (`key`, `user`, `note`, `expires`, `status`, `level`, `genby`, `gendate`, `app`) VALUES (?, ?, NULLIF(?, ''), ?, 'Not Used', ?, ?, ?, ?)", [$license, $user, $note, $duration, $level, $owner ?? $_SESSION['username'], time(), $secret ?? $_SESSION['app']]); + $licenses[] = $license; + } + return $licenses; +} + +function addTime($time, $expiry, $secret = null) +{ + $time = etc\sanitize($time); + $expiry = etc\sanitize($expiry); + + $time = $time * $expiry; + $query = mysql\query("UPDATE `keys` SET `expires` = `expires`+? WHERE `app` = ? AND `status` = 'Not Used'",[$time, $secret ?? $_SESSION['app']]); + if ($query->affected_rows > 0) + { + if ($_SESSION['role'] == "seller" || !is_null($secret)) + { + cache\purge('KeyAuthKeys:' . ($secret ?? $_SESSION['app'])); + } + return 'success'; + } + else + { + return 'failure'; + } +} +function deleteAll($secret = null) +{ + $query = mysql\query("DELETE FROM `keys` WHERE `app` = ?",[$secret ?? $_SESSION['app']]); + if ($query->affected_rows > 0) + { + $query = mysql\query("DELETE FROM `tokens` WHERE `app` = ? AND `type` = ?",[$secret ?? $_SESSION['app'], "license"]); + + if ($query->affected_rows > 0) { cache\purgePattern('KeyAuthUserTokens:' . ($secret ?? $_SESSION['app'])); } + + if ($_SESSION['role'] == "seller" || !is_null($secret)) { + cache\purge('KeyAuthKeys:' . ($secret ?? $_SESSION['app'])); + } + return 'success'; + } + else + { + return 'failure'; + } +} +function deleteAllUnused($secret = null) +{ + $query = mysql\query("DELETE FROM `keys` WHERE `app` = ? AND `status` = 'Not Used'",[$secret ?? $_SESSION['app']]); + if ($query->affected_rows > 0) + { + $query = mysql\query("DELETE FROM `tokens` WHERE `app` = ? AND `status` = ? AND `type` = ?",[$secret ?? $_SESSION['app'], "Not Used", "license"]); + + if ($query->affected_rows > 0) { cache\purgePattern('KeyAuthUserTokens:' . ($secret ?? $_SESSION['app'])); } + + if ($_SESSION['role'] == "seller" || !is_null($secret)) + { + cache\purge('KeyAuthKeys:' . ($secret ?? $_SESSION['app'])); + } + return 'success'; + } + else + { + return 'failure'; + } +} +function deleteAllUsed($secret = null) +{ + $query = mysql\query("DELETE FROM `keys` WHERE `app` = ? AND `status` = 'Used'",[$secret ?? $_SESSION['app']]); + if ($query->affected_rows > 0) + { + if ($_SESSION['role'] == "seller" || !is_null($secret)) + { + cache\purge('KeyAuthKeys:' . ($secret ?? $_SESSION['app'])); + } + return 'success'; + } + else + { + return 'failure'; + } +} +function deleteSingular($key, $userToo, $secret = null) +{ + $key = etc\sanitize($key); + $userToo = etc\sanitize($userToo); + + if ($_SESSION['role'] == "Reseller") + { + $query = mysql\query("SELECT 1 FROM `keys` WHERE `app` = ? AND `key` = ? AND `genby` = ?",[$secret ?? $_SESSION['app'], $key, $_SESSION['username']]); + if ($query->num_rows < 1) + { + return 'nope'; + } + } + + if ($userToo) { + $query = mysql\query("SELECT `usedby` FROM `keys` WHERE `app` = ? AND `key` = ?",[$secret ?? $_SESSION['app'], $key]); + $row = mysqli_fetch_array($query->result); + $usedby = $row['usedby']; + + user\deleteSingular($usedby, $secret); + } + + $query = mysql\query("DELETE FROM `subs` WHERE `app` = ? AND `key` = ?",[$secret ?? $_SESSION['app'], $key]);// delete any subscriptions created with key + $query = mysql\query("DELETE FROM `tokens` WHERE `app` = ? AND `assigned` = ?", [$secret ?? $_SESSION['app'], $key]); + $query = mysql\query("DELETE FROM `keys` WHERE `app` = ? AND `key` = ?",[$secret ?? $_SESSION['app'], $key]); + if ($query->affected_rows > 0) { + cache\purgePattern('KeyAuthUserTokens:' . ($secret ?? $_SESSION['app'])); + if ($_SESSION['role'] == "seller" || !is_null($secret)) { + cache\purge('KeyAuthKeys:' . ($secret ?? $_SESSION['app'])); + cache\purge('KeyAuthKey:' . ($secret ?? $_SESSION['app']) . ':' . $key); + } + return 'success'; + } else { + return 'failure'; + } +} + +function deleteMultiple($keys, $userToo, $secret = null) { + $keys = explode(', ', $keys); + $userToo = etc\sanitize($userToo); + + foreach ($keys as $key) { + $key = etc\sanitize(trim($key)); + + if ($_SESSION['role'] == "Reseller") { + $query = mysql\query("SELECT 1 FROM `keys` WHERE `app` = ? AND `key` = ? AND `genby` = ?",[$secret ?? $_SESSION['app'], $key, $_SESSION['username']]); + if ($query->num_rows < 1) { + return 'nope'; + } + } + + if ($userToo) { + $query = mysql\query("SELECT `usedby` FROM `keys` WHERE `app` = ? AND `key` = ?",[$secret ?? $_SESSION['app'], $key]); + $row = mysqli_fetch_array($query->result); + $usedby = $row['usedby']; + + user\deleteSingular($usedby, $secret); + } + + $query = mysql\query("DELETE FROM `subs` WHERE `app` = ? AND `key` = ?",[$secret ?? $_SESSION['app'], $key]);// delete any subscriptions created with key + $query = mysql\query("DELETE FROM `tokens` WHERE `app` = ? AND `assigned` = ?", [$secret ?? $_SESSION['app'], $key]); + $query = mysql\query("DELETE FROM `keys` WHERE `app` = ? AND `key` = ?",[$secret ?? $_SESSION['app'], $key]); + if ($query->affected_rows > 0) { + cache\purgePattern('KeyAuthUserTokens:' . ($secret ?? $_SESSION['app'])); + if ($_SESSION['role'] == "seller" || !is_null($secret)) { + cache\purge('KeyAuthKeys:' . ($secret ?? $_SESSION['app'])); + cache\purge('KeyAuthKey:' . ($secret ?? $_SESSION['app']) . ':' . $key); + } + } else { + return 'failure'; + } + } + return 'success'; +} + +function ban($key, $reason, $userToo, $secret = null) +{ + $key = etc\sanitize($key); + $reason = etc\sanitize($reason); + $userToo = etc\sanitize($userToo); + + if ($_SESSION['role'] == "Reseller") + { + $query = mysql\query("SELECT 1 FROM `keys` WHERE `app` = ? AND `key` = ? AND `genby` = ?", [$secret ?? $_SESSION['app'], $key, $_SESSION['username']]); + if ($query->num_rows === 0) + { + return 'nope'; + } + } + + if ($userToo) { + $query = mysql\query("SELECT `usedby` FROM `keys` WHERE `app` = ? AND `key` = ?", [$secret ?? $_SESSION['app'], $key]); + $row = mysqli_fetch_array($query->result); + $usedby = $row['usedby']; + + user\ban($usedby, $reason, $secret); + } + + $query = mysql\query("UPDATE `keys` SET `banned` = ?, `status` = 'Banned' WHERE `app` = ? AND `key` = ?",[$reason, $secret ?? $_SESSION['app'], $key]); + if ($query->affected_rows > 0) + { + if ($_SESSION['role'] == "seller" || !is_null($secret)) { + cache\purge('KeyAuthKeys:' . ($secret ?? $_SESSION['app'])); + } + + $query = mysql\query("UPDATE `tokens` SET `banned` = 1, `reason` = ? WHERE `app` = ? AND `assigned` = ? AND `type` = ?", [$reason, $secret ?? $_SESSION['app'], $key, "license"]); + if ($query->affected_rows > 0) { + cache\purgePattern('KeyAuthUserTokens:' . ($secret ?? $_SESSION['app'])); + } else { + return 'failure'; + } + return 'success'; + } + else + { + return 'failure'; + } +} +function unban($key, $secret = null) +{ + $key = etc\sanitize($key); + + if ($_SESSION['role'] == "Reseller") + { + $query = mysql\query("SELECT 1 FROM `keys` WHERE `app` = ? AND `key` = ? AND `genby` = ?",[$secret ?? $_SESSION['app'], $key, $_SESSION['username']]); + if ($query->num_rows === 0) + { + return 'nope'; + } + } + + $status = "Not Used"; + $query = mysql\query("SELECT `usedby` FROM `keys` WHERE `app` = ? AND `key` = ?",[$secret ?? $_SESSION['app'], $key]); + $row = mysqli_fetch_array($query->result); + if (!is_null($row['usedby'])) + { + $status = "Used"; + user\unban($row['usedby'], $secret); + } + + $query = mysql\query("UPDATE `keys` SET `banned` = NULL, `status` = ? WHERE `app` = ? AND `key` = ?",[$status, $secret ?? $_SESSION['app'], $key]);// update key from banned to its old status + if ($query->affected_rows > 0) + { + if ($_SESSION['role'] == "seller" || !is_null($secret)) + { + cache\purge('KeyAuthKeys:' . ($secret ?? $_SESSION['app'])); + } + + $query = mysql\query("UPDATE `tokens` SET `banned` = 0, `reason` = NULL WHERE `app` = ? AND `assigned` = ? AND `type` = ?", [$secret ?? $_SESSION['app'], $key, "license"]); + + if ($query->affected_rows > 0) { + cache\purgePattern('KeyAuthUserTokens:' . ($secret ?? $_SESSION['app'])); + } else { + return 'failure'; + } + return 'success'; + } + else + { + return 'failure'; + } +} \ No newline at end of file diff --git a/includes/misc/log.php b/includes/misc/log.php new file mode 100644 index 0000000..6fed3b6 --- /dev/null +++ b/includes/misc/log.php @@ -0,0 +1,16 @@ +affected_rows > 0) { + return 'success'; + } else { + return 'failure'; + } +} diff --git a/includes/misc/mysql.php b/includes/misc/mysql.php new file mode 100644 index 0000000..46d0283 --- /dev/null +++ b/includes/misc/mysql.php @@ -0,0 +1,74 @@ +ssl_set(NULL, NULL, "/etc/ssl/certs/ca-bundle.crt", NULL, NULL); + } + + $readOnlyConnection->real_connect($readOnlyRegions[$_SERVER['SERVER_ADDR']]["host"], $readOnlyRegions[$_SERVER['SERVER_ADDR']]["username"], $readOnlyRegions[$_SERVER['SERVER_ADDR']]["password"], $databaseName); + + if (!$readOnlyConnection) + die($readOnlyConnection->connect_error); + + $readOnlyConnection->set_charset('utf8'); + } + $connectionToUse = $readOnlyConnection; + } + else { + if (!$connection) { + $connection = new \mysqli(); + + if ($mysqlRequireSSL) { + $connection->ssl_set(NULL, NULL, "/etc/ssl/certs/ca-bundle.crt", NULL, NULL); + } + + $connection->real_connect($databaseHost, $databaseUsername, $databasePassword, $databaseName); + + if (!$connection) + die($connection->connect_error); + + $connection->set_charset('utf8'); + } + $connectionToUse = $connection; + } + + if ($types === null && $args !== []) + $types = str_repeat('s', count($args)); // unless otherwise specified, set type to string + + $stmt = $connectionToUse->prepare($query); + + if (!$stmt) + die($connectionToUse->error); + + if (strpos($query, '?') !== false) + $stmt->bind_param($types, ...$args); + + $stmt->execute(); + + $query = new \stdClass(); + $query->result = $stmt->get_result(); + $query->num_rows = $query->result->num_rows; + $query->affected_rows = $stmt->affected_rows; + + $stmt->close(); + + return $query; +} diff --git a/includes/misc/session.php b/includes/misc/session.php new file mode 100644 index 0000000..e9afaba --- /dev/null +++ b/includes/misc/session.php @@ -0,0 +1,53 @@ +affected_rows > 0) { + cache\purgePattern('KeyAuthState:' . ($secret ?? $_SESSION['app'])); + cache\purge('KeyAuthSessions:' . ($secret ?? $_SESSION['app'])); + return 'success'; + } else { + return 'failure'; + } +} +function killSingular($id, $secret = null) +{ + $id = etc\sanitize($id); + + $query = mysql\query("SELECT `ip` FROM `sessions` WHERE `app` = ? AND `id` = ?",[$secret ?? $_SESSION['app'], $id]); + $row = mysqli_fetch_array($query->result); + + $query = mysql\query("DELETE FROM `sessions` WHERE `app` = ? AND `id` = ?",[$secret ?? $_SESSION['app'], $id]); + if ($query->affected_rows > 0) { + global $cfZoneIdCache; + global $cfApiKeyCache; + + $appSecret = ($secret ?? $_SESSION['app']); + $sessionId = strtolower($id); + + $url = "https://api.cloudflare.com/client/v4/zones/{$cfZoneIdCache}/purge_cache"; + + $curl = curl_init($url); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); + curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode(array("files" => ["https://keyauth.win/api/KeyAuthState-{$appSecret}-{$sessionId}"]))); + + $headers = array( + "Authorization: Bearer {$cfApiKeyCache}", + "Content-Type: application/json", + ); + curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); + + curl_exec($curl); + cache\purge('KeyAuthState:' . ($secret ?? $_SESSION['app']) . ':' . $id); + return 'success'; + } else { + return 'failure'; + } +} diff --git a/includes/misc/sub.php b/includes/misc/sub.php new file mode 100644 index 0000000..b568c84 --- /dev/null +++ b/includes/misc/sub.php @@ -0,0 +1,84 @@ +affected_rows > 0) { + if ($_SESSION['role'] == "seller" || !is_null($secret)) { + cache\purge('KeyAuthSubscriptions:' . ($secret ?? $_SESSION['app'])); + } + return 'success'; + } else { + return 'failure'; + } +} +function deleteAll($secret = null){ + $query = mysql\query("DELETE FROM `subscriptions` WHERE `app` = ? AND `name` != ?",[$secret ?? $_SESSION['app'], "default"]); + if ($query->affected_rows > 0) { + if ($_SESSION['role'] == "seller" || !is_null($secret)) { + cache\purge('KeyAuthSubscriptions:' . ($secret ?? $_SESSION['app'])); + } + return 'success'; + } else { + return 'failure'; + } +} +function add($name, $level, $secret = null){ + $name = etc\sanitize($name); + $level = etc\sanitize($level); + + $query = mysql\query("SELECT 1 FROM `subscriptions` WHERE `name` = ? AND `app` = ?", [$name, $secret ?? $_SESSION['app']]); + + if ($query->num_rows > 0){ + return 'already_exists'; + } + + $query = mysql\query("INSERT INTO `subscriptions` (`name`, `level`, `app`) VALUES (?, ?, ?)",[$name , $level,$secret ?? $_SESSION['app']]); + if ($query->affected_rows > 0) { + if ($_SESSION['role'] == "seller" || !is_null($secret)) { + cache\purge('KeyAuthSubscriptions:' . ($secret ?? $_SESSION['app'])); + } + return 'success'; + } else { + return 'failure'; + } +} +function pause($subscription, $secret = null){ + $subscription = etc\sanitize($subscription); + $query = mysql\query("SELECT * FROM `subs` WHERE `app` = ? AND `expiry` > ? AND `subscription` = ?", [$secret ?? $_SESSION['app'], time(), $subscription], "sis"); + $updateQuery = NULL; + while ($row = mysqli_fetch_array($query->result)){ + $expires = $row['expiry']; + $exp = (int)$expires - time(); + $updateQuery = mysql\query("UPDATE `subs` SET `paused` = 1, `expiry` = ? WHERE `app` = ? AND `id` = ?", [$exp, $secret ?? $_SESSION['app'], $row['id']], "iss"); + } + if ($updateQuery->affected_rows > 0){ + cache\purge('KeyAuthSubs:' . $secret ?? $_SESSION['app'] . ':' . $subscription); + return 'success'; + } else { + return 'failure'; + } +} +function unpause($subscription, $secret = null){ + $subscription = etc\sanitize($subscription); + $query = mysql\query("SELECT * FROM `subs` WHERE `app` = ? AND `subscription` = ? AND `paused` = 1", [$secret ?? $_SESSION['app'], $subscription]); + $updateQuery = NULL; + while ($row = mysqli_fetch_array($query->result)){ + $expires = $row['expiry']; + $exp = (int)$expires + time(); + $updateQuery = mysql\query("UPDATE `subs` SET `paused` = 0, `expiry` = ? WHERE `app` = ? AND `id` = ?", [$exp, $secret ?? $_SESSION['app'], $row['id']], "iss"); + } + if ($updateQuery->affected_rows > 0){ + cache\purge('KeyAuthSubs:' . $secret ?? $_SESSION['app'] . ':' . $subscription); + return 'success'; + } else { + return 'failure'; + } +} \ No newline at end of file diff --git a/includes/misc/token.php b/includes/misc/token.php new file mode 100644 index 0000000..874a0d1 --- /dev/null +++ b/includes/misc/token.php @@ -0,0 +1,182 @@ +affected_rows < 1) { + return "failed"; + } + else { + return "success"; + } + + case 'License': + + $query = mysql\query("INSERT INTO `tokens` (`app`, `token`, `type`, `assigned`) VALUES (?, ?, ?, ?)", [$secret ?? $_SESSION["app"], $generated_token, "license", $credential]); + + if ($query->affected_rows < 1) { + return "failed"; + } + else { + return "success"; + } + + case 'UpdateToUser': + $query = mysql\query("UPDATE `tokens` SET `type` = ?, SET `assigned` = ? WHERE `app` = ? AND `token` = ?", ["user", $username, $secret ?? $_SESSION["app"], $token]); + + if ($query->affected_rows < 1) { + return "failed"; + } + else { + + cache\purge('KeyAuthUserTokens:' . $secret . ':' . $token); + + return "success"; + } + + case 'UpdateStatus': + + $query = mysql\query("UPDATE `tokens` SET `status` = ? WHERE `token` = ? AND `app` = ?", ["Used", $token, $secret ?? $_SESSION["app"]]); + + if ($query->affected_rows < 1) { + return "failed"; + } + else { + + cache\purge('KeyAuthUserTokens:'.$secret ?? $_SESSION["app"] . ':' . $token); + + return "success"; + } + + } + +} + +function checktoken($function, $token, $secret, $username = NULL, $token_hash = NULL) { + + $token = etc\sanitize($token); + + $row = cache\fetch('KeyAuthUserTokens:'.$secret.':'.$token ,"SELECT * FROM `tokens` WHERE `token` = ? AND `app` = ?", [$token, $secret], 0); + + if ($row === "not_found") { + return "invalid_token"; + } + + switch ($function) { + + case 'check_data': + + if ($row["banned"]) { + return "token_blacklisted, " . $row["reason"]; + } + + if (!is_null($row["hash"]) && $row["hash"] !== $token_hash) { + return "hash_mismatch"; + } + + if (is_null($row["hash"])) + { + mysql\query("UPDATE `tokens` SET `hash` = ? WHERE `token` = ? AND `app` = ?", [$token_hash, $token, $secret]); + cache\purge('KeyAuthUserTokens:'.$secret ?? $_SESSION["app"] . ':' . $token); + } + + return 'success'; + + case 'check_username': + + if (!is_null($username) && $row["assigned"] !== $username) { + return "token_reuse"; + } + } + + +} + +function addtokenblacklist($token, $reason, $secret = null) { + + $token = etc\sanitize($token); + + $reason = etc\sanitize($reason); + + $query = mysql\query("UPDATE `tokens` SET `reason` = ?, `status` = ? WHERE `token` = ? AND `app` = ?", [$reason, 1, $token, $secret ?? $_SESSION["app"]]); + cache\purge('KeyAuthUserTokens:'.$secret ?? $_SESSION["app"] . ':' . $token); + + + if ($query->affected_rows < 0) { + return "failed"; + } + + if ($query->affected_rows > 0) { + return "success"; + } + +} + +function removetokenblacklist($token, $secret = null) { + + $token = etc\sanitize($token); + + $query = mysql\query("UPDATE `tokens` SET `reason` = ?, `status` = ? WHERE `token` = ? AND `app` = ?", ["", 0, $token, $secret ?? $_SESSION["app"]]); + cache\purge('KeyAuthUserTokens:'.$secret ?? $_SESSION["app"] . ':' . $token); + + if ($query->affected_rows < 0) { + return "failed"; + } + + if ($query->affected_rows > 0) { + return "success"; + } + +} + +function resettokenhash($token, $secret = null) { + + $token = etc\sanitize($token); + + $query = mysql\query("UPDATE `tokens` SET `hash` = ? WHERE `token` = ? AND `app` = ?", [NULL, $token, $secret]); + cache\purge('KeyAuthUserTokens:'.$secret ?? $_SESSION["app"] . ':' . $token); + + if ($query->affected_rows < 0) { + return "failed"; + } + + if ($query->affected_rows > 1) { + return "success"; + } + +} + +?> \ No newline at end of file diff --git a/includes/misc/upload.php b/includes/misc/upload.php new file mode 100644 index 0000000..6258f38 --- /dev/null +++ b/includes/misc/upload.php @@ -0,0 +1,161 @@ + 10000000 && $_SESSION['role'] == "tester") { + return 'tester_file_exceed'; + } else if ($filesize > 50000000 && ($_SESSION['role'] == "developer" || $_SESSION['role'] == "Manager")) { + return 'dev_file_exceed'; + } else if ($filesize > 75000000) { + return 'seller_file_exceed'; + } + $id = etc\generateRandomNum(); + $fn = basename(parse_url($url, PHP_URL_PATH)); + $fs = etc\formatBytes($filesize); + + if (strlen($fn) > 49) { + return 'name_too_large'; + } + + $query = mysql\query("INSERT INTO `files` (name, id, url, size, uploaddate, app, authed) VALUES (?, ?, ?, ?, ?, ?, ?)", [$fn, $id, $url, $fs, time(), $secret ?? $_SESSION['app'], $authed]); + if ($query->affected_rows > 0) { + if ($_SESSION['role'] == "seller" || !is_null($secret)) { + cache\purge('KeyAuthFiles:' . ($secret ?? $_SESSION['app'])); + } + return 'success'; + } else { + return 'failure'; + } +} +function deleteAll($secret = null){ + $query = mysql\query("DELETE FROM `files` WHERE `app` = ?", [$secret ?? $_SESSION['app']]); + + if ($query->affected_rows > 0) { + cache\purgePattern('KeyAuthFile:' . ($secret ?? $_SESSION['app'])); + if ($_SESSION['role'] == "seller" || !is_null($secret)) { + cache\purge('KeyAuthFiles:' . ($secret ?? $_SESSION['app'])); + } + return 'success'; + } else { + return 'failure'; + } +} +function deleteSingular($file, $secret = null){ + $file = etc\sanitize($file); + + $query = mysql\query("DELETE FROM `files` WHERE `app` = ? AND `id` = ?", [$secret ?? $_SESSION['app'], $file]); + + if ($query->affected_rows > 0) { + cache\purge('KeyAuthFile:' . ($secret ?? $_SESSION['app']) . ':' . $file); + if ($_SESSION['role'] == "seller" || !is_null($secret)) { + cache\purge('KeyAuthFiles:' . ($secret ?? $_SESSION['app'])); + } + return 'success'; + } else { + return 'failure'; + } +} diff --git a/includes/misc/user.php b/includes/misc/user.php new file mode 100644 index 0000000..4fcdabf --- /dev/null +++ b/includes/misc/user.php @@ -0,0 +1,524 @@ +num_rows < 1) { + return 'nope'; + } + } + + $query = mysql\query("DELETE FROM `subs` WHERE `app` = ? AND `user` = ?", [$secret ?? $_SESSION['app'], $username]); + $query = mysql\query("DELETE FROM `uservars` WHERE `app` = ? AND `user` = ?", [$secret ?? $_SESSION['app'], $username]); + $query = mysql\query("DELETE FROM `tokens` WHERE `app` = ? AND `assigned` = ? AND `type` = ?", [$secret ?? $_SESSION['app'], $username, "user"]); + $query = mysql\query("DELETE FROM `users` WHERE `app` = ? AND `username` = ?", [$secret ?? $_SESSION['app'], $username]); + + if ($query->affected_rows > 0) { + cache\purge('KeyAuthUser:' . ($secret ?? $_SESSION['app']) . ':' . $username); + if ($_SESSION['role'] == "seller" || !is_null($secret)) { + cache\purge('KeyAuthUsernames:' . ($secret ?? $_SESSION['app'])); + cache\purge('KeyAuthUsers:' . ($secret ?? $_SESSION['app'])); + } + return 'success'; + } else { + return 'failure'; + } +} + +function setVariable($user, $var, $data, $secret = null, $readOnly = 0) +{ + $user = etc\sanitize($user); + $var = etc\sanitize($var); + $data = etc\sanitize($data); + $readOnly = intval($readOnly); + + if ($user == "all") { + $query = mysql\query("SELECT `username` FROM `users` WHERE `app` = ?", [$secret ?? $_SESSION['app']]); + if ($query->num_rows < 1) { + return 'missing'; + } + $rows = array(); + while ($r = mysqli_fetch_assoc($query->result)) { + $rows[] = $r; + } + foreach ($rows as $row) { + $query = mysql\query("REPLACE INTO `uservars` (`name`, `data`, `user`, `app`, `readOnly`) VALUES (?, ?, ?, ?, ?)", [$var, $data, $row['username'], $secret ?? $_SESSION['app'], $readOnly]); + } + cache\purgePattern('KeyAuthUserVar:' . ($secret ?? $_SESSION['app'])); + } else { + $query = mysql\query("REPLACE INTO `uservars` (`name`, `data`, `user`, `app`, `readOnly`) VALUES (?, ?, ?, ?, ?)", [$var, $data, $user, $secret ?? $_SESSION['app'], $readOnly]); + cache\purge('KeyAuthUserVar:' . ($secret ?? $_SESSION['app']) . ':' . $var . ':' . $user); + } + if ($query->affected_rows > 0) { + if ($_SESSION['role'] == "seller" || !is_null($secret)) { + cache\purge('KeyAuthUserVars:' . ($secret ?? $_SESSION['app'])); + } + return 'success'; + } else { + return 'failure'; + } +} +function ban($username, $reason, $secret = null) +{ + $username = etc\sanitize($username); + $reason = etc\sanitize($reason); + + if ($_SESSION['role'] == "Reseller") { + $query = mysql\query("SELECT 1 FROM `users` WHERE `app` = ? AND `username` = ? AND `owner` = ?", [$secret ?? $_SESSION['app'], $username, $_SESSION['username']]); + if ($query->num_rows < 1) { + return 'nope'; + } + } + + $query = mysql\query("SELECT * FROM `users` WHERE `app` = ? AND `username` = ?", [$secret ?? $_SESSION['app'], $username]); + if ($query->num_rows < 1) { + return 'missing'; + } + $row = mysqli_fetch_array($query->result); + $hwid = $row["hwid"]; + $ip = $row["ip"]; + $query = mysql\query("UPDATE `users` SET `banned` = ? WHERE `app` = ? AND `username` = ?", [$reason, $secret ?? $_SESSION['app'], $username]); + if (!is_null($hwid)) { + blacklist\add($hwid, "Hardware ID", ($secret ?? $_SESSION['app'])); + } + if (!is_null($ip)) { + blacklist\add($ip, "IP Address", ($secret ?? $_SESSION['app'])); + } + if ($query->affected_rows > 0) { + mysql\query("UPDATE `tokens` SET `banned` = ?, `reason` = ? WHERE `app` = ? AND `assigned` = ? AND `type` = ?", [1, $reason, $secret ?? $_SESSION['app'], $username, "user"]); + cache\purge('KeyAuthUser:' . ($secret ?? $_SESSION['app']) . ':' . $username); + cache\purge('KeyAuthUserTokens:' . ($secret ?? $_SESSION['app']) . ':' . token\IsAssignedToken($username, "user", $secret ?? $_SESSION["app"], true)); + if ($_SESSION['role'] == "seller" || !is_null($secret)) { + cache\purge('KeyAuthUsernames:' . ($secret ?? $_SESSION['app'])); + cache\purge('KeyAuthUsers:' . ($secret ?? $_SESSION['app'])); + } + return 'success'; + } else { + return 'failure'; + } +} +function pauseUser($username, $secret = null){ + $username = etc\sanitize($username); + $query = mysql\query("SELECT * FROM `subs` WHERE `app` = ? AND `expiry` > ? AND `user` = ?", [$secret ?? $_SESSION['app'], time(), $username], "sis"); + $updateQuery = NULL; + while ($row = mysqli_fetch_array($query->result)){ + $expires = $row['expiry']; + $exp = (int)$expires - time(); + $updateQuery = mysql\query("UPDATE `subs` SET `paused` = 1, `expiry` = ? WHERE `app` = ? AND `id` = ?", [$exp, $secret ?? $_SESSION['app'], $row['id']], "iss"); + } + if ($updateQuery->affected_rows > 0){ + cache\purge('KeyAuthSubs:' . $secret ?? $_SESSION['app'] . ':' . $username); + return 'success'; + } else { + return 'failure'; + } +} +function unpauseUser($username, $secret = null){ + $username = etc\sanitize($username); + $query = mysql\query("SELECT * FROM `subs` WHERE `app` = ? AND `user` = ? AND `paused` = 1", [$secret ?? $_SESSION['app'], $username]); + $updateQuery = NULL; + while ($row = mysqli_fetch_array($query->result)){ + $expires = $row['expiry']; + $exp = (int)$expires + time(); + $updateQuery = mysql\query("UPDATE `subs` SET `paused` = 0, `expiry` = ? WHERE `app` = ? AND `id` = ?", [$exp, $secret ?? $_SESSION['app'], $row['id']], "iss"); + } + if ($updateQuery->affected_rows > 0){ + cache\purge('KeyAuthSubs:' . $secret ?? $_SESSION['app'] . ':' . $username); + return 'success'; + } else { + return 'failure'; + } +} +function unban($username, $secret = null) +{ + $username = etc\sanitize($username); + + if ($_SESSION['role'] == "Reseller") { + $query = mysql\query("SELECT 1 FROM `users` WHERE `app` = ? AND `username` = ? AND `owner` = ?", [$secret ?? $_SESSION['app'], $username, $_SESSION['username']]); + if ($query->num_rows < 1) { + return 'nope'; + } + } + + $query = mysql\query("SELECT `hwid`, `ip` FROM `users` WHERE `app` = ? AND `username` = ?", [$secret ?? $_SESSION['app'], $username]); + if ($query->num_rows < 1) { + return 'missing'; + } + $row = mysqli_fetch_array($query->result); + $hwid = $row["hwid"]; + $ip = $row["ip"]; + cache\purgePattern('KeyAuthBlacklist:' . ($secret ?? $_SESSION['app']) . ':' . $ip); + if (!is_null($hwid)) { + cache\purgePattern('KeyAuthBlacklist:' . ($secret ?? $_SESSION['app']) . ':*:' . $hwid); + } + + $query = mysql\query("DELETE FROM `bans` WHERE `hwid` = ? OR `ip` = ? AND `app` = ?", [$hwid, $ip, $secret ?? $_SESSION['app']]); + $query = mysql\query("UPDATE `users` SET `banned` = NULL WHERE `app` = ? AND `username` = ?", [$secret ?? $_SESSION['app'], $username]); + if ($query->affected_rows > 0) { + mysql\query("UPDATE `tokens` SET `banned` = 0, `reason` = NULL WHERE `app` = ? AND `assigned` = ? AND `type` = ?", [$secret ?? $_SESSION['app'], $username, "user"]); + + cache\purge('KeyAuthUserTokens:' . ($secret ?? $_SESSION['app']) . ':' . token\IsAssignedToken($username, "user", $secret ?? $_SESSION["app"], true)); + cache\purge('KeyAuthUser:' . ($secret ?? $_SESSION['app']) . ':' . $username); + if ($_SESSION['role'] == "seller" || !is_null($secret)) { + cache\purge('KeyAuthUsernames:' . ($secret ?? $_SESSION['app'])); + cache\purge('KeyAuthUsers:' . ($secret ?? $_SESSION['app'])); + } + return 'success'; + } else { + return 'failure'; + } +} +function deleteVar($username, $var, $secret = null) +{ + $username = etc\sanitize($username); + $var = etc\sanitize($var); + + $query = mysql\query("DELETE FROM `uservars` WHERE `app` = ? AND `user` = ? AND `name` = ?", [$secret ?? $_SESSION['app'], $username, $var]); + if ($query->affected_rows > 0) { + cache\purge('KeyAuthUserVar:' . ($secret ?? $_SESSION['app']) . ':' . $var . ':' . $username); + if ($_SESSION['role'] == "seller" || !is_null($secret)) { + cache\purge('KeyAuthUserVars:' . ($secret ?? $_SESSION['app'])); + } + return 'success'; + } else { + return 'failure'; + } +} +function deleteSub($username, $sub, $secret = null) +{ + $username = etc\sanitize($username); + $sub = etc\sanitize($sub); + + $query = mysql\query("DELETE FROM `subs` WHERE `app` = ? AND `user` = ? AND `subscription` = ?", [$secret ?? $_SESSION['app'], $username, $sub]); + + if ($query->affected_rows > 0) { + cache\purge('KeyAuthSubs:' . ($secret ?? $_SESSION['app']) . ':' . $username); + return 'success'; + } else { + return 'failure'; + } +} +function extend($username, $sub, $expiry, $activeOnly = 0, $secret = null) +{ + $username = etc\sanitize($username); + $sub = etc\sanitize($sub); + $expiry = etc\sanitize($expiry); + + $query = mysql\query("SELECT 1 FROM `subscriptions` WHERE `name` = ? AND `app` = ?", [$sub, $secret ?? $_SESSION['app']]); + if ($query->num_rows < 1) { + return 'sub_missing'; + } else if ($expiry < time()) { + return 'date_past'; + } + if ($username == "all") { + if (!$activeOnly) { + $query = mysql\query("SELECT `username` FROM `users` WHERE `username` NOT IN (SELECT `user` FROM `subs` WHERE `subscription` = ? AND `expiry` > ? AND `app` = ?) AND `app` = ?", [$sub, time(), $secret ?? $_SESSION['app'], $secret ?? $_SESSION['app']]); + + $rows = array(); + while ($r = mysqli_fetch_assoc($query->result)) { + $rows[] = $r; + } + foreach ($rows as $row) { + $query = mysql\query("INSERT INTO `subs` (`user`, `subscription`, `expiry`, `app`) VALUES (?, ?, ?, ?)", [$row['username'], $sub, $expiry, $secret ?? $_SESSION['app']]); + } + } + $appendExpiry = $expiry - time(); + $query = mysql\query("UPDATE `subs` SET `expiry` = `expiry`+? WHERE `subscription` = ? AND `expiry` > " . time() . " AND `app` = ?", [$appendExpiry, $sub, $secret ?? $_SESSION['app']]); + + cache\purgePattern('KeyAuthSubs:' . ($secret ?? $_SESSION['app'])); + } else { + $query = mysql\query("SELECT `username` FROM `users` WHERE `username` = ? AND `app` = ?", [$username, $secret ?? $_SESSION['app']]); + + if ($query->num_rows < 1) { + return 'missing'; + } + $query = mysql\query("SELECT `id` FROM `subs` WHERE `user` = ? AND `subscription` = ? AND `expiry` > " . time() . " AND `app` = ?", [$username, $sub, $secret ?? $_SESSION['app']]); + + if ($query->num_rows > 0) { + $appendExpiry = $expiry - time(); + $query = mysql\query("UPDATE `subs` SET `expiry` = `expiry`+? WHERE `user` = ? AND `subscription` = ? AND `app` = ?", [$appendExpiry, $username, $sub, $secret ?? $_SESSION['app']]); + } else { + $query = mysql\query("INSERT INTO `subs` (`user`, `subscription`, `expiry`, `app`) VALUES (?, ?, ?, ?)", [$username, $sub, $expiry, $secret ?? $_SESSION['app']]); + } + cache\purge('KeyAuthSubs:' . ($secret ?? $_SESSION['app']) . ':' . $username); + } + if ($query->affected_rows > 0) { + return 'success'; + } else { + return 'failure'; + } +} +function subtract($username, $sub, $seconds, $secret = null) +{ + $username = etc\sanitize($username); + $sub = etc\sanitize($sub); + $seconds = etc\sanitize($seconds); + + if ($seconds <= 0) { + return 'invalid_seconds'; + } + + if ($username == "all") { + $query = mysql\query("UPDATE `subs` SET `expiry` = `expiry`-? WHERE `subscription` = ? AND `app` = ?", [$seconds, $sub, $secret ?? $_SESSION['app']]); + } else { + $query = mysql\query("UPDATE `subs` SET `expiry` = `expiry`-? WHERE `user` = ? AND `subscription` = ? AND `app` = ?", [$seconds, $username, $sub, $secret ?? $_SESSION['app']]); + } + + if ($query->affected_rows > 0) { + cache\purge('KeyAuthSubs:' . ($secret ?? $_SESSION['app']) . ':' . $username); + return 'success'; + } else { + return 'failure'; + } +} +function add($username, $sub, $expiry, $secret = null, $password = null) +{ + $username = etc\sanitize($username); + $query = mysql\query("SELECT 1 FROM `users` WHERE `username` = ? AND `app` = ?", [$username, $secret ?? $_SESSION['app']]); + + if ($query->num_rows > 0) { + return 'already_exist'; + } + + if (strtolower($username) === "all" || strtoupper($username) === "ALL"){ + return 'username_not_allowed'; + } + + if (!empty($password)) + $password = password_hash(etc\sanitize($password), PASSWORD_BCRYPT); + + $sub = etc\sanitize($sub); + $expiry = etc\sanitize($expiry); + + $query = mysql\query("SELECT 1 FROM `subscriptions` WHERE `name` = ? AND `app` = ?", [$sub, $secret ?? $_SESSION['app']]); + + if ($query->num_rows < 1) { + return 'sub_missing'; + } else if ($expiry < time()) { + return 'date_past'; + } + + $subQuery = mysql\query("SELECT * FROM `subs` WHERE `subscription` = ? AND `paused` = 1 AND `app` = ?", [$sub, $secret ?? $_SESSION['app']]); + if ($subQuery->num_rows > 0) { + return 'sub_paused'; + } + + $query = mysql\query("INSERT INTO `subs` (`user`, `subscription`, `expiry`, `app`) VALUES (?, ?, ?, ?)", [$username, $sub, $expiry, $secret ?? $_SESSION['app']]); + $query = mysql\query("INSERT INTO `users` (`username`, `password`, `hwid`, `app`,`owner`,`createdate`) VALUES (?, NULLIF(?, ''), NULL, ?, ?, ?);", [$username, $password, $secret ?? $_SESSION['app'], $_SESSION['username'] ?? 'SellerAPI', time()]); + if ($query->affected_rows > 0) { + if ($_SESSION['role'] == "seller" || !is_null($secret)) { + cache\purge('KeyAuthUsernames:' . ($secret ?? $_SESSION['app'])); + cache\purge('KeyAuthUsers:' . ($secret ?? $_SESSION['app'])); + cache\purge('KeyAuthUser:' . ($secret ?? $_SESSION['app']) . ':' . $username); + } + if (token\ModifyUserToken($username, "User") === "failed") { return "failure"; } + return 'success'; + } else { + return 'failure'; + } +} +function deleteExpiredUsers($secret = null) +{ + $query = mysql\query("SELECT `username` FROM `users` WHERE `app` = ?", [$secret ?? $_SESSION['app']]); + + if ($query->num_rows < 1) { + return 'missing'; + } + $rows = array(); + while ($r = mysqli_fetch_assoc($query->result)) { + $rows[] = $r; + } + $success = 0; + foreach ($rows as $row) { + $query = mysql\query("SELECT 1 FROM `subs` WHERE `user` = ? AND `app` = ? AND `expiry` > ?", [$row['username'], $secret ?? $_SESSION['app'], time()]); + + if ($query->num_rows < 1) { + $success = 1; + $query = mysql\query("DELETE FROM `users` WHERE `app` = ? AND `username` = ?", [$secret ?? $_SESSION['app'], $row['username']]); + cache\purge('KeyAuthUser:' . ($secret ?? $_SESSION['app']) . ':' . $row['username']); + } + } + if ($success) { + if ($_SESSION['role'] == "seller" || !is_null($secret)) { + cache\purge('KeyAuthUsernames:' . ($secret ?? $_SESSION['app'])); + cache\purge('KeyAuthUsers:' . ($secret ?? $_SESSION['app'])); + } + $query = mysql\query("DELETE FROM `tokens` WHERE `app` = ? AND `assigned` = ? AND `type` = ?", [$secret ?? $_SESSION['app'], $row['username'], "user"]); + if ($query->affected_rows >= 0) { cache\purgePattern('KeyAuthUserTokens:' . ($secret ?? $_SESSION['app'])); } else { return "failure"; } + return 'success'; + } else { + return 'failure'; + } +} +function deleteAll($secret = null) +{ + $query = mysql\query("DELETE FROM `users` WHERE `app` = ?", [$secret ?? $_SESSION['app']]); + if ($query->affected_rows > 0) { + cache\purgePattern('KeyAuthUser:' . ($secret ?? $_SESSION['app'])); + if ($_SESSION['role'] == "seller" || !is_null($secret)) { + cache\purge('KeyAuthUsernames:' . ($secret ?? $_SESSION['app'])); + cache\purge('KeyAuthUsers:' . ($secret ?? $_SESSION['app'])); + } + $query = mysql\query("DELETE FROM `tokens` WHERE `app` = ? AND `type` = ?", [$secret ?? $_SESSION['app'], "user"]); + + if ($query->affected_rows >= 0) { cache\purgePattern('KeyAuthUserTokens:' . ($secret ?? $_SESSION['app'])); } else { return "failure"; } + return 'success'; + } else { + return 'failure'; + } +} +function resetSingular($username, $secret = null) +{ + $username = etc\sanitize($username); + + if ($_SESSION['role'] == "Reseller") { + $query = mysql\query("SELECT 1 FROM `users` WHERE `app` = ? AND `username` = ? AND `owner` = ?", [$secret ?? $_SESSION['app'], $username, $_SESSION['username']]); + if ($query->num_rows < 1) { + return 'nope'; + } + } + + $query = mysql\query("UPDATE `users` SET `hwid` = NULL WHERE `app` = ? AND `username` = ?", [$secret ?? $_SESSION['app'], $username]); + if ($query->affected_rows > 0) { + cache\purge('KeyAuthUser:' . ($secret ?? $_SESSION['app']) . ':' . $username); + if ($_SESSION['role'] == "seller" || !is_null($secret)) { + cache\purge('KeyAuthUsernames:' . ($secret ?? $_SESSION['app'])); + cache\purge('KeyAuthUsers:' . ($secret ?? $_SESSION['app'])); + } + + $query = mysql\query("UPDATE `tokens` SET `hash` = NULL WHERE `app` = ? AND `type` = ?", [$secret ?? $_SESSION['app'], "user"]); + if ($query->affected_rows >= 0) { + cache\purgePattern('KeyAuthUserTokens:' . ($secret ?? $_SESSION['app'])); + } else { + return "failure"; + } + return 'success'; + } else { + return 'failure'; + } +} +function resetAll($secret = null) +{ + $query = mysql\query("UPDATE `users` SET `hwid` = NULL WHERE `app` = ?", [$secret ?? $_SESSION['app']]); + if ($query->affected_rows > 0) { + cache\purgePattern('KeyAuthUser:' . ($secret ?? $_SESSION['app'])); + if ($_SESSION['role'] == "seller" || !is_null($secret)) { + cache\purge('KeyAuthUsernames:' . ($secret ?? $_SESSION['app'])); + cache\purge('KeyAuthUsers:' . ($secret ?? $_SESSION['app'])); + } + + $query = mysql\query("UPDATE `tokens` SET `hash` = NULL WHERE `app` = ? AND `type` = ?", [$secret ?? $_SESSION['app'], "user"]); + if ($query->affected_rows >= 0) { + cache\purgePattern('KeyAuthUserTokens:' . ($secret ?? $_SESSION['app'])); + } else { + return "failure"; + } + return 'success'; + } else { + return 'failure'; + } +} +function unbanAll($secret = null) +{ + $query = mysql\query("UPDATE `users` SET `banned` = NULL WHERE `app` = ?", [$secret ?? $_SESSION['app']]); + if ($query->affected_rows > 0) { + cache\purgePattern('KeyAuthUser:' . ($secret ?? $_SESSION['app'])); + if ($_SESSION['role'] == "seller" || !is_null($secret)) { + cache\purge('KeyAuthUsernames:' . ($secret ?? $_SESSION['app'])); + cache\purge('KeyAuthUsers:' . ($secret ?? $_SESSION['app'])); + } + $query = mysql\query("UPDATE `tokens` SET `banned` = 0, `reason` = NULL WHERE `app` = ?", [$secret ?? $_SESSION['app']]); + + if ($query->affected_rows >= 0) { cache\purgePattern('KeyAuthUserTokens:' . ($secret ?? $_SESSION['app'])); } else { return "failure"; } + return 'success'; + } else { + return 'failure'; + } +} +function changeUsername($oldUsername, $newUsername, $secret = null) +{ + $oldUsername = etc\sanitize($oldUsername); + $newUsername = etc\sanitize($newUsername); + + $query = mysql\query("SELECT 1 FROM `users` WHERE `username` = ? AND `app` = ?", [$newUsername, $secret ?? $_SESSION['app']]); + if ($query->num_rows > 0) { + return 'already_used'; + } + $query = mysql\query("UPDATE `users` SET `username` = ? WHERE `username` = ? AND `app` = ?", [$newUsername, $oldUsername, $secret ?? $_SESSION['app']]); + if ($query->affected_rows > 0) { + mysql\query("UPDATE `subs` SET `user` = ? WHERE `user` = ? AND `app` = ?", [$newUsername, $oldUsername, $secret ?? $_SESSION['app']]); + mysql\query("UPDATE `uservars` SET `user` = ? WHERE `user` = ? AND `app` = ?", [$newUsername, $oldUsername, $secret ?? $_SESSION['app']]); + mysql\query("UPDATE `chatmsgs` SET `author` = ? WHERE `author` = ? AND `app` = ?", [$newUsername, $oldUsername, $secret ?? $_SESSION['app']]); + mysql\query("UPDATE `keys` SET `usedby` = ? WHERE `usedby` = ? AND `app` = ?", [$newUsername, $oldUsername, $secret ?? $_SESSION['app']]); + mysql\query("UPDATE `tokens` SET `assigned` = ? WHERE `assigned` = ? AND `app` = ?", [$newUsername, $oldUsername, $secret ?? $_SESSION['app']]); + cache\purge('KeyAuthUser:' . ($secret ?? $_SESSION['app']) . ':' . $oldUsername); + cache\purge('KeyAuthSubs:' . ($secret ?? $_SESSION['app']) . ':' . $oldUsername); + if ($_SESSION['role'] == "seller" || !is_null($secret)) { + cache\purge('KeyAuthUsernames:' . ($secret ?? $_SESSION['app'])); + cache\purge('KeyAuthUsers:' . ($secret ?? $_SESSION['app'])); + } + return 'success'; + } else { + return 'failure'; + } +} +function changePassword($username, $password, $secret = null) +{ + $username = etc\sanitize($username); + $password = etc\sanitize($password); + + $query = mysql\query("UPDATE `users` SET `password` = ? WHERE `username` = ? AND `app` = ?", [password_hash($password, PASSWORD_BCRYPT), $username, $secret ?? $_SESSION['app']]); + if ($query->affected_rows > 0) { + cache\purge('KeyAuthUser:' . ($secret ?? $_SESSION['app']) . ':' . $username); + if ($_SESSION['role'] == "seller" || !is_null($secret)) { + cache\purge('KeyAuthUsers:' . ($secret ?? $_SESSION['app'])); + cache\purge('KeyAuthUserData:' . $_SESSION['app'] . ':' . $username); + } + return 'success'; + } else { + return 'failure'; + } +} +function changeEmail($username, $email, $secret = null){ + $username = etc\sanitize($username); + $email = etc\sanitize($email); + + $query = mysql\query("UPDATE `users` SET `email` = SHA1(LOWER(?)) WHERE `username` = ? AND `app` = ?", [$email, $username, $secret ?? $_SESSION['app']]); + if ($query->affected_rows > 0){ + cache\purge('KeyAuthUser:' . ($secret ?? $_SESSION['app']) . ':' . $username); + if ($_SESSION['role'] == "seller" || !is_null($secret)){ + cache\purge('KeyAuthUsers:' . ($secret ?? $_SESSION['app'])); + } + return 'success'; + } else { + return 'failure'; + } +} +function disable2fa($username, $secret = null) { + + $username = etc\sanitize($username); + + $query = mysql\query("UPDATE `users` SET `googleAuthCode` = NULL, `2fa` = 0 WHERE `username` = ? AND `app` = ?", [$username, $secret ?? $_SESSION['app']]); + if ($query->affected_rows > 0) { + cache\purge('KeyAuthUser:' . ($secret ?? $_SESSION['app']) . ':' . $username); + if ($_SESSION['role'] == "seller" || !is_null($secret)) { + cache\purge('KeyAuthUsers:' . ($secret ?? $_SESSION['app'])); + } + return 'success'; + } else { + return 'failure'; + } + +} + diff --git a/includes/misc/variable.php b/includes/misc/variable.php new file mode 100644 index 0000000..337d696 --- /dev/null +++ b/includes/misc/variable.php @@ -0,0 +1,101 @@ + 1000) { + return 'too_long'; + } + + $name_check = mysql\query("SELECT 1 FROM `vars` WHERE `varid` = ? AND `app` = ?",[$name, $secret ?? $_SESSION['app']]); + if ($name_check->num_rows > 0) { + return 'exists'; + } + $query = mysql\query("INSERT INTO `vars`(`varid`, `msg`, `app`, `authed`) VALUES (?, ?, ?, ?)",[$name, $data,$secret ?? $_SESSION['app'], $authed]); + if ($query->affected_rows > 0) { + if ($_SESSION['role'] == "seller" || !is_null($secret)) { + cache\purge('KeyAuthVars:' . ($secret ?? $_SESSION['app'])); + } + return 'success'; + } else { + return 'failure'; + } +} +function deleteAll($secret = null) +{ + $query = mysql\query("DELETE FROM `vars` WHERE `app` = ?",[$secret ?? $_SESSION['app']]); + if ($query->affected_rows > 0) { + cache\purgePattern('KeyAuthVar:' . ($secret ?? $_SESSION['app'])); + if ($_SESSION['role'] == "seller" || !is_null($secret)) { + cache\purge('KeyAuthVars:' . ($secret ?? $_SESSION['app'])); + } + return 'success'; + } else { + return 'failure'; + } +} +function deleteSingular($var, $secret = null) +{ + $var = etc\sanitize($var); + + $query = mysql\query("DELETE FROM `vars` WHERE `app` = ? AND `varid` = ?",[$secret ?? $_SESSION['app'], $var]); + if ($query->affected_rows > 0) { + cache\purge('KeyAuthVar:' . ($secret ?? $_SESSION['app']) . ':' . $var); + if ($_SESSION['role'] == "seller" || !is_null($secret)) { + cache\purge('KeyAuthVars:' . ($secret ?? $_SESSION['app'])); + } + return 'success'; + } else { + return 'failure'; + } +} +function edit($name, $data, $authed, $secret = null) +{ + $name = etc\sanitize($name); + $data = etc\sanitize($data); + $authed = etc\sanitize($authed); + + if(strlen($data) > 1000) { + return 'too_long'; + } + + $query = mysql\query("UPDATE `vars` SET `msg` = ?, `authed` = ? WHERE `varid` = ? AND `app` = ?",[$data, $authed, $name, $secret ?? $_SESSION['app']]); + if ($query->affected_rows > 0) { + global $cfZoneIdCache; + global $cfApiKeyCache; + + $appSecret = ($secret ?? $_SESSION['app']); + $varId = strtolower($name); + + $url = "https://api.cloudflare.com/client/v4/zones/{$cfZoneIdCache}/purge_cache"; + + $curl = curl_init($url); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); + curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode(array("files" => ["https://keyauth.win/api/KeyAuthVar-{$appSecret}-{$varId}"]))); + + $headers = array( + "Authorization: Bearer {$cfApiKeyCache}", + "Content-Type: application/json", + ); + curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); + + curl_exec($curl); + + cache\purge('KeyAuthVar:' . ($secret ?? $_SESSION['app']) . ':' . $name); + if ($_SESSION['role'] == "seller" || !is_null($secret)) { + cache\purge('KeyAuthVars:' . ($secret ?? $_SESSION['app'])); + } + return 'success'; + } else { + return 'failure'; + } +} diff --git a/includes/misc/webhook.php b/includes/misc/webhook.php new file mode 100644 index 0000000..5639adf --- /dev/null +++ b/includes/misc/webhook.php @@ -0,0 +1,51 @@ +affected_rows > 0) { + return 'success'; + } else { + return 'failure'; + } +} +function deleteSingular($webhook, $secret = null){ + $webhook = etc\sanitize($webhook); + + $query = mysql\query("DELETE FROM `webhooks` WHERE `app` = ? AND `webid` = ?",[$secret ?? $_SESSION['app'], $webhook]); + if ($query->affected_rows > 0) { + cache\purge('KeyAuthWebhook:' . ($secret ?? $_SESSION['app']) . ':' . $webhook); + return 'success'; + } else { + return 'failure'; + } +} + +function deleteAll($secret = null){ + $query = mysql\query("DELETE FROM `webhooks` WHERE `app` = ?", [$secret ?? $_SESSION['app']]); + if ($query->affected_rows > 0){ + cache\purge('KeyAuthWebhook:' . ($secret ?? $_SESSION['app'])); + return 'success'; + } else { + return 'failure'; + } +} diff --git a/includes/misc/whitelist.php b/includes/misc/whitelist.php new file mode 100644 index 0000000..dd87571 --- /dev/null +++ b/includes/misc/whitelist.php @@ -0,0 +1,50 @@ +affected_rows > 0) { + return 'success'; + } else { + return 'failure'; + } +} + +function deleteWhite($ip, $secret = null) +{ + $ip = etc\sanitize($ip); + + $query = mysql\query("DELETE FROM `whitelist` WHERE `app` = ? AND `ip` = ?",[$secret ?? $_SESSION['app'], $ip]); + cache\purge('KeyAuthWhitelist:' . ($secret ?? $_SESSION['app']) . ':' . $ip); + + if ($query->affected_rows > 0) { + return 'success'; + } else { + return 'failure'; + } +} + +function deleteAll($secret = null){ + $query = mysql\query("DELETE FROM `whitelist` WHERE `app` = ?", [$secret ?? $_SESSION['app']]); + + if ($query->affected_rows > 0){ + cache\purgePattern('KeyAuthWhitelist:' . ($secret ?? $_SESSION['app'])); + if ($_SESSION['role'] == "seller" || !is_null($secret)) { + cache\purge('KeyAuthWhitelist:' . ($secret ?? $_SESSION['app'])); + } + return 'success'; + } else { + return 'failure'; + } +} diff --git a/includes/redis.php b/includes/redis.php new file mode 100644 index 0000000..f2affcd --- /dev/null +++ b/includes/redis.php @@ -0,0 +1,15 @@ +
Or if your configuration can\'t install Redis, remove code containing Redis from /includes/misc/cache.php'); +} + +$redis = new Redis(); +$redis->connect('localhost', 6380, 10); + +global $redisPass; + +if(!empty($redisPass)) { + $redis->auth($redisPass); +} diff --git a/index.html b/index.html new file mode 100644 index 0000000..582a173 --- /dev/null +++ b/index.html @@ -0,0 +1,1646 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + KeyAuth - Open Source Auth + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+
+
+
+ + + Join US! + + Apply for support, enjoy unlimited seller subscription while on staff. + + + + + +

+ Unleashing the Ultimate Power of Authentication +

+

+ KeyAuth Seamlessly Blends Cloud-Powered Subscription Hosting with an Open-Source Foundation. +

+ + Onboard Now + + + + + + Client Area + +
+
+ +
+
+ +
+
+
+
+
+
+ +
+
+
+
+ + + + +
+

+ Server-Side Webhooks & Variables +

+

+ Private Webhooks, Secure Server-side File Management, and Protected Variables. +

+
+
+
+ + + +
+

+ Privacy First +

+

+ We prioritize your needs, your users, and the sanctity of your data. +

+
+
+
+ + + + +
+

+ Open-Source +

+

+ KeyAuth operates as open-source, granting you full transparency into its functionalities. +

+
+
+
+
+
+ +
+
+ +
+

+ Craft Secure + and Reliable + Applications with KeyAuth +

+

+ KeyAuth is a cloud-based subscription authentication platform that allows you to implement + authentication into your software, website, or application with ease. +

+
+
+
+ +
+
+
+
+

+ KeyAuth is the Ultimate + Authentication Solution +

+
+
+
+
+

+ 0 +

+

+ Accounts +

+
+
+

+ 0 +

+

+ Applications +

+
+
+

+ 0 +

+

+ Licenses +

+
+
+

+ 0 +

+

+ Users Logged In +

+
+
+
+
+
+
+ +
+
+
+

+ Control Everything + with the Mobile App. +

+

+ KeyAuth's mobile app allows you to do anything from anywhere. Manage your users, view your logs, and + more. +

+ +
+ + +
+
+ +
+
+
+

Pricing Options

+

We offer a variety of plans to suit your + needs.

+ +
+ +
+
+
+
+
+
+
+

Tester

+
+
+

+ $ +

+

+ Limited Access for those looking to experiment implementing KeyAuth +

+
+
+
    +
  • + + + + +

    + Users: 10 +

    +
  • +
  • + + + + +

    + Upload Files: (10 MB) +

    +
  • +
  • + + + + +

    + Global Variables: 5 +

    +
  • +
  • + + + + +

    + User Variables +

    +
  • +
  • + + + + +

    + Logs (includes Discord logs): 20 +

    +
  • +
  • + + + + +

    + Hardware/IP Blacklist/Whitelist +

    +
  • +
  • + + + + +

    + Web Loader +

    +
  • +
  • + + + + +

    + Chatrooms +

    +
  • +
  • + + + + +

    + Create Webhooks +

    +
  • +
  • + + + + +

    + Reseller & Manager Access +

    +
  • +
  • + + + + +

    + SellerAPI Access +

    +
  • +
  • + + + + +

    + Discord Bot +

    +
  • +
+ + + +

No credit card required

+
+
+ +
+
+
+
+

Developer

+
+
+

+ $ +

+

+ Ample limits plus full access to reseller system. Most folks start here. +

+
+
+
    +
  • + + + + +

    + Users: Unlimited +

    +
  • +
  • + + + + +

    + Upload Files: (50 MB) +

    +
  • +
  • + + + + +

    + Global Variables: Unlimited +

    +
  • +
  • + + + + +

    + User Variables +

    +
  • +
  • + + + + +

    + Logs (includes Discord logs): Unlimited +

    +
  • +
  • + + + + +

    + Hardware/IP Blacklist/Whitelist +

    +
  • +
  • + + + + +

    + Web Loader +

    +
  • +
  • + + + + +

    + Chatrooms +

    +
  • +
  • + + + + +

    + Create Webhooks +

    +
  • +
  • + + + + +

    + Reseller & Manager Access +

    +
  • +
  • + + + + +

    + SellerAPI Access +

    +
  • +
  • + + + + +

    + Discord Bot +

    +
  • +
+ + + Purchase Developer Now + +
+
+ +
+
+
+
+

Seller

+
+
+

+ $ +

+

+ Full-fledged supporter, we appreciate you for keeping our servers running! +

+
+
+
    +
  • + + + + +

    + Users: Unlimited +

    +
  • +
  • + + + + +

    + Upload Files: (75 MB) +

    +
  • +
  • + + + + +

    + Global Variables: Unlimited +

    +
  • +
  • + + + + +

    + User Variables +

    +
  • +
  • + + + + +

    + Logs (includes Discord logs): Unlimited +

    +
  • +
  • + + + + +

    + Hardware/IP Blacklist/Whitelist +

    +
  • +
  • + + + + +

    + Web Loader +

    +
  • +
  • + + + + +

    + Chatrooms +

    +
  • +
  • + + + + +

    + Create Webhooks +

    +
  • +
  • + + + + +

    + Reseller & Manager Access +

    +
  • +
  • + + + + +

    + SellerAPI Access +

    +
  • +
  • + + + + +

    + Discord Bot +

    +
  • +
+ + + Purchase Seller Now + +
+
+ +
+
+
+
+

Enterprise (Source + Code)

+
+
+

+ $79.99 / One-Time +

+

+ Opt for large-scale projects at $79.99 one-time cost.
Access paid KeyAuth + features' source code, one-on-one setup support, and more. +

+
+
+
    +
  • + + + + +

    + Cloud Hosted Subscription (KeyAuth Servers) +

    +
  • +
  • + + + + +

    + Source code of paid KeyAuth features +

    +
  • +
  • + + + + +

    + One-on-one setup support +

    +
  • +
  • + + + + +

    + Tutorial video showing how to host KeyAuth for 100% free +

    +
  • +
+ + + Purchase Enterprise Now + +
+
+
+
+
+ +
+
+
+

Our + integrations +

+

Explore seamless integrations + effortlessly linking with widely-used systems.

+
+ +
+
+ +
+
+
+
+
+ + + + + + + + + +

+ HMAC Signature Check +

+

+ Ensuring data integrity, we employ HMAC signature checks to verify the authenticity of + requests. +

+
+
+
+
+ + + + + +

+ Multi Layered Blacklist Options +

+

+ Tailor your security with IP, HWID, and token blacklist options, providing a comprehensive + shield against unauthorized access. +

+
+
+
+
+ + + + + +

+ Data Protection & Encryption +

+

+ We hash emails upon registration and never store passwords in plaintext, safeguarding your + information. +

+
+
+
+
+
+ +
+
+
+
+

+ Our Team +

+

+ We are a team of developers who are passionate about creating the best authentication solution + for you. +

+
+ +
+
+ +
+
+

+ IT'S Networking +

+

+ CEO & Full Stack Developer +

+
+
+
+ +
+ +
+
+

+ Shxde +

+

+ Admin & Support +

+
+
+
+ +
+ +
+
+

+ mazkdevf +

+

+ Full Stack Developer +

+
+
+
+
+
+
+
+ +
+
+
+

+ Partners & Verified Developers +

+

+ We are proud to have partnered with these amazing developers and projects. +

+
+
+
+
+
+
+ ... +

+ SellSN +

+ + + 0% Fees + + Sell Software + + + Stripe Alternative + + +
+ +
+ +

+ Create a website in just 1 minute and start selling software, accounts, or any products with 0% fees! Enjoy full support from our team and seamless integration with KeyAuth to streamline your business operations. +

+
+
+ +
+ + + + + +
+
+
+
+
+ + ... + +

+ VaultCord +

+ + Discord + Bot + Restore + members + Better + than RestoreCord + +
+ +
+ +

+ Discord Recovery Service to restore your Discord Guild & its Members. Backup server, members, channels, messages & more. Custom verify page, block alt accounts, VPNs & more. Try now for FREE! +

+
+
+ +
+ + + + + +
+
+
+
+ + + + + + + + + + + + + + + + + + diff --git a/login/index.php b/login/index.php new file mode 100644 index 0000000..fd47998 --- /dev/null +++ b/login/index.php @@ -0,0 +1,635 @@ +getMessage()); + \dashboard\primary\error($errorMsg); +}); + +$istwofa = $_SESSION["temp_istwofamode"] ? true : false; + +?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + KeyAuth - Login + + + + + + + + + + + + + + + + + + +
+ +
+
+ +
+ +
+
+
+
+

+ Welcome back to KeyAuth + 👋 +

+ +

+ Seamless authentication for a more secure and user-friendly experience. +

+
+
+
+
+
+ + + + + + + + +
+ + +
+ + + + + + + + + + + + +
+
+ or +
+
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ + + +
+ Forgot your password? Reset + It Now! +
+ +
+ Need an Account? Register +
+ +
+
+
+
+
+ + + + + + + + + + + num_rows < 1) { + dashboard\primary\error("Account doesn't exist!"); + return; + } + while ($row = mysqli_fetch_array($query->result)) { + $user = $row['username']; + $pass = $row['password']; + $id = $row['ownerid']; + $email = $row['email']; + $role = $row['role']; + $app = misc\etc\sanitize($row['app']); + $banned = $row['banned']; + $locked = $row['locked']; + $img = $row['img']; + + $owner = misc\etc\sanitize($row['owner']); + $twofactor_optional = $row['twofactor']; + $acclogs = $row['acclogs']; + $google_Code = $row['googleAuthCode']; + + $regionSaved = $row['region']; + $asNumSaved = $row['asNum']; + $emailVerify = $row['emailVerify']; + $securityKey = $row['securityKey']; + } + + if (!is_null($banned)) { + dashboard\primary\error("Banned: Reason: " . misc\etc\sanitize($banned)); + return; + } + + if (!password_verify($password, $pass)) { + dashboard\primary\error("Password is invalid!"); + return; + } + + if ($locked) { + header("location: ./accShare/"); + die(); + } + + if (misc\etc\isBreached($password)) { + dashboard\primary\wh_log($logwebhook, "{$username} attempted to login with leaked password `{$password}`", $webhookun, "db1010", "No ping"); + dashboard\primary\error("Password has been leaked in a data breach (not from us)! You must click Forgot Password and change password."); + return; + } + + $ip = api\shared\primary\getIp(); + + /* + * Email verification + * For paid customers, checks if ISP and region (aka state) match. If not, they must verify it's them via an email. + * Customers can opt to disable email verification. + * This code is also used to notify the KeyAuth owner of account sharing, since that's against our ToS. + */ + if (in_array($role, array("developer", "seller")) && $username != "demoseller" && $username != "demodeveloper" && !empty($awsAccessKey)) { + $region = $_SERVER['HTTP_X_REGION_CODE']; + $asNum = "AS" . $_SERVER['HTTP_X_ASN_NUM']; + if (!is_null($asNumSaved)) { + if ($asNum != $asNumSaved || $region != $regionSaved) { + // if user not using VPN and IP location changed, notify KeyAuth owner of account sharing + if($region != $regionSaved) { + dashboard\primary\wh_log($logwebhook, "user `{$username}` detected account sharing **IP Address:** `{$ip}` **Old AS:** {$asNumSaved} **New AS:** {$asNum} **Old Region:** {$regionSaved} **New Region:** {$region}", $webhookun, "db1010", "<@ArBEr3YA> <@mqzvzejA> <@4vErXlPA> <@m6oPVR1A>"); + if(!$emailVerify) { + misc\mysql\query("UPDATE `accounts` SET `region` = ?,`asNum` = ?,`lastip` = ? WHERE `username` = ?",[$region, $asNum, $ip, $username]); + } + } + + if($emailVerify) { // only require email verification if enabled. + if ($twofactor_optional) { + // 2FA verification on new login location + $twofactor = misc\etc\sanitize($_POST['keyauthtwofactor']); + if (empty($twofactor)) { + dashboard\primary\error("Please enter 2FA code!"); + return; + } + + require_once '../auth/GoogleAuthenticator.php'; + $gauth = new GoogleAuthenticator(); + $checkResult = $gauth->verifyCode($google_Code, $twofactor, 2); + + if (!$checkResult) { + dashboard\primary\error("Invalid 2FA code! Make sure your device time settings are synced."); + return; + } + + misc\mysql\query("UPDATE `accounts` SET `region` = ?,`asNum` = ?,`lastip` = ? WHERE `username` = ?",[$region, $asNum, $ip, $username]); + } else { + // email verification on new login location + header("location: ./emailVerify/"); + die(); + } + } + } + } + else { + misc\mysql\query("UPDATE `accounts` SET `region` = ?,`asNum` = ?,`lastip` = ? WHERE `username` = ?",[$region, $asNum, $ip, $username]); + } + } + + if((!$emailVerify || $role == "tester") && $twofactor_optional) { + require_once '../auth/GoogleAuthenticator.php'; + $gauth = new GoogleAuthenticator(); + $twofactor = misc\etc\sanitize($_POST['keyauthtwofactor']); + $checkResult = $gauth->verifyCode($google_Code, $twofactor, 2); + + if (!$checkResult) { + dashboard\primary\error("Invalid 2FA code! Make sure your device time settings are synced."); + return; + } + } + + $_SESSION['username'] = $username; + $_SESSION['ownerid'] = $id; + $_SESSION['role'] = $role; + $_SESSION['logindate'] = time(); + $_SESSION['img'] = $img; + + if($securityKey) { + // set a temporary session variable to be used until the user completes WebAuthn + unset($_SESSION['username']); + $_SESSION['pendingUsername'] = $username; + header("location: ./securityKey.html"); + die(); + } + + if ($role == "Reseller" || $role == "Manager") { + ($query = misc\mysql\query("SELECT `secret`, `ownerid` FROM `apps` WHERE `name` = ? AND `owner` = ?",[$app, $owner])); + if ($query->num_rows < 1) { + dashboard\primary\error("Application you're assigned to no longer exists!"); + return; + } + while ($row = mysqli_fetch_array($query->result)) { + $secret = $row["secret"]; + $ownerid = $row["ownerid"]; + } + $_SESSION['app'] = $secret; + $_SESSION['name'] = $app; + $_SESSION['ownerid'] = $ownerid; + } + + if ($acclogs) // check if account logs enabled + { + $ua = misc\etc\sanitize($_SERVER['HTTP_USER_AGENT']); + misc\mysql\query("INSERT INTO `acclogs`(`username`, `date`, `ip`, `useragent`) VALUES (?, ?, ?, ?);",[$username, time(), $ip, $ua]); // insert ip log + $ts = time() - 604800; + misc\mysql\query("DELETE FROM `acclogs` WHERE `username` = ? AND `date` < ?",[$username, $ts]); // delete any account logs more than a week old + } + + if(strtolower($username) != "itsnetworking") { + dashboard\primary\wh_log($logwebhook, "{$username} has logged into KeyAuth with IP `{$ip}`", $webhookun, "3586ee", "No ping"); + } + + if ($role == "Reseller") { + header("location: ../app/?page=reseller-licenses"); + } else if (!is_null($_SESSION['oldUrl'])) { + header("location: " . $_SESSION['oldUrl']); + } else { + header("location: ../app/"); + } + }?> + + + + + + \ No newline at end of file diff --git a/login/renders/twofactor.php b/login/renders/twofactor.php new file mode 100644 index 0000000..51e8ab9 --- /dev/null +++ b/login/renders/twofactor.php @@ -0,0 +1,21 @@ + +
+ + +
+ '; + + return $html; +} + +?> \ No newline at end of file diff --git a/login/securityKey.html b/login/securityKey.html new file mode 100644 index 0000000..41460d2 --- /dev/null +++ b/login/securityKey.html @@ -0,0 +1,139 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + KeyAuth - Security Key + + + + + + + + + + + + + + + +
+ +
+ +
+
+
+

Security Key Required

+

If you're using a Security Key for your KeyAuth account, you will need to insert it now to gain access.

+ Need Help? + + +
+
+
+

+ Insert Security Key +

+
+ + Security Key + + +
+
+
+
+
+ + + + + + + + \ No newline at end of file diff --git a/panel/.htaccess b/panel/.htaccess new file mode 100644 index 0000000..e38f1fe --- /dev/null +++ b/panel/.htaccess @@ -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] \ No newline at end of file diff --git a/panel/dashboard/index.php b/panel/dashboard/index.php new file mode 100644 index 0000000..cce5cd1 --- /dev/null +++ b/panel/dashboard/index.php @@ -0,0 +1,92 @@ +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"]; + +?> + + + + + + + + + + + + + <?= $name; ?> Panel + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/panel/dashboard/layout/customeraside.php b/panel/dashboard/layout/customeraside.php new file mode 100644 index 0000000..5f4756d --- /dev/null +++ b/panel/dashboard/layout/customeraside.php @@ -0,0 +1,20 @@ + + + \ No newline at end of file diff --git a/panel/dashboard/layout/master.php b/panel/dashboard/layout/master.php new file mode 100644 index 0000000..9af8a0a --- /dev/null +++ b/panel/dashboard/layout/master.php @@ -0,0 +1,41 @@ + + +
+ + + + + +
+
+ +
+ + +
+
\ No newline at end of file diff --git a/panel/dashboard/layout/profile.php b/panel/dashboard/layout/profile.php new file mode 100644 index 0000000..f021002 --- /dev/null +++ b/panel/dashboard/layout/profile.php @@ -0,0 +1,48 @@ + + +
+
+ + +
+ +
+
+
+ ? LIMIT 1", [$_SESSION['panelapp'], $_SESSION['un'], time()]); + $row = mysqli_fetch_array($query->result); + $subName = $row["subscription"]; + $subExpiry = $row["expiry"]; + ?> +
+ + " . $subName . "

"; + + ?> + +
+
\ No newline at end of file diff --git a/panel/dashboard/pages/customer-actions.php b/panel/dashboard/pages/customer-actions.php new file mode 100644 index 0000000..644ffd0 --- /dev/null +++ b/panel/dashboard/pages/customer-actions.php @@ -0,0 +1,214 @@ +"; +} +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!"); + } +} +?> +
+
+
+

Customer Actions

+

View and Modify your account on

+
+
+
+ + +
+
+ + +
+ +
+
+
+ +
+
+
+

HWID Reset

+

Reset your hwid

+
+ result); + $today = time(); + $cooldown = $row["cooldown"]; + + if (is_null($cooldown)){ + echo '
'; + } else { + if ($today > $cooldown) { + echo '
'; + } else { + echo ''; + } + } +?> +
+
+ + result); + + $token = md5(substr($row["password"], -5)); + ?> +
+
+
+

Web Loader

+

Control your application from the website

+
+ result)) { + $rows[] = $r; + } + + foreach ($rows as $row) { + ?> + + +
+ + + +
+ + +
+
+
+

Stay Updated! +

+

If there is a link visible, there is a new version + of the app +

+
+ + + + + + + +
+
+ + + + \ No newline at end of file diff --git a/panel/dashboard/pages/customer-logout.php b/panel/dashboard/pages/customer-logout.php new file mode 100644 index 0000000..f19bb78 --- /dev/null +++ b/panel/dashboard/pages/customer-logout.php @@ -0,0 +1,5 @@ +"; +session_destroy(); +exit(); diff --git a/panel/dashboard/pages/logout.php b/panel/dashboard/pages/logout.php new file mode 100644 index 0000000..23c6073 --- /dev/null +++ b/panel/dashboard/pages/logout.php @@ -0,0 +1,12 @@ +"; +else + die('

Logged Out!

'); diff --git a/panel/index.php b/panel/index.php new file mode 100644 index 0000000..b7402a5 --- /dev/null +++ b/panel/index.php @@ -0,0 +1,206 @@ +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!"); +} + +?> + + + + + + + + + + + Login to <?= $name; ?> panel + + + + + + + + + +
+ +
+ +
+
+
+

+ Customer Panel

+

To access customer panel, + 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. +

+
+
+
+
+
+ + +
+
+ + +
+ +
+ New to the panel? Register Now. +
+
+ Need to to upgrade your account? Upgrade + Now. +
+
+
+
+
+
+ + + + + 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; + } + } + ?> + + + \ No newline at end of file diff --git a/panel/register/index.php b/panel/register/index.php new file mode 100644 index 0000000..3382fcd --- /dev/null +++ b/panel/register/index.php @@ -0,0 +1,148 @@ +getMessage()); + \dashboard\primary\error($errorMsg); +}); +?> + + + + + + + + + + + Register + + + + + + + + + +
+ +
+ +
+
+
+

+ Register

+

Please register an account for the panel you are trying to access. + This page is NOT 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. +

+
+
+
+
+
+ + +
+
+ + +
+
+ + +
+ +
+
+
+
+
+ + + + + + + + \ No newline at end of file diff --git a/panel/upgrade/index.php b/panel/upgrade/index.php new file mode 100644 index 0000000..a978f78 --- /dev/null +++ b/panel/upgrade/index.php @@ -0,0 +1,163 @@ +getMessage()); + \dashboard\primary\error($errorMsg); +}); +?> + + + + + + + + + + + Upgrade + + + + + + + + + +
+ +
+ +
+
+
+

+ Customer Panel

+

To access customer panel, + 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. +

+
+
+
+
+
+ + +
+
+ + +
+ +
+
+
+
+
+ + + + + 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; + } + } + } + ?> + + + \ No newline at end of file diff --git a/privacy/index.html b/privacy/index.html new file mode 100644 index 0000000..8a9e0bc --- /dev/null +++ b/privacy/index.html @@ -0,0 +1,668 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + KeyAuth - Privacy + + + + + + + + + + + + + + + +
+ +
+ +
+

+ Privacy

+
+

We understand privacy is important! Below you will find what we gather and for which reasons

+
+
+
+
+ +

+ +

+ + +

+ +

+ + +

+ +

+ + + +

+ +

+ + +

+ +

+ +
+
+
+
+ + + + + + + + + + + \ No newline at end of file diff --git a/register/index.php b/register/index.php new file mode 100644 index 0000000..a0cbfd1 --- /dev/null +++ b/register/index.php @@ -0,0 +1,563 @@ +getMessage()); + \dashboard\primary\error($errorMsg); +}); +?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + KeyAuth - Register + + + + + + + + + + + + + + + + + + + +
+ +
+
+ +
+ +
+
+
+
+

+ Welcome to KeyAuth! +

+

+ Seamless authentication for a more secure and user-friendly experience. +

+
+
+
+
+
+ + + + + + +
+
+ or +
+
+ +
+ + +
+
+ + +
+ +
+ + +
+ + +
+

+ By creating an account, you agree to our + Terms of Service and + Privacy Policy +

+ + + +
+ Need a good password manager? Use Bitwarden it's free! +
+ +
+ Have an Account? Login +
+ + +
+
+
+
+
+ + + + + + + + + + + = 33){ + dashboard\primary\error("Password must be less than 33 characters!"); + return; + } + $uppercase = preg_match('@[A-Z]@', $password); + $lowercase = preg_match('@[a-z]@', $password); + $number = preg_match('@[0-9]@', $password); + if (!$uppercase || !$lowercase || !$number || strlen($password) < 12) { + dashboard\primary\error("Password must have at least one capital letter, one lowercase letter, one number, and be at least 12 characters long."); + return; + } + if (misc\etc\isPhonyEmail($email)) { + dashboard\primary\error("Please use a real email. You will need email access to reset password, new login location if you have enabled, etc."); + dashboard\primary\wh_log($logwebhook, "{$username} has failed email validation with `{$email}`", $webhookun, "db1010", "No ping"); + return; + } + if (misc\etc\isBreached($password)) { + dashboard\primary\wh_log($logwebhook, "{$username} attempted to register with leaked password `{$password}`", $webhookun, "db1010", "No ping"); + dashboard\primary\error("Password has been leaked in a data breach (not from us)! Please use different password."); + return; + } + $query = misc\mysql\query("SELECT 1 FROM `accounts` WHERE `username` = ?", [$username]); + if ($query->num_rows == 1) { + dashboard\primary\error("Username already taken!"); + return; + } + $query = misc\mysql\query("SELECT `username` FROM `accounts` WHERE `email` = SHA1(?)", [$email]); + if ($query->num_rows > 0) { + dashboard\primary\error('Email already used by username: ' . mysqli_fetch_array($query->result)['username'] . ''); + return; + } + $pass_encrypted = password_hash($password, PASSWORD_BCRYPT); + $ownerid = misc\etc\generateRandomString(); + $ip = api\shared\primary\getIp(); + misc\mysql\query("INSERT INTO `accounts` (`username`, `email`, `password`, `ownerid`, `role`, `registrationip`) VALUES (?, SHA1(LOWER(?)), ?, ?, 'tester', ?)", [$username, $email, $pass_encrypted, $ownerid, $ip]); + dashboard\primary\wh_log($logwebhook, "{$username} has registered successfully", $webhookun, "41db10", "No ping"); + $htmlContent = " + +

Welcome!

+

Please join our Telegram group for updates and chat https://t.me/keyauth

+

KeyAuth code can be seen here https://github.com/KeyAuth/

+

KeyAuth API documentation can be seen here https://keyauthdocs.apidog.io

+

Please leave a review on TrustPilot if you enjoy KeyAuth https://trustpilot.com/review/keyauth.com

+

Thanks,
KeyAuth.

+ + "; + misc\email\send($username, $email, $htmlContent, "Welcome to KeyAuth"); + $_SESSION['logindate'] = time(); + $_SESSION['username'] = $username; + $_SESSION['ownerid'] = $ownerid; + $_SESSION['role'] = 'tester'; + $_SESSION['img'] = 'https://cdn.keyauth.cc/front/assets/img/favicon.png'; + header("location: ../app/"); + } + ?> + + + + + + \ No newline at end of file diff --git a/safe-harbot.txt b/safe-harbot.txt new file mode 100644 index 0000000..40e931f --- /dev/null +++ b/safe-harbot.txt @@ -0,0 +1,14 @@ +Gold Standard Safe Harbor supports the protection of organizations and hackers engaged in Good Faith Security Research. "Good Faith Security Research" is accessing a computer solely for purposes of good-faith testing, investigation, and/or correction of a security flaw or vulnerability, where such activity is carried out in a manner designed to avoid any harm to individuals or the public, and where the information derived from the activity is used primarily to promote the security or safety of the class of devices, machines, or online services to which the accessed computer belongs, or those who use such devices, machines, or online services. +We consider Good Faith Security Research to be authorized activity that is protected from adversarial legal action by us. We waive any relevant restriction in our Terms of Service ("TOS") and/or Acceptable Use Policies ("AUP") that conflicts with the standard for Good Faith Security Research outlined here. +This means that, for activities conducted while this program is active, we: + + - Will not bring legal action against you or report you for Good Faith Security Research, including for bypassing technological measures we use to protect the applications in scope; and, + - Will take steps to make known that you conducted Good Faith Security Research if someone else brings legal action against you. + +You should contact us for clarification before engaging in conduct that you think might be inconsistent with Good Faith Security Research or unaddressed by our policy. +Keep in mind that we are not able to authorize security research on third-party infrastructure and a third party is not bound by this safe harbor statement. + +Good Faith Security Research: + - No DDoS or spam attacks + - No modifying accounts/applications you did not create + - No sharing vulnerabilities until we have emailed you saying the bug report is closed. \ No newline at end of file diff --git a/scripts/datatables.js b/scripts/datatables.js new file mode 100644 index 0000000..77f2fc2 --- /dev/null +++ b/scripts/datatables.js @@ -0,0 +1,642 @@ +$("#kt_datatable_licenses").DataTable({ + "order": [[1, 'desc']], + 'processing': true, + 'serverSide': true, + 'serverMethod': 'post', + 'ajax': { + 'url': 'license-fetch.php' + }, + 'columns': [ + { + data: 'checkbox' + }, + { + data: 'key' + }, + { + data: 'user' + }, + { + data: 'gendate' + }, + { + data: 'genby' + }, + { + data: 'expires' + }, + { + data: 'note' + }, + { + data: 'usedon' + }, + { + data: 'usedby' + }, + { + data: 'status' + }, + { + data: 'actions' + }, + ], + "language": { + "lengthMenu": "Show _MENU_" + }, + "dom": "<'row'" + + "<'col-sm-6 d-flex align-items-center justify-conten-start'l>" + + "<'col-sm-6 d-flex align-items-center justify-content-end'f>" + + ">" + + + "<'table-responsive'tr>" + + + "<'row'" + + "<'col-sm-12 col-md-5 d-flex align-items-center justify-content-center justify-content-md-start'i>" + + "<'col-sm-12 col-md-7 d-flex align-items-center justify-content-center justify-content-md-end'p>" + + ">" +}); + +$("#kt_datatable_tokens").DataTable({ + "order": [[1, 'desc']], + 'processing': true, + 'serverSide': true, + 'serverMethod': 'post', + 'ajax': { + 'url': 'token-fetch.php' + }, + 'columns': [ + { + data: 'app' + }, + { + data: 'token' + }, + { + data: 'assigned' + }, + { + data: 'banned' + }, + { + data: 'reason' + }, + { + data: 'hash' + }, + { + data: 'type' + }, + { + data: 'status' + }, + ], + "language": { + "lengthMenu": "Show _MENU_" + }, + "dom": "<'row'" + + "<'col-sm-6 d-flex align-items-center justify-conten-start'l>" + + "<'col-sm-6 d-flex align-items-center justify-content-end'f>" + + ">" + + + "<'table-responsive'tr>" + + + "<'row'" + + "<'col-sm-12 col-md-5 d-flex align-items-center justify-content-center justify-content-md-start'i>" + + "<'col-sm-12 col-md-7 d-flex align-items-center justify-content-center justify-content-md-end'p>" + + ">" +}); + +$("#kt_datatable_reseller_licenses").DataTable({ + "order": [[1, 'desc']], + 'processing': true, + 'serverSide': true, + 'serverMethod': 'post', + 'ajax': { + 'url': 'reseller-license-fetch.php' + }, + 'columns': [{ + data: 'key' + }, + { + data: 'gendate' + }, + { + data: 'expires' + }, + { + data: 'note' + }, + { + data: 'usedon' + }, + { + data: 'usedby' + }, + { + data: 'status' + }, + { + data: 'actions' + }, + ], + "language": { + "lengthMenu": "Show _MENU_" + }, + "dom": "<'row'" + + "<'col-sm-6 d-flex align-items-center justify-conten-start'l>" + + "<'col-sm-6 d-flex align-items-center justify-content-end'f>" + + ">" + + + "<'table-responsive'tr>" + + + "<'row'" + + "<'col-sm-12 col-md-5 d-flex align-items-center justify-content-center justify-content-md-start'i>" + + "<'col-sm-12 col-md-7 d-flex align-items-center justify-content-center justify-content-md-end'p>" + + ">" +}); + +$("#kt_datatable_users").DataTable({ + "order": [[3, 'desc']], + 'processing': true, + 'serverSide': true, + 'serverMethod': 'post', + 'ajax': { + 'url': 'user-fetch.php' + }, + 'columns': [ + { + data: 'checkbox' + }, + { + data: 'username' + }, + { + data: 'hwid' + }, + { + data: 'ip' + }, + { + data: 'createdate' + }, + { + data: 'lastlogin' + }, + { + data: 'banned' + }, + { + data: 'actions' + }, + ], + "language": { + "lengthMenu": "Show _MENU_", + }, + "dom": "<'row'" + + "<'col-sm-6 d-flex align-items-center justify-conten-start'l>" + + "<'col-sm-6 d-flex align-items-center justify-content-end'f>" + + ">" + + + "<'table-responsive'tr>" + + + "<'row'" + + "<'col-sm-12 col-md-5 d-flex align-items-center justify-content-center justify-content-md-start'i>" + + "<'col-sm-12 col-md-7 d-flex align-items-center justify-content-center justify-content-md-end'p>" + + ">" +}); + +$("#kt_datatable_user_vars").DataTable({ + "order": [[2, 'asc']], + 'processing': true, + 'serverSide': true, + 'serverMethod': 'post', + 'ajax': { + 'url': 'user-var-fetch.php' + }, + 'columns': [{ + data: 'name' + }, + { + data: 'data' + }, + { + data: 'user' + }, + { + data: 'readOnly' + }, + { + data: 'actions' + }, + ], + "language": { + "lengthMenu": "Show _MENU_", + }, + "dom": "<'row'" + + "<'col-sm-6 d-flex align-items-center justify-conten-start'l>" + + "<'col-sm-6 d-flex align-items-center justify-content-end'f>" + + ">" + + + "<'table-responsive'tr>" + + + "<'row'" + + "<'col-sm-12 col-md-5 d-flex align-items-center justify-content-center justify-content-md-start'i>" + + "<'col-sm-12 col-md-7 d-flex align-items-center justify-content-center justify-content-md-end'p>" + + ">" +}); + +$("#kt_datatable_reseller_users").DataTable({ + "order": [[3, 'desc']], + 'processing': true, + 'serverSide': true, + 'serverMethod': 'post', + 'ajax': { + 'url': 'reseller-user-fetch.php' + }, + 'columns': [{ + data: 'username' + }, + { + data: 'hwid' + }, + { + data: 'ip' + }, + { + data: 'createdate' + }, + { + data: 'lastlogin' + }, + { + data: 'banned' + }, + { + data: 'actions' + }, + ], + "language": { + "lengthMenu": "Show _MENU_", + }, + "dom": "<'row'" + + "<'col-sm-6 d-flex align-items-center justify-conten-start'l>" + + "<'col-sm-6 d-flex align-items-center justify-content-end'f>" + + ">" + + + "<'table-responsive'tr>" + + + "<'row'" + + "<'col-sm-12 col-md-5 d-flex align-items-center justify-content-center justify-content-md-start'i>" + + "<'col-sm-12 col-md-7 d-flex align-items-center justify-content-center justify-content-md-end'p>" + + ">" +}); + +$("#kt_datatable_subs").DataTable({ + "order": [[1, 'asc']], + "language": { + "lengthMenu": "Show _MENU_", + }, + "dom": "<'row'" + + "<'col-sm-6 d-flex align-items-center justify-conten-start'l>" + + "<'col-sm-6 d-flex align-items-center justify-content-end'f>" + + ">" + + + "<'table-responsive'tr>" + + + "<'row'" + + "<'col-sm-12 col-md-5 d-flex align-items-center justify-content-center justify-content-md-start'i>" + + "<'col-sm-12 col-md-7 d-flex align-items-center justify-content-center justify-content-md-end'p>" + + ">" +}); + +$("#kt_datatable_chats").DataTable({ + "language": { + "lengthMenu": "Show _MENU_", + }, + "dom": "<'row'" + + "<'col-sm-6 d-flex align-items-center justify-conten-start'l>" + + "<'col-sm-6 d-flex align-items-center justify-content-end'f>" + + ">" + + + "<'table-responsive'tr>" + + + "<'row'" + + "<'col-sm-12 col-md-5 d-flex align-items-center justify-content-center justify-content-md-start'i>" + + "<'col-sm-12 col-md-7 d-flex align-items-center justify-content-center justify-content-md-end'p>" + + ">" +}); + +$("#kt_datatable_messages").DataTable({ + "order": [[2, 'desc']], + "language": { + "lengthMenu": "Show _MENU_", + }, + "dom": "<'row'" + + "<'col-sm-6 d-flex align-items-center justify-conten-start'l>" + + "<'col-sm-6 d-flex align-items-center justify-content-end'f>" + + ">" + + + "<'table-responsive'tr>" + + + "<'row'" + + "<'col-sm-12 col-md-5 d-flex align-items-center justify-content-center justify-content-md-start'i>" + + "<'col-sm-12 col-md-7 d-flex align-items-center justify-content-center justify-content-md-end'p>" + + ">" +}); + +$("#kt_datatable_sessions").DataTable({ + "order": [[2, 'desc']], + 'processing': true, + 'serverSide': true, + 'serverMethod': 'post', + 'ajax': { + 'url': 'session-fetch.php' + }, + 'columns': [{ + data: 'id' + }, + { + data: 'credential' + }, + { + data: 'expiry' + }, + { + data: 'validated' + }, + { + data: 'ip' + }, + { + data: 'actions' + }, + ], + "language": { + "lengthMenu": "Show _MENU_", + }, + "dom": "<'row'" + + "<'col-sm-6 d-flex align-items-center justify-conten-start'l>" + + "<'col-sm-6 d-flex align-items-center justify-content-end'f>" + + ">" + + + "<'table-responsive'tr>" + + + "<'row'" + + "<'col-sm-12 col-md-5 d-flex align-items-center justify-content-center justify-content-md-start'i>" + + "<'col-sm-12 col-md-7 d-flex align-items-center justify-content-center justify-content-md-end'p>" + + ">" +}); + +$("#kt_datatable_webhooks").DataTable({ + "language": { + "lengthMenu": "Show _MENU_", + }, + "dom": "<'row'" + + "<'col-sm-6 d-flex align-items-center justify-conten-start'l>" + + "<'col-sm-6 d-flex align-items-center justify-content-end'f>" + + ">" + + + "<'table-responsive'tr>" + + + "<'row'" + + "<'col-sm-12 col-md-5 d-flex align-items-center justify-content-center justify-content-md-start'i>" + + "<'col-sm-12 col-md-7 d-flex align-items-center justify-content-center justify-content-md-end'p>" + + ">" +}); + +$("#kt_datatable_files").DataTable({ + "order": [[3, 'desc']], + "language": { + "lengthMenu": "Show _MENU_", + }, + "dom": "<'row'" + + "<'col-sm-6 d-flex align-items-center justify-conten-start'l>" + + "<'col-sm-6 d-flex align-items-center justify-content-end'f>" + + ">" + + + "<'table-responsive'tr>" + + + "<'row'" + + "<'col-sm-12 col-md-5 d-flex align-items-center justify-content-center justify-content-md-start'i>" + + "<'col-sm-12 col-md-7 d-flex align-items-center justify-content-center justify-content-md-end'p>" + + ">" +}); + +$("#kt_datatable_vars").DataTable({ + "order": [[0, 'asc']], + 'processing': true, + 'serverSide': true, + 'serverMethod': 'post', + 'ajax': { + 'url': 'var-fetch.php' + }, + 'columns': [{ + data: 'varid' + }, + { + data: 'msg' + }, + { + data: 'authed' + }, + { + data: 'actions' + }, + ], + "language": { + "lengthMenu": "Show _MENU_", + }, + "dom": "<'row'" + + "<'col-sm-6 d-flex align-items-center justify-conten-start'l>" + + "<'col-sm-6 d-flex align-items-center justify-content-end'f>" + + ">" + + + "<'table-responsive'tr>" + + + "<'row'" + + "<'col-sm-12 col-md-5 d-flex align-items-center justify-content-center justify-content-md-start'i>" + + "<'col-sm-12 col-md-7 d-flex align-items-center justify-content-center justify-content-md-end'p>" + + ">" +}); + +$("#kt_datatable_logs").DataTable({ + "order": [[0, 'desc']], + 'processing': true, + 'serverSide': true, + 'serverMethod': 'post', + 'ajax': { + 'url': 'log-fetch.php' + }, + 'columns': [{ + data: 'logdate' + }, + { + data: 'logdata' + }, + { + data: 'credential' + }, + { + data: 'pcuser' + }, + ], + "language": { + "lengthMenu": "Show _MENU_", + }, + "dom": "<'row'" + + "<'col-sm-6 d-flex align-items-center justify-conten-start'l>" + + "<'col-sm-6 d-flex align-items-center justify-content-end'f>" + + ">" + + + "<'table-responsive'tr>" + + + "<'row'" + + "<'col-sm-12 col-md-5 d-flex align-items-center justify-content-center justify-content-md-start'i>" + + "<'col-sm-12 col-md-7 d-flex align-items-center justify-content-center justify-content-md-end'p>" + + ">" +}); + +$("#kt_datatable_blacklists").DataTable({ + "order": [[1, 'desc']], + 'processing': true, + 'serverSide': true, + 'serverMethod': 'post', + 'ajax': { + 'url': 'black-fetch.php' + }, + 'columns': [ + { + data: 'checkbox' + }, + { + data: 'data' + }, + { + data: 'type' + }, + { + data: 'reason' + }, + { + data: 'actions' + }, + ], + "language": { + "lengthMenu": "Show _MENU_", + }, + "dom": "<'row'" + + "<'col-sm-6 d-flex align-items-center justify-conten-start'l>" + + "<'col-sm-6 d-flex align-items-center justify-content-end'f>" + + ">" + + + "<'table-responsive'tr>" + + + "<'row'" + + "<'col-sm-12 col-md-5 d-flex align-items-center justify-content-center justify-content-md-start'i>" + + "<'col-sm-12 col-md-7 d-flex align-items-center justify-content-center justify-content-md-end'p>" + + ">" +}); + +$("#kt_datatable_whitelists").DataTable({ + "order": [[1, 'desc']], + 'processing': true, + 'serverSide': true, + 'serverMethod': 'post', + 'ajax': { + 'url': 'white-fetch.php' + }, + 'columns': [{ + data: 'ip' + }, + { + data: 'reason' + }, + { + data: 'actions' + }, + ], + "language": { + "lengthMenu": "Show _MENU_", + }, + "dom": "<'row'" + + "<'col-sm-6 d-flex align-items-center justify-conten-start'l>" + + "<'col-sm-6 d-flex align-items-center justify-content-end'f>" + + ">" + + + "<'table-responsive'tr>" + + + "<'row'" + + "<'col-sm-12 col-md-5 d-flex align-items-center justify-content-center justify-content-md-start'i>" + + "<'col-sm-12 col-md-7 d-flex align-items-center justify-content-center justify-content-md-end'p>" + + ">" +}); + +$("#kt_datatable_account_logs").DataTable({ + "order": [[0, 'desc']], + "language": { + "lengthMenu": "Show _MENU_", + }, + "dom": "<'row'" + + "<'col-sm-6 d-flex align-items-center justify-conten-start'l>" + + "<'col-sm-6 d-flex align-items-center justify-content-end'f>" + + ">" + + + "<'table-responsive'tr>" + + + "<'row'" + + "<'col-sm-12 col-md-5 d-flex align-items-center justify-content-center justify-content-md-start'i>" + + "<'col-sm-12 col-md-7 d-flex align-items-center justify-content-center justify-content-md-end'p>" + + ">" +}); + +$("#kt_datatable_manageaccs").DataTable({ + "language": { + "lengthMenu": "Show _MENU_", + }, + "dom": "<'row'" + + "<'col-sm-6 d-flex align-items-center justify-conten-start'l>" + + "<'col-sm-6 d-flex align-items-center justify-content-end'f>" + + ">" + + + "<'table-responsive'tr>" + + + "<'row'" + + "<'col-sm-12 col-md-5 d-flex align-items-center justify-content-center justify-content-md-start'i>" + + "<'col-sm-12 col-md-7 d-flex align-items-center justify-content-center justify-content-md-end'p>" + + ">" +}); + +$("#kt_datatable_webloader").DataTable({ + "language": { + "lengthMenu": "Show _MENU_", + }, + "dom": "<'row'" + + "<'col-sm-6 d-flex align-items-center justify-conten-start'l>" + + "<'col-sm-6 d-flex align-items-center justify-content-end'f>" + + ">" + + + "<'table-responsive'tr>" + + + "<'row'" + + "<'col-sm-12 col-md-5 d-flex align-items-center justify-content-center justify-content-md-start'i>" + + "<'col-sm-12 col-md-7 d-flex align-items-center justify-content-center justify-content-md-end'p>" + + ">" +}); + +$("#kt_datatable_admin").DataTable({ + "language": { + "lengthMenu": "Show _MENU_", + }, + "dom": "<'row'" + + "<'col-sm-6 d-flex align-items-center justify-conten-start'l>" + + "<'col-sm-6 d-flex align-items-center justify-content-end'f>" + + ">" + + + "<'table-responsive'tr>" + + + "<'row'" + + "<'col-sm-12 col-md-5 d-flex align-items-center justify-content-center justify-content-md-start'i>" + + "<'col-sm-12 col-md-7 d-flex align-items-center justify-content-center justify-content-md-end'p>" + + ">" +}); \ No newline at end of file diff --git a/setup-script/etc.php b/setup-script/etc.php new file mode 100644 index 0000000..ba2d9d4 --- /dev/null +++ b/setup-script/etc.php @@ -0,0 +1,130 @@ += 31536000) { + $value = floor($expires / 31536000); + $unit = 'Year(s)'; + } + elseif ($expires >= 2419200) { + $value = floor($expires / 2592000); + $unit = 'Month(s)'; + } + elseif ($expires >= 604800) { + $value = floor($expires / 604800); + $unit = 'Weeks(s)'; + } + elseif ($expires >= 86400) { + $value = floor($expires / 86400); + $unit = 'Day(s)'; + } elseif ($expires >= 3600) { + $value = floor($expires / 3600); + $unit = 'Hour(s)'; + } elseif ($expires >= 60) { + $value = floor($expires / 60); + $unit = 'Minute(s)'; + } else { + $value = $expires; + $unit = 'Second(s)'; + } + + return "$value $unit"; +} \ No newline at end of file diff --git a/setup-script/nginx.conf b/setup-script/nginx.conf new file mode 100644 index 0000000..fa06a66 --- /dev/null +++ b/setup-script/nginx.conf @@ -0,0 +1,120 @@ +# For more information on configuration, see: +# * Official English Documentation: http://nginx.org/en/docs/ +# * Official Russian Documentation: http://nginx.org/ru/docs/ + +user www-data; +worker_processes auto; +worker_rlimit_nofile 65535; + +pid /run/nginx.pid; + +# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic. +include /usr/share/nginx/modules/*.conf; + +events { + worker_connections 65535; + multi_accept on; +} + +http { + access_log off; + + sendfile on; + tcp_nopush on; + tcp_nodelay on; + keepalive_timeout 10; + keepalive_requests 500; + log_not_found off; + types_hash_max_size 2048; + types_hash_bucket_size 64; + client_max_body_size 150M; + server_tokens off; + include /etc/nginx/mime.types; + default_type application/octet-stream; + + # Load modular configuration files from the /etc/nginx/conf.d directory. + # See http://nginx.org/en/docs/ngx_core_module.html#include + # for more information. + include /etc/nginx/conf.d/*.conf; + + server { + listen 80 default_server; + + error_page 405 =200 $uri; + server_name _; + root /usr/share/nginx/html/; + + location / { + index index.php index.html index.htm; + try_files $uri $uri/ =404; + } + + location ~ \.php$ { + try_files $uri =404; + fastcgi_pass unix:/var/run/php/php8.1-fpm.sock; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include fastcgi_params; + #limit_req zone=mylimit burst=7; + } + + location ^~ /includes { + allow 127.0.0.1; + deny all; + } + + location ^~ /app/pages { + allow 127.0.0.1; + deny all; + } + + location ^~ /app/layout { + allow 127.0.0.1; + deny all; + } + + location ^~ /panel/dashboard/pages { + allow 127.0.0.1; + deny all; + } + + location ^~ /panel/dashboard/layout { + allow 127.0.0.1; + deny all; + } + + location ~ /panel/(.+)/(.+) { + rewrite ^ /panel/index.php?/$1 last; + } + } +# Settings for a TLS enabled server. +# +# server { +# listen 443 ssl http2 default_server; +# listen [::]:443 ssl http2 default_server; +# server_name _; +# root /usr/share/nginx/html; +# +# ssl_certificate "/etc/pki/nginx/server.crt"; +# ssl_certificate_key "/etc/pki/nginx/private/server.key"; +# ssl_session_cache shared:SSL:1m; +# ssl_session_timeout 10m; +# ssl_ciphers PROFILE=SYSTEM; +# ssl_prefer_server_ciphers on; +# +# # Load configuration files for the default server block. +# include /etc/nginx/default.d/*.conf; +# +# location / { +# } +# +# error_page 404 /404.html; +# location = /40x.html { +# } +# +# error_page 500 502 503 504 /50x.html; +# location = /50x.html { +# } +# } + +} \ No newline at end of file diff --git a/setup-script/test.php b/setup-script/test.php new file mode 100644 index 0000000..bfd863b --- /dev/null +++ b/setup-script/test.php @@ -0,0 +1,2 @@ +}t tag +; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t +; %T: time the log has been written (the request has finished) +; it can accept a strftime(3) format: +; %d/%b/%Y:%H:%M:%S %z (default) +; The strftime(3) format must be encapsuled in a %{}t tag +; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t +; %u: remote user +; +; Default: "%R - %u %t \"%m %r\" %s" +;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%" + +; The log file for slow requests +; Default Value: not set +; Note: slowlog is mandatory if request_slowlog_timeout is set +slowlog = /var/log/php-fpm/www-slow.log + +; The timeout for serving a single request after which a PHP backtrace will be +; dumped to the 'slowlog' file. A value of '0s' means 'off'. +; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) +; Default Value: 0 +;request_slowlog_timeout = 0 + +; Depth of slow log stack trace. +; Default Value: 20 +;request_slowlog_trace_depth = 20 + +; The timeout for serving a single request after which the worker process will +; be killed. This option should be used when the 'max_execution_time' ini option +; does not stop script execution for some reason. A value of '0' means 'off'. +; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) +; Default Value: 0 +;request_terminate_timeout = 0 + +; Set open file descriptor rlimit. +; Default Value: system defined value +;rlimit_files = 1024 + +; Set max core size rlimit. +; Possible Values: 'unlimited' or an integer greater or equal to 0 +; Default Value: system defined value +;rlimit_core = 0 + +; Chroot to this directory at the start. This value must be defined as an +; absolute path. When this value is not set, chroot is not used. +; Note: you can prefix with '$prefix' to chroot to the pool prefix or one +; of its subdirectories. If the pool prefix is not set, the global prefix +; will be used instead. +; Note: chrooting is a great security feature and should be used whenever +; possible. However, all PHP paths will be relative to the chroot +; (error_log, sessions.save_path, ...). +; Default Value: not set +;chroot = + +; Chdir to this directory at the start. +; Note: relative path can be used. +; Default Value: current directory or / when chroot +;chdir = /var/www + +; Redirect worker stdout and stderr into main error log. If not set, stdout and +; stderr will be redirected to /dev/null according to FastCGI specs. +; Note: on highloaded environement, this can cause some delay in the page +; process time (several ms). +; Default Value: no +;catch_workers_output = yes + +; Clear environment in FPM workers +; Prevents arbitrary environment variables from reaching FPM worker processes +; by clearing the environment in workers before env vars specified in this +; pool configuration are added. +; Setting to "no" will make all environment variables available to PHP code +; via getenv(), $_ENV and $_SERVER. +; Default Value: yes +;clear_env = no + +; Limits the extensions of the main script FPM will allow to parse. This can +; prevent configuration mistakes on the web server side. You should only limit +; FPM to .php extensions to prevent malicious users to use other extensions to +; execute php code. +; Note: set an empty value to allow all extensions. +; Default Value: .php +;security.limit_extensions = .php .php3 .php4 .php5 .php7 + +; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from +; the current environment. +; Default Value: clean env +;env[HOSTNAME] = $HOSTNAME +;env[PATH] = /usr/local/bin:/usr/bin:/bin +;env[TMP] = /tmp +;env[TMPDIR] = /tmp +;env[TEMP] = /tmp + +; Additional php.ini defines, specific to this pool of workers. These settings +; overwrite the values previously defined in the php.ini. The directives are the +; same as the PHP SAPI: +; php_value/php_flag - you can set classic ini defines which can +; be overwritten from PHP call 'ini_set'. +; php_admin_value/php_admin_flag - these directives won't be overwritten by +; PHP call 'ini_set' +; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no. + +; Defining 'extension' will load the corresponding shared extension from +; extension_dir. Defining 'disable_functions' or 'disable_classes' will not +; overwrite previously defined php.ini values, but will append the new value +; instead. + +; Note: path INI options can be relative and will be expanded with the prefix +; (pool, global or @prefix@) + +; Default Value: nothing is defined by default except the values in php.ini and +; specified at startup with the -d argument +;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com +;php_flag[display_errors] = off +php_admin_value[error_log] = /var/log/php-fpm/www-error.log +php_admin_flag[log_errors] = on +;php_admin_value[memory_limit] = 128M + +; Set the following data paths to directories owned by the FPM process user. +; +; Do not change the ownership of existing system directories, if the process +; user does not have write permission, create dedicated directories for this +; purpose. +; +; See warning about choosing the location of these directories on your system +; at http://php.net/session.save-path +php_value[session.save_handler] = files +php_value[session.save_path] = /var/lib/php/sessions +php_value[soap.wsdl_cache_dir] = /var/lib/php/wsdlcache +;php_value[opcache.file_cache] = /var/lib/php/opcache \ No newline at end of file diff --git a/stats.php b/stats.php new file mode 100644 index 0000000..91fe5b3 --- /dev/null +++ b/stats.php @@ -0,0 +1,19 @@ + ?), '') AS 'numOnlineUsers', FORMAT((SELECT COUNT(*) FROM `keys`), '') AS 'numKeys', FORMAT((SELECT COUNT(*) FROM `apps`), '') AS 'numApps';", [time()], 0, 3600, "i"); + +$numAccs = $row['numAccs']; +$numOnlineUsers = $row['numOnlineUsers']; +$numApps = $row['numApps']; +$numKeys = $row['numKeys']; + +die(json_encode(array( + "accounts" => $numAccs, + "applications" => $numApps, + "licenses" => $numKeys, + "activeUsers" => $numOnlineUsers +))); \ No newline at end of file diff --git a/tbs.png b/tbs.png new file mode 100644 index 0000000000000000000000000000000000000000..b35416bbf67416b7abaa7c9f98aadd504b26719c G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m{uaAvP51(8TS0_nA| z%tGYTa$Yphq7^u+tJ9XOoh{f7kX9Rxp#({O2)~PRSBExns{8dnIF+N)EPa0YOwvE7 z4T-VeJx3zw)lleL_kM;oXP4~qq1PDk8VsBY7;)wbC&sqx+z1ALbWDChL| zQ0J%wnY4QE^EHmxG=EYV8(c=e#ydFfs5Yl=QOl;JJILAu^?`LLuDLK;di%v{y4QFC$yq%|&d`7Wlpny;-qGh>s{~xkF zPSjIbmOJR^@kXOKZ@~LAhC%n8q_H_B%)pKHPwiOAPO!)b*-sRex&C!SwNVTJBAoJ3Mu!8mb}yq>ej zu$DC?M`o&g0xHdqPkaJ7!vhoDEEG>#pB&sbPZP>_FHB4mymdB_w?_1^e%_-d ziMHSMN7gspEW2dK&)JF@$MSFb2;afpjb_=ray=ud@M`JP6LbKcTmlGQ!XDb2bt$EmI%xhogdjwB(JPVX;dB>pS(*N z5ad!xyV8+1e@;g^iCXzF^6x2$IW{kFaM~AmxGx$x);X5g;_BHg?~~t zp~pnZ?nb{xK^Z%$(y*U}<;Z?XaCy&kruONjwQWeVUgg<|V|$jNYv#Qvy%yb6y;Q6i zy)tP92)yjj(5xOxk64*$bhHC8dlicb?0{@P-FJ{k28kJGWi!mD>UZyOO1$p2ioUqs z6HCoH!#(1})j}HrGEmLpdFTM9wma!*8wKc!r*faVQ6@j{GH7_Sb}HpC&?>-QF9nEx z93Tp^B>c~M2c7bSB6ni^Iv&>_keK#!7^R>3>aCc6EL{ilbFy^PPMCRJrr%BzQh?m9 zHJ2WM%(b|tqBwB+xr$LY^O*!SLTy9L6N7lKBON$Wii-b4Y0vRcG!f26- z#*!r&4C|H004wC0_#=|cMDwO?RrakZnGKaRHYB11BXP \ No newline at end of file diff --git a/terms/index.html b/terms/index.html new file mode 100644 index 0000000..73eb573 --- /dev/null +++ b/terms/index.html @@ -0,0 +1,793 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + KeyAuth - Terms + + + + + + + + + + + + + + + +
+ +
+ +
+

+ Terms and Conditions

+
+

KeyAuth is an Open-source authentication system with + cloud-hosted subscriptions available as well.

+
+
+
+
+

+ +

+ + + +

+ +

+ + +

+ +

+ + + +

+ +

+ + +

+ +

+ + +

+ +

+ + +

+ +

+ + +

+ +

+ + +

+ +

+ + +

+ +

+ + + +

+ +

+ + + +

+ +

+ +
+
+
+
+ + + + + + + + + + + \ No newline at end of file