|
33 | 33 | if ($v_timezone == 'America/Puerto_Rico' ) $v_timezone = 'AST'; |
34 | 34 | if ($v_timezone == 'America/Halifax' ) $v_timezone = 'ADT'; |
35 | 35 |
|
| 36 | +// List supported php versions |
| 37 | +exec (HESTIA_CMD."v-list-web-templates-backend json", $output, $return_var); |
| 38 | +$backend_templates = json_decode(implode('', $output), true); |
| 39 | +unset($output); |
| 40 | + |
| 41 | +$v_php_versions = [ |
| 42 | + 'php-5.6', |
| 43 | + 'php-7.0', |
| 44 | + 'php-7.1', |
| 45 | + 'php-7.2', |
| 46 | + 'php-7.3', |
| 47 | +]; |
| 48 | +sort($v_php_versions); |
| 49 | + |
| 50 | +$v_php_versions = array_map(function($php_version) use ($backend_templates, $v_php_versions) { |
| 51 | + // Mark installed php versions |
| 52 | + |
| 53 | + if(stripos($php_version,'php') !== 0) |
| 54 | + return false; |
| 55 | + |
| 56 | + $phpinfo = (object) [ |
| 57 | + "name" => $php_version, |
| 58 | + "tpl" => strtoupper(str_replace('.', '_', $php_version)), |
| 59 | + "version" => str_ireplace('php-', '', $php_version) |
| 60 | + ]; |
| 61 | + |
| 62 | + if(in_array($phpinfo->tpl, $backend_templates)) { |
| 63 | + $phpinfo->installed = true; |
| 64 | + } |
| 65 | + |
| 66 | + if(array_search($phpinfo->name, array_reverse($v_php_versions, true)) == array_key_last($v_php_versions)) { |
| 67 | + // Prevent default php version to be removed |
| 68 | + $phpinfo->protected = true; |
| 69 | + } |
| 70 | + |
| 71 | + return $phpinfo; |
| 72 | +}, $v_php_versions); |
| 73 | + |
36 | 74 | // List supported languages |
37 | 75 | exec (HESTIA_CMD."v-list-sys-languages json", $output, $return_var); |
38 | 76 | $languages = json_decode(implode('', $output), true); |
|
115 | 153 | $v_hostname = $_POST['v_hostname']; |
116 | 154 | } |
117 | 155 |
|
| 156 | + // Install/remove php versions |
| 157 | + if (empty($_SESSION['error_msg'])) { |
| 158 | + if(!empty($v_php_versions) && count($_POST['v_php_versions'] != count($v_php_versions))) { |
| 159 | + $post_php = $_POST['v_php_versions']; |
| 160 | + |
| 161 | + array_map(function($php_version) use ($post_php) { |
| 162 | + |
| 163 | + if(array_key_exists($php_version->tpl, $post_php)) { |
| 164 | + if(!$php_version->installed) { |
| 165 | + exec (HESTIA_CMD . "v-add-web-php " . escapeshellarg($php_version->version), $output, $return_var); |
| 166 | + check_return_code($return_var, $output); |
| 167 | + unset($output); |
| 168 | + if(empty($_SESSION['error_msg'])) |
| 169 | + $php_version->installed = true; |
| 170 | + } |
| 171 | + } else { |
| 172 | + if($php_version->installed && !$php_version->protected) { |
| 173 | + exec (HESTIA_CMD . "v-delete-web-php " . escapeshellarg($php_version->version), $output, $return_var); |
| 174 | + check_return_code($return_var, $output); |
| 175 | + unset($output); |
| 176 | + if(empty($_SESSION['error_msg'])) |
| 177 | + $php_version->installed = false; |
| 178 | + } |
| 179 | + } |
| 180 | + |
| 181 | + return $php_version; |
| 182 | + }, $v_php_versions); |
| 183 | + } |
| 184 | + } |
| 185 | + |
118 | 186 | // Change timezone |
119 | 187 | if (empty($_SESSION['error_msg'])) { |
120 | 188 | if (!empty($_POST['v_timezone'])) { |
|
0 commit comments