Compare commits

...

143 Commits
1.5.3 ... 2.3

Author SHA1 Message Date
Dennis
b5963693e6 Prod mix 2022-06-27 10:26:40 +02:00
Dennis
1b7ea67fde Merge branch 'develop'
# Conflicts:
#	public/css/app.css
#	public/js/app.js
2022-06-27 10:25:39 +02:00
Dennis
d4f2b9839e package updates 2022-06-27 10:25:10 +02:00
Dennis
817f6a175c wip 2022-06-27 10:23:57 +02:00
Dennis
b3619e5941 wip 2022-06-20 09:14:56 +02:00
Dennis
33784410e5 wip trial 2022-06-07 13:36:49 +02:00
Dennis
6ecf7904fe wip roadmap 2022-06-07 11:31:39 +02:00
Dennis
21986f2394 add ability to run octane 2022-06-07 11:00:56 +02:00
Dennis
4d8212e56f package updates and add aws for ses emailing 2022-06-07 10:58:38 +02:00
Dennis
865f2958cf Merge branch 'develop' 2022-05-23 16:43:39 +02:00
Dennis
17890d13ad Merge branch 'develop' of https://github.com/ploi-deploy/ploi-core into develop 2022-05-23 16:43:28 +02:00
Dennis
2d33455731 Closes #1 2022-05-23 16:43:15 +02:00
Dennis
49481f9b6a Prod mix 2022-04-14 12:39:01 +02:00
Dennis
7bb800cc0a Merge branch 'develop'
# Conflicts:
#	public/css/app.css
#	public/js/app.js
2022-04-14 12:38:06 +02:00
Dennis
1b8c2c764f fx 2022-04-14 12:37:39 +02:00
Dennis
cb1a1c4c06 w 2022-04-12 10:18:47 +02:00
Dennis
ddd80a8687 site email 2022-04-11 19:13:40 +02:00
Dennis
010d4569c2 package updates 2022-04-11 18:54:44 +02:00
Dennis
62ae0f8299 wip 2022-04-09 19:06:17 +02:00
Dennis
2a3d9cabd0 wip 2022-04-09 07:54:47 +02:00
Dennis
e2a58cf2df tweaks 2022-04-07 14:48:45 +02:00
Dennis
0fd6db251b remove these 2022-04-07 14:47:31 +02:00
Dennis
94d50c11ef wip 2022-04-07 14:46:56 +02:00
Dennis
14c6faafa2 wip 2022-04-07 14:21:57 +02:00
Dennis
ea21076eda wip 2022-04-07 11:15:06 +02:00
Dennis
d378323602 wip 2022-04-07 10:52:42 +02:00
Dennis
f074dee990 wip 2022-04-05 14:59:27 +02:00
Dennis
7bd2917ec4 wip 2022-04-01 10:50:05 +02:00
Dennis
823a39ffa2 prod mix 2022-03-23 09:58:27 +01:00
Dennis
6953a8d2b2 Merge branch 'develop'
# Conflicts:
#	public/css/app.css
#	public/js/app.js
2022-03-23 09:58:01 +01:00
Dennis
fb40b450b6 BRL 2022-03-23 09:54:11 +01:00
Dennis
a28c053945 wip 2022-03-23 09:40:29 +01:00
Dennis
ea0c4ed66d wip 2022-03-23 09:06:28 +01:00
Dennis
7a0716959a Laravel 9 upgrade 2022-03-01 11:21:58 +01:00
Dennis
da322d7b1e prod mix 2022-01-21 13:57:39 +01:00
Dennis
bbff8a5403 Merge branch 'develop'
# Conflicts:
#	public/js/app.js
2022-01-21 13:57:04 +01:00
Dennis
c1ad600042 Ability to select database type, package updates, bugfixes 2022-01-21 13:56:48 +01:00
Dennis
5fc32759fd prod mix 2022-01-19 14:29:36 +01:00
Dennis
59cfd8d71b Merge branch 'develop'
# Conflicts:
#	public/css/app.css
#	public/js/app.js
2022-01-19 14:28:00 +01:00
Dennis
51d5b89df7 wip 2022-01-19 14:26:08 +01:00
Dennis
7c0dcbeb88 TW3.0 upgrade 2021-12-24 16:30:41 +01:00
Dennis
b4467f8d5b Package updates 2021-12-21 09:04:54 +01:00
Dennis
363f4ed801 default to predis here 2021-12-21 08:58:25 +01:00
Dennis
1b6b950fb5 Bugfixing 2021-12-21 08:57:55 +01:00
Dennis
90988f1538 Prod mix 2021-12-19 21:58:01 +01:00
Dennis
139ba793d0 Merge branch 'develop'
# Conflicts:
#	public/js/app.js
2021-12-19 21:57:32 +01:00
Dennis
c505dd0924 PSR 2021-12-19 21:57:23 +01:00
Dennis
ca5ee33978 Bugfix in terms page, made system available in demo 2021-12-19 21:57:10 +01:00
Dennis
c2fd5e3fa9 Prod mix 2021-12-07 15:20:10 +01:00
Dennis
b04176ce48 Merge branch 'develop'
# Conflicts:
#	public/js/app.js
2021-12-07 15:19:25 +01:00
Dennis
5136a4b9f8 Bugfix 2021-12-07 15:18:35 +01:00
Dennis
dcee703aa1 wip 2021-11-30 13:30:21 +01:00
Dennis
7c504339d9 Added favicon if logo is uploaded 2021-11-30 13:18:10 +01:00
Dennis
5ea0761fe9 prod mix 2021-11-24 11:25:14 +01:00
Dennis
c9125c3be8 Merge branch 'develop'
# Conflicts:
#	public/js/app.js
2021-11-24 11:22:00 +01:00
Dennis
84503c19db Ability to revoke card & DNS fix on site show 2021-11-24 11:20:24 +01:00
Dennis
cfd9eba5d7 Ability to remove logo and pagination to system logs 2021-11-19 14:14:20 +01:00
Dennis
10689d3d12 Ability to rotate logs in system 2021-11-19 13:52:32 +01:00
Dennis
e190fb7805 prod mix 2021-11-02 11:44:32 +01:00
Dennis
c1351f7d28 Merge branch 'develop'
# Conflicts:
#	public/js/app.js
2021-11-02 11:43:24 +01:00
Dennis
01f5469e86 Generic fixes 2021-11-02 11:43:10 +01:00
Dennis
8c5c86eb6a Preserve scroll by default 2021-11-02 11:26:53 +01:00
Dennis
995ada46aa Prod mix 2021-09-27 09:51:05 +02:00
Dennis
2e79381872 Merge branch 'develop'
# Conflicts:
#	public/js/app.js
2021-09-27 09:50:24 +02:00
Dennis
d1c7b9a418 Fixes 2021-09-27 09:49:42 +02:00
Dennis
34da2f563d Ability to configure per page number 2021-09-23 14:22:01 +02:00
Dennis
5cf77fde1c Package updates 2021-09-23 08:28:54 +02:00
Dennis
aabf6f27ac Ran PSR formatter 2021-09-23 08:27:27 +02:00
Dennis
fbcaee3bdc prod mix 2021-09-23 08:26:39 +02:00
Dennis
3082c10cdb Merge branch 'develop'
# Conflicts:
#	public/js/app.js
2021-09-23 08:26:03 +02:00
Dennis
a4d90f0017 OG image updatee readme 2021-09-23 08:25:52 +02:00
Dennis
8adfc9837e fixes 2021-09-23 08:20:22 +02:00
Dennis
aa20c8a42b prod mix 2021-09-16 09:51:17 +02:00
Dennis
0f100d6159 Merge branch 'develop'
# Conflicts:
#	public/css/app.css
#	public/js/app.js
2021-09-16 09:50:07 +02:00
Dennis
7c896243a5 wip 2021-09-16 09:49:53 +02:00
Dennis
954fef7c3e Dynamic servers tab, fix for domain uppercase 2021-09-16 09:19:41 +02:00
Dennis
105126e498 prod mix 2021-08-25 09:20:18 +02:00
Dennis
7aa5a8949d Merge branch 'develop'
# Conflicts:
#	public/js/app.js
2021-08-25 09:19:45 +02:00
Dennis
27079928a7 added demo quick-login support 2021-08-25 09:19:10 +02:00
Dennis
99968e57ec wip 2021-08-17 13:00:47 +02:00
Dennis
f75bc1a551 Production mix 2021-08-12 11:25:19 +02:00
Dennis
ef347f9381 Merge branch 'develop' 2021-08-12 11:24:30 +02:00
Dennis
f1aace3d8f Ability to select allowed regions/plans per provider 2021-08-12 11:23:01 +02:00
Dennis
b2bec62766 Merge branch 'develop'
# Conflicts:
#	public/js/app.js
2021-08-12 11:03:51 +02:00
Dennis
3a8682bbed Textual change 2021-08-12 11:03:25 +02:00
Dennis
5cfc1f97fe Logo fix 2021-08-12 10:26:29 +02:00
Dennis
cfc8220f8e Wip 2021-08-12 10:23:23 +02:00
Dennis
ac5ffefaed Horizon status to system settings tab 2021-08-10 14:04:52 +02:00
Dennis
cbd2b8e0e9 Wip on terms & privacy page configurator 2021-08-10 13:51:37 +02:00
Dennis
f0f427a7bb General improvements 2021-08-05 11:31:38 +02:00
Dennis
7b6f651015 Consistent Ploi class instantiate 2021-08-05 11:14:16 +02:00
Dennis
c793daa79a wip 2021-08-05 11:08:19 +02:00
Dennis
71b436aebe Production mix 2021-08-04 10:17:42 +02:00
Dennis
06e108da5b Merge branch 'develop'
# Conflicts:
#	public/js/app.js
2021-08-04 10:17:03 +02:00
Dennis
5677c58dd2 Package updates 2021-08-04 10:07:36 +02:00
Dennis
58ca801e30 PSR formatting 2021-08-04 09:49:47 +02:00
Dennis
e750d7caba Cleaning 2021-08-04 09:49:24 +02:00
Dennis
3c0964ef0e Bugfixes in server settings, site creation 2021-08-04 09:46:11 +02:00
Dennis
33613cdf1c Sync all sites & servers, bugfix in pagination providers 2021-08-04 09:36:28 +02:00
Dennis
abfe174825 Autofocus on login page 2021-08-04 09:19:40 +02:00
Dennis
c750f469bb Updates
- Generic demo check in base controller
- Site synchronization
- User show pagination preserve scroll
2021-08-03 11:58:38 +02:00
Dennis
c7ac56d5cc Wip custom certificates 2021-07-29 09:59:20 +02:00
Dennis
6601f44013 wip custom certificates 2021-07-29 09:07:06 +02:00
Dennis
b7baf862b6 prod mix 2021-07-27 08:33:16 +02:00
Dennis
ca79f4cf21 Merge branch 'develop'
# Conflicts:
#	public/js/app.js
2021-07-27 08:32:39 +02:00
Dennis
58ffbe8c74 URL fixes 2021-07-27 08:32:30 +02:00
Dennis
dfa7b995fc wip 2021-07-23 13:46:53 +02:00
Dennis
59c65fe6ee prod 2021-07-18 10:12:47 +02:00
Dennis
087c042c14 Merge branch 'develop'
# Conflicts:
#	public/js/app.js
2021-07-18 10:12:15 +02:00
Dennis
d1ee488ffd fixes 2021-07-18 10:11:50 +02:00
Dennis
34100bc580 prod mix 2021-07-14 09:51:24 +02:00
Dennis
22d91517fb Merge branch 'develop'
# Conflicts:
#	public/js/app.js
2021-07-14 09:50:10 +02:00
Dennis
1c088bd4e0 Bugfixes and improvements 2021-07-14 09:50:00 +02:00
Dennis
fd5bbb7f5d Merge branch 'develop' 2021-07-13 14:49:03 +02:00
Dennis
426d39bec0 wip 2021-07-13 14:48:56 +02:00
Dennis
8244c2dfb2 Merge branch 'develop' 2021-07-13 14:23:54 +02:00
Dennis
e7f9d32f68 wip 2021-07-13 14:23:49 +02:00
Dennis
71158a0030 prod 2021-07-12 12:33:07 +02:00
Dennis
573ce14b7a Merge branch 'develop'
# Conflicts:
#	public/css/app.css
#	public/js/app.js
2021-07-12 12:31:37 +02:00
Dennis
00ef1f470f add debugging 2021-07-12 12:31:19 +02:00
Dennis
a9357034c8 THB currency, annual billing added 2021-07-12 12:26:21 +02:00
Dennis
a45f5157d4 wip 2021-07-09 11:48:12 +02:00
Dennis
0d1009b8db horizon config update 2021-07-09 11:45:57 +02:00
Dennis
4f0416cd45 Added user show, pagination simplified, package updates 2021-07-09 09:08:09 +02:00
Dennis
76655d76d5 Installation command improvements 2021-07-08 14:26:28 +02:00
Dennis
3b38cbe9ac Merge branch 'develop' 2021-06-17 09:18:34 +02:00
Dennis
acf37b8850 Suppport PHP 8 2021-06-17 09:18:28 +02:00
Dennis
f47a0699d3 Merge branch 'develop' 2021-06-07 09:18:21 +02:00
Dennis
8ae429b06b Tweak 2021-06-07 09:18:14 +02:00
Dennis
626dbbcb49 Fix 2021-06-05 20:30:22 +02:00
Dennis
b623dd80fd Merge branch 'develop' 2021-05-31 15:55:32 +02:00
Dennis
3978a7c9f7 User deleting fix 2021-05-31 15:53:58 +02:00
Dennis
7d2acb7438 Merge branch 'develop' 2021-05-31 08:55:21 +02:00
Dennis
096032301c Fix when deleting user with support tickets 2021-05-31 08:55:15 +02:00
Dennis
c3e99bf2ff Merge branch 'develop' 2021-05-25 07:37:34 +02:00
Dennis
9795642bc7 Bugfix 2021-05-25 07:37:28 +02:00
Dennis
4281a432fb Merge branch 'develop' 2021-05-22 09:36:29 +02:00
Dennis
18df5589b1 Fix title 2021-05-22 09:36:25 +02:00
Dennis
79536eac2e Fresh mix 2021-05-19 09:38:13 +02:00
Dennis
6df82fca04 Clean push 2021-05-19 09:36:22 +02:00
Dennis
cc14123d27 Merge branch 'develop' 2021-05-19 09:36:04 +02:00
Dennis
bd5e7b87ff Package update && password uncomprimised 2021-05-19 09:35:54 +02:00
Dennis
42568916d6 prod mix 2021-05-18 12:17:24 +02:00
445 changed files with 13495 additions and 14547 deletions

View File

@@ -26,6 +26,7 @@ SESSION_LIFETIME=120
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
REDIS_CLIENT=predis
MAIL_MAILER=smtp
MAIL_HOST=smtp.mailtrap.io

5
.gitignore vendored
View File

@@ -12,4 +12,9 @@ npm-debug.log
yarn-error.log
.idea
.php_cs.cache
.php-cs-fixer.cache
/public/js/resources*.js
/storage/views/header.blade.php
/storage/views/footer.blade.php
rr
.rr.yaml

View File

@@ -3,7 +3,7 @@
With Ploi Core, you'll power-launch your webhosting company.
Using the ploi.io system as backbone you will be able to serve your customers your custom panel & feeling.
<p align="center"><img src="https://ploi-core.io/images/featured.png" width="100%"></p>
<p align="center"><img src="https://ploi-core.io/images/og.jpg" width="100%"></p>
## Documentation

26
app/Casts/SiteAlias.php Normal file
View File

@@ -0,0 +1,26 @@
<?php
namespace App\Casts;
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
class SiteAlias implements CastsAttributes
{
public function get($model, string $key, $value, array $attributes)
{
if (!$value) {
return [];
}
$data = json_decode($value, true);
sort($data);
return $data;
}
public function set($model, string $key, $value, array $attributes)
{
return json_encode($value);
}
}

View File

@@ -0,0 +1,60 @@
<?php
namespace App\Console\Commands\Core;
use App\Models\SystemLog;
use Illuminate\Console\Command;
class Cleanup extends Command
{
protected $signature = 'core:cleanup';
protected $description = 'Clean up any old logs';
public function handle()
{
if (!setting('rotate_logs_after')) {
return Command::SUCCESS;
}
$rotationDate = $this->getRotationDate();
$rotated = SystemLog::query()
->where('created_at', '<', $rotationDate)
->delete();
$this->info('Rotated ' . $rotated . ' system logs!');
return Command::SUCCESS;
}
protected function getRotationDate()
{
switch (setting('rotate_logs_after')) {
case 'weeks-1':
return now()->subWeek();
break;
case 'months-1':
return now()->subMonth();
break;
case 'months-3':
return now()->subMonths(3);
break;
case 'months-6':
return now()->subMonths(6);
break;
case 'years-1':
return now()->subYear();
break;
case 'years-2':
return now()->subYears(2);
break;
case 'years-3':
return now()->subYears(3);
break;
case 'years-4':
return now()->subYears(4);
break;
}
}
}

View File

@@ -7,6 +7,7 @@ use App\Models\User;
use RuntimeException;
use App\Models\Package;
use App\Services\Ploi\Ploi;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Illuminate\Console\Command;
use App\Services\VersionChecker;
@@ -17,7 +18,7 @@ use Illuminate\Support\Facades\Artisan;
class Install extends Command
{
protected $company;
protected $signature = 'core:install';
protected $signature = 'core:install {--force}';
protected $description = 'Installation command for Ploi Core';
protected $versionChecker;
protected $installationFile = 'app/installation';
@@ -37,7 +38,15 @@ class Install extends Command
$this->createInstallationFile();
$this->linkStorage();
$this->info('Succes! Installation has finished.');
$this->info('Success! Installation has finished.');
$this->line(' ');
$this->writeSeparationLine();
$this->info('Make sure to also setup emailing, the cronjob and the queue worker.');
$this->line(' ');
$this->info('Setting up emailing: https://docs.ploi-core.io/getting-started/setting-up-email');
$this->info('Setting up cronjob & queue worker: https://docs.ploi-core.io/getting-started/installation');
$this->writeSeparationLine();
$this->line(' ');
$this->info('Visit your platform at ' . env('APP_URL'));
}
@@ -48,28 +57,32 @@ class Install extends Command
protected function askAboutAdministrationAccount()
{
$this->info('Let\'s start by setting up your administration account.');
if (!User::query()->where('role', User::ADMIN)->count()) {
$this->info('Let\'s start by setting up your administration account.');
$name = $this->ask('What is your name', $this->company['user_name']);
$email = $this->ask('What is your e-mail address', $this->company['email']);
$password = $this->secret('What password do you desire');
$name = $this->ask('What is your name', $this->company['user_name']);
$email = $this->ask('What is your e-mail address', $this->company['email']);
$password = $this->secret('What password do you desire');
$check = User::where('email', $email)->count();
$check = User::where('email', $email)->count();
if ($check) {
$this->line('');
$this->comment('This user is already present in your system, please refresh your database or use different credentials.');
$this->comment('Aborting installation..');
if ($check) {
$this->line('');
$this->comment('This user is already present in your system, please refresh your database or use different credentials.');
$this->comment('Aborting installation..');
exit();
exit();
}
User::forceCreate([
'name' => $name,
'email' => $email,
'password' => $password,
'role' => User::ADMIN
]);
} else {
$this->line('Already found a administrator user in your system. Use that user to login.');
}
User::forceCreate([
'name' => $name,
'email' => $email,
'password' => $password,
'role' => User::ADMIN
]);
}
protected function askAboutDefaultPackages()
@@ -140,7 +153,9 @@ class Install extends Command
->get((new Ploi)->url . 'ping');
if (!$response->ok() || !$response->json()) {
return false;
return [
'error' => Arr::get($response->json(), 'message', 'An unknown error has occurred.')
];
}
return $response->json();
@@ -155,7 +170,7 @@ class Install extends Command
protected function intro()
{
$this->info('*---------------------------------------------------------------------------*');
$this->writeSeparationLine();
$this->line('Ploi Core Installation');
$this->line('Ploi Core version: ' . $this->versionChecker->currentVersion);
$this->line('Ploi Core remote: ' . $this->versionChecker->remoteVersion);
@@ -165,13 +180,13 @@ class Install extends Command
$this->line('Website: https://ploi-core.io');
$this->line('E-mail: core@ploi.io');
$this->line('Terms of service: https://ploi-core.io/terms');
$this->info('*---------------------------------------------------------------------------*');
$this->writeSeparationLine();
$this->line('');
}
protected function isInstalled()
{
if (file_exists(storage_path($this->installationFile))) {
if (file_exists(storage_path($this->installationFile)) && !$this->option('force')) {
$this->line('');
$this->comment('Ploi Core has already been installed before.');
$this->comment('If you still want to start installation, remove this file to continue: ./storage/' . $this->installationFile);
@@ -187,9 +202,9 @@ class Install extends Command
{
if (!config('app.key')) {
$this->call('key:generate');
}
$this->info('Application key has been set');
$this->info('Application key has been set');
}
}
protected function checkApplicationUrl()
@@ -276,6 +291,18 @@ class Install extends Command
exit();
}
if (isset($this->company['error'])) {
$this->error($this->company['error']);
exit();
}
if ($this->company['user']['subscription'] !== 'unlimited') {
$this->error('Your subscription does not cover the usage of Ploi Core. Please upgrade your subscription to Unlimited.');
exit();
}
$this->writeToEnvironmentFile('PLOI_TOKEN', $ploiApiToken);
$this->writeToEnvironmentFile('PLOI_CORE_TOKEN', $ploiCoreKey);
@@ -288,7 +315,7 @@ class Install extends Command
protected function runDatabaseMigrations()
{
$this->info('Running database migrations..');
$this->call('migrate');
$this->call('migrate', ['--force' => true]);
$this->info('Database migrations successful');
}
@@ -379,4 +406,9 @@ class Install extends Command
{
$this->laravel['config'][$key] = $value;
}
protected function writeSeparationLine()
{
$this->info('*---------------------------------------------------------------------------*');
}
}

View File

@@ -9,7 +9,7 @@ class Synchronize extends Command
{
protected $signature = 'core:synchronize';
protected $description = 'Synchronze data';
protected $description = 'Synchronize data';
public function handle()
{

View File

@@ -0,0 +1,24 @@
<?php
namespace App\Console\Commands\Core;
use App\Models\User;
use Illuminate\Console\Command;
class Trial extends Command
{
protected $signature = 'core:trial';
protected $description = 'Check for expired trials';
public function handle()
{
User::query()
->where('trial_ends_at', '<', now())
->each(function (User $user) {
$user->trial_ends_at = null;
$user->package_id = setting('default_package');
$user->save();
});
}
}

View File

@@ -2,8 +2,10 @@
namespace App\Console;
use App\Console\Commands\Core\Trial;
use App\Jobs\Core\Ping;
use App\Console\Commands\Core\Css;
use App\Console\Commands\Core\Cleanup;
use App\Console\Commands\Core\Install;
use App\Console\Commands\Core\CssBackup;
use App\Console\Commands\Core\Synchronize;
@@ -17,6 +19,8 @@ class Kernel extends ConsoleKernel
CssBackup::class,
Install::class,
Synchronize::class,
Cleanup::class,
Trial::class,
];
protected function schedule(Schedule $schedule)
@@ -24,5 +28,8 @@ class Kernel extends ConsoleKernel
$schedule->call(function () {
dispatch(new Ping())->delay(now()->addMinutes(rand(1, 30)));
})->dailyAt('02:00');
$schedule->command('core:cleanup')->daily();
$schedule->command('core:trial')->dailyAt('10:00');
}
}

View File

@@ -28,7 +28,7 @@ if (!function_exists('setting')) {
$value = Arr::get(app('settings'), $key, $default);
// Boolean casting
if ($value === "0" || $value === "1") {
if ($value === "0" || $value === "1" && $key !== 'trial_package') {
return (bool) $value;
}

View File

@@ -10,14 +10,17 @@ use App\Http\Controllers\Controller;
class DashboardController extends Controller
{
public function index()
public function __invoke()
{
return inertia('Admin/Dashboard', [
'servers' => Server::count(),
'sites' => Site::count(),
'users' => User::count(),
'logs' => SystemLog::latest()->limit(10)->with('model')->get()
->map(function (SystemLog $systemLog) {
'logs' => SystemLog::query()
->latest()
->with('model')
->paginate(5)
->through(function (SystemLog $systemLog) {
return [
'title' => __($systemLog->title, [
'site' => $systemLog->model->domain ?? '-Unknown-'

View File

@@ -14,6 +14,8 @@ class ProviderController extends Controller
return inertia('Admin/Services/Provider/Edit', [
'provider' => $provider,
'availablePlans' => $provider->plans()->pluck('label', 'id'),
'availableRegions' => $provider->regions()->pluck('label', 'id'),
]);
}

View File

@@ -4,12 +4,39 @@ namespace App\Http\Controllers\Admin;
use App\Models\User;
use App\Models\Server;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Http\Resources\Admin\ServerResource;
use App\Http\Requests\Admin\ServerAttachRequest;
class ServerController extends Controller
{
public function index()
{
return inertia('Admin/Servers/Index', [
'filters' => request()->all('search'),
'servers' => ServerResource::collection(
Server::query()
->when(request()->input('search'), function (Builder $query, $value) {
return $query
->where('name', 'like', '%' . $value . '%')
->orWhere('ip', 'like', '%' . $value . '%')
->orWhereHas('users', function (Builder $query) use ($value) {
return $query
->where('name', 'LIKE', '%' . $value . '%')
->orWhere('email', 'LIKE', '%' . $value . '%');
});
})
->with('users:id,name')
->withCount('sites')
->latest()
->paginate(config('core.pagination.per_page'))
->withQueryString()
)
]);
}
public function edit($id)
{
$server = Server::findOrFail($id);

View File

@@ -12,12 +12,12 @@ class ServiceController extends Controller
public function index()
{
return inertia('Admin/Services/Index', [
'servers' => Server::withCount('sites')->latest()->paginate(5, ['*'], 'servers_per_page'),
'sites' => Site::with('server:id,name')->latest()->paginate(5, ['*'], 'sites_per_page'),
'servers' => Server::query()->withCount('sites', 'users')->latest()->paginate(config('core.pagination.per_page'), ['*'], 'servers_per_page'),
'sites' => Site::with('server:id,name')->withCount('users')->latest()->paginate(config('core.pagination.per_page'), ['*'], 'sites_per_page'),
'providers' => Provider::query()
->withCount('regions', 'plans', 'servers')
->latest()
->paginate(5, ['*'], 'providers_per_page'),
->paginate(config('core.pagination.per_page'), ['*'], 'providers_per_page'),
]);
}
}

View File

@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Admin;
use App\Models\Package;
use Illuminate\Support\Str;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Storage;
use App\Http\Requests\Admin\SettingRequest;
@@ -21,10 +22,15 @@ class SettingController extends Controller
'allow_registration' => setting('allow_registration'),
'default_package' => setting('default_package'),
'receive_email_on_server_creation' => setting('receive_email_on_server_creation'),
'receive_email_on_site_creation' => setting('receive_email_on_site_creation'),
'isolate_per_site_per_user' => setting('isolate_per_site_per_user'),
'enable_api' => setting('enable_api'),
'api_token' => setting('api_token') ? decrypt(setting('api_token')) : null,
'default_language' => setting('default_language', 'en')
'rotate_logs_after' => setting('rotate_logs_after') ? setting('rotate_logs_after') : null,
'default_language' => setting('default_language', 'en'),
'has_logo' => (bool)setting('logo'),
'trial' => setting('trial'),
'trial_package' => setting('trial_package'),
];
$packages = Package::pluck('name', 'id');
@@ -47,10 +53,14 @@ class SettingController extends Controller
'documentation',
'default_package',
'receive_email_on_server_creation',
'receive_email_on_site_creation',
'isolate_per_site_per_user',
'enable_api',
'api_token',
'default_language'
'default_language',
'rotate_logs_after',
'trial',
'trial_package'
]) as $key => $value) {
if ($key === 'api_token') {
$value = encrypt($value);
@@ -87,4 +97,51 @@ class SettingController extends Controller
return redirect()->route('admin.settings')->with('success', __('Settings have been updated'));
}
public function terms()
{
return inertia('Admin/Terms', [
'terms_settings' => [
'logo' => setting('logo'),
'name' => setting('name'),
'terms_required' => setting('accept_terms_required'),
'terms' => setting('terms'),
'privacy' => setting('privacy')
]
]);
}
public function updateTerms(Request $request)
{
setting(['accept_terms_required' => $request->input('terms_required'),]);
setting(['terms' => $request->input('terms'),]);
setting(['privacy' => $request->input('privacy'),]);
return redirect()->route('admin.settings.terms')->with('success', __('Terms have been updated'));
}
public function termsTemplate(Request $request)
{
$template = file_get_contents(storage_path('templates/terms-of-service.md'));
$template = str_replace([
'{NAME}',
'{WEBSITE}',
'{DATE}'
], [
setting('name'),
config('app.url'),
date('Y-m-d')
], $template);
return ['content' => $template];
}
public function removeLogo(Request $request)
{
Storage::delete(setting('logo'));
setting(['logo' => null]);
return redirect()->back()->with('success', 'Logo has ben removed');
}
}

View File

@@ -2,6 +2,7 @@
namespace App\Http\Controllers\Admin;
use App\Http\Resources\Admin\SiteResource;
use App\Models\Site;
use App\Models\User;
use Illuminate\Http\Request;
@@ -10,6 +11,23 @@ use App\Http\Requests\Admin\ServerAttachRequest;
class SiteController extends Controller
{
public function index()
{
return inertia('Admin/Sites/Index', [
'filters' => request()->all('search'),
'sites' => SiteResource::collection(
Site::query()
->when(request()->input('search'), function ($query, $value) {
return $query->where('domain', 'like', '%' . $value . '%');
})
->with('server:id,name', 'users:id,name')
->latest()
->paginate(config('core.pagination.per_page'))
->withQueryString()
)
]);
}
public function edit($id)
{
$site = Site::findOrFail($id);

View File

@@ -3,7 +3,6 @@
namespace App\Http\Controllers\Admin;
use App\Models\Provider;
use App\Services\Ploi\Ploi;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
@@ -11,15 +10,15 @@ class SynchronizeProviderController extends Controller
{
public function index()
{
if (config('app.demo')) {
if ($this->isDemo()) {
return redirect('/')->with('info', __('This feature is not available in demo mode.'));
}
$ploi = new Ploi(config('services.ploi.token'));
$availableProviders = $this->getPloi()->user()->serverProviders()->getData();
$availableProviders = $ploi->user()->serverProviders()->getData();
$currentProviders = Provider::whereNotIn('id', array_keys((array)$availableProviders))->get();
$currentProviders = Provider::query()
->whereNotIn('id', array_keys((array)$availableProviders))
->get();
return inertia('Admin/Services/Providers', [
'availableProviders' => $availableProviders,
@@ -29,7 +28,7 @@ class SynchronizeProviderController extends Controller
public function synchronize(Request $request, $providerId)
{
$ploiProvider = (new Ploi)->user()->serverProviders($providerId)->getData();
$ploiProvider = $this->getPloi()->user()->serverProviders($providerId)->getData();
$provider = Provider::updateOrCreate([
'ploi_id' => $ploiProvider->id,

View File

@@ -3,7 +3,6 @@
namespace App\Http\Controllers\Admin;
use App\Models\Server;
use App\Services\Ploi\Ploi;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
@@ -11,15 +10,15 @@ class SynchronizeServerController extends Controller
{
public function index()
{
if (config('app.demo')) {
if ($this->isDemo()) {
return redirect('/')->with('info', __('This feature is not available in demo mode.'));
}
$ploi = new Ploi(config('services.ploi.token'));
$availableServers = $this->getPloi()->synchronize()->servers()->getData();
$availableServers = $ploi->synchronize()->servers()->getData();
$currentServers = Server::whereNotIn('id', array_keys((array)$availableServers))->get();
$currentServers = Server::query()
->whereNotIn('id', array_keys((array)$availableServers))
->get();
return inertia('Admin/Services/Servers', [
'availableServers' => $availableServers,
@@ -29,15 +28,37 @@ class SynchronizeServerController extends Controller
public function synchronizeServer(Request $request)
{
Server::updateOrCreate([
'ploi_id' => $request->input('id')
], [
'status' => $request->input('status'),
'name' => $request->input('name'),
'ip' => $request->input('ip_address'),
'ssh_port' => $request->input('ssh_port', 22),
'internal_ip' => $request->input('internal_ip'),
'available_php_versions' => $request->input('installed_php_versions')
]);
Server::query()
->updateOrCreate([
'ploi_id' => $request->input('id')
], [
'status' => $request->input('status'),
'name' => $request->input('name'),
'ip' => $request->input('ip_address'),
'ssh_port' => $request->input('ssh_port', 22),
'internal_ip' => $request->input('internal_ip'),
'available_php_versions' => $request->input('installed_php_versions')
]);
}
public function synchronizeAll(Request $request)
{
$availableServers = $this->getPloi()->synchronize()->servers()->getData();
foreach ($availableServers as $availableServer) {
Server::query()
->updateOrCreate([
'ploi_id' => $availableServer->id
], [
'status' => $availableServer->status,
'name' => $availableServer->name,
'ip' => $availableServer->ip_address,
'ssh_port' => $availableServer->ssh_port,
'internal_ip' => $availableServer->internal_ip,
'available_php_versions' => $availableServer->installed_php_versions
]);
}
return response('ok');
}
}

View File

@@ -2,12 +2,85 @@
namespace App\Http\Controllers\Admin;
use App\Models\Site;
use App\Models\Server;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
class SynchronizeSiteController extends Controller
{
public function index()
{
return inertia('Admin/Services/Sites');
if ($this->isDemo()) {
return redirect('/')->with('info', __('This feature is not available in demo mode.'));
}
$availableSites = $this->getPloi()->synchronize()->sites()->getData();
$currentSites = Site::query()
->whereNotIn('id', array_keys((array)$availableSites))
->get();
return inertia('Admin/Services/Sites', [
'availableSites' => $availableSites,
'currentSites' => $currentSites
]);
}
public function synchronizeSite(Request $request)
{
$server = Server::query()->where('ploi_id', $request->input('server_id'))->firstOrFail();
/* @var $site \App\Models\Site */
$site = Site::query()
->updateOrCreate([
'ploi_id' => $request->input('id')
], [
'domain' => $request->input('domain'),
'php_version' => $request->input('php_version'),
'project' => $request->input('project_type')
]);
$site->status = $request->input('status');
$site->server_id = $server->id;
$site->save();
$certificates = $this->getPloi()->server($request->input('server_id'))->sites($request->input('id'))->certificates()->get()->getData();
if ($certificates) {
foreach ($certificates as $certificate) {
$site->certificates()->updateOrCreate([
'ploi_id' => $certificate->id,
], [
'status' => $certificate->status,
'ploi_id' => $certificate->id,
'domain' => $certificate->domain,
'type' => $certificate->type,
]);
}
}
return response('ok');
}
public function synchronizeAll(Request $request)
{
$availableSites = $this->getPloi()->synchronize()->sites()->getData();
foreach ($availableSites as $availableSite) {
$server = Server::query()->where('ploi_id', $availableSite->server_id)->firstOrFail();
$site = Site::query()
->updateOrCreate([
'ploi_id' => $availableSite->id
], [
'domain' => $availableSite->domain,
'php_version' => $availableSite->php_version,
]);
$site->status = $availableSite->status;
$site->server_id = $server->id;
$site->save();
}
}
}

View File

@@ -6,15 +6,12 @@ use Illuminate\Http\Request;
use App\Jobs\Core\UpdateSystem;
use App\Services\VersionChecker;
use App\Http\Controllers\Controller;
use Laravel\Horizon\Contracts\MasterSupervisorRepository;
class SystemController extends Controller
{
public function index()
public function index(MasterSupervisorRepository $masterSupervisorRepository)
{
if (config('app.demo')) {
return redirect('/')->with('info', __('This feature is not available in demo mode.'));
}
$version = (new VersionChecker)->getVersions();
return inertia('Admin/System', [
@@ -22,7 +19,8 @@ class SystemController extends Controller
'out_of_date' => $version->isOutOfDate(),
'current' => $version->currentVersion,
'remote' => $version->remoteVersion
]
],
'horizonRunning' => !!$masterSupervisorRepository->all()
]);
}

View File

@@ -11,12 +11,14 @@ class UserController extends Controller
{
public function index()
{
$users = User::with('package:id,name')
$users = User::query()
->withCount('sites', 'servers')
->with('package:id,name')
->when(request()->input('search'), function ($query, $value) {
return $query->where('name', 'like', '%' . $value . '%')->orWhere('email', 'like', '%' . $value . '%');
})
->latest()
->paginate(5);
->paginate(config('core.pagination.per_page'));
return inertia('Admin/Users/Index', [
'filters' => request()->all('search'),
@@ -45,8 +47,8 @@ class UserController extends Controller
$user->save();
}
if ($package = $request->input('package')) {
$user->package_id = $package;
if ($request->input('package') && Package::find($request->input('package'))) {
$user->package_id = $request->input('package');
$user->save();
}
@@ -55,7 +57,17 @@ class UserController extends Controller
public function show($id)
{
// TODO: Implement show feature for a user
$user = User::query()->findOrFail($id);
$servers = $user->servers()->withCount('sites')->latest()->paginate(config('core.pagination.per_page'), ['*'], 'page_servers');
$sites = $user->sites()->with('server:id,name')->latest()->paginate(config('core.pagination.per_page'), ['*'], 'page_sites');
return inertia('Admin/Users/Show', [
'user' => $user,
'sites' => $sites,
'servers' => $servers,
]);
}
public function edit($id)

View File

@@ -7,6 +7,7 @@ use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\Rules\Password;
use Illuminate\Foundation\Auth\RegistersUsers;
class RegisterController extends Controller
@@ -27,27 +28,55 @@ class RegisterController extends Controller
protected function validator(array $data)
{
return Validator::make($data, [
$rules = [
'name' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
'password' => ['required', 'string', 'min:8', 'confirmed'],
]);
'password' => [
'required',
'string',
'confirmed',
Password::defaults()
],
];
if (setting('accept_terms_required')) {
$rules['terms'] = [
'accepted'
];
}
return Validator::make($data, $rules);
}
protected function create(array $data)
{
return User::create([
$fields = [
'name' => $data['name'],
'email' => $data['email'],
'password' => $data['password'],
]);
];
if ($days = setting('trial')) {
$fields['trial_ends_at'] = now()->addDays($days);
}
return User::create($fields);
}
protected function registered(Request $request, $user)
{
if (setting('default_package') && setting('default_package') != 'false') {
if (
setting('default_package') &&
setting('default_package') != 'false' &&
!setting('trial')
) {
$user->package_id = setting('default_package');
$user->save();
}
if (setting('trial') && setting('trial_package')) {
$user->package_id = setting('trial_package');
$user->save();
}
}
}

View File

@@ -2,11 +2,17 @@
namespace App\Http\Controllers;
use App\Traits\HasPloi;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
class Controller extends BaseController
{
use ValidatesRequests, AuthorizesRequests;
use ValidatesRequests, AuthorizesRequests, HasPloi;
protected function isDemo()
{
return config('app.demo');
}
}

View File

@@ -2,10 +2,29 @@
namespace App\Http\Controllers;
use Illuminate\Support\Str;
class PageController extends Controller
{
public function installationIncomplete()
{
return inertia('Core/InstallationIncomplete');
}
public function show($slug)
{
if ($slug === 'terms-of-service' && setting('terms')) {
return inertia('Pages/Terms', [
'content' => Str::markdown(setting('terms'))
]);
}
if ($slug === 'privacy-policy' && setting('privacy')) {
return inertia('Pages/Privacy', [
'content' => Str::markdown(setting('privacy'))
]);
}
abort(404);
}
}

View File

@@ -22,7 +22,11 @@ class ProfileBillingController extends Controller
$packages = Package::query()
->where(function ($query) {
return $query
->where('price_monthly', '>', 0)
->where(function ($query) {
return $query
->where('price_monthly', '>', 0)
->orWhere('price_yearly', '>', 0);
})
->whereNotNull('plan_id');
})
->when($request->input('sortBy.' . $sortByType), function ($query, $value) use ($sortByType) {
@@ -55,7 +59,14 @@ class ProfileBillingController extends Controller
->transform(function (Package $package) {
$currency = $this->transformCurrency($package->currency);
$package->period = 'monthly';
if ($package->price_yearly > 0) {
$package->period = 'yearly';
}
$package->price_monthly = ($currency ?? '[Unknown currency]') . number_format($package->price_monthly, 2, ',', '.');
$package->price_yearly = ($currency ?? '[Unknown currency]') . number_format($package->price_yearly, 2, ',', '.');
return $package;
});
@@ -66,11 +77,14 @@ class ProfileBillingController extends Controller
return inertia('Profile/BillingError');
}
$subscription = $user->subscription();
return inertia('Profile/Billing', [
'packages' => $packages,
'countries' => countries(),
'subscription' => $user->subscription('default'),
'subscription' => $subscription,
'public_key' => config('cashier.key'),
'ends' => $subscription ? Carbon::createFromTimeStamp($subscription->asStripeSubscription()->current_period_end)->format('F jS, Y') ?? null : null,
'data_client_secret' => $clientSecret,
'card' => [
'last_four' => $user->card_last_four,
@@ -111,6 +125,16 @@ class ProfileBillingController extends Controller
return redirect()->route('profile.billing.index')->with('success', 'Your card has been added, you can now update your plan');
}
public function deleteCard(Request $request)
{
/** @var User $user */
$user = $request->user();
$user->deletePaymentMethods();
return redirect()->route('profile.billing.index')->with('success', 'Your credit card has been removed from your account');
}
public function updatePlan(Request $request)
{
/** @var User $user */
@@ -198,8 +222,10 @@ class ProfileBillingController extends Controller
Package::CURRENCY_AUD => 'AUD $',
Package::CURRENCY_GBP => 'GBP £',
Package::CURRENCY_INR => 'INR ₹',
Package::CURRENCY_THB => 'THB ',
Package::CURRENCY_BRL=> 'BRL R$ ',
];
return $currencies[strtolower($key)];
return $currencies[strtolower($key)] ?? '$';
}
}

View File

@@ -37,4 +37,21 @@ class ProfileController extends Controller
return $mode;
}
public function destroy(Request $request)
{
/* @var $user \App\Models\User */
$user = $request->user();
$user->sites()->detach();
$user->servers()->detach();
$user->supportTicketReplies()->delete();
$user->supportTickets()->delete();
$user->delete();
auth()->logout();
return redirect()->route('login');
}
}

View File

@@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use App\Models\Server;
use App\Models\User;
use Illuminate\Http\Request;
use App\Jobs\Servers\CreateServer;
@@ -38,7 +39,8 @@ class ServerController extends Controller
/* @var $server \App\Models\Server */
$server = $request->user()->servers()->create([
'name' => $request->input('name')
'name' => $request->input('name'),
'database_type' => $request->input('database_type', 'mysql')
]);
$server->provider()->associate($provider);
@@ -65,6 +67,10 @@ class ServerController extends Controller
{
$server = auth()->user()->servers()->findOrFail($id);
if ($server->status === Server::STATUS_BUSY) {
return redirect()->back()->with('info', 'This server is currently busy, please check back later.');
}
return inertia('Servers/Show', [
'server' => $server,
'sites' => $server->sites()->latest()->paginate(5, ['*'], 'sites_per_page'),
@@ -104,9 +110,21 @@ class ServerController extends Controller
{
$provider = $request->user()->package->providers()->findOrFail($providerId);
$regions = $provider->regions()
->when($provider->allowed_regions, function ($query) use ($provider) {
return $query->whereIn('id', $provider->allowed_regions);
})
->pluck('label', 'id');
$plans = $provider->plans()
->when($provider->allowed_plans, function ($query) use ($provider) {
return $query->whereIn('id', $provider->allowed_plans);
})
->pluck('label', 'id');
return [
'regions' => $provider->regions()->pluck('label', 'id'),
'plans' => $provider->plans()->pluck('label', 'id'),
'regions' => $regions,
'plans' => $plans,
];
}
}

View File

@@ -0,0 +1,44 @@
<?php
namespace App\Http\Controllers;
use App\Http\Requests\SiteAliasRequest;
use App\Http\Resources\SiteAliasResource;
use App\Jobs\Aliases\CreateAlias;
use App\Jobs\Aliases\DeleteAlias;
use Illuminate\Http\Request;
class SiteAliasController extends Controller
{
public function index($id)
{
$site = auth()->user()->sites()->findOrFail($id);
return inertia('Sites/Aliases', [
'site' => $site,
'aliases' => $site->aliases
]);
}
public function store(SiteAliasRequest $request, $id)
{
$site = $request->user()->sites()->findOrFail($id);
$site->addAlias($request->input('domain'));
dispatch(new CreateAlias($site, $request->input('domain')));
return redirect()->route('sites.aliases.index', $id)->with('success', __('Alias has been created'));
}
public function destroy($id, $alias)
{
$site = auth()->user()->sites()->findOrFail($id);
dispatch(new DeleteAlias($site, $alias));
$site->removeAlias($alias);
return redirect()->route('sites.aliases.index', $id)->with('success', __('Alias has been deleted'));
}
}

View File

@@ -25,6 +25,9 @@ class SiteCertificateController extends Controller
$certificate = $site->certificates()->create([
'domain' => $request->input('domain'),
'type' => $request->input('type', 'letsencrypt'),
'certificate' => $request->input('certificate'),
'private' => $request->input('private')
]);
$certificate->server_id = $site->server_id;

View File

@@ -2,7 +2,9 @@
namespace App\Http\Controllers;
use App\Mail\Admin\Site\AdminSiteCreatedEmail;
use App\Models\Server;
use App\Models\User;
use Illuminate\Support\Arr;
use Illuminate\Http\Request;
use App\Jobs\Sites\CreateSite;
@@ -10,6 +12,7 @@ use App\Jobs\Sites\DeleteSite;
use App\Http\Requests\SiteRequest;
use App\Http\Resources\SiteResource;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Mail;
class SiteController extends Controller
{
@@ -17,11 +20,12 @@ class SiteController extends Controller
{
$sites = auth()->user()
->sites()
->with('server:id,name')
->when(request('server'), function ($query, $value) {
return $query->where('server_id', $value);
})
->latest()
->paginate(10);
->paginate(config('core.pagination.per_page'));
$availableServers = auth()->user()->servers()->pluck('name', 'id');
@@ -37,7 +41,18 @@ class SiteController extends Controller
$server = $request->user()->servers()->findOrFail($serverId);
} else {
$server = Server::query()
->doesntHave('users')
->where('maximum_sites', '>', 0)
->where(function ($query) {
return $query
->where(function ($query) {
return $query->whereHas('users', function ($query) {
return $query->where('user_id', auth()->id());
});
})
->orWhere(function ($query) {
return $query->doesntHave('users');
});
})
->withCount('sites')
->inRandomOrder()
->first();
@@ -64,6 +79,14 @@ class SiteController extends Controller
'description' => 'A new site has been created'
])->model()->associate($site)->save();
if (setting('receive_email_on_site_creation')) {
$admins = User::query()->where('role', User::ADMIN)->get();
foreach ($admins as $admin) {
Mail::to($admin)->send(new AdminSiteCreatedEmail($request->user(), $server, $site));
}
}
return redirect()->route('sites.index')->with('success', __('Your website is being created'));
}

View File

@@ -16,7 +16,7 @@ class Kernel extends HttpKernel
protected $middleware = [
// \App\Http\Middleware\TrustHosts::class,
\App\Http\Middleware\TrustProxies::class,
\Fruitcake\Cors\HandleCors::class,
\Illuminate\Http\Middleware\HandleCors::class,
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class,
@@ -68,6 +68,7 @@ class Kernel extends HttpKernel
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'has.access' => \App\Http\Middleware\HasAccessToThisGroup::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'global.api.authenticated' => \App\Http\Middleware\GlobalApiAuthenticated::class,
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,

View File

@@ -10,7 +10,7 @@ class Demo
protected $safeRoutes = [
'login',
'logout',
//'profile/toggle-theme'
'profile/toggle-theme'
];
protected $allowedIps = [

View File

@@ -68,7 +68,8 @@ class HandleInertiaRequests extends Middleware
] : null,
'package' => auth()->user() && auth()->user()->package ? [
'name' => auth()->user()->package->name,
'maximum_sites' => auth()->user()->package->maximum_sites
'maximum_sites' => auth()->user()->package->maximum_sites,
'trial' => auth()->user()->onTrial()
] : [
'name' => __('None')
],
@@ -87,7 +88,10 @@ class HandleInertiaRequests extends Middleware
'documentation' => setting('documentation', false),
'logo' => setting('logo'),
'allow_registration' => setting('allow_registration'),
'billing' => config('cashier.key') && config('cashier.secret')
'billing' => config('cashier.key') && config('cashier.secret'),
'has_terms' => (bool)setting('terms'),
'has_privacy' => (bool)setting('privacy'),
'accept_terms_required' => (bool)setting('accept_terms_required')
];
},
'flash' => function () {

View File

@@ -0,0 +1,27 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Arr;
use Illuminate\Http\Request;
class HasAccessToThisGroup
{
public function handle(Request $request, Closure $next, $group)
{
if ($group === 'servers') {
$package = $request->user()->package ?? [];
if (
!Arr::get($package->server_permissions, 'create', false) &&
!Arr::get($package->server_permissions, 'update', false) &&
!Arr::get($package->server_permissions, 'delete', false)
) {
abort(404);
}
}
return $next($request);
}
}

View File

@@ -2,15 +2,15 @@
namespace App\Http\Middleware;
use Illuminate\Http\Middleware\TrustProxies as Middleware;
use Illuminate\Http\Request;
use Fideloper\Proxy\TrustProxies as Middleware;
class TrustProxies extends Middleware
{
/**
* The trusted proxies for this application.
*
* @var array|string|null
* @var array<int, string>|string|null
*/
protected $proxies;
@@ -19,5 +19,10 @@ class TrustProxies extends Middleware
*
* @var int
*/
protected $headers = Request::HEADER_X_FORWARDED_ALL;
protected $headers =
Request::HEADER_X_FORWARDED_FOR |
Request::HEADER_X_FORWARDED_HOST |
Request::HEADER_X_FORWARDED_PORT |
Request::HEADER_X_FORWARDED_PROTO |
Request::HEADER_X_FORWARDED_AWS_ELB;
}

View File

@@ -41,6 +41,8 @@ class PackageRequest extends FormRequest
Package::CURRENCY_CAD,
Package::CURRENCY_GBP,
Package::CURRENCY_INR,
Package::CURRENCY_THB,
Package::CURRENCY_BRL,
])
],
'maximum_sites' => [
@@ -58,7 +60,11 @@ class PackageRequest extends FormRequest
],
'price_monthly' => [
'nullable',
'numeric'
'numeric',
],
'price_yearly' => [
'nullable',
'numeric',
],
'server_permissions' => [
'array'
@@ -78,8 +84,12 @@ class PackageRequest extends FormRequest
$merge['price_monthly'] = 0.000;
}
if (!$this->price_yearly) {
$merge['price_yearly'] = 0.000;
}
// If we don't have the currency filled in, merge a default
if (!$this->price_monthly) {
if (!$this->price_monthly || !$this->price_yearly) {
$merge['currency'] = Package::CURRENCY_USD;
}

View File

@@ -28,6 +28,14 @@ class ProviderRequest extends FormRequest
'required',
'string',
'max:255'
],
'allowed_plans' => [
'nullable',
'array'
],
'allowed_regions' => [
'nullable',
'array'
]
];
}

View File

@@ -39,6 +39,10 @@ class SettingRequest extends FormRequest
'nullable',
'image',
'max:2000'
],
'trial_package' => [
'required_with:trial'
]
];
}

View File

@@ -4,6 +4,7 @@ namespace App\Http\Requests;
use App\Models\Server;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class ServerRequest extends FormRequest
{
@@ -45,6 +46,11 @@ class ServerRequest extends FormRequest
'required',
'not_in:0',
'exists:provider_plans,id'
],
'database_type' => [
'required',
'string',
Rule::in(['mysql', 'mariadb', 'postgresql', 'postgresql13'])
]
];
}

View File

@@ -0,0 +1,25 @@
<?php
namespace App\Http\Requests;
use App\Rules\Hostname;
use Illuminate\Foundation\Http\FormRequest;
class SiteAliasRequest extends FormRequest
{
public function authorize()
{
return auth()->check();
}
public function rules()
{
return [
'domain' => [
'required',
'string',
new Hostname,
]
];
}
}

View File

@@ -25,15 +25,36 @@ class SiteCertificateRequest extends FormRequest
*/
public function rules()
{
return [
'domain' => [
'required',
'string',
Rule::unique('certificates', 'domain')->where(function ($query) {
return $query->where('site_id', $this->route('site'));
}),
new LetsEncryptMatchHostWithIp($this->route('site'))
]
];
$rules = [];
if ($this->input('type') === 'letsencrypt') {
$rules = [
'domain' => [
'required',
'string',
Rule::unique('certificates', 'domain')->where(function ($query) {
return $query->where('site_id', $this->route('site'));
}),
new LetsEncryptMatchHostWithIp($this->route('site'))
]
];
}
if ($this->input('type') === 'custom') {
$rules = [
'certificate' => [
'required',
'string',
'min:5'
],
'private' => [
'required',
'string',
'min:5'
]
];
}
return $rules;
}
}

View File

@@ -0,0 +1,21 @@
<?php
namespace App\Http\Resources\Admin;
use Illuminate\Http\Resources\Json\JsonResource;
class ServerResource extends JsonResource
{
public function toArray($request)
{
return [
'id' => $this->id,
'name' => $this->name,
'ip' => $this->ip,
'users' => $this->users,
'sites_count' => $this->sites_count,
'maximum_sites' => $this->maximum_sites,
'created_at' => $this->created_at->format('Y-m-d H:i:s')
];
}
}

View File

@@ -0,0 +1,13 @@
<?php
namespace App\Http\Resources\Admin;
use Illuminate\Http\Resources\Json\JsonResource;
class SiteResource extends JsonResource
{
public function toArray($request)
{
return parent::toArray($request);
}
}

View File

@@ -7,12 +7,6 @@ use Illuminate\Http\Resources\Json\JsonResource;
class SiteResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
/* @var $this \App\Models\Site */
@@ -20,7 +14,11 @@ class SiteResource extends JsonResource
'id' => $this->id,
'status' => $this->parseStatus($this->status),
'domain' => $this->domain,
'php_version' => $this->php_version,
'project' => $this->project,
'server' => $this->server ? [
'name' => $this->server->name
] : null,
'created_at' => $this->created_at
];
}

View File

@@ -0,0 +1,41 @@
<?php
namespace App\Jobs\Aliases;
use App\Models\Site;
use App\Traits\HasPloi;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class CreateAlias implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, HasPloi;
public Site $site;
public string $alias;
public function __construct(Site $site, $alias)
{
$this->site = $site;
$this->alias = $alias;
}
public function handle()
{
$this->getPloi()
->server($this->site->server->ploi_id)
->sites($this->site->ploi_id)
->aliases()
->create([$this->alias]);
}
public function failed()
{
$this->site->aliases = array_diff($this->site->aliases, [$this->alias]);
$this->site->save();
}
}

View File

@@ -0,0 +1,35 @@
<?php
namespace App\Jobs\Aliases;
use App\Models\Site;
use App\Traits\HasPloi;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class DeleteAlias implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, HasPloi;
public Site $site;
public string $alias;
public function __construct(Site $site, $alias)
{
$this->site = $site;
$this->alias = $alias;
}
public function handle()
{
$this->getPloi()
->server($this->site->server->ploi_id)
->sites($this->site->ploi_id)
->aliases()
->delete($this->alias);
}
}

View File

@@ -2,45 +2,46 @@
namespace App\Jobs\Apps;
use App\Models\Database;
use App\Models\Site;
use App\Services\Ploi\Ploi;
use App\Traits\HasPloi;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Support\Arr;
class InstallApp implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, HasPloi;
public $site;
public Site $site;
public $type;
public $options;
/**
* Create a new job instance.
*
* @param Site $site
* @param string $type
* @param array $options
*/
public function __construct(Site $site, $type = Site::PROJECT_WORDPRESS, array $options = [])
public function __construct(Site $site, string $type = Site::PROJECT_WORDPRESS, array $options = [])
{
$this->site = $site;
$this->type = $type;
$this->options = $options;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
$ploi = new Ploi(config('services.ploi.token'));
$response = $this->getPloi()
->server($this->site->server->ploi_id)
->sites($this->site->ploi_id)
->app()
->install($this->type, $this->options);
$ploi->server($this->site->server->ploi_id)->sites($this->site->ploi_id)->app()->install($this->type, $this->options);
if (Arr::get($this->options, 'create_database', false)) {
$database = $this->site->databases()->create([
'name' => $response->database_name,
]);
$database->status = Database::STATUS_ACTIVE;
$database->save();
}
}
}

View File

@@ -3,7 +3,7 @@
namespace App\Jobs\Apps;
use App\Models\Site;
use App\Services\Ploi\Ploi;
use App\Traits\HasPloi;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
@@ -12,9 +12,9 @@ use Illuminate\Foundation\Bus\Dispatchable;
class UninstallApp implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, HasPloi;
public $site;
public Site $site;
/**
* Create a new job instance.
@@ -37,9 +37,11 @@ class UninstallApp implements ShouldQueue
return;
}
$ploi = new Ploi(config('services.ploi.token'));
$ploi->server($this->site->server->ploi_id)->sites($this->site->ploi_id)->app()->uninstall($this->site->project);
$this->getPloi()
->server($this->site->server->ploi_id)
->sites($this->site->ploi_id)
->app()
->uninstall($this->site->project);
$this->site->project = null;
$this->site->save();

View File

@@ -2,8 +2,8 @@
namespace App\Jobs\Certificates;
use App\Traits\HasPloi;
use App\Models\Certificate;
use App\Services\Ploi\Ploi;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
@@ -12,38 +12,44 @@ use Illuminate\Foundation\Bus\Dispatchable;
class CreateCertificate implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, HasPloi;
public $certificate;
public Certificate $certificate;
/**
* Create a new job instance.
*
* @param Certificate $certificate
*/
public function __construct(Certificate $certificate)
{
$this->certificate = $certificate;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
$ploi = new Ploi(config('services.ploi.token'));
if ($this->certificate->type === 'letsencrypt') {
$ploiCertificate = $this->getPloi()
->server($this->certificate->server->ploi_id)
->sites($this->certificate->site->ploi_id)
->certificates()
->create(
$this->certificate->domain
);
$ploiCertificate = $ploi->server($this->certificate->server->ploi_id)
->sites($this->certificate->site->ploi_id)
->certificates()
->create(
$this->certificate->domain
);
$this->certificate->ploi_id = $ploiCertificate->id;
$this->certificate->save();
}
$this->certificate->ploi_id = $ploiCertificate->id;
$this->certificate->save();
if ($this->certificate->type === 'custom') {
$ploiCertificate = $this->getPloi()
->server($this->certificate->server->ploi_id)
->sites($this->certificate->site->ploi_id)
->certificates()
->create(
$this->certificate->certificate,
$this->certificate->type,
$this->certificate->private
);
$this->certificate->ploi_id = $ploiCertificate->id;
$this->certificate->save();
}
// Lets fetch the status after 5 seconds
dispatch(new FetchCertificateStatus($this->certificate))->delay(now()->addSeconds(5));

View File

@@ -2,7 +2,7 @@
namespace App\Jobs\Certificates;
use App\Services\Ploi\Ploi;
use App\Traits\HasPloi;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
@@ -11,7 +11,7 @@ use Illuminate\Foundation\Bus\Dispatchable;
class DeleteCertificate implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, HasPloi;
public $serverPloiId;
public $sitePloiId;
@@ -42,9 +42,8 @@ class DeleteCertificate implements ShouldQueue
return;
}
$ploi = new Ploi(config('services.ploi.token'));
$ploi->server($this->serverPloiId)
$this->getPloi()
->server($this->serverPloiId)
->sites($this->sitePloiId)
->certificates()
->delete($this->certificatePloiId);

View File

@@ -2,8 +2,8 @@
namespace App\Jobs\Certificates;
use App\Traits\HasPloi;
use App\Models\Certificate;
use App\Services\Ploi\Ploi;
use Illuminate\Bus\Queueable;
use App\Traits\JobHasThresholds;
use Illuminate\Queue\SerializesModels;
@@ -13,7 +13,7 @@ use Illuminate\Foundation\Bus\Dispatchable;
class FetchCertificateStatus implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, JobHasThresholds;
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, JobHasThresholds, HasPloi;
public $certificate;
@@ -23,7 +23,7 @@ class FetchCertificateStatus implements ShouldQueue
* @param Certificate $certificate
* @param int $threshold
*/
public function __construct(Certificate $certificate, $threshold = 0)
public function __construct(Certificate $certificate, int $threshold = 0)
{
$this->certificate = $certificate;
$this->setThreshold($threshold);
@@ -43,9 +43,8 @@ class FetchCertificateStatus implements ShouldQueue
return;
}
$ploi = new Ploi(config('services.ploi.token'));
$ploiCronjob = $ploi->server($this->certificate->server->ploi_id)
$ploiCronjob = $this->getPloi()
->server($this->certificate->server->ploi_id)
->sites($this->certificate->site->ploi_id)
->certificates()
->get($this->certificate->ploi_id)

View File

@@ -3,7 +3,7 @@
namespace App\Jobs\Cronjobs;
use App\Models\Cronjob;
use App\Services\Ploi\Ploi;
use App\Traits\HasPloi;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
@@ -12,7 +12,7 @@ use Illuminate\Foundation\Bus\Dispatchable;
class CreateCronjob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, HasPloi;
public $cronjob;
@@ -35,13 +35,14 @@ class CreateCronjob implements ShouldQueue
{
$owner = $this->cronjob->site->users()->first();
$ploi = new Ploi(config('services.ploi.token'));
$ploiCronjob = $ploi->server($this->cronjob->server->ploi_id)->cronjobs()->create(
$this->cronjob->command,
$this->cronjob->frequency,
$owner->user_name
);
$ploiCronjob = $this->getPloi()
->server($this->cronjob->server->ploi_id)
->cronjobs()
->create(
$this->cronjob->command,
$this->cronjob->frequency,
$owner->user_name
);
$this->cronjob->ploi_id = $ploiCronjob->id;
$this->cronjob->save();

View File

@@ -2,7 +2,7 @@
namespace App\Jobs\Cronjobs;
use App\Services\Ploi\Ploi;
use App\Traits\HasPloi;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
@@ -11,7 +11,7 @@ use Illuminate\Foundation\Bus\Dispatchable;
class DeleteCronjob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, HasPloi;
public $serverPloiId;
public $cronjobPloiId;
@@ -39,8 +39,9 @@ class DeleteCronjob implements ShouldQueue
return;
}
$ploi = new Ploi(config('services.ploi.token'));
$ploi->server($this->serverPloiId)->cronjobs()->delete($this->cronjobPloiId);
$this->getPloi()
->server($this->serverPloiId)
->cronjobs()
->delete($this->cronjobPloiId);
}
}

View File

@@ -3,7 +3,7 @@
namespace App\Jobs\Cronjobs;
use App\Models\Cronjob;
use App\Services\Ploi\Ploi;
use App\Traits\HasPloi;
use Illuminate\Bus\Queueable;
use App\Traits\JobHasThresholds;
use Illuminate\Queue\SerializesModels;
@@ -13,7 +13,7 @@ use Illuminate\Foundation\Bus\Dispatchable;
class FetchCronjobStatus implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, JobHasThresholds;
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, JobHasThresholds, HasPloi;
public $cronjob;
@@ -23,7 +23,7 @@ class FetchCronjobStatus implements ShouldQueue
* @param Cronjob $cronjob
* @param int $threshold
*/
public function __construct(Cronjob $cronjob, $threshold = 0)
public function __construct(Cronjob $cronjob, int $threshold = 0)
{
$this->cronjob = $cronjob;
$this->setThreshold($threshold);
@@ -43,9 +43,11 @@ class FetchCronjobStatus implements ShouldQueue
return;
}
$ploi = new Ploi(config('services.ploi.token'));
$ploiCronjob = $ploi->server($this->cronjob->server->ploi_id)->cronjobs()->get($this->cronjob->ploi_id)->getData();
$ploiCronjob = $this->getPloi()
->server($this->cronjob->server->ploi_id)
->cronjobs()
->get($this->cronjob->ploi_id)
->getData();
if ($ploiCronjob->status !== Cronjob::STATUS_ACTIVE) {
$this->incrementThreshold();

View File

@@ -2,8 +2,8 @@
namespace App\Jobs\Databases;
use App\Traits\HasPloi;
use App\Models\Database;
use App\Services\Ploi\Ploi;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
@@ -12,7 +12,7 @@ use Illuminate\Foundation\Bus\Dispatchable;
class CreateDatabase implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, HasPloi;
public $database;
public $password;
@@ -38,9 +38,10 @@ class CreateDatabase implements ShouldQueue
{
$databaseUser = $this->database->users()->first();
$ploi = new Ploi(config('services.ploi.token'));
$ploiDatabase = $ploi->server($this->database->server->ploi_id)->databases()->create($this->database->name, $databaseUser->name, $this->password);
$ploiDatabase = $this->getPloi()
->server($this->database->server->ploi_id)
->databases()
->create($this->database->name, $databaseUser->name, $this->password);
$this->database->ploi_id = $ploiDatabase->id;
$this->database->save();

View File

@@ -2,7 +2,7 @@
namespace App\Jobs\Databases;
use App\Services\Ploi\Ploi;
use App\Traits\HasPloi;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
@@ -11,7 +11,7 @@ use Illuminate\Foundation\Bus\Dispatchable;
class DeleteDatabase implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, HasPloi;
public $serverPloiId;
public $databasePloiId;
@@ -40,8 +40,6 @@ class DeleteDatabase implements ShouldQueue
return;
}
$ploi = new Ploi(config('services.ploi.token'));
$ploi->server($this->serverPloiId)->databases()->delete($this->databasePloiId);
$this->getPloi()->server($this->serverPloiId)->databases()->delete($this->databasePloiId);
}
}

View File

@@ -2,8 +2,8 @@
namespace App\Jobs\Databases;
use App\Traits\HasPloi;
use App\Models\Database;
use App\Services\Ploi\Ploi;
use Illuminate\Bus\Queueable;
use App\Traits\JobHasThresholds;
use Illuminate\Queue\SerializesModels;
@@ -13,7 +13,7 @@ use Illuminate\Foundation\Bus\Dispatchable;
class FetchDatabaseStatus implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, JobHasThresholds;
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, JobHasThresholds, HasPloi;
public $database;
@@ -23,7 +23,7 @@ class FetchDatabaseStatus implements ShouldQueue
* @param Database $database
* @param int $threshold
*/
public function __construct(Database $database, $threshold = 0)
public function __construct(Database $database, int $threshold = 0)
{
$this->database = $database;
$this->setThreshold($threshold);
@@ -43,9 +43,11 @@ class FetchDatabaseStatus implements ShouldQueue
return;
}
$ploi = new Ploi(config('services.ploi.token'));
$ploiDatabase = $ploi->server($this->database->server->ploi_id)->databases()->get($this->database->ploi_id)->getData();
$ploiDatabase = $this->getPloi()
->server($this->database->server->ploi_id)
->databases()
->get($this->database->ploi_id)
->getData();
if ($ploiDatabase->status !== Database::STATUS_ACTIVE) {
$this->incrementThreshold();

View File

@@ -2,8 +2,8 @@
namespace App\Jobs\Redirects;
use App\Traits\HasPloi;
use App\Models\Redirect;
use App\Services\Ploi\Ploi;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
@@ -12,7 +12,7 @@ use Illuminate\Foundation\Bus\Dispatchable;
class CreateRedirect implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, HasPloi;
public $redirect;
@@ -33,9 +33,7 @@ class CreateRedirect implements ShouldQueue
*/
public function handle()
{
$ploi = new Ploi(config('services.ploi.token'));
$ploiRedirect = $ploi
$ploiRedirect = $this->getPloi()
->server($this->redirect->server->ploi_id)
->sites($this->redirect->site->ploi_id)
->redirects()

View File

@@ -2,7 +2,7 @@
namespace App\Jobs\Redirects;
use App\Services\Ploi\Ploi;
use App\Traits\HasPloi;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
@@ -11,7 +11,7 @@ use Illuminate\Foundation\Bus\Dispatchable;
class DeleteRedirect implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, HasPloi;
public $serverPloiId;
public $sitePloiId;
@@ -42,9 +42,8 @@ class DeleteRedirect implements ShouldQueue
return;
}
$ploi = new Ploi(config('services.ploi.token'));
$ploi->server($this->serverPloiId)
$this->getPloi()
->server($this->serverPloiId)
->sites($this->sitePloiId)
->redirects()
->delete($this->redirectPloiId);

View File

@@ -2,8 +2,8 @@
namespace App\Jobs\Redirects;
use App\Traits\HasPloi;
use App\Models\Redirect;
use App\Services\Ploi\Ploi;
use Illuminate\Bus\Queueable;
use App\Traits\JobHasThresholds;
use Illuminate\Queue\SerializesModels;
@@ -13,7 +13,7 @@ use Illuminate\Foundation\Bus\Dispatchable;
class FetchRedirectStatus implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, JobHasThresholds;
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, JobHasThresholds, HasPloi;
public $redirect;
@@ -23,7 +23,7 @@ class FetchRedirectStatus implements ShouldQueue
* @param Redirect $redirect
* @param int $threshold
*/
public function __construct(Redirect $redirect, $threshold = 0)
public function __construct(Redirect $redirect, int $threshold = 0)
{
$this->redirect = $redirect;
$this->setThreshold($threshold);
@@ -43,9 +43,8 @@ class FetchRedirectStatus implements ShouldQueue
return;
}
$ploi = new Ploi(config('services.ploi.token'));
$ploiRedirect = $ploi->server($this->redirect->server->ploi_id)
$ploiRedirect = $this->getPloi()
->server($this->redirect->server->ploi_id)
->sites($this->redirect->site->ploi_id)
->redirects()
->get($this->redirect->ploi_id)->getData();

View File

@@ -3,7 +3,7 @@
namespace App\Jobs\Servers;
use App\Models\Server;
use App\Services\Ploi\Ploi;
use App\Traits\HasPloi;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
@@ -12,41 +12,31 @@ use Illuminate\Foundation\Bus\Dispatchable;
class CreateServer implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, HasPloi;
public $server;
public $tries = 1;
/**
* Create a new job instance.
*
* @param Server $server
*/
public function __construct(Server $server)
{
$this->server = $server;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
$ploi = new Ploi(config('services.ploi.token'));
$ploiServer = $ploi->server()->create(
$ploiServer = $this->getPloi()->server()->create(
$this->server->name,
$this->server->provider->ploi_id,
$this->server->providerRegion->region_id,
$this->server->providerPlan->plan_id,
'server',
$this->server->database_type
);
$this->server->ploi_id = $ploiServer->id;
$this->server->save();
// Lets fetch the status after 5 minutes
// Let's fetch the status after 5 minutes
dispatch(new FetchServerStatus($this->server))->delay(now()->addMinutes(5));
}

View File

@@ -2,7 +2,7 @@
namespace App\Jobs\Servers;
use App\Services\Ploi\Ploi;
use App\Traits\HasPloi;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
@@ -11,7 +11,7 @@ use Illuminate\Foundation\Bus\Dispatchable;
class DeleteServer implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, HasPloi;
public $serverPloiId;
@@ -32,8 +32,6 @@ class DeleteServer implements ShouldQueue
*/
public function handle()
{
$ploi = new Ploi(config('services.ploi.token'));
$ploi->server($this->serverPloiId)->delete();
$this->getPloi()->server($this->serverPloiId)->delete();
}
}

View File

@@ -3,7 +3,7 @@
namespace App\Jobs\Servers;
use App\Models\Server;
use App\Services\Ploi\Ploi;
use App\Traits\HasPloi;
use Illuminate\Bus\Queueable;
use App\Traits\JobHasThresholds;
use Illuminate\Queue\SerializesModels;
@@ -13,7 +13,7 @@ use Illuminate\Foundation\Bus\Dispatchable;
class FetchServerStatus implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, JobHasThresholds;
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, JobHasThresholds, HasPloi;
public $server;
@@ -43,9 +43,7 @@ class FetchServerStatus implements ShouldQueue
return;
}
$ploi = new Ploi;
$ploiServer = $ploi->server($this->server->ploi_id)->get()->getData();
$ploiServer = $this->getPloi()->server($this->server->ploi_id)->get()->getData();
if ($ploiServer->status !== Server::STATUS_ACTIVE) {
$this->incrementThreshold();

View File

@@ -1,35 +0,0 @@
<?php
namespace App\Jobs\Servers;
use App\Models\Server;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
class SynchronizeServers implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
$ploi = new \App\Services\Ploi\Ploi(config('services.ploi.token'));
$servers = $ploi->server()->get()->getData();
foreach ($servers as $server) {
Server::firstOrCreate([
'ip' => $server->ip_address,
], [
'name' => $server->name
]);
}
}
}

View File

@@ -3,7 +3,7 @@
namespace App\Jobs\Sites;
use App\Models\Site;
use App\Services\Ploi\Ploi;
use App\Traits\HasPloi;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
@@ -12,7 +12,7 @@ use Illuminate\Foundation\Bus\Dispatchable;
class ChangePhpVersion implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, HasPloi;
public $site;
public $version;
@@ -36,9 +36,7 @@ class ChangePhpVersion implements ShouldQueue
*/
public function handle()
{
$ploi = new Ploi(config('services.ploi.token'));
$ploi->server($this->site->server->ploi_id)->sites($this->site->ploi_id)->phpVersion($this->version);
$this->getPloi()->server($this->site->server->ploi_id)->sites($this->site->ploi_id)->phpVersion($this->version);
$this->site->php_version = $this->version;
$this->site->save();

View File

@@ -3,7 +3,7 @@
namespace App\Jobs\Sites;
use App\Models\Site;
use App\Services\Ploi\Ploi;
use App\Traits\HasPloi;
use Illuminate\Support\Arr;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
@@ -13,7 +13,7 @@ use Illuminate\Foundation\Bus\Dispatchable;
class CreateSite implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, HasPloi;
public $site;
@@ -34,11 +34,9 @@ class CreateSite implements ShouldQueue
*/
public function handle()
{
$ploi = new Ploi(config('services.ploi.token'));
$systemUser = $this->site->getSystemUser();
$ploiSite = $ploi->server($this->site->server->ploi_id)->sites()->create(
$ploiSite = $this->getPloi()->server($this->site->server->ploi_id)->sites()->create(
$this->site->domain,
'/public',
'/',

View File

@@ -2,7 +2,7 @@
namespace App\Jobs\Sites;
use App\Services\Ploi\Ploi;
use App\Traits\HasPloi;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
@@ -11,7 +11,7 @@ use Illuminate\Foundation\Bus\Dispatchable;
class DeleteSite implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, HasPloi;
public $serverPloiId;
public $sitePloiId;
@@ -34,8 +34,6 @@ class DeleteSite implements ShouldQueue
*/
public function handle()
{
$ploi = new Ploi(config('services.ploi.token'));
$ploi->server($this->serverPloiId)->sites()->delete($this->sitePloiId);
$this->getPloi()->server($this->serverPloiId)->sites()->delete($this->sitePloiId);
}
}

View File

@@ -3,7 +3,7 @@
namespace App\Jobs\Sites;
use App\Models\Site;
use App\Services\Ploi\Ploi;
use App\Traits\HasPloi;
use Illuminate\Bus\Queueable;
use App\Traits\JobHasThresholds;
use Illuminate\Queue\SerializesModels;
@@ -13,7 +13,7 @@ use Illuminate\Foundation\Bus\Dispatchable;
class FetchSiteStatus implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, JobHasThresholds;
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, JobHasThresholds, HasPloi;
public $site;
@@ -43,9 +43,7 @@ class FetchSiteStatus implements ShouldQueue
return;
}
$ploi = new Ploi;
$ploiSite = $ploi->server($this->site->server->ploi_id)->sites()->get($this->site->ploi_id)->getData();
$ploiSite = $this->getPloi()->server($this->site->server->ploi_id)->sites()->get($this->site->ploi_id)->getData();
if ($ploiSite->status !== Site::STATUS_ACTIVE) {
$this->incrementThreshold();

View File

@@ -13,26 +13,15 @@ class AdminServerCreatedEmail extends Mailable implements ShouldQueue
{
use Queueable, SerializesModels;
public $user;
public $server;
public User $user;
public Server $server;
/**
* Create a new message instance.
*
* @param User $user
* @param Server $server
*/
public function __construct(User $user, Server $server)
{
$this->user = $user;
$this->server = $server;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this

View File

@@ -0,0 +1,34 @@
<?php
namespace App\Mail\Admin\Site;
use App\Models\Server;
use App\Models\Site;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class AdminSiteCreatedEmail extends Mailable implements ShouldQueue
{
use Queueable, SerializesModels;
public User $user;
public Server $server;
public Site $site;
public function __construct(User $user, Server $server, Site $site)
{
$this->user = $user;
$this->server = $server;
$this->site = $site;
}
public function build()
{
return $this
->subject(__('A user has created a new site'))
->markdown('emails.admin.site.new-site');
}
}

View File

@@ -18,6 +18,10 @@ class Certificate extends Model
public $fillable = [
'domain',
'type'
'type',
'certificate',
'private',
'ploi_id',
'status'
];
}

View File

@@ -14,6 +14,8 @@ class Package extends Model
const CURRENCY_CAD = 'cad';
const CURRENCY_GBP = 'gbp';
const CURRENCY_INR = 'inr';
const CURRENCY_THB = 'thb';
const CURRENCY_BRL = 'brl';
public $fillable = [
'name',
@@ -21,6 +23,7 @@ class Package extends Model
'currency',
'price_hourly',
'price_monthly',
'price_yearly',
'maximum_sites',
'maximum_servers',
'site_permissions',

View File

@@ -8,6 +8,11 @@ class Provider extends Model
{
protected $guarded = [];
protected $casts = [
'allowed_plans' => 'json',
'allowed_regions' => 'json',
];
public function getNameWithLabelAttribute()
{
$string = $this->name;

View File

@@ -17,7 +17,8 @@ class Server extends Model
'internal_ip',
'ssh_port',
'maximum_sites',
'available_php_versions'
'available_php_versions',
'database_type'
];
protected $casts = [

View File

@@ -2,9 +2,13 @@
namespace App\Models;
use App\Casts\SiteAlias;
use DateTimeInterface;
use Illuminate\Database\Eloquent\Model;
/**
* @property mixed|string domain
*/
class Site extends Model
{
const STATUS_BUSY = 'busy';
@@ -15,8 +19,15 @@ class Site extends Model
const PROJECT_OCTOBERCMS = 'october-cms';
public $fillable = [
'ploi_id',
'domain',
'dns_id'
'dns_id',
'project',
'aliases'
];
public $casts = [
'aliases' => SiteAlias::class,
];
public function setDnsIdAttribute($value)
@@ -93,8 +104,28 @@ class Site extends Model
] + ($withPassword ? ['ftp_password' => $user->ftp_password] : []);
}
public function addAlias($alias)
{
$aliases = $this->aliases;
$aliases[] = $alias;
$this->aliases = $aliases;
$this->save();
}
public function removeAlias($alias)
{
$this->aliases = array_diff($this->aliases, [$alias]);
$this->save();
}
public static function booted()
{
static::creating(function (self $site) {
$site->domain = strtolower($site->domain);
});
static::created(function (self $site) {
$site->systemUsers()->create();
});

View File

@@ -47,7 +47,8 @@ class User extends Authenticatable implements HasLocalePreference
'email_verified_at' => 'datetime',
'ftp_password' => Encrypted::class,
'keyboard_shortcuts' => 'boolean',
'requires_password_for_ftp' => 'boolean'
'requires_password_for_ftp' => 'boolean',
'trial_ends_at' => 'datetime',
];
protected $appends = [
@@ -110,6 +111,11 @@ class User extends Authenticatable implements HasLocalePreference
return $this->hasMany(SupportTicket::class);
}
public function supportTicketReplies()
{
return $this->hasMany(SupportTicketReply::class);
}
public function systemLogs()
{
return $this->hasMany(SystemLog::class);
@@ -129,6 +135,10 @@ class User extends Authenticatable implements HasLocalePreference
if (!$user->language) {
$user->language = setting('default_language', 'en');
}
if($days = setting('trial')){
$user->trial_ends_at = now()->addDays($days);
}
});
static::created(function (self $user) {
@@ -139,6 +149,10 @@ class User extends Authenticatable implements HasLocalePreference
$user->systemLogs()->delete();
$user->servers()->detach();
$user->sites()->detach();
foreach ($user->supportTickets as $supportTicket) {
$supportTicket->replies()->delete();
}
$user->supportTickets()->delete();
});
}
}

View File

@@ -3,19 +3,11 @@
namespace App\Providers;
use App\Models\Setting;
use Illuminate\Support\Collection;
use Illuminate\Pagination\UrlWindow;
use Illuminate\Support\Facades\Request;
use Illuminate\Support\ServiceProvider;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Validation\Rules\Password;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
$this->app->singleton('settings', function ($app) {
@@ -27,75 +19,16 @@ class AppServiceProvider extends ServiceProvider
}
});
});
if (!$this->app->request->is('api*')) {
$this->registerLengthAwarePaginator();
}
}
protected function registerLengthAwarePaginator()
public function boot()
{
$this->app->bind(LengthAwarePaginator::class, function ($app, $values) {
return new class(...array_values($values)) extends LengthAwarePaginator {
public function only(...$attributes)
{
return $this->transform(function ($item) use ($attributes) {
return $item->only($attributes);
});
}
Password::defaults(function () {
$rule = Password::min(6);
public function transform($callback)
{
$this->items->transform($callback);
return $this;
}
public function toArray()
{
return [
'data' => $this->items->toArray(),
'links' => $this->links(),
'per_page' => $this->perPage(),
'total' => $this->total(),
];
}
public function links($view = null, $data = [])
{
$this->appends(Request::all());
$window = UrlWindow::make($this);
$elements = array_filter([
$window['first'],
is_array($window['slider']) ? '...' : null,
$window['slider'],
is_array($window['last']) ? '...' : null,
$window['last'],
]);
return Collection::make($elements)->flatMap(function ($item) {
if (is_array($item)) {
return Collection::make($item)->map(function ($url, $page) {
return [
'url' => $url,
'label' => $page,
'active' => $this->currentPage() === $page,
];
});
} else {
return [
[
'url' => null,
'label' => '...',
'active' => false,
],
];
}
});
}
};
return $this->app->isProduction()
? $rule->letters()->numbers()->uncompromised()
: $rule;
});
}
}

View File

@@ -21,4 +21,9 @@ class Unauthenticated extends Exception
{
parent::__construct($message);
}
public function render($request)
{
return redirect()->route('dashboard')->with('error', 'Unable to authenticate with backend server, please check API keys and connection.');
}
}

View File

@@ -25,7 +25,7 @@ class Ploi
public function __construct(string $token = null, string $coreApiToken = null)
{
$this->url = app()->isLocal() ? 'http://core-api.ploi.test/' : 'https://core-api.ploi.io/';
$this->url = config('services.ploi-api.url');
if (!$token) {
$token = config('services.ploi.token');

View File

@@ -0,0 +1,44 @@
<?php
namespace App\Services\Ploi\Resources;
class Alias extends Resource
{
public function __construct(Server $server, Site $site)
{
parent::__construct($server->getPloi());
$this->setServer($server);
$this->setSite($site);
$this->buildEndpoint();
}
public function buildEndpoint(): self
{
$this->setEndpoint($this->getSite()->getEndpoint() . '/aliases');
return $this;
}
public function get()
{
return $this->getPloi()->makeAPICall($this->getEndpoint());
}
public function create(array $aliases)
{
$options = [
'body' => json_encode([
'aliases' => $aliases,
]),
];
return $this->getPloi()->makeAPICall($this->getEndpoint(), 'post', $options);
}
public function delete(string $alias)
{
return $this->getPloi()->makeAPICall($this->getEndpoint() . '/' . $alias , 'delete');
}
}

View File

@@ -66,7 +66,7 @@ class App extends Resource
$this->setId($response->getJson()->data->id);
// Return the data
return $response->getJson()->data;
return $response->getJson();
}
public function uninstall($type): bool

View File

@@ -43,7 +43,7 @@ class Certificate extends Resource
return $this->getPloi()->makeAPICall($this->getEndpoint());
}
public function create(string $certificate, string $type = 'letsencrypt'): stdClass
public function create(string $certificate, string $type = 'letsencrypt', string $private = null): stdClass
{
// Remove the id
$this->setId(null);
@@ -51,8 +51,9 @@ class Certificate extends Resource
// Set the options
$options = [
'body' => json_encode([
'certificate' => $certificate,
'type' => $type,
'certificate' => $certificate,
'private' => $private,
]),
];

View File

@@ -61,9 +61,13 @@ class Server extends Resource
public function create(
string $name,
int $provider,
int $region,
int $plan
$provider,
$region,
$plan,
$type = 'server',
$databaseType = 'mysql',
$webserverType = 'nginx',
$phpVersion = '7.4'
): stdClass {
// Remove the id
@@ -76,10 +80,10 @@ class Server extends Resource
'plan' => $plan,
'region' => $region,
'credential' => $provider,
'type' => 'server',
'database_type' => 'mysql',
'webserver_type' => 'nginx',
'php_version' => '7.4'
'type' => $type,
'database_type' => $databaseType,
'webserver_type' => $webserverType,
'php_version' => $phpVersion
]),
];
@@ -89,8 +93,6 @@ class Server extends Resource
} catch (NotValid $exception) {
$errors = json_decode($exception->getMessage())->errors;
dd($errors);
throw $exception;
}

View File

@@ -98,6 +98,13 @@ class Site extends Resource
}
throw $exception;
} catch (\Exception $exception) {
info($exception->getMessage());
}
// TODO: Debugging purposes
if (!$response->getJson() || !isset($response->getJson()->data)) {
throw new \Exception($response->getJson()->error ?? 'Unknown error has occured');
}
// Set the id of the site
@@ -142,7 +149,7 @@ class Site extends Resource
return $response->getJson()->data;
}
public function phpVersion($version = '7.4') :stdClass
public function phpVersion($version = '7.4'): stdClass
{
// Set the options
$options = [
@@ -197,4 +204,9 @@ class Site extends Resource
{
return new App($this->getServer(), $this, $id);
}
public function aliases($id = null): Alias
{
return new Alias($this->getServer(), $this, $id);
}
}

View File

@@ -19,4 +19,9 @@ class Synchronize extends Resource
{
return $this->getPloi()->makeAPICall($this->getEndpoint() . '/servers');
}
public function sites()
{
return $this->getPloi()->makeAPICall($this->getEndpoint() . '/sites');
}
}

13
app/Traits/HasPloi.php Normal file
View File

@@ -0,0 +1,13 @@
<?php
namespace App\Traits;
use App\Services\Ploi\Ploi;
trait HasPloi
{
protected function getPloi()
{
return new Ploi(config('services.ploi.token'));
}
}

View File

@@ -9,31 +9,34 @@
],
"license": "MIT",
"require": {
"php": "^7.3",
"php": "^8.0.2",
"ext-json": "*",
"cloudflare/sdk": "^1.1",
"fideloper/proxy": "^4.2",
"fruitcake/laravel-cors": "^1.0",
"guzzlehttp/guzzle": "^6.2|^7.0.1",
"inertiajs/inertia-laravel": "^0.3.1",
"laravel/cashier": "^12.3",
"laravel/framework": "^8.4",
"laravel/horizon": "^5.0",
"aws/aws-sdk-php": "^3.224",
"cloudflare/sdk": "^1.3",
"guzzlehttp/guzzle": "^7.4.1",
"inertiajs/inertia-laravel": "^0.5.4",
"laravel/cashier": "^12.16",
"laravel/framework": "^9.0.2",
"laravel/horizon": "^5.8",
"laravel/octane": "^1.2",
"laravel/tinker": "^2.0",
"laravel/ui": "^2.1",
"league/glide": "^1.6",
"laravel/ui": "^2.1|^3.3.0",
"pragmarx/google2fa-laravel": "^1.3",
"predis/predis": "^1.1",
"tightenco/ziggy": "^0.9.4"
"spiral/roadrunner": "^2.8.2",
"symfony/http-client": "^6.1",
"symfony/mailgun-mailer": "^6.1",
"symfony/postmark-mailer": "^6.1",
"tightenco/ziggy": "^1.3"
},
"require-dev": {
"barryvdh/laravel-debugbar": "^3.3",
"facade/ignition": "^2.3",
"friendsofphp/php-cs-fixer": "^2.16",
"spatie/laravel-ignition": "^1.0",
"friendsofphp/php-cs-fixer": "^3.1.0",
"fzaninotto/faker": "^1.9.1",
"laravel/dusk": "^6.15",
"mockery/mockery": "^1.3.1",
"nunomaduro/collision": "^5.0",
"nunomaduro/collision": "^6.1",
"phpunit/phpunit": "^9.5.4"
},
"config": {

5500
composer.lock generated

File diff suppressed because it is too large Load Diff

7
config/core.php Normal file
View File

@@ -0,0 +1,7 @@
<?php
return [
'pagination' => [
'per_page' => env('PAGINATION_PER_PAGE', 5)
]
];

View File

@@ -15,7 +15,7 @@ return [
|
*/
'domain' => null,
'domain' => env('HORIZON_DOMAIN', null),
/*
|--------------------------------------------------------------------------
@@ -28,7 +28,7 @@ return [
|
*/
'path' => 'horizon',
'path' => env('HORIZON_PATH', 'horizon'),
/*
|--------------------------------------------------------------------------
@@ -145,13 +145,13 @@ return [
| Memory Limit (MB)
|--------------------------------------------------------------------------
|
| This value describes the maximum amount of memory the Horizon worker
| may consume before it is terminated and restarted. You should set
| this value according to the resources available to your server.
| This value describes the maximum amount of memory the Horizon master
| supervisor may consume before it is terminated and restarted. For
| configuring these limits on your workers, see the next section.
|
*/
'memory_limit' => 64,
'memory_limit' => env('HORIZON_MEMORY_LIMIT', 64),
/*
|--------------------------------------------------------------------------
@@ -164,6 +164,9 @@ return [
|
*/
'defaults' => [
],
'environments' => [
'production' => [
'supervisor-1' => [

221
config/octane.php Normal file
View File

@@ -0,0 +1,221 @@
<?php
use Laravel\Octane\Contracts\OperationTerminated;
use Laravel\Octane\Events\RequestHandled;
use Laravel\Octane\Events\RequestReceived;
use Laravel\Octane\Events\RequestTerminated;
use Laravel\Octane\Events\TaskReceived;
use Laravel\Octane\Events\TaskTerminated;
use Laravel\Octane\Events\TickReceived;
use Laravel\Octane\Events\TickTerminated;
use Laravel\Octane\Events\WorkerErrorOccurred;
use Laravel\Octane\Events\WorkerStarting;
use Laravel\Octane\Events\WorkerStopping;
use Laravel\Octane\Listeners\CollectGarbage;
use Laravel\Octane\Listeners\DisconnectFromDatabases;
use Laravel\Octane\Listeners\EnsureUploadedFilesAreValid;
use Laravel\Octane\Listeners\EnsureUploadedFilesCanBeMoved;
use Laravel\Octane\Listeners\FlushTemporaryContainerInstances;
use Laravel\Octane\Listeners\FlushUploadedFiles;
use Laravel\Octane\Listeners\ReportException;
use Laravel\Octane\Listeners\StopWorkerIfNecessary;
use Laravel\Octane\Octane;
return [
/*
|--------------------------------------------------------------------------
| Octane Server
|--------------------------------------------------------------------------
|
| This value determines the default "server" that will be used by Octane
| when starting, restarting, or stopping your server via the CLI. You
| are free to change this to the supported server of your choosing.
|
| Supported: "roadrunner", "swoole"
|
*/
'server' => env('OCTANE_SERVER', 'roadrunner'),
/*
|--------------------------------------------------------------------------
| Force HTTPS
|--------------------------------------------------------------------------
|
| When this configuration value is set to "true", Octane will inform the
| framework that all absolute links must be generated using the HTTPS
| protocol. Otherwise your links may be generated using plain HTTP.
|
*/
'https' => env('OCTANE_HTTPS', false),
/*
|--------------------------------------------------------------------------
| Octane Listeners
|--------------------------------------------------------------------------
|
| All of the event listeners for Octane's events are defined below. These
| listeners are responsible for resetting your application's state for
| the next request. You may even add your own listeners to the list.
|
*/
'listeners' => [
WorkerStarting::class => [
EnsureUploadedFilesAreValid::class,
EnsureUploadedFilesCanBeMoved::class,
],
RequestReceived::class => [
...Octane::prepareApplicationForNextOperation(),
...Octane::prepareApplicationForNextRequest(),
//
],
RequestHandled::class => [
//
],
RequestTerminated::class => [
// FlushUploadedFiles::class,
],
TaskReceived::class => [
...Octane::prepareApplicationForNextOperation(),
//
],
TaskTerminated::class => [
//
],
TickReceived::class => [
...Octane::prepareApplicationForNextOperation(),
//
],
TickTerminated::class => [
//
],
OperationTerminated::class => [
FlushTemporaryContainerInstances::class,
// DisconnectFromDatabases::class,
// CollectGarbage::class,
],
WorkerErrorOccurred::class => [
ReportException::class,
StopWorkerIfNecessary::class,
],
WorkerStopping::class => [
//
],
],
/*
|--------------------------------------------------------------------------
| Warm / Flush Bindings
|--------------------------------------------------------------------------
|
| The bindings listed below will either be pre-warmed when a worker boots
| or they will be flushed before every new request. Flushing a binding
| will force the container to resolve that binding again when asked.
|
*/
'warm' => [
...Octane::defaultServicesToWarm(),
],
'flush' => [
//
],
/*
|--------------------------------------------------------------------------
| Octane Cache Table
|--------------------------------------------------------------------------
|
| While using Swoole, you may leverage the Octane cache, which is powered
| by a Swoole table. You may set the maximum number of rows as well as
| the number of bytes per row using the configuration options below.
|
*/
'cache' => [
'rows' => 1000,
'bytes' => 10000,
],
/*
|--------------------------------------------------------------------------
| Octane Swoole Tables
|--------------------------------------------------------------------------
|
| While using Swoole, you may define additional tables as required by the
| application. These tables can be used to store data that needs to be
| quickly accessed by other workers on the particular Swoole server.
|
*/
'tables' => [
'example:1000' => [
'name' => 'string:1000',
'votes' => 'int',
],
],
/*
|--------------------------------------------------------------------------
| File Watching
|--------------------------------------------------------------------------
|
| The following list of files and directories will be watched when using
| the --watch option offered by Octane. If any of the directories and
| files are changed, Octane will automatically reload your workers.
|
*/
'watch' => [
'app',
'bootstrap',
'config',
'database',
'public/**/*.php',
'resources/**/*.php',
'routes',
'composer.lock',
'.env',
],
/*
|--------------------------------------------------------------------------
| Garbage Collection Threshold
|--------------------------------------------------------------------------
|
| When executing long-lived PHP scripts such as Octane, memory can build
| up before being cleared by PHP. You can force Octane to run garbage
| collection if your application consumes this amount of megabytes.
|
*/
'garbage' => 50,
/*
|--------------------------------------------------------------------------
| Maximum Execution Time
|--------------------------------------------------------------------------
|
| The following setting configures the maximum execution time for requests
| being handled by Octane. You may set this value to 0 to indicate that
| there isn't a specific time limit on Octane request execution time.
|
*/
'max_execution_time' => 30,
];

View File

@@ -33,5 +33,9 @@ return [
'ploi' => [
'token' => env('PLOI_TOKEN'),
'core-token' => env('PLOI_CORE_TOKEN')
],
'ploi-api' => [
'url' => env('PLOI_API_URL', 'https://core-api.ploi.io/')
]
];

View File

@@ -15,6 +15,7 @@ return [
'paths' => [
resource_path('views'),
storage_path('views'),
],
/*

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddPriceYearlyToPackagesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('packages', function (Blueprint $table) {
$table->decimal('price_yearly', 10, 4)->after('price_monthly')->default(0);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('packages', function (Blueprint $table) {
$table->dropColumn('price_yearly');
});
}
}

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddColumnsToCertificatesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('certificates', function (Blueprint $table) {
$table->after('domain', function ($table) {
$table->longText('certificate')->nullable();
$table->longText('private')->nullable();
});
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('certificates', function (Blueprint $table) {
//
});
}
}

View File

@@ -0,0 +1,33 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddAllowedRegionsAndPlansToProvidersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('providers', function (Blueprint $table) {
$table->json('allowed_plans')->nullable()->after('name');
$table->json('allowed_regions')->nullable()->after('allowed_plans');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('providers', function (Blueprint $table) {
$table->dropColumn('allowed_plans', 'allowed_regions');
});
}
}

View File

@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddColumnsToServersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('servers', function (Blueprint $table) {
$table->after('available_php_versions', function (Blueprint $table) {
$table->string('type')->default('server');
$table->string('database_type')->default('mysql');
});
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('servers', function (Blueprint $table) {
$table->dropColumn('type', 'database_type');
});
}
}

View File

@@ -0,0 +1,31 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('sites', function (Blueprint $table) {
$table->json('aliases')->nullable()->after('php_version');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('sites', function (Blueprint $table) {
$table->dropColumn('aliases');
});
}
};

14792
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -6,33 +6,36 @@
"watch": "mix watch",
"watch-poll": "mix watch -- --watch-options-poll=1000",
"hot": "mix watch --hot",
"production": "rm -rf ./public/js/*.js && mix --production"
"production": "mix --production"
},
"devDependencies": {
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@inertiajs/inertia": "^0.4.3",
"@inertiajs/inertia-vue": "^0.3.2",
"@inertiajs/progress": "^0.1.2",
"@tailwindcss/forms": "^0.3.2",
"@tailwindcss/typography": "^0.4.0",
"autoprefixer": "^10.2.5",
"axios": "^0.19",
"@inertiajs/inertia": "^0.10.0",
"@inertiajs/inertia-vue": "^0.7.1",
"@inertiajs/progress": "^0.2.6",
"@tailwindcss/forms": "^0.4.0",
"@tailwindcss/typography": "^0.5.0",
"autoprefixer": "^10.4.0",
"axios": "^0.21.1",
"balloon-css": "^1.2.0",
"cross-env": "^7.0",
"laravel-mix": "^6.0.18",
"cross-env": "^7.0.3",
"laravel-mix": "^6.0.41",
"lodash": "^4.17.15",
"portal-vue": "^2.1.7",
"postcss": "^8.2.13",
"postcss": "^8.4.5",
"resolve-url-loader": "^3.1.0",
"sass": "^1.15.2",
"sass-loader": "^8.0.0",
"tailwindcss": "^2.1.2",
"v-click-outside": "^3.0.1",
"tailwindcss": "^3.0.7",
"v-click-outside": "^3.1.2",
"vue": "^2.6.11",
"vue-clipboard2": "^0.3.1",
"vue-loader": "^15.9.6",
"vue-loader": "^15.9.8",
"vue-meta": "^2.4.0",
"vue-template-compiler": "^2.6.11",
"vuex": "^3.5.1"
"vuex": "^3.6.2"
},
"dependencies": {
"vue-simplemde": "^2.0.0"
}
}

Some files were not shown because too many files have changed in this diff Show More