Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 53 lines (47 sloc) 3.194 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");
a099167 @vrana Simplify initializing post variables
authored
5 $row = $_POST;
ff97ef9 Events (MySQL 5.1)
jakubvrana authored
6
7 if ($_POST && !$error) {
8 if ($_POST["drop"]) {
79d1902 Substitute table name to $TABLE
jakubvrana authored
9 query_redirect("DROP EVENT " . idf_escape($EVENT), substr(ME, 0, -1), lang('Event has been dropped.'));
a099167 @vrana Simplify initializing post variables
authored
10 } elseif (in_array($row["INTERVAL_FIELD"], $intervals) && isset($statuses[$row["STATUS"]])) {
11 $schedule = "\nON SCHEDULE " . ($row["INTERVAL_VALUE"]
12 ? "EVERY " . q($row["INTERVAL_VALUE"]) . " $row[INTERVAL_FIELD]"
13 . ($row["STARTS"] ? " STARTS " . q($row["STARTS"]) : "")
14 . ($row["ENDS"] ? " ENDS " . q($row["ENDS"]) : "") //! ALTER EVENT doesn't drop ENDS - MySQL bug #39173
15 : "AT " . q($row["STARTS"])
16 ) . " ON COMPLETION" . ($row["ON_COMPLETION"] ? "" : " NOT") . " PRESERVE"
c463946 Event status, comment and preserve
jakubvrana authored
17 ;
9c78b3b @vrana Add empty lines to source code
authored
18
d06de55 @vrana Use DELIMITER in history
authored
19 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
20 ? "ALTER EVENT " . idf_escape($EVENT) . $schedule
a099167 @vrana Simplify initializing post variables
authored
21 . ($EVENT != $row["EVENT_NAME"] ? "\nRENAME TO " . idf_escape($row["EVENT_NAME"]) : "")
22 : "CREATE EVENT " . idf_escape($row["EVENT_NAME"]) . $schedule
23 ) . "\n" . $statuses[$row["STATUS"]] . " COMMENT " . q($row["EVENT_COMMENT"])
24 . rtrim(" DO\n$row[EVENT_DEFINITION]", ";") . ";"
d06de55 @vrana Use DELIMITER in history
authored
25 ));
ff97ef9 Events (MySQL 5.1)
jakubvrana authored
26 }
27 }
36d6864 Whitespace
jakubvrana authored
28
7352c28 Replace strlen() by != ""
jakubvrana authored
29 page_header(($EVENT != "" ? lang('Alter event') . ": " . h($EVENT) : lang('Create event')), $error);
ff97ef9 Events (MySQL 5.1)
jakubvrana authored
30
b7e1cb0 @vrana Save bytes
authored
31 if (!$row && $EVENT != "") {
7e644b4 @vrana Save bytes ($connection->quote shortcut)
authored
32 $rows = get_rows("SELECT * FROM information_schema.EVENTS WHERE EVENT_SCHEMA = " . q(DB) . " AND EVENT_NAME = " . q($EVENT));
b0d637b @vrana Avoid fatal errors
authored
33 $row = reset($rows);
ff97ef9 Events (MySQL 5.1)
jakubvrana authored
34 }
35 ?>
36
37 <form action="" method="post">
d30face Remove useless table attributes (thanks to Juraj Krivda)
jakubvrana authored
38 <table cellspacing="0">
f86cb5f @vrana Use autocapitalize="off"
authored
39 <tr><th><?php echo lang('Name'); ?><td><input name="EVENT_NAME" value="<?php echo h($row["EVENT_NAME"]); ?>" maxlength="64" autocapitalize="off">
3d2b869 @vrana Add typehint to event fields
authored
40 <tr><th title="datetime"><?php echo lang('Start'); ?><td><input name="STARTS" value="<?php echo h("$row[EXECUTE_AT]$row[STARTS]"); ?>">
41 <tr><th title="datetime"><?php echo lang('End'); ?><td><input name="ENDS" value="<?php echo h($row["ENDS"]); ?>">
2fb1ebc @vrana HTML5 input fields
authored
42 <tr><th><?php echo lang('Every'); ?><td><input type="number" name="INTERVAL_VALUE" value="<?php echo h($row["INTERVAL_VALUE"]); ?>" class="size"> <?php echo html_select("INTERVAL_FIELD", $intervals, $row["INTERVAL_FIELD"]); ?>
0698409 Utilize html_select
jakubvrana authored
43 <tr><th><?php echo lang('Status'); ?><td><?php echo html_select("STATUS", $statuses, $row["STATUS"]); ?>
689699a Shortcut for htmlspecialchars
jakubvrana authored
44 <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
45 <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
46 </table>
6fffbbd Disable spell checking in SQL textareas
jakubvrana authored
47 <p><?php textarea("EVENT_DEFINITION", $row["EVENT_DEFINITION"]); ?>
ff97ef9 Events (MySQL 5.1)
jakubvrana authored
48 <p>
ace55ed HTML instead of XHTML
jakubvrana authored
49 <input type="submit" value="<?php echo lang('Save'); ?>">
a93bc19 @vrana Create confirm function
authored
50 <?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
51 <input type="hidden" name="token" value="<?php echo $token; ?>">
ff97ef9 Events (MySQL 5.1)
jakubvrana authored
52 </form>
Something went wrong with that request. Please try again.