mirror of
https://github.com/serghey-rodin/vesta.git
synced 2025-08-14 18:49:17 -07:00
cron add page
This commit is contained in:
parent
d218e55de5
commit
f14550a5a7
3 changed files with 150 additions and 0 deletions
78
web/add/cron/index.php
Normal file
78
web/add/cron/index.php
Normal file
|
@ -0,0 +1,78 @@
|
|||
<?php
|
||||
// Init
|
||||
//error_reporting(NULL);
|
||||
ob_start();
|
||||
session_start();
|
||||
$TAB = 'CRON';
|
||||
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
|
||||
|
||||
// Header
|
||||
include($_SERVER['DOCUMENT_ROOT'].'/templates/header.html');
|
||||
|
||||
// Panel
|
||||
top_panel($user,$TAB);
|
||||
|
||||
// Are you admin?
|
||||
if ($_SESSION['user'] == 'admin') {
|
||||
if (!empty($_POST['ok'])) {
|
||||
// Check input
|
||||
if (empty($_POST['v_min'])) $errors[] = 'minute';
|
||||
if (empty($_POST['v_hour'])) $errors[] = 'hour';
|
||||
if (empty($_POST['v_day'])) $errors[] = 'day';
|
||||
if (empty($_POST['v_month'])) $errors[] = 'month';
|
||||
if (empty($_POST['v_wday'])) $errors[] = 'day of week';
|
||||
if (empty($_POST['v_cmd'])) $errors[] = 'cmd';
|
||||
|
||||
// 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']);
|
||||
|
||||
// Check for errors
|
||||
if (!empty($errors[0])) {
|
||||
foreach ($errors as $i => $error) {
|
||||
if ( $i == 0 ) {
|
||||
$error_msg = $error;
|
||||
} else {
|
||||
$error_msg = $error_msg.", ".$error;
|
||||
}
|
||||
}
|
||||
$_SESSION['error_msg'] = "Error: field ".$error_msg." can not be blank.";
|
||||
} else {
|
||||
// Add Cron Job
|
||||
exec (VESTA_CMD."v_add_cron_job ".$user." ".$v_min." ".$v_hour." ".$v_day." ".$v_month." ".$v_wday." ".$v_cmd, $output, $return_var);
|
||||
$v_type = $_POST['v_type'];
|
||||
$v_charset = $_POST['v_charset'];
|
||||
if ($return_var != 0) {
|
||||
$error = implode('<br>', $output);
|
||||
if (empty($error)) $error = 'Error: vesta did not return any output.';
|
||||
$_SESSION['error_msg'] = $error;
|
||||
unset($v_password);
|
||||
unset($output);
|
||||
} else {
|
||||
$_SESSION['ok_msg'] = "OK: cron job has been created successfully.";
|
||||
unset($v_min);
|
||||
unset($v_hour);
|
||||
unset($v_day);
|
||||
unset($v_month);
|
||||
unset($v_wday);
|
||||
unset($v_cmd);
|
||||
unset($output);
|
||||
}
|
||||
}
|
||||
}
|
||||
exec (VESTA_CMD."v_list_database_types 'json'", $output, $return_var);
|
||||
$db_types = json_decode(implode('', $output), true);
|
||||
unset($output);
|
||||
|
||||
include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/menu_add_cron.html');
|
||||
include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/add_cron.html');
|
||||
unset($_SESSION['error_msg']);
|
||||
unset($_SESSION['ok_msg']);
|
||||
}
|
||||
|
||||
// Footer
|
||||
include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html');
|
57
web/templates/admin/add_cron.html
Normal file
57
web/templates/admin/add_cron.html
Normal file
|
@ -0,0 +1,57 @@
|
|||
<script type="text/javascript">
|
||||
function elementHideShow(elementToHideOrShow) {
|
||||
var el = document.getElementById(elementToHideOrShow);
|
||||
if (el.style.display == "block") {
|
||||
el.style.display = "none";
|
||||
} else {
|
||||
el.style.display = "block";
|
||||
}
|
||||
}
|
||||
|
||||
function randomString() {
|
||||
var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
|
||||
var string_length = 10;
|
||||
var randomstring = '';
|
||||
for (var i=0; i<string_length; i++) {
|
||||
var rnum = Math.floor(Math.random() * chars.length);
|
||||
randomstring += chars.substring(rnum,rnum+1);
|
||||
}
|
||||
document.v_add_user.v_password.value = randomstring;
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<table class='data'>
|
||||
<tr class="data-add">
|
||||
<td class="data-dotted" style="padding: 0px 10px 0px 0px" width="150">
|
||||
<table class="data-col1">
|
||||
<tr><td style="padding: 18 0 4 18;"></td></tr>
|
||||
</table>
|
||||
</td>
|
||||
<td class="data-dotted" width="830px" style="vertical-align:top;">
|
||||
<table width="830px"><tr>
|
||||
<td></td>
|
||||
</tr></table>
|
||||
<table class="data-col2" width="600px">
|
||||
<form method="post" name="v_add_user">
|
||||
<tr><td class="add-text" style="padding: 10 0 0 2px;">Minute</td></tr>
|
||||
<tr><td><input type="text" size="20" class="add-input" name="v_min" <?php if (!empty($v_min)) echo "value=".$v_min; ?>></td></tr>
|
||||
<tr><td class="add-text" style="padding: 10px 0 0 2px;">Hour</td></tr>
|
||||
<tr><td></span><input type="text" size="20" class="add-input" name="v_hour" <?php if (!empty($v_hour)) echo "value=".$v_hour; ?>></tr>
|
||||
<tr><td class="add-text" style="padding: 10px 0 0 2px;">Day</td></tr>
|
||||
<tr><td></span><input type="text" size="20" class="add-input" name="v_day" <?php if (!empty($v_day)) echo "value=".$v_day; ?>></tr>
|
||||
<tr><td class="add-text" style="padding: 10px 0 0 2px;">Month</td></tr>
|
||||
<tr><td></span><input type="text" size="20" class="add-input" name="v_month" <?php if (!empty($v_month)) echo "value=".$v_month; ?>></tr>
|
||||
<tr><td class="add-text" style="padding: 10px 0 0 2px;">Day of Week</td></tr>
|
||||
<tr><td></span><input type="text" size="20" class="add-input" name="v_wday" <?php if (!empty($v_wday)) echo "value=".$v_wday; ?>></tr>
|
||||
<tr><td class="add-text" style="padding: 10px 0 0 2px;">Command</td></tr>
|
||||
<tr><td></span><input type="text" size="20" class="add-input" name="v_cmd" <?php if (!empty($v_cmd)) echo "value=".$v_cmd; ?>></tr>
|
||||
|
||||
<tr><td style="padding: 24px 0 0 0;">
|
||||
<input type="submit" name="ok" value="OK" class="add-button"></form>
|
||||
<input type="button" class="add-button" value="Cancel" onClick="location.href='/list/cron/'">
|
||||
</td></tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
15
web/templates/admin/menu_add_cron.html
Normal file
15
web/templates/admin/menu_add_cron.html
Normal file
|
@ -0,0 +1,15 @@
|
|||
<table class="sub-menu">
|
||||
<tr>
|
||||
<td style="padding: 10px 2px 28px 0;" ><a class="add-name"><b>Adding Cron Job</b></a>
|
||||
<?php
|
||||
if (!empty($_SESSION['error_msg'])) {
|
||||
echo "<a class=\"add-error\"> → ".$_SESSION['error_msg']."</a>";
|
||||
} else {
|
||||
if (!empty($_SESSION['ok_msg'])) {
|
||||
echo "<a class=\"add-ok\"> → ".$_SESSION['ok_msg']."</a>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
Loading…
Add table
Add a link
Reference in a new issue