This commit is contained in:
Bozhidar Slaveykov 2024-04-06 16:01:46 +03:00
parent 000a0db564
commit 67cd7ec58b
103 changed files with 383 additions and 517 deletions

View file

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

View file

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

View file

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

View file

@ -7,7 +7,6 @@ use App\VirtualHosts\ApacheVirtualHostConfigBase;
class LetsEncryptApacheVirtualHostConfig extends ApacheVirtualHostConfigBase
{
public array $phpAdminValueOpenBaseDirs = [
'/usr/share/letsencrypt'
'/usr/share/letsencrypt',
];
}

View file

@ -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;
@ -106,6 +106,5 @@ class HostingAccountIsCreatedListener
$applySSLVirtualHost->setSslCertificateChainFilePath($sslCertificateChainFilePath);
$applySSLVirtualHost->handle();
}
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -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,
];
}
@ -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;

View file

@ -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,7 +21,6 @@ class Whitelabel extends BaseSettings
protected static ?string $navigationLabel = 'Whitelabel';
public static function getNavigationLabel(): 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'),
])
]),
];
}
}

View file

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

View file

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

View file

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

View file

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

View file

@ -9,5 +9,4 @@ class MicroweberCluster extends Cluster
protected static ?string $navigationIcon = 'heroicon-o-squares-2x2';
protected static ?string $navigationGroup = 'Server Management';
}

View file

@ -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
{
@ -95,6 +93,5 @@ class DomainIsCreatedListener
}
}
}

View file

@ -7,7 +7,6 @@ use App\VirtualHosts\ApacheVirtualHostConfigBase;
class MicroweberApacheVirtualHostConfig extends ApacheVirtualHostConfigBase
{
public array $phpAdminValueOpenBaseDirs = [
'/usr/share/microweber'
'/usr/share/microweber',
];
}

View file

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

View file

@ -1,15 +1,13 @@
<?php
namespace Modules\Microweber\Shell\Adapters;
use App\ShellApi;
use MicroweberPackages\SharedServerScripts\Shell\Adapters\IShellExecutor;
use MicroweberPackages\SharedServerScripts\Shell\Adapters\pm_ApiCli;
class PhyreShellExecutor implements IShellExecutor
{
/**
* @param string $file
* @param array $args
* @return mixed
*/
public function executeFile(string $file, array $args)

View file

@ -5,7 +5,7 @@ return [
'sharedPaths' => [
'app' => '/usr/share/microweber/latest',
'modules' => '/usr/share/microweber/latest/userfiles/modules',
'templates'=>'/usr/share/microweber/latest/userfiles/templates'
'templates' => '/usr/share/microweber/latest/userfiles/templates',
],
];

View file

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

View file

@ -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)
@ -106,7 +108,6 @@ class ApacheWebsiteCreate
file_put_contents('/etc/apache2/sites-available/'.$settings['domain'].'.conf', $apache2Sample);
$indexContent = '
<?php print_r($_ENV); ?>
@ -115,7 +116,6 @@ class ApacheWebsiteCreate
';
file_put_contents($settings['domainPublic'].'/index.php', $indexContent);
shell_exec('chown -R '.$settings['user'].':'.$settings['group'].' '.$allDomainsRoot);
@ -141,7 +141,7 @@ class ApacheWebsiteCreate
'user' => $this->user,
'email' => $this->email,
'linuxUser' => $linuxUser,
'apache2Sample' => $apache2Sample
'apache2Sample' => $apache2Sample,
];
}

View file

@ -21,7 +21,6 @@ class ApacheWebsiteDelete
$apacheConfEnabled = '/etc/apache2/sites-enabled/'.$this->domain.'.conf';
ShellApi::exec('rm -rf '.$apacheConfEnabled);
// SSL
$apacheSSLConf = '/etc/apache2/sites-available/'.$this->domain.'-ssl.conf';
ShellApi::exec('rm -rf '.$apacheSSLConf);

View file

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

View file

@ -7,7 +7,9 @@ use App\ShellApi;
class CreateLinuxWebUser
{
public $username;
public $email;
public $password;
public function setUsername($username)

View file

@ -6,6 +6,6 @@ class ApiClient
{
public static function getPhyrePHP()
{
return "/usr/local/phyre/php/bin/php";
return '/usr/local/phyre/php/bin/php';
}
}

View file

@ -57,8 +57,6 @@ class ApachePingWebsitesWithCurl extends Command
}
return 0;
}
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -16,7 +16,6 @@ class Modules extends Page
protected static ?int $navigationSort = 1;
protected function getViewData(): array
{
return [
@ -27,7 +26,7 @@ class Modules extends Page
'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' => [
@ -36,15 +35,15 @@ class Modules extends Page
'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.',
'url' => url('admin/wordpress'),
'iconUrl' => url('images/modules/wordpress.svg'),
'category'=>'Content Management'
]
'category' => 'Content Management',
],
],
'E-Commerce' => [
[
@ -52,11 +51,10 @@ class Modules extends Page
'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'
'category' => 'E-Commerce',
],
],
],
]
];
}
}

View file

@ -1,4 +1,5 @@
<?php
namespace App\Filament\Pages\Settings;
use Closure;
@ -8,7 +9,6 @@ use Outerweb\FilamentSettings\Filament\Pages\Settings as BaseSettings;
class Settings extends BaseSettings
{
protected static ?string $navigationGroup = 'Server Management';
protected static ?int $navigationSort = 2;

View file

@ -3,15 +3,11 @@
namespace App\Filament\Resources;
use App\Filament\Resources\BackupResource\Pages;
use App\Filament\Resources\BackupResource\RelationManagers;
use App\Models\Backup;
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 BackupResource extends Resource
{

View file

@ -3,7 +3,6 @@
namespace App\Filament\Resources\BackupResource\Pages;
use App\Filament\Resources\BackupResource;
use Filament\Actions;
use Filament\Resources\Pages\CreateRecord;
class CreateBackup extends CreateRecord

View file

@ -3,15 +3,12 @@
namespace App\Filament\Resources;
use App\Filament\Resources\CronJobResource\Pages;
use App\Filament\Resources\CronJobResource\RelationManagers;
use App\Models\CronJob;
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 CronJobResource extends Resource
{

View file

@ -3,7 +3,6 @@
namespace App\Filament\Resources\CronJobResource\Pages;
use App\Filament\Resources\CronJobResource;
use Filament\Actions;
use Filament\Resources\Pages\CreateRecord;
class CreateCronJob extends CreateRecord

View file

@ -3,16 +3,12 @@
namespace App\Filament\Resources;
use App\Filament\Resources\CustomerResource\Pages;
use App\Filament\Resources\CustomerResource\RelationManagers;
use App\Models\Customer;
use Faker\Provider\Text;
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 CustomerResource extends Resource
{
@ -71,7 +67,7 @@ class CustomerResource extends Resource
->sortable(),
Tables\Columns\TextColumn::make('email')
->searchable()
->sortable()
->sortable(),
])
->defaultSort('id', 'desc')
->filters([

View file

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

View file

@ -25,7 +25,7 @@ class EditCustomer extends EditRecord
->send();
$action->cancel();
}
})
}),
];
}
}

View file

@ -2,7 +2,6 @@
namespace App\Filament\Resources\CustomerResource\Pages;
use App\Filament\Resources\CustomerResource;
use Filament\Actions;
use Filament\Resources\Pages\ManageRecords;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -2,7 +2,6 @@
namespace App\Filament\Resources\HostingSubscriptionResource\Pages;
use App\Filament\Resources\HostingSubscriptionResource;
use Filament\Actions;
use Filament\Resources\Pages\ManageRecords;

View file

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

View file

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

View file

@ -19,7 +19,6 @@ class CustomersCount extends BaseWidget
// $serverStatistic = new \App\Statistics\ServerStatistic();
// $serverStats = $serverStatistic->getCurrentStats();
$customersCount = Customer::count();
$websiteCount = Domain::count();
@ -32,7 +31,6 @@ class CustomersCount extends BaseWidget
// Stat::make('Available Memory', $serverStats['memory']['available']),
//
Stat::make('Websites', $websiteCount)->icon('heroicon-o-globe-alt'),
Stat::make('Customers', $customersCount)->icon('heroicon-o-users'),
Stat::make('Active Customers', $customersCount)->icon('heroicon-o-user-group'),

View file

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

View file

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

View file

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

View file

@ -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;
@ -34,7 +33,7 @@ class Websites extends BaseWidget
->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');
}
}

View file

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

View file

@ -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,7 +73,7 @@ class CustomersController extends ApiController
'message' => 'Customer created',
'data' => [
'customer' => $customer,
]
],
]);
}
@ -94,7 +100,7 @@ class CustomersController extends ApiController
'message' => 'Hosting subscriptions found',
'data' => [
'hostingSubscriptions' => $findHostingSubscriptions,
]
],
]);
}
}

View file

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

View file

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

View file

@ -18,7 +18,7 @@ class HostingSubscriptionsController extends ApiController
'message' => 'Hosting subscriptions found',
'data' => [
'HostingSubscriptions' => $findHostingSubscription,
]
],
]);
}
@ -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',

View file

@ -1,4 +1,5 @@
<?php
namespace App\Http\Controllers\Api\Request;
class CustomerCreateRequest extends AuthorizedApiRequest
@ -12,7 +13,7 @@ class CustomerCreateRequest extends AuthorizedApiRequest
{
return [
'name' => 'required',
'email' => 'required|email|unique:customers,email'
'email' => 'required|email|unique:customers,email',
];
}
}

View file

@ -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"
* ),
@ -19,6 +20,4 @@ class ApiController extends BaseController
{
// use AuthorizesRequests, ValidatesRequests;
use ValidatesRequests;
}

View file

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

View file

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

View file

@ -75,7 +75,7 @@ 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);

View file

@ -3,7 +3,6 @@
namespace App\Listeners;
use App\Actions\GetLinuxUser;
use App\Events\ModelHostingSubscriptionCreated;
use App\Events\ModelHostingSubscriptionDeleting;
use App\Models\Domain;
@ -38,5 +37,4 @@ class ModelHostingSubscriptionDeletingListener
}
}
}

View file

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

View file

@ -2,7 +2,6 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Sushi\Sushi;

View file

@ -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,7 +63,7 @@ class CronJob extends Model
$user = ShellApi::exec('whoami');
$cronList = ShellApi::callBin('cron-jobs-list', [
$user
$user,
]);
$rows = [];

View file

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

View file

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

View file

@ -23,5 +23,4 @@ class DomainSslCertificate extends Model
'renewed_date',
'renewed_until_date',
];
}

View file

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

View file

@ -34,5 +34,4 @@ class HostingPlan extends Model
'features' => 'array',
'limitations' => 'array',
];
}

View file

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

View file

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

View file

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

View file

@ -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
@ -65,8 +65,10 @@ class CustomerPolicy
$findWebsites = Domain::where('customer_id', $customer->id)->count();
if ($findWebsites > 0) {
Response::deny('Customer has websites, please delete them first.');
return false;
}
return true;
}
}

View file

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

View file

@ -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,7 +67,7 @@ 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,
@ -77,7 +77,7 @@ class AdminPanelProvider extends PanelProvider
FilamentApexChartsPlugin::make(),
FilamentSettingsPlugin::make()->pages([
Settings::class,
])
]),
])
// ->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\\Filament\\Widgets')
->widgets([

View file

@ -26,5 +26,4 @@ class Settings
return self::$general;
}
}

View file

@ -16,7 +16,7 @@ class ShellApi
$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;

View file

@ -2,8 +2,6 @@
namespace App\Statistics;
use Illuminate\Support\Facades\Cache;
class ServerStatistic
{
public function getCurrentStats()
@ -14,7 +12,7 @@ class ServerStatistic
'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,7 +50,7 @@ class ServerStatistic
'used' => 0,
'free' => 0,
'usedPercentage' => 0,
'mountedOn' => ''
'mountedOn' => '',
];
if (isset($diskMemoryExp[0])) {
$diskMemory['total'] = $diskMemoryExp[0].'B';
@ -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)
public function getFormattedFileSize($size, $precision)
{
case ($size/1024 < 1):
switch (true) {
case $size / 1024 < 1:
return $size.'B';
case ($size/pow(1024, 2) < 1):
case $size / pow(1024, 2) < 1:
return round($size / 1024, $precision).'KB';
case ($size/pow(1024, 3) < 1):
case $size / pow(1024, 3) < 1:
return round($size / pow(1024, 2), $precision).'MB';
case ($size/pow(1024, 4) < 1):
case $size / pow(1024, 4) < 1:
return round($size / pow(1024, 3), $precision).'GB';
case ($size/pow(1024, 5) < 1):
case $size / pow(1024, 5) < 1:
return round($size / pow(1024, 4), $precision).'TB';
default:
return 'Error: invalid input or file is too large.';
}
}
}

View file

@ -14,5 +14,4 @@ abstract class ApacheVirtualHostConfigBase
return $configValues;
}
}

View file

@ -38,5 +38,4 @@ class ApacheVirtualHostManager
return $allConfigs;
}
}

View file

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

2
web/composer.lock generated
View file

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

View file

@ -32,7 +32,6 @@ return new class extends Migration
$table->longText('private_key')->nullable();
$table->longText('certificate_chain')->nullable();
$table->timestamps();
});
}

View file

@ -1,4 +1,5 @@
<?php
use Illuminate\Contracts\Http\Kernel;
use Illuminate\Http\Request;

View file

@ -16,7 +16,6 @@ use Illuminate\Support\Facades\Route;
Route::get('health', [\App\Http\Controllers\Api\HealthController::class, 'index']);
Route::get('customers', [\App\Http\Controllers\Api\CustomersController::class, 'index']);
Route::post('customers', [\App\Http\Controllers\Api\CustomersController::class, 'store']);
Route::get('customers/{id}', [\App\Http\Controllers\Api\CustomersController::class, 'show']);
@ -30,11 +29,9 @@ Route::delete('hosting-subscriptions/{id}', [\App\Http\Controllers\Api\HostingSu
Route::get('hosting-plans', [\App\Http\Controllers\Api\HostingPlansController::class, 'index']);
Route::middleware('auth:sanctum')->group(function () {
Route::get('/user', function (Request $request) {
return $request->user();
});
});

View file

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