Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 54 lines (49 sloc) 3.621 kB
ff97ef9 Events (MySQL 5.1)
jakubvrana authored
1 <?php
2 $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
3 $statuses = array("ENABLED" => "ENABLE", "DISABLED" => "DISABLE", "SLAVESIDE_DISABLED" => "DISABLE ON SLAVE");
ff97ef9 Events (MySQL 5.1)
jakubvrana authored
4
5 if ($_POST && !$error) {
6 if ($_POST["drop"]) {
f91b2c4 Print SQL query by message
jakubvrana authored
7 query_redirect("DROP EVENT " . idf_escape($_GET["event"]), substr($SELF, 0, -1), lang('Event has been dropped.'));
ced9de9 Create single column foreign key in table structure
jakubvrana authored
8 } elseif (in_array($_POST["INTERVAL_FIELD"], $intervals) && isset($statuses[$_POST["STATUS"]])) {
20679d8 Use \n in SQL commands
jakubvrana authored
9 $schedule = "\nON SCHEDULE " . ($_POST["INTERVAL_VALUE"]
36a3656 Change escape_string to quote
jakubvrana authored
10 ? "EVERY " . $dbh->quote($_POST["INTERVAL_VALUE"]) . " $_POST[INTERVAL_FIELD]"
11 . ($_POST["STARTS"] ? " STARTS " . $dbh->quote($_POST["STARTS"]) : "")
12 . ($_POST["ENDS"] ? " ENDS " . $dbh->quote($_POST["ENDS"]) : "") //! ALTER EVENT doesn't drop ENDS - MySQL bug #39173
13 : "AT " . $dbh->quote($_POST["STARTS"])
c463946 Event status, comment and preserve
jakubvrana authored
14 ) . " ON COMPLETION" . ($_POST["ON_COMPLETION"] ? "" : " NOT") . " PRESERVE"
15 ;
16 query_redirect((strlen($_GET["event"])
17 ? "ALTER EVENT " . idf_escape($_GET["event"]) . $schedule
20679d8 Use \n in SQL commands
jakubvrana authored
18 . ($_GET["event"] != $_POST["EVENT_NAME"] ? "\nRENAME TO " . idf_escape($_POST["EVENT_NAME"]) : "")
c463946 Event status, comment and preserve
jakubvrana authored
19 : "CREATE EVENT " . idf_escape($_POST["EVENT_NAME"]) . $schedule
ced9de9 Create single column foreign key in table structure
jakubvrana authored
20 ) . "\n" . $statuses[$_POST["STATUS"]] . " COMMENT " . $dbh->quote($_POST["EVENT_COMMENT"])
36a3656 Change escape_string to quote
jakubvrana authored
21 . " DO\n$_POST[EVENT_DEFINITION]"
c463946 Event status, comment and preserve
jakubvrana authored
22 , substr($SELF, 0, -1), (strlen($_GET["event"]) ? lang('Event has been altered.') : lang('Event has been created.')));
ff97ef9 Events (MySQL 5.1)
jakubvrana authored
23 }
24 }
36d6864 Whitespace
jakubvrana authored
25
ff97ef9 Events (MySQL 5.1)
jakubvrana authored
26 page_header((strlen($_GET["event"]) ? lang('Alter event') . ": " . htmlspecialchars($_GET["event"]) : lang('Create event')), $error);
27
28 $row = array();
29 if ($_POST) {
30 $row = $_POST;
31 } elseif (strlen($_GET["event"])) {
36a3656 Change escape_string to quote
jakubvrana authored
32 $result = $dbh->query("SELECT * FROM information_schema.EVENTS WHERE EVENT_SCHEMA = " . $dbh->quote($_GET["db"]) . " AND EVENT_NAME = " . $dbh->quote($_GET["event"]));
ff97ef9 Events (MySQL 5.1)
jakubvrana authored
33 $row = $result->fetch_assoc();
34 $result->free();
35 }
36 ?>
37
38 <form action="" method="post">
d30face Remove useless table attributes (thanks to Juraj Krivda)
jakubvrana authored
39 <table cellspacing="0">
ace55ed HTML instead of XHTML
jakubvrana authored
40 <tr><th><?php echo lang('Name'); ?><td><input name="EVENT_NAME" value="<?php echo htmlspecialchars($row["EVENT_NAME"]); ?>" maxlength="64">
41 <tr><th><?php echo lang('Start'); ?><td><input name="STARTS" value="<?php echo htmlspecialchars("$row[EXECUTE_AT]$row[STARTS]"); ?>">
42 <tr><th><?php echo lang('End'); ?><td><input name="ENDS" value="<?php echo htmlspecialchars($row["ENDS"]); ?>">
43 <tr><th><?php echo lang('Every'); ?><td><input name="INTERVAL_VALUE" value="<?php echo htmlspecialchars($row["INTERVAL_VALUE"]); ?>" size="6"> <select name="INTERVAL_FIELD"><?php echo optionlist($intervals, $row["INTERVAL_FIELD"]); ?></select>
44 <tr><th><?php echo lang('Status'); ?><td><select name="STATUS"><?php echo optionlist($statuses, $row["STATUS"]); ?></select>
45 <tr><th><?php echo lang('Comment'); ?><td><input name="EVENT_COMMENT" value="<?php echo htmlspecialchars($row["EVENT_COMMENT"]); ?>" maxlength="64">
46 <tr><th>&nbsp;<td><label><input type="checkbox" name="ON_COMPLETION" value="PRESERVE"<?php echo ($row["ON_COMPLETION"] == "PRESERVE" ? " checked='checked'" : ""); ?>><?php echo lang('On completion preserve'); ?></label>
ff97ef9 Events (MySQL 5.1)
jakubvrana authored
47 </table>
ace55ed HTML instead of XHTML
jakubvrana authored
48 <p><textarea name="EVENT_DEFINITION" rows="10" cols="80" style="width: 98%;"><?php echo htmlspecialchars($row["EVENT_DEFINITION"]); ?></textarea>
ff97ef9 Events (MySQL 5.1)
jakubvrana authored
49 <p>
ace55ed HTML instead of XHTML
jakubvrana authored
50 <input type="hidden" name="token" value="<?php echo $token; ?>">
51 <input type="submit" value="<?php echo lang('Save'); ?>">
52 <?php if (strlen($_GET["event"])) { ?><input type="submit" name="drop" value="<?php echo lang('Drop'); ?>"<?php echo $confirm; ?>><?php } ?>
ff97ef9 Events (MySQL 5.1)
jakubvrana authored
53 </form>
Something went wrong with that request. Please try again.