index.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. // Init
  3. error_reporting(NULL);
  4. ob_start();
  5. session_start();
  6. $TAB = 'CRON';
  7. include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
  8. // Header
  9. include($_SERVER['DOCUMENT_ROOT'].'/templates/header.html');
  10. // Panel
  11. top_panel($user,$TAB);
  12. if (!empty($_POST['ok'])) {
  13. // Check input
  14. if ((!isset($_POST['v_min'])) || ($_POST['v_min'] == '')) $errors[] = __('minute');
  15. if ((!isset($_POST['v_hour'])) || ($_POST['v_hour'] == '')) $errors[] = __('hour');
  16. if ((!isset($_POST['v_day'])) || ($_POST['v_day'] == '')) $errors[] = __('day');
  17. if ((!isset($_POST['v_month'])) || ($_POST['v_month'] == '')) $errors[] = __('month');
  18. if ((!isset($_POST['v_wday'])) || ($_POST['v_wday'] == '')) $errors[] = __('day of week');
  19. if ((!isset($_POST['v_cmd'])) || ($_POST['v_cmd'] == '')) $errors[] = __('cmd');
  20. // Protect input
  21. $v_min = escapeshellarg($_POST['v_min']);
  22. $v_hour = escapeshellarg($_POST['v_hour']);
  23. $v_day = escapeshellarg($_POST['v_day']);
  24. $v_month = escapeshellarg($_POST['v_month']);
  25. $v_wday = escapeshellarg($_POST['v_wday']);
  26. $v_cmd = escapeshellarg($_POST['v_cmd']);
  27. // Check for errors
  28. if (!empty($errors[0])) {
  29. foreach ($errors as $i => $error) {
  30. if ( $i == 0 ) {
  31. $error_msg = $error;
  32. } else {
  33. $error_msg = $error_msg.", ".$error;
  34. }
  35. }
  36. $_SESSION['error_msg'] = __('Field "%s" can not be blank.',$error_msg);
  37. } else {
  38. // Add Cron Job
  39. exec (VESTA_CMD."v-add-cron-job ".$user." ".$v_min." ".$v_hour." ".$v_day." ".$v_month." ".$v_wday." ".$v_cmd, $output, $return_var);
  40. $v_type = $_POST['v_type'];
  41. $v_charset = $_POST['v_charset'];
  42. check_return_code($return_var,$output);
  43. unset($v_password);
  44. unset($output);
  45. if (empty($_SESSION['error_msg'])) {
  46. $_SESSION['ok_msg'] = __('CRON_CREATED_OK');
  47. unset($v_min);
  48. unset($v_hour);
  49. unset($v_day);
  50. unset($v_month);
  51. unset($v_wday);
  52. unset($v_cmd);
  53. unset($output);
  54. }
  55. }
  56. }
  57. exec (VESTA_CMD."v-list-database-types 'json'", $output, $return_var);
  58. $db_types = json_decode(implode('', $output), true);
  59. unset($output);
  60. include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_cron.html');
  61. unset($_SESSION['error_msg']);
  62. unset($_SESSION['ok_msg']);
  63. // Footer
  64. include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html');