index.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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(
  27. HESTIA_CMD . "v-change-sys-service-config " . $new_conf . " mysql " . $v_restart,
  28. $output,
  29. $return_var,
  30. );
  31. check_return_code($return_var, $output);
  32. unset($output);
  33. unlink($new_conf);
  34. }
  35. // Set success message
  36. if (empty($_SESSION["error_msg"])) {
  37. $_SESSION["ok_msg"] = _("Changes have been saved.");
  38. }
  39. }
  40. // List config
  41. exec(HESTIA_CMD . "v-list-sys-mysql-config json", $output, $return_var);
  42. $data = json_decode(implode("", $output), true);
  43. unset($output);
  44. $v_max_user_connections = $data["CONFIG"]["max_user_connections"];
  45. $v_max_connections = $data["CONFIG"]["max_connections"];
  46. $v_wait_timeout = $data["CONFIG"]["wait_timeout"];
  47. $v_interactive_timeout = $data["CONFIG"]["interactive_timeout"];
  48. $v_max_allowed_packet = $data["CONFIG"]["max_allowed_packet"];
  49. $v_config_path = $data["CONFIG"]["config_path"];
  50. $v_service_name = strtoupper("mysql");
  51. # Read config
  52. $v_config = shell_exec(HESTIA_CMD . "v-open-fs-config " . $v_config_path);
  53. // Render page
  54. render_page($user, $TAB, "edit_server_mysql");
  55. // Flush session messages
  56. unset($_SESSION["error_msg"]);
  57. unset($_SESSION["ok_msg"]);