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