1
0

index.php 1.8 KB

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