From 67cd7ec58b3998442c53393426d13594b93902a7 Mon Sep 17 00:00:00 2001 From: Bozhidar Slaveykov Date: Sat, 6 Apr 2024 16:01:46 +0300 Subject: [PATCH] update --- .../Controllers/LetsEncryptController.php | 1 - .../Providers/LetsEncryptServiceProvider.php | 3 +- .../App/Providers/RouteServiceProvider.php | 2 +- .../LetsEncryptApacheVirtualHostConfig.php | 3 +- .../HostingAccountIsCreatedListener.php | 21 +++-- .../Providers/Filament/AdminPanelProvider.php | 4 +- .../Http/Controllers/MicroweberController.php | 1 - .../App/Models/MicroweberInstallation.php | 5 +- .../Providers/MicroweberServiceProvider.php | 5 +- .../App/Providers/RouteServiceProvider.php | 2 +- .../Clusters/Microweber/Pages/Settings.php | 7 +- .../Clusters/Microweber/Pages/Version.php | 22 +++--- .../Clusters/Microweber/Pages/Whitelabel.php | 10 +-- .../Resources/InstallationResource.php | 14 ++-- .../Pages/CreateInstallation.php | 1 - .../Pages/EditInstallation.php | 2 +- .../Pages/ListInstallations.php | 8 +- .../Filament/Clusters/MicroweberCluster.php | 1 - .../Listeners/DomainIsCreatedListener.php | 51 ++++++------ .../MicroweberApacheVirtualHostConfig.php | 3 +- .../Providers/Filament/AdminPanelProvider.php | 4 +- .../Shell/Adapters/PhyreShellExecutor.php | 16 ++-- web/Modules/Microweber/config/config.php | 8 +- .../ApacheWebsiteApplySSLVirtualHost.php | 11 ++- web/app/Actions/ApacheWebsiteCreate.php | 60 +++++++------- web/app/Actions/ApacheWebsiteDelete.php | 9 +-- web/app/Actions/CreateLinuxUser.php | 5 +- web/app/Actions/CreateLinuxWebUser.php | 4 +- web/app/ApiClient.php | 2 +- .../Commands/ApachePingWebsitesWithCurl.php | 4 +- web/app/Events/HostingAccountIsCreated.php | 3 - web/app/Events/ModelCustomerCreated.php | 3 - web/app/Events/ModelCustomerDeleting.php | 4 +- web/app/Events/ModelDomainCreated.php | 3 - web/app/Events/ModelDomainDeleting.php | 4 +- .../ModelHostingSubscriptionCreated.php | 4 +- .../ModelHostingSubscriptionDeleting.php | 4 +- web/app/Filament/Pages/Modules.php | 38 +++++---- web/app/Filament/Pages/Settings/Settings.php | 2 +- web/app/Filament/Resources/BackupResource.php | 4 - .../BackupResource/Pages/CreateBackup.php | 1 - .../Filament/Resources/CronJobResource.php | 3 - .../CronJobResource/Pages/CreateCronJob.php | 1 - .../Filament/Resources/CustomerResource.php | 12 +-- .../CustomerResource/Pages/CreateCustomer.php | 1 - .../CustomerResource/Pages/EditCustomer.php | 2 +- .../Pages/ManageCustomers.php | 1 - web/app/Filament/Resources/DomainResource.php | 26 +++---- .../DomainResource/Pages/CreateWebsite.php | 1 - .../DomainResource/Pages/EditWebsite.php | 2 +- .../DomainResource/Pages/ViewWebsite.php | 2 - .../Resources/HostingPlanResource.php | 6 +- .../Pages/CreateHostingPlan.php | 1 - .../Resources/HostingSubscriptionResource.php | 44 +++++------ .../Pages/CreateHostingSubscription.php | 2 - .../Pages/ManageHostingSubscriptions.php | 1 - web/app/Filament/Resources/UserResource.php | 3 - .../UserResource/Pages/CreateUser.php | 1 - web/app/Filament/Widgets/CustomersCount.php | 20 +++-- .../Widgets/ServerDiskUsageStatistic.php | 7 -- .../Widgets/ServerMemoryStatistic.php | 7 -- .../Widgets/ServerMemoryStatisticCount.php | 3 - web/app/Filament/Widgets/Websites.php | 9 +-- web/app/FileManagerApi.php | 4 +- .../Controllers/Api/CustomersController.php | 16 ++-- .../Http/Controllers/Api/HealthController.php | 6 +- .../Api/HostingPlansController.php | 14 +++- .../Api/HostingSubscriptionsController.php | 11 +-- .../Api/Request/AuthLoginRequest.php | 2 +- .../Api/Request/CustomerCreateRequest.php | 3 +- web/app/Http/Controllers/ApiController.php | 5 +- .../Listeners/ModelDomainCreatedListener.php | 17 ++-- .../Listeners/ModelDomainDeletingListener.php | 4 +- ...odelHostingSubscriptionCreatedListener.php | 14 ++-- ...delHostingSubscriptionDeletingListener.php | 8 +- web/app/Livewire/Installer.php | 4 +- web/app/Models/Backup.php | 1 - web/app/Models/CronJob.php | 9 +-- web/app/Models/Customer.php | 2 - web/app/Models/Domain.php | 3 - web/app/Models/DomainSslCertificate.php | 1 - web/app/Models/HostingDatabase.php | 5 +- web/app/Models/HostingPlan.php | 1 - web/app/Models/HostingSubscription.php | 3 +- web/app/Models/User.php | 2 +- web/app/PhyreLaravelApplication.php | 5 +- web/app/Policies/CustomerPolicy.php | 18 +++-- web/app/Providers/AppServiceProvider.php | 20 ++--- .../Providers/Filament/AdminPanelProvider.php | 14 ++-- web/app/Settings.php | 3 +- web/app/ShellApi.php | 16 ++-- web/app/Statistics/ServerStatistic.php | 44 +++++------ .../ApacheVirtualHostConfigBase.php | 1 - .../VirtualHosts/ApacheVirtualHostManager.php | 7 +- web/composer.json | 2 +- web/composer.lock | 2 +- web/config/database.php | 14 ++-- web/config/filament-authentication-log.php | 78 +++++++++---------- ...1_create_domain_ssl_certificates_table.php | 1 - web/database/seeders/DatabaseSeeder.php | 6 +- web/public/index.php | 1 + web/routes/api.php | 3 - web/routes/web.php | 16 ---- 103 files changed, 383 insertions(+), 517 deletions(-) diff --git a/web/Modules/LetsEncrypt/App/Http/Controllers/LetsEncryptController.php b/web/Modules/LetsEncrypt/App/Http/Controllers/LetsEncryptController.php index 6aa5e36..b091ae9 100644 --- a/web/Modules/LetsEncrypt/App/Http/Controllers/LetsEncryptController.php +++ b/web/Modules/LetsEncrypt/App/Http/Controllers/LetsEncryptController.php @@ -5,7 +5,6 @@ namespace Modules\LetsEncrypt\App\Http\Controllers; use App\Http\Controllers\Controller; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Http\Response; class LetsEncryptController extends Controller { diff --git a/web/Modules/LetsEncrypt/App/Providers/LetsEncryptServiceProvider.php b/web/Modules/LetsEncrypt/App/Providers/LetsEncryptServiceProvider.php index 04a09e2..1d0a6d6 100644 --- a/web/Modules/LetsEncrypt/App/Providers/LetsEncryptServiceProvider.php +++ b/web/Modules/LetsEncrypt/App/Providers/LetsEncryptServiceProvider.php @@ -28,7 +28,7 @@ class LetsEncryptServiceProvider extends ServiceProvider $this->registerViews(); $this->loadMigrationsFrom(module_path($this->moduleName, 'Database/migrations')); - // Event::listen(HostingAccountIsCreated::class,HostingAccountIsCreatedListener::class); + // Event::listen(HostingAccountIsCreated::class,HostingAccountIsCreatedListener::class); } /** @@ -39,7 +39,6 @@ class LetsEncryptServiceProvider extends ServiceProvider $this->app->register(RouteServiceProvider::class); $this->app->register(AdminPanelProvider::class); - app()->virtualHostManager->registerConfig(LetsEncryptApacheVirtualHostConfig::class, $this->moduleNameLower); } diff --git a/web/Modules/LetsEncrypt/App/Providers/RouteServiceProvider.php b/web/Modules/LetsEncrypt/App/Providers/RouteServiceProvider.php index 5e9f4c2..49d1587 100644 --- a/web/Modules/LetsEncrypt/App/Providers/RouteServiceProvider.php +++ b/web/Modules/LetsEncrypt/App/Providers/RouteServiceProvider.php @@ -2,8 +2,8 @@ namespace Modules\LetsEncrypt\App\Providers; -use Illuminate\Support\Facades\Route; use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; +use Illuminate\Support\Facades\Route; class RouteServiceProvider extends ServiceProvider { diff --git a/web/Modules/LetsEncrypt/LetsEncryptApacheVirtualHostConfig.php b/web/Modules/LetsEncrypt/LetsEncryptApacheVirtualHostConfig.php index 5f7b3a5..95736af 100644 --- a/web/Modules/LetsEncrypt/LetsEncryptApacheVirtualHostConfig.php +++ b/web/Modules/LetsEncrypt/LetsEncryptApacheVirtualHostConfig.php @@ -7,7 +7,6 @@ use App\VirtualHosts\ApacheVirtualHostConfigBase; class LetsEncryptApacheVirtualHostConfig extends ApacheVirtualHostConfigBase { public array $phpAdminValueOpenBaseDirs = [ - '/usr/share/letsencrypt' + '/usr/share/letsencrypt', ]; - } diff --git a/web/Modules/LetsEncrypt/Listeners/HostingAccountIsCreatedListener.php b/web/Modules/LetsEncrypt/Listeners/HostingAccountIsCreatedListener.php index e4113af..fdb8d0b 100644 --- a/web/Modules/LetsEncrypt/Listeners/HostingAccountIsCreatedListener.php +++ b/web/Modules/LetsEncrypt/Listeners/HostingAccountIsCreatedListener.php @@ -6,8 +6,8 @@ use App\Actions\ApacheWebsiteApplySSLVirtualHost; use App\ApiClient; use App\Events\HostingAccountIsCreated; use App\FileManagerApi; -use App\Models\HostingPlan; use App\Models\DomainSslCertificate; +use App\Models\HostingPlan; use App\Settings; use App\ShellApi; @@ -27,16 +27,16 @@ class HostingAccountIsCreatedListener public function handle(HostingAccountIsCreated $event): void { $findWebsite = \App\Models\Domain::where('id', $event->model->id)->first(); - if (!$findWebsite) { + if (! $findWebsite) { return; } $findHostingPlan = HostingPlan::where('id', $findWebsite->hosting_plan_id)->first(); - if (!$findHostingPlan) { + if (! $findHostingPlan) { return; } - if (!in_array('letsencrypt', $findHostingPlan->additional_services)) { + if (! in_array('letsencrypt', $findHostingPlan->additional_services)) { return; } @@ -53,13 +53,13 @@ class HostingAccountIsCreatedListener ])->render(); $fmApi = new FileManagerApi(); - $fmApi->filePutContents($event->model->domain_root . '/acme-config.yaml', $acmeConfigYaml); + $fmApi->filePutContents($event->model->domain_root.'/acme-config.yaml', $acmeConfigYaml); - $amePHPPharFile = base_path() . '/Modules/LetsEncrypt/Actions/acmephp.phar'; + $amePHPPharFile = base_path().'/Modules/LetsEncrypt/Actions/acmephp.phar'; $phyrePHP = ApiClient::getPhyrePHP(); - $command = $phyrePHP . ' ' . $amePHPPharFile . ' run ' . $event->model->domain_root . '/acme-config.yaml'; + $command = $phyrePHP.' '.$amePHPPharFile.' run '.$event->model->domain_root.'/acme-config.yaml'; ShellApi::exec($command); $validateCertificates = []; @@ -71,13 +71,13 @@ class HostingAccountIsCreatedListener $sslCertificateKeyFileContent = $fmApi->fileGetContents($sslCertificateKeyFilePath); $sslCertificateChainFileContent = $fmApi->fileGetContents($sslCertificateChainFilePath); - if (!empty($sslCertificateChainFileContent)) { + if (! empty($sslCertificateChainFileContent)) { $validateCertificates['certificate'] = $sslCertificateFileContent; } - if (!empty($sslCertificateKeyFileContent)) { + if (! empty($sslCertificateKeyFileContent)) { $validateCertificates['private_key'] = $sslCertificateKeyFileContent; } - if (!empty($sslCertificateChainFileContent)) { + if (! empty($sslCertificateChainFileContent)) { $validateCertificates['certificate_chain'] = $sslCertificateChainFileContent; } if (count($validateCertificates) !== 3) { @@ -106,6 +106,5 @@ class HostingAccountIsCreatedListener $applySSLVirtualHost->setSslCertificateChainFilePath($sslCertificateChainFilePath); $applySSLVirtualHost->handle(); - } } diff --git a/web/Modules/LetsEncrypt/Providers/Filament/AdminPanelProvider.php b/web/Modules/LetsEncrypt/Providers/Filament/AdminPanelProvider.php index e08d131..c2f7b5b 100644 --- a/web/Modules/LetsEncrypt/Providers/Filament/AdminPanelProvider.php +++ b/web/Modules/LetsEncrypt/Providers/Filament/AdminPanelProvider.php @@ -20,10 +20,12 @@ use Illuminate\View\Middleware\ShareErrorsFromSession; class AdminPanelProvider extends PanelProvider { - private string $module = "LetsEncrypt"; + private string $module = 'LetsEncrypt'; + public function panel(Panel $panel): Panel { $moduleNamespace = $this->getModuleNamespace(); + return $panel ->id('Lets Encrypt ::admin') ->path('admin/modules/letsencrypt') diff --git a/web/Modules/Microweber/App/Http/Controllers/MicroweberController.php b/web/Modules/Microweber/App/Http/Controllers/MicroweberController.php index 686c2b9..a3d999d 100644 --- a/web/Modules/Microweber/App/Http/Controllers/MicroweberController.php +++ b/web/Modules/Microweber/App/Http/Controllers/MicroweberController.php @@ -5,7 +5,6 @@ namespace Modules\Microweber\App\Http\Controllers; use App\Http\Controllers\Controller; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Http\Response; class MicroweberController extends Controller { diff --git a/web/Modules/Microweber/App/Models/MicroweberInstallation.php b/web/Modules/Microweber/App/Models/MicroweberInstallation.php index 846324a..3431f87 100644 --- a/web/Modules/Microweber/App/Models/MicroweberInstallation.php +++ b/web/Modules/Microweber/App/Models/MicroweberInstallation.php @@ -3,18 +3,15 @@ namespace Modules\Microweber\App\Models; use App\Models\Domain; -use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Factories\HasFactory; -use Modules\Microweber\Database\factories\MicroweberInstallationFactory; +use Illuminate\Database\Eloquent\Model; class MicroweberInstallation extends Model { use HasFactory; - public function domain() { return $this->hasOne(Domain::class, 'id', 'domain_id'); } - } diff --git a/web/Modules/Microweber/App/Providers/MicroweberServiceProvider.php b/web/Modules/Microweber/App/Providers/MicroweberServiceProvider.php index ba470aa..d2b768c 100644 --- a/web/Modules/Microweber/App/Providers/MicroweberServiceProvider.php +++ b/web/Modules/Microweber/App/Providers/MicroweberServiceProvider.php @@ -2,12 +2,11 @@ namespace Modules\Microweber\App\Providers; +use App\Events\DomainIsCreated; use Illuminate\Support\Facades\Blade; use Illuminate\Support\Facades\Event; use Illuminate\Support\ServiceProvider; -use App\Events\DomainIsCreated; use Modules\Microweber\Listeners\DomainIsCreatedListener; -use App\VirtualHosts\ApacheVirtualHostManager; use Modules\Microweber\MicroweberApacheVirtualHostConfig; class MicroweberServiceProvider extends ServiceProvider @@ -28,7 +27,7 @@ class MicroweberServiceProvider extends ServiceProvider $this->registerViews(); $this->loadMigrationsFrom(module_path($this->moduleName, 'Database/migrations')); - Event::listen(DomainIsCreated::class,DomainIsCreatedListener::class); + Event::listen(DomainIsCreated::class, DomainIsCreatedListener::class); } /** diff --git a/web/Modules/Microweber/App/Providers/RouteServiceProvider.php b/web/Modules/Microweber/App/Providers/RouteServiceProvider.php index 4b21a63..3550a39 100644 --- a/web/Modules/Microweber/App/Providers/RouteServiceProvider.php +++ b/web/Modules/Microweber/App/Providers/RouteServiceProvider.php @@ -2,8 +2,8 @@ namespace Modules\Microweber\App\Providers; -use Illuminate\Support\Facades\Route; use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; +use Illuminate\Support\Facades\Route; class RouteServiceProvider extends ServiceProvider { diff --git a/web/Modules/Microweber/Filament/Clusters/Microweber/Pages/Settings.php b/web/Modules/Microweber/Filament/Clusters/Microweber/Pages/Settings.php index 6f39d62..873f52b 100644 --- a/web/Modules/Microweber/Filament/Clusters/Microweber/Pages/Settings.php +++ b/web/Modules/Microweber/Filament/Clusters/Microweber/Pages/Settings.php @@ -2,11 +2,8 @@ namespace Modules\Microweber\Filament\Clusters\Microweber\Pages; -use Filament\Forms\Components\Card; -use Filament\Forms\Components\Radio; use Filament\Forms\Components\Section; use Filament\Forms\Components\Select; -use Filament\Forms\Components\Tabs; use Filament\Forms\Components\TextInput; use Modules\Microweber\Filament\Clusters\MicroweberCluster; use Outerweb\FilamentSettings\Filament\Pages\Settings as BaseSettings; @@ -21,7 +18,6 @@ class Settings extends BaseSettings protected static ?int $navigationSort = 3; - public function schema(): array { return [ @@ -71,7 +67,6 @@ class Settings extends BaseSettings ]) ->label('Allow customers to choose installation type'), - Select::make('microweber.allow_customers_to_choose_installation_database_driver') ->options([ 'yes' => 'Yes', @@ -133,6 +128,6 @@ class Settings extends BaseSettings ->label('Allow resellers to use their own White Label'), ]), - ]; + ]; } } diff --git a/web/Modules/Microweber/Filament/Clusters/Microweber/Pages/Version.php b/web/Modules/Microweber/Filament/Clusters/Microweber/Pages/Version.php index 9118327..754a755 100644 --- a/web/Modules/Microweber/Filament/Clusters/Microweber/Pages/Version.php +++ b/web/Modules/Microweber/Filament/Clusters/Microweber/Pages/Version.php @@ -24,12 +24,14 @@ class Version extends Page protected static ?int $navigationSort = 1; public $currentVersionOfApp = 0; + public $latestVersionOfApp = 0; + public $latestDownloadDateOfApp = 0; public $supportedTemplates = []; - public $supportedLanguages = []; + public $supportedLanguages = []; protected function getViewData(): array { @@ -51,7 +53,7 @@ class Version extends Page 'totalAppTemplates' => count($this->supportedTemplates), 'appTemplates' => $this->supportedTemplates, 'supportedLanguages' => $this->supportedLanguages, - 'supportedTemplates' => $this->supportedTemplates + 'supportedTemplates' => $this->supportedTemplates, ]; } @@ -60,12 +62,12 @@ class Version extends Page { $sharedAppPath = config('microweber.sharedPaths.app'); - if (!is_dir(dirname($sharedAppPath))) { + if (! is_dir(dirname($sharedAppPath))) { mkdir(dirname($sharedAppPath)); } $shellPath = '/usr/local/phyre/web/vendor/microweber-packages/shared-server-scripts/shell-scripts'; - ShellApi::exec('chmod +x ' . $shellPath . '/*'); + ShellApi::exec('chmod +x '.$shellPath.'/*'); // Download core app $status = $this->__getMicroweberDownloaderInstance() @@ -88,7 +90,7 @@ class Version extends Page // The module connector must have own instance of composer client $composerClient = new Client(); $composerClient->packageServers = [ - 'https://market.microweberapi.com/packages/microweberserverpackages/packages.json' + 'https://market.microweberapi.com/packages/microweberserverpackages/packages.json', ]; return $composerClient; @@ -97,11 +99,11 @@ class Version extends Page private function __getComposerLicensedInstance() { $composerClientLicensed = new Client(); -// if (Option::getOption('license_key_status', 'whitelabel_license') == 'valid') { -// $composerClientLicensed->addLicense([ -// 'local_key' => Option::getOption('license_key', 'whitelabel_license') -// ]); -// } + // if (Option::getOption('license_key_status', 'whitelabel_license') == 'valid') { + // $composerClientLicensed->addLicense([ + // 'local_key' => Option::getOption('license_key', 'whitelabel_license') + // ]); + // } return $composerClientLicensed; } diff --git a/web/Modules/Microweber/Filament/Clusters/Microweber/Pages/Whitelabel.php b/web/Modules/Microweber/Filament/Clusters/Microweber/Pages/Whitelabel.php index 93e0d57..3358bd6 100644 --- a/web/Modules/Microweber/Filament/Clusters/Microweber/Pages/Whitelabel.php +++ b/web/Modules/Microweber/Filament/Clusters/Microweber/Pages/Whitelabel.php @@ -6,7 +6,6 @@ use Filament\Forms\Components\Checkbox; use Filament\Forms\Components\Section; use Filament\Forms\Components\Textarea; use Filament\Forms\Components\TextInput; -use Filament\Pages\Page; use Modules\Microweber\Filament\Clusters\MicroweberCluster; use Outerweb\FilamentSettings\Filament\Pages\Settings as BaseSettings; @@ -22,13 +21,12 @@ class Whitelabel extends BaseSettings protected static ?string $navigationLabel = 'Whitelabel'; - - public static function getNavigationLabel() : string + public static function getNavigationLabel(): string { return self::$navigationLabel; } - public function getTitle() : string + public function getTitle(): string { return self::$navigationLabel; } @@ -84,12 +82,10 @@ class Whitelabel extends BaseSettings Checkbox::make('microweber.whitelabel.enable_microweber_service_links') ->label('Enable Microweber Service Links'), - Textarea::make('microweber.whitelabel.admin_colors_sass') ->label('Enter "Admin colors" sass'), - - ]) + ]), ]; } } diff --git a/web/Modules/Microweber/Filament/Clusters/Microweber/Resources/InstallationResource.php b/web/Modules/Microweber/Filament/Clusters/Microweber/Resources/InstallationResource.php index cacc76a..6b0418c 100644 --- a/web/Modules/Microweber/Filament/Clusters/Microweber/Resources/InstallationResource.php +++ b/web/Modules/Microweber/Filament/Clusters/Microweber/Resources/InstallationResource.php @@ -2,14 +2,11 @@ namespace Modules\Microweber\Filament\Clusters\Microweber\Resources; -use Modules\Microweber\App\Models\MicroweberInstallation; -use Filament\Forms; use Filament\Forms\Form; use Filament\Resources\Resource; use Filament\Tables; use Filament\Tables\Table; -use Illuminate\Database\Eloquent\Builder; -use Illuminate\Database\Eloquent\SoftDeletingScope; +use Modules\Microweber\App\Models\MicroweberInstallation; use Modules\Microweber\Filament\Clusters\Microweber\Resources\InstallationResource\Pages\ListInstallations; use Modules\Microweber\Filament\Clusters\MicroweberCluster; @@ -27,7 +24,6 @@ class InstallationResource extends Resource protected static ?int $navigationSort = 0; - public static function form(Form $form): Form { return $form @@ -44,9 +40,9 @@ class InstallationResource extends Resource Tables\Columns\TextColumn::make('website.domain')->label('Domain'), Tables\Columns\TextColumn::make('app_version')->label('Version'), Tables\Columns\TextColumn::make('installation_type')->label('Type'), - // Tables\Columns\TextColumn::make('installation_path')->label('Path'), + // Tables\Columns\TextColumn::make('installation_path')->label('Path'), Tables\Columns\TextColumn::make('template')->label('Template'), -// Tables\Columns\TextColumn::make('admin_email')->label('Admin Email'), + // Tables\Columns\TextColumn::make('admin_email')->label('Admin Email'), ]) ->filters([ @@ -73,8 +69,8 @@ class InstallationResource extends Resource { return [ 'index' => ListInstallations::route('/'), -// 'create' => Pages\CreateInstallation::route('/create'), -// 'edit' => Pages\EditInstallation::route('/{record}/edit'), + // 'create' => Pages\CreateInstallation::route('/create'), + // 'edit' => Pages\EditInstallation::route('/{record}/edit'), ]; } } diff --git a/web/Modules/Microweber/Filament/Clusters/Microweber/Resources/InstallationResource/Pages/CreateInstallation.php b/web/Modules/Microweber/Filament/Clusters/Microweber/Resources/InstallationResource/Pages/CreateInstallation.php index 519871e..4dddf3c 100644 --- a/web/Modules/Microweber/Filament/Clusters/Microweber/Resources/InstallationResource/Pages/CreateInstallation.php +++ b/web/Modules/Microweber/Filament/Clusters/Microweber/Resources/InstallationResource/Pages/CreateInstallation.php @@ -2,7 +2,6 @@ namespace Modules\Microweber\Filament\Clusters\Microweber\Resources\InstallationResource\Pages; -use Filament\Actions; use Filament\Resources\Pages\CreateRecord; use Modules\Microweber\Filament\Clusters\Microweber\Resources\InstallationResource; diff --git a/web/Modules/Microweber/Filament/Clusters/Microweber/Resources/InstallationResource/Pages/EditInstallation.php b/web/Modules/Microweber/Filament/Clusters/Microweber/Resources/InstallationResource/Pages/EditInstallation.php index 1c1e429..006be61 100644 --- a/web/Modules/Microweber/Filament/Clusters/Microweber/Resources/InstallationResource/Pages/EditInstallation.php +++ b/web/Modules/Microweber/Filament/Clusters/Microweber/Resources/InstallationResource/Pages/EditInstallation.php @@ -2,9 +2,9 @@ namespace Modules\Microweber\Filament\Clusters\Microweber\Resources\InstallationResource\Pages; -use Modules\Microweber\Filament\Admin\Resources\InstallationResource; use Filament\Actions; use Filament\Resources\Pages\EditRecord; +use Modules\Microweber\Filament\Admin\Resources\InstallationResource; class EditInstallation extends EditRecord { diff --git a/web/Modules/Microweber/Filament/Clusters/Microweber/Resources/InstallationResource/Pages/ListInstallations.php b/web/Modules/Microweber/Filament/Clusters/Microweber/Resources/InstallationResource/Pages/ListInstallations.php index aee5b28..4a21dd0 100644 --- a/web/Modules/Microweber/Filament/Clusters/Microweber/Resources/InstallationResource/Pages/ListInstallations.php +++ b/web/Modules/Microweber/Filament/Clusters/Microweber/Resources/InstallationResource/Pages/ListInstallations.php @@ -17,7 +17,7 @@ class ListInstallations extends ListRecords { return [ Actions\CreateAction::make(), - Actions\Action::make('Scan for installations')->action('scanForInstallations') + Actions\Action::make('Scan for installations')->action('scanForInstallations'), ]; } @@ -31,14 +31,14 @@ class ListInstallations extends ListRecords $installations = $scan->scanRecusrive(); - if (!empty($installations)) { + if (! empty($installations)) { foreach ($installations as $installation) { $findInstallation = MicroweberInstallation::where('installation_path', $installation['path']) ->where('domain_id', $domain->id) ->first(); - if (!$findInstallation) { + if (! $findInstallation) { $findInstallation = new MicroweberInstallation(); $findInstallation->domain_id = $domain->id; $findInstallation->installation_path = $installation['path']; @@ -62,7 +62,7 @@ class ListInstallations extends ListRecords $getAppInstallations = MicroweberInstallation::get(); if ($getAppInstallations != null) { foreach ($getAppInstallations as $appInstallation) { - if (!is_file($appInstallation['installation_path'] . '/config/microweber.php')) { + if (! is_file($appInstallation['installation_path'].'/config/microweber.php')) { $appInstallation->delete(); } } diff --git a/web/Modules/Microweber/Filament/Clusters/MicroweberCluster.php b/web/Modules/Microweber/Filament/Clusters/MicroweberCluster.php index 56ed9d4..5076244 100644 --- a/web/Modules/Microweber/Filament/Clusters/MicroweberCluster.php +++ b/web/Modules/Microweber/Filament/Clusters/MicroweberCluster.php @@ -9,5 +9,4 @@ class MicroweberCluster extends Cluster protected static ?string $navigationIcon = 'heroicon-o-squares-2x2'; protected static ?string $navigationGroup = 'Server Management'; - } diff --git a/web/Modules/Microweber/Listeners/DomainIsCreatedListener.php b/web/Modules/Microweber/Listeners/DomainIsCreatedListener.php index e7a2a88..2e92225 100644 --- a/web/Modules/Microweber/Listeners/DomainIsCreatedListener.php +++ b/web/Modules/Microweber/Listeners/DomainIsCreatedListener.php @@ -6,9 +6,7 @@ use App\Events\DomainIsCreated; use App\Models\Domain; use App\Models\HostingPlan; use App\Models\HostingSubscription; -use App\ShellApi; use Modules\Microweber\App\Models\MicroweberInstallation; -use Psy\Shell; class DomainIsCreatedListener { @@ -26,20 +24,20 @@ class DomainIsCreatedListener public function handle(DomainIsCreated $event): void { $findDomain = Domain::where('id', $event->model->id)->first(); - if (!$findDomain) { + if (! $findDomain) { return; } $findHostingSubscription = HostingSubscription::where('id', $findDomain->hosting_subscription_id)->first(); - if (!$findHostingSubscription) { + if (! $findHostingSubscription) { return; } $findHostingPlan = HostingPlan::where('id', $findHostingSubscription->hosting_plan_id)->first(); - if (!$findHostingPlan) { + if (! $findHostingPlan) { return; } - if (!in_array('microweber', $findHostingPlan->additional_services)) { + if (! in_array('microweber', $findHostingPlan->additional_services)) { return; } @@ -60,7 +58,7 @@ class DomainIsCreatedListener $install->setLanguage($installationLanguage); $install->setTemplate($installationTemplate); - // $install->setStandaloneInstallation(); + // $install->setStandaloneInstallation(); $install->setSymlinkInstallation(); $install->setDatabaseDriver('sqlite'); @@ -68,33 +66,32 @@ class DomainIsCreatedListener $install->setAdminUsername('bojotjo'); $install->setAdminPassword('bojotjo'); - $status = $install->run(); + $status = $install->run(); - if (isset($status['success']) && $status['success']) { + if (isset($status['success']) && $status['success']) { - $findInstallation = MicroweberInstallation::where('installation_path', $findDomain->domain_public) - ->where('domain_id', $findDomain->id) - ->first(); + $findInstallation = MicroweberInstallation::where('installation_path', $findDomain->domain_public) + ->where('domain_id', $findDomain->id) + ->first(); - if (!$findInstallation) { - $findInstallation = new MicroweberInstallation(); - $findInstallation->domain_id = $findDomain->id; - $findInstallation->installation_path = $findDomain->domain_public; - } + if (! $findInstallation) { + $findInstallation = new MicroweberInstallation(); + $findInstallation->domain_id = $findDomain->id; + $findInstallation->installation_path = $findDomain->domain_public; + } - $findInstallation->app_version = 'latest'; - $findInstallation->template = $installationTemplate; + $findInstallation->app_version = 'latest'; + $findInstallation->template = $installationTemplate; - if ($installationType == 'symlink') { - $findInstallation->installation_type = 'symlink'; - } else { - $findInstallation->installation_type = 'standalone'; - } + if ($installationType == 'symlink') { + $findInstallation->installation_type = 'symlink'; + } else { + $findInstallation->installation_type = 'standalone'; + } - $findInstallation->save(); - - } + $findInstallation->save(); + } } } diff --git a/web/Modules/Microweber/MicroweberApacheVirtualHostConfig.php b/web/Modules/Microweber/MicroweberApacheVirtualHostConfig.php index 03e30b3..1af9e97 100644 --- a/web/Modules/Microweber/MicroweberApacheVirtualHostConfig.php +++ b/web/Modules/Microweber/MicroweberApacheVirtualHostConfig.php @@ -7,7 +7,6 @@ use App\VirtualHosts\ApacheVirtualHostConfigBase; class MicroweberApacheVirtualHostConfig extends ApacheVirtualHostConfigBase { public array $phpAdminValueOpenBaseDirs = [ - '/usr/share/microweber' + '/usr/share/microweber', ]; - } diff --git a/web/Modules/Microweber/Providers/Filament/AdminPanelProvider.php b/web/Modules/Microweber/Providers/Filament/AdminPanelProvider.php index e6a346f..2cd5bd4 100644 --- a/web/Modules/Microweber/Providers/Filament/AdminPanelProvider.php +++ b/web/Modules/Microweber/Providers/Filament/AdminPanelProvider.php @@ -20,10 +20,12 @@ use Illuminate\View\Middleware\ShareErrorsFromSession; class AdminPanelProvider extends PanelProvider { - private string $module = "Microweber"; + private string $module = 'Microweber'; + public function panel(Panel $panel): Panel { $moduleNamespace = $this->getModuleNamespace(); + return $panel ->id('microweber::admin') ->path('microweber/admin') diff --git a/web/Modules/Microweber/Shell/Adapters/PhyreShellExecutor.php b/web/Modules/Microweber/Shell/Adapters/PhyreShellExecutor.php index 36ac286..d93a18f 100644 --- a/web/Modules/Microweber/Shell/Adapters/PhyreShellExecutor.php +++ b/web/Modules/Microweber/Shell/Adapters/PhyreShellExecutor.php @@ -1,15 +1,13 @@ $command, -// 'path' => $path, -// 'args' => $args, -// 'commandAsLine' => $commandAsLine -// ]); + // dd([ + // 'command' => $command, + // 'path' => $path, + // 'args' => $args, + // 'commandAsLine' => $commandAsLine + // ]); return ShellApi::exec($commandAsLine); } } diff --git a/web/Modules/Microweber/config/config.php b/web/Modules/Microweber/config/config.php index c49f31a..e0e83dc 100644 --- a/web/Modules/Microweber/config/config.php +++ b/web/Modules/Microweber/config/config.php @@ -2,10 +2,10 @@ return [ 'name' => 'Microweber', - 'sharedPaths'=>[ - 'app'=>'/usr/share/microweber/latest', - 'modules'=>'/usr/share/microweber/latest/userfiles/modules', - 'templates'=>'/usr/share/microweber/latest/userfiles/templates' + 'sharedPaths' => [ + 'app' => '/usr/share/microweber/latest', + 'modules' => '/usr/share/microweber/latest/userfiles/modules', + 'templates' => '/usr/share/microweber/latest/userfiles/templates', ], ]; diff --git a/web/app/Actions/ApacheWebsiteApplySSLVirtualHost.php b/web/app/Actions/ApacheWebsiteApplySSLVirtualHost.php index c69f610..f6c4dfb 100644 --- a/web/app/Actions/ApacheWebsiteApplySSLVirtualHost.php +++ b/web/app/Actions/ApacheWebsiteApplySSLVirtualHost.php @@ -8,12 +8,15 @@ use App\ShellApi; class ApacheWebsiteApplySSLVirtualHost { public $domain; + public $domainRoot; public $domainPublic; public $sslCertificateFilePath; + public $sslCertificateKeyFilePath; + public $sslCertificateChainFilePath; public function setSslCertificateFilePath($sslCertificateFilePath) @@ -49,7 +52,7 @@ class ApacheWebsiteApplySSLVirtualHost public function handle() { $settings = [ - 'port'=> 443, + 'port' => 443, 'domain' => $this->domain, 'domainRoot' => $this->domainRoot, 'domainPublic' => $this->domainPublic, @@ -58,16 +61,16 @@ class ApacheWebsiteApplySSLVirtualHost 'sslCertificateKeyFilePath' => $this->sslCertificateKeyFilePath, 'sslCertificateChainFilePath' => $this->sslCertificateChainFilePath, ]; - $apache2SSLSample = view('actions.samples.ubuntu.apache2-ssl-conf',$settings)->render(); + $apache2SSLSample = view('actions.samples.ubuntu.apache2-ssl-conf', $settings)->render(); $fileManagerApi = new FileManagerApi(); $apache2SSLOptionsSample = view('actions.samples.ubuntu.apache2-ssl-options-conf')->render(); $apache2SSLOptionsFilePath = '/etc/apache2/phyre/options-ssl-apache.conf'; - if (!$fileManagerApi->isDir('/etc/apache2/phyre')) { + if (! $fileManagerApi->isDir('/etc/apache2/phyre')) { $fileManagerApi->mkdir('/etc/apache2/phyre'); } - if (!$fileManagerApi->fileExists($apache2SSLOptionsFilePath)) { + if (! $fileManagerApi->fileExists($apache2SSLOptionsFilePath)) { $fileManagerApi->filePutContents($apache2SSLOptionsFilePath, $apache2SSLOptionsSample); } diff --git a/web/app/Actions/ApacheWebsiteCreate.php b/web/app/Actions/ApacheWebsiteCreate.php index 77c6dad..0f727b5 100644 --- a/web/app/Actions/ApacheWebsiteCreate.php +++ b/web/app/Actions/ApacheWebsiteCreate.php @@ -2,18 +2,20 @@ namespace App\Actions; -use App\FileManagerApi; -use App\ShellApi; -use App\VirtualHosts\ApacheVirtualHostManager; - class ApacheWebsiteCreate { public $domain; + public $user; + public $email; + public $password; + public $isMainDomain = false; + public $additionalServices = []; + public $features = []; public function setDomain($domain) @@ -62,15 +64,15 @@ class ApacheWebsiteCreate } if ($this->isMainDomain) { - $allDomainsRoot = '/home/' . $this->user . '/public_html'; - $domainRoot = '/home/' . $this->user; - $domainPublic = '/home/' . $this->user . '/public_html'; - $homeRoot = '/home/' . $this->user; + $allDomainsRoot = '/home/'.$this->user.'/public_html'; + $domainRoot = '/home/'.$this->user; + $domainPublic = '/home/'.$this->user.'/public_html'; + $homeRoot = '/home/'.$this->user; } else { - $allDomainsRoot = '/home/' . $this->user . '/domains'; - $domainRoot = '/home/' . $this->user . '/domains/' . $this->domain; - $domainPublic = $domainRoot . '/public_html'; - $homeRoot = '/home/' . $this->user; + $allDomainsRoot = '/home/'.$this->user.'/domains'; + $domainRoot = '/home/'.$this->user.'/domains/'.$this->domain; + $domainPublic = $domainRoot.'/public_html'; + $homeRoot = '/home/'.$this->user; } $apacheVirtualHostConfigs = app()->virtualHostManager->getConfigs($this->additionalServices); @@ -89,23 +91,22 @@ class ApacheWebsiteCreate $settings = array_merge($settings, $apacheVirtualHostConfigs); $apache2Sample = view('actions.samples.ubuntu.apache2-conf', $settings)->render(); - if (!is_dir($homeRoot)) { + if (! is_dir($homeRoot)) { mkdir($homeRoot); } - if (!is_dir($allDomainsRoot)) { + if (! is_dir($allDomainsRoot)) { mkdir($allDomainsRoot); } - if (!is_dir($domainRoot)) { + if (! is_dir($domainRoot)) { mkdir($domainRoot); } - if (!is_dir($domainPublic)) { + if (! is_dir($domainPublic)) { mkdir($domainPublic); } shell_exec('chmod -R 775 /etc/apache2/sites-available/'); - file_put_contents('/etc/apache2/sites-available/' . $settings['domain'] . '.conf', $apache2Sample); - + file_put_contents('/etc/apache2/sites-available/'.$settings['domain'].'.conf', $apache2Sample); $indexContent = ' @@ -115,22 +116,21 @@ class ApacheWebsiteCreate '; + file_put_contents($settings['domainPublic'].'/index.php', $indexContent); - file_put_contents($settings['domainPublic'] . '/index.php', $indexContent); + shell_exec('chown -R '.$settings['user'].':'.$settings['group'].' '.$allDomainsRoot); + shell_exec('chown -R '.$settings['user'].':'.$settings['group'].' '.$homeRoot); - shell_exec('chown -R ' . $settings['user'] . ':' . $settings['group'] . ' ' . $allDomainsRoot); - shell_exec('chown -R ' . $settings['user'] . ':' . $settings['group'] . ' ' . $homeRoot); + shell_exec('chown -R '.$settings['user'].':'.$settings['group'].' '.$settings['domainRoot']); + shell_exec('chown -R '.$settings['user'].':'.$settings['group'].' '.$settings['domainPublic']); - shell_exec('chown -R ' . $settings['user'] . ':' . $settings['group'] . ' ' . $settings['domainRoot']); - shell_exec('chown -R ' . $settings['user'] . ':' . $settings['group'] . ' ' . $settings['domainPublic']); + shell_exec('chmod -R 775 '.$allDomainsRoot); + shell_exec('chmod -R 775 '.$homeRoot); - shell_exec('chmod -R 775 ' . $allDomainsRoot); - shell_exec('chmod -R 775 ' . $homeRoot); + shell_exec('chmod -R 775 '.$settings['domainRoot']); + shell_exec('chmod -R 775 '.$settings['domainPublic']); - shell_exec('chmod -R 775 ' . $settings['domainRoot']); - shell_exec('chmod -R 775 ' . $settings['domainPublic']); - - shell_exec('a2ensite ' . $settings['domain'] . '.conf'); + shell_exec('a2ensite '.$settings['domain'].'.conf'); shell_exec('systemctl reload apache2'); return [ @@ -141,7 +141,7 @@ class ApacheWebsiteCreate 'user' => $this->user, 'email' => $this->email, 'linuxUser' => $linuxUser, - 'apache2Sample' => $apache2Sample + 'apache2Sample' => $apache2Sample, ]; } diff --git a/web/app/Actions/ApacheWebsiteDelete.php b/web/app/Actions/ApacheWebsiteDelete.php index 1d97f06..b143411 100644 --- a/web/app/Actions/ApacheWebsiteDelete.php +++ b/web/app/Actions/ApacheWebsiteDelete.php @@ -16,18 +16,17 @@ class ApacheWebsiteDelete public function handle() { $apacheConf = '/etc/apache2/sites-available/'.$this->domain.'.conf'; - ShellApi::exec('rm -rf ' . $apacheConf); + ShellApi::exec('rm -rf '.$apacheConf); $apacheConfEnabled = '/etc/apache2/sites-enabled/'.$this->domain.'.conf'; - ShellApi::exec('rm -rf ' . $apacheConfEnabled); - + ShellApi::exec('rm -rf '.$apacheConfEnabled); // SSL $apacheSSLConf = '/etc/apache2/sites-available/'.$this->domain.'-ssl.conf'; - ShellApi::exec('rm -rf ' . $apacheSSLConf); + ShellApi::exec('rm -rf '.$apacheSSLConf); $apacheSSLConfEnabled = '/etc/apache2/sites-enabled/'.$this->domain.'-ssl.conf'; - ShellApi::exec('rm -rf ' . $apacheSSLConfEnabled); + ShellApi::exec('rm -rf '.$apacheSSLConfEnabled); } } diff --git a/web/app/Actions/CreateLinuxUser.php b/web/app/Actions/CreateLinuxUser.php index 2413c2d..d6f0510 100644 --- a/web/app/Actions/CreateLinuxUser.php +++ b/web/app/Actions/CreateLinuxUser.php @@ -7,7 +7,9 @@ use App\ShellApi; class CreateLinuxUser { public $username; + public $email; + public $password; public function setUsername($username) @@ -29,6 +31,7 @@ class CreateLinuxUser { $this->isWebUser = true; } + public function handle() { $output = ''; @@ -41,7 +44,7 @@ class CreateLinuxUser $output .= ShellApi::exec($command); $command = 'echo '.$username.':'.$password.' | sudo chpasswd -e'; - $output .= ShellApi::exec($command); + $output .= ShellApi::exec($command); return $output; } diff --git a/web/app/Actions/CreateLinuxWebUser.php b/web/app/Actions/CreateLinuxWebUser.php index 025222c..3f15e37 100644 --- a/web/app/Actions/CreateLinuxWebUser.php +++ b/web/app/Actions/CreateLinuxWebUser.php @@ -7,7 +7,9 @@ use App\ShellApi; class CreateLinuxWebUser { public $username; + public $email; + public $password; public function setUsername($username) @@ -33,7 +35,7 @@ class CreateLinuxWebUser $command = 'groupadd '.$username; $output .= ShellApi::exec($command); - $command = 'usermod -a -G www-data ' . $username; + $command = 'usermod -a -G www-data '.$username; $output .= ShellApi::exec($command); $command = 'echo '.$username.':'.$password.' | chpasswd -e'; diff --git a/web/app/ApiClient.php b/web/app/ApiClient.php index a66c54a..ee555a2 100644 --- a/web/app/ApiClient.php +++ b/web/app/ApiClient.php @@ -6,6 +6,6 @@ class ApiClient { public static function getPhyrePHP() { - return "/usr/local/phyre/php/bin/php"; + return '/usr/local/phyre/php/bin/php'; } } diff --git a/web/app/Console/Commands/ApachePingWebsitesWithCurl.php b/web/app/Console/Commands/ApachePingWebsitesWithCurl.php index 41f37e7..9dd159c 100644 --- a/web/app/Console/Commands/ApachePingWebsitesWithCurl.php +++ b/web/app/Console/Commands/ApachePingWebsitesWithCurl.php @@ -42,7 +42,7 @@ class ApachePingWebsitesWithCurl extends Command } // Retrieve all website configurations from the database - $websiteConfigs = Domain::get(); + $websiteConfigs = Domain::get(); foreach ($websiteConfigs as $config) { $domain = $config->domain; @@ -57,8 +57,6 @@ class ApachePingWebsitesWithCurl extends Command } - - return 0; } } diff --git a/web/app/Events/HostingAccountIsCreated.php b/web/app/Events/HostingAccountIsCreated.php index 22a60fd..313875d 100644 --- a/web/app/Events/HostingAccountIsCreated.php +++ b/web/app/Events/HostingAccountIsCreated.php @@ -2,11 +2,8 @@ namespace App\Events; -use Illuminate\Broadcasting\Channel; use Illuminate\Broadcasting\InteractsWithSockets; -use Illuminate\Broadcasting\PresenceChannel; use Illuminate\Broadcasting\PrivateChannel; -use Illuminate\Contracts\Broadcasting\ShouldBroadcast; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Queue\SerializesModels; diff --git a/web/app/Events/ModelCustomerCreated.php b/web/app/Events/ModelCustomerCreated.php index 147d285..6120df9 100644 --- a/web/app/Events/ModelCustomerCreated.php +++ b/web/app/Events/ModelCustomerCreated.php @@ -2,11 +2,8 @@ namespace App\Events; -use Illuminate\Broadcasting\Channel; use Illuminate\Broadcasting\InteractsWithSockets; -use Illuminate\Broadcasting\PresenceChannel; use Illuminate\Broadcasting\PrivateChannel; -use Illuminate\Contracts\Broadcasting\ShouldBroadcast; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Queue\SerializesModels; diff --git a/web/app/Events/ModelCustomerDeleting.php b/web/app/Events/ModelCustomerDeleting.php index 6e80f0b..7f4751a 100644 --- a/web/app/Events/ModelCustomerDeleting.php +++ b/web/app/Events/ModelCustomerDeleting.php @@ -2,11 +2,8 @@ namespace App\Events; -use Illuminate\Broadcasting\Channel; use Illuminate\Broadcasting\InteractsWithSockets; -use Illuminate\Broadcasting\PresenceChannel; use Illuminate\Broadcasting\PrivateChannel; -use Illuminate\Contracts\Broadcasting\ShouldBroadcast; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Queue\SerializesModels; @@ -15,6 +12,7 @@ class ModelCustomerDeleting use Dispatchable, InteractsWithSockets, SerializesModels; public $model; + /** * Create a new event instance. */ diff --git a/web/app/Events/ModelDomainCreated.php b/web/app/Events/ModelDomainCreated.php index 4daf144..35d287b 100644 --- a/web/app/Events/ModelDomainCreated.php +++ b/web/app/Events/ModelDomainCreated.php @@ -2,11 +2,8 @@ namespace App\Events; -use Illuminate\Broadcasting\Channel; use Illuminate\Broadcasting\InteractsWithSockets; -use Illuminate\Broadcasting\PresenceChannel; use Illuminate\Broadcasting\PrivateChannel; -use Illuminate\Contracts\Broadcasting\ShouldBroadcast; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Queue\SerializesModels; diff --git a/web/app/Events/ModelDomainDeleting.php b/web/app/Events/ModelDomainDeleting.php index b670ad9..a014ff7 100644 --- a/web/app/Events/ModelDomainDeleting.php +++ b/web/app/Events/ModelDomainDeleting.php @@ -2,11 +2,8 @@ namespace App\Events; -use Illuminate\Broadcasting\Channel; use Illuminate\Broadcasting\InteractsWithSockets; -use Illuminate\Broadcasting\PresenceChannel; use Illuminate\Broadcasting\PrivateChannel; -use Illuminate\Contracts\Broadcasting\ShouldBroadcast; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Queue\SerializesModels; @@ -15,6 +12,7 @@ class ModelDomainDeleting use Dispatchable, InteractsWithSockets, SerializesModels; public $model; + /** * Create a new event instance. */ diff --git a/web/app/Events/ModelHostingSubscriptionCreated.php b/web/app/Events/ModelHostingSubscriptionCreated.php index ee930d8..0d4a016 100644 --- a/web/app/Events/ModelHostingSubscriptionCreated.php +++ b/web/app/Events/ModelHostingSubscriptionCreated.php @@ -2,11 +2,8 @@ namespace App\Events; -use Illuminate\Broadcasting\Channel; use Illuminate\Broadcasting\InteractsWithSockets; -use Illuminate\Broadcasting\PresenceChannel; use Illuminate\Broadcasting\PrivateChannel; -use Illuminate\Contracts\Broadcasting\ShouldBroadcast; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Queue\SerializesModels; @@ -15,6 +12,7 @@ class ModelHostingSubscriptionCreated use Dispatchable, InteractsWithSockets, SerializesModels; public $model; + /** * Create a new event instance. */ diff --git a/web/app/Events/ModelHostingSubscriptionDeleting.php b/web/app/Events/ModelHostingSubscriptionDeleting.php index fd5cc34..0d4b378 100644 --- a/web/app/Events/ModelHostingSubscriptionDeleting.php +++ b/web/app/Events/ModelHostingSubscriptionDeleting.php @@ -2,11 +2,8 @@ namespace App\Events; -use Illuminate\Broadcasting\Channel; use Illuminate\Broadcasting\InteractsWithSockets; -use Illuminate\Broadcasting\PresenceChannel; use Illuminate\Broadcasting\PrivateChannel; -use Illuminate\Contracts\Broadcasting\ShouldBroadcast; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Queue\SerializesModels; @@ -15,6 +12,7 @@ class ModelHostingSubscriptionDeleting use Dispatchable, InteractsWithSockets, SerializesModels; public $model; + /** * Create a new event instance. */ diff --git a/web/app/Filament/Pages/Modules.php b/web/app/Filament/Pages/Modules.php index f4e87de..aae9462 100644 --- a/web/app/Filament/Pages/Modules.php +++ b/web/app/Filament/Pages/Modules.php @@ -16,47 +16,45 @@ class Modules extends Page protected static ?int $navigationSort = 1; - protected function getViewData(): array { return [ 'categories' => [ - 'Security'=>[ + 'Security' => [ [ 'name' => 'Lets Encrypt', 'description' => 'Automatically secure your website with a free SSL certificate from Lets Encrypt.', 'url' => url('admin/letsencrypt'), 'iconUrl' => url('images/modules/letsencrypt.png'), - 'category' => 'Security' + 'category' => 'Security', ], ], - 'Content Management'=>[ + 'Content Management' => [ [ 'name' => 'Microweber', 'description' => 'A drag and drop website builder and a powerful next-generation CMS.', 'url' => url('admin/microweber'), 'iconUrl' => url('images/modules/microweber.png'), - 'category' => 'Content Management' + 'category' => 'Content Management', ], [ - 'name'=>'WordPress', - 'description'=>'WordPress is a free and open-source content management system written in PHP and paired with a MySQL or MariaDB database.', + 'name' => 'WordPress', + 'description' => 'WordPress is a free and open-source content management system written in PHP and paired with a MySQL or MariaDB database.', 'url' => url('admin/wordpress'), - 'iconUrl'=>url('images/modules/wordpress.svg'), - 'category'=>'Content Management' - ] - ], - 'E-Commerce'=>[ - [ - 'name'=>'OpenCart', - 'description'=>'A free shopping cart system. OpenCart is an open source PHP-based online e-commerce solution.', - 'url' => url('admin/opencart'), - 'iconUrl'=>url('images/modules/opencart.png'), - 'category'=>'E-Commerce' + 'iconUrl' => url('images/modules/wordpress.svg'), + 'category' => 'Content Management', ], ], - ] + 'E-Commerce' => [ + [ + 'name' => 'OpenCart', + 'description' => 'A free shopping cart system. OpenCart is an open source PHP-based online e-commerce solution.', + 'url' => url('admin/opencart'), + 'iconUrl' => url('images/modules/opencart.png'), + 'category' => 'E-Commerce', + ], + ], + ], ]; } - } diff --git a/web/app/Filament/Pages/Settings/Settings.php b/web/app/Filament/Pages/Settings/Settings.php index 84bdad1..f19726d 100644 --- a/web/app/Filament/Pages/Settings/Settings.php +++ b/web/app/Filament/Pages/Settings/Settings.php @@ -1,4 +1,5 @@ sortable(), Tables\Columns\TextColumn::make('email') ->searchable() - ->sortable() + ->sortable(), ]) ->defaultSort('id', 'desc') ->filters([ @@ -99,9 +95,9 @@ class CustomerResource extends Resource { return [ 'index' => Pages\ManageCustomers::route('/'), -// 'index' => Pages\ListCustomers::route('/'), -// 'create' => Pages\CreateCustomer::route('/create'), -// 'edit' => Pages\EditCustomer::route('/{record}/edit'), + // 'index' => Pages\ListCustomers::route('/'), + // 'create' => Pages\CreateCustomer::route('/create'), + // 'edit' => Pages\EditCustomer::route('/{record}/edit'), ]; } } diff --git a/web/app/Filament/Resources/CustomerResource/Pages/CreateCustomer.php b/web/app/Filament/Resources/CustomerResource/Pages/CreateCustomer.php index cceec24..f050642 100644 --- a/web/app/Filament/Resources/CustomerResource/Pages/CreateCustomer.php +++ b/web/app/Filament/Resources/CustomerResource/Pages/CreateCustomer.php @@ -3,7 +3,6 @@ namespace App\Filament\Resources\CustomerResource\Pages; use App\Filament\Resources\CustomerResource; -use Filament\Actions; use Filament\Resources\Pages\CreateRecord; class CreateCustomer extends CreateRecord diff --git a/web/app/Filament/Resources/CustomerResource/Pages/EditCustomer.php b/web/app/Filament/Resources/CustomerResource/Pages/EditCustomer.php index 53e39a1..0c4d5a1 100644 --- a/web/app/Filament/Resources/CustomerResource/Pages/EditCustomer.php +++ b/web/app/Filament/Resources/CustomerResource/Pages/EditCustomer.php @@ -25,7 +25,7 @@ class EditCustomer extends EditRecord ->send(); $action->cancel(); } - }) + }), ]; } } diff --git a/web/app/Filament/Resources/CustomerResource/Pages/ManageCustomers.php b/web/app/Filament/Resources/CustomerResource/Pages/ManageCustomers.php index 0070b28..3f86ebf 100644 --- a/web/app/Filament/Resources/CustomerResource/Pages/ManageCustomers.php +++ b/web/app/Filament/Resources/CustomerResource/Pages/ManageCustomers.php @@ -2,7 +2,6 @@ namespace App\Filament\Resources\CustomerResource\Pages; - use App\Filament\Resources\CustomerResource; use Filament\Actions; use Filament\Resources\Pages\ManageRecords; diff --git a/web/app/Filament/Resources/DomainResource.php b/web/app/Filament/Resources/DomainResource.php index e30a828..3d15d8f 100644 --- a/web/app/Filament/Resources/DomainResource.php +++ b/web/app/Filament/Resources/DomainResource.php @@ -3,16 +3,11 @@ namespace App\Filament\Resources; use App\Filament\Resources\DomainResource\Pages; -use App\Filament\Resources\DomainResource\RelationManagers; use App\Models\Domain; -use Filament\Forms; use Filament\Forms\Form; use Filament\Resources\Resource; use Filament\Tables; use Filament\Tables\Table; -use Illuminate\Database\Eloquent\Builder; -use Illuminate\Database\Eloquent\SoftDeletingScope; -use Illuminate\Support\Str; class DomainResource extends Resource { @@ -29,7 +24,6 @@ class DomainResource extends Resource return $form ->schema([ - ]); } @@ -41,13 +35,13 @@ class DomainResource extends Resource ->searchable() ->sortable(), -// Tables\Columns\TextColumn::make('hostingPlan.name') -// ->searchable() -// ->sortable(), + // Tables\Columns\TextColumn::make('hostingPlan.name') + // ->searchable() + // ->sortable(), -// Tables\Columns\TextColumn::make('customer.name') -// ->searchable() -// ->sortable(), + // Tables\Columns\TextColumn::make('customer.name') + // ->searchable() + // ->sortable(), ]) ->defaultSort('id', 'desc') @@ -59,11 +53,11 @@ class DomainResource extends Resource ->label('Open website') ->icon('heroicon-m-arrow-top-right-on-square') ->color('gray') - ->url(fn ($record): string => 'http://' . $record->domain, true), + ->url(fn ($record): string => 'http://'.$record->domain, true), ]) ->bulkActions([ Tables\Actions\BulkActionGroup::make([ - // Tables\Actions\DeleteBulkAction::make(), + // Tables\Actions\DeleteBulkAction::make(), ]), ]); } @@ -79,8 +73,8 @@ class DomainResource extends Resource { return [ 'index' => Pages\ListWebsites::route('/'), - // 'create' => Pages\CreateWebsite::route('/create'), -// 'edit' => Pages\EditWebsite::route('/{record}/edit'), + // 'create' => Pages\CreateWebsite::route('/create'), + // 'edit' => Pages\EditWebsite::route('/{record}/edit'), 'view' => Pages\ViewWebsite::route('/{record}'), ]; } diff --git a/web/app/Filament/Resources/DomainResource/Pages/CreateWebsite.php b/web/app/Filament/Resources/DomainResource/Pages/CreateWebsite.php index 6445b37..1bbe22f 100644 --- a/web/app/Filament/Resources/DomainResource/Pages/CreateWebsite.php +++ b/web/app/Filament/Resources/DomainResource/Pages/CreateWebsite.php @@ -3,7 +3,6 @@ namespace App\Filament\Resources\DomainResource\Pages; use App\Filament\Resources\DomainResource; -use Filament\Actions; use Filament\Resources\Pages\CreateRecord; class CreateWebsite extends CreateRecord diff --git a/web/app/Filament/Resources/DomainResource/Pages/EditWebsite.php b/web/app/Filament/Resources/DomainResource/Pages/EditWebsite.php index 8e2a822..6b8065b 100644 --- a/web/app/Filament/Resources/DomainResource/Pages/EditWebsite.php +++ b/web/app/Filament/Resources/DomainResource/Pages/EditWebsite.php @@ -13,7 +13,7 @@ class EditWebsite extends EditRecord protected function getHeaderActions(): array { return [ - // Actions\DeleteAction::make(), + // Actions\DeleteAction::make(), ]; } } diff --git a/web/app/Filament/Resources/DomainResource/Pages/ViewWebsite.php b/web/app/Filament/Resources/DomainResource/Pages/ViewWebsite.php index 61bdc74..71494c1 100644 --- a/web/app/Filament/Resources/DomainResource/Pages/ViewWebsite.php +++ b/web/app/Filament/Resources/DomainResource/Pages/ViewWebsite.php @@ -3,7 +3,6 @@ namespace App\Filament\Resources\DomainResource\Pages; use App\Filament\Resources\DomainResource; -use Filament\Actions; use Filament\Resources\Pages\ViewRecord; class ViewWebsite extends ViewRecord @@ -11,5 +10,4 @@ class ViewWebsite extends ViewRecord protected static string $resource = DomainResource::class; protected static string $view = 'filament.resources.website.pages.view-website'; - } diff --git a/web/app/Filament/Resources/HostingPlanResource.php b/web/app/Filament/Resources/HostingPlanResource.php index 1f88588..0bc5d51 100644 --- a/web/app/Filament/Resources/HostingPlanResource.php +++ b/web/app/Filament/Resources/HostingPlanResource.php @@ -3,15 +3,12 @@ namespace App\Filament\Resources; use App\Filament\Resources\HostingPlanResource\Pages; -use App\Filament\Resources\HostingPlanResource\RelationManagers; use App\Models\HostingPlan; use Filament\Forms; use Filament\Forms\Form; use Filament\Resources\Resource; use Filament\Tables; use Filament\Tables\Table; -use Illuminate\Database\Eloquent\Builder; -use Illuminate\Database\Eloquent\SoftDeletingScope; class HostingPlanResource extends Resource { @@ -108,11 +105,10 @@ class HostingPlanResource extends Resource ->label('Features') ->options([ 'ssl' => 'SSL', - 'backup' => 'Backup' + 'backup' => 'Backup', ]) ->multiple(), - ]); } diff --git a/web/app/Filament/Resources/HostingPlanResource/Pages/CreateHostingPlan.php b/web/app/Filament/Resources/HostingPlanResource/Pages/CreateHostingPlan.php index aa046f3..f7e4b4d 100644 --- a/web/app/Filament/Resources/HostingPlanResource/Pages/CreateHostingPlan.php +++ b/web/app/Filament/Resources/HostingPlanResource/Pages/CreateHostingPlan.php @@ -3,7 +3,6 @@ namespace App\Filament\Resources\HostingPlanResource\Pages; use App\Filament\Resources\HostingPlanResource; -use Filament\Actions; use Filament\Resources\Pages\CreateRecord; class CreateHostingPlan extends CreateRecord diff --git a/web/app/Filament/Resources/HostingSubscriptionResource.php b/web/app/Filament/Resources/HostingSubscriptionResource.php index 8815c41..dfd907a 100644 --- a/web/app/Filament/Resources/HostingSubscriptionResource.php +++ b/web/app/Filament/Resources/HostingSubscriptionResource.php @@ -3,16 +3,12 @@ namespace App\Filament\Resources; use App\Filament\Resources\HostingSubscriptionResource\Pages; -use App\Filament\Resources\HostingSubscriptionResource\RelationManagers; use App\Models\HostingSubscription; use Filament\Forms; -use Filament\Forms\Components\Field; use Filament\Forms\Form; use Filament\Resources\Resource; use Filament\Tables; use Filament\Tables\Table; -use Illuminate\Database\Eloquent\Builder; -use Illuminate\Database\Eloquent\SoftDeletingScope; use Illuminate\Support\HtmlString; class HostingSubscriptionResource extends Resource @@ -41,8 +37,8 @@ class HostingSubscriptionResource extends Resource } }) ->content(fn ($record) => new HtmlString(' - - http://' . $record->domain . ' + + http://'.$record->domain.' ')), Forms\Components\TextInput::make('domain') @@ -56,7 +52,7 @@ class HostingSubscriptionResource extends Resource } }) ->suffixIcon('heroicon-m-globe-alt') - ->columnSpanFull(), + ->columnSpanFull(), Forms\Components\Select::make('customer_id') ->label('Customer') @@ -94,20 +90,20 @@ class HostingSubscriptionResource extends Resource }) ->suffixIcon('heroicon-m-user'), - Forms\Components\TextInput::make('system_password') - ->hidden(fn (Forms\Get $get): bool => ! $get('advanced')) - ->disabled(function ($record) { - if (isset($record->exists)) { - return $record->exists; - } else { - return false; - } - }) - ->suffixIcon('heroicon-m-lock-closed'), + Forms\Components\TextInput::make('system_password') + ->hidden(fn (Forms\Get $get): bool => ! $get('advanced')) + ->disabled(function ($record) { + if (isset($record->exists)) { + return $record->exists; + } else { + return false; + } + }) + ->suffixIcon('heroicon-m-lock-closed'), - Forms\Components\Textarea::make('description') - ->hidden(fn (Forms\Get $get): bool => ! $get('advanced')) - ->columnSpanFull(), + Forms\Components\Textarea::make('description') + ->hidden(fn (Forms\Get $get): bool => ! $get('advanced')) + ->columnSpanFull(), ]); } @@ -143,7 +139,7 @@ class HostingSubscriptionResource extends Resource ->label('Open website') ->icon('heroicon-m-arrow-top-right-on-square') ->color('gray') - ->url(fn ($record): string => 'http://' . $record->domain, true), + ->url(fn ($record): string => 'http://'.$record->domain, true), Tables\Actions\EditAction::make(), Tables\Actions\DeleteAction::make(), ]) @@ -165,9 +161,9 @@ class HostingSubscriptionResource extends Resource { return [ 'index' => Pages\ManageHostingSubscriptions::route('/'), -// 'index' => Pages\ListHostingSubscriptions::route('/'), -// 'create' => Pages\CreateHostingSubscription::route('/create'), -// 'edit' => Pages\EditHostingSubscription::route('/{record}/edit'), + // 'index' => Pages\ListHostingSubscriptions::route('/'), + // 'create' => Pages\CreateHostingSubscription::route('/create'), + // 'edit' => Pages\EditHostingSubscription::route('/{record}/edit'), ]; } } diff --git a/web/app/Filament/Resources/HostingSubscriptionResource/Pages/CreateHostingSubscription.php b/web/app/Filament/Resources/HostingSubscriptionResource/Pages/CreateHostingSubscription.php index 15cb8a4..a522b3a 100644 --- a/web/app/Filament/Resources/HostingSubscriptionResource/Pages/CreateHostingSubscription.php +++ b/web/app/Filament/Resources/HostingSubscriptionResource/Pages/CreateHostingSubscription.php @@ -3,11 +3,9 @@ namespace App\Filament\Resources\HostingSubscriptionResource\Pages; use App\Filament\Resources\HostingSubscriptionResource; -use Filament\Actions; use Filament\Resources\Pages\CreateRecord; class CreateHostingSubscription extends CreateRecord { protected static string $resource = HostingSubscriptionResource::class; - } diff --git a/web/app/Filament/Resources/HostingSubscriptionResource/Pages/ManageHostingSubscriptions.php b/web/app/Filament/Resources/HostingSubscriptionResource/Pages/ManageHostingSubscriptions.php index 4a388ed..ed3fd41 100644 --- a/web/app/Filament/Resources/HostingSubscriptionResource/Pages/ManageHostingSubscriptions.php +++ b/web/app/Filament/Resources/HostingSubscriptionResource/Pages/ManageHostingSubscriptions.php @@ -2,7 +2,6 @@ namespace App\Filament\Resources\HostingSubscriptionResource\Pages; - use App\Filament\Resources\HostingSubscriptionResource; use Filament\Actions; use Filament\Resources\Pages\ManageRecords; diff --git a/web/app/Filament/Resources/UserResource.php b/web/app/Filament/Resources/UserResource.php index 161cebf..4e2b378 100644 --- a/web/app/Filament/Resources/UserResource.php +++ b/web/app/Filament/Resources/UserResource.php @@ -3,15 +3,12 @@ namespace App\Filament\Resources; use App\Filament\Resources\UserResource\Pages; -use App\Filament\Resources\UserResource\RelationManagers; use App\Models\User; use Filament\Forms; use Filament\Forms\Form; use Filament\Resources\Resource; use Filament\Tables; use Filament\Tables\Table; -use Illuminate\Database\Eloquent\Builder; -use Illuminate\Database\Eloquent\SoftDeletingScope; class UserResource extends Resource { diff --git a/web/app/Filament/Resources/UserResource/Pages/CreateUser.php b/web/app/Filament/Resources/UserResource/Pages/CreateUser.php index 73aa46d..78a3894 100644 --- a/web/app/Filament/Resources/UserResource/Pages/CreateUser.php +++ b/web/app/Filament/Resources/UserResource/Pages/CreateUser.php @@ -3,7 +3,6 @@ namespace App\Filament\Resources\UserResource\Pages; use App\Filament\Resources\UserResource; -use Filament\Actions; use Filament\Resources\Pages\CreateRecord; class CreateUser extends CreateRecord diff --git a/web/app/Filament/Widgets/CustomersCount.php b/web/app/Filament/Widgets/CustomersCount.php index fbf02db..00083c8 100644 --- a/web/app/Filament/Widgets/CustomersCount.php +++ b/web/app/Filament/Widgets/CustomersCount.php @@ -16,22 +16,20 @@ class CustomersCount extends BaseWidget protected function getStats(): array { -// $serverStatistic = new \App\Statistics\ServerStatistic(); -// $serverStats = $serverStatistic->getCurrentStats(); - + // $serverStatistic = new \App\Statistics\ServerStatistic(); + // $serverStats = $serverStatistic->getCurrentStats(); $customersCount = Customer::count(); $websiteCount = Domain::count(); return [ -// Stat::make('Total Memory', $serverStats['memory']['total']), -// Stat::make('Used Memory', $serverStats['memory']['used']), -// Stat::make('Free Memory', $serverStats['memory']['free']), -// Stat::make('Shared Memory', $serverStats['memory']['shared']), -// Stat::make('Buffer Cache', $serverStats['memory']['buffCache']), -// Stat::make('Available Memory', $serverStats['memory']['available']), -// - + // Stat::make('Total Memory', $serverStats['memory']['total']), + // Stat::make('Used Memory', $serverStats['memory']['used']), + // Stat::make('Free Memory', $serverStats['memory']['free']), + // Stat::make('Shared Memory', $serverStats['memory']['shared']), + // Stat::make('Buffer Cache', $serverStats['memory']['buffCache']), + // Stat::make('Available Memory', $serverStats['memory']['available']), + // Stat::make('Websites', $websiteCount)->icon('heroicon-o-globe-alt'), Stat::make('Customers', $customersCount)->icon('heroicon-o-users'), diff --git a/web/app/Filament/Widgets/ServerDiskUsageStatistic.php b/web/app/Filament/Widgets/ServerDiskUsageStatistic.php index bc84db0..e1949e4 100644 --- a/web/app/Filament/Widgets/ServerDiskUsageStatistic.php +++ b/web/app/Filament/Widgets/ServerDiskUsageStatistic.php @@ -8,27 +8,21 @@ class ServerDiskUsageStatistic extends ApexChartWidget { /** * Chart Id - * - * @var string */ protected static ?string $chartId = 'serverDiskUsageStatisticChart'; /** * Widget Title - * - * @var string|null */ protected static ?string $heading = 'Disk Usage'; protected static ?int $sort = 1; - /** * Widget content height */ protected static ?int $contentHeight = 100; - /** * Widget Footer */ @@ -40,7 +34,6 @@ class ServerDiskUsageStatistic extends ApexChartWidget return view('charts.order-status.footer', ['data' => $serverStats]); } - /** * Chart options (series, labels, types, size, animations...) * https://apexcharts.com/docs/options diff --git a/web/app/Filament/Widgets/ServerMemoryStatistic.php b/web/app/Filament/Widgets/ServerMemoryStatistic.php index 79cd196..2065909 100644 --- a/web/app/Filament/Widgets/ServerMemoryStatistic.php +++ b/web/app/Filament/Widgets/ServerMemoryStatistic.php @@ -8,27 +8,21 @@ class ServerMemoryStatistic extends ApexChartWidget { /** * Chart Id - * - * @var string */ protected static ?string $chartId = 'serverMemoryStatisticChart'; /** * Widget Title - * - * @var string|null */ protected static ?string $heading = 'RAM Usage'; protected static ?int $sort = 2; - /** * Widget content height */ protected static ?int $contentHeight = 100; - /** * Widget Footer */ @@ -40,7 +34,6 @@ class ServerMemoryStatistic extends ApexChartWidget return view('filament.widgets.server-memory-statistic', ['data' => $serverStats]); } - /** * Chart options (series, labels, types, size, animations...) * https://apexcharts.com/docs/options diff --git a/web/app/Filament/Widgets/ServerMemoryStatisticCount.php b/web/app/Filament/Widgets/ServerMemoryStatisticCount.php index c32f02b..572f611 100644 --- a/web/app/Filament/Widgets/ServerMemoryStatisticCount.php +++ b/web/app/Filament/Widgets/ServerMemoryStatisticCount.php @@ -2,10 +2,7 @@ namespace App\Filament\Widgets; -use App\Models\Customer; -use App\Models\Domain; use Filament\Widgets\StatsOverviewWidget as BaseWidget; -use Filament\Widgets\StatsOverviewWidget\Stat; class ServerMemoryStatisticCount extends BaseWidget { diff --git a/web/app/Filament/Widgets/Websites.php b/web/app/Filament/Widgets/Websites.php index 38b38cb..56c5612 100644 --- a/web/app/Filament/Widgets/Websites.php +++ b/web/app/Filament/Widgets/Websites.php @@ -3,7 +3,6 @@ namespace App\Filament\Widgets; use App\Models\Domain; -use Faker\Provider\Text; use Filament\Tables; use Filament\Tables\Table; use Filament\Widgets\TableWidget as BaseWidget; @@ -14,9 +13,9 @@ class Websites extends BaseWidget protected static ?string $heading = 'Last created websites'; - protected int | string | array $columnSpan = 2; + protected int|string|array $columnSpan = 2; - protected static ?int $sort =5; + protected static ?int $sort = 5; public function table(Table $table): Table { @@ -29,12 +28,12 @@ class Websites extends BaseWidget ->label('Open website') ->icon('heroicon-m-arrow-top-right-on-square') ->color('gray') - ->url(fn ($record): string => 'http://' . $record->domain, true), + ->url(fn ($record): string => 'http://'.$record->domain, true), ]) ->columns([ Tables\Columns\TextColumn::make('domain'), Tables\Columns\TextColumn::make('hostingPlan.name'), - Tables\Columns\TextColumn::make('created_at') + Tables\Columns\TextColumn::make('created_at'), ])->defaultSort('id', 'desc'); } } diff --git a/web/app/FileManagerApi.php b/web/app/FileManagerApi.php index a57c5e6..f0189dd 100644 --- a/web/app/FileManagerApi.php +++ b/web/app/FileManagerApi.php @@ -13,6 +13,7 @@ class FileManagerApi { return is_file($path); } + public function isWritable($path) { return is_writable($path); @@ -37,10 +38,9 @@ class FileManagerApi { return file_exists($file); } + public function filePutContents($file, $data) { return file_put_contents($file, $data); } - - } diff --git a/web/app/Http/Controllers/Api/CustomersController.php b/web/app/Http/Controllers/Api/CustomersController.php index 2344499..4968e4a 100644 --- a/web/app/Http/Controllers/Api/CustomersController.php +++ b/web/app/Http/Controllers/Api/CustomersController.php @@ -6,17 +6,18 @@ use App\Http\Controllers\Api\Request\CustomerCreateRequest; use App\Http\Controllers\ApiController; use App\Models\Customer; use App\Models\HostingSubscription; -use Illuminate\Http\Request; class CustomersController extends ApiController { /** * @OA\Get( * path="/api/customers", + * * @OA\Response( * response=200, * description="Successful operation", * ), + * * @OA\PathItem ( * ), * ) @@ -30,7 +31,7 @@ class CustomersController extends ApiController 'message' => 'Customers found', 'data' => [ 'customers' => $findCustomers, - ] + ], ]); } @@ -38,16 +39,21 @@ class CustomersController extends ApiController /** * @OA\Post( * path="/api/customers", + * * @OA\Response( * response=200, * description="Successful operation", * ), + * * @OA\PathItem ( * ), + * * @OA\RequestBody( * required=true, + * * @OA\JsonContent( * required={"name","email","phone"}, + * * @OA\Property(property="name", type="string", example="John Doe", description="Name of the customer"), * @OA\Property(property="email", type="string", example="jhon@gmail.com", description="Email of the customer"), * @OA\Property(property="phone", type="string", example="1234567890", description="Phone of the customer") @@ -67,14 +73,14 @@ class CustomersController extends ApiController 'message' => 'Customer created', 'data' => [ 'customer' => $customer, - ] + ], ]); } public function getHostingSubscriptionsByCustomerId($customerId) { $findCustomer = Customer::where('id', $customerId)->first(); - if (!$findCustomer) { + if (! $findCustomer) { return response()->json([ 'status' => 'error', 'message' => 'Customer not found', @@ -94,7 +100,7 @@ class CustomersController extends ApiController 'message' => 'Hosting subscriptions found', 'data' => [ 'hostingSubscriptions' => $findHostingSubscriptions, - ] + ], ]); } } diff --git a/web/app/Http/Controllers/Api/HealthController.php b/web/app/Http/Controllers/Api/HealthController.php index f8e432b..335f9d9 100644 --- a/web/app/Http/Controllers/Api/HealthController.php +++ b/web/app/Http/Controllers/Api/HealthController.php @@ -2,19 +2,19 @@ namespace App\Http\Controllers\Api; - use App\Http\Controllers\ApiController; -use App\ShellApi; class HealthController extends ApiController { /** * @OA\Get( * path="/api/health", + * * @OA\Response( * response=200, * description="Successful operation", * ), + * * @OA\PathItem ( * ), * ) @@ -23,7 +23,7 @@ class HealthController extends ApiController { return response()->json([ 'status' => 'ok', - 'message' => 'API is running.' + 'message' => 'API is running.', ]); } diff --git a/web/app/Http/Controllers/Api/HostingPlansController.php b/web/app/Http/Controllers/Api/HostingPlansController.php index de0a8bd..2d6781e 100644 --- a/web/app/Http/Controllers/Api/HostingPlansController.php +++ b/web/app/Http/Controllers/Api/HostingPlansController.php @@ -6,17 +6,18 @@ use App\Http\Controllers\Api\Request\CustomerCreateRequest; use App\Http\Controllers\ApiController; use App\Models\Customer; use App\Models\HostingPlan; -use Illuminate\Http\Request; class HostingPlansController extends ApiController { /** * @OA\Get( * path="/api/hosting-plans", + * * @OA\Response( * response=200, * description="Successful operation", * ), + * * @OA\PathItem ( * ), * ) @@ -29,8 +30,8 @@ class HostingPlansController extends ApiController 'status' => 'ok', 'message' => 'Hosting Plans found', 'data' => [ - 'hostingPlans' => $findHostingPlans->toArray() - ] + 'hostingPlans' => $findHostingPlans->toArray(), + ], ]); } @@ -38,16 +39,21 @@ class HostingPlansController extends ApiController /** * @OA\Post( * path="/api/customers", + * * @OA\Response( * response=200, * description="Successful operation", * ), + * * @OA\PathItem ( * ), + * * @OA\RequestBody( * required=true, + * * @OA\JsonContent( * required={"name","email","phone"}, + * * @OA\Property(property="name", type="string", example="John Doe", description="Name of the customer"), * @OA\Property(property="email", type="string", example="jhon@gmail.com", description="Email of the customer"), * @OA\Property(property="phone", type="string", example="1234567890", description="Phone of the customer") @@ -68,7 +74,7 @@ class HostingPlansController extends ApiController 'message' => 'Customer created', 'data' => [ 'customer' => $customer, - ] + ], ]); } } diff --git a/web/app/Http/Controllers/Api/HostingSubscriptionsController.php b/web/app/Http/Controllers/Api/HostingSubscriptionsController.php index 7ed0aeb..f78cab3 100644 --- a/web/app/Http/Controllers/Api/HostingSubscriptionsController.php +++ b/web/app/Http/Controllers/Api/HostingSubscriptionsController.php @@ -18,7 +18,7 @@ class HostingSubscriptionsController extends ApiController 'message' => 'Hosting subscriptions found', 'data' => [ 'HostingSubscriptions' => $findHostingSubscription, - ] + ], ]); } @@ -29,9 +29,9 @@ class HostingSubscriptionsController extends ApiController $hostingSubscription->customer_id = $request->customer_id; $hostingSubscription->hosting_plan_id = $request->hosting_plan_id; $hostingSubscription->domain = $request->domain; -// $hostingSubscription->username = $request->username; -// $hostingSubscription->password = $request->password; -// $hostingSubscription->description = $request->description; + // $hostingSubscription->username = $request->username; + // $hostingSubscription->password = $request->password; + // $hostingSubscription->description = $request->description; $hostingSubscription->setup_date = Carbon::now(); $hostingSubscription->save(); @@ -40,7 +40,7 @@ class HostingSubscriptionsController extends ApiController 'message' => 'Hosting subscription created', 'data' => [ 'hostingSubscription' => $hostingSubscription, - ] + ], ]); } @@ -49,6 +49,7 @@ class HostingSubscriptionsController extends ApiController $findHostingSubscription = HostingSubscription::where('id', $id)->first(); if ($findHostingSubscription) { $findHostingSubscription->delete(); + return response()->json([ 'status' => 'ok', 'message' => 'Hosting subscription deleted', diff --git a/web/app/Http/Controllers/Api/Request/AuthLoginRequest.php b/web/app/Http/Controllers/Api/Request/AuthLoginRequest.php index bd319c0..5cbc7ef 100644 --- a/web/app/Http/Controllers/Api/Request/AuthLoginRequest.php +++ b/web/app/Http/Controllers/Api/Request/AuthLoginRequest.php @@ -14,7 +14,7 @@ class AuthLoginRequest extends ApiRequest return [ 'email' => 'required|string|email', 'password' => 'required|string', - // 'browserAgent' => 'required|string', + // 'browserAgent' => 'required|string', ]; } } diff --git a/web/app/Http/Controllers/Api/Request/CustomerCreateRequest.php b/web/app/Http/Controllers/Api/Request/CustomerCreateRequest.php index 3204ad0..c28f11b 100644 --- a/web/app/Http/Controllers/Api/Request/CustomerCreateRequest.php +++ b/web/app/Http/Controllers/Api/Request/CustomerCreateRequest.php @@ -1,4 +1,5 @@ 'required', - 'email' => 'required|email|unique:customers,email' + 'email' => 'required|email|unique:customers,email', ]; } } diff --git a/web/app/Http/Controllers/ApiController.php b/web/app/Http/Controllers/ApiController.php index 1df189c..44ec164 100644 --- a/web/app/Http/Controllers/ApiController.php +++ b/web/app/Http/Controllers/ApiController.php @@ -10,6 +10,7 @@ use Illuminate\Routing\Controller as BaseController; * @OA\Info( * title="PhyrePanel - API Documentation", * version="0.1", + * * @OA\Contact( * email="info@phyrepanel.com" * ), @@ -17,8 +18,6 @@ use Illuminate\Routing\Controller as BaseController; */ class ApiController extends BaseController { - // use AuthorizesRequests, ValidatesRequests; + // use AuthorizesRequests, ValidatesRequests; use ValidatesRequests; - - } diff --git a/web/app/Listeners/ModelDomainCreatedListener.php b/web/app/Listeners/ModelDomainCreatedListener.php index 9027a22..af000e0 100644 --- a/web/app/Listeners/ModelDomainCreatedListener.php +++ b/web/app/Listeners/ModelDomainCreatedListener.php @@ -5,16 +5,9 @@ namespace App\Listeners; use App\Actions\ApacheWebsiteCreate; use App\Events\DomainIsCreated; use App\Events\ModelDomainCreated; -use App\Models\Customer; use App\Models\Domain; -use App\Models\HostingPackage; use App\Models\HostingPlan; use App\Models\HostingSubscription; -use Cassandra\Custom; -use Illuminate\Contracts\Queue\ShouldQueue; -use Illuminate\Queue\InteractsWithQueue; -use Illuminate\Support\Str; -use function Symfony\Component\String\u; class ModelDomainCreatedListener { @@ -32,16 +25,16 @@ class ModelDomainCreatedListener public function handle(ModelDomainCreated $event): void { $findDomain = Domain::where('id', $event->model->id)->first(); - if (!$findDomain) { + if (! $findDomain) { return; } $findHostingSubscription = HostingSubscription::where('id', $findDomain->hosting_subscription_id)->first(); - if (!$findHostingSubscription) { + if (! $findHostingSubscription) { return; } $findHostingPlan = HostingPlan::where('id', $findHostingSubscription->hosting_plan_id)->first(); - if (!$findHostingPlan) { + if (! $findHostingPlan) { return; } @@ -54,9 +47,9 @@ class ModelDomainCreatedListener $newApacheWebsite->setIsMainDomain(true); } - $create = $newApacheWebsite->handle(); + $create = $newApacheWebsite->handle(); - if (!empty($create)) { + if (! empty($create)) { $findDomain->home_root = $create['homeRoot']; $findDomain->domain_root = $create['domainRoot']; diff --git a/web/app/Listeners/ModelDomainDeletingListener.php b/web/app/Listeners/ModelDomainDeletingListener.php index 890fd99..ff3715b 100644 --- a/web/app/Listeners/ModelDomainDeletingListener.php +++ b/web/app/Listeners/ModelDomainDeletingListener.php @@ -5,8 +5,6 @@ namespace App\Listeners; use App\Actions\ApacheWebsiteDelete; use App\Events\ModelDomainDeleting; use App\ShellApi; -use Illuminate\Contracts\Queue\ShouldQueue; -use Illuminate\Queue\InteractsWithQueue; class ModelDomainDeletingListener { @@ -25,7 +23,7 @@ class ModelDomainDeletingListener { $domainRoot = '/home/'.$event->model->domain_username.'/domains/'.$event->model->domain; - ShellApi::exec('rm -rf ' . $domainRoot); + ShellApi::exec('rm -rf '.$domainRoot); $deleteApacheWebsite = new ApacheWebsiteDelete(); $deleteApacheWebsite->setDomain($event->model->domain); diff --git a/web/app/Listeners/ModelHostingSubscriptionCreatedListener.php b/web/app/Listeners/ModelHostingSubscriptionCreatedListener.php index da078b5..ed269a1 100644 --- a/web/app/Listeners/ModelHostingSubscriptionCreatedListener.php +++ b/web/app/Listeners/ModelHostingSubscriptionCreatedListener.php @@ -27,24 +27,24 @@ class ModelHostingSubscriptionCreatedListener { $findHostingSubscription = HostingSubscription::where('id', $event->model->id)->first(); - if (!$findHostingSubscription) { + if (! $findHostingSubscription) { return; } $findCustomer = Customer::where('id', $event->model->customer_id)->first(); - if (!$findCustomer) { + if (! $findCustomer) { return; } $systemUsername = $this->_generateUsername($event->model->domain); - $systemUsername = $systemUsername . $findCustomer->id . $findHostingSubscription->id; + $systemUsername = $systemUsername.$findCustomer->id.$findHostingSubscription->id; $getLinuxUser = new GetLinuxUser(); $getLinuxUser->setUsername($systemUsername); $linuxUser = $getLinuxUser->handle(); - if (!empty($linuxUser)) { + if (! empty($linuxUser)) { $systemUsername = $this->_generateUsername(Str::random(10)); - $systemUsername = $systemUsername . $findCustomer->id . $findHostingSubscription->id; + $systemUsername = $systemUsername.$findCustomer->id.$findHostingSubscription->id; } $systemPassword = Str::random(14); @@ -75,13 +75,13 @@ class ModelHostingSubscriptionCreatedListener $removedMultispace = preg_replace('/\s+/', ' ', $string); $sanitized = preg_replace('/[^A-Za-z0-9\ ]/', '', $removedMultispace); $lowercased = strtolower($sanitized); - $lowercased = str_replace(" ", "", $lowercased); + $lowercased = str_replace(' ', '', $lowercased); $lowercased = trim($lowercased); if (strlen($lowercased) > 10) { $lowercased = substr($lowercased, 0, 10); } - $username = $lowercased . rand(1111,9999) . Str::random(4); + $username = $lowercased.rand(1111, 9999).Str::random(4); $username = strtolower($username); return $username; diff --git a/web/app/Listeners/ModelHostingSubscriptionDeletingListener.php b/web/app/Listeners/ModelHostingSubscriptionDeletingListener.php index d0e2eb3..db52e4f 100644 --- a/web/app/Listeners/ModelHostingSubscriptionDeletingListener.php +++ b/web/app/Listeners/ModelHostingSubscriptionDeletingListener.php @@ -3,7 +3,6 @@ namespace App\Listeners; use App\Actions\GetLinuxUser; -use App\Events\ModelHostingSubscriptionCreated; use App\Events\ModelHostingSubscriptionDeleting; use App\Models\Domain; @@ -26,9 +25,9 @@ class ModelHostingSubscriptionDeletingListener $getLinuxUser->setUsername($event->model->system_username); $getLinuxUserStatus = $getLinuxUser->handle(); - if (!empty($getLinuxUserStatus)) { - shell_exec('userdel ' . $event->model->system_username); - shell_exec('rm -rf /home/' . $event->model->system_username); + if (! empty($getLinuxUserStatus)) { + shell_exec('userdel '.$event->model->system_username); + shell_exec('rm -rf /home/'.$event->model->system_username); } $findRelatedDomains = Domain::where('hosting_subscription_id', $event->model->id)->get(); if ($findRelatedDomains->count() > 0) { @@ -38,5 +37,4 @@ class ModelHostingSubscriptionDeletingListener } } - } diff --git a/web/app/Livewire/Installer.php b/web/app/Livewire/Installer.php index 1b3d059..f519426 100644 --- a/web/app/Livewire/Installer.php +++ b/web/app/Livewire/Installer.php @@ -3,7 +3,6 @@ namespace App\Livewire; use App\Models\User; -use Illuminate\Support\Facades\Artisan; use Livewire\Component; class Installer extends Component @@ -11,8 +10,11 @@ class Installer extends Component public $step = 1; public $name; + public $email; + public $password; + public $password_confirmation; public function install() diff --git a/web/app/Models/Backup.php b/web/app/Models/Backup.php index c6e7eb5..642d552 100644 --- a/web/app/Models/Backup.php +++ b/web/app/Models/Backup.php @@ -2,7 +2,6 @@ namespace App\Models; -use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Sushi\Sushi; diff --git a/web/app/Models/CronJob.php b/web/app/Models/CronJob.php index 5677b0e..cc0dccb 100644 --- a/web/app/Models/CronJob.php +++ b/web/app/Models/CronJob.php @@ -3,7 +3,6 @@ namespace App\Models; use App\ShellApi; -use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Sushi\Sushi; @@ -64,20 +63,20 @@ class CronJob extends Model $user = ShellApi::exec('whoami'); $cronList = ShellApi::callBin('cron-jobs-list', [ - $user + $user, ]); $rows = []; - if (!empty($cronList)) { + if (! empty($cronList)) { $cronList = json_decode($cronList, true); - if (!empty($cronList)) { + if (! empty($cronList)) { foreach ($cronList as $cron) { if (isset($cron['schedule'])) { $rows[] = [ 'schedule' => $cron['schedule'], 'command' => $cron['command'], 'user' => $user, - 'time'=> time(), + 'time' => time(), ]; } } diff --git a/web/app/Models/Customer.php b/web/app/Models/Customer.php index 1c120bc..bec0f4b 100644 --- a/web/app/Models/Customer.php +++ b/web/app/Models/Customer.php @@ -5,7 +5,6 @@ namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; - class Customer extends Model { use HasFactory; @@ -28,5 +27,4 @@ class Customer extends Model { return $this->hasMany(HostingSubscription::class); } - } diff --git a/web/app/Models/Domain.php b/web/app/Models/Domain.php index 2e72d4e..92f1968 100644 --- a/web/app/Models/Domain.php +++ b/web/app/Models/Domain.php @@ -4,8 +4,6 @@ namespace App\Models; use App\Events\ModelDomainCreated; use App\Events\ModelDomainDeleting; -use App\ShellApi; -use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; class Domain extends Model @@ -30,5 +28,4 @@ class Domain extends Model }); } - } diff --git a/web/app/Models/DomainSslCertificate.php b/web/app/Models/DomainSslCertificate.php index 6440f3b..89377bd 100644 --- a/web/app/Models/DomainSslCertificate.php +++ b/web/app/Models/DomainSslCertificate.php @@ -23,5 +23,4 @@ class DomainSslCertificate extends Model 'renewed_date', 'renewed_until_date', ]; - } diff --git a/web/app/Models/HostingDatabase.php b/web/app/Models/HostingDatabase.php index c61823b..d60c697 100644 --- a/web/app/Models/HostingDatabase.php +++ b/web/app/Models/HostingDatabase.php @@ -10,7 +10,7 @@ class HostingDatabase extends Model protected $fillable = [ 'database_name', 'database_username', - 'database_password' + 'database_password', ]; public static function boot() @@ -22,7 +22,7 @@ class HostingDatabase extends Model $createDbAndUser = ShellApi::callBin('mysql-create-db-and-user', [ $model->database_name, $model->database_username, - $model->database_password + $model->database_password, ]); if (empty($createDbAndUser)) { @@ -35,5 +35,4 @@ class HostingDatabase extends Model }); } - } diff --git a/web/app/Models/HostingPlan.php b/web/app/Models/HostingPlan.php index 1eebd99..9c57d0f 100644 --- a/web/app/Models/HostingPlan.php +++ b/web/app/Models/HostingPlan.php @@ -34,5 +34,4 @@ class HostingPlan extends Model 'features' => 'array', 'limitations' => 'array', ]; - } diff --git a/web/app/Models/HostingSubscription.php b/web/app/Models/HostingSubscription.php index 46bb9c4..73076c5 100644 --- a/web/app/Models/HostingSubscription.php +++ b/web/app/Models/HostingSubscription.php @@ -18,7 +18,7 @@ class HostingSubscription extends Model 'description', 'setup_date', 'expiry_date', - 'renewal_date' + 'renewal_date', ]; public static function boot() @@ -44,5 +44,4 @@ class HostingSubscription extends Model { return $this->belongsTo(HostingPlan::class); } - } diff --git a/web/app/Models/User.php b/web/app/Models/User.php index 553b186..1a5b4a1 100644 --- a/web/app/Models/User.php +++ b/web/app/Models/User.php @@ -11,7 +11,7 @@ use Rappasoft\LaravelAuthenticationLog\Traits\AuthenticationLoggable; class User extends Authenticatable { - use HasApiTokens, HasFactory, Notifiable, AuthenticationLoggable; + use AuthenticationLoggable, HasApiTokens, HasFactory, Notifiable; /** * The attributes that are mass assignable. diff --git a/web/app/PhyreLaravelApplication.php b/web/app/PhyreLaravelApplication.php index 6ffe203..6a87851 100644 --- a/web/app/PhyreLaravelApplication.php +++ b/web/app/PhyreLaravelApplication.php @@ -8,7 +8,6 @@ use Illuminate\Foundation\Application; * @property \App\FileManagerApi $file_manager_api * @property \App\VirtualHosts\ApacheVirtualHostManager $virtualHostManager */ -class PhyreLaravelApplication extends Application { - +class PhyreLaravelApplication extends Application +{ } - diff --git a/web/app/Policies/CustomerPolicy.php b/web/app/Policies/CustomerPolicy.php index bf8ef48..002d8fa 100644 --- a/web/app/Policies/CustomerPolicy.php +++ b/web/app/Policies/CustomerPolicy.php @@ -3,8 +3,8 @@ namespace App\Policies; use App\Models\Customer; -use App\Models\User; use App\Models\Domain; +use App\Models\User; use Illuminate\Auth\Access\Response; class CustomerPolicy @@ -12,7 +12,7 @@ class CustomerPolicy /** * Determine whether the user can view any models. */ - public function viewAny(User $user) : bool + public function viewAny(User $user): bool { return true; } @@ -20,7 +20,7 @@ class CustomerPolicy /** * Determine whether the user can view the model. */ - public function view(User $user, Customer $customer) : bool + public function view(User $user, Customer $customer): bool { return true; } @@ -28,7 +28,7 @@ class CustomerPolicy /** * Determine whether the user can create models. */ - public function create(User $user) : bool + public function create(User $user): bool { return true; } @@ -36,7 +36,7 @@ class CustomerPolicy /** * Determine whether the user can update the model. */ - public function update(User $user, Customer $customer) : bool + public function update(User $user, Customer $customer): bool { return true; } @@ -44,7 +44,7 @@ class CustomerPolicy /** * Determine whether the user can delete the model. */ - public function delete(User $user, Customer $customer) : bool + public function delete(User $user, Customer $customer): bool { return true; } @@ -52,7 +52,7 @@ class CustomerPolicy /** * Determine whether the user can restore the model. */ - public function restore(User $user, Customer $customer) : bool + public function restore(User $user, Customer $customer): bool { return true; } @@ -60,13 +60,15 @@ class CustomerPolicy /** * Determine whether the user can permanently delete the model. */ - public function forceDelete(User $user, Customer $customer) : bool + public function forceDelete(User $user, Customer $customer): bool { $findWebsites = Domain::where('customer_id', $customer->id)->count(); if ($findWebsites > 0) { Response::deny('Customer has websites, please delete them first.'); + return false; } + return true; } } diff --git a/web/app/Providers/AppServiceProvider.php b/web/app/Providers/AppServiceProvider.php index 9348555..e8ee77e 100644 --- a/web/app/Providers/AppServiceProvider.php +++ b/web/app/Providers/AppServiceProvider.php @@ -2,18 +2,14 @@ namespace App\Providers; - -use App\Events\ModelHostingSubscriptionCreated; -use App\Events\ModelHostingSubscriptionDeleting; - -use App\Listeners\ModelHostingSubscriptionCreatedListener; -use App\Listeners\ModelHostingSubscriptionDeletingListener; - use App\Events\ModelDomainCreated; use App\Events\ModelDomainDeleting; +use App\Events\ModelHostingSubscriptionCreated; +use App\Events\ModelHostingSubscriptionDeleting; use App\Listeners\ModelDomainCreatedListener; use App\Listeners\ModelDomainDeletingListener; - +use App\Listeners\ModelHostingSubscriptionCreatedListener; +use App\Listeners\ModelHostingSubscriptionDeletingListener; use App\Policies\CustomerPolicy; use Filament\Facades\Filament; use Illuminate\Support\Facades\App; @@ -49,10 +45,10 @@ class AppServiceProvider extends ServiceProvider Gate::define('delete-customer', [CustomerPolicy::class, 'delete']); - Event::listen(ModelDomainCreated::class,ModelDomainCreatedListener::class); - Event::listen(ModelDomainDeleting::class,ModelDomainDeletingListener::class); + Event::listen(ModelDomainCreated::class, ModelDomainCreatedListener::class); + Event::listen(ModelDomainDeleting::class, ModelDomainDeletingListener::class); - Event::listen(ModelHostingSubscriptionCreated::class,ModelHostingSubscriptionCreatedListener::class); - Event::listen(ModelHostingSubscriptionDeleting::class,ModelHostingSubscriptionDeletingListener::class); + Event::listen(ModelHostingSubscriptionCreated::class, ModelHostingSubscriptionCreatedListener::class); + Event::listen(ModelHostingSubscriptionDeleting::class, ModelHostingSubscriptionDeletingListener::class); } } diff --git a/web/app/Providers/Filament/AdminPanelProvider.php b/web/app/Providers/Filament/AdminPanelProvider.php index 25eee84..1a289a7 100644 --- a/web/app/Providers/Filament/AdminPanelProvider.php +++ b/web/app/Providers/Filament/AdminPanelProvider.php @@ -43,7 +43,7 @@ class AdminPanelProvider extends PanelProvider ->brandLogo(asset('images/phyre-logo.svg')) ->brandLogoHeight('2.4rem') ->colors([ - Color::Yellow + Color::Yellow, ]) // ->colors([ // 'primary' => [ @@ -67,27 +67,27 @@ class AdminPanelProvider extends PanelProvider ->discoverResources(in: app_path('Filament/Resources'), for: 'App\\Filament\\Resources') ->discoverPages(in: app_path('Filament/Pages'), for: 'App\\Filament\\Pages') - ->discoverClusters(in: module_path('Microweber', 'Filament/Clusters'), for: "Modules\\Microweber\\Filament\\Clusters") + ->discoverClusters(in: module_path('Microweber', 'Filament/Clusters'), for: 'Modules\\Microweber\\Filament\\Clusters') ->pages([ Pages\Dashboard::class, ]) ->plugins([ - // FilamentAuthenticationLogPlugin::make(), + // FilamentAuthenticationLogPlugin::make(), FilamentApexChartsPlugin::make(), FilamentSettingsPlugin::make()->pages([ Settings::class, - ]) + ]), ]) // ->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\\Filament\\Widgets') ->widgets([ ServerDiskUsageStatistic::class, ServerMemoryStatistic::class, - // ServerMemoryStatisticCount::class, + // ServerMemoryStatisticCount::class, CustomersCount::class, Websites::class, - // Widgets\AccountWidget::class, -// Widgets\FilamentInfoWidget::class, + // Widgets\AccountWidget::class, + // Widgets\FilamentInfoWidget::class, ]) ->middleware([ EncryptCookies::class, diff --git a/web/app/Settings.php b/web/app/Settings.php index 12cf12f..417e8f1 100644 --- a/web/app/Settings.php +++ b/web/app/Settings.php @@ -16,7 +16,7 @@ class Settings public static function general() { $settings = setting('general'); - if (!empty($settings)) { + if (! empty($settings)) { foreach ($settings as $key => $value) { if (isset(self::$general[$key])) { self::$general[$key] = $value; @@ -26,5 +26,4 @@ class Settings return self::$general; } - } diff --git a/web/app/ShellApi.php b/web/app/ShellApi.php index b077a3f..f777b01 100644 --- a/web/app/ShellApi.php +++ b/web/app/ShellApi.php @@ -7,16 +7,16 @@ class ShellApi public static function exec($command, $argsArray = []) { $args = ''; - if (!empty($argsArray)) { + if (! empty($argsArray)) { foreach ($argsArray as $arg) { - $args .= escapeshellarg($arg) . ' '; + $args .= escapeshellarg($arg).' '; } } - $fullCommand = $command . ' ' . $args; + $fullCommand = $command.' '.$args; // Run the command as sudo "/usr/bin/sudo " - $execOutput = shell_exec("/usr/bin/sudo " . $fullCommand); + $execOutput = shell_exec('/usr/bin/sudo '.$fullCommand); $execOutput = str_replace(PHP_EOL, '', $execOutput); return $execOutput; @@ -25,14 +25,14 @@ class ShellApi public static function callBin($command, $argsArray = []) { $args = ''; - if (!empty($argsArray)) { + if (! empty($argsArray)) { foreach ($argsArray as $arg) { - $args .= escapeshellarg($arg) . ' '; + $args .= escapeshellarg($arg).' '; } } - $fullCommand = escapeshellarg('/usr/local/phyre/bin/' . $command . '.sh') . ' ' . $args; - $commandAsSudo = '/usr/bin/sudo ' . $fullCommand; + $fullCommand = escapeshellarg('/usr/local/phyre/bin/'.$command.'.sh').' '.$args; + $commandAsSudo = '/usr/bin/sudo '.$fullCommand; $execOutput = shell_exec($commandAsSudo); diff --git a/web/app/Statistics/ServerStatistic.php b/web/app/Statistics/ServerStatistic.php index 4817135..3ac56c7 100644 --- a/web/app/Statistics/ServerStatistic.php +++ b/web/app/Statistics/ServerStatistic.php @@ -2,19 +2,17 @@ namespace App\Statistics; -use Illuminate\Support\Facades\Cache; - class ServerStatistic { public function getCurrentStats() { - $memory =[ + $memory = [ 'total' => 0, 'used' => 0, 'free' => 0, 'shared' => 0, 'buffCache' => 0, - 'available' => 0 + 'available' => 0, ]; $freeMemoryExec = shell_exec('free -m | grep Mem | awk \'{print $1 " " $2 " " $3 " " $4 " " $5 " " $6 " " $7}\''); @@ -52,16 +50,16 @@ class ServerStatistic 'used' => 0, 'free' => 0, 'usedPercentage' => 0, - 'mountedOn' => '' + 'mountedOn' => '', ]; if (isset($diskMemoryExp[0])) { - $diskMemory['total'] = $diskMemoryExp[0]. 'B'; + $diskMemory['total'] = $diskMemoryExp[0].'B'; } if (isset($diskMemoryExp[1])) { - $diskMemory['used'] = $diskMemoryExp[1]. 'B'; + $diskMemory['used'] = $diskMemoryExp[1].'B'; } if (isset($diskMemoryExp[2])) { - $diskMemory['free'] = $diskMemoryExp[2]. 'B'; + $diskMemory['free'] = $diskMemoryExp[2].'B'; } if (isset($diskMemoryExp[3])) { $diskMemory['usedPercentage'] = $diskMemoryExp[3]; @@ -70,7 +68,7 @@ class ServerStatistic $cpuLoad = [ '1min' => 0, '5min' => 0, - '15min' => 0 + '15min' => 0, ]; $cpuLoadExec = shell_exec('uptime'); $cpuLoadExp = explode('load average:', $cpuLoadExec); @@ -98,28 +96,26 @@ class ServerStatistic 'disk' => $diskMemory, 'cpu' => $cpuLoad, 'totalTasks' => $totalTasks, - 'uptime' => $uptime + 'uptime' => $uptime, ]; } - public function getFormattedFileSize($size, $precision) { - switch (true) - { - case ($size/1024 < 1): + public function getFormattedFileSize($size, $precision) + { + switch (true) { + case $size / 1024 < 1: return $size.'B'; - case ($size/pow(1024, 2) < 1): - return round($size/1024, $precision).'KB'; - case ($size/pow(1024, 3) < 1): - return round($size/pow(1024, 2), $precision).'MB'; - case ($size/pow(1024, 4) < 1): - return round($size/pow(1024, 3), $precision).'GB'; - case ($size/pow(1024, 5) < 1): - return round($size/pow(1024, 4), $precision).'TB'; + case $size / pow(1024, 2) < 1: + return round($size / 1024, $precision).'KB'; + case $size / pow(1024, 3) < 1: + return round($size / pow(1024, 2), $precision).'MB'; + case $size / pow(1024, 4) < 1: + return round($size / pow(1024, 3), $precision).'GB'; + case $size / pow(1024, 5) < 1: + return round($size / pow(1024, 4), $precision).'TB'; default: return 'Error: invalid input or file is too large.'; } } - - } diff --git a/web/app/VirtualHosts/ApacheVirtualHostConfigBase.php b/web/app/VirtualHosts/ApacheVirtualHostConfigBase.php index 8f6759c..289c31b 100644 --- a/web/app/VirtualHosts/ApacheVirtualHostConfigBase.php +++ b/web/app/VirtualHosts/ApacheVirtualHostConfigBase.php @@ -14,5 +14,4 @@ abstract class ApacheVirtualHostConfigBase return $configValues; } - } diff --git a/web/app/VirtualHosts/ApacheVirtualHostManager.php b/web/app/VirtualHosts/ApacheVirtualHostManager.php index 943cc68..8ddff66 100644 --- a/web/app/VirtualHosts/ApacheVirtualHostManager.php +++ b/web/app/VirtualHosts/ApacheVirtualHostManager.php @@ -15,16 +15,16 @@ class ApacheVirtualHostManager { $allConfigs = []; foreach ($this->registerConfigs as $module => $configs) { - if (!in_array($module, $forModules)) { + if (! in_array($module, $forModules)) { continue; } foreach ($configs as $config) { try { $registerConfigInstance = app()->make($config); $getConfig = $registerConfigInstance->getConfig(); - if (!empty($getConfig)) { + if (! empty($getConfig)) { foreach ($getConfig as $key => $value) { - if (!isset($allConfigs[$key])) { + if (! isset($allConfigs[$key])) { $allConfigs[$key] = []; } $allConfigs[$key] = array_merge($allConfigs[$key], $value); @@ -38,5 +38,4 @@ class ApacheVirtualHostManager return $allConfigs; } - } diff --git a/web/composer.json b/web/composer.json index 2571e4b..7ee7e4e 100644 --- a/web/composer.json +++ b/web/composer.json @@ -32,7 +32,7 @@ }, "require-dev": { "fakerphp/faker": "^1.9.1", - "laravel/pint": "^1.0", + "laravel/pint": "^1.15", "laravel/sail": "^1.18", "mockery/mockery": "^1.4.4", "nunomaduro/collision": "^7.0", diff --git a/web/composer.lock b/web/composer.lock index dbaf7e4..8a19d61 100644 --- a/web/composer.lock +++ b/web/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "bb37d9fbda9151cc830ea85df5e6d431", + "content-hash": "4abe345fdbef63cc6393bf28582dc8cf", "packages": [ { "name": "acmephp/core", diff --git a/web/config/database.php b/web/config/database.php index 38f65eb..863f0dc 100644 --- a/web/config/database.php +++ b/web/config/database.php @@ -35,13 +35,13 @@ return [ 'connections' => [ -// 'sqlite' => [ -// 'driver' => 'sqlite', -// 'url' => env('DATABASE_URL'), -// 'database' => env('DB_DATABASE', database_path('database.sqlite')), -// 'prefix' => '', -// 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true), -// ], + // 'sqlite' => [ + // 'driver' => 'sqlite', + // 'url' => env('DATABASE_URL'), + // 'database' => env('DB_DATABASE', database_path('database.sqlite')), + // 'prefix' => '', + // 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true), + // ], 'sqlite' => [ 'driver' => 'sqlite', diff --git a/web/config/filament-authentication-log.php b/web/config/filament-authentication-log.php index 81eeb6e..2e2871b 100644 --- a/web/config/filament-authentication-log.php +++ b/web/config/filament-authentication-log.php @@ -4,45 +4,45 @@ return [ 'notifications' => [ -// 'new-device' => [ -// -// // Send the NewDevice notification -// -// 'enabled' => env('NEW_DEVICE_NOTIFICATION', true), -// -// -// -// // Use torann/geoip to attempt to get a location -// -// 'location' => true, -// -// -// -// // The Notification class to send -// -// 'template' => \Rappasoft\LaravelAuthenticationLog\Notifications\NewDevice::class, -// -// ], -// -// 'failed-login' => [ -// -// // Send the FailedLogin notification -// -// 'enabled' => env('FAILED_LOGIN_NOTIFICATION', false), -// -// -// -// // Use torann/geoip to attempt to get a location -// -// 'location' => true, -// -// -// -// // The Notification class to send -// -// 'template' => \Rappasoft\LaravelAuthenticationLog\Notifications\FailedLogin::class, -// -// ], + // 'new-device' => [ + // + // // Send the NewDevice notification + // + // 'enabled' => env('NEW_DEVICE_NOTIFICATION', true), + // + // + // + // // Use torann/geoip to attempt to get a location + // + // 'location' => true, + // + // + // + // // The Notification class to send + // + // 'template' => \Rappasoft\LaravelAuthenticationLog\Notifications\NewDevice::class, + // + // ], + // + // 'failed-login' => [ + // + // // Send the FailedLogin notification + // + // 'enabled' => env('FAILED_LOGIN_NOTIFICATION', false), + // + // + // + // // Use torann/geoip to attempt to get a location + // + // 'location' => true, + // + // + // + // // The Notification class to send + // + // 'template' => \Rappasoft\LaravelAuthenticationLog\Notifications\FailedLogin::class, + // + // ], ], diff --git a/web/database/migrations/2024_04_01_073021_create_domain_ssl_certificates_table.php b/web/database/migrations/2024_04_01_073021_create_domain_ssl_certificates_table.php index 4926014..d4b9235 100644 --- a/web/database/migrations/2024_04_01_073021_create_domain_ssl_certificates_table.php +++ b/web/database/migrations/2024_04_01_073021_create_domain_ssl_certificates_table.php @@ -32,7 +32,6 @@ return new class extends Migration $table->longText('private_key')->nullable(); $table->longText('certificate_chain')->nullable(); - $table->timestamps(); }); } diff --git a/web/database/seeders/DatabaseSeeder.php b/web/database/seeders/DatabaseSeeder.php index 6aa62f9..3d8b397 100644 --- a/web/database/seeders/DatabaseSeeder.php +++ b/web/database/seeders/DatabaseSeeder.php @@ -14,7 +14,7 @@ class DatabaseSeeder extends Seeder public function run(): void { $findHostingPlan = HostingPlan::where('slug', 'free')->first(); - if (!$findHostingPlan) { + if (! $findHostingPlan) { HostingPlan::create([ 'name' => 'Hosting Free', 'slug' => 'free', @@ -37,7 +37,7 @@ class DatabaseSeeder extends Seeder } $findHostingPlan = HostingPlan::where('slug', 'basic')->first(); - if (!$findHostingPlan) { + if (! $findHostingPlan) { HostingPlan::create([ 'name' => 'Hosting Basic', 'slug' => 'basic', @@ -60,7 +60,7 @@ class DatabaseSeeder extends Seeder } $findHostingPlan = HostingPlan::where('slug', 'pro')->first(); - if (!$findHostingPlan) { + if (! $findHostingPlan) { HostingPlan::create([ 'name' => 'Hosting Pro', 'slug' => 'pro', diff --git a/web/public/index.php b/web/public/index.php index 24d0093..1d69f3a 100644 --- a/web/public/index.php +++ b/web/public/index.php @@ -1,4 +1,5 @@ group(function () { Route::get('/user', function (Request $request) { return $request->user(); }); }); - diff --git a/web/routes/web.php b/web/routes/web.php index 0a839fc..82dbc8a 100644 --- a/web/routes/web.php +++ b/web/routes/web.php @@ -2,20 +2,6 @@ use Illuminate\Support\Facades\Route; - -use AcmePhp\Core\Protocol\ExternalAccount; -use AcmePhp\Core\Http\Base64SafeEncoder; -use AcmePhp\Core\Http\SecureHttpClientFactory; -use AcmePhp\Core\Http\ServerErrorHandler; -use AcmePhp\Ssl\KeyPair; -use AcmePhp\Ssl\PrivateKey; -use AcmePhp\Ssl\PublicKey; -use AcmePhp\Ssl\Parser\KeyParser; -use AcmePhp\Ssl\Signer\DataSigner; -use GuzzleHttp\Client as GuzzleHttpClient; -use AcmePhp\Ssl\Generator\KeyPairGenerator; -use AcmePhp\Core\AcmeClient; - /* |-------------------------------------------------------------------------- | Web Routes @@ -41,6 +27,4 @@ Route::get('dev', function () { set_time_limit(0); - - });