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