Browse Source

remove encryption to continue working // FIX INSTALLER [value] -> [payload]

1day2die 2 năm trước cách đây
mục cha
commit
0bde32bd2f

+ 1 - 6
app/Extensions/PaymentGateways/Mollie/MollieSettings.php

@@ -15,12 +15,7 @@ class MollieSettings extends Settings
         return 'mollie';
     }
 
-    public static function encrypted(): array
-    {
-        return [
-            'api_key',
-        ];
-    }
+
 
     public static function getOptionInputData()
     {

+ 1 - 1
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->addEncrypted('mollie.api_key', null);
+        $this->migrator->add('mollie.api_key', null);
         $this->migrator->add('mollie.enabled', false);
     }
 

+ 1 - 9
app/Extensions/PaymentGateways/PayPal/PayPalSettings.php

@@ -18,15 +18,7 @@ class PayPalSettings extends Settings
     }
 
 
-    public static function encrypted(): array
-    {
-        return [
-            'client_id',
-            'client_secret',
-            'sandbox_client_id',
-            'sandbox_client_secret'
-        ];
-    }
+
 
     /**
      * Summary of optionInputData array

+ 4 - 4
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->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.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->add('paypal.enabled', false);
     }
 

+ 1 - 9
app/Extensions/PaymentGateways/Stripe/StripeSettings.php

@@ -19,15 +19,7 @@ class StripeSettings extends Settings
         return 'stripe';
     }
 
-    public static function encrypted(): array
-    {
-        return [
-            "secret_key",
-            "endpoint_secret",
-            "test_secret_key",
-            "test_endpoint_secret"
-        ];
-    }
+
 
     public static function getOptionInputData()
     {

+ 4 - 4
app/Extensions/PaymentGateways/Stripe/migrations/2023_03_04_181917_create_stripe_settings.php

@@ -9,10 +9,10 @@ class CreateStripeSettings extends SettingsMigration
     {
         $table_exists = DB::table('settings_old')->exists();
 
-        $this->migrator->addEncrypted('stripe.secret_key', $table_exists ? $this->getOldValue('SETTINGS::PAYMENTS:STRIPE:SECRET') : null);
-        $this->migrator->addEncrypted('stripe.endpoint_secret', $table_exists ? $this->getOldValue('SETTINGS::PAYMENTS:STRIPE:ENDPOINT_SECRET') : null);
-        $this->migrator->addEncrypted('stripe.test_secret_key', $table_exists ? $this->getOldValue('SETTINGS::PAYMENTS:STRIPE:TEST_SECRET') : null);
-        $this->migrator->addEncrypted('stripe.test_endpoint_secret', $table_exists ? $this->getOldValue('SETTINGS::PAYMENTS:STRIPE:ENDPOINT_TEST_SECRET') : null);
+        $this->migrator->add('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->add('stripe.test_endpoint_secret', $table_exists ? $this->getOldValue('SETTINGS::PAYMENTS:STRIPE:ENDPOINT_TEST_SECRET') : null);
         $this->migrator->add('stripe.enabled', false);
     }
 

+ 1 - 8
app/Settings/DiscordSettings.php

@@ -18,14 +18,7 @@ class DiscordSettings extends Settings
         return 'discord';
     }
 
-    public static function encrypted(): array
-    {
-        return [
-            'bot_token',
-            'client_id',
-            'client_secret'
-        ];
-    }
+
 
     /**
      * Summary of validations array

+ 1 - 7
app/Settings/GeneralSettings.php

@@ -24,13 +24,7 @@ class GeneralSettings extends Settings
         return 'general';
     }
 
-    public static function encrypted(): array
-    {
-        return [
-            'recaptcha_site_key',
-            'recaptcha_secret_key'
-        ];
-    }
+
 
     /**
      * Summary of validations array

+ 1 - 6
app/Settings/MailSettings.php

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

+ 1 - 7
app/Settings/PterodactylSettings.php

@@ -16,13 +16,7 @@ class PterodactylSettings extends Settings
         return 'pterodactyl';
     }
 
-    public static function encrypted(): array
-    {
-        return [
-            'admin_token',
-            'user_token'
-        ];
-    }
+
 
     /**
      * Get url with ensured ending backslash

+ 2 - 2
database/settings/2023_02_01_164731_create_general_settings.php

@@ -12,8 +12,8 @@ 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->addEncrypted('general.recaptcha_site_key', $table_exists ? $this->getOldValue("SETTINGS::RECAPTCHA:SITE_KEY") : env('RECAPTCHA_SITE_KEY', '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI'));
-        $this->migrator->addEncrypted('general.recaptcha_secret_key', $table_exists ? $this->getOldValue("SETTINGS::RECAPTCHA:SECRET_KEY") : env('RECAPTCHA_SECRET_KEY', '6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe'));
+        $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);

+ 2 - 2
database/settings/2023_02_01_181334_create_pterodactyl_settings.php

@@ -10,8 +10,8 @@ class CreatePterodactylSettings extends SettingsMigration
         $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.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);
     }

+ 1 - 1
database/settings/2023_02_01_181453_create_mail_settings.php

@@ -13,7 +13,7 @@ class CreateMailSettings extends SettingsMigration
         $this->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->addEncrypted('mail.mail_password', $table_exists ? $this->getOldValue('SETTINGS::MAIL:PASSWORD') : env('MAIL_PASSWORD', ''));
+        $this->migrator->add('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', 'ControlPanel.gg'));

+ 3 - 3
database/settings/2023_02_01_182043_create_discord_settings.php

@@ -10,9 +10,9 @@ class CreateDiscordSettings extends SettingsMigration
         $table_exists = DB::table('settings_old')->exists();
 
         // Get the user-set configuration values from the old table.
-        $this->migrator->addEncrypted('discord.bot_token', $table_exists ? $this->getOldValue('SETTINGS::DISCORD:BOT_TOKEN') : '');
-        $this->migrator->addEncrypted('discord.client_id', $table_exists ? $this->getOldValue('SETTINGS::DISCORD:CLIENT_ID') : '');
-        $this->migrator->addEncrypted('discord.client_secret', $table_exists ? $this->getOldValue('SETTINGS::DISCORD:CLIENT_SECRET') : '');
+        $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') : '');

+ 10 - 9
public/install/forms.php

@@ -1,5 +1,6 @@
 <?php
 
+
 use PHPMailer\PHPMailer\Exception;
 use PHPMailer\PHPMailer\PHPMailer;
 
@@ -32,7 +33,7 @@ if (isset($_POST['checkDB'])) {
         header('LOCATION: index.php?step=2&message=' . $e->getMessage());
         exit();
     }
-    
+
 
     foreach ($values as $key => $value) {
         $param = $_POST[$value];
@@ -131,7 +132,7 @@ if (isset($_POST['checkSMTP'])) {
         'mail_host' => $_POST['host'],
         'mail_port' => $_POST['port'],
         'mail_username' => $_POST['user'],
-        'mail_password' => encryptSettingsValue($_POST['pass']),
+        'mail_password' => $_POST['pass'],
         'mail_encryption' => $_POST['encryption'],
         'mail_from_address' => $_POST['user'],
     ];
@@ -196,8 +197,8 @@ if (isset($_POST['checkPtero'])) {
         wh_log('Pterodactyl Settings are correct', 'debug');
         wh_log('Updating Database', 'debug');
 
-        $key = encryptSettingsValue($key);
-        $clientkey = encryptSettingsValue($clientkey);
+        $key = $key;
+        $clientkey = $clientkey;
 
         $query1 = 'UPDATE `' . getenv('DB_DATABASE') . "`.`settings` SET `payload` = '" . json_encode($url) . "' WHERE (`name` = 'panel_url' AND `group` = 'pterodactyl')";
         $query2 = 'UPDATE `' . getenv('DB_DATABASE') . "`.`settings` SET `payload` = '" . json_encode($key) . "' WHERE (`name` = 'admin_token' AND `group` = 'pterodactyl')";
@@ -234,10 +235,10 @@ if (isset($_POST['createUser'])) {
     $repass = $_POST['repass'];
 
     $key = $db->query('SELECT `payload` FROM `' . getenv('DB_DATABASE') . "`.`settings` WHERE `name` = 'admin_token' AND `group` = 'pterodactyl'")->fetch_assoc();
-    $key = encryptSettingsValue($key['value']);
+    $key = removeQuotes($key['payload']);
     $pterobaseurl = $db->query('SELECT `payload` FROM `' . getenv('DB_DATABASE') . "`.`settings` WHERE `name` = 'panel_url' AND `group` = 'pterodactyl'")->fetch_assoc();
 
-    $pteroURL = $pterobaseurl['value'] . '/api/application/users/' . $pteroID;
+    $pteroURL = removeQuotes($pterobaseurl['payload']) . '/api/application/users/' . $pteroID;
     $ch = curl_init();
 
     curl_setopt($ch, CURLOPT_URL, $pteroURL);
@@ -264,7 +265,7 @@ if (isset($_POST['createUser'])) {
     $name = $result['attributes']['username'];
     $pass = password_hash($pass, PASSWORD_DEFAULT);
 
-    $pteroURL = $pterobaseurl['value'] . '/api/application/users/' . $pteroID;
+    $pteroURL = removeQuotes($pterobaseurl['payload']) . '/api/application/users/' . $pteroID;
     $ch = curl_init();
 
     curl_setopt($ch, CURLOPT_URL, $pteroURL);
@@ -272,7 +273,7 @@ if (isset($_POST['createUser'])) {
     curl_setopt($ch, CURLOPT_HTTPHEADER, [
         'Accept: application/json',
         'Content-Type: application/json',
-        'Authorization: Bearer ' . $key['value'],
+        'Authorization: Bearer ' . $key,
     ]);
     curl_setopt($ch, CURLOPT_POSTFIELDS, [
         'email' => $mail,
@@ -300,4 +301,4 @@ if (isset($_POST['createUser'])) {
         wh_log($db->error, 'error');
         header('LOCATION: index.php?step=6&message=Something went wrong when communicating with the Database');
     }
-}
+}

+ 4 - 0
public/install/functions.php

@@ -150,6 +150,10 @@ function checkExtensions(): array
     return $not_ok;
 }
 
+function removeQuotes($string){
+    return str_replace('"', "", $string);
+}
+
 /**
  * Sets the environment variable into the env file
  * @param string $envKey The environment key to set or modify