Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 54 lines (49 sloc) 3.18 kB
ff97ef9 Events (MySQL 5.1)
jakubvrana authored
1 <?php
79d1902 Substitute table name to $TABLE
jakubvrana authored
2 $EVENT = $_GET["event"];
ff97ef9 Events (MySQL 5.1)
jakubvrana authored
3 $intervals = array("YEAR", "QUARTER", "MONTH", "DAY", "HOUR", "MINUTE", "WEEK", "SECOND", "YEAR_MONTH", "DAY_HOUR", "DAY_MINUTE", "DAY_SECOND", "HOUR_MINUTE", "HOUR_SECOND", "MINUTE_SECOND");
c463946 Event status, comment and preserve
jakubvrana authored
4 $statuses = array("ENABLED" => "ENABLE", "DISABLED" => "DISABLE", "SLAVESIDE_DISABLED" => "DISABLE ON SLAVE");
ff97ef9 Events (MySQL 5.1)
jakubvrana authored
5
6 if ($_POST && !$error) {
7 if ($_POST["drop"]) {
79d1902 Substitute table name to $TABLE
jakubvrana authored
8 query_redirect("DROP EVENT " . idf_escape($EVENT), substr(ME, 0, -1), lang('Event has been dropped.'));
ced9de9 Create single column foreign key in table structure
jakubvrana authored
9 } elseif (in_array($_POST["INTERVAL_FIELD"], $intervals) && isset($statuses[$_POST["STATUS"]])) {
20679d8 Use \n in SQL commands
jakubvrana authored
10 $schedule = "\nON SCHEDULE " . ($_POST["INTERVAL_VALUE"]
7e644b4 @vrana Save bytes ($connection->quote shortcut)
authored
11 ? "EVERY " . q($_POST["INTERVAL_VALUE"]) . " $_POST[INTERVAL_FIELD]"
12 . ($_POST["STARTS"] ? " STARTS " . q($_POST["STARTS"]) : "")
13 . ($_POST["ENDS"] ? " ENDS " . q($_POST["ENDS"]) : "") //! ALTER EVENT doesn't drop ENDS - MySQL bug #39173
14 : "AT " . q($_POST["STARTS"])
c463946 Event status, comment and preserve
jakubvrana authored
15 ) . " ON COMPLETION" . ($_POST["ON_COMPLETION"] ? "" : " NOT") . " PRESERVE"
16 ;
d06de55 @vrana Use DELIMITER in history
authored
17 queries_redirect(substr(ME, 0, -1), ($EVENT != "" ? lang('Event has been altered.') : lang('Event has been created.')), queries(($EVENT != ""
79d1902 Substitute table name to $TABLE
jakubvrana authored
18 ? "ALTER EVENT " . idf_escape($EVENT) . $schedule
19 . ($EVENT != $_POST["EVENT_NAME"] ? "\nRENAME TO " . idf_escape($_POST["EVENT_NAME"]) : "")
c463946 Event status, comment and preserve
jakubvrana authored
20 : "CREATE EVENT " . idf_escape($_POST["EVENT_NAME"]) . $schedule
7e644b4 @vrana Save bytes ($connection->quote shortcut)
authored
21 ) . "\n" . $statuses[$_POST["STATUS"]] . " COMMENT " . q($_POST["EVENT_COMMENT"])
d06de55 @vrana Use DELIMITER in history
authored
22 . rtrim(" DO\n$_POST[EVENT_DEFINITION]", ";") . ";"
23 ));
ff97ef9 Events (MySQL 5.1)
jakubvrana authored
24 }
25 }
36d6864 Whitespace
jakubvrana authored
26
7352c28 Replace strlen() by != ""
jakubvrana authored
27 page_header(($EVENT != "" ? lang('Alter event') . ": " . h($EVENT) : lang('Create event')), $error);
ff97ef9 Events (MySQL 5.1)
jakubvrana authored
28
29 $row = array();
30 if ($_POST) {
31 $row = $_POST;
7352c28 Replace strlen() by != ""
jakubvrana authored
32 } elseif ($EVENT != "") {
7e644b4 @vrana Save bytes ($connection->quote shortcut)
authored
33 $rows = get_rows("SELECT * FROM information_schema.EVENTS WHERE EVENT_SCHEMA = " . q(DB) . " AND EVENT_NAME = " . q($EVENT));
b0d637b @vrana Avoid fatal errors
authored
34 $row = reset($rows);
ff97ef9 Events (MySQL 5.1)
jakubvrana authored
35 }
36 ?>
37
38 <form action="" method="post">
d30face Remove useless table attributes (thanks to Juraj Krivda)
jakubvrana authored
39 <table cellspacing="0">
689699a Shortcut for htmlspecialchars
jakubvrana authored
40 <tr><th><?php echo lang('Name'); ?><td><input name="EVENT_NAME" value="<?php echo h($row["EVENT_NAME"]); ?>" maxlength="64">
41 <tr><th><?php echo lang('Start'); ?><td><input name="STARTS" value="<?php echo h("$row[EXECUTE_AT]$row[STARTS]"); ?>">
42 <tr><th><?php echo lang('End'); ?><td><input name="ENDS" value="<?php echo h($row["ENDS"]); ?>">
0698409 Utilize html_select
jakubvrana authored
43 <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"]); ?>
44 <tr><th><?php echo lang('Status'); ?><td><?php echo html_select("STATUS", $statuses, $row["STATUS"]); ?>
689699a Shortcut for htmlspecialchars
jakubvrana authored
45 <tr><th><?php echo lang('Comment'); ?><td><input name="EVENT_COMMENT" value="<?php echo h($row["EVENT_COMMENT"]); ?>" maxlength="64">
6b30cfa Separate checkbox
jakubvrana authored
46 <tr><th>&nbsp;<td><?php echo checkbox("ON_COMPLETION", "PRESERVE", $row["ON_COMPLETION"] == "PRESERVE", lang('On completion preserve')); ?>
ff97ef9 Events (MySQL 5.1)
jakubvrana authored
47 </table>
6fffbbd Disable spell checking in SQL textareas
jakubvrana authored
48 <p><?php textarea("EVENT_DEFINITION", $row["EVENT_DEFINITION"]); ?>
ff97ef9 Events (MySQL 5.1)
jakubvrana authored
49 <p>
ace55ed HTML instead of XHTML
jakubvrana authored
50 <input type="submit" value="<?php echo lang('Save'); ?>">
a93bc19 @vrana Create confirm function
authored
51 <?php if ($EVENT != "") { ?><input type="submit" name="drop" value="<?php echo lang('Drop'); ?>"<?php echo confirm(); ?>><?php } ?>
740ae10 @vrana Don't send incomplete forms
authored
52 <input type="hidden" name="token" value="<?php echo $token; ?>">
ff97ef9 Events (MySQL 5.1)
jakubvrana authored
53 </form>
Something went wrong with that request. Please try again.