|
| 1 | +<?php |
| 2 | +use MythicalDash\Database\Connect; |
| 3 | +use MythicalDash\SettingsManager; |
| 4 | +use MythicalDash\ErrorHandler; |
| 5 | + |
| 6 | +$conn = new Connect(); |
| 7 | +$conn = $conn->connectToDatabase(); |
| 8 | +header('Content-type: application/json'); |
| 9 | +ini_set('display_errors', 0); |
| 10 | +ini_set('display_startup_errors', 0); |
| 11 | +if (!is_writable(__DIR__)) { |
| 12 | + http_response_code(500); |
| 13 | + $rsp = array( |
| 14 | + 'code' => 500, |
| 15 | + 'error' => 'The server is not ready to handle the request.', |
| 16 | + '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/*' |
| 17 | + ); |
| 18 | + die (json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); |
| 19 | +} |
| 20 | + |
| 21 | +try { |
| 22 | + $rsp = array( |
| 23 | + 'code' => 200, |
| 24 | + 'error' => null, |
| 25 | + 'data' => array( |
| 26 | + 'dash_name' => SettingsManager::getSetting('name'), |
| 27 | + 'dash_version' => SettingsManager::getSetting('version'), |
| 28 | + 'security_modules' => array( |
| 29 | + 'turnstile' => SettingsManager::getSetting('enable_turnstile'), |
| 30 | + 'anti-adblocker' => SettingsManager::getSetting('enable_adblocker_detection'), |
| 31 | + 'anti-alting' => SettingsManager::getSetting('enable_alting'), |
| 32 | + 'anti-vpn' => SettingsManager::getSetting('enable_anti_vpn'), |
| 33 | + 'purge' => SettingsManager::getSetting("server_purge") |
| 34 | + ), |
| 35 | + 'stripe' => array( |
| 36 | + 'enabled' => SettingsManager::getSetting("enable_stripe"), |
| 37 | + 'public-key' => SettingsManager::getSetting("stripe_publishable_key"), |
| 38 | + 'currency' => SettingsManager::getSetting("stripe_currency"), |
| 39 | + ), |
| 40 | + 'linkvertise' => array( |
| 41 | + 'enabled' => SettingsManager::getSetting("linkvertise_enabled"), |
| 42 | + 'code' => SettingsManager::getSetting("linkvertise_code"), |
| 43 | + 'coins' => SettingsManager::getSetting("linkvertise_coins") |
| 44 | + ), |
| 45 | + 'pterodactyl' => array( |
| 46 | + 'url' => SettingsManager::getSetting("PterodactylURL") |
| 47 | + ), |
| 48 | + 'smtp' => array( |
| 49 | + 'enabled' => SettingsManager::getSetting("enable_smtp"), |
| 50 | + 'encryption' => SettingsManager::getSetting("smtpSecure"), |
| 51 | + 'port' => SettingsManager::getSetting("smtpPort"), |
| 52 | + 'from' => SettingsManager::getSetting("fromEmail") |
| 53 | + ), |
| 54 | + 'discord' => array( |
| 55 | + 'account_link' => SettingsManager::getSetting("enable_discord_link"), |
| 56 | + 'server_id' => SettingsManager::getSetting("discord_serverid"), |
| 57 | + "client_id" => SettingsManager::getSetting("discord_clientid") |
| 58 | + ) |
| 59 | + ), |
| 60 | + ); |
| 61 | + $conn->close(); |
| 62 | + http_response_code(200); |
| 63 | + die (json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); |
| 64 | +} catch (Exception $e) { |
| 65 | + ErrorHandler::Critical('Settings DB ', $e); |
| 66 | + $rsp = array( |
| 67 | + 'code' => 500, |
| 68 | + 'error' => "The server encountered a situation it doesn't know how to handle.", |
| 69 | + 'message' => 'We are sorry, but our server cannot handle this request. Please do not try again!' |
| 70 | + ); |
| 71 | + http_response_code(500); |
| 72 | + die (json_encode($rsp, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); |
| 73 | +} |
| 74 | +?> |
0 commit comments