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['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." mysql ".$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-mysql-config json", $output, $return_var);
  40. $data = json_decode(implode('', $output), true);
  41. unset($output);
  42. $v_max_user_connections = $data['CONFIG']['max_user_connections'];
  43. $v_max_connections = $data['CONFIG']['max_connections'];
  44. $v_wait_timeout = $data['CONFIG']['wait_timeout'];
  45. $v_interactive_timeout = $data['CONFIG']['interactive_timeout'];
  46. $v_max_allowed_packet = $data['CONFIG']['max_allowed_packet'];
  47. $v_config_path = $data['CONFIG']['config_path'];
  48. $v_service_name = strtoupper('mysql');
  49. # Read config
  50. $v_config = shell_exec(VESTA_CMD."v-open-fs-config ".$v_config_path);
  51. // Render page
  52. render_page($user, $TAB, 'edit_server_mysql');
  53. // Flush session messages
  54. unset($_SESSION['error_msg']);
  55. unset($_SESSION['ok_msg']);