From 48f80379a4484d3d0cb8ece1cd7486bc0e5fcb7a Mon Sep 17 00:00:00 2001 From: Matthew Saunders Brown Date: Wed, 18 Sep 2024 12:36:22 -0700 Subject: [PATCH] add support for multiple php versions --- panel/classes/Panel.php | 12 ++++++++++++ panel/classes/Panel/Vhost/VhostsAdd.php | 9 ++++++++- panel/config/maps-vhost.ini | 1 + panel/config/maps-vpanel.ini | 1 + panel/ui/vhost/users-user.html | 8 +++++--- panel/ui/vhost/vhosts-add.html | 15 +++++++++++++++ panel/ui/vhost/vhosts-vhost.html | 17 +++++++++-------- 7 files changed, 51 insertions(+), 12 deletions(-) diff --git a/panel/classes/Panel.php b/panel/classes/Panel.php index 29e73ad..db3e56e 100644 --- a/panel/classes/Panel.php +++ b/panel/classes/Panel.php @@ -63,6 +63,18 @@ class Panel { echo \Template::instance()->render('home.html'); } + public static function setPHPVersions($f3) { + + $phpFPMVersion = readlink("/etc/alternatives/php-fpm.sock"); + $phpFPMVersion = str_replace('/run/php/php', '', $phpFPMVersion); + $phpFPMVersion = str_replace('-fpm.sock', '', $phpFPMVersion); + exec("/usr/bin/update-alternatives --list php-fpm.sock | sed 's|/run/php/php||g' | cut -d \- -f 1", $phpFPMVersionsArray); + $f3->set('PHP.fpm_version', $phpFPMVersion); + $f3->set('PHP.fpm_versions_array', $phpFPMVersionsArray); + $f3->set('PHP.fpm_version_count', count($phpFPMVersionsArray)); + + } + public static function validateEmail($email) { global $f3; diff --git a/panel/classes/Panel/Vhost/VhostsAdd.php b/panel/classes/Panel/Vhost/VhostsAdd.php index 37b0e92..1440596 100644 --- a/panel/classes/Panel/Vhost/VhostsAdd.php +++ b/panel/classes/Panel/Vhost/VhostsAdd.php @@ -35,6 +35,12 @@ class VhostsAdd extends \Panel\Vhost { $deploy['showwriteinfo'] = 0; } + /* set php fpm version vars */ + $f3->call('\Panel::setPHPVersions', $f3); + $deploy['fpm_version'] = $f3->get('PHP.fpm_version'); + $deploy['fpm_versions_array'] = $f3->get('PHP.fpm_versions_array'); + $deploy['fpm_version_count'] = $f3->get('PHP.fpm_version_count'); + $f3->set('deploy', $deploy); /* check if VHOSTLIMIT is set */ @@ -76,7 +82,8 @@ class VhostsAdd extends \Panel\Vhost { $f3->set('SESSION.messages', $messages); $f3->reroute("/Websites/Add"); } else { - $cmd = "/usr/local/bin/vhost-deploy.sh -d $domain"; + $fpm_version = $_POST['fpm_version']; + $cmd = "/usr/local/bin/vhost-deploy.sh -d $domain -f $fpm_version"; } } else { $f3->reroute("/Websites/Add"); diff --git a/panel/config/maps-vhost.ini b/panel/config/maps-vhost.ini index 3f64254..446494c 100644 --- a/panel/config/maps-vhost.ini +++ b/panel/config/maps-vhost.ini @@ -8,4 +8,5 @@ / [sync] = Panel\Vhost\Vhosts /Login [sync] = Panel\Login /Logout [sync] = Panel\Logout +/Websites/@vhost/Edit [sync] = Panel\Vhost\VhostsEdit /Users/@username/Edit [sync] = Panel\Vhost\UsersEdit diff --git a/panel/config/maps-vpanel.ini b/panel/config/maps-vpanel.ini index f1578bd..fdc2085 100644 --- a/panel/config/maps-vpanel.ini +++ b/panel/config/maps-vpanel.ini @@ -41,6 +41,7 @@ /Websites [sync] = Panel\Vhost\Vhosts /Websites/Add [sync] = Panel\Vhost\VhostsAdd /Websites/@vhost [sync] = Panel\Vhost\Vhosts +/Websites/@vhost/Edit [sync] = Panel\Vhost\VhostsEdit /Websites/@vhost/Disable [sync] = Panel\Vhost\VhostsDisable /Websites/@vhost/Enable [sync] = Panel\Vhost\VhostsEnable /Websites/@vhost/Delete [sync] = Panel\Vhost\VhostsDelete diff --git a/panel/ui/vhost/users-user.html b/panel/ui/vhost/users-user.html index 5e4b542..ca89582 100644 --- a/panel/ui/vhost/users-user.html +++ b/panel/ui/vhost/users-user.html @@ -30,6 +30,7 @@ Website Username Status + PHP Version Action @@ -37,9 +38,10 @@ {{ @vhost_domain.virtualhost }} - {{ @vhost_domain.username }} - {{ @vhost_domain.status }} - Disable Delete + {{ @vhost_domain.username }} + {{ @vhost_domain.status }} + {{ @vhost_domain.php }} + Disable Delete diff --git a/panel/ui/vhost/vhosts-add.html b/panel/ui/vhost/vhosts-add.html index 975e2bf..87efdbc 100644 --- a/panel/ui/vhost/vhosts-add.html +++ b/panel/ui/vhost/vhosts-add.html @@ -7,6 +7,20 @@ + + +