|
| 1 | +<?php |
| 2 | +error_reporting(NULL); |
| 3 | +$TAB = 'SERVER'; |
| 4 | + |
| 5 | +// Main include |
| 6 | +include($_SERVER['DOCUMENT_ROOT']."/inc/main.php"); |
| 7 | + |
| 8 | +// Check user |
| 9 | +if ($_SESSION['user'] != 'admin') { |
| 10 | + header("Location: /list/user"); |
| 11 | + exit; |
| 12 | +} |
| 13 | + |
| 14 | +// Check POST request |
| 15 | +if (!empty($_POST['save'])) { |
| 16 | + |
| 17 | + // Check token |
| 18 | + if ((!isset($_POST['token'])) || ($_SESSION['token'] != $_POST['token'])) { |
| 19 | + header('location: /login/'); |
| 20 | + exit(); |
| 21 | + } |
| 22 | + |
| 23 | + // Set restart flag |
| 24 | + $v_restart = 'yes'; |
| 25 | + if (empty($_POST['v_restart'])) $v_restart = 'no'; |
| 26 | + |
| 27 | + // Update config |
| 28 | + if (!empty($_POST['v_config'])) { |
| 29 | + exec ('mktemp', $mktemp_output, $return_var); |
| 30 | + $new_conf = $mktemp_output[0]; |
| 31 | + $fp = fopen($new_conf, 'w'); |
| 32 | + fwrite($fp, str_replace("\r\n", "\n", $_POST['v_config'])); |
| 33 | + fclose($new_conf); |
| 34 | + exec (VESTA_CMD."v-change-sys-service-config ".$new_conf." php ".$v_restart, $output, $return_var); |
| 35 | + check_return_code($return_var,$output); |
| 36 | + unset($output); |
| 37 | + unlink($new_conf); |
| 38 | + } |
| 39 | + |
| 40 | + // Set success message |
| 41 | + if (empty($_SESSION['error_msg'])) { |
| 42 | + $_SESSION['ok_msg'] = __('Changes has been saved.'); |
| 43 | + } |
| 44 | + |
| 45 | +} |
| 46 | + |
| 47 | +// List config |
| 48 | +exec (VESTA_CMD."v-list-sys-php-config json", $output, $return_var); |
| 49 | +$data = json_decode(implode('', $output), true); |
| 50 | +unset($output); |
| 51 | +$v_memory_limit = $data['CONFIG']['memory_limit']; |
| 52 | +$v_max_execution_time = $data['CONFIG']['max_execution_time']; |
| 53 | +$v_max_input_time = $data['CONFIG']['max_input_time']; |
| 54 | +$v_upload_max_filesize = $data['CONFIG']['upload_max_filesize']; |
| 55 | +$v_post_max_size = $data['CONFIG']['post_max_size']; |
| 56 | +$v_display_errors = $data['CONFIG']['display_errors']; |
| 57 | +$v_error_reporting = $data['CONFIG']['error_reporting']; |
| 58 | +$v_config_path = $data['CONFIG']['config_path']; |
| 59 | + |
| 60 | +# Read config |
| 61 | +$v_config = shell_exec(VESTA_CMD."v-open-fs-config ".$v_config_path); |
| 62 | + |
| 63 | +// Render page |
| 64 | +render_page($user, $TAB, 'edit_server_php'); |
| 65 | + |
| 66 | +// Flush session messages |
| 67 | +unset($_SESSION['error_msg']); |
| 68 | +unset($_SESSION['ok_msg']); |
0 commit comments