From d4d555746be848e7a3ee42d677d69fd9c6433c49 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Tue, 3 Dec 2024 14:47:10 +0100 Subject: [PATCH] wip #7218 @0:10 --- app/Jobs/HostingUpdate.php | 14 ++++++++++++-- app/Models/FluidbookExternalInstallServer.php | 3 ++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/app/Jobs/HostingUpdate.php b/app/Jobs/HostingUpdate.php index d7b3ade4e..74382cf07 100644 --- a/app/Jobs/HostingUpdate.php +++ b/app/Jobs/HostingUpdate.php @@ -17,6 +17,8 @@ class HostingUpdate extends Base 'ushosting' => ['host' => 'kingkong.cubedesigners.com', 'basepath' => '/home/fluidbook/data/hosting'], ]; + const LATEST_PHP = '8.3'; + public function handle() { foreach (static::$_data as $name => $s) { @@ -36,20 +38,28 @@ class HostingUpdate extends Base copy($r . 'updateall', $d . 'update'); + + foreach ($servers as $server) { $basePath = trim($server->base_path, '/'); if ($basePath != '') { $basePath = '/' . $basePath; } + $phpversion=floatval($server->php); + $image = 'php:apache'; + if ($phpversion > 1) { + $image = 'php:' . $phpversion . '-apache'; + } + /** @var FluidbookExternalInstallServer $server */ $server->updateHtaccess(); $s = $d . 'server-' . $server->id; Files::copy($r . 'server', $s); Files::recursiveReplaceStringInDir($s, [ '$sid' => $server->id, - '$image' => (true || $server->php) ? 'php:apache' : 'httpd', - '$dockerpath' => (true || $server->php) ? '/var/www/html' : '/usr/local/apache2/htdocs', + '$image' => $image, + '$dockerpath' => ($image !== 'httpd') ? '/var/www/html' : '/usr/local/apache2/htdocs', '$domains' => implode(',', Text::explodeNewLines($server->subdomains)), '$hosting' => $name, '$path' => $data['basepath'] . $basePath, diff --git a/app/Models/FluidbookExternalInstallServer.php b/app/Models/FluidbookExternalInstallServer.php index 7187d58a6..e0ebf987e 100644 --- a/app/Models/FluidbookExternalInstallServer.php +++ b/app/Models/FluidbookExternalInstallServer.php @@ -8,6 +8,7 @@ use App\Jobs\HostingUpdate; use App\Models\Traits\Owner; use App\Models\Traits\Permissions; use Cubist\Backpack\Magic\Fields\Checkbox; +use Cubist\Backpack\Magic\Fields\SelectFromArray; use Cubist\Backpack\Magic\Fields\Table; use Cubist\Backpack\Magic\Fields\Textarea; use Cubist\Backpack\Magic\Models\ExternalServer; @@ -64,7 +65,7 @@ class FluidbookExternalInstallServer extends ExternalServer $this->addOwnerField(['column' => true]); $this->getField('base_url')->setAttribute('when', ['protocol' => $nothostingProtocols]); $this->addField('subdomains', Textarea::class, __('Sous-domaines'), ['when' => ['protocol' => $hostingProtocols]]); - $this->addField('php', Checkbox::class, __('Activer le support de PHP'), ['default' => false, 'when' => ['protocol' => $hostingProtocols]]); + $this->addField('php', SelectFromArray::class, __('Activer le support de PHP'), ['default' => false, 'options' => [0 => __('Non'), 1 => __('Dernière version'), '8.3' => '8.3', '8.2' => '8.2', '8.1' => '8.1'], 'when' => ['protocol' => $hostingProtocols]]); $this->addField('redirections', Table::class, __('Redirections'), ['entity_singular' => __('redirection'), 'columns' => ['from' => __('De'), 'to' => __('Vers')], 'when' => ['protocol' => $hostingProtocols]]); $this->addField('allows_root', Checkbox::class, __('Autoriser le chargement à la racine (sur le chemin de base)'), ['default' => false]); } -- 2.39.5