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 1e64e53e..dc186d0e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,29 +1,36 @@ +# 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 -/public/install/logs.txt + +# Ignore installation logs and locks +public/install/logs.txt install.lock /public/install/logs/*.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 c121ff78..291c86cf 100644 --- a/README.md +++ b/README.md @@ -1,67 +1,87 @@ -### Features - -- PayPal, Stripe and Mollie Integration -- Hourly, Weekely, Monthly, Quarterly and Annual billing Cycles -- Referral System -- Partner System -- Ticket System -- Upgrade/Downgrade Server Resources -- Store (credit system with hourly billing and invoices) -- Email Verification -- Audit Log -- Admin Dashboard -- User/Server Management -- Customisable server plans -- Vouchers -- Alert System -- Theme Support -- and so much more! +
+ +
# 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/Extensions/PaymentGateways/Mollie/migrations/2023_03_26_215801_create_mollie_settings.php b/app/Extensions/PaymentGateways/Mollie/migrations/2023_03_26_215801_create_mollie_settings.php index b32027e3..a3b6bfd0 100644 --- a/app/Extensions/PaymentGateways/Mollie/migrations/2023_03_26_215801_create_mollie_settings.php +++ b/app/Extensions/PaymentGateways/Mollie/migrations/2023_03_26_215801_create_mollie_settings.php @@ -6,7 +6,7 @@ class CreateMollieSettings extends SettingsMigration { public function up(): void { - $this->migrator->add('mollie.api_key', null); + $this->migrator->addEncrypted('mollie.api_key', null); $this->migrator->add('mollie.enabled', false); } diff --git a/app/Extensions/PaymentGateways/PayPal/migrations/2023_03_04_135248_create_pay_pal_settings.php b/app/Extensions/PaymentGateways/PayPal/migrations/2023_03_04_135248_create_pay_pal_settings.php index 3c011057..db7d0bdd 100644 --- a/app/Extensions/PaymentGateways/PayPal/migrations/2023_03_04_135248_create_pay_pal_settings.php +++ b/app/Extensions/PaymentGateways/PayPal/migrations/2023_03_04_135248_create_pay_pal_settings.php @@ -11,10 +11,10 @@ class CreatePayPalSettings extends SettingsMigration $table_exists = DB::table('settings_old')->exists(); - $this->migrator->add('paypal.client_id', $table_exists ? $this->getOldValue('SETTINGS::PAYMENTS:PAYPAL:CLIENT_ID') : null); - $this->migrator->add('paypal.client_secret', $table_exists ? $this->getOldValue('SETTINGS::PAYMENTS:PAYPAL:SECRET') : null); - $this->migrator->add('paypal.sandbox_client_id', $table_exists ? $this->getOldValue('SETTINGS::PAYMENTS:PAYPAL:SANDBOX_CLIENT_ID') : null); - $this->migrator->add('paypal.sandbox_client_secret', $table_exists ? $this->getOldValue('SETTINGS::PAYMENTS:PAYPAL:SANDBOX_SECRET') : null); + $this->migrator->addEncrypted('paypal.client_id', $table_exists ? $this->getOldValue('SETTINGS::PAYMENTS:PAYPAL:CLIENT_ID') : null); + $this->migrator->addEncrypted('paypal.client_secret', $table_exists ? $this->getOldValue('SETTINGS::PAYMENTS:PAYPAL:SECRET') : null); + $this->migrator->addEncrypted('paypal.sandbox_client_id', $table_exists ? $this->getOldValue('SETTINGS::PAYMENTS:PAYPAL:SANDBOX_CLIENT_ID') : null); + $this->migrator->addEncrypted('paypal.sandbox_client_secret', $table_exists ? $this->getOldValue('SETTINGS::PAYMENTS:PAYPAL:SANDBOX_SECRET') : null); $this->migrator->add('paypal.enabled', false); } diff --git a/app/Extensions/PaymentGateways/Stripe/migrations/2023_03_04_181917_create_stripe_settings.php b/app/Extensions/PaymentGateways/Stripe/migrations/2023_03_04_181917_create_stripe_settings.php index 1483732b..c320c80d 100644 --- a/app/Extensions/PaymentGateways/Stripe/migrations/2023_03_04_181917_create_stripe_settings.php +++ b/app/Extensions/PaymentGateways/Stripe/migrations/2023_03_04_181917_create_stripe_settings.php @@ -9,9 +9,9 @@ class CreateStripeSettings extends SettingsMigration { $table_exists = DB::table('settings_old')->exists(); - $this->migrator->add('stripe.secret_key', $table_exists ? $this->getOldValue('SETTINGS::PAYMENTS:STRIPE:SECRET') : null); + $this->migrator->addEncrypted('stripe.secret_key', $table_exists ? $this->getOldValue('SETTINGS::PAYMENTS:STRIPE:SECRET') : null); $this->migrator->add('stripe.endpoint_secret', $table_exists ? $this->getOldValue('SETTINGS::PAYMENTS:STRIPE:ENDPOINT_SECRET') : null); - $this->migrator->add('stripe.test_secret_key', $table_exists ? $this->getOldValue('SETTINGS::PAYMENTS:STRIPE:TEST_SECRET') : null); + $this->migrator->addEncrypted('stripe.test_secret_key', $table_exists ? $this->getOldValue('SETTINGS::PAYMENTS:STRIPE:TEST_SECRET') : null); $this->migrator->add('stripe.test_endpoint_secret', $table_exists ? $this->getOldValue('SETTINGS::PAYMENTS:STRIPE:ENDPOINT_TEST_SECRET') : null); $this->migrator->add('stripe.enabled', false); } diff --git a/app/Http/Controllers/Admin/CouponController.php b/app/Http/Controllers/Admin/CouponController.php index 1287a57c..71caaf31 100644 --- a/app/Http/Controllers/Admin/CouponController.php +++ b/app/Http/Controllers/Admin/CouponController.php @@ -185,29 +185,32 @@ class CouponController extends Controller public function dataTable() { - $query = Coupon::query(); + $query = Coupon::selectRaw(' + coupons.*, + CASE + WHEN coupons.uses >= coupons.max_uses THEN "USES_LIMIT_REACHED" + WHEN coupons.expires_at IS NOT NULL AND coupons.expires_at < NOW() THEN "EXPIRED" + ELSE "VALID" + END as derived_status + '); return datatables($query) ->addColumn('actions', function(Coupon $coupon) { return ' - +
'.csrf_field().' '.method_field('DELETE').' - +
'; }) - ->addColumn('status', function(Coupon $coupon) { - $color = 'success'; - $status = $coupon->getStatus(); + ->addColumn('status', function (Coupon $coupon) { + $color = ($coupon->derived_status == 'VALID') ? 'success' : 'danger'; + $status = str_replace('_', ' ', $coupon->derived_status); - if ($status != __('VALID')) { - $color = 'danger'; - } - - return ''.str_replace('_', ' ', $status).''; + return ''.$status.''; }) ->editColumn('uses', function (Coupon $coupon) { return "{$coupon->uses} / {$coupon->max_uses}"; @@ -232,6 +235,7 @@ class CouponController extends Controller ->editColumn('code', function (Coupon $coupon) { return "{$coupon->code}"; }) + ->orderColumn('status', 'derived_status $1') ->rawColumns(['actions', 'code', 'status']) ->make(); } diff --git a/app/Http/Controllers/Admin/PartnerController.php b/app/Http/Controllers/Admin/PartnerController.php index 5c4a6bab..8b65eec3 100644 --- a/app/Http/Controllers/Admin/PartnerController.php +++ b/app/Http/Controllers/Admin/PartnerController.php @@ -122,11 +122,11 @@ class PartnerController extends Controller return datatables($query) ->addColumn('actions', function (PartnerDiscount $partner) { return ' - +
'.csrf_field().' '.method_field('DELETE').' - +
'; }) @@ -145,6 +145,7 @@ class PartnerController extends Controller ->editColumn('referral_system_commission', function (PartnerDiscount $partner, ReferralSettings $referral_settings) { return $partner->referral_system_commission >= 0 ? $partner->referral_system_commission . '%' : __('Default') . ' ('.$referral_settings->percentage . '%)'; }) + ->orderColumn('user', 'user_id $1') ->rawColumns(['user', 'actions']) ->make(); } diff --git a/app/Http/Controllers/Admin/PaymentController.php b/app/Http/Controllers/Admin/PaymentController.php index 66292bd5..0b11597e 100644 --- a/app/Http/Controllers/Admin/PaymentController.php +++ b/app/Http/Controllers/Admin/PaymentController.php @@ -180,7 +180,10 @@ class PaymentController extends Controller $paymentGatewayExtension = ExtensionHelper::getExtensionClass($paymentGateway); $redirectUrl = $paymentGatewayExtension::getRedirectUrl($payment, $shopProduct, $totalPriceString); - event(new CouponUsedEvent($couponCode)); + + if ($couponCode) { + event(new CouponUsedEvent($couponCode)); + } } catch (Exception $e) { Log::error($e->getMessage()); return redirect()->route('store.index')->with('error', __('Oops, something went wrong! Please try again later.')); diff --git a/app/Http/Controllers/Admin/ProductController.php b/app/Http/Controllers/Admin/ProductController.php index ddc91fa8..6ddae3e3 100644 --- a/app/Http/Controllers/Admin/ProductController.php +++ b/app/Http/Controllers/Admin/ProductController.php @@ -223,17 +223,18 @@ class ProductController extends Controller public function dataTable() { $query = Product::with(['servers']); + return datatables($query) ->addColumn('actions', function (Product $product) { return ' - - - + + +
'.csrf_field().' '.method_field('DELETE').' - +
'; }) @@ -247,7 +248,7 @@ class ProductController extends Controller ->addColumn('eggs', function (Product $product) { return $product->eggs()->count(); }) - ->addColumn('disabled', function (Product $product) { + ->editColumn('disabled', function (Product $product) { $checked = $product->disabled == false ? 'checked' : ''; return ' @@ -264,7 +265,7 @@ class ProductController extends Controller ->editColumn('minimum_credits', function (Product $product, UserSettings $user_settings) { return $product->minimum_credits==-1 ? $user_settings->min_credits_to_make_server : $product->minimum_credits; }) - ->editColumn('oom_killer', function (Product $product, UserSettings $user_settings) { + ->editColumn('oom_killer', function (Product $product) { return $product->oom_killer ? __("enabled") : __("disabled"); }) ->editColumn('created_at', function (Product $product) { diff --git a/app/Http/Controllers/Admin/RoleController.php b/app/Http/Controllers/Admin/RoleController.php index b10c1b01..cc75f178 100644 --- a/app/Http/Controllers/Admin/RoleController.php +++ b/app/Http/Controllers/Admin/RoleController.php @@ -182,8 +182,7 @@ class RoleController extends Controller */ public function dataTable() { - $query = Role::query()->withCount(['users', 'permissions']); - + $query = Role::query()->withCount(['users', 'permissions'])->get(); return datatables($query) ->editColumn('id', function (Role $role) { @@ -205,10 +204,10 @@ class RoleController extends Controller ->editColumn('name', function (Role $role) { return "$role->name"; }) - ->editColumn('usercount', function ($query) { + ->editColumn('users_count', function ($query) { return $query->users_count; }) - ->editColumn('permissionscount', function ($query){ + ->editColumn('permissions_count', function ($query){ return $query->permissions_count; }) ->editColumn('power', function (Role $role){ diff --git a/app/Http/Controllers/Admin/ShopProductController.php b/app/Http/Controllers/Admin/ShopProductController.php index 74c32639..db07916a 100644 --- a/app/Http/Controllers/Admin/ShopProductController.php +++ b/app/Http/Controllers/Admin/ShopProductController.php @@ -156,16 +156,16 @@ class ShopProductController extends Controller return datatables($query) ->addColumn('actions', function (ShopProduct $shopProduct) { return ' - +
' . csrf_field() . ' ' . method_field('DELETE') . ' - +
'; }) - ->addColumn('disabled', function (ShopProduct $shopProduct) { + ->editColumn('disabled', function (ShopProduct $shopProduct) { $checked = $shopProduct->disabled == false ? 'checked' : ''; return ' diff --git a/app/Http/Controllers/Admin/TicketsController.php b/app/Http/Controllers/Admin/TicketsController.php index 3622c22a..025c58de 100644 --- a/app/Http/Controllers/Admin/TicketsController.php +++ b/app/Http/Controllers/Admin/TicketsController.php @@ -121,11 +121,12 @@ class TicketsController extends Controller public function dataTable() { - $query = Ticket::query(); + $query = Ticket::leftJoin('ticket_categories', 'tickets.ticketcategory_id', '=', 'ticket_categories.id') + ->select(['tickets.*', 'ticket_categories.name as category_name']); return datatables($query) - ->addColumn('category', function (Ticket $tickets) { - return $tickets->ticketcategory->name; + ->addColumn('category', function (Ticket $ticket) { + return $ticket->category_name; }) ->editColumn('title', function (Ticket $tickets) { return ''.'#'.$tickets->ticket_id.' - '.htmlspecialchars($tickets->title).''; @@ -139,16 +140,16 @@ class TicketsController extends Controller $statusButtonText = ($tickets->status == "Closed") ? __('Reopen') : __('Close'); return ' - +
'.csrf_field().' '.method_field('POST').' - +
'.csrf_field().' '.method_field('POST').' - +
'; }) @@ -178,7 +179,8 @@ class TicketsController extends Controller return ['display' => $tickets->updated_at ? $tickets->updated_at->diffForHumans() : '', 'raw' => $tickets->updated_at ? strtotime($tickets->updated_at) : '']; }) - ->rawColumns(['category', 'title', 'user_id', 'status', 'priority', 'updated_at', 'actions']) + ->orderColumn('category', 'category_name $1') + ->rawColumns(['title', 'user_id', 'status', 'priority', 'updated_at', 'actions']) ->make(true); } @@ -279,12 +281,12 @@ class TicketsController extends Controller
'.csrf_field().' '.method_field('POST').' - +
'.csrf_field().' '.method_field('POST').' - +
'; }) diff --git a/app/Http/Controllers/Admin/UserController.php b/app/Http/Controllers/Admin/UserController.php index ff3d7b91..6e8462e4 100644 --- a/app/Http/Controllers/Admin/UserController.php +++ b/app/Http/Controllers/Admin/UserController.php @@ -148,7 +148,7 @@ class UserController extends Controller */ public function update(Request $request, User $user) { - $request->validate([ + $data = $request->validate([ 'name' => 'required|string|min:4|max:30', 'pterodactyl_id' => "required|numeric|unique:users,pterodactyl_id,{$user->id}", 'email' => 'required|string|email', @@ -179,23 +179,23 @@ class UserController extends Controller ]); } - if($this->can(self::CHANGE_USERNAME_PERMISSION)){ - $user->name = $request->name; - } - if($this->can(self::CHANGE_CREDITS_PERMISSION)){ - $user->credits = $request->credits; - } - if($this->can(self::CHANGE_PTERO_PERMISSION)){ - $user->pterodactyl_id = $request->pterodactyl_id; - } - if($this->can(self::CHANGE_REFERAL_PERMISSION)){ - $user->referral_code = $request->referral_code; - } - if($this->can(self::CHANGE_EMAIL_PERMISSION)){ - $user->email = $request->email; - } + // if($this->can(self::CHANGE_USERNAME_PERMISSION)){ + // $user->name = $request->name; + // } + // if($this->can(self::CHANGE_CREDITS_PERMISSION)){ + // $user->credits = $request->credits; + // } + // if($this->can(self::CHANGE_PTERO_PERMISSION)){ + // $user->pterodactyl_id = $request->pterodactyl_id; + // } + // if($this->can(self::CHANGE_REFERAL_PERMISSION)){ + // $user->referral_code = $request->referral_code; + // } + // if($this->can(self::CHANGE_EMAIL_PERMISSION)){ + // $user->email = $request->email; + // } - $user->save(); + $user->update($data); event(new UserUpdateCreditsEvent($user)); @@ -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(); @@ -340,6 +341,10 @@ class UserController extends Controller { $this->checkPermission(self::SUSPEND_PERMISSION); + if (Auth::user()->id === $user->id) { + return redirect()->back()->with('error', __('You can not suspend yourself!')); + } + try { !$user->isSuspended() ? $user->suspend() : $user->unSuspend(); } catch (Exception $exception) { @@ -354,17 +359,19 @@ class UserController extends Controller */ public function dataTable(Request $request) { - $query = User::with('discordUser')->withCount('servers'); - // manually count referrals in user_referrals table - $query->selectRaw('users.*, (SELECT COUNT(*) FROM user_referrals WHERE user_referrals.referral_id = users.id) as referrals_count'); - + $query = User::query() + ->withCount('servers') + ->leftJoin('model_has_roles', 'users.id', '=', 'model_has_roles.model_id') + ->leftJoin('roles', 'model_has_roles.role_id', '=', 'roles.id') + ->selectRaw('users.*, roles.name as role_name, (SELECT COUNT(*) FROM user_referrals WHERE user_referrals.referral_id = users.id) as referrals_count') + ->where('model_has_roles.model_type', User::class); return datatables($query) ->addColumn('avatar', function (User $user) { - return ''; + return ''; }) ->addColumn('credits', function (User $user) { - return ' ' . $user->credits(); + return ' ' . $user->credits(); }) ->addColumn('verified', function (User $user) { return $user->getVerifiedStatus(); @@ -378,10 +385,10 @@ class UserController extends Controller $suspendText = $user->isSuspended() ? __('Unsuspend') : __('Suspend'); return ' - - - - + + + +
' . csrf_field() . ' @@ -389,7 +396,7 @@ class UserController extends Controller ' . csrf_field() . ' ' . method_field('DELETE') . ' - +
'; }) @@ -408,6 +415,7 @@ class UserController extends Controller ->editColumn('name', function (User $user, PterodactylSettings $ptero_settings) { return '' . strip_tags($user->name) . ''; }) + ->orderColumn('role', 'role_name $1') ->rawColumns(['avatar', 'name', 'credits', 'role', 'usage', 'actions']) ->make(); } diff --git a/app/Http/Controllers/Admin/VoucherController.php b/app/Http/Controllers/Admin/VoucherController.php index ec6c5232..b42d5094 100644 --- a/app/Http/Controllers/Admin/VoucherController.php +++ b/app/Http/Controllers/Admin/VoucherController.php @@ -203,7 +203,7 @@ class VoucherController extends Controller return ''.$user->name.''; }) ->addColumn('credits', function (User $user) { - return ' '.$user->credits(); + return ' '.$user->credits(); }) ->addColumn('last_seen', function (User $user) { return $user->last_seen ? $user->last_seen->diffForHumans() : ''; @@ -214,28 +214,33 @@ class VoucherController extends Controller public function dataTable() { - $query = Voucher::query(); + $query = Voucher::selectRaw(' + vouchers.*, + CASE + WHEN (SELECT COUNT(*) FROM user_voucher WHERE user_voucher.voucher_id = vouchers.id) >= vouchers.uses THEN "USES_LIMIT_REACHED" + WHEN vouchers.expires_at IS NOT NULL AND vouchers.expires_at < NOW() THEN "EXPIRED" + ELSE "VALID" + END as derived_status + '); return datatables($query) ->addColumn('actions', function (Voucher $voucher) { return ' - - + +
'.csrf_field().' '.method_field('DELETE').' - +
'; }) ->addColumn('status', function (Voucher $voucher) { - $color = 'success'; - if ($voucher->getStatus() != __('VALID')) { - $color = 'danger'; - } + $color = ($voucher->derived_status == 'VALID') ? 'success' : 'danger'; + $status = str_replace('_', ' ', $voucher->derived_status); - return ''.$voucher->getStatus().''; + return ''.$status.''; }) ->editColumn('uses', function (Voucher $voucher) { return "{$voucher->used} / {$voucher->uses}"; @@ -253,6 +258,7 @@ class VoucherController extends Controller ->editColumn('code', function (Voucher $voucher) { return "{$voucher->code}"; }) + ->orderColumn('status', 'derived_status $1') ->rawColumns(['actions', 'code', 'status']) ->make(); } 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/Listeners/Verified.php b/app/Listeners/Verified.php index 9ed9bf37..c6e75912 100644 --- a/app/Listeners/Verified.php +++ b/app/Listeners/Verified.php @@ -7,7 +7,6 @@ use App\Settings\UserSettings; class Verified { private $server_limit_after_verify_email; - private $credits_reward_after_verify_email; /** @@ -29,9 +28,10 @@ class Verified */ public function handle($event) { - if (! $event->user->email_verified_reward) { + if (!$event->user->email_verified_reward) { $event->user->increment('server_limit', $this->server_limit_after_verify_email); $event->user->increment('credits', $this->credits_reward_after_verify_email); + $event->user->update(['email_verified_reward' => true]); } } } diff --git a/app/Models/User.php b/app/Models/User.php index 84f54298..5ae64529 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -298,8 +298,7 @@ class User extends Authenticatable implements MustVerifyEmail public function reVerifyEmail() { $this->forceFill([ - 'email_verified_at' => null, - 'email_verified_reward' => true + 'email_verified_at' => null ])->save(); } 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 1ea8309d..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() { @@ -80,12 +85,17 @@ class MailSettings extends Settings ], 'mail_password' => [ 'label' => 'Mail Password', - 'type' => 'string', + 'type' => 'password', 'description' => 'The password of your mail server.', ], 'mail_encryption' => [ 'label' => 'Mail Encryption', - 'type' => 'string', + 'type' => 'select', + 'options' => [ + 'null' => 'None', + 'tls' => 'TLS', + 'ssl' => 'SSL' + ], 'description' => 'The encryption of your mail server.', ], 'mail_from_address' => [ 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/app/Traits/Coupon.php b/app/Traits/Coupon.php index 5dd0e7e9..f1d06d27 100644 --- a/app/Traits/Coupon.php +++ b/app/Traits/Coupon.php @@ -95,27 +95,6 @@ trait Coupon return true; } - public function calcDiscount($productPrice, stdClass $data) - { - - if ($data->isValid) { - if ($data->couponType === 'percentage') { - return $productPrice - ($productPrice * $data->couponValue / 100); - } - - if ($data->couponType === 'amount') { - // There is no discount if the value of the coupon is greater than or equal to the value of the product. - if ($data->couponValue >= $productPrice) { - return $productPrice; - } - } - - return $productPrice - $data->couponValue; - } - - return $productPrice; - } - public function applyCoupon(string $couponCode, float $price) { $coupon = CouponModel::where('code', $couponCode)->first(); 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 3de54175..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->add('pterodactyl.admin_token', $table_exists ? $this->getOldValue('SETTINGS::SYSTEM:PTERODACTYL:TOKEN') : env('PTERODACTYL_TOKEN', '')); - $this->migrator->add('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 56953b78..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 @@ migrator->add('mail.mail_host', $table_exists ? $this->getOldValue('SETTINGS::MAIL:HOST') : env('MAIL_HOST', 'localhost')); $this->migrator->add('mail.mail_port', $table_exists ? $this->getOldValue('SETTINGS::MAIL:PORT') : env('MAIL_PORT', 25)); $this->migrator->add('mail.mail_username', $table_exists ? $this->getOldValue('SETTINGS::MAIL:USERNAME') : env('MAIL_USERNAME', '')); - $this->migrator->add('mail.mail_password', $table_exists ? $this->getOldValue('SETTINGS::MAIL:PASSWORD') : env('MAIL_PASSWORD', '')); + $this->migrator->addEncrypted('mail.mail_password', $table_exists ? $this->getOldValue('SETTINGS::MAIL:PASSWORD') : env('MAIL_PASSWORD', '')); $this->migrator->add('mail.mail_encryption', $table_exists ? $this->getOldValue('SETTINGS::MAIL:ENCRYPTION') : env('MAIL_ENCRYPTION', 'tls')); $this->migrator->add('mail.mail_from_address', $table_exists ? $this->getOldValue('SETTINGS::MAIL:FROM_ADDRESS') : env('MAIL_FROM_ADDRESS', 'example@example.com')); $this->migrator->add('mail.mail_from_name', $table_exists ? $this->getOldValue('SETTINGS::MAIL:FROM_NAME') : env('APP_NAME', 'CtrlPanel.gg')); @@ -25,105 +25,66 @@ class CreateMailSettings extends SettingsMigration DB::table('settings_old')->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 b966cf72..10164dad 100644 --- a/routes/web.php +++ b/routes/web.php @@ -35,6 +35,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; /* @@ -81,11 +82,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/coupons/index.blade.php b/themes/default/views/admin/coupons/index.blade.php index d89135cf..cad2aa4e 100644 --- a/themes/default/views/admin/coupons/index.blade.php +++ b/themes/default/views/admin/coupons/index.blade.php @@ -4,7 +4,7 @@
-
+

{{__('Coupons')}}

@@ -31,7 +31,7 @@ {{__('Coupons')}} - + {{__('Create new')}}
@@ -82,7 +82,7 @@ {data: 'status'}, {data: 'code'}, {data: 'value'}, - {data: 'uses'}, + {data: 'uses', sortable: false}, {data: 'expires_at'}, {data: 'created_at'}, {data: 'actions', sortable: false}, diff --git a/themes/default/views/admin/overview/index.blade.php b/themes/default/views/admin/overview/index.blade.php index 5a6fc1d5..09f07e93 100644 --- a/themes/default/views/admin/overview/index.blade.php +++ b/themes/default/views/admin/overview/index.blade.php @@ -4,7 +4,7 @@
-
+

{{__('Admin Overview')}}

@@ -33,22 +33,22 @@
-
+ @@ -59,7 +59,7 @@
{{__('Servers')}} - @@ -77,7 +77,7 @@
{{__('Users')}} - @@ -92,7 +92,7 @@
+ class="text-white fas fa-coins">
{{__('Total')}} {{ $credits_display_name }} @@ -123,15 +123,15 @@
- {{__('Pterodactyl')}} + {{__('Pterodactyl')}}
{{__('Sync')}} + class="mr-2 fas fa-sync">{{__('Sync')}}
-
+
@if ($deletedNodesPresent) -
+
{{ __('Warning!') }}

{{ __('Some nodes got deleted on pterodactyl only. Please click the sync button above.') }} @@ -166,42 +166,44 @@

- {{__('Latest tickets')}} + {{__('Latest tickets')}}
-
+
@if(!$tickets->count()){{__('There are no tickets')}}. @else - - - - - - - - - - +
+
{{__('Title')}}{{__('User')}}{{__('Status')}}{{__('Last updated')}}
+ + + + + + + + + - @foreach($tickets as $ticket_id => $ticket) - - - - - - - @endforeach + @foreach($tickets as $ticket_id => $ticket) + + + + + + + @endforeach - -
{{__('Title')}}{{__('User')}}{{__('Status')}}{{__('Last updated')}}
#{{$ticket_id}} - {{$ticket->title}}{{$ticket->user}}{{$ticket->status}}{{$ticket->last_updated}}
#{{$ticket_id}} - {{$ticket->title}}{{$ticket->user}}{{$ticket->status}}{{$ticket->last_updated}}
+ + +
@endif
@@ -209,14 +211,14 @@
- {{__('CtrlPanel.gg')}} + {{__('CtrlPanel.gg')}}
-
+
@@ -226,13 +228,13 @@
- {{__('Individual nodes')}} + {{__('Individual nodes')}}
-
+
@if ($perPageLimit) -
+
{{ __('Error!') }}

{{ __('You reached the Pterodactyl perPage limit. Please make sure to set it higher than your server count.') }}
@@ -240,39 +242,41 @@ {{ __('Note') }}: {{ __('If this error persists even after changing the limit, it might mean a server was deleted on Pterodactyl, but not on CtrlPanel. Try clicking the button below.') }}

{{__('Sync servers')}} + class="mr-2 fas fa-sync">{{__('Sync servers')}}
@endif - - - - - - - - - - - - @foreach($nodes as $nodeID => $node) - - - - - - - - @endforeach - - - - - - - +
+
{{__('ID')}}{{__('Node')}}{{__('Server count')}}{{__('Resource usage')}}{{ $credits_display_name . ' ' . __('Usage') ." (".__('per month').")"}}
{{$nodeID}}{{$node->name}}{{$node->activeServers}}/{{$node->totalServers}}{{$node->usagePercent}}%{{$node->activeEarnings}}/{{$node->totalEarnings}}
{{__('Total')}} ({{__('active')}}/{{__('total')}}):{{$counters['servers']->active}}/{{$counters['servers']->total}}{{$counters['totalUsagePercent']}}%{{$counters['earnings']->active}}/{{$counters['earnings']->total}}
+ + + + + + + - -
{{__('ID')}}{{__('Node')}}{{__('Server count')}}{{__('Resource usage')}}{{ $credits_display_name . ' ' . __('Usage') ." (".__('per month').")"}}
+ + + @foreach($nodes as $nodeID => $node) + + {{$nodeID}} + {{$node->name}} + {{$node->activeServers}}/{{$node->totalServers}} + {{$node->usagePercent}}% + {{$node->activeEarnings}}/{{$node->totalEarnings}} + + @endforeach + + + + {{__('Total')}} ({{__('active')}}/{{__('total')}}): + {{$counters['servers']->active}}/{{$counters['servers']->total}} + {{$counters['totalUsagePercent']}}% + {{$counters['earnings']->active}}/{{$counters['earnings']->total}} + + + +

@@ -280,11 +284,11 @@
- {{__('Latest payments')}} + {{__('Latest payments')}}
-
+
@if($counters['payments']['lastMonth']->count())
@@ -293,25 +297,26 @@ data-content="{{ __('Payments in this time window') }}:
{{$counters['payments']['lastMonth']->timeStart}} - {{$counters['payments']['lastMonth']->timeEnd}}" class="fas fa-info-circle"> - - - - - - - - - - @foreach($counters['payments']['lastMonth'] as $currency => $income) - - - - - - @endforeach - -
{{__('Currency')}}{{__('Number of payments')}}{{__('Total amount')}}
{{$currency}}{{$income->count}}{{$income->total}}
-
+
+ + + + + + + + + + @foreach($counters['payments']['lastMonth'] as $currency => $income) + + + + + + @endforeach + +
{{__('Currency')}}{{__('Number of payments')}}{{__('Total amount')}}
{{$currency}}{{$income->count}}{{$income->total}}
+
@endif @if($counters['payments']['lastMonth']->count())
@@ -321,25 +326,26 @@ data-content="{{ __('Payments in this time window') }}:
{{$counters['payments']['thisMonth']->timeStart}} - {{$counters['payments']['thisMonth']->timeEnd}}" class="fas fa-info-circle"> - - - - - - - - - - @foreach($counters['payments']['thisMonth'] as $currency => $income) - - - - - - @endforeach - -
{{__('Currency')}}{{__('Number of payments')}}{{__('Total amount')}}
{{$currency}}{{$income->count}}{{$income->total}}
-
+
+ + + + + + + + + + @foreach($counters['payments']['thisMonth'] as $currency => $income) + + + + + + @endforeach + +
{{__('Currency')}}{{__('Number of payments')}}{{__('Total amount')}}
{{$currency}}{{$income->count}}{{$income->total}}
+
@@ -349,20 +355,52 @@
- {{__('Tax overview')}} + {{__('Tax overview')}}
-
+
@if($counters['taxPayments']['lastYear']->count()) {{__('Last year')}}: +
+ + + + + + + + + + + + @foreach($counters['taxPayments']['lastYear'] as $currency => $income) + + + + + + + + @endforeach + +
{{__('Currency')}}{{__('Number of payments')}}{{__('Base amount')}}{{__('Total taxes')}}{{__('Total amount')}}
{{$currency}}{{$income->count}}{{$income->price}}{{$income->taxes}}{{$income->total}}
+
+
+ @endif + {{__('This year')}}: + + +
- + @@ -371,7 +409,7 @@ - @foreach($counters['taxPayments']['lastYear'] as $currency => $income) + @foreach($counters['taxPayments']['thisYear'] as $currency => $income) @@ -382,35 +420,7 @@ @endforeach
{{__('Currency')}} {{__('Number of payments')}} {{__('Base amount')}}
{{$currency}} {{$income->count}}
-
- @endif - {{__('This year')}}: - - - - - - - - - - - - - - @foreach($counters['taxPayments']['thisYear'] as $currency => $income) - - - - - - - - @endforeach - -
{{__('Currency')}}{{__('Number of payments')}}{{__('Base amount')}}{{__('Total taxes')}}{{__('Total amount')}}
{{$currency}}{{$income->count}}{{$income->price}}{{$income->taxes}}{{$income->total}}
+

diff --git a/themes/default/views/admin/products/index.blade.php b/themes/default/views/admin/products/index.blade.php index a951a46f..22659804 100644 --- a/themes/default/views/admin/products/index.blade.php +++ b/themes/default/views/admin/products/index.blade.php @@ -4,7 +4,7 @@
-
+

{{__('Products')}}

@@ -30,9 +30,9 @@
-
{{__('Products')}}
+
{{__('Products')}}
{{__('Create new')}} + class="mr-1 fas fa-plus">{{__('Create new')}}
diff --git a/themes/default/views/admin/products/show.blade.php b/themes/default/views/admin/products/show.blade.php index 217a27bf..922d5d01 100644 --- a/themes/default/views/admin/products/show.blade.php +++ b/themes/default/views/admin/products/show.blade.php @@ -4,7 +4,7 @@
-
+

{{__('Products')}}

@@ -28,17 +28,17 @@
-
{{__('Product')}}
+
{{__('Product')}}
{{ csrf_field() }} {{ method_field('DELETE') }} + class="mr-1 btn btn-sm btn-danger">
@@ -78,7 +78,7 @@
- {{ $product->price }} + {{ $product->price }}
@@ -92,9 +92,9 @@
@if ($product->minimum_credits == -1) - {{ $minimum_credits }} + {{ $minimum_credits }} @else - {{ $product->minimum_credits }} + {{ $product->minimum_credits }} @endif
@@ -213,7 +213,7 @@
- + {{ $product->description }}
@@ -240,7 +240,7 @@
-
{{__('Servers')}}
+
{{__('Servers')}}
diff --git a/themes/default/views/admin/roles/index.blade.php b/themes/default/views/admin/roles/index.blade.php index 213a7724..b327fce9 100644 --- a/themes/default/views/admin/roles/index.blade.php +++ b/themes/default/views/admin/roles/index.blade.php @@ -1,16 +1,16 @@ @extends('layouts.main') @section('content') -
+
@can('admin.roles.write') -
+ @endcan -
+

{{ __('Roles') }}

@@ -48,8 +48,8 @@ columns: [ {data: 'id'}, {data: 'name'}, - {data: 'usercount'}, - {data: 'permissionscount'}, + {data: 'users_count'}, + {data: 'permissions_count'}, {data: 'power'}, {data: 'actions' , sortable : false}, ], diff --git a/themes/default/views/admin/servers/index.blade.php b/themes/default/views/admin/servers/index.blade.php index 3cfec164..2a0f8791 100644 --- a/themes/default/views/admin/servers/index.blade.php +++ b/themes/default/views/admin/servers/index.blade.php @@ -4,7 +4,7 @@
-
+

{{ __('Servers') }}

@@ -28,10 +28,10 @@
- {{ __('Servers') }} + {{ __('Servers') }}
{{ __('Sync') }} + class="mr-2 fas fa-sync">{{ __('Sync') }}
@@ -93,7 +93,6 @@ }, { data: 'product.name', - sortable: false }, { data: 'suspended' diff --git a/themes/default/views/admin/settings/index.blade.php b/themes/default/views/admin/settings/index.blade.php index 78454fd7..799e426d 100644 --- a/themes/default/views/admin/settings/index.blade.php +++ b/themes/default/views/admin/settings/index.blade.php @@ -4,7 +4,7 @@
-
+

{{ __('Settings') }}

@@ -37,13 +37,13 @@
-
{{ __('Settings') }}
+
{{ __('Settings') }}
-
+
-
-
-
+
+
+
@csrf @method('POST')
-
- {{ __('FavIcon') }} +
+ {{ __('FavIcon') }} ... @@ -130,8 +130,8 @@ name="favicon" id="favicon">
-
- {{ __('Icon') }} +
+ {{ __('Icon') }} ... @@ -142,8 +142,8 @@ class="form-control" name="icon" id="icon">
-
- {{ __('Login-page Logo') }} +
+ {{ __('Login-page Logo') }} ... @@ -155,7 +155,7 @@
- +
@@ -182,14 +182,14 @@
-
+
@if ($value['description']) - @else - + @endif
@@ -200,6 +200,12 @@ value="{{ $value['value'] }}"> @break + @case($value['type'] == 'password') + + @break + @case($value['type'] == 'boolean')
-
+
{!! htmlScriptTagJsApi() !!} {!! htmlFormSnippet() !!} @error('g-recaptcha-response') @@ -294,10 +300,10 @@
-
diff --git a/themes/default/views/admin/ticket/blacklist.blade.php b/themes/default/views/admin/ticket/blacklist.blade.php index e26304a1..f501d399 100644 --- a/themes/default/views/admin/ticket/blacklist.blade.php +++ b/themes/default/views/admin/ticket/blacklist.blade.php @@ -4,7 +4,7 @@
-
+

{{ __('Ticket Blacklist') }}

@@ -29,7 +29,7 @@
-
{{__('Blacklist List')}}
+
{{__('Blacklist List')}}
@@ -62,7 +62,7 @@
@csrf -
+