git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1498 7c3ca157-0c34-0410-bff1-cbf682f78f5c
54 lines
3.2 KiB
PHP
54 lines
3.2 KiB
PHP
<?php
|
|
$EVENT = $_GET["event"];
|
|
$intervals = array("YEAR", "QUARTER", "MONTH", "DAY", "HOUR", "MINUTE", "WEEK", "SECOND", "YEAR_MONTH", "DAY_HOUR", "DAY_MINUTE", "DAY_SECOND", "HOUR_MINUTE", "HOUR_SECOND", "MINUTE_SECOND");
|
|
$statuses = array("ENABLED" => "ENABLE", "DISABLED" => "DISABLE", "SLAVESIDE_DISABLED" => "DISABLE ON SLAVE");
|
|
|
|
if ($_POST && !$error) {
|
|
if ($_POST["drop"]) {
|
|
query_redirect("DROP EVENT " . idf_escape($EVENT), substr(ME, 0, -1), lang('Event has been dropped.'));
|
|
} elseif (in_array($_POST["INTERVAL_FIELD"], $intervals) && isset($statuses[$_POST["STATUS"]])) {
|
|
$schedule = "\nON SCHEDULE " . ($_POST["INTERVAL_VALUE"]
|
|
? "EVERY " . $connection->quote($_POST["INTERVAL_VALUE"]) . " $_POST[INTERVAL_FIELD]"
|
|
. ($_POST["STARTS"] ? " STARTS " . $connection->quote($_POST["STARTS"]) : "")
|
|
. ($_POST["ENDS"] ? " ENDS " . $connection->quote($_POST["ENDS"]) : "") //! ALTER EVENT doesn't drop ENDS - MySQL bug #39173
|
|
: "AT " . $connection->quote($_POST["STARTS"])
|
|
) . " ON COMPLETION" . ($_POST["ON_COMPLETION"] ? "" : " NOT") . " PRESERVE"
|
|
;
|
|
query_redirect(($EVENT != ""
|
|
? "ALTER EVENT " . idf_escape($EVENT) . $schedule
|
|
. ($EVENT != $_POST["EVENT_NAME"] ? "\nRENAME TO " . idf_escape($_POST["EVENT_NAME"]) : "")
|
|
: "CREATE EVENT " . idf_escape($_POST["EVENT_NAME"]) . $schedule
|
|
) . "\n" . $statuses[$_POST["STATUS"]] . " COMMENT " . $connection->quote($_POST["EVENT_COMMENT"])
|
|
. " DO\n$_POST[EVENT_DEFINITION]"
|
|
, substr(ME, 0, -1), ($EVENT != "" ? lang('Event has been altered.') : lang('Event has been created.')));
|
|
}
|
|
}
|
|
|
|
page_header(($EVENT != "" ? lang('Alter event') . ": " . h($EVENT) : lang('Create event')), $error);
|
|
|
|
$row = array();
|
|
if ($_POST) {
|
|
$row = $_POST;
|
|
} elseif ($EVENT != "") {
|
|
$result = $connection->query("SELECT * FROM information_schema.EVENTS WHERE EVENT_SCHEMA = " . $connection->quote(DB) . " AND EVENT_NAME = " . $connection->quote($EVENT));
|
|
$row = $result->fetch_assoc();
|
|
}
|
|
?>
|
|
|
|
<form action="" method="post">
|
|
<table cellspacing="0">
|
|
<tr><th><?php echo lang('Name'); ?><td><input name="EVENT_NAME" value="<?php echo h($row["EVENT_NAME"]); ?>" maxlength="64">
|
|
<tr><th><?php echo lang('Start'); ?><td><input name="STARTS" value="<?php echo h("$row[EXECUTE_AT]$row[STARTS]"); ?>">
|
|
<tr><th><?php echo lang('End'); ?><td><input name="ENDS" value="<?php echo h($row["ENDS"]); ?>">
|
|
<tr><th><?php echo lang('Every'); ?><td><input name="INTERVAL_VALUE" value="<?php echo h($row["INTERVAL_VALUE"]); ?>" size="6"> <?php echo html_select("INTERVAL_FIELD", $intervals, $row["INTERVAL_FIELD"]); ?>
|
|
<tr><th><?php echo lang('Status'); ?><td><?php echo html_select("STATUS", $statuses, $row["STATUS"]); ?>
|
|
<tr><th><?php echo lang('Comment'); ?><td><input name="EVENT_COMMENT" value="<?php echo h($row["EVENT_COMMENT"]); ?>" maxlength="64">
|
|
<tr><th> <td><?php echo checkbox("ON_COMPLETION", "PRESERVE", $row["ON_COMPLETION"] == "PRESERVE", lang('On completion preserve')); ?>
|
|
</table>
|
|
<p><?php textarea("EVENT_DEFINITION", $row["EVENT_DEFINITION"]); ?>
|
|
<p>
|
|
<input type="hidden" name="token" value="<?php echo $token; ?>">
|
|
<input type="submit" value="<?php echo lang('Save'); ?>">
|
|
<?php if ($EVENT != "") { ?><input type="submit" name="drop" value="<?php echo lang('Drop'); ?>"<?php echo $confirm; ?>><?php } ?>
|
|
</form>
|