index.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. if ($return_var != 0) {
  43. $error = implode('<br>', $output);
  44. if (empty($error)) $error = __('Error code:',$return_var);
  45. $_SESSION['error_msg'] = $error;
  46. unset($v_password);
  47. unset($output);
  48. } else {
  49. $_SESSION['ok_msg'] = __('CRON_CREATED_OK');
  50. unset($v_min);
  51. unset($v_hour);
  52. unset($v_day);
  53. unset($v_month);
  54. unset($v_wday);
  55. unset($v_cmd);
  56. unset($output);
  57. }
  58. }
  59. }
  60. exec (VESTA_CMD."v-list-database-types 'json'", $output, $return_var);
  61. $db_types = json_decode(implode('', $output), true);
  62. unset($output);
  63. include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_cron.html');
  64. unset($_SESSION['error_msg']);
  65. unset($_SESSION['ok_msg']);
  66. // Footer
  67. include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html');