index.php 2.0 KB

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