Merge branch 'development' into mercadopago-implementation

This commit is contained in:
S0ly 2024-05-16 18:04:24 +02:00 committed by GitHub
commit 1e1aad1aba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
43 changed files with 633 additions and 885 deletions

View file

@ -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 --- ###

5
.gitattributes vendored
View file

@ -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

22
.github/CODE_OF_CONDUCT.md vendored Normal file
View file

@ -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

34
.github/CONTRIBUTING.md vendored Normal file
View file

@ -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! 🎉

View file

@ -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

37
.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View file

@ -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.

17
.github/SECURITY.md vendored Normal file
View file

@ -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.

35
.gitignore vendored
View file

@ -1,29 +1,34 @@
# Ignore dependencies and cache
/node_modules
/vendor
/storage/*.key
# Ignore public assets
/public/hot
/public/storage
/storage/*.key
/vendor
/storage/credit_deduction_log
storage/debugbar
/storage/app/public/logo.png
# Ignore environment files and configuration
.env
.env.testing
.env.backup
.idea
.env.dev
# Ignore testing and debug logs
.phpunit.result.cache
.editorconfig
docker-compose.override.yml
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
yarn.lock
# Ignore Docker and Homestead configuration
docker-compose.override.yml
Homestead.json
Homestead.yaml
# Ignore gitignore itself
.gitignore
.env.dev
.env.testing
storage/invoices.zip
storage/app/public/logo.png
*vscode
- Kopie.env
# Ignore installation logs and locks
public/install/logs.txt
install.lock
public/install/logs/installer.log

View file

@ -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

View file

@ -1,3 +1,4 @@
<<<<<<< mercadopago-implementation
### Features
- PayPal, Stripe, Mollie and MercadoPago Integration
@ -16,52 +17,92 @@
- Alert System
- Theme Support
- and so much more!
=======
<div align="center">
<img src="https://ctrlpanel.gg/img/controlpanel.png" width="128" alt="" />
</div>
>>>>>>> development
# CtrlPanel-gg
![ctrlpanel](https://user-images.githubusercontent.com/67899387/214684708-739c1d21-06e8-4dec-a4f1-81533a46cc7e.png)
CtrlPanel offers an easy-to-use and free billing solution for all starting and experienced hosting providers that seamlessly integrates with the Pterodactyl panel. It facilitates account creation, server ordering, and management, while offering addons, multiple payment methods, and customizable themes for a comprehensive solution.
![GitHub tag](https://img.shields.io/github/tag/ControlPanel-gg/dashboard)
![Overall Installations](https://img.shields.io/badge/Overall%20Installations-5000%2B-green)
![GitHub stars](https://img.shields.io/github/stars/ControlPanel-gg/dashboard)
[![Crowdin](https://badges.crowdin.net/controlpanelgg/localized.svg)](https://crowdin.com/project/controlpanelgg)
![License](https://img.shields.io/github/license/ControlPanel-gg/dashboard)
![Discord](https://img.shields.io/discord/787829714483019826)
![](https://img.shields.io/endpoint?label=v0.9%20Installations&url=https%3A%2F%2Fmarket.ctrlpanel.gg%2Fcallhome.php%3Fgetinstalls)
![](https://img.shields.io/badge/Overall%20Installations-5000%2B-green)
![](https://img.shields.io/github/stars/ctrlpanel-gg/dashboard) ![](https://img.shields.io/github/forks/ctrlpanel-gg/panel) ![](https://img.shields.io/github/tag/ctrlpanel-gg/panel) [![Crowdin](https://badges.crowdin.com/project/controlpanelgg/localized.svg)](https://crowdin.com/project/controlpanelgg) ![](https://img.shields.io/github/issues/ctrlpanel-gg/panel) ![](https://img.shields.io/github/license/ctrlpanel-gg/panel) ![](https://img.shields.io/discord/787829714483019826)
## About
![CtrlPanel](https://user-images.githubusercontent.com/67899387/214684708-739c1d21-06e8-4dec-a4f1-81533a46cc7e.png)
CtrlPanel's Dashboard is a dashboard application designed to offer clients a management tool to manage their pterodactyl servers. This dashboard comes with a credit-based billing solution that charges users depending on the billing cycle you chose for each server they have and suspends them if they run out of credits.
## ⭐ Features
This dashboard offers an easy to use and free billing solution for all starting and experienced hosting providers. This dashboard has many customisation options and added discord Oauth verification to offer a solid link between your discord server and your dashboard. You can check our [Demo here](https://demo.CtrlPanel.gg "Demo").
- Store (credit system with hourly billing and invoices)
- Many Popular Payment Methods
- Referral
- Partner
- Vouchers
- Ticket
- Account Management
- Admin Dashboard and Tools
- Addon Support
- and more!
### [Installation](https://ctrlpanel.gg/docs/intro "Installation")
## ⛰️ Live Demo
### [Updating](https://ctrlpanel.gg/docs/Installation/updating "Updating")
Try it!
### [Discord](https://discord.gg/4Y6HjD2uyU "Discord")
Demo Server: [demo.CtrlPanel.gg](https://demo.CtrlPanel.gg)
### [Contributing](https://ctrlpanel.gg/docs/Contributing/contributing "Contributing")
<!-- It is a temporary live demo; all data will be deleted. -->
### [Donating](https://ctrlpanel.gg/docs/Contributing/donating "Donating")
## 🔧 How to Install
### 🐳 Docker
Soon...
# Preview
<!-- ```bash
docker run ...
```
### Server Creation
![image](https://user-images.githubusercontent.com/67899387/214687234-d1ae58c0-5667-4e99-ac39-adeaabfcc7f2.png)
CtrlPanel is now running on [0.0.0.0:3001](http://0.0.0.0:3001). Don't forget to configure the database and Pterodactyl. [Documentation](documentation link here)
### Overview
![image](https://user-images.githubusercontent.com/67899387/214685859-03c8d9e1-c685-4a07-979f-df2e88ec3931.png)
more info: [Docker](docker documentation link here) -->
### 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.

View file

@ -0,0 +1,63 @@
<?php
namespace App\Classes;
use Exception;
use Illuminate\Support\Facades\DB;
use Spatie\LaravelSettings\Migrations\SettingsMigration;
abstract class LegacySettingsMigration extends SettingsMigration
{
public function getNewValue(string $name, string $group)
{
$new_value = DB::table('settings')->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}");
}
}
}

View file

@ -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();

View file

@ -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;

View file

@ -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();
}
}

View file

@ -18,8 +18,6 @@ class DiscordSettings extends Settings
return 'discord';
}
/**
* Summary of validations array
* @return array<string, string>

View file

@ -20,7 +20,12 @@ class MailSettings extends Settings
return 'mail';
}
public static function encrypted(): array
{
return [
'mail_password',
];
}
public function setConfig()
{

View file

@ -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

View file

View file

@ -32,7 +32,7 @@ return [
UserSettings::class,
WebsiteSettings::class,
TicketSettings::class,
CouponSettings::class,
CouponSettings::class,
],
/*

View file

@ -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();
});
}
}

View file

@ -1,9 +1,9 @@
<?php
use Spatie\LaravelSettings\Migrations\SettingsMigration;
use App\Classes\LegacySettingsMigration;
use Illuminate\Support\Facades\DB;
class CreateGeneralSettings extends SettingsMigration
class CreateGeneralSettings extends LegacySettingsMigration
{
public function up(): void
{
@ -11,15 +11,15 @@ class CreateGeneralSettings extends SettingsMigration
// Get the user-set configuration values from the old table.
$this->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);
}
}

View file

@ -1,19 +1,18 @@
<?php
use Spatie\LaravelSettings\Migrations\SettingsMigration;
use App\Classes\LegacySettingsMigration;
use Illuminate\Support\Facades\DB;
class CreatePterodactylSettings extends SettingsMigration
class CreatePterodactylSettings extends LegacySettingsMigration
{
public function up(): void
{
$table_exists = DB::table('settings_old')->exists();
// Get the user-set configuration values from the old table.
$this->migrator->addEncrypted('pterodactyl.admin_token', $table_exists ? $this->getOldValue('SETTINGS::SYSTEM:PTERODACTYL:TOKEN') : env('PTERODACTYL_TOKEN', ''));
$this->migrator->addEncrypted('pterodactyl.user_token', $table_exists ? $this->getOldValue('SETTINGS::SYSTEM:PTERODACTYL:ADMIN_USER_TOKEN') : '');
$this->migrator->add('pterodactyl.panel_url', $table_exists ? $this->getOldValue('SETTINGS::SYSTEM:PTERODACTYL:URL') : env('PTERODACTYL_URL', ''));
$this->migrator->add('pterodactyl.per_page_limit', $table_exists ? $this->getOldValue('SETTINGS::SYSTEM:PTERODACTYL:PER_PAGE_LIMIT') : 200);
$this->migrator->addEncrypted('pterodactyl.admin_token', $table_exists ? $this->getOldValue('SETTINGS::SYSTEM:PTERODACTYL:TOKEN', '') : env('PTERODACTYL_TOKEN', ''));
$this->migrator->addEncrypted('pterodactyl.user_token', $table_exists ? $this->getOldValue('SETTINGS::SYSTEM:PTERODACTYL:ADMIN_USER_TOKEN', '') : '');
$this->migrator->add('pterodactyl.panel_url', $table_exists ? $this->getOldValue('SETTINGS::SYSTEM:PTERODACTYL:URL', '') : env('PTERODACTYL_URL', ''));
$this->migrator->add('pterodactyl.per_page_limit', $table_exists ? $this->getOldValue('SETTINGS::SYSTEM:PTERODACTYL:PER_PAGE_LIMIT', 200) : 200);
}
public function down(): void
@ -23,76 +22,37 @@ class CreatePterodactylSettings extends SettingsMigration
DB::table('settings_old')->insert([
[
'key' => 'SETTINGS::SYSTEM:PTERODACTYL:TOKEN',
'value' => $this->getNewValue('admin_token'),
'value' => $this->getNewValue('admin_token', 'pterodactyl'),
'type' => 'string',
'description' => 'The admin token for the Pterodactyl panel.',
],
[
'key' => 'SETTINGS::SYSTEM:PTERODACTYL:ADMIN_USER_TOKEN',
'value' => $this->getNewValue('user_token'),
'value' => $this->getNewValue('user_token', 'pterodactyl'),
'type' => 'string',
'description' => 'The user token for the Pterodactyl panel.',
],
[
'key' => 'SETTINGS::SYSTEM:PTERODACTYL:URL',
'value' => $this->getNewValue('panel_url'),
'value' => $this->getNewValue('panel_url', 'pterodactyl'),
'type' => 'string',
'description' => 'The URL for the Pterodactyl panel.',
],
[
'key' => 'SETTINGS::SYSTEM:PTERODACTYL:PER_PAGE_LIMIT',
'value' => $this->getNewValue('per_page_limit'),
'value' => $this->getNewValue('per_page_limit', 'pterodactyl'),
'type' => 'integer',
'description' => 'The number of servers to show per page.',
],
]);
$this->migrator->delete('pterodactyl.admin_token');
$this->migrator->delete('pterodactyl.user_token');
$this->migrator->delete('pterodactyl.panel_url');
$this->migrator->delete('pterodactyl.per_page_limit');
}
public function getNewValue(string $name)
{
$new_value = DB::table('settings')->where([['group', '=', 'pterodactyl'], ['name', '=', $name]])->get(['payload'])->first();
// Some keys returns '""' as a value.
if ($new_value->payload === '""') {
return null;
try {
$this->migrator->delete('pterodactyl.admin_token');
$this->migrator->delete('pterodactyl.user_token');
$this->migrator->delete('pterodactyl.panel_url');
$this->migrator->delete('pterodactyl.per_page_limit');
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}
// remove the quotes from the string
if (substr($new_value->payload, 0, 1) === '"' && substr($new_value->payload, -1) === '"') {
return substr($new_value->payload, 1, -1);
}
return $new_value->payload;
}
public function getOldValue(string $key)
{
// Always get the first value of the key.
$old_value = DB::table('settings_old')->where('key', '=', $key)->get(['value', 'type'])->first();
// Handle the old values to return without it being a string in all cases.
if ($old_value->type === "string" || $old_value->type === "text") {
if (is_null($old_value->value)) {
return '';
}
// Some values have the type string, but their values are boolean.
if ($old_value->value === "false" || $old_value->value === "true") {
return filter_var($old_value->value, FILTER_VALIDATE_BOOL);
}
return $old_value->value;
}
if ($old_value->type === "boolean") {
return filter_var($old_value->value, FILTER_VALIDATE_BOOL);
}
return filter_var($old_value->value, FILTER_VALIDATE_INT);
}
}

View file

@ -1,9 +1,9 @@
<?php
use Spatie\LaravelSettings\Migrations\SettingsMigration;
use App\Classes\LegacySettingsMigration;
use Illuminate\Support\Facades\DB;
class CreateMailSettings extends SettingsMigration
class CreateMailSettings extends LegacySettingsMigration
{
public function up(): void
{
@ -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);
}
}

View file

@ -1,27 +1,27 @@
<?php
use Spatie\LaravelSettings\Migrations\SettingsMigration;
use App\Classes\LegacySettingsMigration;
use Illuminate\Support\Facades\DB;
class CreateUserSettings extends SettingsMigration
class CreateUserSettings extends LegacySettingsMigration
{
public function up(): void
{
$table_exists = DB::table('settings_old')->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);
}
}

View file

@ -1,18 +1,18 @@
<?php
use Spatie\LaravelSettings\Migrations\SettingsMigration;
use App\Classes\LegacySettingsMigration;
use Illuminate\Support\Facades\DB;
class CreateServerSettings extends SettingsMigration
class CreateServerSettings extends LegacySettingsMigration
{
public function up(): void
{
$table_exists = DB::table('settings_old')->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);
}
}

View file

@ -1,23 +1,23 @@
<?php
use Spatie\LaravelSettings\Migrations\SettingsMigration;
use App\Classes\LegacySettingsMigration;
use Illuminate\Support\Facades\DB;
class CreateInvoiceSettings extends SettingsMigration
class CreateInvoiceSettings extends LegacySettingsMigration
{
public function up(): void
{
$table_exists = DB::table('settings_old')->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);
}
}

View file

@ -1,21 +1,21 @@
<?php
use Spatie\LaravelSettings\Migrations\SettingsMigration;
use App\Classes\LegacySettingsMigration;
use Illuminate\Support\Facades\DB;
class CreateDiscordSettings extends SettingsMigration
class CreateDiscordSettings extends LegacySettingsMigration
{
public function up(): void
{
$table_exists = DB::table('settings_old')->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);
}
}

View file

@ -1,9 +1,9 @@
<?php
use Spatie\LaravelSettings\Migrations\SettingsMigration;
use App\Classes\LegacySettingsMigration;
use Illuminate\Support\Facades\DB;
class CreateLocaleSettings extends SettingsMigration
class CreateLocaleSettings extends LegacySettingsMigration
{
public function up(): void
{
@ -11,10 +11,10 @@ class CreateLocaleSettings extends SettingsMigration
// Get the user-set configuration values from the old table.
$this->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);
}
}

View file

@ -1,20 +1,20 @@
<?php
use Spatie\LaravelSettings\Migrations\SettingsMigration;
use App\Classes\LegacySettingsMigration;
use Illuminate\Support\Facades\DB;
class CreateReferralSettings extends SettingsMigration
class CreateReferralSettings extends LegacySettingsMigration
{
public function up(): void
{
$table_exists = DB::table('settings_old')->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);
}
}

View file

@ -1,27 +1,28 @@
<?php
use Spatie\LaravelSettings\Migrations\SettingsMigration;
use App\Classes\LegacySettingsMigration;
use Illuminate\Support\Facades\DB;
class CreateWebsiteSettings extends SettingsMigration
class CreateWebsiteSettings extends LegacySettingsMigration
{
public function up(): void
{
$table_exists = DB::table('settings_old')->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") :
"<h1 style='text-align: center;'><img style='display: block; margin-left: auto; margin-right: auto;' src='https://ctrlpanel.gg/img/controlpanel.png' alt=' width='200' height='200'><span style='font-size: 36pt;'>CtrlPanel.gg</span></h1>
<p><span style='font-size: 18pt;'>Thank you for using our Software</span></p>
<p><span style='font-size: 18pt;'>If you have any questions, make sure to join our <a href='https://discord.com/invite/4Y6HjD2uyU' target='_blank' rel='noopener'>Discord</a></span></p>
<p><span style='font-size: 10pt;'>(you can change this message in the <a href='admin/settings#system'>Settings</a> )</span></p>");
$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);
<p><span style='font-size: 10pt;'>(you can change this message in the <a href='admin/settings#system'>Settings</a> )</span></p>"
);
$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);
}
}

View file

@ -1,9 +1,9 @@
<?php
use Spatie\LaravelSettings\Migrations\SettingsMigration;
use App\Classes\LegacySettingsMigration;
use Illuminate\Support\Facades\DB;
class CreateTicketSettings extends SettingsMigration
class CreateTicketSettings extends LegacySettingsMigration
{
public function up(): void
{
@ -19,67 +19,23 @@ class CreateTicketSettings extends SettingsMigration
DB::table('settings_old')->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);
}
}

View file

@ -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');
}
};

View file

@ -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:

View file

@ -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

View file

@ -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() . " <br>Please check the installer.log file in /var/www/controlpanel/storage/logs !");
}
}

View file

@ -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':

View file

@ -34,6 +34,7 @@ use App\Http\Controllers\TicketsController;
use App\Http\Controllers\TranslationController;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Route;
/*
@ -77,11 +78,13 @@ Route::middleware(['auth', 'checkSuspended'])->group(function () {
Route::patch('/servers/cancel/{server}', [ServerController::class, 'cancel'])->name('servers.cancel');
Route::resource('servers', ServerController::class);
if (config('app.key')) {
try {
$serverSettings = app(App\Settings\ServerSettings::class);
if ($serverSettings->enable_upgrade) {
if ($serverSettings->creation_enabled) {
Route::post('servers/{server}/upgrade', [ServerController::class, 'upgrade'])->name('servers.upgrade');
}
} catch (Exception $e) {
Log::error("ServerSettings not found, skipping server upgrade route");
}
Route::post('profile/selfdestruct', [ProfileController::class, 'selfDestroyUser'])->name('profile.selfDestroyUser');

BIN
storage/app/public/logo.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 94 KiB

After

Width:  |  Height:  |  Size: 95 KiB

View file

@ -1,12 +0,0 @@
[
{
"PASSWORD": "",
"USERNAME": "",
"AUTO_UPDATE": "0",
"BOT_PY_FILE": "bot.py",
"PY_PACKAGES": "",
"USER_UPLOAD": "0",
"INSTALL_REPO": "",
"INSTALL_BRANCH": ""
}
]

View file

@ -43,7 +43,7 @@
class="mr-2 fas fa-link"></i> {{__('Documentation')}}</a>
</div>
<div class="col-md-3">
<a href="https://github.com/ControlPanel-gg/dashboard" class="px-3 btn btn-dark btn-block"><i
<a href="https://github.com/Ctrlpanel-gg/panel" class="px-3 btn btn-dark btn-block"><i
class="mr-2 fab fa-github"></i> {{__('Github')}}</a>
</div>
<div class="col-md-3">

View file

@ -49,8 +49,8 @@
Service or from the Service infrastructure itself (for example, the duration of a page visit).</p>
</li>
<li>
<p><strong>Website</strong> refers to CtrlPanel, accessible from <a href="controlpanel"
rel="external nofollow noopener" target="_blank">controlpanel</a></p>
<p><strong>Website</strong> refers to CtrlPanel, accessible from <a href="ctrlpanel"
rel="external nofollow noopener" target="_blank">ctrlpanel</a></p>
</li>
<li>
<p><strong>You</strong> means the individual accessing or using the Service, or the company, or other legal

View file

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