index.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. use function Hestiacp\quoteshellarg\quoteshellarg;
  3. ob_start();
  4. include $_SERVER["DOCUMENT_ROOT"] . "/inc/main.php";
  5. // Check token
  6. verify_csrf($_POST);
  7. if (empty($_POST["job"])) {
  8. header("Location: /list/cron/");
  9. exit();
  10. }
  11. $job = $_POST["job"];
  12. if (empty($_POST["action"])) {
  13. header("Location: /list/cron/");
  14. exit();
  15. }
  16. $action = $_POST["action"];
  17. if ($_SESSION["userContext"] === "admin") {
  18. switch ($action) {
  19. case "delete":
  20. $cmd = "v-delete-cron-job";
  21. break;
  22. case "suspend":
  23. $cmd = "v-suspend-cron-job";
  24. break;
  25. case "unsuspend":
  26. $cmd = "v-unsuspend-cron-job";
  27. break;
  28. case "delete-cron-reports":
  29. $cmd = "v-delete-cron-reports";
  30. exec(HESTIA_CMD . $cmd . " " . $user, $output, $return_var);
  31. $_SESSION["error_msg"] = _("Cron job email reporting has been successfully disabled.");
  32. unset($output);
  33. header("Location: /list/cron/");
  34. exit();
  35. break;
  36. case "add-cron-reports":
  37. $cmd = "v-add-cron-reports";
  38. exec(HESTIA_CMD . $cmd . " " . $user, $output, $return_var);
  39. $_SESSION["error_msg"] = _("Cron job email reporting has been successfully enabled.");
  40. unset($output);
  41. header("Location: /list/cron/");
  42. exit();
  43. break;
  44. default:
  45. header("Location: /list/cron/");
  46. exit();
  47. }
  48. } else {
  49. switch ($action) {
  50. case "delete":
  51. $cmd = "v-delete-cron-job";
  52. break;
  53. case "delete-cron-reports":
  54. $cmd = "v-delete-cron-reports";
  55. exec(HESTIA_CMD . $cmd . " " . $user, $output, $return_var);
  56. $_SESSION["error_msg"] = _("Cron job email reporting has been successfully disabled.");
  57. unset($output);
  58. header("Location: /list/cron/");
  59. exit();
  60. break;
  61. case "add-cron-reports":
  62. $cmd = "v-add-cron-reports";
  63. exec(HESTIA_CMD . $cmd . " " . $user, $output, $return_var);
  64. $_SESSION["error_msg"] = _("Cron job email reporting has been successfully enabled.");
  65. unset($output);
  66. header("Location: /list/cron/");
  67. exit();
  68. break;
  69. default:
  70. header("Location: /list/cron/");
  71. exit();
  72. }
  73. }
  74. foreach ($job as $value) {
  75. $value = quoteshellarg($value);
  76. exec(HESTIA_CMD . $cmd . " " . $user . " " . $value . " no", $output, $return_var);
  77. $restart = "yes";
  78. }
  79. if (!empty($restart)) {
  80. exec(HESTIA_CMD . "v-restart-cron", $output, $return_var);
  81. }
  82. header("Location: /list/cron/");