index.php 1.9 KB

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