]> git.joonet.de Git - adminer.git/commitdiff
Events (MySQL 5.1)
authorjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Mon, 1 Sep 2008 16:49:38 +0000 (16:49 +0000)
committerjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Mon, 1 Sep 2008 16:49:38 +0000 (16:49 +0000)
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@473 7c3ca157-0c34-0410-bff1-cbf682f78f5c

design.inc.php
dump.inc.php
event.inc.php [new file with mode: 0644]
index.php
lang/cs.inc.php

index e0b3da840a9af64491fda28ec0d35c06a8ab182b..a87f49f62d5852b1dd76d096108b15ead6e679a4 100644 (file)
@@ -9,7 +9,7 @@ function page_header($title, $error = "", $breadcrumb = array(), $title2 = "") {
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <meta http-equiv="Content-Script-Type" content="text/javascript" />
 <meta name="robots" content="noindex" />
-<title><?php echo $title . (strlen($title2) ? ": " . htmlspecialchars($title2) : "") . " - " . lang('phpMinAdmin') . " 1.7.1-dev"; ?></title>
+<title><?php echo $title . (strlen($title2) ? ": " . htmlspecialchars($title2) : "") . " - " . lang('phpMinAdmin') . " 1.8.0-dev"; ?></title>
 <link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
 <link rel="stylesheet" type="text/css" href="default.css" /><?php // Ondrej Valka, http://valka.info ?>
 </head>
index 2ca198b717502561d1e7c9fef5c175d9235a2d3b..6c01169015068ad3b6bb075fa94a90ee7de839ac 100644 (file)
@@ -33,21 +33,24 @@ if ($_POST) {
                        }
                        if ($style && $_POST["format"] != "csv") {
                                echo "USE " . idf_escape($db) . ";\n\n";
+                               $out = "";
                                if ($mysql->server_info >= 5) {
-                                       $out = "";
                                        foreach (array("FUNCTION", "PROCEDURE") as $routine) {
                                                $result = $mysql->query("SHOW $routine STATUS WHERE Db = '" . $mysql->escape_string($db) . "'");
                                                while ($row = $result->fetch_assoc()) {
-                                                       if (!$out) {
-                                                               echo "DELIMITER ;;\n\n";
-                                                               $out = "DELIMITER ;\n\n";
-                                                       }
-                                                       echo $mysql->result($mysql->query("SHOW CREATE $routine " . idf_escape($row["Name"])), 2) . ";;\n\n";
+                                                       $out .= $mysql->result($mysql->query("SHOW CREATE $routine " . idf_escape($row["Name"])), 2) . ";;\n\n";
                                                }
                                                $result->free();
                                        }
-                                       echo $out;
                                }
+                               if ($mysql->server_info >= 5.1) {
+                                       $result = $mysql->query("SHOW EVENTS");
+                                       while ($row = $result->fetch_assoc()) {
+                                               $out .= $mysql->result($mysql->query("SHOW CREATE EVENT " . idf_escape($row["Name"])), 1) . ";;\n\n";
+                                       }
+                                       $result->free();
+                               }
+                               echo ($out ? "DELIMITER ;;\n\n$out" . "DELIMITER ;\n\n" : "");
                        }
                        
                        if (($style || strlen($_GET["db"])) && (array_filter($_POST["tables"]) || array_filter($_POST["data"]))) {
diff --git a/event.inc.php b/event.inc.php
new file mode 100644 (file)
index 0000000..ba443ab
--- /dev/null
@@ -0,0 +1,41 @@
+<?php
+$intervals = array("YEAR", "QUARTER", "MONTH", "DAY", "HOUR", "MINUTE", "WEEK", "SECOND", "YEAR_MONTH", "DAY_HOUR", "DAY_MINUTE", "DAY_SECOND", "HOUR_MINUTE", "HOUR_SECOND", "MINUTE_SECOND");
+
+if ($_POST && !$error) {
+       if ($_POST["drop"]) {
+               if ($mysql->query("DROP EVENT " . idf_escape($_GET["event"]))) {
+                       redirect(substr($SELF, 0, -1), lang('Event has been dropped.'));
+               }
+       } elseif (in_array($_POST["INTERVAL_FIELD"], $intervals)) {
+               $schedule = " ON SCHEDULE " . ($_POST["INTERVAL_VALUE"] ? "EVERY '" . $mysql->escape_string($_POST["INTERVAL_VALUE"]) . "' $_POST[INTERVAL_FIELD]" : "AT '" . $mysql->escape_string($_POST["EXECUTE_AT"]) . "'");
+               if ($mysql->query((strlen($_GET["event"]) ? "ALTER EVENT " . idf_escape($_GET["event"]) . $schedule . ($_GET["event"] != $_POST["EVENT_NAME"] ? " RENAME TO " . idf_escape($_POST["EVENT_NAME"]) : "") : "CREATE EVENT " . idf_escape($_POST["EVENT_NAME"]) . $schedule) . " DO $_POST[EVENT_DEFINITION]")) {
+                       redirect(substr($SELF, 0, -1), (strlen($_GET["event"]) ? lang('Event has been altered.') : lang('Event has been created.')));
+               }
+       }
+       $error = $mysql->error;
+}
+page_header((strlen($_GET["event"]) ? lang('Alter event') . ": " . htmlspecialchars($_GET["event"]) : lang('Create event')), $error);
+
+$row = array();
+if ($_POST) {
+       $row = $_POST;
+} elseif (strlen($_GET["event"])) {
+       $result = $mysql->query("SELECT * FROM information_schema.EVENTS WHERE EVENT_SCHEMA = '" . $mysql->escape_string($_GET["db"]) . "' AND EVENT_NAME = '" . $mysql->escape_string($_GET["event"]) . "'");
+       $row = $result->fetch_assoc();
+       $result->free();
+}
+?>
+
+<form action="" method="post">
+<table border="0" cellspacing="0" cellpadding="2">
+<tr><th><?php echo lang('Name'); ?></th><td><input name="EVENT_NAME" value="<?php echo htmlspecialchars($row["EVENT_NAME"]); ?>" maxlength="64" /></td></tr>
+<tr><th><?php echo lang('At given time'); ?></th><td><input name="EXECUTE_AT" value="<?php echo htmlspecialchars($row["EXECUTE_AT"]); ?>" /></td></tr>
+<tr><th><?php echo lang('Every'); ?></th><td><input name="INTERVAL_VALUE" value="<?php echo htmlspecialchars($row["INTERVAL_VALUE"]); ?>" /> <select name="INTERVAL_FIELD"><?php echo optionlist($intervals, $row["INTERVAL_FIELD"]); ?></select></td></tr>
+</table>
+<p><textarea name="EVENT_DEFINITION" rows="10" cols="80" style="width: 98%;"><?php echo htmlspecialchars($row["EVENT_DEFINITION"]); ?></textarea></p>
+<p>
+<input type="hidden" name="token" value="<?php echo $token; ?>" />
+<input type="submit" value="<?php echo lang('Save'); ?>" />
+<?php if (strlen($_GET["event"])) { ?><input type="submit" name="drop" value="<?php echo lang('Drop'); ?>" onclick="return confirm('<?php echo lang('Are you sure?'); ?>');" /><?php } ?>
+</p>
+</form>
index d8aef432e3d075b06c9c3d34de414122bea4fe09..e28b7cffd93db131d7c4a719ce65eca77cffccca 100644 (file)
--- a/index.php
+++ b/index.php
@@ -105,6 +105,8 @@ if (isset($_GET["download"])) {
                        include "./foreign.inc.php";
                } elseif (isset($_GET["createv"])) {
                        include "./createv.inc.php";
+               } elseif (isset($_GET["event"])) {
+                       include "./event.inc.php";
                } elseif (isset($_GET["procedure"])) {
                        include "./procedure.inc.php";
                } elseif (isset($_GET["trigger"])) {
@@ -138,6 +140,24 @@ if (isset($_GET["download"])) {
                                $result->free();
                                echo '<p><a href="' . htmlspecialchars($SELF) . 'procedure=">' . lang('Create procedure') . '</a> <a href="' . htmlspecialchars($SELF) . 'function=">' . lang('Create function') . "</a></p>\n";
                        }
+                       if ($mysql->server_info >= 5.1) {
+                               echo "<h3>" . lang('Events') . "</h3>\n";
+                               $result = $mysql->query("SHOW EVENTS");
+                               if ($result->num_rows) {
+                                       echo "<table border='0' cellspacing='0' cellpadding='2'>\n";
+                                       echo "<thead><tr><th>" . lang('Name') . "</th><td>" . lang('Schedule') . "</td><td>" . lang('Start') . "</td><td>" . lang('End') . "</td></tr></thead>\n";
+                                       while ($row = $result->fetch_assoc()) {
+                                               echo "<tr>";
+                                               echo '<th><a href="' . htmlspecialchars($SELF) . 'event=' . urlencode($row["Name"]) . '">' . htmlspecialchars($row["Name"]) . "</a></th>";
+                                               echo "<td>" . ($row["Execute at"] ? lang('At given time') . "</td><td>" . $row["Execute at"] : lang('Every') . " " . $row["Interval value"] . " " . $row["Interval field"] . "</td><td>$row[Starts]") . "</td>";
+                                               echo "<td>$row[Ends]</td>";
+                                               echo "</tr>\n";
+                                       }
+                                       echo "</table>\n";
+                               }
+                               $result->free();
+                               echo '<p><a href="' . htmlspecialchars($SELF) . 'event=">' . lang('Create event') . "</a></p>\n";
+                       }
                }
        }
        page_footer();
index 68fbdd5e3571a3c3078772e41b0543dc14dada0b..b7ac0a62262e305c50a772655745c7d9a7a8c253 100644 (file)
@@ -174,4 +174,15 @@ $translations = array(
        'Data' => 'Data',
        'Export selected' => 'Exportovat označené',
        'Export result' => 'Exportovat výsledek',
+       'Event has been dropped.' => 'Událost byla odstraněna.',
+       'Event has been altered.' => 'Událost byla změněna.',
+       'Event has been created.' => 'Událost byla vytvořena.',
+       'Alter event' => 'Pozměnit událost',
+       'Create event' => 'Vytvořit událost',
+       'At given time' => 'V daný čas',
+       'Every' => 'Každých',
+       'Events' => 'Události',
+       'Schedule' => 'Plán',
+       'Start' => 'Začátek',
+       'End' => 'Konec',
 );