diff --git a/.github/README.md b/.github/README.md index 0d30939c..09196441 100644 --- a/.github/README.md +++ b/.github/README.md @@ -1,74 +1,104 @@ -![Logo](https://camo.githubusercontent.com/4cf45904e67161611071520974b92a39ef49544ad2c03c027a4e07bf7f44d871/68747470733a2f2f692e696d6775722e636f6d2f784933474c46632e6a706567) - -# MythicalDash - -Open-Source Client Area for Pterodactyl -MythicalDash is currently in development by [@SnyderWillCode](https://github.com/SnyderWillCode) & [@NaysKutzu](https://github.com/nayskutzu). - -# Docs -https://docs.mythicalsystems.me/docs/mythicaldash/intro - -### 🎧 Support - -You can join our support server: - -https://discord.gg/7BZTmSK2D8 - -### 🎨 Frontend -We are using vuexy as a frontend. - -### πŸ‘” Contributing -I'm open to all contributions! Feel free to help! :) - -### πŸ’Έ Financial support -Do you want to support our hard work? - -MythicalSystems -https://paypal.me/mythicalsystems - - -## Desktop Application -Hi, if you want to setup this right, you will have to go inside the `public/manifest.webmanifest` -Here is an example of the file: -```json -{ - "name": "MyAwsomeDash", - "short_name": "Dash", - "start_url": "/", - "display": "standalone", - "orientation": "portrait", - "background_color": "#161931", - "theme_color": "#161931", - "icons": [ - { - "src": "https://mydash.dev/assets/img/logo.png", - "sizes": "192x192", - "type": "image/png" - }, - { - "src": "https://mydash.dev/assets/img/logo.png", - "sizes": "192x192", - "type": "image/png", - "purpose": "maskable" - }, - { - "src": "https://mydash.dev/assets/img/logo.png", - "sizes": "512x512", - "type": "image/png" - } - ], - "description": "MythicalDash is a feature-rich and user-friendly client area for Pterodactyl, designed to simplify server management. With MythicalDash, you have unparalleled control over your hosting environment, effortlessly managing game servers, databases, files, and more. Experience seamless server administration, enhanced security, and optimized performance with MythicalDash, your ultimate solution for streamlined Pterodactyl server management.", - "lang": "en", - "categories": ["hosting", "news"] - } -``` - -## CLI -To compile the CLI you need to install dotnet core: -```bash -wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh -chmod +x ./dotnet-install.sh -./dotnet-install.sh --channel 7.0 -dotnet run --project /var/www/client/cli -help -``` +# MythicalDash V3 +MythicalDash is a client area/dashboard for the Pterodactyl Game Panel with features for managing client servers and much more. + + + +[![MIT License](https://img.shields.io/badge/License-MIT-green.svg)](https://choosealicense.com/licenses/mit/) +## Documentation + +Do you want MythicalDash? + +You can find a step-by-step installation documentation over here:Β  + +https://docs.mythicalsystems.me +## Support + +For support, discord server: [discord.gg/freehost](https://discord.gg/freehost) + + +## Optimizations + +MythicalDash is one of the fastest dashboards out there. It has lightning-fast loading speeds! + + +## FAQ + +#### Why is MythicalDash really the best? + +Well, we created a table to compare the most commonly used pterodactyl clients, so you can see it for yourself! + +| Feature | MythicalDash | Dashactyl | Heliactyl | NorthClient | HolaClient | Meteor | +| :---: | :---: | :---: | :--: | :--: | :--: | :--: | +| Essentials Options | βœ…|βœ…|βœ…|βœ…|βœ…|βœ…| +| API (Client/Admin) |βœ…|❌|βœ…|βœ…|βœ…| βœ…| +| Payment Options | πŸ”„|πŸ”„|βœ…|βœ…|βœ…|βœ…| +| J4R | πŸ”„|βœ…|βœ…|βœ…|βœ…|βœ…| +| Referrals |πŸ”„|βœ…|βœ…|βœ…|βœ…|βœ…| +| Linkvertise | βœ…|❌|βœ…|βœ…|βœ…|βœ…| +| Custom Ads | βœ…|❌|❌|βœ…|βœ…|βœ…| +| Purge System | βœ…|⚠️|⚠️|⚠️|βœ…|βœ…| +| Anti CSRF |βœ…|βœ…|βœ…|❌|βœ…|βœ…| +| Anti Bot |βœ…|βœ…|βœ…|❌|βœ…|βœ…| +|Telemetry|βœ…|⚠️|⚠️|⚠️|⚠️|βœ…| +| Legal (Terms / Privacy)|βœ…|❌|❌|❌|βœ…|βœ…| +| Leaderboards |βœ…|❌|❌|❌|❌|βœ…| +| Support System | βœ…|❌|❌|❌|❌|βœ…| +| EasyΒ Customizations | βœ…|❌|❌|❌|❌|⚠️| +| Custom (CSS/Header/HTML) |βœ…|❌|❌|❌|❌|βœ…| +| Leaderboards |βœ…|❌|❌|❌|❌|βœ…| +| Runs everywhere |βœ…|❌|❌|❌|❌|⚠️| +| CLI |βœ…|❌|❌|❌|❌|βœ…| + + +## Demo + +You can find a live deployment copy of MythicalDash here: +- https://devclient.mythicalsystems.me + +## Roadmap + +You can find the roadmap at: https://github.com/orgs/MythicalLTD/projects/5 + + +## Contributing + +Contributions are always welcome! + + +## Used By + +This project is used by the following companies: + +- MythicalSystems +- NyxHost + + +## Screenshots + +- ![App Screenshot1](https://i.imgur.com/fLIYnqK.png) +- ![App Screenshot1](https://i.imgur.com/k3hBOut.png) +- ![App Screenshot1](https://i.imgur.com/QDr6jk5.png) +- ![App Screenshot1](https://i.imgur.com/1o5WNHo.png) +- ![App Screenshot1](https://i.imgur.com/YcEb4YE.png) +- ![App Screenshot1](https://i.imgur.com/KuJMgZk.png) +- ![App Screenshot1](https://i.imgur.com/Nf0aFAt.png) +- ![App Screenshot1](https://i.imgur.com/GwVkHbT.png) +- ![App Screenshot1](https://i.imgur.com/mVBrtV5.png) +- ![App Screenshot1](https://i.imgur.com/70rXiHt.png) +- ![App Screenshot1](https://i.imgur.com/WrroKW3.png) + +## API Reference + +We did not write specific API documentation, but you can use [Insomnia](https://insomnia.rest/download) to see more info on what requests you can execute with our API. Here you can download the JSON for the Insomnia client: https://raw.githubusercontent.com/MythicalLTD/MythicalDash/v3/Insomnia.json + +## Tech Stack + +Here is a list of the core components that MythicalDash uses to run! + +**Client:** [Composer](https://getcomposer.org/), [DotNet](https://dot.net) + +**Server:** [PHP](https://php.net), [Pterodactyl](https://pterodactyl.io), [MariaDB](https://mariadb.com)/[MySQL](https://mysql.com) + +**Packages:** +[PHP-Router](https://packagist.org/packages/mythicalsystems/php-router), [Yaml](https://packagist.org/packages/symfony/yaml), [PHPMailer](https://packagist.org/packages/phpmailer/phpmailer), [Fody](https://www.nuget.org/packages/Costura.Fody/), [MySqlConnector](https://www.nuget.org/packages/MySqlConnector/), [YamlDotNet](https://www.nuget.org/packages/YamlDotNet) \ No newline at end of file diff --git a/.gitignore b/.gitignore index a1177dfd..b7182d10 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,5 @@ logs/*.log /cli/obj /cli/.vs migrates.ini -/logs/*.txt \ No newline at end of file +/logs/*.txt +/cli/logs \ No newline at end of file diff --git a/Insomnia_2023-10-20.json b/Insomnia.json similarity index 100% rename from Insomnia_2023-10-20.json rename to Insomnia.json diff --git a/MythicalDash64 b/MythicalDash64 index 0b7e0cdd..a811939c 100755 Binary files a/MythicalDash64 and b/MythicalDash64 differ diff --git a/MythicalDashARM32 b/MythicalDashARM32 index c7a2ab0f..553e4030 100755 Binary files a/MythicalDashARM32 and b/MythicalDashARM32 differ diff --git a/MythicalDashARM64 b/MythicalDashARM64 index e63df210..29bad1eb 100755 Binary files a/MythicalDashARM64 and b/MythicalDashARM64 differ diff --git a/api/admin/settings/get.php b/api/admin/settings/get.php index 6350e079..3f5494ba 100644 --- a/api/admin/settings/get.php +++ b/api/admin/settings/get.php @@ -1,4 +1,5 @@ 200, "error" => null, "data" => array( - "name" => $settings['name'], - "logo" => $settings["logo"], + "name" => SettingsManager::getSetting("name"), + "logo" => SettingsManager::getSetting("logo"), "seo" => array( - "description" => $settings["seo_description"], - "keywords" => $settings["seo_keywords"], + "description" => SettingsManager::getSetting("seo_description"), + "keywords" => SettingsManager::getSetting("seo_keywords"), ), "turnstile" => array( - "enabled" => $settings["enable_turnstile"], - "sitekey" => $settings["turnstile_sitekey"], - "secretkey" => $settings["turnstile_secretkey"], + "enabled" => SettingsManager::getSetting("enable_turnstile"), + "sitekey" => SettingsManager::getSetting("turnstile_sitekey"), + "secretkey" => SettingsManager::getSetting("turnstile_secretkey"), ), "discord" => array( - "enabled" => $settings["enable_discord_link"], - "invite" => $settings["discord_invite"], - "serverid" => $settings["discord_serverid"], - "clientid" => $settings["discord_clientid"], - "clientsecret" => $settings["discord_clientsecret"], - "webhook" => $settings["discord_webhook"], + "enabled" => SettingsManager::getSetting("enable_discord_link"), + "invite" => SettingsManager::getSetting("discord_invite"), + "serverid" => SettingsManager::getSetting("discord_serverid"), + "clientid" => SettingsManager::getSetting("discord_clientid"), + "clientsecret" => SettingsManager::getSetting("discord_clientsecret"), + "webhook" => SettingsManager::getSetting("discord_webhook"), ), "mailserver" => array( - "enabled" => $settings["enable_smtp"], - "host" => $settings["smtpHost"], - "port" => $settings["smtpPort"], - "encryption" => $settings["smtpSecure"], - "username" => $settings["smtpUsername"], - "password" => $settings["smtpPassword"], - "email" => $settings["fromEmail"], + "enabled" => SettingsManager::getSetting("enable_smtp"), + "host" => SettingsManager::getSetting("smtpHost"), + "port" => SettingsManager::getSetting("smtpPort"), + "encryption" => SettingsManager::getSetting("smtpSecure"), + "username" => SettingsManager::getSetting("smtpUsername"), + "password" => SettingsManager::getSetting("smtpPassword"), + "email" => SettingsManager::getSetting("fromEmail"), ), "pterodactyl" => array( - "url" => $settings["PterodactylURL"], - "key" => $settings["PterodactylAPIKey"], + "url" => SettingsManager::getSetting("PterodactylURL"), + "key" => SettingsManager::getSetting("PterodactylAPIKey"), ), "mythicaldash" => array( - "version" => $settings["version"], + "version" => SettingsManager::getSetting("version"), ) ), ); diff --git a/api/admin/user/info.php b/api/admin/user/info.php index c22f1e59..da8af2ba 100644 --- a/api/admin/user/info.php +++ b/api/admin/user/info.php @@ -1,4 +1,5 @@ $userdb["panel_id"], "username" => $userdb['username'], "email" => $userdb['email'], - "first_name" => decrypt($userdb['first_name'], $ekey), - "last_name" => decrypt($userdb['last_name'], $ekey), + "first_name" => Encryption::decrypt($userdb['first_name'], $ekey), + "last_name" => Encryption::decrypt($userdb['last_name'], $ekey), "role" => $userdb['role'], "banned" => $userdb['banned'], "last_ip" => $userdb["last_ip"], diff --git a/api/admin/user/reset-password.php b/api/admin/user/reset-password.php index d1a4483c..ab949b26 100644 --- a/api/admin/user/reset-password.php +++ b/api/admin/user/reset-password.php @@ -1,4 +1,5 @@ 0) { $userdb = $conn->query("SELECT * FROM mythicaldash_users WHERE email = '" . $email . "'")->fetch_array(); - $skey = generate_keynoinfo(); + $skey = Encryption::generate_keynoinfo(); $conn->query("INSERT INTO `mythicaldash_resetpasswords` (`email`, `ownerkey`, `resetkeycode`, `ip_addres`) VALUES ('".$email."', '".$userdb['api_key']."', '".$skey."', '127.0.0.7');"); $rsp = array( "code" => 200, diff --git a/include/php-csrf.php b/app/CSRF.php similarity index 83% rename from include/php-csrf.php rename to app/CSRF.php index 67fc2e4f..105c185a 100644 --- a/include/php-csrf.php +++ b/app/CSRF.php @@ -43,7 +43,12 @@ * // You can use as a group name the form name * echo $csrf_tokens->input(); */ -class CSRF { + +namespace MythicalDash; + + +class CSRF +{ private $name; private $hashes; @@ -58,7 +63,8 @@ class CSRF { * @param integer $hashTime2Live Default seconds hash before expiration * @param integer $hashSize Default hash size in chars */ - function __construct ($session_name='csrf-lib', $input_name='key-awesome', $hashTime2Live=0, $hashSize=64) { + function __construct($session_name = 'csrf-lib', $input_name = 'key-awesome', $hashTime2Live = 0, $hashSize = 64) + { // Session mods $this->name = $session_name; // Form input name @@ -78,9 +84,11 @@ function __construct ($session_name='csrf-lib', $input_name='key-awesome', $hash * @param integer $max_hashes Clear old context hashes if more than this number * @return CSRF_Hash */ - private function generateHash ($context='', $time2Live=-1, $max_hashes=5) { + private function generateHash($context = '', $time2Live = -1, $max_hashes = 5) + { // If no time2live (or invalid) use default - if ($time2Live < 0) $time2Live = $this->hashTime2Live; + if ($time2Live < 0) + $time2Live = $this->hashTime2Live; // Generate new hash $hash = new CSRF_Hash($context, $time2Live, $this->hashSize); // Save it @@ -99,7 +107,8 @@ private function generateHash ($context='', $time2Live=-1, $max_hashes=5) { * @param integer $max_hashes max hashes to get * @return array array of hashes as strings */ - public function getHashes ($context='', $max_hashes=-1) { + public function getHashes($context = '', $max_hashes = -1) + { $len = count($this->hashes); $hashes = array(); // Check in the hash list @@ -118,7 +127,8 @@ public function getHashes ($context='', $max_hashes=-1) { * @param integer $max_hashes ignore first x hashes * @return integer number of deleted hashes */ - public function clearHashes ($context='', $max_hashes=0) { + public function clearHashes($context = '', $max_hashes = 0) + { $ignore = $max_hashes; $deleted = 0; // Check in the hash list @@ -141,9 +151,10 @@ public function clearHashes ($context='', $max_hashes=0) { * @param integer $max_hashes Clear old context hashes if more than this number * @return integer html input element code as a string */ - public function input ($context='', $time2Live=-1, $max_hashes=5) { + public function input($context = '', $time2Live = -1, $max_hashes = 5): string + { // Generate hash - $hash = $this->generateHash ($context, $time2Live, $max_hashes); + $hash = $this->generateHash($context, $time2Live, $max_hashes); // Generate html input string return ''; } @@ -156,9 +167,10 @@ public function input ($context='', $time2Live=-1, $max_hashes=5) { * @param integer $max_hashes Clear old context hashes if more than this number * @return integer html script element code as a string */ - public function script ($context='', $name='', $declaration='var', $time2Live=-1, $max_hashes=5) { + public function script($context = '', $name = '', $declaration = 'var', $time2Live = -1, $max_hashes = 5): string + { // Generate hash - $hash = $this->generateHash ($context, $time2Live, $max_hashes); + $hash = $this->generateHash($context, $time2Live, $max_hashes); // Variable name if (strlen($name) === 0) { $name = $this->inputName; @@ -175,9 +187,10 @@ public function script ($context='', $name='', $declaration='var', $time2Live=-1 * @param integer $max_hashes Clear old context hashes if more than this number * @return integer html script element code as a string */ - public function javascript ($context='', $name='', $declaration='var', $time2Live=-1, $max_hashes=5) { + public function javascript($context = '', $name = '', $declaration = 'var', $time2Live = -1, $max_hashes = 5): string + { // Generate hash - $hash = $this->generateHash ($context, $time2Live, $max_hashes); + $hash = $this->generateHash($context, $time2Live, $max_hashes); // Variable name if (strlen($name) === 0) { $name = $this->inputName; @@ -193,9 +206,10 @@ public function javascript ($context='', $name='', $declaration='var', $time2Liv * @param integer $max_hashes Clear old context hashes if more than this number * @return integer hash as a string */ - public function string ($context='', $time2Live=-1, $max_hashes=5) { + public function string($context = '', $time2Live = -1, $max_hashes = 5): string + { // Generate hash - $hash = $this->generateHash ($context, $time2Live, $max_hashes); + $hash = $this->generateHash($context, $time2Live, $max_hashes); // Generate html input string return $hash->get(); } @@ -205,16 +219,15 @@ public function string ($context='', $time2Live=-1, $max_hashes=5) { * @param string $context Name of the form * @return boolean Valid or not */ - public function validate ($context='', $hash = null) { + public function validate($context = '', $hash = null) + { // If hash was not given, find hash if (is_null($hash)) { if (isset($_POST[$this->inputName])) { $hash = $_POST[$this->inputName]; - } - else if (isset($_GET[$this->inputName])) { + } else if (isset($_GET[$this->inputName])) { $hash = $_GET[$this->inputName]; - } - else { + } else { return false; } } @@ -233,7 +246,8 @@ public function validate ($context='', $hash = null) { /** * Load hash list */ - private function _load () { + private function _load() + { $this->hashes = array(); // If there are hashes on the session if (isset($_SESSION[$this->name])) { @@ -256,12 +270,14 @@ private function _load () { /** * Save hash list */ - private function _save () { + private function _save() + { $_SESSION[$this->name] = serialize($this->hashes); } } -class CSRF_Hash { +class CSRF_Hash +{ private $hash; private $context; @@ -272,7 +288,8 @@ class CSRF_Hash { * @param string $context [description] * @param integer $time2Live Number of seconds before expiration */ - function __construct($context, $time2Live=0, $hashSize=64) { + function __construct($context, $time2Live = 0, $hashSize = 64) + { // Save context name $this->context = $context; @@ -282,8 +299,7 @@ function __construct($context, $time2Live=0, $hashSize=64) { // Set expiration time if ($time2Live > 0) { $this->expire = time() + $time2Live; - } - else { + } else { $this->expire = 0; } } @@ -293,15 +309,17 @@ function __construct($context, $time2Live=0, $hashSize=64) { * @param int $n Size in bytes * @return string The generated hash */ - private function _generateHash ($n) { - return bin2hex(openssl_random_pseudo_bytes($n/2)); + private function _generateHash($n) + { + return bin2hex(openssl_random_pseudo_bytes($n / 2)); } /** * Check if hash has expired * @return boolean */ - public function hasExpire () { + public function hasExpire() + { if ($this->expire === 0 || $this->expire > time()) { return false; } @@ -312,7 +330,8 @@ public function hasExpire () { * Verify hash * @return boolean */ - public function verify ($hash, $context='') { + public function verify($hash, $context = '') + { if (strcmp($context, $this->context) === 0 && !$this->hasExpire() && strcmp($hash, $this->hash) === 0) { return true; } @@ -323,7 +342,8 @@ public function verify ($hash, $context='') { * Check Context * @return boolean */ - public function inContext ($context='') { + public function inContext($context = '') + { if (strcmp($context, $this->context) === 0) { return true; } @@ -334,7 +354,8 @@ public function inContext ($context='') { * Get hash * @return string */ - public function get () { + public function get() + { return $this->hash; } } \ No newline at end of file diff --git a/app/CloudFlare/Captcha.php b/app/CloudFlare/Captcha.php new file mode 100644 index 00000000..99d16016 --- /dev/null +++ b/app/CloudFlare/Captcha.php @@ -0,0 +1,36 @@ + $cf_secret_key, + "response" => $cf_turnstile_response, + "remoteip" => $cf_connecting_ip + ); + + $url = "https://challenges.cloudflare.com/turnstile/v0/siteverify"; + + $options = array( + "http" => array( + "header" => "Content-Type: application/x-www-form-urlencoded\r\n", + "method" => "POST", + "content" => http_build_query($data) + ) + ); + $context = stream_context_create($options); + $result = file_get_contents($url, false, $context); + + if ($result == false) { + return false; + } + + $result = json_decode($result, true); + + return $result["success"]; + } + +} +?> \ No newline at end of file diff --git a/app/Database/Connect.php b/app/Database/Connect.php new file mode 100644 index 00000000..ecc66b62 --- /dev/null +++ b/app/Database/Connect.php @@ -0,0 +1,29 @@ +connect_error) { + ErrorHandler::ShowCritical("Failed to connect to the MySQL server: ".$conn->connect_error); + die(); + } + + return $conn; + } +} +?> \ No newline at end of file diff --git a/app/Encryption.php b/app/Encryption.php new file mode 100644 index 00000000..3d23039a --- /dev/null +++ b/app/Encryption.php @@ -0,0 +1,74 @@ + \ No newline at end of file diff --git a/app/ErrorHandler.php b/app/ErrorHandler.php new file mode 100644 index 00000000..74392392 --- /dev/null +++ b/app/ErrorHandler.php @@ -0,0 +1,312 @@ + "https://api.mythicalsystems.me/problem?authKey=AxWTnecj85SI4bG6rIP8bvw2uCF7W5MmkJcQIkrYS80MzeTraQWyICL690XOio8F&project=mythicaldash&type=error&title=" . $title . "&message=" . $text, + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => "", + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 30, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => "GET", + CURLOPT_POSTFIELDS => "", + CURLOPT_HTTPHEADER => [ + "Content-Type: application/json", + "User-Agent: insomnia/8.2.0" + ], + ]); + + curl_exec($curl); + } + + public static function Warning($title, $text) + { + $curl = curl_init(); + + curl_setopt_array($curl, [ + CURLOPT_URL => "https://api.mythicalsystems.me/problem?authKey=AxWTnecj85SI4bG6rIP8bvw2uCF7W5MmkJcQIkrYS80MzeTraQWyICL690XOio8F&project=mythicaldash&type=warning&title=" . $title . "&message=" . $text, + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => "", + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 30, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => "GET", + CURLOPT_POSTFIELDS => "", + CURLOPT_HTTPHEADER => [ + "Content-Type: application/json", + "User-Agent: insomnia/8.2.0" + ], + ]); + + curl_exec($curl); + } + public static function Critical($title, $text) + { + $curl = curl_init(); + + curl_setopt_array($curl, [ + CURLOPT_URL => "https://api.mythicalsystems.me/problem?authKey=AxWTnecj85SI4bG6rIP8bvw2uCF7W5MmkJcQIkrYS80MzeTraQWyICL690XOio8F&project=mythicaldash&type=critical&title=" . $title . "&message=" . $text, + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => "", + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 30, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => "GET", + CURLOPT_POSTFIELDS => "", + CURLOPT_HTTPHEADER => [ + "Content-Type: application/json", + "User-Agent: insomnia/8.2.0" + ], + ]); + + curl_exec($curl); + } + public static function ShowCritical($message) + { + ErrorHandler::Critical("Automated error report", $message); + ob_start(); + ?> + + + + + + + MythicalDash - Critical Error + + + + + + + + +
+
+
Kindly hold for a moment as we gather the error report.
+
+
+
+
+
+

Critical Error

+
+
+

+ We are sorry, but something went wrong. +

+
+ + + +
+

+ We apologize for the inconvenience. Please report this to the site administrator. +

+
+
+
+ + + + + + + \ No newline at end of file diff --git a/app/Main.php b/app/Main.php new file mode 100644 index 00000000..f6c468bd --- /dev/null +++ b/app/Main.php @@ -0,0 +1,28 @@ + \ No newline at end of file diff --git a/app/SessionManager.php b/app/SessionManager.php new file mode 100644 index 00000000..66e8749b --- /dev/null +++ b/app/SessionManager.php @@ -0,0 +1,101 @@ +dbConnection = $dbConnector->connectToDatabase(); + $this->encryption = new Encryption(); + } + + public function authenticateUser() + { + if (isset($_COOKIE['token'])) { + $session_id = mysqli_real_escape_string($this->dbConnection,$_COOKIE['token']); + $query = "SELECT * FROM mythicaldash_users WHERE api_key='" . $session_id . "'"; + $result = mysqli_query($this->dbConnection, $query); + + if (mysqli_num_rows($result) > 0) { + session_start(); + $_SESSION["token"] = $session_id; + $_SESSION['loggedin'] = true; + } else { + $this->redirectToLogin($this->getFullUrl()); + } + } else { + $this->redirectToLogin($this->getFullUrl()); + } + } + + public function getUserInfo($info) + { + $session_id = mysqli_real_escape_string($this->dbConnection, $_COOKIE["token"]); + $safeInfo = $this->dbConnection->real_escape_string($info); + $query = "SELECT `$safeInfo` FROM mythicaldash_users WHERE api_key='$session_id' LIMIT 1"; + $result = $this->dbConnection->query($query); + + if ($result && $result->num_rows > 0) { + $row = $result->fetch_assoc(); + return $row[$info]; + } else { + return null; // User or data not found + } + } + + private function redirectToLogin($fullUrl) + { + $this->deleteCookies(); + header('location: /auth/login?r=' . $fullUrl); + die(); + } + + private function deleteCookies() + { + if (isset($_SERVER['HTTP_COOKIE'])) { + $cookies = explode(';', $_SERVER['HTTP_COOKIE']); + foreach ($cookies as $cookie) { + $parts = explode('=', $cookie); + $name = trim($parts[0]); + setcookie($name, '', time() - 1000); + setcookie($name, '', time() - 1000, '/'); + } + } + } + public function getIP() + { + if (isset($_SERVER["HTTP_CF_CONNECTING_IP"])) { + $_SERVER['REMOTE_ADDR'] = $_SERVER["HTTP_CF_CONNECTING_IP"]; + $_SERVER['HTTP_CLIENT_IP'] = $_SERVER["HTTP_CF_CONNECTING_IP"]; + } + $client = @$_SERVER['HTTP_CLIENT_IP']; + $forward = @$_SERVER['HTTP_X_FORWARDED_FOR']; + $remote = $_SERVER['REMOTE_ADDR']; + + if (filter_var($client, FILTER_VALIDATE_IP)) { + $ip = $client; + } elseif (filter_var($forward, FILTER_VALIDATE_IP)) { + $ip = $forward; + } else { + $ip = $remote; + } + + return $ip; + } + private function getFullUrl() + { + $fullUrl = "http"; + if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) { + $fullUrl .= "s"; + } + $fullUrl .= "://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; + return $fullUrl; + } +} +?> \ No newline at end of file diff --git a/app/SettingsManager.php b/app/SettingsManager.php new file mode 100644 index 00000000..11cf29cf --- /dev/null +++ b/app/SettingsManager.php @@ -0,0 +1,25 @@ +connectToDatabase(); + $safeSettingName = $conn->real_escape_string($settingName); + + $query = "SELECT `$safeSettingName` FROM mythicaldash_settings LIMIT 1"; + $result = $conn->query($query); + + if ($result && $result->num_rows > 0) { + $row = $result->fetch_assoc(); + $conn->close(); + return $row[$settingName]; + } else { + $conn->close(); + return null; + } + } +} \ No newline at end of file diff --git a/app/Telemetry.php b/app/Telemetry.php new file mode 100644 index 00000000..eae4a70c --- /dev/null +++ b/app/Telemetry.php @@ -0,0 +1,92 @@ + "https://api.mythicalsystems.me/telemetry?project=mythicaldash&action=NewUser&authKey=AxWTnecj85SI4bG6rIP8bvw2uCF7W5MmkJcQIkrYS80MzeTraQWyICL690XOio8F", + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => "", + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 30, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => "GET", + CURLOPT_POSTFIELDS => "", + ]); + + curl_exec($curl); + } + public static function NewServer() + { + $curl = curl_init(); + + curl_setopt_array($curl, [ + CURLOPT_URL => "https://api.mythicalsystems.me/telemetry?project=mythicaldash&action=NewWebsite&authKey=AxWTnecj85SI4bG6rIP8bvw2uCF7W5MmkJcQIkrYS80MzeTraQWyICL690XOio8F", + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => "", + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 30, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => "GET", + CURLOPT_POSTFIELDS => "", + ]); + + curl_exec($curl); + } + public static function NewInstall() + { + $curl = curl_init(); + + curl_setopt_array($curl, [ + CURLOPT_URL => "https://api.mythicalsystems.me/telemetry?project=mythicaldash&action=NewInstall&authKey=AxWTnecj85SI4bG6rIP8bvw2uCF7W5MmkJcQIkrYS80MzeTraQWyICL690XOio8F", + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => "", + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 30, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => "GET", + CURLOPT_POSTFIELDS => "", + ]); + + curl_exec($curl); + } + public static function NewNode() + { + $curl = curl_init(); + + curl_setopt_array($curl, [ + CURLOPT_URL => "https://api.mythicalsystems.me/telemetry?project=mythicaldash&action=NewNode&authKey=AxWTnecj85SI4bG6rIP8bvw2uCF7W5MmkJcQIkrYS80MzeTraQWyICL690XOio8F", + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => "", + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 30, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => "GET", + CURLOPT_POSTFIELDS => "", + ]); + + curl_exec($curl); + } + public static function NewTicket() + { + $curl = curl_init(); + + curl_setopt_array($curl, [ + CURLOPT_URL => "https://api.mythicalsystems.me/telemetry?project=mythicaldash&action=NewTicket&authKey=AxWTnecj85SI4bG6rIP8bvw2uCF7W5MmkJcQIkrYS80MzeTraQWyICL690XOio8F", + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => "", + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 30, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => "GET", + CURLOPT_POSTFIELDS => "", + ]); + + curl_exec($curl); + } +} +?> \ No newline at end of file diff --git a/bot/README.md b/bot/README.md index 8b39b3f8..4e751b8c 100644 --- a/bot/README.md +++ b/bot/README.md @@ -1,5 +1,5 @@ -# MythicalDash : Bot -The bot used for MythicalDash +# MythicalDash EOL : Bot +The old bot used for MythicalDash To use it you have to download pycord: ```bash diff --git a/cli/Program.cs b/cli/Program.cs index 16bac220..efac9415 100644 --- a/cli/Program.cs +++ b/cli/Program.cs @@ -21,7 +21,6 @@ __ __ _ _ _ _ _____ _ "; public static string version = "1.0.0"; public static bool skiposcheck = false; - public static ConfigHandler cfg_handler = new ConfigHandler(); public static Debug dbg = new Debug(); public static Encryption encryption = new Encryption(); public static IConsole iconsole = new IConsole(); @@ -34,17 +33,17 @@ public static void Main(string[] args) Console.WriteLine(ascii); if (skiposcheck == false) { - if (!System.OperatingSystem.IsLinux()) + if (!OperatingSystem.IsLinux()) { logger.Log(LogType.Error, "Sorry but this app runs on linux!"); Environment.Exit(0x0); } } - if (args.Contains("-generate-config")) + if (args.Contains("-environment:newconfig")) { try { - cfg_handler.CreateConfig(); + ConfigHandler.CreateConfig(); Environment.Exit(0x0); } catch (Exception ex) @@ -54,7 +53,7 @@ public static void Main(string[] args) logger.Log(LogType.Info, "Configuration file generated."); Environment.Exit(0x0); } - else if (args.Contains("-delete-config")) + else if (args.Contains("-environment:delconfig")) { logger.Log(LogType.Info, "Wow, buddy, this command shall be run only if you know what it does."); logger.Log(LogType.Info, "Are you sure you want to proceed? (yes/no)"); @@ -64,7 +63,7 @@ public static void Main(string[] args) { try { - cfg_handler.DeleteConfig(); + ConfigHandler.DeleteConfig(); Environment.Exit(0x0); } catch (Exception ex) @@ -85,7 +84,7 @@ public static void Main(string[] args) Environment.Exit(0x0); } } - else if (args.Contains("-key-generate")) + else if (args.Contains("-key:generate")) { logger.Log(LogType.Info, "Wow, buddy, this command shall be run only once, and that's when you set up the dashboard. Please do not run this command if you don't know what it does or if you have users in your database."); logger.Log(LogType.Info, "Are you sure you want to proceed? (yes/no)"); @@ -116,7 +115,7 @@ public static void Main(string[] args) Environment.Exit(0x0); } } - else if (args.Contains("-enable-debug")) + else if (args.Contains("-debug:enable")) { try { @@ -129,7 +128,7 @@ public static void Main(string[] args) Environment.Exit(0x0); } } - else if (args.Contains("-enable-console")) + else if (args.Contains("-console:enable")) { try { @@ -142,7 +141,7 @@ public static void Main(string[] args) Environment.Exit(0x0); } } - else if (args.Contains("-disable-console")) + else if (args.Contains("-console:disable")) { try { @@ -155,7 +154,7 @@ public static void Main(string[] args) Environment.Exit(0x0); } } - else if (args.Contains("-disable-debug")) + else if (args.Contains("-debug:disable")) { try { @@ -168,7 +167,7 @@ public static void Main(string[] args) Environment.Exit(0x0); } } - else if (args.Contains("-enable-silent-debug")) + else if (args.Contains("-debug:silent:on")) { try { @@ -181,7 +180,7 @@ public static void Main(string[] args) Environment.Exit(0x0); } } - else if (args.Contains("-disable-silent-debug")) + else if (args.Contains("-debug:silent:off")) { try { @@ -199,17 +198,17 @@ public static void Main(string[] args) logger.Log(LogType.Info, "You are running version: " + version); Environment.Exit(0x0); } - else if (args.Contains("-config-database")) + else if (args.Contains("-environment:database")) { db.Configurator(); Environment.Exit(0x0); } - else if (args.Contains("-migrate-database-now")) + else if (args.Contains("-migrate")) { mg.Now(); Environment.Exit(0x0); } - else if (args.Contains("-config-setup")) + else if (args.Contains("-environment:setup")) { sh.Setup(); Environment.Exit(0x0); @@ -217,24 +216,24 @@ public static void Main(string[] args) else if (args.Contains("-help")) { Console.Clear(); - Console.WriteLine("--------------------------------------------MythicalDash CLI-------------------------------------------------"); - Console.WriteLine("| |"); - Console.WriteLine("| -help | Opens a help menu with the available commands. |"); - Console.WriteLine("| -generate-config | Generate a new config file for MythicalDash. |"); - Console.WriteLine("| -delete-config | Delete the config file for MythicalDash. |"); - Console.WriteLine("| -key-generate | Generate a new encryption key for MythicalDash. |"); - Console.WriteLine("| -enable-debug | Enables the debug mode to display error messages for MythicalDash. |"); - Console.WriteLine("| -disable-console | Disables the browser's inspect element or console from being used on MythicalDash. |"); - Console.WriteLine("| -enable-console | Enables the browser's inspect element or console on MythicalDash. |"); - Console.WriteLine("| -disable-debug | Disables the debug mode to hide error messages for MythicalDash. |"); - Console.WriteLine("| -enable-silent-debug | Hides the debug mode online status messages from being disabled. |"); - Console.WriteLine("| -disable-silent-debug | Shows the debug mode online status messages from being enabled. |"); - Console.WriteLine("| -config-database | Add the database connection to your config file. |"); - Console.WriteLine("| -migrate-database-now | Create and setup all tables in the database |"); - Console.WriteLine("| -config-setup | This is a command to help you setup your dashboard! |"); - Console.WriteLine("| -version | See the version / build version of the CLI. |"); - Console.WriteLine("| |"); - Console.WriteLine("-------------------------------------------------------------------------------------------------------------"); + Console.WriteLine("β•”β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘βŠ³ MythicalDash CLI βŠ²β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β•—"); + Console.WriteLine("β€– β€–"); + Console.WriteLine("β€– -help β€– Opens a help menu with the available commands. β€–"); + Console.WriteLine("β€– -environment:newconfig β€– Generate a new config file for MythicalDash. β€–"); + Console.WriteLine("β€– -environment:delconfig β€– Delete the config file for MythicalDash. β€–"); + Console.WriteLine("β€– -environment:database β€– Add the database connection to your config file. β€–"); + Console.WriteLine("β€– -environment:setup β€– This is a command to help you setup your dashboard! β€–"); + Console.WriteLine("β€– -key:generate β€– Generate a new encryption key for MythicalDash. β€–"); + Console.WriteLine("β€– -debug:enable β€– Enables the debug mode to display error messages for MythicalDash. β€–"); + Console.WriteLine("β€– -console:disable β€– Disables the browser's inspect element or console from being used on MythicalDash. β€–"); + Console.WriteLine("β€– -console:enable β€– Enables the browser's inspect element or console on MythicalDash. β€–"); + Console.WriteLine("β€– -debug:disable β€– Disables the debug mode to hide error messages for MythicalDash. β€–"); + Console.WriteLine("β€– -debug:silent:on β€– Hides the debug mode online status messages from being disabled. β€–"); + Console.WriteLine("β€– -debug:silent:off β€– Shows the debug mode online status messages from being enabled. β€–"); + Console.WriteLine("β€– -migrate β€– Create and setup all tables in the database β€–"); + Console.WriteLine("β€– -version β€– See the version / build version of the CLI. β€–"); + Console.WriteLine("β€– β€–"); + Console.WriteLine("β•šβ‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘βŠ³ Copyright 2023 MythicalSystems βŠ²β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β‰‘β•"); Environment.Exit(0x0); } else if (args.Length > 0) diff --git a/cli/scripts/ConfigHandler.cs b/cli/scripts/ConfigHandler.cs index 4b6bf69a..707ed2d5 100644 --- a/cli/scripts/ConfigHandler.cs +++ b/cli/scripts/ConfigHandler.cs @@ -6,7 +6,7 @@ namespace MythicalDash { public class ConfigHandler { - public void DeleteConfig() { + public static void DeleteConfig() { string filePath = "config.yml"; if (File.Exists(filePath)) { File.Delete(filePath); @@ -16,7 +16,7 @@ public void DeleteConfig() { Environment.Exit(0x0); } } - public void CreateConfig() + public static void CreateConfig() { string filePath = "config.yml"; diff --git a/composer.json b/composer.json index 324eecd7..4c0511aa 100644 --- a/composer.json +++ b/composer.json @@ -20,9 +20,11 @@ "php": ">=8.0.0", "mythicalsystems/php-router": "^1.0", "symfony/yaml": "^6.3", - "phpseclib/phpseclib": "^3.0", - "phpmailer/phpmailer": "^6.8", - "livaco/easydiscordwebhook": "^2.0", - "mythicalsystems/aapanelapi": "^1.0" + "phpmailer/phpmailer": "^6.8" + }, + "autoload": { + "psr-4": { + "MythicalDash\\": "app/" + } } } diff --git a/composer.lock b/composer.lock index cd15ae65..ed27fba2 100644 --- a/composer.lock +++ b/composer.lock @@ -4,111 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "f138f7bf8d8527a2f12614d8e5574aed", + "content-hash": "0ad983bd673dffc8c6a1069c5facd12b", "packages": [ - { - "name": "livaco/easydiscordwebhook", - "version": "2.0.0", - "source": { - "type": "git", - "url": "https://github.com/LivacoNew/EasyDiscordWebhook.git", - "reference": "0c9ff91f7eef4994632b92a65ce772aefbd1f70c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/LivacoNew/EasyDiscordWebhook/zipball/0c9ff91f7eef4994632b92a65ce772aefbd1f70c", - "reference": "0c9ff91f7eef4994632b92a65ce772aefbd1f70c", - "shasum": "" - }, - "type": "library", - "autoload": { - "psr-4": { - "Livaco\\EasyDiscordWebhook\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "Apache-2.0" - ], - "authors": [ - { - "name": "Livaco", - "homepage": "https://www.livaco.dev/" - } - ], - "description": "An simple, lightweight, easy to use library to allow you to create and send discord webhooks in PHP.", - "homepage": "https://github.com/LivacoNew/EasyDiscordWebhook", - "keywords": [ - "discord", - "php", - "webhook" - ], - "support": { - "issues": "https://github.com/LivacoNew/EasyDiscordWebhook/issues", - "source": "https://github.com/LivacoNew/EasyDiscordWebhook/tree/2.0.0" - }, - "time": "2023-01-16T19:23:43+00:00" - }, - { - "name": "mythicalsystems/aapanelapi", - "version": "1.0.1", - "source": { - "type": "git", - "url": "https://github.com/MythicalLTD/AAPanel-API.git", - "reference": "a25739b9370fa4ff5c1ca597f4abc36d322e1f37" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/MythicalLTD/AAPanel-API/zipball/a25739b9370fa4ff5c1ca597f4abc36d322e1f37", - "reference": "a25739b9370fa4ff5c1ca597f4abc36d322e1f37", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "Mythicalsystems\\AaPanelApi\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "NaysKutzu", - "email": "ghermancassian2008@gmail.com" - } - ], - "description": "AAPanel-PHP is a library that allows you to interact with your AAPanel account using PHP. It provides a simple and easy-to-use API that you can use to manage your AAPanel account, such as creating and managing users, domains, and websites.", - "keywords": [ - "AAPanel", - "aapanel-api", - "mythicalsystems", - "nayskutzu" - ], - "support": { - "issues": "https://github.com/MythicalLTD/AAPanel-API/issues", - "source": "https://github.com/MythicalLTD/AAPanel-API/tree/1.0.1" - }, - "funding": [ - { - "url": "https://paypal.me/mythicalsystems", - "type": "custom" - }, - { - "url": "https://github.com/nayskutzu", - "type": "github" - }, - { - "url": "https://ko-fi.com/nayskutzu", - "type": "ko_fi" - } - ], - "time": "2023-08-12T10:21:16+00:00" - }, { "name": "mythicalsystems/php-router", "version": "1.0.3", @@ -166,123 +63,6 @@ }, "time": "2023-08-27T16:23:31+00:00" }, - { - "name": "paragonie/constant_time_encoding", - "version": "v2.6.3", - "source": { - "type": "git", - "url": "https://github.com/paragonie/constant_time_encoding.git", - "reference": "58c3f47f650c94ec05a151692652a868995d2938" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/paragonie/constant_time_encoding/zipball/58c3f47f650c94ec05a151692652a868995d2938", - "reference": "58c3f47f650c94ec05a151692652a868995d2938", - "shasum": "" - }, - "require": { - "php": "^7|^8" - }, - "require-dev": { - "phpunit/phpunit": "^6|^7|^8|^9", - "vimeo/psalm": "^1|^2|^3|^4" - }, - "type": "library", - "autoload": { - "psr-4": { - "ParagonIE\\ConstantTime\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Paragon Initiative Enterprises", - "email": "security@paragonie.com", - "homepage": "https://paragonie.com", - "role": "Maintainer" - }, - { - "name": "Steve 'Sc00bz' Thomas", - "email": "steve@tobtu.com", - "homepage": "https://www.tobtu.com", - "role": "Original Developer" - } - ], - "description": "Constant-time Implementations of RFC 4648 Encoding (Base-64, Base-32, Base-16)", - "keywords": [ - "base16", - "base32", - "base32_decode", - "base32_encode", - "base64", - "base64_decode", - "base64_encode", - "bin2hex", - "encoding", - "hex", - "hex2bin", - "rfc4648" - ], - "support": { - "email": "info@paragonie.com", - "issues": "https://github.com/paragonie/constant_time_encoding/issues", - "source": "https://github.com/paragonie/constant_time_encoding" - }, - "time": "2022-06-14T06:56:20+00:00" - }, - { - "name": "paragonie/random_compat", - "version": "v9.99.100", - "source": { - "type": "git", - "url": "https://github.com/paragonie/random_compat.git", - "reference": "996434e5492cb4c3edcb9168db6fbb1359ef965a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/paragonie/random_compat/zipball/996434e5492cb4c3edcb9168db6fbb1359ef965a", - "reference": "996434e5492cb4c3edcb9168db6fbb1359ef965a", - "shasum": "" - }, - "require": { - "php": ">= 7" - }, - "require-dev": { - "phpunit/phpunit": "4.*|5.*", - "vimeo/psalm": "^1" - }, - "suggest": { - "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes." - }, - "type": "library", - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Paragon Initiative Enterprises", - "email": "security@paragonie.com", - "homepage": "https://paragonie.com" - } - ], - "description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7", - "keywords": [ - "csprng", - "polyfill", - "pseudorandom", - "random" - ], - "support": { - "email": "info@paragonie.com", - "issues": "https://github.com/paragonie/random_compat/issues", - "source": "https://github.com/paragonie/random_compat" - }, - "time": "2020-10-15T08:29:30+00:00" - }, { "name": "phpmailer/phpmailer", "version": "v6.8.1", @@ -363,116 +143,6 @@ ], "time": "2023-08-29T08:26:30+00:00" }, - { - "name": "phpseclib/phpseclib", - "version": "3.0.23", - "source": { - "type": "git", - "url": "https://github.com/phpseclib/phpseclib.git", - "reference": "866cc78fbd82462ffd880e3f65692afe928bed50" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/866cc78fbd82462ffd880e3f65692afe928bed50", - "reference": "866cc78fbd82462ffd880e3f65692afe928bed50", - "shasum": "" - }, - "require": { - "paragonie/constant_time_encoding": "^1|^2", - "paragonie/random_compat": "^1.4|^2.0|^9.99.99", - "php": ">=5.6.1" - }, - "require-dev": { - "phpunit/phpunit": "*" - }, - "suggest": { - "ext-dom": "Install the DOM extension to load XML formatted public keys.", - "ext-gmp": "Install the GMP (GNU Multiple Precision) extension in order to speed up arbitrary precision integer arithmetic operations.", - "ext-libsodium": "SSH2/SFTP can make use of some algorithms provided by the libsodium-php extension.", - "ext-mcrypt": "Install the Mcrypt extension in order to speed up a few other cryptographic operations.", - "ext-openssl": "Install the OpenSSL extension in order to speed up a wide variety of cryptographic operations." - }, - "type": "library", - "autoload": { - "files": [ - "phpseclib/bootstrap.php" - ], - "psr-4": { - "phpseclib3\\": "phpseclib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jim Wigginton", - "email": "terrafrost@php.net", - "role": "Lead Developer" - }, - { - "name": "Patrick Monnerat", - "email": "pm@datasphere.ch", - "role": "Developer" - }, - { - "name": "Andreas Fischer", - "email": "bantu@phpbb.com", - "role": "Developer" - }, - { - "name": "Hans-JΓΌrgen Petrich", - "email": "petrich@tronic-media.com", - "role": "Developer" - }, - { - "name": "Graham Campbell", - "email": "graham@alt-three.com", - "role": "Developer" - } - ], - "description": "PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH2, SFTP, X.509 etc.", - "homepage": "http://phpseclib.sourceforge.net", - "keywords": [ - "BigInteger", - "aes", - "asn.1", - "asn1", - "blowfish", - "crypto", - "cryptography", - "encryption", - "rsa", - "security", - "sftp", - "signature", - "signing", - "ssh", - "twofish", - "x.509", - "x509" - ], - "support": { - "issues": "https://github.com/phpseclib/phpseclib/issues", - "source": "https://github.com/phpseclib/phpseclib/tree/3.0.23" - }, - "funding": [ - { - "url": "https://github.com/terrafrost", - "type": "github" - }, - { - "url": "https://www.patreon.com/phpseclib", - "type": "patreon" - }, - { - "url": "https://tidelift.com/funding/github/packagist/phpseclib/phpseclib", - "type": "tidelift" - } - ], - "time": "2023-09-18T17:22:01+00:00" - }, { "name": "symfony/deprecation-contracts", "version": "v3.3.0", diff --git a/crons/server.php b/crons/server.php index bc284806..b4eb5ee3 100644 --- a/crons/server.php +++ b/crons/server.php @@ -1,19 +1,11 @@ -connect_error) { - echo ''; + echo "[WARNING] We can't connect to the MySQL server."; } -//SETTINGS TABLE -$settings = $conn->query("SELECT * FROM mythicaldash_settings")->fetch_array(); $timeAtStart = time(); $i = 0; $nodesFull = 0; @@ -77,11 +67,11 @@ continue; } $egg = $eggd->fetch_object(); - $egginfocurl = curl_init($settings['PterodactylURL'] . "/api/application/nests/" . $egg->nest . "/eggs/" . $egg->egg); + $egginfocurl = curl_init(SettingsManager::getSetting("PterodactylURL") . "/api/application/nests/" . $egg->nest . "/eggs/" . $egg->egg); $httpheader = array( 'Accept: application/json', 'Content-Type: application/json', - 'Authorization: Bearer ' . $settings['PterodactylAPIKey'] + 'Authorization: Bearer ' . SettingsManager::getSetting("PterodactylAPIKey") ); curl_setopt($egginfocurl, CURLOPT_HTTPHEADER, $httpheader); curl_setopt($egginfocurl, CURLOPT_RETURNTRANSFER, 1); @@ -91,7 +81,7 @@ $docker_image = $response['attributes']['docker_image']; $startup = $response['attributes']['startup']; $ports = $server['xtra_ports'] + 1; - $panelcurl = curl_init($settings['PterodactylURL'] . "/api/application/servers"); + $panelcurl = curl_init(SettingsManager::getSetting("PterodactylURL") . "/api/application/servers"); $postfields = array( 'name' => $server['name'], 'user' => $server['puid'], @@ -133,7 +123,9 @@ 'LIT_PACKAGES' => '', 'JS_FILE' => 'index.js', 'JARFILE' => 'app.jar', - 'MAIN_FILE' => 'index.js' + 'MAIN_FILE' => 'index.js', + 'PROJECT_FILE' => 'MyProject.sln', + 'PROJECT_DIR' => '/home/container' ), 'limits' => array( 'memory' => $server['ram'], @@ -159,7 +151,7 @@ curl_setopt($panelcurl, CURLOPT_HTTPHEADER, array( 'Accept: application/json', 'Content-Type: application/json', - 'Authorization: Bearer ' . $settings["PterodactylAPIKey"] + 'Authorization: Bearer ' . SettingsManager::getSetting("PterodactylAPIKey") )); $result = curl_exec($panelcurl); curl_close($panelcurl); diff --git a/functions/base64.php b/functions/base64.php deleted file mode 100644 index fcfe39c0..00000000 --- a/functions/base64.php +++ /dev/null @@ -1,11 +0,0 @@ - diff --git a/functions/cloudflare.php b/functions/cloudflare.php deleted file mode 100644 index 9aecb490..00000000 --- a/functions/cloudflare.php +++ /dev/null @@ -1,30 +0,0 @@ - $cf_secret_key, - "response" => $cf_turnstile_response, - "remoteip" => $cf_connecting_ip - ); - - $url = "https://challenges.cloudflare.com/turnstile/v0/siteverify"; - - $options = array( - "http" => array( - "header" => "Content-Type: application/x-www-form-urlencoded\r\n", - "method" => "POST", - "content" => http_build_query($data) - ) - ); - $context = stream_context_create($options); - $result = file_get_contents($url, false, $context); - - if ($result == false) { - return false; - } - - $result = json_decode($result, true); - - return $result["success"]; -} -?> \ No newline at end of file diff --git a/functions/encryption.php b/functions/encryption.php deleted file mode 100644 index ef8e9953..00000000 --- a/functions/encryption.php +++ /dev/null @@ -1,29 +0,0 @@ - \ No newline at end of file diff --git a/functions/getclientip.php b/functions/getclientip.php deleted file mode 100644 index 636fa12e..00000000 --- a/functions/getclientip.php +++ /dev/null @@ -1,17 +0,0 @@ - \ No newline at end of file diff --git a/functions/https.php b/functions/https.php deleted file mode 100644 index 5a5df882..00000000 --- a/functions/https.php +++ /dev/null @@ -1,9 +0,0 @@ - \ No newline at end of file diff --git a/functions/keygen.php b/functions/keygen.php deleted file mode 100644 index a2f4983d..00000000 --- a/functions/keygen.php +++ /dev/null @@ -1,32 +0,0 @@ - \ No newline at end of file diff --git a/functions/logout.php b/functions/logout.php deleted file mode 100644 index 0aea3f45..00000000 --- a/functions/logout.php +++ /dev/null @@ -1,18 +0,0 @@ -query("SELECT * FROM mythicaldash_users WHERE api_key = '".$_COOKIE['token']. "'")->fetch_array(); -$username = $userdb['username']; -if (!$username == "") -{ - if (isset($_SERVER['HTTP_COOKIE'])) { - $cookies = explode(';', $_SERVER['HTTP_COOKIE']); - foreach($cookies as $cookie) { - $parts = explode('=', $cookie); - $name = trim($parts[0]); - setcookie($name, '', time()-1000); - setcookie($name, '', time()-1000, '/'); - } - } - header('location: /auth/login'); -} -?> \ No newline at end of file diff --git a/functions/passwordgen.php b/functions/passwordgen.php deleted file mode 100644 index b88e378a..00000000 --- a/functions/passwordgen.php +++ /dev/null @@ -1,14 +0,0 @@ - \ No newline at end of file diff --git a/functions/report.php b/functions/report.php deleted file mode 100644 index b90fab64..00000000 --- a/functions/report.php +++ /dev/null @@ -1,66 +0,0 @@ - "https://api.mythicalsystems.me/problem?authKey=AxWTnecj85SI4bG6rIP8bvw2uCF7W5MmkJcQIkrYS80MzeTraQWyICL690XOio8F&project=mythicaldash&type=error&title=".$title."&message=".$text, - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => "", - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 30, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => "GET", - CURLOPT_POSTFIELDS => "", - CURLOPT_HTTPHEADER => [ - "Content-Type: application/json", - "User-Agent: insomnia/8.2.0" - ], - ]); - - curl_exec($curl); -} - -function Warning($title, $text) -{ - $curl = curl_init(); - - curl_setopt_array($curl, [ - CURLOPT_URL => "https://api.mythicalsystems.me/problem?authKey=AxWTnecj85SI4bG6rIP8bvw2uCF7W5MmkJcQIkrYS80MzeTraQWyICL690XOio8F&project=mythicaldash&type=warning&title=".$title."&message=".$text, - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => "", - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 30, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => "GET", - CURLOPT_POSTFIELDS => "", - CURLOPT_HTTPHEADER => [ - "Content-Type: application/json", - "User-Agent: insomnia/8.2.0" - ], - ]); - - curl_exec($curl); -} -function Critical($title, $text) -{ - $curl = curl_init(); - - curl_setopt_array($curl, [ - CURLOPT_URL => "https://api.mythicalsystems.me/problem?authKey=AxWTnecj85SI4bG6rIP8bvw2uCF7W5MmkJcQIkrYS80MzeTraQWyICL690XOio8F&project=mythicaldash&type=critical&title=".$title."&message=".$text, - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => "", - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 30, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => "GET", - CURLOPT_POSTFIELDS => "", - CURLOPT_HTTPHEADER => [ - "Content-Type: application/json", - "User-Agent: insomnia/8.2.0" - ], - ]); - - curl_exec($curl); -} -?> \ No newline at end of file diff --git a/functions/session.php b/functions/session.php deleted file mode 100644 index fe3b4c7a..00000000 --- a/functions/session.php +++ /dev/null @@ -1,49 +0,0 @@ - 0) { - session_start(); - $userdbd = $conn->query("SELECT * FROM mythicaldash_users WHERE api_key='$session_id'")->fetch_array(); - $_SESSION["token"] = $session_id; - $_SESSION['loggedin'] = true; - $_SESSION['SESSION_EMAIL'] = $userdbd['email']; - $_SESSION["email"] = $userdbd['email']; - $_SESSION["username"] = $userdbd['username']; - } - else - { - if (isset($_SERVER['HTTP_COOKIE'])) { - $cookies = explode(';', $_SERVER['HTTP_COOKIE']); - foreach($cookies as $cookie) { - $parts = explode('=', $cookie); - $name = trim($parts[0]); - setcookie($name, '', time()-1000); - setcookie($name, '', time()-1000, '/'); - } - } - echo ''; - die(); - } -} -else -{ - if (isset($_SERVER['HTTP_COOKIE'])) { - $cookies = explode(';', $_SERVER['HTTP_COOKIE']); - foreach($cookies as $cookie) { - $parts = explode('=', $cookie); - $name = trim($parts[0]); - setcookie($name, '', time()-1000); - setcookie($name, '', time()-1000, '/'); - } - } - header('location: /auth/login?r='.$fullUrl); - die(); -} -?> \ No newline at end of file diff --git a/functions/telemetry.php b/functions/telemetry.php deleted file mode 100644 index da9809ce..00000000 --- a/functions/telemetry.php +++ /dev/null @@ -1,87 +0,0 @@ - "https://api.mythicalsystems.me/telemetry?project=mythicaldash&action=NewUser&authKey=AxWTnecj85SI4bG6rIP8bvw2uCF7W5MmkJcQIkrYS80MzeTraQWyICL690XOio8F", - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => "", - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 30, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => "GET", - CURLOPT_POSTFIELDS => "", - ]); - - curl_exec($curl); -} -function NewServer() -{ - $curl = curl_init(); - - curl_setopt_array($curl, [ - CURLOPT_URL => "https://api.mythicalsystems.me/telemetry?project=mythicaldash&action=NewWebsite&authKey=AxWTnecj85SI4bG6rIP8bvw2uCF7W5MmkJcQIkrYS80MzeTraQWyICL690XOio8F", - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => "", - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 30, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => "GET", - CURLOPT_POSTFIELDS => "", - ]); - - curl_exec($curl); -} -function NewInstall() -{ - $curl = curl_init(); - - curl_setopt_array($curl, [ - CURLOPT_URL => "https://api.mythicalsystems.me/telemetry?project=mythicaldash&action=NewInstall&authKey=AxWTnecj85SI4bG6rIP8bvw2uCF7W5MmkJcQIkrYS80MzeTraQWyICL690XOio8F", - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => "", - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 30, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => "GET", - CURLOPT_POSTFIELDS => "", - ]); - - curl_exec($curl); -} -function NewNode() -{ - $curl = curl_init(); - - curl_setopt_array($curl, [ - CURLOPT_URL => "https://api.mythicalsystems.me/telemetry?project=mythicaldash&action=NewNode&authKey=AxWTnecj85SI4bG6rIP8bvw2uCF7W5MmkJcQIkrYS80MzeTraQWyICL690XOio8F", - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => "", - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 30, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => "GET", - CURLOPT_POSTFIELDS => "", - ]); - - curl_exec($curl); -} -function NewTicket() -{ - $curl = curl_init(); - - curl_setopt_array($curl, [ - CURLOPT_URL => "https://api.mythicalsystems.me/telemetry?project=mythicaldash&action=NewTicket&authKey=AxWTnecj85SI4bG6rIP8bvw2uCF7W5MmkJcQIkrYS80MzeTraQWyICL690XOio8F", - CURLOPT_RETURNTRANSFER => true, - CURLOPT_ENCODING => "", - CURLOPT_MAXREDIRS => 10, - CURLOPT_TIMEOUT => 30, - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_CUSTOMREQUEST => "GET", - CURLOPT_POSTFIELDS => "", - ]); - - curl_exec($curl); -} -?> \ No newline at end of file diff --git a/functions/writelog.php b/functions/writelog.php deleted file mode 100644 index db09f291..00000000 --- a/functions/writelog.php +++ /dev/null @@ -1,21 +0,0 @@ -query($query); - $conn->close(); - } - } catch (Exception $e) { - - } -} -?> \ No newline at end of file diff --git a/include/main.php b/include/main.php index 6c93ed52..60332599 100644 --- a/include/main.php +++ b/include/main.php @@ -1,4 +1,5 @@ connect_error) { - throw new Exception(''); -} -//SETTINGS TABLE -$settings = $conn->query("SELECT * FROM mythicaldash_settings")->fetch_array(); -//GET USER REAL IP -include('../functions/getclientip.php'); -$ip_address = getclientip(); //APP URL $prot = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http'; $svhost = $_SERVER['HTTP_HOST']; $appURL = $prot . '://' . $svhost; -// GET CURRENT PATH -$current_path = $_SERVER['REQUEST_URI']; -//PASSWORD GENERATOR -include('../functions/passwordgen.php'); -//KEY GENERATOR -include('../functions/keygen.php'); -//Encryption -include('../functions/encryption.php'); -//CloudFlare -include('../functions/cloudflare.php'); - ?> \ No newline at end of file diff --git a/include/ssh.php b/include/ssh.php deleted file mode 100644 index 0f9a6053..00000000 --- a/include/ssh.php +++ /dev/null @@ -1,14 +0,0 @@ -login($ssh_username, $ssh_password)) { - throw new \Exception('Login failed'); -} - -?> - diff --git a/install/servercheck.php b/install/servercheck.php index 793693e6..4c8ccf3a 100644 --- a/install/servercheck.php +++ b/install/servercheck.php @@ -2,9 +2,10 @@ ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); -include(__DIR__.'/../functions/telemetry.php'); +use MythicalDash\Telemetry; + if (isset($_GET['rr'])) { - NewInstall(); + Telemetry::NewInstall(); unlink("FIRST_INSTALL"); header('location: /'); } diff --git a/migrate/18.sql b/migrate/18.sql new file mode 100644 index 00000000..12a29101 --- /dev/null +++ b/migrate/18.sql @@ -0,0 +1 @@ +ALTER TABLE `mythicaldash_settings` ADD `terms_of_service` LONGTEXT NOT NULL DEFAULT 'Hell this looks like the host did not set up any terms of service please contact the host and if the host does not want to add any terms of service please make sure to report this here.' AFTER `linkvertise_coins`, ADD `privacy_policy` LONGTEXT NOT NULL DEFAULT 'Hell this looks like the host did not set up any privacy policy please contact the host and if the host does not want to add any privacy policy please make sure to report this here.' AFTER `terms_of_service`; \ No newline at end of file diff --git a/migrate/19.sql b/migrate/19.sql new file mode 100644 index 00000000..63000889 --- /dev/null +++ b/migrate/19.sql @@ -0,0 +1 @@ +DROP TABLE `mythicaldash`.`mythicaldash_logs`; \ No newline at end of file diff --git a/migrate/20.sql b/migrate/20.sql new file mode 100644 index 00000000..c0ced96c --- /dev/null +++ b/migrate/20.sql @@ -0,0 +1,3 @@ +ALTER TABLE `mythicaldash_users` + DROP `first_name`, + DROP `last_name`; \ No newline at end of file diff --git a/migrate/21.sql b/migrate/21.sql new file mode 100644 index 00000000..c9b2e908 --- /dev/null +++ b/migrate/21.sql @@ -0,0 +1 @@ +ALTER TABLE `mythicaldash_users` ADD `first_name` TEXT NOT NULL AFTER `username`, ADD `last_name` TEXT NOT NULL AFTER `first_name`; \ No newline at end of file diff --git a/migrate/22.sql b/migrate/22.sql new file mode 100644 index 00000000..576dc1a1 --- /dev/null +++ b/migrate/22.sql @@ -0,0 +1 @@ +ALTER TABLE `mythicaldash_users` CHANGE `role` `role` ENUM('Administrator','Support','User') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'User'; \ No newline at end of file diff --git a/migrate/23.sql b/migrate/23.sql new file mode 100644 index 00000000..c45ac3a2 --- /dev/null +++ b/migrate/23.sql @@ -0,0 +1 @@ +ALTER TABLE `mythicaldash_settings` ADD `enable_adblocker_detection` ENUM('true','false') NOT NULL AFTER `enable_ads`; \ No newline at end of file diff --git a/migrate/24.sql b/migrate/24.sql new file mode 100644 index 00000000..8c4fce26 --- /dev/null +++ b/migrate/24.sql @@ -0,0 +1 @@ +ALTER TABLE `mythicaldash_servers` ADD `purge` ENUM('true','false') NOT NULL DEFAULT 'true' AFTER `uid`; \ No newline at end of file diff --git a/migrate/25.sql b/migrate/25.sql new file mode 100644 index 00000000..57b15f75 --- /dev/null +++ b/migrate/25.sql @@ -0,0 +1 @@ +ALTER TABLE `mythicaldash_settings` ADD `server_purge` ENUM('false','true') NOT NULL AFTER `privacy_policy` \ No newline at end of file diff --git a/pages/index.html b/pages/index.html index 6a0651f7..8fb0c1d1 100644 --- a/pages/index.html +++ b/pages/index.html @@ -22,7 +22,7 @@
- +
query("INSERT INTO `mythicaldash_tickets` (`ownerkey`, `ticketuuid`, `subject`, `priority`, `description`, `attachment`) VALUES ('".$api_key."', '".generate_keynoinfo()."', '".$subject."', '".$priority."', '".$description."', '".$attachment."');"); + $api_key = mysqli_real_escape_string($conn, $_COOKIE['token']); + $conn->query("INSERT INTO `mythicaldash_tickets` (`ownerkey`, `ticketuuid`, `subject`, `priority`, `description`, `attachment`) VALUES ('" . $api_key . "', '" . Encryption::generate_keynoinfo() . "', '" . $subject . "', '" . $priority . "', '" . $description . "', '" . $attachment . "');"); $conn->close(); - NewTicket(); header('location: /help-center/tickets'); - $conn->close(); die(); } else { header('location: /help-center?e=Missing the required information to create a ticket.'); diff --git a/view/tickets/reopen.php b/view/tickets/reopen.php index 4b6dce6f..3e4e5215 100644 --- a/view/tickets/reopen.php +++ b/view/tickets/reopen.php @@ -1,4 +1,6 @@ 0) { - $conn->query("UPDATE `mythicaldash_tickets` SET `status` = 'open' WHERE `mythicaldash_tickets`.`ticketuuid` = '".mysqli_real_escape_string($conn,$_GET['ticketuuid'])."';"); + $conn->query("UPDATE `mythicaldash_tickets` SET `status` = 'open' WHERE `mythicaldash_tickets`.`ticketuuid` = '" . mysqli_real_escape_string($conn, $_GET['ticketuuid']) . "';"); $conn->close(); header('location: /help-center/tickets'); die(); } else { - header('location: /help-center/tickets?e=We can\'t find this ticket in the database'); + header("location: /help-center/tickets?e=We can't find this ticket in the database"); $conn->close(); die(); } } else { - header('location: /help-center/tickets?e=We can\'t find this ticket in the database'); + header("location: /help-center/tickets?e=We can't find this ticket in the database"); die(); } ?> \ No newline at end of file diff --git a/view/tickets/reply.php b/view/tickets/reply.php index 06d7d73c..8bc55923 100644 --- a/view/tickets/reply.php +++ b/view/tickets/reply.php @@ -12,12 +12,12 @@ header('location: /help-center/tickets/view?ticketuuid=' . $_GET['ticketuuid']); die(); } else { - header('location: /help-center/tickets?e=We can\'t find this ticket in the database'); + header("location: /help-center/tickets?e=We can't find this ticket in the database"); $conn->close(); die(); } } else { - header('location: /help-center/tickets?e=Can\'t find the ticket in the database'); + header("location: /help-center/tickets?e=Can't find the ticket in the database"); die(); } ?> \ No newline at end of file diff --git a/view/user/connections.php b/view/user/connections.php index 5e5e1f52..a430b6af 100644 --- a/view/user/connections.php +++ b/view/user/connections.php @@ -1,4 +1,6 @@ query("UPDATE `mythicaldash_users` SET `discord_linked` = 'false' WHERE `mythicaldash_users`.`api_key` = '" . mysqli_real_escape_string($conn, $_COOKIE['token']) . "';"); @@ -13,7 +15,7 @@ - <?= $settings['name'] ?> | Edit + <?= SettingsManager::getSetting("name") ?> - Edit @@ -32,10 +34,10 @@

- +
Connections
Discord
getUserInfo("discord_linked") == "true") { ?> - + getUserInfo("discord_username") ?> Connections ?>
getUserInfo("discord_linked") == "true") { ?>
0) { - $conn->query("DELETE FROM `mythicaldash_users` WHERE `mythicaldash_users`.`api_key` = '".$_COOKIE['token']."';"); - header('location: /auth/logout'); - die(); - } else { - header('location: /user/profile?e=Can`t find this user in the database'); - die(); - } +if (isset($_COOKIE['token']) && !$_COOKIE['token'] == "") { + $user_query = "SELECT * FROM mythicaldash_users WHERE api_key = ?"; + $stmt = mysqli_prepare($conn, $user_query); + mysqli_stmt_bind_param($stmt, "s", $_COOKIE['token']); + mysqli_stmt_execute($stmt); + $result = mysqli_stmt_get_result($stmt); + if (mysqli_num_rows($result) > 0) { + deleteUserServers($conn, mysqli_real_escape_string($conn,$_COOKIE['token']), SettingsManager::getSetting("PterodactylURL"), SettingsManager::getSetting("PterodactylAPIKey")); + deleteUserServersInQueue($conn, mysqli_real_escape_string($conn,$_COOKIE['token']), SettingsManager::getSetting("PterodactylURL"), SettingsManager::getSetting("PterodactylAPIKey")); + deleteApiKeys($conn, mysqli_real_escape_string($conn,$_COOKIE['token'])); + deleteLoginLogs($conn, mysqli_real_escape_string($conn,$_COOKIE['token'])); + deleteTickets($conn, mysqli_real_escape_string($conn,$_COOKIE['token'])); + deleteTicketsMsgs($conn, mysqli_real_escape_string($conn,$_COOKIE['token'])); + deletePasswordsReset($conn, mysqli_real_escape_string($conn,$_COOKIE['token'])); + deleteUserFromPterodactyl(SettingsManager::getSetting("PterodactylURL"), $user_info['panel_id'], SettingsManager::getSetting("PterodactylAPIKey")); + deleteUserFromDb($conn, mysqli_real_escape_string($conn,$_COOKIE['token'])); + header('location: /auth/logout'); + die(); } else { header('location: /user/profile?e=Can`t find this user in the database'); die(); } - } else { header('location: /user/profile'); die(); } + + +function deleteUserFromDb($dbconn, $userkey) +{ + $query = "SELECT * FROM mythicaldash_users WHERE mythicaldash_users.api_key='" . $userkey . "'"; + $result = mysqli_query($dbconn, $query); + if ($result) { + while ($row = mysqli_fetch_assoc($result)) { + $key = $row["id"]; + if (mysqli_query($dbconn, "DELETE FROM mythicaldash_users WHERE id = '" . mysqli_real_escape_string($dbconn, $key) . "'")) { + + } else { + $dbconn->close(); + header('location: /admin/users?e=Failed to remove from database'); + die(); + } + } + } else { + $dbconn->close(); + header('location: /admin/users?e=Database query error'); + die(); + } +} + +function deleteUserFromPterodactyl($panel_url, $user_id, $api_key) +{ + $url = $panel_url . "/api/application/users/" . $user_id; + $ch = curl_init($url); + $headers = array( + 'Accept: application/json', + 'Content-Type: application/json', + 'Authorization: Bearer ' . $api_key + ); + curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); + $response = curl_exec($ch); + curl_close($ch); + + if ($response === false) { + header('location: /admin/users?e=Failed to remove from pterodactyl'); + die(); + } else { + + } +} + +function deleteTickets($dbconn, $userkey) +{ + $query = "SELECT * FROM mythicaldash_tickets WHERE mythicaldash_tickets.ownerkey='" . $userkey . "'"; + $result = mysqli_query($dbconn, $query); + if ($result) { + while ($row = mysqli_fetch_assoc($result)) { + $key = $row["id"]; + $ticketuuid = $row['ticketuuid']; + if (mysqli_query($dbconn, "DELETE FROM mythicaldash_tickets WHERE id = '" . mysqli_real_escape_string($dbconn, $key) . "'")) { + $query_t = "SELECT * FROM mythicaldash_tickets_messages WHERE mythicaldash_tickets_messages.ticketuuid='" . $ticketuuid . "'"; + $result_t = mysqli_query($dbconn, $query_t); + if ($result_t) { + while ($row_t = mysqli_fetch_assoc($result_t)) { + $key = $row["id"]; + if (mysqli_query($dbconn, "DELETE FROM mythicaldash_tickets_messages WHERE id = '" . mysqli_real_escape_string($dbconn, $key) . "'")) { + + } else { + $dbconn->close(); + header('location: /admin/users?e=Failed to remove from database'); + die(); + } + } + } else { + $dbconn->close(); + header('location: /admin/users?e=Database query error'); + die(); + } + } else { + $dbconn->close(); + header('location: /admin/users?e=Failed to remove from database'); + die(); + } + } + } else { + $dbconn->close(); + header('location: /admin/users?e=Database query error'); + die(); + } +} + +function deleteTicketsMsgs($dbconn, $userkey) +{ + $query = "SELECT * FROM mythicaldash_tickets_messages WHERE mythicaldash_tickets_messages.userkey='" . $userkey . "'"; + $result = mysqli_query($dbconn, $query); + if ($result) { + while ($row = mysqli_fetch_assoc($result)) { + $key = $row["id"]; + if (mysqli_query($dbconn, "DELETE FROM mythicaldash_tickets_messages WHERE id = '" . mysqli_real_escape_string($dbconn, $key) . "'")) { + + } else { + $dbconn->close(); + header('location: /admin/users?e=Failed to remove from database'); + die(); + } + } + } else { + $dbconn->close(); + header('location: /admin/users?e=Database query error'); + die(); + } +} + +function deletePasswordsReset($dbconn, $userkey) +{ + $query = "SELECT * FROM mythicaldash_resetpasswords WHERE mythicaldash_resetpasswords.ownerkey='" . $userkey . "'"; + $result = mysqli_query($dbconn, $query); + if ($result) { + while ($row = mysqli_fetch_assoc($result)) { + $key = $row["id"]; + if (mysqli_query($dbconn, "DELETE FROM mythicaldash_resetpasswords WHERE id = '" . mysqli_real_escape_string($dbconn, $key) . "'")) { + + } else { + $dbconn->close(); + header('location: /admin/users?e=Failed to remove from database'); + die(); + } + } + } else { + $dbconn->close(); + header('location: /admin/users?e=Database query error'); + die(); + } +} + +function deleteApiKeys($dbconn, $userkey) +{ + $query = "SELECT * FROM mythicaldash_apikeys WHERE mythicaldash_apikeys.ownerkey='" . $userkey . "'"; + $result = mysqli_query($dbconn, $query); + if ($result) { + while ($row = mysqli_fetch_assoc($result)) { + $key = $row["id"]; + if (mysqli_query($dbconn, "DELETE FROM mythicaldash_apikeys WHERE id = '" . mysqli_real_escape_string($dbconn, $key) . "'")) { + + } else { + $dbconn->close(); + header('location: /admin/users?e=Failed to remove from database'); + die(); + } + } + } else { + $dbconn->close(); + header('location: /admin/users?e=Database query error'); + die(); + } +} + +function deleteLoginLogs($dbconn, $userkey) +{ + $query = "SELECT * FROM mythicaldash_login_logs WHERE mythicaldash_login_logs.userkey='" . $userkey . "'"; + $result = mysqli_query($dbconn, $query); + if ($result) { + while ($row = mysqli_fetch_assoc($result)) { + $key = $row["id"]; + if (mysqli_query($dbconn, "DELETE FROM mythicaldash_login_logs WHERE id = '" . mysqli_real_escape_string($dbconn, $key) . "'")) { + + } else { + $dbconn->close(); + header('location: /admin/users?e=Failed to remove from database'); + die(); + } + } + } else { + $dbconn->close(); + header('location: /admin/users?e=Database query error'); + die(); + } +} + +function deleteUserServersInQueue($dbconn, $userkey, $panel_url, $panel_apikey) +{ + $query = "SELECT * FROM mythicaldash_servers_queue WHERE mythicaldash_servers_queue.ownerid='" . $userkey . "'"; + $result = mysqli_query($dbconn, $query); + if ($result) { + while ($row = mysqli_fetch_assoc($result)) { + $svid = $row["id"]; + if (mysqli_query($dbconn, "DELETE FROM mythicaldash_servers_queue WHERE id = '" . mysqli_real_escape_string($dbconn, $svid) . "'")) { + + } else { + $dbconn->close(); + header('location: /admin/users?e=Failed to remove from database'); + die(); + } + } + } else { + $dbconn->close(); + header('location: /admin/users?e=Database query error'); + die(); + } +} + +function deleteUserServers($dbconn, $userkey, $panel_url, $panel_apikey) +{ + $query = "SELECT * FROM mythicaldash_servers WHERE mythicaldash_servers.uid='" . $userkey . "'"; + $result = mysqli_query($dbconn, $query); + if ($result) { + while ($row = mysqli_fetch_assoc($result)) { + $panel_id = $row['pid']; + $delete_server = curl_init($panel_url . "/api/application/servers/" . $panel_id . "/force"); + curl_setopt($delete_server, CURLOPT_CUSTOMREQUEST, "DELETE"); + $headers = array( + 'Accept: application/json', + 'Content-Type: application/json', + "Authorization: Bearer " . $panel_apikey + ); + curl_setopt($delete_server, CURLOPT_HTTPHEADER, $headers); + curl_setopt($delete_server, CURLOPT_RETURNTRANSFER, 1); + $curl_result = curl_exec($delete_server); + curl_close($delete_server); + if (!empty($curl_result)) { + $dbconn->close(); + header('location: /admin/users?e=Failed to remove from panel'); + die(); + } + if (mysqli_query($dbconn, "DELETE FROM mythicaldash_servers WHERE pid = '" . mysqli_real_escape_string($dbconn, $panel_id) . "'")) { + + } else { + $dbconn->close(); + header('location: /admin/users?e=Failed to remove from database'); + die(); + } + } + mysqli_free_result($result); + } else { + $dbconn->close(); + header('location: /admin/users?e=Database query error'); + die(); + } +} ?> \ No newline at end of file diff --git a/view/user/edit.php b/view/user/edit.php index a353cfb5..ef19e43a 100644 --- a/view/user/edit.php +++ b/view/user/edit.php @@ -1,12 +1,14 @@ validate('profile-form')) { if (isset($_POST['edit_user'])) { - $userdb = $conn->query("SELECT * FROM mythicaldash_users WHERE api_key = '" . $_COOKIE['token'] . "'")->fetch_array(); + $userdb = $conn->query("SELECT * FROM mythicaldash_users WHERE api_key = '" . mysqli_real_escape_string($conn, $_COOKIE['token']) . "'")->fetch_array(); $username = mysqli_real_escape_string($conn, $_POST['username']); $firstName = mysqli_real_escape_string($conn, $_POST['firstName']); $lastName = mysqli_real_escape_string($conn, $_POST['lastName']); @@ -17,20 +19,53 @@ $check_query = "SELECT * FROM mythicaldash_users WHERE username = '$username' OR email = '$email'"; $result = mysqli_query($conn, $check_query); if (mysqli_num_rows($result) > 0) { - header('location: /user/profile?e=Username or email already exists. Please choose a different one'); + header('location: /user/edit?e=Username or email already exists. Please choose a different one'); die(); } } else { - $conn->query("UPDATE `mythicaldash_users` SET `username` = '" . $username . "' WHERE `mythicaldash_users`.`api_key` = '" . $_COOKIE['token'] . "';"); - $conn->query("UPDATE `mythicaldash_users` SET `first_name` = '" . $firstName . "' WHERE `mythicaldash_users`.`api_key` = '" . $_COOKIE['token'] . "';"); - $conn->query("UPDATE `mythicaldash_users` SET `last_name` = '" . $lastName . "' WHERE `mythicaldash_users`.`api_key` = '" . $_COOKIE['token'] . "';"); - $conn->query("UPDATE `mythicaldash_users` SET `avatar` = '" . $avatar . "' WHERE `mythicaldash_users`.`api_key` = '" . $_COOKIE['token'] . "';"); - $conn->query("UPDATE `mythicaldash_users` SET `email` = '" . $email . "' WHERE `mythicaldash_users`.`api_key` = '" . $_COOKIE['token'] . "';"); + $conn->query("UPDATE `mythicaldash_users` SET `username` = '" . $username . "' WHERE `mythicaldash_users`.`api_key` = '" . mysqli_real_escape_string($conn, $_COOKIE['token']) . "';"); + $conn->query("UPDATE `mythicaldash_users` SET `first_name` = '" . Encryption::encrypt($firstName, $ekey) . "' WHERE `mythicaldash_users`.`api_key` = '" . mysqli_real_escape_string($conn, $_COOKIE['token']) . "';"); + $conn->query("UPDATE `mythicaldash_users` SET `last_name` = '" . Encryption::encrypt($lastName, $ekey) . "' WHERE `mythicaldash_users`.`api_key` = '" . mysqli_real_escape_string($conn, $_COOKIE['token']) . "';"); + $conn->query("UPDATE `mythicaldash_users` SET `avatar` = '" . $avatar . "' WHERE `mythicaldash_users`.`api_key` = '" . mysqli_real_escape_string($conn, $_COOKIE['token']) . "';"); + $conn->query("UPDATE `mythicaldash_users` SET `email` = '" . $email . "' WHERE `mythicaldash_users`.`api_key` = '" . mysqli_real_escape_string($conn, $_COOKIE['token']) . "';"); $conn->close(); - header('location: /user/profile?s=We updated the user settings in the database'); + $api_url = SettingsManager::getSetting("PterodactylURL") . "/api/application/users/" . $user_info['panel_id'] . ""; + $data = [ + "email" => $_GET['email'], + "username" => $_GET['username'], + "first_name" => $_GET['firstName'], + "last_name" => $_GET['lastName'], + "language" => "en" + ]; + + $data_json = json_encode($data); + + $ch = curl_init($api_url); + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PATCH"); + curl_setopt($ch, CURLOPT_HTTPHEADER, [ + "Accept: application/json", + "Content-Type: application/json", + "Authorization: Bearer " . SettingsManager::getSetting("PterodactylAPIKey") + ]); + curl_setopt($ch, CURLOPT_POSTFIELDS, $data_json); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + + $response = curl_exec($ch); + $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); + + if ($http_code == 200) { + $api_response = json_decode($response, true); + header('location: /user/edit?s=We updated the user settings in the database'); + curl_close($ch); + die(); + } else { + header("location: /user/edit?e=Failed to update the user settings inside the panel"); + curl_close($ch); + die(); + } } } else { - header('location: /user/profile?e=Please fill in all the info'); + header('location: /user/edit?e=Please fill in all the info'); die(); } } @@ -46,7 +81,7 @@ - <?= $settings['name'] ?> | Edit + <?= SettingsManager::getSetting("name") ?> - Edit @@ -65,10 +100,10 @@

- +
Connections
- user-avatar" alt="user-avatar" class="d-block w-px-100 h-px-100 rounded" id="uploadedAvatar" />
@@ -112,32 +147,32 @@ class="d-block w-px-100 h-px-100 rounded" id="uploadedAvatar" />
" placeholder="jhondoe" />
+ value="getUserInfo('last_name'), $ekey) ?>" />
" placeholder="john.doe@example.com" />
+ value="getUserInfo("avatar") ?>" />
@@ -158,9 +193,9 @@ class="d-block w-px-100 h-px-100 rounded" id="uploadedAvatar" />
- +
Delete Account client API and this is your login security token, so make sure not to share it!

- + getUserInfo("api_key") ?>
- @@ -249,7 +285,8 @@ class="btn btn-danger me-sm-3 me-1">Delete user
- @@ -276,7 +313,8 @@ class="btn btn-danger me-sm-3 me-1">Reset key placeholder="" required />
- diff --git a/view/user/gift.php b/view/user/gift.php index 9325d323..1efebf56 100644 --- a/view/user/gift.php +++ b/view/user/gift.php @@ -9,24 +9,24 @@ $userResult = mysqli_query($conn, $userQuery); if (mysqli_num_rows($userResult) > 0) { - if ($userdb['id'] == $_GET['userid']) { - header("location: /user/profile?e=You can't send coins to yourself!&id=".$_GET['userid']); + if ($session->getUserInfo("id") == $_GET['userid']) { + header("location: /user/profile?e=You can't send coins to yourself!&id=" . $_GET['userid']); die(); } if ($coins <= 0) { - header("location: /user/profile?e=Please enter a valid number of coins to send&id=".$_GET['userid']); + header("location: /user/profile?e=Please enter a valid number of coins to send&id=" . $_GET['userid']); die(); } - if ($coins <= $userdb['coins']) { + if ($coins <= $session->getUserInfo("coins")) { $giftUserQuery = "SELECT * FROM mythicaldash_users WHERE id = '$userid'"; $giftUserResult = mysqli_query($conn, $giftUserQuery); $giftUser = mysqli_fetch_assoc($giftUserResult); - $u_new_coins = $userdb['coins'] - $coins; + $u_new_coins = $session->getUserInfo("coins") - $coins; $g_new_coins = $giftUser['coins'] + $coins; $updateGiftUserQuery = "UPDATE `mythicaldash_users` SET `coins` = '$g_new_coins' WHERE `id` = {$giftUser['id']}"; - $updateSenderQuery = "UPDATE `mythicaldash_users` SET `coins` = '$u_new_coins' WHERE `id` = {$userdb['id']}"; + $updateSenderQuery = "UPDATE `mythicaldash_users` SET `coins` = '$u_new_coins' WHERE `id` = {$session->getUserInfo("id")}"; mysqli_query($conn, $updateSenderQuery); mysqli_query($conn, $updateGiftUserQuery); @@ -45,4 +45,4 @@ header("location: /dashboard?e=Invalid input"); die(); } -?> +?> \ No newline at end of file diff --git a/view/user/list.php b/view/user/list.php index dddcb6d5..f5872b33 100644 --- a/view/user/list.php +++ b/view/user/list.php @@ -1,4 +1,5 @@ - <?= $settings['name'] ?> | Users + <?= SettingsManager::getSetting("name") ?> - Users