Files
VestaCP/web/add/cron/index.php

80 lines
2.4 KiB
PHP
Raw Normal View History

2013-01-18 18:23:04 +04:00
<?php
// Init
2013-01-29 00:18:09 +02:00
error_reporting(NULL);
2013-01-18 18:23:04 +04:00
ob_start();
session_start();
$TAB = 'CRON';
2014-07-30 15:34:34 +03:00
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
2013-01-18 18:23:04 +04:00
2014-07-30 15:34:34 +03:00
// Check POST request
2013-08-21 12:05:51 +03:00
if (!empty($_POST['ok'])) {
2014-07-30 15:34:34 +03:00
2015-06-03 02:31:03 +03:00
// Check token
if ((!isset($_POST['token'])) || ($_SESSION['token'] != $_POST['token'])) {
header('location: /login/');
exit();
2015-06-03 02:31:03 +03:00
}
2014-07-30 15:34:34 +03:00
// Check empty fields
if ((!isset($_POST['v_min'])) || ($_POST['v_min'] == '')) $errors[] = __('minute');
if ((!isset($_POST['v_hour'])) || ($_POST['v_hour'] == '')) $errors[] = __('hour');
if ((!isset($_POST['v_day'])) || ($_POST['v_day'] == '')) $errors[] = __('day');
if ((!isset($_POST['v_month'])) || ($_POST['v_month'] == '')) $errors[] = __('month');
if ((!isset($_POST['v_wday'])) || ($_POST['v_wday'] == '')) $errors[] = __('day of week');
if ((!isset($_POST['v_cmd'])) || ($_POST['v_cmd'] == '')) $errors[] = __('cmd');
2013-08-21 12:05:51 +03:00
if (!empty($errors[0])) {
foreach ($errors as $i => $error) {
if ( $i == 0 ) {
$error_msg = $error;
2013-01-18 18:23:04 +04:00
} else {
2013-08-21 12:05:51 +03:00
$error_msg = $error_msg.", ".$error;
2013-01-18 18:23:04 +04:00
}
}
2013-08-21 12:05:51 +03:00
$_SESSION['error_msg'] = __('Field "%s" can not be blank.',$error_msg);
2014-07-30 15:34:34 +03:00
}
// Protect input
$v_min = escapeshellarg($_POST['v_min']);
$v_hour = escapeshellarg($_POST['v_hour']);
$v_day = escapeshellarg($_POST['v_day']);
$v_month = escapeshellarg($_POST['v_month']);
$v_wday = escapeshellarg($_POST['v_wday']);
$v_cmd = escapeshellarg($_POST['v_cmd']);
2014-07-30 15:34:34 +03:00
// Add cron job
if (empty($_SESSION['error_msg'])) {
exec (VESTA_CMD."v-add-cron-job ".$user." ".$v_min." ".$v_hour." ".$v_day." ".$v_month." ".$v_wday." ".$v_cmd, $output, $return_var);
check_return_code($return_var,$output);
unset($output);
2014-07-30 15:34:34 +03:00
}
// Flush field values on success
if (empty($_SESSION['error_msg'])) {
$_SESSION['ok_msg'] = __('CRON_CREATED_OK');
unset($v_min);
unset($v_hour);
unset($v_day);
unset($v_month);
unset($v_wday);
unset($v_cmd);
unset($output);
2013-01-18 18:23:04 +04:00
}
2013-08-21 12:05:51 +03:00
}
2014-07-30 15:34:34 +03:00
// Header
include($_SERVER['DOCUMENT_ROOT'].'/templates/header.html');
2013-01-18 18:23:04 +04:00
2014-07-30 15:34:34 +03:00
// Panel
top_panel($user,$TAB);
// Display body
2013-08-21 12:05:51 +03:00
include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_cron.html');
2014-07-30 15:34:34 +03:00
// Flush session messages
2013-08-21 12:05:51 +03:00
unset($_SESSION['error_msg']);
unset($_SESSION['ok_msg']);
2013-01-18 18:23:04 +04:00
// Footer
include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html');