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