diff --git a/addons/core/routes.php b/addons/core/routes.php index ca279f34..5169a4cc 100644 --- a/addons/core/routes.php +++ b/addons/core/routes.php @@ -2,10 +2,29 @@ return [ [ - 'path' => '/addon-route', + 'path' => '/mythicaldash/php', 'view' => 'about.php', - 'addon' => __DIR__, // Assuming the routes.php file is in the root of the addon folder + 'addon' => __DIR__, + ], + [ + 'path' => '/mythicaldash/info', + 'view' => 'info.php', + 'addon' => __DIR__, + ], + [ + 'path' => '/mythicaldash/system', + 'view' => 'sysinfo.php', + 'addon' => __DIR__, + ], + [ + 'path' => '/mythicaldash/addons', + 'view' => 'addons.php', + 'addon' => __DIR__, + ], + [ + 'path' => '/mythicaldash/logs', + 'view' => 'logs.php', + 'addon' => __DIR__, ], - // Add more routes as needed ]; ?> diff --git a/addons/core/view/about.php b/addons/core/view/about.php index 56b9e1fb..a68d3dcf 100644 --- a/addons/core/view/about.php +++ b/addons/core/view/about.php @@ -2,11 +2,9 @@ - Addon Manager + MythicalDash - PhP Info - +

\ No newline at end of file diff --git a/addons/core/view/addons.php b/addons/core/view/addons.php new file mode 100644 index 00000000..be3c9e44 --- /dev/null +++ b/addons/core/view/addons.php @@ -0,0 +1,56 @@ +loadAddons(); +$conn = new Connect(); +$conn = $conn->connectToDatabase(); + +header('Content-type: application/json'); +ini_set('display_errors', 0); +ini_set('display_startup_errors', 0); + +if (!is_writable(__DIR__)) { + http_response_code(500); + $rsp = array( + 'code' => 500, + 'error' => 'The server is not ready to handle the request.', + 'message' => 'We have no write permission for our home directory. Please update the permission by executing this in the server shell: chown -R www-data:www-data /var/www/mythicaldash/ && chown -R www-data:www-data /var/www/mythicaldash/*' + ); + die(json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); +} + +try { + $addonsData = []; + + foreach ($loadedAddons as $addon) { + $addonDetails = $addon['details']; + $addonsData[] = [ + 'name' => $addonDetails['name'], + 'description' => $addonDetails['description'], + 'version' => $addonDetails['version'], + 'author' => $addonDetails['author'], + ]; + } + + $rsp = array( + 'code' => 200, + 'error' => null, + 'data' => $addonsData, + ); + + $conn->close(); + http_response_code(200); + die(json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); +} catch (Exception $e) { + ErrorHandler::Critical('Settings DB ', $e); + $rsp = array( + 'code' => 500, + 'error' => "The server encountered a situation it doesn't know how to handle.", + 'message' => 'We are sorry, but our server cannot handle this request. Please do not try again!' + ); + http_response_code(500); + die(json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); +} diff --git a/addons/core/view/info.php b/addons/core/view/info.php new file mode 100644 index 00000000..eb141d06 --- /dev/null +++ b/addons/core/view/info.php @@ -0,0 +1,74 @@ +connectToDatabase(); +header('Content-type: application/json'); +ini_set('display_errors', 0); +ini_set('display_startup_errors', 0); +if (!is_writable(__DIR__)) { + http_response_code(500); + $rsp = array( + 'code' => 500, + 'error' => 'The server is not ready to handle the request.', + 'message' => 'We have no write permission for our home directory. Please update the permission by executing this in the server shell: chown -R www-data:www-data /var/www/mythicaldash/ && chown -R www-data:www-data /var/www/mythicaldash/*' + ); + die (json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); +} + +try { + $rsp = array( + 'code' => 200, + 'error' => null, + 'data' => array( + 'dash_name' => SettingsManager::getSetting('name'), + 'dash_version' => SettingsManager::getSetting('version'), + 'security_modules' => array( + 'turnstile' => SettingsManager::getSetting('enable_turnstile'), + 'anti-adblocker' => SettingsManager::getSetting('enable_adblocker_detection'), + 'anti-alting' => SettingsManager::getSetting('enable_alting'), + 'anti-vpn' => SettingsManager::getSetting('enable_anti_vpn'), + 'purge' => SettingsManager::getSetting("server_purge") + ), + 'stripe' => array( + 'enabled' => SettingsManager::getSetting("enable_stripe"), + 'public-key' => SettingsManager::getSetting("stripe_publishable_key"), + 'currency' => SettingsManager::getSetting("stripe_currency"), + ), + 'linkvertise' => array( + 'enabled' => SettingsManager::getSetting("linkvertise_enabled"), + 'code' => SettingsManager::getSetting("linkvertise_code"), + 'coins' => SettingsManager::getSetting("linkvertise_coins") + ), + 'pterodactyl' => array( + 'url' => SettingsManager::getSetting("PterodactylURL") + ), + 'smtp' => array( + 'enabled' => SettingsManager::getSetting("enable_smtp"), + 'encryption' => SettingsManager::getSetting("smtpSecure"), + 'port' => SettingsManager::getSetting("smtpPort"), + 'from' => SettingsManager::getSetting("fromEmail") + ), + 'discord' => array( + 'account_link' => SettingsManager::getSetting("enable_discord_link"), + 'server_id' => SettingsManager::getSetting("discord_serverid"), + "client_id" => SettingsManager::getSetting("discord_clientid") + ) + ), + ); + $conn->close(); + http_response_code(200); + die (json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); +} catch (Exception $e) { + ErrorHandler::Critical('Settings DB ', $e); + $rsp = array( + 'code' => 500, + 'error' => "The server encountered a situation it doesn't know how to handle.", + 'message' => 'We are sorry, but our server cannot handle this request. Please do not try again!' + ); + http_response_code(500); + die (json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); +} +?> diff --git a/addons/core/view/logs.php b/addons/core/view/logs.php new file mode 100644 index 00000000..b9bd7f84 --- /dev/null +++ b/addons/core/view/logs.php @@ -0,0 +1,41 @@ +connectToDatabase(); +header('Content-type: application/json'); +ini_set('display_errors', 0); +ini_set('display_startup_errors', 0); +if (!is_writable(__DIR__)) { + http_response_code(500); + $rsp = array( + 'code' => 500, + 'error' => 'The server is not ready to handle the request.', + 'message' => 'We have no write permission for our home directory. Please update the permission by executing this in the server shell: chown -R www-data:www-data /var/www/mythicaldash/ && chown -R www-data:www-data /var/www/mythicaldash/*' + ); + die (json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); +} +try { + $logFilePath = '../logs/mythicaldash.app-error.log'; + $logContent = file_get_contents($logFilePath); + + $conn->close(); + http_response_code(200); + if ($logContent == null) + { + die("No logs to show"); + } else { + die ($logContent); + } +} catch (Exception $e) { + ErrorHandler::Critical('Settings DB ', $e); + $rsp = array( + 'code' => 500, + 'error' => "The server encountered a situation it doesn't know how to handle.", + 'message' => 'We are sorry, but our server cannot handle this request. Please do not try again!' + ); + http_response_code(500); + die (json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); +} +?> diff --git a/addons/core/view/sysinfo.php b/addons/core/view/sysinfo.php new file mode 100644 index 00000000..def64cab --- /dev/null +++ b/addons/core/view/sysinfo.php @@ -0,0 +1,44 @@ +connectToDatabase(); +header('Content-type: application/json'); +ini_set('display_errors', 0); +ini_set('display_startup_errors', 0); +if (!is_writable(__DIR__)) { + http_response_code(500); + $rsp = array( + 'code' => 500, + 'error' => 'The server is not ready to handle the request.', + 'message' => 'We have no write permission for our home directory. Please update the permission by executing this in the server shell: chown -R www-data:www-data /var/www/mythicaldash/ && chown -R www-data:www-data /var/www/mythicaldash/*' + ); + die (json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); +} +try { + $rsp = array( + 'code' => 200, + 'error' => null, + 'data' => array( + 'os' => php_uname('s'), + 'hostname' => php_uname('n'), + 'kernel' => php_uname('r'), + 'version' => php_uname("v"), + 'arch' => php_uname("m") + ), + ); + $conn->close(); + http_response_code(200); + die (json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); +} catch (Exception $e) { + ErrorHandler::Critical('Settings DB ', $e); + $rsp = array( + 'code' => 500, + 'error' => "The server encountered a situation it doesn't know how to handle.", + 'message' => 'We are sorry, but our server cannot handle this request. Please do not try again!' + ); + http_response_code(500); + die (json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); +} +?> diff --git a/api/base.php b/api/base.php index 2ab2d3f7..4ce377fa 100644 --- a/api/base.php +++ b/api/base.php @@ -10,7 +10,7 @@ $rsp = array( "code" => 500, "error" => "The server is not ready to handle the request.", - "message" => "We have no write permission for our home directory. Please update the permission by executing this in the server shell: chown -R www-data:www-data /var/www/client/ && chown -R www-data:www-data /var/www/client/*" + "message" => "We have no write permission for our home directory. Please update the permission by executing this in the server shell: chown -R www-data:www-data /var/www/mythicaldash/ && chown -R www-data:www-data /var/www/mythicaldash/*" ); die(json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); } diff --git a/cli/Program.cs b/cli/Program.cs index 0f306706..1f996442 100644 --- a/cli/Program.cs +++ b/cli/Program.cs @@ -154,6 +154,32 @@ public static void Main(string[] args) Environment.Exit(0x0); } } + else if (args.Contains("-environment:down")) + { + try + { + sh.SetMaintenance(true); + Environment.Exit(0x0); + } + catch (Exception ex) + { + logger.Log(LogType.Error, "Failed to update config: " + ex.Message); + Environment.Exit(0x0); + } + } + else if (args.Contains("-environment:up")) + { + try + { + sh.SetMaintenance(false); + Environment.Exit(0x0); + } + catch (Exception ex) + { + logger.Log(LogType.Error, "Failed to update config: " + ex.Message); + Environment.Exit(0x0); + } + } else if (args.Contains("-debug:disable")) { try diff --git a/cli/build.bash b/cli/build.bash index c743b3af..bdfe2660 100755 --- a/cli/build.bash +++ b/cli/build.bash @@ -3,9 +3,9 @@ runtimes=("linux-x64" "linux-x86" "linux-arm64" "linux-arm") rm -r bin/Release rm -r obj/ -rm /var/www/client/MythicalDashARM32 -rm /var/www/client/MythicalDashARM64 -rm /var/www/client/MythicalDash64 +rm /var/www/mythicaldash/MythicalDashARM32 +rm /var/www/mythicaldash/MythicalDashARM64 +rm /var/www/mythicaldash/MythicalDash64 for runtime in "${runtimes[@]}"; do echo "Publishing for runtime: $runtime" @@ -14,9 +14,9 @@ for runtime in "${runtimes[@]}"; do dotnet publish -c Release -r "$runtime" --self-contained true /p:PublishSingleFile=true -p:Version=1.0.0.1 echo "----------------------------------" done -mv /var/www/client/cli/bin/Release/net7.0/linux-arm/publish/MythicalDash /var/www/client -mv /var/www/client/MythicalDash /var/www/client/MythicalDashARM32 -mv /var/www/client/cli/bin/Release/net7.0/linux-arm64/publish/MythicalDash /var/www/client -mv /var/www/client/MythicalDash /var/www/client/MythicalDashARM64 -mv /var/www/client/cli/bin/Release/net7.0/linux-x64/publish/MythicalDash /var/www/client -mv /var/www/client/MythicalDash /var/www/client/MythicalDash64 \ No newline at end of file +mv /var/www/mythicaldash/cli/bin/Release/net7.0/linux-arm/publish/MythicalDash /var/www/client +mv /var/www/mythicaldash/MythicalDash /var/www/mythicaldash/MythicalDashARM32 +mv /var/www/mythicaldash/cli/bin/Release/net7.0/linux-arm64/publish/MythicalDash /var/www/client +mv /var/www/mythicaldash/MythicalDash /var/www/mythicaldash/MythicalDashARM64 +mv /var/www/mythicaldash/cli/bin/Release/net7.0/linux-x64/publish/MythicalDash /var/www/client +mv /var/www/mythicaldash/MythicalDash /var/www/mythicaldash/MythicalDash64 \ No newline at end of file diff --git a/cli/scripts/SettingsHandler.cs b/cli/scripts/SettingsHandler.cs index 4dd8e4f0..56085485 100644 --- a/cli/scripts/SettingsHandler.cs +++ b/cli/scripts/SettingsHandler.cs @@ -86,6 +86,25 @@ public void Setup() } } + public void SetMaintenance(bool status) + { + try + { + if (status == true) + { + + } + else if (status == false) + { + + } + } + catch (Exception ex) + { + Program.logger.Log(LogType.Error, "Sorry but the auto settings throws this error: " + ex.Message); + } + } + public void PurgeCache() { if (fm.ConfigExists() == true) @@ -107,7 +126,7 @@ public void PurgeCache() { File.Delete(logFile); } - Program.logger.Log(LogType.Info,"Done"); + Program.logger.Log(LogType.Info, "Done"); } catch (Exception ex) { diff --git a/migrate/42.sql b/migrate/42.sql new file mode 100644 index 00000000..e86d0d44 --- /dev/null +++ b/migrate/42.sql @@ -0,0 +1 @@ +UPDATE `mythicaldash_settings` SET `version` = '3.0.3' WHERE `mythicaldash_settings`.`id` = 1; diff --git a/view/admin/settings/main.php b/view/admin/settings/main.php index 35958428..d6a7bcb3 100644 --- a/view/admin/settings/main.php +++ b/view/admin/settings/main.php @@ -938,7 +938,7 @@ class="btn btn-primary me-2 waves-effect waves-light" value="true">Save
-
+
diff --git a/view/admin/settings/security.php b/view/admin/settings/security.php index 4cad79b7..0c125af3 100644 --- a/view/admin/settings/security.php +++ b/view/admin/settings/security.php @@ -3,7 +3,7 @@ include(__DIR__ . '/../../requirements/page.php'); include(__DIR__ . '/../../requirements/admin.php'); try { - if (isset($_GET['update_settings'])) { + if (isset($_GET[' '])) { $enable_adblocker_detection = mysqli_real_escape_string($conn, $_GET['ads:adblocker']); $enable_alting = mysqli_real_escape_string($conn, $_GET['enable_alting']); $enable_anti_vpn = mysqli_real_escape_string($conn, $_GET['enable_anti_vpn']); @@ -14,7 +14,7 @@ $conn->close(); die(); } else { - header('location: /admin/settings'); + header('location: /admin/settings?e=Failed to update the settings inside the database'); die(); } } catch (Exception $ex) {