From 256baadb853006a5a5a3287ac7e4231aa09d7113 Mon Sep 17 00:00:00 2001 From: Ludovic Poujol Date: Wed, 27 Mar 2019 14:07:47 +0100 Subject: [PATCH] Add PHP version update interface when running in multiphp mode --- htdocs/common.php | 10 +++++ htdocs/index.php | 9 ++-- inc/webadmin-php.php | 94 ++++++++++++++++++++++++++++++++++++++++ tpl/webadmin-php.tpl.php | 26 +++++++++++ tpl/webadmin.tpl.php | 24 +++++----- 5 files changed, 148 insertions(+), 15 deletions(-) create mode 100644 inc/webadmin-php.php create mode 100644 tpl/webadmin-php.tpl.php diff --git a/htdocs/common.php b/htdocs/common.php index 1c4acba..1e2532f 100644 --- a/htdocs/common.php +++ b/htdocs/common.php @@ -87,6 +87,16 @@ function load_config_cluster($cluster) { $conf = array_merge($conf, $clusterconf); } +/** + * Return wether or not this evoadmin install is a multi PHP install + * + * @return boolean - True when it's a multi PHP system + */ +function is_multiphp() +{ + return array_key_exists('php_versions', $conf) && count($conf['php_versions']) > 1; +} + /** * Includes */ diff --git a/htdocs/index.php b/htdocs/index.php index 7e78c11..62d2a65 100755 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -4,7 +4,7 @@ * common DirectoryIndex page * * Copyright (c) 2009 Evolix - Tous droits reserves - * + * * vim: expandtab softtabstop=4 tabstop=4 shiftwidth=4 showtabline=2 * * @author Gregory Colpart @@ -24,7 +24,7 @@ define('EVOADMIN_BASE','./'); session_name('EVOADMINWEB_SESS'); session_start(); -error_reporting(E_ALL | E_NOTICE); +error_reporting(E_ALL); header('Content-Type: text/html; charset=utf-8'); /** @@ -56,6 +56,10 @@ if (!array_key_exists('auth', $_SESSION) || $_SESSION['auth']!=1) { include_once EVOADMIN_BASE . '../inc/webadmin-itk.php'; +} elseif (preg_match('#^/webadmin/php/(.*)/?$#', $uri, $params)) { + + include_once EVOADMIN_BASE . '../inc/webadmin-php.php'; + } elseif (preg_match('#^/webadmin/edit/(.*)/?$#', $uri, $params)) { include_once EVOADMIN_BASE . '../inc/webadmin-edit.php'; @@ -83,4 +87,3 @@ if (!array_key_exists('auth', $_SESSION) || $_SESSION['auth']!=1) { } else { die ("Cette page n'existe pas !!!"); } - diff --git a/inc/webadmin-php.php b/inc/webadmin-php.php new file mode 100644 index 0000000..6afba03 --- /dev/null +++ b/inc/webadmin-php.php @@ -0,0 +1,94 @@ + + * @author Thomas Martin + * @author Sebastien Palma + * @version 1.0 + */ + +require_once EVOADMIN_BASE . '../lib/bdd.php'; +require_once EVOADMIN_BASE . '../lib/domain.php'; +require_once EVOADMIN_BASE . '../evolibs/Form.php'; + +global $conf; + +$form = new FormPage("Modification de la version de PHP", FALSE); +$form->addField('php_version', new SelectFormField("Nouvelle version de PHP", True, $conf['php_versions'])); + +include_once EVOADMIN_BASE . '../tpl/header.tpl.php'; +include_once EVOADMIN_BASE . '../tpl/menu.tpl.php'; + +$domain = $params[1]; + +// TODO: adapt for cluster mode +if ($conf['cluster']) { + print "
"; + printf ('

ERREUR

'); + printf ('

Cette action n\'est pas encore supportée en mode cluster

'); + printf ('

Retour à liste des comptes

'); + print "
"; +} +else { + $cmd = 'web-add.sh list-vhost ' . escapeshellarg($domain); + sudoexec($cmd, $data_output, $exec_return); + + $data_split = explode(':', $data_output[0]); + $current_PHP_version = $data_split[7]; + + if (!empty($_POST)) { + $form->isCurrentPage(TRUE); + $form->initFields(); + + if ($form->verify(TRUE)) { + if (isset($conf['php_versions'][$form->getField('php_version')->getValue()])) + { + $selected_php_version = $conf['php_versions'][$form->getField('php_version')->getValue()]; + $exec_cmd = 'web-add.sh setphpversion '.escapeshellarg($domain).' '.escapeshellarg($selected_php_version); + sudoexec($exec_cmd, $exec_output, $exec_return); + + if ($exec_return == 0) { + + print "
"; + printf ('

La version de PHP bien été modifié

'); + printf ('

Retour à liste des comptes

'); + print "
"; + + } + else { + print "
"; + printf ('

ERREUR

'); + printf ('

Une erreur innatendue s\'est produite

'); + + if ($conf['debug'] == TRUE) { + print '
';
+                            foreach($exec_output as $exec_line) {
+                                printf("%s\n", $exec_line);
+                            }
+                            print '
'; + } + + printf ('

Retour à liste des comptes

'); + print "
"; + } + } + else { + include_once EVOADMIN_BASE . '../tpl/webadmin-php.tpl.php'; + } + } + else { + include_once EVOADMIN_BASE . '../tpl/webadmin-php.tpl.php'; + } + } + else { + include_once EVOADMIN_BASE . '../tpl/webadmin-php.tpl.php'; + } + + include_once EVOADMIN_BASE . '../tpl/footer.tpl.php'; +} diff --git a/tpl/webadmin-php.tpl.php b/tpl/webadmin-php.tpl.php new file mode 100644 index 0000000..34f590b --- /dev/null +++ b/tpl/webadmin-php.tpl.php @@ -0,0 +1,26 @@ + + * @version 1.0 + */ + +?> + +

Version PHP

+ +

Version actuelle de PHP :

+ +
+
+ Changement de version de PHP + +

+
+
diff --git a/tpl/webadmin.tpl.php b/tpl/webadmin.tpl.php index 6a7cbfb..3ae37f0 100755 --- a/tpl/webadmin.tpl.php +++ b/tpl/webadmin.tpl.php @@ -5,7 +5,7 @@ * * Copyright (c) 2009 Evolix - Tous droits reserves * - * vim: expandtab softtabstop=4 tabstop=4 shiftwidth=4 showtabline=2 + * vim: expandtab softtabstop=4 tabstop=4 shiftwidth=4 showtabline=2 * * @author Gregory Colpart * @author Thomas Martin @@ -15,7 +15,7 @@ ?> -

Domaines

+

Liste des comptes web

0) { ?> @@ -41,9 +41,7 @@  Alias '; - print ''; - print ''; + print ''; } ?> @@ -65,7 +63,7 @@ } printf('', $vhost_info['server_name'], $vhost_info['server_name']); - + if ($conf['cluster']) { if (empty($vhost_info['bdd'])) printf('', preg_replace("/^(\d)(\d)$/", '\1.\2', $vhost_info['php_version'])); } printf('', ($vhost_info['is_enabled'] ? 'Activé' : 'Désactivé' )); + if (is_superadmin()) { - printf('', - $vhost_info['owner']); - printf('', - $vhost_info['owner']); - printf('', - $vhost_info['owner']); + printf(''); + } print '';
 Actif ?   ServerName  Sécurité Administrationhttp://%s'); @@ -101,13 +99,15 @@ printf('%s%sGérerModifierGérer'); + printf('Alias - ', $vhost_info['owner']); + printf('Servername - ', $vhost_info['owner']); + printf('ITK - ', $vhost_info['owner']); + printf('PHP', $vhost_info['owner']); + printf('