index.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. // Are you admin?
  13. //if ($_SESSION['user'] == 'admin') {
  14. if (!empty($_POST['ok'])) {
  15. // Check input
  16. if (empty($_POST['v_min'])) $errors[] = __('minute');
  17. if (empty($_POST['v_hour'])) $errors[] = __('hour');
  18. if (empty($_POST['v_day'])) $errors[] = __('day');
  19. if (empty($_POST['v_month'])) $errors[] = __('month');
  20. if (empty($_POST['v_wday'])) $errors[] = __('day of week');
  21. if (empty($_POST['v_cmd'])) $errors[] = __('cmd');
  22. // Protect input
  23. $v_min = escapeshellarg($_POST['v_min']);
  24. $v_hour = escapeshellarg($_POST['v_hour']);
  25. $v_day = escapeshellarg($_POST['v_day']);
  26. $v_month = escapeshellarg($_POST['v_month']);
  27. $v_wday = escapeshellarg($_POST['v_wday']);
  28. $v_cmd = escapeshellarg($_POST['v_cmd']);
  29. // Check for errors
  30. if (!empty($errors[0])) {
  31. foreach ($errors as $i => $error) {
  32. if ( $i == 0 ) {
  33. $error_msg = $error;
  34. } else {
  35. $error_msg = $error_msg.", ".$error;
  36. }
  37. }
  38. $_SESSION['error_msg'] = __('Field "%s" can not be blank.',$error_msg);
  39. } else {
  40. // Add Cron Job
  41. exec (VESTA_CMD."v-add-cron-job ".$user." ".$v_min." ".$v_hour." ".$v_day." ".$v_month." ".$v_wday." ".$v_cmd, $output, $return_var);
  42. $v_type = $_POST['v_type'];
  43. $v_charset = $_POST['v_charset'];
  44. if ($return_var != 0) {
  45. $error = implode('<br>', $output);
  46. if (empty($error)) $error = __('Error code:',$return_var);
  47. $_SESSION['error_msg'] = $error;
  48. unset($v_password);
  49. unset($output);
  50. } else {
  51. $_SESSION['ok_msg'] = __('CRON_CREATED_OK');
  52. unset($v_min);
  53. unset($v_hour);
  54. unset($v_day);
  55. unset($v_month);
  56. unset($v_wday);
  57. unset($v_cmd);
  58. unset($output);
  59. }
  60. }
  61. }
  62. exec (VESTA_CMD."v-list-database-types 'json'", $output, $return_var);
  63. $db_types = json_decode(implode('', $output), true);
  64. unset($output);
  65. include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_cron.html');
  66. unset($_SESSION['error_msg']);
  67. unset($_SESSION['ok_msg']);
  68. //}
  69. // Footer
  70. include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html');