index.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. $TAB = "SERVER";
  3. // Main include
  4. include $_SERVER["DOCUMENT_ROOT"] . "/inc/main.php";
  5. // Check user
  6. if ($_SESSION["userContext"] !== "admin" && $user_plain === "$ROOT_USER") {
  7. header("Location: /list/user");
  8. exit();
  9. }
  10. // Check POST request
  11. if (!empty($_POST["save"])) {
  12. if (!empty($_POST["v_config"])) {
  13. exec("mktemp", $mktemp_output, $return_var);
  14. $new_conf = $mktemp_output[0];
  15. $fp = fopen($new_conf, "w");
  16. $config = str_replace("\r\n", "\n", $_POST["v_config"]);
  17. if (!str_ends_with($config, "\n")) {
  18. $config .= "\n";
  19. }
  20. fwrite($fp, $config);
  21. fclose($fp);
  22. exec(
  23. HESTIA_CMD . "v-change-sys-service-config " . $new_conf . " hestiaweb yes",
  24. $output,
  25. $return_var,
  26. );
  27. check_return_code($return_var, $output);
  28. unset($output);
  29. unlink($new_conf);
  30. }
  31. }
  32. $v_config_path = "/var/spool/cron/crontabs/hestiaweb";
  33. $v_service_name = _("Panel Cronjobs");
  34. // Read config
  35. $v_config = shell_exec(HESTIA_CMD . "v-open-fs-config " . $v_config_path);
  36. // Render page
  37. render_page($user, $TAB, "edit_server_service");
  38. // Flush session messages
  39. unset($_SESSION["error_msg"]);
  40. unset($_SESSION["ok_msg"]);