index.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. use function Hestiacp\quoteshellarg\quoteshellarg;
  3. $TAB = "SERVER";
  4. // Main include
  5. include $_SERVER["DOCUMENT_ROOT"] . "/inc/main.php";
  6. // Check user
  7. if ($_SESSION["userContext"] !== "admin" && $user_plain === "$ROOT_USER") {
  8. header("Location: /list/user");
  9. exit();
  10. }
  11. // Check POST request
  12. if (!empty($_POST["save"])) {
  13. if (!empty($_POST["v_config"])) {
  14. $fp = tmpfile();
  15. $new_conf = stream_get_meta_data($fp)["uri"];
  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. exec(
  22. HESTIA_CMD .
  23. "v-change-sys-service-config " .
  24. quoteshellarg($new_conf) .
  25. " hestiaweb yes",
  26. $output,
  27. $return_var,
  28. );
  29. check_return_code($return_var, $output);
  30. unset($output);
  31. fclose($fp);
  32. }
  33. }
  34. $v_config_path = "/var/spool/cron/crontabs/hestiaweb";
  35. $v_service_name = _("Panel Cronjobs");
  36. // Read config
  37. $v_config = shell_exec(HESTIA_CMD . "v-open-fs-config " . $v_config_path);
  38. // Render page
  39. render_page($user, $TAB, "edit_server_service");
  40. // Flush session messages
  41. unset($_SESSION["error_msg"]);
  42. unset($_SESSION["ok_msg"]);