Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 54 lines (49 sloc) 3.354 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"]
64d616c Rename get_dbh to connection
jakubvrana authored
11 ? "EVERY " . $connection->quote($_POST["INTERVAL_VALUE"]) . " $_POST[INTERVAL_FIELD]"
12 . ($_POST["STARTS"] ? " STARTS " . $connection->quote($_POST["STARTS"]) : "")
13 . ($_POST["ENDS"] ? " ENDS " . $connection->quote($_POST["ENDS"]) : "") //! ALTER EVENT doesn't drop ENDS - MySQL bug #39173
14 : "AT " . $connection->quote($_POST["STARTS"])
c463946 Event status, comment and preserve
jakubvrana authored
15 ) . " ON COMPLETION" . ($_POST["ON_COMPLETION"] ? "" : " NOT") . " PRESERVE"
16 ;
7352c28 Replace strlen() by != ""
jakubvrana authored
17 query_redirect(($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
64d616c Rename get_dbh to connection
jakubvrana authored
21 ) . "\n" . $statuses[$_POST["STATUS"]] . " COMMENT " . $connection->quote($_POST["EVENT_COMMENT"])
36a3656 Change escape_string to quote
jakubvrana authored
22 . " DO\n$_POST[EVENT_DEFINITION]"
7352c28 Replace strlen() by != ""
jakubvrana authored
23 , substr(ME, 0, -1), ($EVENT != "" ? lang('Event has been altered.') : lang('Event has been created.')));
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 != "") {
64d616c Rename get_dbh to connection
jakubvrana authored
33 $result = $connection->query("SELECT * FROM information_schema.EVENTS WHERE EVENT_SCHEMA = " . $connection->quote(DB) . " AND EVENT_NAME = " . $connection->quote($EVENT));
ff97ef9 Events (MySQL 5.1)
jakubvrana authored
34 $row = $result->fetch_assoc();
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>
689699a Shortcut for htmlspecialchars
jakubvrana authored
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
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'); ?>">
7352c28 Replace strlen() by != ""
jakubvrana authored
52 <?php if ($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.