From 1678fa0a49f0297050e30c4d5328cebca7bcfdc0 Mon Sep 17 00:00:00 2001 From: Bozhidar Date: Fri, 10 May 2024 19:56:58 +0300 Subject: [PATCH] update --- web/app/Models/Backup.php | 7 ++++--- web/app/Models/Database.php | 9 +++++---- web/app/Models/DatabaseUser.php | 9 +++++---- web/app/Models/HostingSubscriptionBackup.php | 5 +++-- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/web/app/Models/Backup.php b/web/app/Models/Backup.php index 64bf845..51f6882 100644 --- a/web/app/Models/Backup.php +++ b/web/app/Models/Backup.php @@ -5,6 +5,7 @@ namespace App\Models; use App\BackupStorage; use App\Filament\Enums\BackupStatus; use App\Helpers; +use App\PhyreConfig; use App\ShellApi; use Dotenv\Dotenv; use Illuminate\Database\Eloquent\Factories\HasFactory; @@ -213,11 +214,11 @@ class Backup extends Model // Export Phyre Panel database $mysqlAuthConf = '/root/.phyre-mysql.cnf'; $mysqlAuthContent = '[client]' . PHP_EOL; - $mysqlAuthContent .= 'user="' . env('MYSQL_ROOT_USERNAME') .'"'. PHP_EOL; - $mysqlAuthContent .= 'password="' . env('MYSQL_ROOT_PASSWORD') . '"' . PHP_EOL; + $mysqlAuthContent .= 'user="' . PhyreConfig::get('MYSQL_ROOT_USERNAME') .'"'. PHP_EOL; + $mysqlAuthContent .= 'password="' . PhyreConfig::get('MYSQL_ROOT_PASSWORD') . '"' . PHP_EOL; file_put_contents($mysqlAuthConf, $mysqlAuthContent); - $shellFileContent .= 'mysqldump --defaults-extra-file='.$mysqlAuthConf.' "'.env('DB_DATABASE').'" > '.$databaseBackupPath . PHP_EOL; + $shellFileContent .= 'mysqldump --defaults-extra-file='.$mysqlAuthConf.' "'.PhyreConfig::get('DB_DATABASE').'" > '.$databaseBackupPath . PHP_EOL; // Export Phyre Panel Database $database = []; diff --git a/web/app/Models/Database.php b/web/app/Models/Database.php index c32ae60..b616107 100644 --- a/web/app/Models/Database.php +++ b/web/app/Models/Database.php @@ -2,6 +2,7 @@ namespace App\Models; +use App\PhyreConfig; use App\Services\RemoteDatabaseService; use App\UniversalDatabaseExecutor; use Illuminate\Database\Eloquent\Factories\HasFactory; @@ -60,10 +61,10 @@ class Database extends Model } else { $universalDatabaseExecutor = new UniversalDatabaseExecutor( - env('MYSQL_HOST'), - env('MYSQL_PORT'), - env('MYSQL_ROOT_USERNAME'), - env('MYSQL_ROOT_PASSWORD'), + PhyreConfig::get('MYSQL_HOST'), + PhyreConfig::get('MYSQL_PORT'), + PhyreConfig::get('MYSQL_ROOT_USERNAME'), + PhyreConfig::get('MYSQL_ROOT_PASSWORD'), ); $createDatabase = $universalDatabaseExecutor->createDatabase($databaseName); if (isset($createDatabase['error'])) { diff --git a/web/app/Models/DatabaseUser.php b/web/app/Models/DatabaseUser.php index 89fc62c..50ebb14 100644 --- a/web/app/Models/DatabaseUser.php +++ b/web/app/Models/DatabaseUser.php @@ -2,6 +2,7 @@ namespace App\Models; +use App\PhyreConfig; use App\UniversalDatabaseExecutor; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; @@ -56,10 +57,10 @@ class DatabaseUser extends Model } } else { $universalDatabaseExecutor = new UniversalDatabaseExecutor( - env('MYSQL_HOST'), - env('MYSQL_PORT'), - env('MYSQL_ROOT_USERNAME'), - env('MYSQL_ROOT_PASSWORD'), + PhyreConfig::get('MYSQL_HOST'), + PhyreConfig::get('MYSQL_PORT'), + PhyreConfig::get('MYSQL_ROOT_USERNAME'), + PhyreConfig::get('MYSQL_ROOT_PASSWORD'), $findDatabase->database_name_prefix . $findDatabase->database_name ); $createDatabase = $universalDatabaseExecutor->createUser($databaseUsername, $model->password); diff --git a/web/app/Models/HostingSubscriptionBackup.php b/web/app/Models/HostingSubscriptionBackup.php index 9b8dc49..a7e1b2a 100644 --- a/web/app/Models/HostingSubscriptionBackup.php +++ b/web/app/Models/HostingSubscriptionBackup.php @@ -6,6 +6,7 @@ use App\BackupStorage; use App\Filament\Enums\BackupStatus; use App\Helpers; use App\Jobs\ProcessHostingSubscriptionBackup; +use App\PhyreConfig; use App\ShellApi; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Casts\Attribute; @@ -202,8 +203,8 @@ class HostingSubscriptionBackup extends Model // Export Phyre Panel database $mysqlAuthConf = '/root/.phyre-mysql.cnf'; $mysqlAuthContent = '[client]' . PHP_EOL; - $mysqlAuthContent .= 'user="' . env('MYSQL_ROOT_USERNAME') .'"'. PHP_EOL; - $mysqlAuthContent .= 'password="' . env('MYSQL_ROOT_PASSWORD') . '"' . PHP_EOL; + $mysqlAuthContent .= 'user="' . PhyreConfig::get('MYSQL_ROOT_USERNAME') .'"'. PHP_EOL; + $mysqlAuthContent .= 'password="' . PhyreConfig::get('MYSQL_ROOT_PASSWORD') . '"' . PHP_EOL; file_put_contents($mysqlAuthConf, $mysqlAuthContent); $getDatabases = Database::where('hosting_subscription_id', $findHostingSubscription->id)