diff --git a/.env.example b/.env.example index 98f9662b..46f1a273 100644 --- a/.env.example +++ b/.env.example @@ -4,25 +4,24 @@ APP_ENV=production APP_KEY= APP_DEBUG=false APP_URL=http://localhost -# List with timezones https://www.php.net/manual/en/timezones.php -APP_TIMEZONE=UTC +APP_TIMEZONE=UTC # List with timezones https://www.php.net/manual/en/timezones.php ### --- App Settings End --- ### -### --- DB Settings (required) --- ### +### --- Database Settings (required) --- ### DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=dashboard DB_USERNAME=dashboarduser DB_PASSWORD= -### --- DB Settings End --- ### +### --- Database Settings End --- ### - -# Google Recaptcha API Credentials - https://www.google.com/recaptcha/admin - reCaptcha V2 (not v3) +### --- Google Recaptcha Settings --- ### RECAPTCHA_SITE_KEY=6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI RECAPTCHA_SECRET_KEY=6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe +### --- Google Recaptcha Settings End --- ### -# Mail Server Settings - (HOST -> SMTP Server) +### --- Mail Server Settings --- ### MAIL_MAILER=smtp MAIL_HOST=mailhog MAIL_PORT=1025 @@ -31,25 +30,22 @@ MAIL_PASSWORD=null MAIL_ENCRYPTION=null MAIL_FROM_ADDRESS=null MAIL_FROM_NAME="${APP_NAME}" +### --- Mail Server Settings End --- ### - -# Laravel Logging Settings - https://laravel.com/docs/5.7/logging - Not needed to be changed +### --- Logging Settings --- ### LOG_CHANNEL=stack LOG_LEVEL=debug +### --- Logging Settings End --- ### -# Do not change anything below this line -BROADCAST_DRIVER=log +### --- Cache and Queue Settings --- ### CACHE_DRIVER=file QUEUE_CONNECTION=database SESSION_DRIVER=file SESSION_LIFETIME=120 +SETTINGS_CACHE_ENABLED=true +### --- Cache and Queue Settings End --- ### -MEMCACHED_HOST=127.0.0.1 - -REDIS_HOST=127.0.0.1 -REDIS_PASSWORD=null -REDIS_PORT=6379 - +### --- External Services Credentials --- ### AWS_ACCESS_KEY_ID= AWS_SECRET_ACCESS_KEY= AWS_DEFAULT_REGION=us-east-1 @@ -59,9 +55,15 @@ PUSHER_APP_ID= PUSHER_APP_KEY= PUSHER_APP_SECRET= PUSHER_APP_CLUSTER=mt1 +### --- External Services Credentials End --- ### + +### --- Additional Configuration --- ### +MEMCACHED_HOST=127.0.0.1 + +REDIS_HOST=127.0.0.1 +REDIS_PASSWORD=null +REDIS_PORT=6379 MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" - -# Settings Cache -SETTINGS_CACHE_ENABLED=true +### --- Additional Configuration End --- ### diff --git a/.gitattributes b/.gitattributes index 967315dd..2f74b7dd 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,5 +1,10 @@ +# Automatically detect text files * text=auto + +# Vendored files for specific languages *.css linguist-vendored *.scss linguist-vendored *.js linguist-vendored + +# Ignore CHANGELOG.md when exporting CHANGELOG.md export-ignore diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md new file mode 100644 index 00000000..6b807f42 --- /dev/null +++ b/.github/CODE_OF_CONDUCT.md @@ -0,0 +1,22 @@ +## Code of Conduct + +### 🤝 Our Pledge + +In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to make participation in our project and community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. + +### 🌟 Our Standards +Examples of behavior that contributes to creating a positive environment include: + +- Using welcoming and inclusive language +- Being respectful of differing viewpoints and experiences +- Gracefully accepting constructive criticism +- Focusing on what is best for the community +- Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +- The use of sexualized language or imagery and unwelcome sexual attention or advances +- Trolling, insulting/derogatory comments, and personal or political attacks +- Public or private harassment +- Publishing others' private information, such as a physical or electronic address, without explicit permission +- Other conduct which could reasonably be considered inappropriate in a professional setting diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 00000000..72eb32a7 --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,34 @@ +# Contributing Guidelines + +Thank you for considering contributing to this repository! Before making a contribution, please take a moment to review the following guidelines. + +## 🕵️‍♂️ Finding Tasks + +Check the open issues to see if there's something you can contribute to. If you have an idea or encounter a bug that's not already listed, feel free to create a new issue and wait for feedback from the development team. + +## 🤝 Code of Conduct + +Please adhere to our [Code of Conduct](https://github.com/Ctrlpanel-gg/panel/blob/main/.github/CODE_OF_CONDUCT.md) in all your interactions with the project. + +## 🌍 Localization + +If you add any strings that are displayed on the frontend, please localize them using the following format: +``` +"New String" -> {{ __('New String') }} +``` +After adding localized strings, run the following command to generate localization files: +```cmd +php artisan translatable:export en +``` + +## 🚀 Pull Request Process + +1. Give your pull request (PR) a clear and descriptive title that summarizes the changes. +2. The development team will review your code and provide feedback or approve/merge it when appropriate. +3. Ensure that your PR follows our Code of Conduct and coding style guidelines. + +### 💻 Coding Style + +We follow the PSR12 code standard for PHP. + +Thank you for your contributions! 🎉 diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml index 24b38f4f..f9e8e9ec 100644 --- a/.github/ISSUE_TEMPLATE/bug.yml +++ b/.github/ISSUE_TEMPLATE/bug.yml @@ -1,6 +1,6 @@ name: "\U0001F41B Bug report" description: Create a report to help us improve -title: "[Bug]: " +title: "[Bug] " labels: ["bug"] body: - type: textarea diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..89224a42 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,37 @@ +✨ Thank you for your contribution to our project! Before you submit your pull request, please take a moment to review and complete the following + +⚠️ Please modify this template below and if not already done, read our pull request rules, Thanks! + +Ensure that your pull request meets the following criteria: + +- The code follows the style guidelines of this project +- You have performed a self-review of your own code and tested it +- You have commented your code, particularly in hard-to-understand areas +- Your changes generate no new warnings + +Delete the above text and the following sections before submitting your pull request. + +--- + +💡 **Description** + +Briefly describe the purpose of your pull request, including any relevant issue numbers it addresses. + +--- + +🛠️ **Type of Change** + +Please select the appropriate type of change: + +- Bug fix (non-breaking change which fixes an issue) +- User interface (UI) improvement +- New feature (non-breaking change which adds functionality) +- Breaking change (a fix or feature that would cause existing functionality to not work as expected) +- Other +- This change requires a documentation update + +--- + +🖼️ **Screenshots (if applicable)** + +If your pull request includes any visual changes, please provide screenshots here, do not use any external link. diff --git a/.github/SECURITY.md b/.github/SECURITY.md new file mode 100644 index 00000000..278e81e7 --- /dev/null +++ b/.github/SECURITY.md @@ -0,0 +1,17 @@ +# Security Policy + +## Reporting a Vulnerability + +🛡️ If you discover a security vulnerability, please report it to us via GitHub Advisories. + +⚠️ Please refrain from using the public issue tracker or discussing the vulnerability in public channels, as it may exacerbate the issue. + +## Acceptance of Bug Bounty Platforms + +At this time, we only accept vulnerability reports through GitHub Advisories. We kindly ask that you do not submit reports via other third-party bug bounty platforms, as they will be disregarded. + +## Supported Versions + +### ControlPanel Versions + +We strongly recommend using or upgrading to the latest version of ControlPanel to ensure you have access to the latest security fixes and enhancements. diff --git a/.gitignore b/.gitignore index ad9d095b..f72249a8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,29 +1,34 @@ +# Ignore dependencies and cache /node_modules +/vendor +/storage/*.key + +# Ignore public assets /public/hot /public/storage -/storage/*.key -/vendor -/storage/credit_deduction_log -storage/debugbar +/storage/app/public/logo.png + +# Ignore environment files and configuration .env .env.testing .env.backup -.idea +.env.dev + +# Ignore testing and debug logs .phpunit.result.cache -.editorconfig -docker-compose.override.yml -Homestead.json -Homestead.yaml npm-debug.log yarn-error.log yarn.lock + +# Ignore Docker and Homestead configuration +docker-compose.override.yml +Homestead.json +Homestead.yaml + +# Ignore gitignore itself .gitignore -.env.dev -.env.testing -storage/invoices.zip -storage/app/public/logo.png -*vscode - - Kopie.env + +# Ignore installation logs and locks public/install/logs.txt install.lock public/install/logs/installer.log diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index 74ddb1f9..00000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,43 +0,0 @@ -# Contributing - -When contributing to this repository, please go through the open issues to see if you can contribute to something. If you want to contribute something that is not in the issues you can make an issue and wait for response from the dev team. - -Please note we have a code of conduct, please follow it in all your interactions with the project. - -If you added any Strings which are displayed at the frontend please localize them (e.g. "New String" -> {{ __('New String') }}) and run the localization string generation: - -```cmd -php artisan translatable:export en -``` - -## Pull request process - -1. Give your PR a good descriptive title, so we can view immediately what the PR is about. -2. The dev team will look at your code and approve / merge when possible. -3. Make sure your PR follows our code of conduct and coding style. - -## Code of Conduct - -### Our Pledge -In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. - -### Coding Style - -We are following the PSR12 code standard for PHP. - -### Our Standards -Examples of behavior that contributes to creating a positive environment include: - -- Using welcoming and inclusive language -- Being respectful of differing viewpoints and experiences -- Gracefully accepting constructive criticism -- Focusing on what is best for the community -- Showing empathy towards other community members - -Examples of unacceptable behavior by participants include: - -- The use of sexualized language or imagery and unwelcome sexual attention or advances -- Trolling, insulting/derogatory comments, and personal or political attacks -- Public or private harassment -- Publishing others' private information, such as a physical or electronic address, without explicit permission -- Other conduct which could reasonably be considered inappropriate in a professional setting diff --git a/README.md b/README.md index 35c7ab7e..a3cc0e35 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +<<<<<<< mercadopago-implementation ### Features - PayPal, Stripe, Mollie and MercadoPago Integration @@ -16,52 +17,92 @@ - Alert System - Theme Support - and so much more! +======= +
+ +
+>>>>>>> development # CtrlPanel-gg -![ctrlpanel](https://user-images.githubusercontent.com/67899387/214684708-739c1d21-06e8-4dec-a4f1-81533a46cc7e.png) +CtrlPanel offers an easy-to-use and free billing solution for all starting and experienced hosting providers that seamlessly integrates with the Pterodactyl panel. It facilitates account creation, server ordering, and management, while offering addons, multiple payment methods, and customizable themes for a comprehensive solution. +![GitHub tag](https://img.shields.io/github/tag/ControlPanel-gg/dashboard) +![Overall Installations](https://img.shields.io/badge/Overall%20Installations-5000%2B-green) +![GitHub stars](https://img.shields.io/github/stars/ControlPanel-gg/dashboard) +[![Crowdin](https://badges.crowdin.net/controlpanelgg/localized.svg)](https://crowdin.com/project/controlpanelgg) +![License](https://img.shields.io/github/license/ControlPanel-gg/dashboard) +![Discord](https://img.shields.io/discord/787829714483019826) -![](https://img.shields.io/endpoint?label=v0.9%20Installations&url=https%3A%2F%2Fmarket.ctrlpanel.gg%2Fcallhome.php%3Fgetinstalls) -![](https://img.shields.io/badge/Overall%20Installations-5000%2B-green) -![](https://img.shields.io/github/stars/ctrlpanel-gg/dashboard) ![](https://img.shields.io/github/forks/ctrlpanel-gg/panel) ![](https://img.shields.io/github/tag/ctrlpanel-gg/panel) [![Crowdin](https://badges.crowdin.com/project/controlpanelgg/localized.svg)](https://crowdin.com/project/controlpanelgg) ![](https://img.shields.io/github/issues/ctrlpanel-gg/panel) ![](https://img.shields.io/github/license/ctrlpanel-gg/panel) ![](https://img.shields.io/discord/787829714483019826) -## About +![CtrlPanel](https://user-images.githubusercontent.com/67899387/214684708-739c1d21-06e8-4dec-a4f1-81533a46cc7e.png) -CtrlPanel's Dashboard is a dashboard application designed to offer clients a management tool to manage their pterodactyl servers. This dashboard comes with a credit-based billing solution that charges users depending on the billing cycle you chose for each server they have and suspends them if they run out of credits. +## ⭐ Features -This dashboard offers an easy to use and free billing solution for all starting and experienced hosting providers. This dashboard has many customisation options and added discord Oauth verification to offer a solid link between your discord server and your dashboard. You can check our [Demo here](https://demo.CtrlPanel.gg "Demo"). +- Store (credit system with hourly billing and invoices) +- Many Popular Payment Methods +- Referral +- Partner +- Vouchers +- Ticket +- Account Management +- Admin Dashboard and Tools +- Addon Support +- and more! -### [Installation](https://ctrlpanel.gg/docs/intro "Installation") +## ⛰️ Live Demo -### [Updating](https://ctrlpanel.gg/docs/Installation/updating "Updating") +Try it! -### [Discord](https://discord.gg/4Y6HjD2uyU "Discord") +Demo Server: [demo.CtrlPanel.gg](https://demo.CtrlPanel.gg) -### [Contributing](https://ctrlpanel.gg/docs/Contributing/contributing "Contributing") + -### [Donating](https://ctrlpanel.gg/docs/Contributing/donating "Donating") +## 🔧 How to Install +### 🐳 Docker +Soon... -# Preview + -### Example server products -![image](https://user-images.githubusercontent.com/67899387/214686950-218e1ede-6a1f-4e53-b3f4-fe1abc371a9c.png) +### 💪🏻 Non-Docker -### Ticket System -![image](https://user-images.githubusercontent.com/67899387/214687123-0a3d0f8f-b53c-4b0d-869a-4d5df45f5184.png) +Requirements: -### Voucher System -![image](https://user-images.githubusercontent.com/67899387/214686578-ec9f0b0f-6047-4665-835f-70594b56dfd5.png) +- Platform + - Major Linux distros such as Debian, Ubuntu, CentOS, Fedora, and ArchLinux etc. + - Windows 10 (x64), Windows Server ... -### Partner System -![image](https://user-images.githubusercontent.com/67899387/214686321-36ba97a3-4181-4e60-9ba3-c9b318fe66a8.png) +Follow the [documentation](https://ctrlpanel.gg/docs/intro) to know how to install. +### MarketPlace +If you need more functionality, check out [Marketplace](https://market.ctrlpanel.gg/resources/). +## 🆙 How to Update + +Please read: [Update Instructions](https://ctrlpanel.gg/docs/Installation/updating) + +## 🆕 What's Next? + +Roadmap: [CtrlPanel Roadmap](https://github.com/orgs/Ctrlpanel-gg/projects/1) + +## 🗣️ Discussion / Ask for Help + +For any general or technical questions, join CtrlPanel Discord for finding answers to your question. If you cannot find the information you need, feel free to ask. + +## 🤝 Contributing + +Please read [CONTRIBUTING.md](https://github.com/Ctrlpanel-gg/panel/blob/main/.github/CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us. + +Thanks to all contributors and supporters! + +## ♥️ Donations + +If you like what we do, please consider [supporting](https://ctrlpanel.gg/docs/Contributing/donating) us. diff --git a/app/Classes/LegacySettingsMigration.php b/app/Classes/LegacySettingsMigration.php new file mode 100644 index 00000000..dd32a761 --- /dev/null +++ b/app/Classes/LegacySettingsMigration.php @@ -0,0 +1,63 @@ +where([['group', '=', $group], ['name', '=', $name]])->get(['payload'])->first(); + + if (is_null($new_value) || is_null($new_value->payload)) { + return null; + } + + // Some keys returns '""' as a value. + if ($new_value->payload === '""') { + return null; + } + + + // remove the quotes from the string + if (substr($new_value->payload, 0, 1) === '"' && substr($new_value->payload, -1) === '"') { + return substr($new_value->payload, 1, -1); + } + + return $new_value->payload; + } + + /** + * Get the old value from the settings_old table. + * @param string $key The key to get the value from table. + * @param int|string|bool|null $default The default value to return if the value is null. If value is not nullable, a default must be provided. + */ + public function getOldValue(string $key, int|string|bool|null $default = null) + { + $old_value = DB::table('settings_old')->where('key', '=', $key)->get(['value', 'type'])->first(); + + if (is_null($old_value) || is_null($old_value->value)) { + return $default; + } + + switch ($old_value->type) { + case 'string': + case 'text': + // Edgecase: The value is a boolean, but it's stored as a string. + if ($old_value->value === "false" || $old_value->value === "true") { + return filter_var($old_value->value, FILTER_VALIDATE_BOOL); + } + return $old_value->value; + case 'boolean': + return filter_var($old_value->value, FILTER_VALIDATE_BOOL); + case 'integer': + return filter_var($old_value->value, FILTER_VALIDATE_INT); + default: + throw new Exception("Unknown type: {$old_value->type}"); + } + } +} diff --git a/app/Http/Controllers/Admin/UserController.php b/app/Http/Controllers/Admin/UserController.php index 60a1120f..b023d232 100644 --- a/app/Http/Controllers/Admin/UserController.php +++ b/app/Http/Controllers/Admin/UserController.php @@ -316,7 +316,8 @@ class UserController extends Controller ->line(new HtmlString($data['content'])); } $all = $data['all'] ?? false; - if(!$data["roles"]){ + $roles = $data['roles'] ?? false; + if(!$roles){ $users = $all ? User::all() : User::whereIn('id', $data['users'])->get(); } else{ $users = User::role($data["roles"])->get(); diff --git a/app/Http/Controllers/ServerController.php b/app/Http/Controllers/ServerController.php index d291e298..0c18a508 100644 --- a/app/Http/Controllers/ServerController.php +++ b/app/Http/Controllers/ServerController.php @@ -8,8 +8,6 @@ use App\Models\Pterodactyl\Nest; use App\Models\Pterodactyl\Node; use App\Models\Product; use App\Models\Server; -use App\Models\User; -use App\Models\Settings; use App\Notifications\ServerCreationError; use Carbon\Carbon; use App\Settings\UserSettings; @@ -18,7 +16,6 @@ use App\Settings\PterodactylSettings; use App\Classes\PterodactylClient; use App\Settings\GeneralSettings; use Exception; -use GuzzleHttp\Promise\Create; use Illuminate\Database\Eloquent\Builder; use Illuminate\Http\Client\Response; use Illuminate\Http\RedirectResponse; diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index fb6e8f9c..5e1f05d0 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -2,7 +2,6 @@ namespace App\Providers; -use App\Extensions\PaymentGateways\PayPal\PayPalSettings; use App\Models\UsefulLink; use App\Settings\GeneralSettings; use App\Settings\MailSettings; @@ -89,20 +88,23 @@ class AppServiceProvider extends ServiceProvider Log::error("Couldnt find useful_links. Probably the installation is not completet. " . $e); } - $generalSettings = $this->app->make(GeneralSettings::class); - if (!file_exists(base_path('themes') . "/" . $generalSettings->theme)) { - $generalSettings->theme = "default"; + + try { + $generalSettings = $this->app->make(GeneralSettings::class); + if (!file_exists(base_path('themes') . "/" . $generalSettings->theme)) { + $generalSettings->theme = "default"; + } + + if ($generalSettings->theme && $generalSettings->theme !== config('theme.active')) { + Theme::set($generalSettings->theme, "default"); + } else { + Theme::set("default", "default"); + } + + $settings = $this->app->make(MailSettings::class); + $settings->setConfig(); + } catch (Exception $e) { + Log::error("Couldnt load Settings. Probably the installation is not completet. " . $e); } - - if ($generalSettings->theme && $generalSettings->theme !== config('theme.active')) { - Theme::set($generalSettings->theme, "default"); - } else { - Theme::set("default", "default"); - } - - - $settings = $this->app->make(MailSettings::class); - $settings->setConfig(); - } } diff --git a/app/Settings/DiscordSettings.php b/app/Settings/DiscordSettings.php index 4788ae7e..79981c71 100644 --- a/app/Settings/DiscordSettings.php +++ b/app/Settings/DiscordSettings.php @@ -18,8 +18,6 @@ class DiscordSettings extends Settings return 'discord'; } - - /** * Summary of validations array * @return array diff --git a/app/Settings/MailSettings.php b/app/Settings/MailSettings.php index 90b5a328..c3a9a367 100644 --- a/app/Settings/MailSettings.php +++ b/app/Settings/MailSettings.php @@ -20,7 +20,12 @@ class MailSettings extends Settings return 'mail'; } - + public static function encrypted(): array + { + return [ + 'mail_password', + ]; + } public function setConfig() { diff --git a/app/Settings/PterodactylSettings.php b/app/Settings/PterodactylSettings.php index 3e888b93..c9693386 100644 --- a/app/Settings/PterodactylSettings.php +++ b/app/Settings/PterodactylSettings.php @@ -16,7 +16,13 @@ class PterodactylSettings extends Settings return 'pterodactyl'; } - + public static function encrypted(): array + { + return [ + 'admin_token', + 'user_token', + ]; + } /** * Get url with ensured ending backslash diff --git a/composer b/composer deleted file mode 100644 index e69de29b..00000000 diff --git a/config/settings.php b/config/settings.php index 6b6ae4b7..e9a3a4b1 100644 --- a/config/settings.php +++ b/config/settings.php @@ -32,7 +32,7 @@ return [ UserSettings::class, WebsiteSettings::class, TicketSettings::class, - CouponSettings::class, + CouponSettings::class, ], /* diff --git a/database/migrations/2023_05_08_094402_update_user_credits_datatype.php b/database/migrations/2023_05_08_094402_update_user_credits_datatype.php index 292102cc..db0acb2f 100644 --- a/database/migrations/2023_05_08_094402_update_user_credits_datatype.php +++ b/database/migrations/2023_05_08_094402_update_user_credits_datatype.php @@ -26,7 +26,7 @@ class UpdateUserCreditsDatatype extends Migration public function down() { Schema::table('users', function (Blueprint $table) { - $table->decimal('price', ['11', '2'])->change(); + $table->decimal('credits', ['11', '2'])->change(); }); } } diff --git a/database/settings/2023_02_01_164731_create_general_settings.php b/database/settings/2023_02_01_164731_create_general_settings.php index 5d183590..06c876c5 100644 --- a/database/settings/2023_02_01_164731_create_general_settings.php +++ b/database/settings/2023_02_01_164731_create_general_settings.php @@ -1,9 +1,9 @@ migrator->add('general.store_enabled', true); - $this->migrator->add('general.credits_display_name', $table_exists ? $this->getOldValue('SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME') : 'Credits'); + $this->migrator->add('general.credits_display_name', $table_exists ? $this->getOldValue('SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME', 'Credits') : 'Credits'); $this->migrator->add('general.recaptcha_site_key', $table_exists ? $this->getOldValue("SETTINGS::RECAPTCHA:SITE_KEY") : env('RECAPTCHA_SITE_KEY', '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI')); $this->migrator->add('general.recaptcha_secret_key', $table_exists ? $this->getOldValue("SETTINGS::RECAPTCHA:SECRET_KEY") : env('RECAPTCHA_SECRET_KEY', '6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe')); - $this->migrator->add('general.recaptcha_enabled', $table_exists ? $this->getOldValue("SETTINGS::RECAPTCHA:ENABLED") : true); - $this->migrator->add('general.phpmyadmin_url', $table_exists ? $this->getOldValue("SETTINGS::MISC:PHPMYADMIN:URL") : env('PHPMYADMIN_URL', '')); - $this->migrator->add('general.alert_enabled', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:ALERT_ENABLED") : false); - $this->migrator->add('general.alert_type', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:ALERT_TYPE") : 'dark'); - $this->migrator->add('general.alert_message', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:ALERT_MESSAGE") : ''); - $this->migrator->add('general.theme', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:THEME") : 'default'); + $this->migrator->add('general.recaptcha_enabled', $table_exists ? $this->getOldValue("SETTINGS::RECAPTCHA:ENABLED", false) : false); + $this->migrator->add('general.phpmyadmin_url', $table_exists ? $this->getOldValue("SETTINGS::MISC:PHPMYADMIN:URL") : env('PHPMYADMIN_URL')); + $this->migrator->add('general.alert_enabled', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:ALERT_ENABLED", false) : false); + $this->migrator->add('general.alert_type', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:ALERT_TYPE", 'dark') : 'dark'); + $this->migrator->add('general.alert_message', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:ALERT_MESSAGE") : null); + $this->migrator->add('general.theme', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:THEME", 'default') : 'default'); } public function down(): void @@ -27,113 +27,73 @@ class CreateGeneralSettings extends SettingsMigration DB::table('settings_old')->insert([ [ 'key' => 'SETTINGS::SYSTEM:CREDITS_DISPLAY_NAME', - 'value' => $this->getNewValue('credits_display_name'), + 'value' => $this->getNewValue('credits_display_name', 'general'), 'type' => 'string', 'description' => 'The name of the credits on the panel.' ], [ 'key' => 'SETTINGS::SYSTEM:ALERT_ENABLED', - 'value' => $this->getNewValue('alert_enabled'), + 'value' => $this->getNewValue('alert_enabled', 'general'), 'type' => 'boolean', 'description' => 'Enable the alert at the top of the panel.' ], [ 'key' => 'SETTINGS::SYSTEM:ALERT_TYPE', - 'value' => $this->getNewValue('alert_type'), + 'value' => $this->getNewValue('alert_type', 'general'), 'type' => 'string', 'description' => 'The type of alert to display.' ], [ 'key' => 'SETTINGS::SYSTEM:ALERT_MESSAGE', - 'value' => $this->getNewValue('alert_message'), + 'value' => $this->getNewValue('alert_message', 'general'), 'type' => 'text', 'description' => 'The message to display in the alert.' ], [ 'key' => 'SETTINGS::SYSTEM:THEME', - 'value' => $this->getNewValue('theme'), + 'value' => $this->getNewValue('theme', 'general'), 'type' => 'string', 'description' => 'The theme to use for the panel.' ], [ 'key' => 'SETTINGS::RECAPTCHA:SITE_KEY', - 'value' => $this->getNewValue('recaptcha_site_key'), + 'value' => $this->getNewValue('recaptcha_site_key', 'general'), 'type' => 'string', 'description' => 'The site key for reCAPTCHA.' ], [ 'key' => 'SETTINGS::RECAPTCHA:SECRET_KEY', - 'value' => $this->getNewValue('recaptcha_secret_key'), + 'value' => $this->getNewValue('recaptcha_secret_key', 'general'), 'type' => 'string', 'description' => 'The secret key for reCAPTCHA.' ], [ 'key' => 'SETTINGS::RECAPTCHA:ENABLED', - 'value' => $this->getNewValue('recaptcha_enabled'), + 'value' => $this->getNewValue('recaptcha_enabled', 'general'), 'type' => 'boolean', 'description' => 'Enable reCAPTCHA on the panel.' ], [ 'key' => 'SETTINGS::MISC:PHPMYADMIN:URL', - 'value' => $this->getNewValue('phpmyadmin_url'), + 'value' => $this->getNewValue('phpmyadmin_url', 'general'), 'type' => 'string', 'description' => 'The URL to your phpMyAdmin installation.' ], ]); - - $this->migrator->delete('general.store_enabled'); - $this->migrator->delete('general.credits_display_name'); - $this->migrator->delete('general.recaptcha_site_key'); - $this->migrator->delete('general.recaptcha_secret_key'); - $this->migrator->delete('general.recaptcha_enabled'); - $this->migrator->delete('general.phpmyadmin_url'); - $this->migrator->delete('general.alert_enabled'); - $this->migrator->delete('general.alert_type'); - $this->migrator->delete('general.alert_message'); - $this->migrator->delete('general.theme'); - } - - public function getNewValue(string $name) - { - $new_value = DB::table('settings')->where([['group', '=', 'general'], ['name', '=', $name]])->get(['payload'])->first(); - - // Some keys returns '""' as a value. - if ($new_value->payload === '""') { - return null; + try { + $this->migrator->delete('general.store_enabled'); + $this->migrator->delete('general.credits_display_name'); + $this->migrator->delete('general.recaptcha_site_key'); + $this->migrator->delete('general.recaptcha_secret_key'); + $this->migrator->delete('general.recaptcha_enabled'); + $this->migrator->delete('general.phpmyadmin_url'); + $this->migrator->delete('general.alert_enabled'); + $this->migrator->delete('general.alert_type'); + $this->migrator->delete('general.alert_message'); + $this->migrator->delete('general.theme'); + } catch (Exception $e) { + // Do nothing } - - // remove the quotes from the string - if (substr($new_value->payload, 0, 1) === '"' && substr($new_value->payload, -1) === '"') { - return substr($new_value->payload, 1, -1); - } - - return $new_value->payload; - } - - public function getOldValue(string $key) - { - // Always get the first value of the key. - $old_value = DB::table('settings_old')->where('key', '=', $key)->get(['value', 'type'])->first(); - - // Handle the old values to return without it being a string in all cases. - if ($old_value->type === "string" || $old_value->type === "text") { - if (is_null($old_value->value)) { - return ''; - } - - // Some values have the type string, but their values are boolean. - if ($old_value->value === "false" || $old_value->value === "true") { - return filter_var($old_value->value, FILTER_VALIDATE_BOOL); - } - - return $old_value->value; - } - - if ($old_value->type === "boolean") { - return filter_var($old_value->value, FILTER_VALIDATE_BOOL); - } - - return filter_var($old_value->value, FILTER_VALIDATE_INT); } } diff --git a/database/settings/2023_02_01_181334_create_pterodactyl_settings.php b/database/settings/2023_02_01_181334_create_pterodactyl_settings.php index f3b5b37d..dbbb93b6 100644 --- a/database/settings/2023_02_01_181334_create_pterodactyl_settings.php +++ b/database/settings/2023_02_01_181334_create_pterodactyl_settings.php @@ -1,19 +1,18 @@ exists(); - // Get the user-set configuration values from the old table. - $this->migrator->addEncrypted('pterodactyl.admin_token', $table_exists ? $this->getOldValue('SETTINGS::SYSTEM:PTERODACTYL:TOKEN') : env('PTERODACTYL_TOKEN', '')); - $this->migrator->addEncrypted('pterodactyl.user_token', $table_exists ? $this->getOldValue('SETTINGS::SYSTEM:PTERODACTYL:ADMIN_USER_TOKEN') : ''); - $this->migrator->add('pterodactyl.panel_url', $table_exists ? $this->getOldValue('SETTINGS::SYSTEM:PTERODACTYL:URL') : env('PTERODACTYL_URL', '')); - $this->migrator->add('pterodactyl.per_page_limit', $table_exists ? $this->getOldValue('SETTINGS::SYSTEM:PTERODACTYL:PER_PAGE_LIMIT') : 200); + $this->migrator->addEncrypted('pterodactyl.admin_token', $table_exists ? $this->getOldValue('SETTINGS::SYSTEM:PTERODACTYL:TOKEN', '') : env('PTERODACTYL_TOKEN', '')); + $this->migrator->addEncrypted('pterodactyl.user_token', $table_exists ? $this->getOldValue('SETTINGS::SYSTEM:PTERODACTYL:ADMIN_USER_TOKEN', '') : ''); + $this->migrator->add('pterodactyl.panel_url', $table_exists ? $this->getOldValue('SETTINGS::SYSTEM:PTERODACTYL:URL', '') : env('PTERODACTYL_URL', '')); + $this->migrator->add('pterodactyl.per_page_limit', $table_exists ? $this->getOldValue('SETTINGS::SYSTEM:PTERODACTYL:PER_PAGE_LIMIT', 200) : 200); } public function down(): void @@ -23,76 +22,37 @@ class CreatePterodactylSettings extends SettingsMigration DB::table('settings_old')->insert([ [ 'key' => 'SETTINGS::SYSTEM:PTERODACTYL:TOKEN', - 'value' => $this->getNewValue('admin_token'), + 'value' => $this->getNewValue('admin_token', 'pterodactyl'), 'type' => 'string', 'description' => 'The admin token for the Pterodactyl panel.', ], [ 'key' => 'SETTINGS::SYSTEM:PTERODACTYL:ADMIN_USER_TOKEN', - 'value' => $this->getNewValue('user_token'), + 'value' => $this->getNewValue('user_token', 'pterodactyl'), 'type' => 'string', 'description' => 'The user token for the Pterodactyl panel.', ], [ 'key' => 'SETTINGS::SYSTEM:PTERODACTYL:URL', - 'value' => $this->getNewValue('panel_url'), + 'value' => $this->getNewValue('panel_url', 'pterodactyl'), 'type' => 'string', 'description' => 'The URL for the Pterodactyl panel.', ], [ 'key' => 'SETTINGS::SYSTEM:PTERODACTYL:PER_PAGE_LIMIT', - 'value' => $this->getNewValue('per_page_limit'), + 'value' => $this->getNewValue('per_page_limit', 'pterodactyl'), 'type' => 'integer', 'description' => 'The number of servers to show per page.', ], ]); - $this->migrator->delete('pterodactyl.admin_token'); - $this->migrator->delete('pterodactyl.user_token'); - $this->migrator->delete('pterodactyl.panel_url'); - $this->migrator->delete('pterodactyl.per_page_limit'); - } - - public function getNewValue(string $name) - { - $new_value = DB::table('settings')->where([['group', '=', 'pterodactyl'], ['name', '=', $name]])->get(['payload'])->first(); - - // Some keys returns '""' as a value. - if ($new_value->payload === '""') { - return null; + try { + $this->migrator->delete('pterodactyl.admin_token'); + $this->migrator->delete('pterodactyl.user_token'); + $this->migrator->delete('pterodactyl.panel_url'); + $this->migrator->delete('pterodactyl.per_page_limit'); + } catch (Exception $e) { + echo 'Caught exception: ', $e->getMessage(), "\n"; } - - // remove the quotes from the string - if (substr($new_value->payload, 0, 1) === '"' && substr($new_value->payload, -1) === '"') { - return substr($new_value->payload, 1, -1); - } - - return $new_value->payload; - } - - public function getOldValue(string $key) - { - // Always get the first value of the key. - $old_value = DB::table('settings_old')->where('key', '=', $key)->get(['value', 'type'])->first(); - - // Handle the old values to return without it being a string in all cases. - if ($old_value->type === "string" || $old_value->type === "text") { - if (is_null($old_value->value)) { - return ''; - } - - // Some values have the type string, but their values are boolean. - if ($old_value->value === "false" || $old_value->value === "true") { - return filter_var($old_value->value, FILTER_VALIDATE_BOOL); - } - - return $old_value->value; - } - - if ($old_value->type === "boolean") { - return filter_var($old_value->value, FILTER_VALIDATE_BOOL); - } - - return filter_var($old_value->value, FILTER_VALIDATE_INT); } } diff --git a/database/settings/2023_02_01_181453_create_mail_settings.php b/database/settings/2023_02_01_181453_create_mail_settings.php index 8437a61a..b7d2c0d3 100644 --- a/database/settings/2023_02_01_181453_create_mail_settings.php +++ b/database/settings/2023_02_01_181453_create_mail_settings.php @@ -1,9 +1,9 @@ insert([ [ 'key' => 'SETTINGS::MAIL:HOST', - 'value' => $this->getNewValue('mail_host'), + 'value' => $this->getNewValue('mail_host', 'mail'), 'type' => 'string', 'description' => 'The host of the mail server.', ], [ 'key' => 'SETTINGS::MAIL:PORT', - 'value' => $this->getNewValue('mail_port'), + 'value' => $this->getNewValue('mail_port', 'mail'), 'type' => 'integer', 'description' => 'The port of the mail server.', ], [ 'key' => 'SETTINGS::MAIL:USERNAME', - 'value' => $this->getNewValue('mail_username'), + 'value' => $this->getNewValue('mail_username', 'mail'), 'type' => 'string', 'description' => 'The username of the mail server.', ], [ 'key' => 'SETTINGS::MAIL:PASSWORD', - 'value' => $this->getNewValue('mail_password'), + 'value' => $this->getNewValue('mail_password', 'mail'), 'type' => 'string', 'description' => 'The password of the mail server.', ], [ 'key' => 'SETTINGS::MAIL:ENCRYPTION', - 'value' => $this->getNewValue('mail_encryption'), + 'value' => $this->getNewValue('mail_encryption', 'mail'), 'type' => 'string', 'description' => 'The encryption of the mail server.', ], [ 'key' => 'SETTINGS::MAIL:FROM_ADDRESS', - 'value' => $this->getNewValue('mail_from_address'), + 'value' => $this->getNewValue('mail_from_address', 'mail'), 'type' => 'string', 'description' => 'The from address of the mail server.', ], [ 'key' => 'SETTINGS::MAIL:FROM_NAME', - 'value' => $this->getNewValue('mail_from_name'), + 'value' => $this->getNewValue('mail_from_name', 'mail'), 'type' => 'string', 'description' => 'The from name of the mail server.', ], [ 'key' => 'SETTINGS::MAIL:MAILER', - 'value' => $this->getNewValue('mail_mailer'), + 'value' => $this->getNewValue('mail_mailer', 'mail'), 'type' => 'string', 'description' => 'The mailer of the mail server.', ], ]); - $this->migrator->delete('mail.mail_host'); - $this->migrator->delete('mail.mail_port'); - $this->migrator->delete('mail.mail_username'); - $this->migrator->delete('mail.mail_password'); - $this->migrator->delete('mail.mail_encryption'); - $this->migrator->delete('mail.mail_from_address'); - $this->migrator->delete('mail.mail_from_name'); - $this->migrator->delete('mail.mail_mailer'); - } - - - public function getNewValue(string $name) - { - $new_value = DB::table('settings')->where([['group', '=', 'mail'], ['name', '=', $name]])->get(['payload'])->first(); - - // Some keys returns '""' as a value. - if ($new_value->payload === '""') { - return null; + try { + $this->migrator->delete('mail.mail_host'); + $this->migrator->delete('mail.mail_port'); + $this->migrator->delete('mail.mail_username'); + $this->migrator->delete('mail.mail_password'); + $this->migrator->delete('mail.mail_encryption'); + $this->migrator->delete('mail.mail_from_address'); + $this->migrator->delete('mail.mail_from_name'); + $this->migrator->delete('mail.mail_mailer'); + } catch (Exception $e) { + // } - - // remove the quotes from the string - if (substr($new_value->payload, 0, 1) === '"' && substr($new_value->payload, -1) === '"') { - return substr($new_value->payload, 1, -1); - } - - return $new_value->payload; - } - public function getOldValue(string $key) - { - // Always get the first value of the key. - $old_value = DB::table('settings_old')->where('key', '=', $key)->get(['value', 'type'])->first(); - - // Handle the old values to return without it being a string in all cases. - if ($old_value->type === "string" || $old_value->type === "text") { - if (is_null($old_value->value)) { - return ''; - } - - // Some values have the type string, but their values are boolean. - if ($old_value->value === "false" || $old_value->value === "true") { - return filter_var($old_value->value, FILTER_VALIDATE_BOOL); - } - - return $old_value->value; - } - - if ($old_value->type === "boolean") { - return filter_var($old_value->value, FILTER_VALIDATE_BOOL); - } - - return filter_var($old_value->value, FILTER_VALIDATE_INT); } } diff --git a/database/settings/2023_02_01_181925_create_user_settings.php b/database/settings/2023_02_01_181925_create_user_settings.php index 524ef0b7..683c998b 100644 --- a/database/settings/2023_02_01_181925_create_user_settings.php +++ b/database/settings/2023_02_01_181925_create_user_settings.php @@ -1,27 +1,27 @@ exists(); // Get the user-set configuration values from the old table. - $this->migrator->add('user.credits_reward_after_verify_discord', $table_exists ? $this->getOldValue('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_DISCORD') : 250); - $this->migrator->add('user.credits_reward_after_verify_email', $table_exists ? $this->getOldValue('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_EMAIL') : 250); - $this->migrator->add('user.force_discord_verification', $table_exists ? $this->getOldValue('SETTINGS::USER:FORCE_DISCORD_VERIFICATION') : false); - $this->migrator->add('user.force_email_verification', $table_exists ? $this->getOldValue('SETTINGS::USER:FORCE_EMAIL_VERIFICATION') : false); - $this->migrator->add('user.initial_credits', $table_exists ? $this->getOldValue('SETTINGS::USER:INITIAL_CREDITS') : 250); - $this->migrator->add('user.initial_server_limit', $table_exists ? $this->getOldValue('SETTINGS::USER:INITIAL_SERVER_LIMIT') : 1); - $this->migrator->add('user.min_credits_to_make_server', $table_exists ? $this->getOldValue('SETTINGS::USER:MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER') : 50); - $this->migrator->add('user.server_limit_after_irl_purchase', $table_exists ? $this->getOldValue('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE') : 10); - $this->migrator->add('user.server_limit_after_verify_discord', $table_exists ? $this->getOldValue('SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_DISCORD') : 2); - $this->migrator->add('user.server_limit_after_verify_email', $table_exists ? $this->getOldValue('SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_EMAIL') : 2); - $this->migrator->add('user.register_ip_check', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:REGISTER_IP_CHECK") : true); - $this->migrator->add('user.creation_enabled', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:CREATION_OF_NEW_USERS") : true); + $this->migrator->add('user.credits_reward_after_verify_discord', $table_exists ? $this->getOldValue('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_DISCORD', 250) : 250); + $this->migrator->add('user.credits_reward_after_verify_email', $table_exists ? $this->getOldValue('SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_EMAIL', 250) : 250); + $this->migrator->add('user.force_discord_verification', $table_exists ? $this->getOldValue('SETTINGS::USER:FORCE_DISCORD_VERIFICATION', false) : false); + $this->migrator->add('user.force_email_verification', $table_exists ? $this->getOldValue('SETTINGS::USER:FORCE_EMAIL_VERIFICATION', false) : false); + $this->migrator->add('user.initial_credits', $table_exists ? $this->getOldValue('SETTINGS::USER:INITIAL_CREDITS', 250) : 250); + $this->migrator->add('user.initial_server_limit', $table_exists ? $this->getOldValue('SETTINGS::USER:INITIAL_SERVER_LIMIT', 1) : 1); + $this->migrator->add('user.min_credits_to_make_server', $table_exists ? $this->getOldValue('SETTINGS::USER:MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER', 50) : 50); + $this->migrator->add('user.server_limit_after_irl_purchase', $table_exists ? $this->getOldValue('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE', 10) : 10); + $this->migrator->add('user.server_limit_after_verify_discord', $table_exists ? $this->getOldValue('SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_DISCORD', 2) : 2); + $this->migrator->add('user.server_limit_after_verify_email', $table_exists ? $this->getOldValue('SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_EMAIL', 2) : 2); + $this->migrator->add('user.register_ip_check', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:REGISTER_IP_CHECK", true) : true); + $this->migrator->add('user.creation_enabled', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:CREATION_OF_NEW_USERS", true) : true); } public function down(): void @@ -29,135 +29,96 @@ class CreateUserSettings extends SettingsMigration DB::table('settings_old')->insert([ [ 'key' => 'SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_DISCORD', - 'value' => $this->getNewValue('credits_reward_after_verify_discord'), + 'value' => $this->getNewValue('credits_reward_after_verify_discord', 'user'), 'type' => 'integer', 'description' => 'The amount of credits that the user will receive after verifying their Discord account.', ], [ 'key' => 'SETTINGS::USER:CREDITS_REWARD_AFTER_VERIFY_EMAIL', - 'value' => $this->getNewValue('credits_reward_after_verify_email'), + 'value' => $this->getNewValue('credits_reward_after_verify_email', 'user'), 'type' => 'integer', 'description' => 'The amount of credits that the user will receive after verifying their email.', ], [ 'key' => 'SETTINGS::USER:FORCE_DISCORD_VERIFICATION', - 'value' => $this->getNewValue('force_discord_verification'), + 'value' => $this->getNewValue('force_discord_verification', 'user'), 'type' => 'boolean', 'description' => 'If the user must verify their Discord account to use the panel.', ], [ 'key' => 'SETTINGS::USER:FORCE_EMAIL_VERIFICATION', - 'value' => $this->getNewValue('force_email_verification'), + 'value' => $this->getNewValue('force_email_verification', 'user'), 'type' => 'boolean', 'description' => 'If the user must verify their email to use the panel.', ], [ 'key' => 'SETTINGS::USER:INITIAL_CREDITS', - 'value' => $this->getNewValue('initial_credits'), + 'value' => $this->getNewValue('initial_credits', 'user'), 'type' => 'integer', 'description' => 'The amount of credits that the user will receive when they register.', ], [ 'key' => 'SETTINGS::USER:INITIAL_SERVER_LIMIT', - 'value' => $this->getNewValue('initial_server_limit'), + 'value' => $this->getNewValue('initial_server_limit', 'user'), 'type' => 'integer', 'description' => 'The amount of servers that the user will be able to create when they register.', ], [ 'key' => 'SETTINGS::USER:MINIMUM_REQUIRED_CREDITS_TO_MAKE_SERVER', - 'value' => $this->getNewValue('min_credits_to_make_server'), + 'value' => $this->getNewValue('min_credits_to_make_server', 'user'), 'type' => 'integer', 'description' => 'The minimum amount of credits that the user must have to create a server.', ], [ 'key' => 'SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE', - 'value' => $this->getNewValue('server_limit_after_irl_purchase'), + 'value' => $this->getNewValue('server_limit_after_irl_purchase', 'user'), 'type' => 'integer', 'description' => 'The amount of servers that the user will be able to create after making a real purchase.', ], [ 'key' => 'SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_DISCORD', - 'value' => $this->getNewValue('server_limit_after_verify_discord'), + 'value' => $this->getNewValue('server_limit_after_verify_discord', 'user'), 'type' => 'integer', 'description' => 'The amount of servers that the user will be able to create after verifying their Discord account.', ], [ 'key' => 'SETTINGS::USER:SERVER_LIMIT_REWARD_AFTER_VERIFY_EMAIL', - 'value' => $this->getNewValue('server_limit_after_verify_email'), + 'value' => $this->getNewValue('server_limit_after_verify_email', 'user'), 'type' => 'integer', 'description' => 'The amount of servers that the user will be able to create after verifying their email.', ], [ 'key' => 'SETTINGS::SYSTEM:REGISTER_IP_CHECK', - 'value' => $this->getNewValue('register_ip_check'), + 'value' => $this->getNewValue('register_ip_check', 'user'), 'type' => 'boolean', 'description' => 'If the user must verify their IP address to register.', ], [ 'key' => 'SETTINGS::SYSTEM:CREATION_OF_NEW_USERS', - 'value' => $this->getNewValue('creation_enabled'), + 'value' => $this->getNewValue('creation_enabled', 'user'), 'type' => 'boolean', 'description' => 'If the user can register.', ], ]); - $this->migrator->delete('user.credits_reward_after_verify_discord'); - $this->migrator->delete('user.credits_reward_after_verify_email'); - $this->migrator->delete('user.force_discord_verification'); - $this->migrator->delete('user.force_email_verification'); - $this->migrator->delete('user.initial_credits'); - $this->migrator->delete('user.initial_server_limit'); - $this->migrator->delete('user.min_credits_to_make_server'); - $this->migrator->delete('user.server_limit_after_irl_purchase'); - $this->migrator->delete('user.server_limit_after_verify_discord'); - $this->migrator->delete('user.server_limit_after_verify_email'); - $this->migrator->delete('user.register_ip_check'); - $this->migrator->delete('user.creation_enabled'); - } - - public function getNewValue(string $name) - { - $new_value = DB::table('settings')->where([['group', '=', 'user'], ['name', '=', $name]])->get(['payload'])->first(); - - // Some keys returns '""' as a value. - if ($new_value->payload === '""') { - return null; + try { + $this->migrator->delete('user.credits_reward_after_verify_discord'); + $this->migrator->delete('user.credits_reward_after_verify_email'); + $this->migrator->delete('user.force_discord_verification'); + $this->migrator->delete('user.force_email_verification'); + $this->migrator->delete('user.initial_credits'); + $this->migrator->delete('user.initial_server_limit'); + $this->migrator->delete('user.min_credits_to_make_server'); + $this->migrator->delete('user.server_limit_after_irl_purchase'); + $this->migrator->delete('user.server_limit_after_verify_discord'); + $this->migrator->delete('user.server_limit_after_verify_email'); + $this->migrator->delete('user.register_ip_check'); + $this->migrator->delete('user.creation_enabled'); + } catch (Exception $e) { + // Do nothing } - - // remove the quotes from the string - if (substr($new_value->payload, 0, 1) === '"' && substr($new_value->payload, -1) === '"') { - return substr($new_value->payload, 1, -1); - } - - return $new_value->payload; - } - - public function getOldValue(string $key) - { - // Always get the first value of the key. - $old_value = DB::table('settings_old')->where('key', '=', $key)->get(['value', 'type'])->first(); - - // Handle the old values to return without it being a string in all cases. - if ($old_value->type === "string" || $old_value->type === "text") { - if (is_null($old_value->value)) { - return ''; - } - - // Some values have the type string, but their values are boolean. - if ($old_value->value === "false" || $old_value->value === "true") { - return filter_var($old_value->value, FILTER_VALIDATE_BOOL); - } - - return $old_value->value; - } - - if ($old_value->type === "boolean") { - return filter_var($old_value->value, FILTER_VALIDATE_BOOL); - } - - return filter_var($old_value->value, FILTER_VALIDATE_INT); } } diff --git a/database/settings/2023_02_01_181950_create_server_settings.php b/database/settings/2023_02_01_181950_create_server_settings.php index 7198adcb..bd63d8e7 100644 --- a/database/settings/2023_02_01_181950_create_server_settings.php +++ b/database/settings/2023_02_01_181950_create_server_settings.php @@ -1,18 +1,18 @@ exists(); // Get the user-set configuration values from the old table. - $this->migrator->add('server.allocation_limit', $table_exists ? $this->getOldValue('SETTINGS::SERVER:ALLOCATION_LIMIT') : 200); - $this->migrator->add('server.creation_enabled', $table_exists ? $this->getOldValue('SETTINGS::SYSTEM:CREATION_OF_NEW_SERVERS') : true); - $this->migrator->add('server.enable_upgrade', $table_exists ? $this->getOldValue('SETTINGS::SYSTEM:ENABLE_UPGRADE') : false); + $this->migrator->add('server.allocation_limit', $table_exists ? $this->getOldValue('SETTINGS::SERVER:ALLOCATION_LIMIT', 200) : 200); + $this->migrator->add('server.creation_enabled', $table_exists ? $this->getOldValue('SETTINGS::SYSTEM:CREATION_OF_NEW_SERVERS', true) : true); + $this->migrator->add('server.enable_upgrade', $table_exists ? $this->getOldValue('SETTINGS::SYSTEM:ENABLE_UPGRADE', false) : false); } public function down(): void @@ -20,69 +20,30 @@ class CreateServerSettings extends SettingsMigration DB::table('settings_old')->insert([ [ 'key' => 'SETTINGS::SERVER:ALLOCATION_LIMIT', - 'value' => $this->getNewValue('allocation_limit'), + 'value' => $this->getNewValue('allocation_limit', 'server'), 'type' => 'integer', 'description' => 'The number of servers to show per page.', ], [ 'key' => 'SETTINGS::SYSTEM:CREATION_OF_NEW_SERVERS', - 'value' => $this->getNewValue('creation_enabled'), + 'value' => $this->getNewValue('creation_enabled', 'server'), 'type' => 'boolean', 'description' => 'Whether or not users can create new servers.', ], [ 'key' => 'SETTINGS::SYSTEM:ENABLE_UPGRADE', - 'value' => $this->getNewValue('enable_upgrade'), + 'value' => $this->getNewValue('enable_upgrade', 'server'), 'type' => 'boolean', 'description' => 'Whether or not users can upgrade their servers.', ], ]); - $this->migrator->delete('server.allocation_limit'); - $this->migrator->delete('server.creation_enabled'); - $this->migrator->delete('server.enable_upgrade'); - } - - public function getNewValue(string $name) - { - $new_value = DB::table('settings')->where([['group', '=', 'server'], ['name', '=', $name]])->get(['payload'])->first(); - - // Some keys returns '""' as a value. - if ($new_value->payload === '""') { - return null; + try { + $this->migrator->delete('server.allocation_limit'); + $this->migrator->delete('server.creation_enabled'); + $this->migrator->delete('server.enable_upgrade'); + } catch (Exception $e) { + // Do nothing } - - // remove the quotes from the string - if (substr($new_value->payload, 0, 1) === '"' && substr($new_value->payload, -1) === '"') { - return substr($new_value->payload, 1, -1); - } - - return $new_value->payload; - } - - public function getOldValue(string $key) - { - // Always get the first value of the key. - $old_value = DB::table('settings_old')->where('key', '=', $key)->get(['value', 'type'])->first(); - - // Handle the old values to return without it being a string in all cases. - if ($old_value->type === "string" || $old_value->type === "text") { - if (is_null($old_value->value)) { - return ''; - } - - // Some values have the type string, but their values are boolean. - if ($old_value->value === "false" || $old_value->value === "true") { - return filter_var($old_value->value, FILTER_VALIDATE_BOOL); - } - - return $old_value->value; - } - - if ($old_value->type === "boolean") { - return filter_var($old_value->value, FILTER_VALIDATE_BOOL); - } - - return filter_var($old_value->value, FILTER_VALIDATE_INT); } } diff --git a/database/settings/2023_02_01_182021_create_invoice_settings.php b/database/settings/2023_02_01_182021_create_invoice_settings.php index 8569c3ff..d3ac8f63 100644 --- a/database/settings/2023_02_01_182021_create_invoice_settings.php +++ b/database/settings/2023_02_01_182021_create_invoice_settings.php @@ -1,23 +1,23 @@ exists(); // Get the user-set configuration values from the old table. - $this->migrator->add('invoice.company_address', $table_exists ? $this->getOldValue('SETTINGS::INVOICE:COMPANY_ADDRESS') : ''); - $this->migrator->add('invoice.company_mail', $table_exists ? $this->getOldValue('SETTINGS::INVOICE:COMPANY_MAIL') : ''); - $this->migrator->add('invoice.company_name', $table_exists ? $this->getOldValue('SETTINGS::INVOICE:COMPANY_NAME') : ''); - $this->migrator->add('invoice.company_phone', $table_exists ? $this->getOldValue('SETTINGS::INVOICE:COMPANY_PHONE') : ''); - $this->migrator->add('invoice.company_vat', $table_exists ? $this->getOldValue('SETTINGS::INVOICE:COMPANY_VAT') : ''); - $this->migrator->add('invoice.company_website', $table_exists ? $this->getOldValue('SETTINGS::INVOICE:COMPANY_WEBSITE') : ''); - $this->migrator->add('invoice.enabled', $table_exists ? $this->getOldValue('SETTINGS::INVOICE:ENABLED') : false); - $this->migrator->add('invoice.prefix', $table_exists ? $this->getOldValue('SETTINGS::INVOICE:PREFIX') : 'INV'); + $this->migrator->add('invoice.company_address', $table_exists ? $this->getOldValue('SETTINGS::INVOICE:COMPANY_ADDRESS') : null); + $this->migrator->add('invoice.company_mail', $table_exists ? $this->getOldValue('SETTINGS::INVOICE:COMPANY_MAIL') : null); + $this->migrator->add('invoice.company_name', $table_exists ? $this->getOldValue('SETTINGS::INVOICE:COMPANY_NAME') : null); + $this->migrator->add('invoice.company_phone', $table_exists ? $this->getOldValue('SETTINGS::INVOICE:COMPANY_PHONE') : null); + $this->migrator->add('invoice.company_vat', $table_exists ? $this->getOldValue('SETTINGS::INVOICE:COMPANY_VAT') : null); + $this->migrator->add('invoice.company_website', $table_exists ? $this->getOldValue('SETTINGS::INVOICE:COMPANY_WEBSITE') : null); + $this->migrator->add('invoice.enabled', $table_exists ? $this->getOldValue('SETTINGS::INVOICE:ENABLED', false) : false); + $this->migrator->add('invoice.prefix', $table_exists ? $this->getOldValue('SETTINGS::INVOICE:PREFIX') : null); } public function down(): void @@ -25,104 +25,65 @@ class CreateInvoiceSettings extends SettingsMigration DB::table('settings_old')->insert([ [ 'key' => 'SETTINGS::INVOICE:COMPANY_ADDRESS', - 'value' => $this->getNewValue('company_address'), + 'value' => $this->getNewValue('company_address', 'invoice'), 'type' => 'string', 'description' => 'The address of the company.', ], [ 'key' => 'SETTINGS::INVOICE:COMPANY_MAIL', - 'value' => $this->getNewValue('company_mail'), + 'value' => $this->getNewValue('company_mail', 'invoice'), 'type' => 'string', 'description' => 'The email address of the company.', ], [ 'key' => 'SETTINGS::INVOICE:COMPANY_NAME', - 'value' => $this->getNewValue('company_name'), + 'value' => $this->getNewValue('company_name', 'invoice'), 'type' => 'string', 'description' => 'The name of the company.', ], [ 'key' => 'SETTINGS::INVOICE:COMPANY_PHONE', - 'value' => $this->getNewValue('company_phone'), + 'value' => $this->getNewValue('company_phone', 'invoice'), 'type' => 'string', 'description' => 'The phone number of the company.', ], [ 'key' => 'SETTINGS::INVOICE:COMPANY_VAT', - 'value' => $this->getNewValue('company_vat'), + 'value' => $this->getNewValue('company_vat', 'invoice'), 'type' => 'string', 'description' => 'The VAT number of the company.', ], [ 'key' => 'SETTINGS::INVOICE:COMPANY_WEBSITE', - 'value' => $this->getNewValue('company_website'), + 'value' => $this->getNewValue('company_website', 'invoice'), 'type' => 'string', 'description' => 'The website of the company.', ], [ 'key' => 'SETTINGS::INVOICE:ENABLED', - 'value' => $this->getNewValue('enabled'), + 'value' => $this->getNewValue('enabled', 'invoice'), 'type' => 'boolean', 'description' => 'Enable or disable the invoice system.', ], [ 'key' => 'SETTINGS::INVOICE:PREFIX', - 'value' => $this->getNewValue('prefix'), + 'value' => $this->getNewValue('prefix', 'invoice'), 'type' => 'string', 'description' => 'The prefix of the invoice.', ], ]); - $this->migrator->delete('invoice.company_address'); - $this->migrator->delete('invoice.company_mail'); - $this->migrator->delete('invoice.company_name'); - $this->migrator->delete('invoice.company_phone'); - $this->migrator->delete('invoice.company_vat'); - $this->migrator->delete('invoice.company_website'); - $this->migrator->delete('invoice.enabled'); - $this->migrator->delete('invoice.prefix'); - } - - public function getNewValue(string $name) - { - $new_value = DB::table('settings')->where([['group', '=', 'invoice'], ['name', '=', $name]])->get(['payload'])->first(); - - // Some keys returns '""' as a value. - if ($new_value->payload === '""') { - return null; + try { + $this->migrator->delete('invoice.company_address'); + $this->migrator->delete('invoice.company_mail'); + $this->migrator->delete('invoice.company_name'); + $this->migrator->delete('invoice.company_phone'); + $this->migrator->delete('invoice.company_vat'); + $this->migrator->delete('invoice.company_website'); + $this->migrator->delete('invoice.enabled'); + $this->migrator->delete('invoice.prefix'); + } catch (Exception $e) { + // Do nothing } - - // remove the quotes from the string - if (substr($new_value->payload, 0, 1) === '"' && substr($new_value->payload, -1) === '"') { - return substr($new_value->payload, 1, -1); - } - - return $new_value->payload; - } - - public function getOldValue(string $key) - { - // Always get the first value of the key. - $old_value = DB::table('settings_old')->where('key', '=', $key)->get(['value', 'type'])->first(); - - // Handle the old values to return without it being a string in all cases. - if ($old_value->type === "string" || $old_value->type === "text") { - if (is_null($old_value->value)) { - return ''; - } - - // Some values have the type string, but their values are boolean. - if ($old_value->value === "false" || $old_value->value === "true") { - return filter_var($old_value->value, FILTER_VALIDATE_BOOL); - } - - return $old_value->value; - } - - if ($old_value->type === "boolean") { - return filter_var($old_value->value, FILTER_VALIDATE_BOOL); - } - - return filter_var($old_value->value, FILTER_VALIDATE_INT); } } diff --git a/database/settings/2023_02_01_182043_create_discord_settings.php b/database/settings/2023_02_01_182043_create_discord_settings.php index 60e450b9..c8216c49 100644 --- a/database/settings/2023_02_01_182043_create_discord_settings.php +++ b/database/settings/2023_02_01_182043_create_discord_settings.php @@ -1,21 +1,21 @@ exists(); // Get the user-set configuration values from the old table. - $this->migrator->add('discord.bot_token', $table_exists ? $this->getOldValue('SETTINGS::DISCORD:BOT_TOKEN') : ''); - $this->migrator->add('discord.client_id', $table_exists ? $this->getOldValue('SETTINGS::DISCORD:CLIENT_ID') : ''); - $this->migrator->add('discord.client_secret', $table_exists ? $this->getOldValue('SETTINGS::DISCORD:CLIENT_SECRET') : ''); - $this->migrator->add('discord.guild_id', $table_exists ? $this->getOldValue('SETTINGS::DISCORD:GUILD_ID') : ''); - $this->migrator->add('discord.invite_url', $table_exists ? $this->getOldValue('SETTINGS::DISCORD:INVITE_URL') : ''); - $this->migrator->add('discord.role_id', $table_exists ? $this->getOldValue('SETTINGS::DISCORD:ROLE_ID') : ''); + $this->migrator->add('discord.bot_token', $table_exists ? $this->getOldValue('SETTINGS::DISCORD:BOT_TOKEN') : null); + $this->migrator->add('discord.client_id', $table_exists ? $this->getOldValue('SETTINGS::DISCORD:CLIENT_ID') : null); + $this->migrator->add('discord.client_secret', $table_exists ? $this->getOldValue('SETTINGS::DISCORD:CLIENT_SECRET') : null); + $this->migrator->add('discord.guild_id', $table_exists ? $this->getOldValue('SETTINGS::DISCORD:GUILD_ID') : null); + $this->migrator->add('discord.invite_url', $table_exists ? $this->getOldValue('SETTINGS::DISCORD:INVITE_URL') : null); + $this->migrator->add('discord.role_id', $table_exists ? $this->getOldValue('SETTINGS::DISCORD:ROLE_ID') : null); } public function down(): void @@ -23,91 +23,52 @@ class CreateDiscordSettings extends SettingsMigration DB::table('settings_old')->insert([ [ 'key' => 'SETTINGS::DISCORD:BOT_TOKEN', - 'value' => $this->getNewValue('bot_token'), + 'value' => $this->getNewValue('bot_token', 'discord'), 'type' => 'string', 'description' => 'The bot token for the Discord bot.', ], [ 'key' => 'SETTINGS::DISCORD:CLIENT_ID', - 'value' => $this->getNewValue('client_id'), + 'value' => $this->getNewValue('client_id', 'discord'), 'type' => 'string', 'description' => 'The client ID for the Discord bot.', ], [ 'key' => 'SETTINGS::DISCORD:CLIENT_SECRET', - 'value' => $this->getNewValue('client_secret'), + 'value' => $this->getNewValue('client_secret', 'discord'), 'type' => 'string', 'description' => 'The client secret for the Discord bot.', ], [ 'key' => 'SETTINGS::DISCORD:GUILD_ID', - 'value' => $this->getNewValue('guild_id'), + 'value' => $this->getNewValue('guild_id', 'discord'), 'type' => 'string', 'description' => 'The guild ID for the Discord bot.', ], [ 'key' => 'SETTINGS::DISCORD:INVITE_URL', - 'value' => $this->getNewValue('invite_url'), + 'value' => $this->getNewValue('invite_url', 'discord'), 'type' => 'string', 'description' => 'The invite URL for the Discord bot.', ], [ 'key' => 'SETTINGS::DISCORD:ROLE_ID', - 'value' => $this->getNewValue('role_id'), + 'value' => $this->getNewValue('role_id', 'discord'), 'type' => 'string', 'description' => 'The role ID for the Discord bot.', ] ]); - $this->migrator->delete('discord.bot_token'); - $this->migrator->delete('discord.client_id'); - $this->migrator->delete('discord.client_secret'); - $this->migrator->delete('discord.guild_id'); - $this->migrator->delete('discord.invite_url'); - $this->migrator->delete('discord.role_id'); - } - - public function getNewValue(string $name) - { - $new_value = DB::table('settings')->where([['group', '=', 'discord'], ['name', '=', $name]])->get(['payload'])->first(); - - // Some keys returns '""' as a value. - if ($new_value->payload === '""') { - return null; + try { + $this->migrator->delete('discord.bot_token'); + $this->migrator->delete('discord.client_id'); + $this->migrator->delete('discord.client_secret'); + $this->migrator->delete('discord.guild_id'); + $this->migrator->delete('discord.invite_url'); + $this->migrator->delete('discord.role_id'); + } catch (Exception $e) { + // Do nothing. } - - // remove the quotes from the string - if (substr($new_value->payload, 0, 1) === '"' && substr($new_value->payload, -1) === '"') { - return substr($new_value->payload, 1, -1); - } - - return $new_value->payload; - } - - public function getOldValue(string $key) - { - // Always get the first value of the key. - $old_value = DB::table('settings_old')->where('key', '=', $key)->get(['value', 'type'])->first(); - - // Handle the old values to return without it being a string in all cases. - if ($old_value->type === "string" || $old_value->type === "text") { - if (is_null($old_value->value)) { - return ''; - } - - // Some values have the type string, but their values are boolean. - if ($old_value->value === "false" || $old_value->value === "true") { - return filter_var($old_value->value, FILTER_VALIDATE_BOOL); - } - - return $old_value->value; - } - - if ($old_value->type === "boolean") { - return filter_var($old_value->value, FILTER_VALIDATE_BOOL); - } - - return filter_var($old_value->value, FILTER_VALIDATE_INT); } } diff --git a/database/settings/2023_02_01_182108_create_locale_settings.php b/database/settings/2023_02_01_182108_create_locale_settings.php index 014dd8fd..86f3d6e4 100644 --- a/database/settings/2023_02_01_182108_create_locale_settings.php +++ b/database/settings/2023_02_01_182108_create_locale_settings.php @@ -1,9 +1,9 @@ migrator->add('locale.available', $table_exists ? $this->getOldValue('SETTINGS::LOCALE:AVAILABLE') : ''); - $this->migrator->add('locale.clients_can_change', $table_exists ? $this->getOldValue('SETTINGS::LOCALE:CLIENTS_CAN_CHANGE') : true); + $this->migrator->add('locale.clients_can_change', $table_exists ? $this->getOldValue('SETTINGS::LOCALE:CLIENTS_CAN_CHANGE', true) : true); $this->migrator->add('locale.datatables', $table_exists ? $this->getOldValue('SETTINGS::LOCALE:DATATABLES') : 'en-gb'); - $this->migrator->add('locale.default', $table_exists ? $this->getOldValue('SETTINGS::LOCALE:DEFAULT') : 'en'); - $this->migrator->add('locale.dynamic', $table_exists ? $this->getOldValue('SETTINGS::LOCALE:DYNAMIC') : false); + $this->migrator->add('locale.default', $table_exists ? $this->getOldValue('SETTINGS::LOCALE:DEFAULT', 'en') : 'en'); + $this->migrator->add('locale.dynamic', $table_exists ? $this->getOldValue('SETTINGS::LOCALE:DYNAMIC', false) : false); } public function down(): void @@ -22,83 +22,44 @@ class CreateLocaleSettings extends SettingsMigration DB::table('settings_old')->insert([ [ 'key' => 'SETTINGS::LOCALE:AVAILABLE', - 'value' => $this->getNewValue('available'), + 'value' => $this->getNewValue('available', 'locale'), 'type' => 'string', 'description' => 'The available locales.', ], [ 'key' => 'SETTINGS::LOCALE:CLIENTS_CAN_CHANGE', - 'value' => $this->getNewValue('clients_can_change'), + 'value' => $this->getNewValue('clients_can_change', 'locale'), 'type' => 'boolean', 'description' => 'If clients can change their locale.', ], [ 'key' => 'SETTINGS::LOCALE:DATATABLES', - 'value' => $this->getNewValue('datatables'), + 'value' => $this->getNewValue('datatables', 'locale'), 'type' => 'string', 'description' => 'The locale for datatables.', ], [ 'key' => 'SETTINGS::LOCALE:DEFAULT', - 'value' => $this->getNewValue('default'), + 'value' => $this->getNewValue('default', 'locale'), 'type' => 'string', 'description' => 'The default locale.', ], [ 'key' => 'SETTINGS::LOCALE:DYNAMIC', - 'value' => $this->getNewValue('dynamic'), + 'value' => $this->getNewValue('dynamic', 'locale'), 'type' => 'boolean', 'description' => 'If the locale should be dynamic.', ], ]); - $this->migrator->delete('locale.available'); - $this->migrator->delete('locale.clients_can_change'); - $this->migrator->delete('locale.datatables'); - $this->migrator->delete('locale.default'); - $this->migrator->delete('locale.dynamic'); - } - - public function getNewValue(string $name) - { - $new_value = DB::table('settings')->where([['group', '=', 'locale'], ['name', '=', $name]])->get(['payload'])->first(); - - // Some keys returns '""' as a value. - if ($new_value->payload === '""') { - return null; + try { + $this->migrator->delete('locale.available'); + $this->migrator->delete('locale.clients_can_change'); + $this->migrator->delete('locale.datatables'); + $this->migrator->delete('locale.default'); + $this->migrator->delete('locale.dynamic'); + } catch (Exception $e) { + // Do nothing } - - // remove the quotes from the string - if (substr($new_value->payload, 0, 1) === '"' && substr($new_value->payload, -1) === '"') { - return substr($new_value->payload, 1, -1); - } - - return $new_value->payload; - } - - public function getOldValue(string $key) - { - // Always get the first value of the key. - $old_value = DB::table('settings_old')->where('key', '=', $key)->get(['value', 'type'])->first(); - - // Handle the old values to return without it being a string in all cases. - if ($old_value->type === "string" || $old_value->type === "text") { - if (is_null($old_value->value)) { - return ''; - } - - // Some values have the type string, but their values are boolean. - if ($old_value->value === "false" || $old_value->value === "true") { - return filter_var($old_value->value, FILTER_VALIDATE_BOOL); - } - - return $old_value->value; - } - - if ($old_value->type === "boolean") { - return filter_var($old_value->value, FILTER_VALIDATE_BOOL); - } - - return filter_var($old_value->value, FILTER_VALIDATE_INT); } } diff --git a/database/settings/2023_02_01_182135_create_referral_settings.php b/database/settings/2023_02_01_182135_create_referral_settings.php index 5727557b..ed7ff3fd 100644 --- a/database/settings/2023_02_01_182135_create_referral_settings.php +++ b/database/settings/2023_02_01_182135_create_referral_settings.php @@ -1,20 +1,20 @@ exists(); // Get the user-set configuration values from the old table. - $this->migrator->add('referral.always_give_commission', $table_exists ? $this->getOldValue('SETTINGS::REFERRAL::ALWAYS_GIVE_COMMISSION') : false); - $this->migrator->add('referral.enabled', $table_exists ? $this->getOldValue('SETTINGS::REFERRAL::ENABLED') : false); + $this->migrator->add('referral.always_give_commission', $table_exists ? $this->getOldValue('SETTINGS::REFERRAL::ALWAYS_GIVE_COMMISSION', false) : false); + $this->migrator->add('referral.enabled', $table_exists ? $this->getOldValue('SETTINGS::REFERRAL::ENABLED', false) : false); $this->migrator->add('referral.reward', $table_exists ? $this->getOldValue('SETTINGS::REFERRAL::REWARD') : 100); - $this->migrator->add('referral.mode', $table_exists ? $this->getOldValue('SETTINGS::REFERRAL:MODE') : 'sign-up'); - $this->migrator->add('referral.percentage', $table_exists ? $this->getOldValue('SETTINGS::REFERRAL:PERCENTAGE') : 100); + $this->migrator->add('referral.mode', $table_exists ? $this->getOldValue('SETTINGS::REFERRAL:MODE', 'sign-up') : 'sign-up'); + $this->migrator->add('referral.percentage', $table_exists ? $this->getOldValue('SETTINGS::REFERRAL:PERCENTAGE', 100) : 100); } public function down(): void @@ -22,90 +22,51 @@ class CreateReferralSettings extends SettingsMigration DB::table('settings_old')->insert([ [ 'key' => 'SETTINGS::REFERRAL::ALLOWED', - 'value' => $this->getNewValue('allowed'), + 'value' => $this->getNewValue('allowed', 'referral'), 'type' => 'string', 'description' => 'The allowed referral types.', ], [ 'key' => 'SETTINGS::REFERRAL::ALWAYS_GIVE_COMMISSION', - 'value' => $this->getNewValue('always_give_commission'), + 'value' => $this->getNewValue('always_give_commission', 'referral'), 'type' => 'boolean', 'description' => 'Whether to always give commission to the referrer.', ], [ 'key' => 'SETTINGS::REFERRAL::ENABLED', - 'value' => $this->getNewValue('enabled'), + 'value' => $this->getNewValue('enabled', 'referral'), 'type' => 'boolean', 'description' => 'Whether to enable the referral system.', ], [ 'key' => 'SETTINGS::REFERRAL::REWARD', - 'value' => $this->getNewValue('reward'), + 'value' => $this->getNewValue('reward', 'referral'), 'type' => 'integer', 'description' => 'The reward for the referral.', ], [ 'key' => 'SETTINGS::REFERRAL:MODE', - 'value' => $this->getNewValue('mode'), + 'value' => $this->getNewValue('mode', 'referral'), 'type' => 'string', 'description' => 'The referral mode.', ], [ 'key' => 'SETTINGS::REFERRAL:PERCENTAGE', - 'value' => $this->getNewValue('percentage'), + 'value' => $this->getNewValue('percentage', 'referral'), 'type' => 'integer', 'description' => 'The referral percentage.', ], ]); - $this->migrator->delete('referral.allowed'); - $this->migrator->delete('referral.always_give_commission'); - $this->migrator->delete('referral.enabled'); - $this->migrator->delete('referral.reward'); - $this->migrator->delete('referral.mode'); - $this->migrator->delete('referral.percentage'); - } - - public function getNewValue(string $name) - { - $new_value = DB::table('settings')->where([['group', '=', 'referral'], ['name', '=', $name]])->get(['payload'])->first(); - - // Some keys returns '""' as a value. - if ($new_value->payload === '""') { - return null; + try { + $this->migrator->delete('referral.allowed'); + $this->migrator->delete('referral.always_give_commission'); + $this->migrator->delete('referral.enabled'); + $this->migrator->delete('referral.reward'); + $this->migrator->delete('referral.mode'); + $this->migrator->delete('referral.percentage'); + } catch (Exception $e) { + // } - - // remove the quotes from the string - if (substr($new_value->payload, 0, 1) === '"' && substr($new_value->payload, -1) === '"') { - return substr($new_value->payload, 1, -1); - } - - return $new_value->payload; - } - - public function getOldValue(string $key) - { - // Always get the first value of the key. - $old_value = DB::table('settings_old')->where('key', '=', $key)->get(['value', 'type'])->first(); - - // Handle the old values to return without it being a string in all cases. - if ($old_value->type === "string" || $old_value->type === "text") { - if (is_null($old_value->value)) { - return ''; - } - - // Some values have the type string, but their values are boolean. - if ($old_value->value === "false" || $old_value->value === "true") { - return filter_var($old_value->value, FILTER_VALIDATE_BOOL); - } - - return $old_value->value; - } - - if ($old_value->type === "boolean") { - return filter_var($old_value->value, FILTER_VALIDATE_BOOL); - } - - return filter_var($old_value->value, FILTER_VALIDATE_INT); } } diff --git a/database/settings/2023_02_01_182158_create_website_settings.php b/database/settings/2023_02_01_182158_create_website_settings.php index fd542ff3..eb8f3295 100644 --- a/database/settings/2023_02_01_182158_create_website_settings.php +++ b/database/settings/2023_02_01_182158_create_website_settings.php @@ -1,27 +1,28 @@ exists(); // Get the user-set configuration values from the old table. - $this->migrator->add('website.motd_enabled', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:MOTD_ENABLED") : true); + $this->migrator->add('website.motd_enabled', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:MOTD_ENABLED", true) : true); $this->migrator->add( 'website.motd_message', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:MOTD_MESSAGE") : "

 width=CtrlPanel.gg

Thank you for using our Software

If you have any questions, make sure to join our Discord

-

(you can change this message in the Settings )

"); - $this->migrator->add('website.show_imprint', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:SHOW_IMPRINT") : false); - $this->migrator->add('website.show_privacy', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:SHOW_PRIVACY") : false); - $this->migrator->add('website.show_tos', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:SHOW_TOS") : false); - $this->migrator->add('website.useful_links_enabled', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:USEFULLINKS_ENABLED") : true); +

(you can change this message in the Settings )

" + ); + $this->migrator->add('website.show_imprint', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:SHOW_IMPRINT", false) : false); + $this->migrator->add('website.show_privacy', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:SHOW_PRIVACY", false) : false); + $this->migrator->add('website.show_tos', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:SHOW_TOS", false) : false); + $this->migrator->add('website.useful_links_enabled', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:USEFULLINKS_ENABLED", true) : true); $this->migrator->add('website.seo_title', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:SEO_TITLE") : 'CtrlPanel.gg'); $this->migrator->add('website.seo_description', $table_exists ? $this->getOldValue("SETTINGS::SYSTEM:SEO_DESCRIPTION") : 'Billing software for Pterodactyl Panel.'); $this->migrator->add('website.enable_login_logo', true); @@ -32,111 +33,72 @@ class CreateWebsiteSettings extends SettingsMigration DB::table('settings_old')->insert([ [ 'key' => 'SETTINGS::SYSTEM:MOTD_ENABLED', - 'value' => $this->getNewValue('motd_enabled'), + 'value' => $this->getNewValue('motd_enabled', 'website'), 'type' => 'boolean', 'description' => 'Enable or disable the MOTD.', ], [ 'key' => 'SETTINGS::SYSTEM:MOTD_MESSAGE', - 'value' => $this->getNewValue('motd_message'), + 'value' => $this->getNewValue('motd_message', 'website'), 'type' => 'text', 'description' => 'The message that will be displayed in the MOTD.', ], [ 'key' => 'SETTINGS::SYSTEM:SHOW_IMPRINT', - 'value' => $this->getNewValue('show_imprint'), + 'value' => $this->getNewValue('show_imprint', 'website'), 'type' => 'boolean', 'description' => 'Enable or disable the imprint.', ], [ 'key' => 'SETTINGS::SYSTEM:SHOW_PRIVACY', - 'value' => $this->getNewValue('show_privacy'), + 'value' => $this->getNewValue('show_privacy', 'website'), 'type' => 'boolean', 'description' => 'Enable or disable the privacy policy.', ], [ 'key' => 'SETTINGS::SYSTEM:SHOW_TOS', - 'value' => $this->getNewValue('show_tos'), + 'value' => $this->getNewValue('show_tos', 'website'), 'type' => 'boolean', 'description' => 'Enable or disable the terms of service.', ], [ 'key' => 'SETTINGS::SYSTEM:USEFULLINKS_ENABLED', - 'value' => $this->getNewValue('useful_links_enabled'), + 'value' => $this->getNewValue('useful_links_enabled', 'website'), 'type' => 'boolean', 'description' => 'Enable or disable the useful links.', ], [ 'key' => 'SETTINGS::SYSTEM:SEO_TITLE', - 'value' => $this->getNewValue('seo_title'), + 'value' => $this->getNewValue('seo_title', 'website'), 'type' => 'string', 'description' => 'The title of the website.', ], [ 'key' => 'SETTINGS::SYSTEM:SEO_DESCRIPTION', - 'value' => $this->getNewValue('seo_description'), + 'value' => $this->getNewValue('seo_description', 'website'), 'type' => 'string', 'description' => 'The description of the website.', ], [ 'key' => 'SETTINGS::SYSTEM:ENABLE_LOGIN_LOGO', - 'value' => $this->getNewValue('enable_login_logo'), + 'value' => $this->getNewValue('enable_login_logo', 'website'), 'type' => 'boolean', 'description' => 'Enable or disable the login logo.', ] ]); - $this->migrator->delete('website.motd_enabled'); - $this->migrator->delete('website.motd_message'); - $this->migrator->delete('website.show_imprint'); - $this->migrator->delete('website.show_privacy'); - $this->migrator->delete('website.show_tos'); - $this->migrator->delete('website.useful_links_enabled'); - $this->migrator->delete('website.seo_title'); - $this->migrator->delete('website.seo_description'); - $this->migrator->delete('website.enable_login_logo'); - } - - public function getNewValue(string $name) - { - $new_value = DB::table('settings')->where([['group', '=', 'website'], ['name', '=', $name]])->get(['payload'])->first(); - - // Some keys returns '""' as a value. - if ($new_value->payload === '""') { - return null; + try { + $this->migrator->delete('website.motd_enabled'); + $this->migrator->delete('website.motd_message'); + $this->migrator->delete('website.show_imprint'); + $this->migrator->delete('website.show_privacy'); + $this->migrator->delete('website.show_tos'); + $this->migrator->delete('website.useful_links_enabled'); + $this->migrator->delete('website.seo_title'); + $this->migrator->delete('website.seo_description'); + $this->migrator->delete('website.enable_login_logo'); + } catch (Exception $e) { + // Do nothing } - - // remove the quotes from the string - if (substr($new_value->payload, 0, 1) === '"' && substr($new_value->payload, -1) === '"') { - return substr($new_value->payload, 1, -1); - } - - return $new_value->payload; - } - - public function getOldValue(string $key) - { - // Always get the first value of the key. - $old_value = DB::table('settings_old')->where('key', '=', $key)->get(['value', 'type'])->first(); - - // Handle the old values to return without it being a string in all cases. - if ($old_value->type === "string" || $old_value->type === "text") { - if (is_null($old_value->value)) { - return ''; - } - - // Some values have the type string, but their values are boolean. - if ($old_value->value === "false" || $old_value->value === "true") { - return filter_var($old_value->value, FILTER_VALIDATE_BOOL); - } - - return $old_value->value; - } - - if ($old_value->type === "boolean") { - return filter_var($old_value->value, FILTER_VALIDATE_BOOL); - } - - return filter_var($old_value->value, FILTER_VALIDATE_INT); } } diff --git a/database/settings/2023_02_04_181156_create_ticket_settings.php b/database/settings/2023_02_04_181156_create_ticket_settings.php index 1e71ad3a..b4cfd8f2 100644 --- a/database/settings/2023_02_04_181156_create_ticket_settings.php +++ b/database/settings/2023_02_04_181156_create_ticket_settings.php @@ -1,9 +1,9 @@ insert([ [ 'key' => 'SETTINGS::TICKET:NOTIFY', - 'value' => $this->getNewValue('notify'), + 'value' => $this->getNewValue('notify', 'ticket'), 'type' => 'string', 'description' => 'The notification type for tickets.', ], [ 'key' => 'SETTINGS::TICKET:ENABLED', - 'value' => $this->getNewValue('enabled'), + 'value' => $this->getNewValue('enabled', 'ticket'), 'type' => 'boolean', 'description' => 'Enable or disable the ticket system.', ] ]); - $this->migrator->delete('ticket.enabled'); - $this->migrator->delete('ticket.notify'); - } - - public function getNewValue(string $name) - { - $new_value = DB::table('settings')->where([['group', '=', 'ticket'], ['name', '=', $name]])->get(['payload'])->first(); - - // Some keys returns '""' as a value. - if ($new_value->payload === '""') { - return null; + try { + $this->migrator->delete('ticket.enabled'); + $this->migrator->delete('ticket.notify'); + } catch (Exception $e) { + // Do nothing. } - - // remove the quotes from the string - if (substr($new_value->payload, 0, 1) === '"' && substr($new_value->payload, -1) === '"') { - return substr($new_value->payload, 1, -1); - } - - return $new_value->payload; - } - - public function getOldValue(string $key) - { - // Always get the first value of the key. - $old_value = DB::table('settings_old')->where('key', '=', $key)->get(['value', 'type'])->first(); - - // Handle the old values to return without it being a string in all cases. - - if (is_null($old_value)) { - return ''; - } - if ($old_value->type === "string" || $old_value->type === "text") { - if (is_null($old_value->value)) { - return ''; - } - - - // Some values have the type string, but their values are boolean. - if ($old_value->value === "false" || $old_value->value === "true") { - return filter_var($old_value->value, FILTER_VALIDATE_BOOL); - } - - return $old_value->value; - } - - if ($old_value->type === "boolean") { - return filter_var($old_value->value, FILTER_VALIDATE_BOOL); - } - - return filter_var($old_value->value, FILTER_VALIDATE_INT); } } diff --git a/database/settings/2023_05_07_195343_ticket_information.php b/database/settings/2023_05_07_195343_delete_notify_add_ticket_information.php similarity index 70% rename from database/settings/2023_05_07_195343_ticket_information.php rename to database/settings/2023_05_07_195343_delete_notify_add_ticket_information.php index 21d9aa67..68ec4555 100644 --- a/database/settings/2023_05_07_195343_ticket_information.php +++ b/database/settings/2023_05_07_195343_delete_notify_add_ticket_information.php @@ -9,4 +9,10 @@ return new class extends SettingsMigration $this->migrator->delete('ticket.notify'); $this->migrator->add('ticket.information', "Can't start your server? Need an additional port? Do you have any other questions? Let us know by opening a ticket."); } + + public function down(): void + { + $this->migrator->add('ticket.notify', 'all'); + $this->migrator->delete('ticket.information'); + } }; diff --git a/BUILDING.md b/docker/README.md similarity index 100% rename from BUILDING.md rename to docker/README.md diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 98eded4a..56c9e24d 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -12,7 +12,7 @@ services: ports: - 80:80 volumes: - - "../:/var/www/html:delegated" + - "../:/var/www/html" depends_on: - php - mysql @@ -42,7 +42,7 @@ services: dockerfile: docker/php/Dockerfile container_name: controlpanel_php volumes: - - "../:/var/www/html:delegated" + - "../:/var/www/html" networks: - laravel @@ -61,19 +61,5 @@ services: networks: - laravel - redis: - image: "redis:alpine" - command: redis-server --requirepass sOmE_sEcUrE_pAsS - ports: - - "6379:6379" - volumes: - - $PWD/redis-data:/var/lib/redis - - $PWD/redis.conf:/usr/local/etc/redis/redis.conf - environment: - - REDIS_REPLICATION_MODE=master - networks: - - laravel - - volumes: - mysql: + mysql: \ No newline at end of file diff --git a/docker/php/Dockerfile b/docker/php/Dockerfile index 65dfab87..4b8d91dd 100644 --- a/docker/php/Dockerfile +++ b/docker/php/Dockerfile @@ -1,16 +1,14 @@ -FROM php:8.0-fpm-alpine3.13 +FROM php:8.1-fpm-buster +RUN apt-get update \ + && apt-get install -y build-essential zlib1g-dev default-mysql-client curl gnupg procps vim git unzip libzip-dev libpq-dev libicu-dev libonig-dev libpng-dev libjpeg-dev libfreetype6-dev -RUN apk update && apk upgrade -RUN apk add --no-cache --repository https://alpine.global.ssl.fastly.net/alpine/edge/community/ - -RUN apk add --no-cache curl-dev icu-dev libzip-dev -RUN docker-php-ext-install mysqli pdo pdo_mysql intl zip +RUN docker-php-ext-install mysqli pdo pdo_mysql intl zip gd bcmath ADD ./docker/php/www.conf /usr/local/etc/php-fpm.d/ RUN mkdir -p /var/www/html -RUN addgroup -g 1000 laravel && adduser -G laravel -g laravel -s /bin/sh -D laravel +RUN addgroup --gid 1000 laravel && adduser --ingroup laravel --uid 1000 --shell /bin/sh --disabled-password --gecos "" laravel RUN chown laravel:laravel /var/www/html WORKDIR /var/www/html @@ -18,4 +16,3 @@ WORKDIR /var/www/html USER laravel COPY --from=composer:latest /usr/bin/composer /usr/bin/composer - diff --git a/public/install/forms.php b/public/install/forms.php index 98f05657..96f1dfa1 100644 --- a/public/install/forms.php +++ b/public/install/forms.php @@ -29,8 +29,7 @@ if (isset($_POST['checkDB'])) { try { $db = new mysqli($_POST['databasehost'], $_POST['databaseuser'], $_POST['databaseuserpass'], $_POST['database'], $_POST['databaseport']); - } - catch (mysqli_sql_exception $e) { + } catch (mysqli_sql_exception $e) { wh_log($e->getMessage(), 'error'); header('LOCATION: index.php?step=2&message=' . $e->getMessage()); exit(); @@ -69,26 +68,26 @@ if (isset($_POST['feedDB'])) { wh_log('Feeding the Database', 'debug'); $logs = ''; - //$logs .= run_console(setenv('COMPOSER_HOME', dirname(__FILE__, 3) . '/vendor/bin/composer')); - //$logs .= run_console('composer install --no-dev --optimize-autoloader'); - if (!str_contains(getenv('APP_KEY'), 'base64')) { - $logs .= run_console('php artisan key:generate --force'); - } else { - $logs .= "Key already exists. Skipping\n"; - } - $logs .= run_console('php artisan storage:link'); - $logs .= run_console('php artisan migrate --seed --force'); - $logs .= run_console('php artisan db:seed --class=ExampleItemsSeeder --force'); - $logs .= run_console('php artisan db:seed --class=PermissionsSeeder --force'); + try { + //$logs .= run_console(setenv('COMPOSER_HOME', dirname(__FILE__, 3) . '/vendor/bin/composer')); + //$logs .= run_console('composer install --no-dev --optimize-autoloader'); + if (!str_contains(getenv('APP_KEY'), 'base64')) { + $logs .= run_console('php artisan key:generate --force'); + } else { + $logs .= "Key already exists. Skipping\n"; + } + $logs .= run_console('php artisan storage:link'); + $logs .= run_console('php artisan migrate --seed --force'); + $logs .= run_console('php artisan db:seed --class=ExampleItemsSeeder --force'); + $logs .= run_console('php artisan db:seed --class=PermissionsSeeder --force'); - wh_log($logs, 'debug'); + wh_log($logs, 'debug'); - if (str_contains(getenv('APP_KEY'), 'base64')) { wh_log('Feeding the Database successful', 'debug'); header('LOCATION: index.php?step=3'); - } else { - wh_log('Feeding the Database failed', 'debug'); - header('LOCATION: index.php?step=2.5&message=There was an error. Please check the installer.log file in /var/www/controlpanel/storage/logs !'); + } catch (\Throwable $th) { + wh_log('Feeding the Database failed', 'error'); + header("LOCATION: index.php?step=2.5&message=" . $th->getMessage() . "
Please check the installer.log file in /var/www/controlpanel/storage/logs !"); } } diff --git a/public/install/functions.php b/public/install/functions.php index 8eb1318c..a5f2b045 100644 --- a/public/install/functions.php +++ b/public/install/functions.php @@ -10,7 +10,7 @@ use Monolog\Handler\StreamHandler; use Monolog\Logger; if (!file_exists('../../.env')) { - echo run_console('cp .env.example .env'); + echo run_console('cp .env.example .env'); } (new DotEnv(dirname(__FILE__, 3) . '/.env'))->load(); @@ -19,7 +19,7 @@ $required_extensions = ['openssl', 'gd', 'mysql', 'PDO', 'mbstring', 'tokenizer' $requirements = [ 'minPhp' => '8.1', - 'maxPhp' => '8.3', // This version is not supported + 'maxPhp' => '8.4', // This version is not supported 'mysql' => '5.7.22', ]; @@ -150,7 +150,8 @@ function checkExtensions(): array return $not_ok; } -function removeQuotes($string){ +function removeQuotes($string) +{ return str_replace('"', "", $string); } @@ -162,7 +163,7 @@ function removeQuotes($string){ */ function setenv($envKey, $envValue) { - $envFile = dirname(__FILE__, 3).'/.env'; + $envFile = dirname(__FILE__, 3) . '/.env'; $str = file_get_contents($envFile); $str .= "\n"; // In case the searched variable is in the last line without \n @@ -236,9 +237,16 @@ function run_console(string $command, array $descriptors = null, string $cwd = n $path = dirname(__FILE__, 3); $descriptors = $descriptors ?? [0 => ['pipe', 'r'], 1 => ['pipe', 'w'], 2 => ['pipe', 'w']]; $handle = proc_open("cd '$path' && bash -c 'exec -a ServerCPP $command'", $descriptors, $pipes, $cwd, null, $options); + $output = stream_get_contents($pipes[1]); + $exit_code = proc_close($handle); - wh_log('command result: ' . stream_get_contents($pipes[1]), 'debug'); - return stream_get_contents($pipes[1]); + if ($exit_code > 0) { + wh_log('command result: ' . $output, 'error'); + throw new Exception("There was an error after running command `$command`", $exit_code); + return $output; + } else { + return $output; + } } /** @@ -259,7 +267,7 @@ function wh_log(string $message, string $level = 'info', array $context = []): v switch (strtolower($level)) { case 'debug': // Only log debug messages if APP_DEBUG is true - if(getenv('APP_DEBUG') === false) return; + if (getenv('APP_DEBUG') === false) return; $log->debug($message, $context); break; case 'info': diff --git a/routes/web.php b/routes/web.php index a6a2ab3c..c575ea98 100644 --- a/routes/web.php +++ b/routes/web.php @@ -34,6 +34,7 @@ use App\Http\Controllers\TicketsController; use App\Http\Controllers\TranslationController; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; +use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Route; /* @@ -77,11 +78,13 @@ Route::middleware(['auth', 'checkSuspended'])->group(function () { Route::patch('/servers/cancel/{server}', [ServerController::class, 'cancel'])->name('servers.cancel'); Route::resource('servers', ServerController::class); - if (config('app.key')) { + try { $serverSettings = app(App\Settings\ServerSettings::class); - if ($serverSettings->enable_upgrade) { + if ($serverSettings->creation_enabled) { Route::post('servers/{server}/upgrade', [ServerController::class, 'upgrade'])->name('servers.upgrade'); } + } catch (Exception $e) { + Log::error("ServerSettings not found, skipping server upgrade route"); } Route::post('profile/selfdestruct', [ProfileController::class, 'selfDestroyUser'])->name('profile.selfDestroyUser'); diff --git a/storage/app/public/logo.png b/storage/app/public/logo.png old mode 100644 new mode 100755 index 1dda9e7c..8a68b5fb Binary files a/storage/app/public/logo.png and b/storage/app/public/logo.png differ diff --git a/test.json b/test.json deleted file mode 100644 index e0ff4215..00000000 --- a/test.json +++ /dev/null @@ -1,12 +0,0 @@ -[ - { - "PASSWORD": "", - "USERNAME": "", - "AUTO_UPDATE": "0", - "BOT_PY_FILE": "bot.py", - "PY_PACKAGES": "", - "USER_UPLOAD": "0", - "INSTALL_REPO": "", - "INSTALL_BRANCH": "" - } -] diff --git a/themes/default/views/admin/overview/index.blade.php b/themes/default/views/admin/overview/index.blade.php index e9c4debf..09f07e93 100644 --- a/themes/default/views/admin/overview/index.blade.php +++ b/themes/default/views/admin/overview/index.blade.php @@ -43,7 +43,7 @@ class="mr-2 fas fa-link"> {{__('Documentation')}}
- {{__('Github')}}
diff --git a/themes/default/views/information/privacy-content.blade.php b/themes/default/views/information/privacy-content.blade.php index 5f465e82..9b1db499 100644 --- a/themes/default/views/information/privacy-content.blade.php +++ b/themes/default/views/information/privacy-content.blade.php @@ -49,8 +49,8 @@ Service or from the Service infrastructure itself (for example, the duration of a page visit).

  • -

    Website refers to CtrlPanel, accessible from controlpanel

    +

    Website refers to CtrlPanel, accessible from ctrlpanel

  • You means the individual accessing or using the Service, or the company, or other legal diff --git a/themes/default/views/information/tos-content.blade.php b/themes/default/views/information/tos-content.blade.php index 6dd7c129..e9a42927 100644 --- a/themes/default/views/information/tos-content.blade.php +++ b/themes/default/views/information/tos-content.blade.php @@ -146,6 +146,10 @@

    - PayPal

    +

    - Stripe

    + +

    - Mollie

    +

    You agree to provide current, complete, and accurate purchase and account information for all purchases made via the Site. You further agree to promptly update account and payment information, including email address, payment method, and payment card expiration date, so that we can complete your transactions and contact you as needed. Sales tax will be added to the price of purchases as deemed required by us. We may change prices at any time. All payments shall beinU.S. dollars.