]> git.joonet.de Git - adminer.git/commitdiff
Define functions unconditionally
authorjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Wed, 9 Sep 2009 11:03:03 +0000 (11:03 +0000)
committerjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Wed, 9 Sep 2009 11:03:03 +0000 (11:03 +0000)
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1075 7c3ca157-0c34-0410-bff1-cbf682f78f5c

adminer/dump.inc.php
adminer/include/adminer.inc.php
adminer/include/bootstrap.inc.php
adminer/include/editing.inc.php
adminer/include/export.inc.php
adminer/user.inc.php
changes.txt
editor/include/adminer.inc.php

index 40cc8816522f0cb2a1ea439817e6a3f29a045001..89eca2c9634ab5a75a39d6fdf288f9db81d31a27 100644 (file)
@@ -1,31 +1,6 @@
 <?php
 $TABLE = $_GET["dump"];
 
-function tar_file($filename, $contents) {
-       $return = pack("a100a8a8a8a12a12", $filename, 644, 0, 0, decoct(strlen($contents)), decoct(time()));
-       $checksum = 8*32; // space for checksum itself
-       for ($i=0; $i < strlen($return); $i++) {
-               $checksum += ord($return{$i});
-       }
-       $return .= sprintf("%06o", $checksum) . "\0 ";
-       return $return . str_repeat("\0", 512 - strlen($return)) . $contents . str_repeat("\0", 511 - (strlen($contents) + 511) % 512);
-}
-
-function dump_triggers($table, $style) {
-       global $dbh;
-       if ($_POST["format"] == "sql" && $style && $dbh->server_info >= 5) {
-               $result = $dbh->query("SHOW TRIGGERS LIKE " . $dbh->quote(addcslashes($table, "%_")));
-               if ($result->num_rows) {
-                       $s = "\nDELIMITER ;;\n";
-                       while ($row = $result->fetch_assoc()) {
-                               $s .= "\n" . ($style == 'CREATE+ALTER' ? "DROP TRIGGER IF EXISTS " . idf_escape($row["Trigger"]) . ";;\n" : "")
-                               . "CREATE TRIGGER " . idf_escape($row["Trigger"]) . " $row[Timing] $row[Event] ON " . idf_escape($row["Table"]) . " FOR EACH ROW\n$row[Statement];;\n";
-                       }
-                       dump("$s\nDELIMITER ;\n");
-               }
-       }
-}
-
 if ($_POST) {
        $ext = dump_headers((strlen($TABLE) ? $TABLE : DB), (!strlen(DB) || count((array) $_POST["tables"] + (array) $_POST["data"]) > 1));
        if ($_POST["format"] == "sql") {
index bcc5feeda0971647bc4979b7d8a37bad9ef296ab..905a572110bd18524dd64313dc683e13fed78fdd 100644 (file)
@@ -457,3 +457,5 @@ class Adminer {
        }
        
 }
+
+$adminer = (function_exists('adminer_object') ? adminer_object() : new Adminer);
index 8a100d928abe9b02880a6f3bc7e5c077109b40f0..94a1dec0a1a9eb26676c31d3f002c7a3f1c15938 100644 (file)
@@ -82,7 +82,6 @@ include "../adminer/include/functions.inc.php";
 include "../adminer/include/lang.inc.php";
 include "../adminer/lang/$LANG.inc.php";
 include "./include/adminer.inc.php";
-$adminer = (function_exists('adminer_object') ? adminer_object() : new Adminer);
 include "../adminer/include/design.inc.php";
 include "../adminer/include/pdo.inc.php";
 include "../adminer/include/mysql.inc.php";
index 786cc2a2e33864aa93371fda97a4e24e02493bf6..d06d7327403d6cda888fb1f26259eac6947405e2 100644 (file)
@@ -20,7 +20,7 @@ function referencable_primary($self) {
 function edit_type($key, $field, $collations, $foreign_keys = array()) {
        global $structured_types, $unsigned, $inout;
        ?>
-<td><select name="<?php echo $key; ?>[type]" onchange="editing_type_change(this);"><?php echo optionlist($structured_types + ($foreign_keys ? array(lang('Foreign keys') => $foreign_keys) : array()), $field["type"]); ?></select>
+<td><select name="<?php echo $key; ?>[type]" onchange="editing_type_change(this);"><?php echo optionlist($structured_types + ($foreign_keys ? array(lang('Foreign keys') => $foreign_keys) : array()), $field["type"]); // foreign keys can be wide but style="width: 15ex;" narrows expanded optionlist in IE too ?></select>
 <td><input name="<?php echo $key; ?>[length]" value="<?php echo h($field["length"]); ?>" size="3">
 <td><?php
 echo "<select name='$key" . "[collation]'" . (ereg('(char|text|enum|set)$', $field["type"]) ? "" : " class='hidden'") . '><option value="">(' . lang('collation') . ')' . optionlist($collations, $field["collation"]) . '</select>';
@@ -171,3 +171,17 @@ function routine($name, $type) {
        $returns = array("type" => $match[10], "length" => $match[11], "unsigned" => $match[13], "collation" => $match[14]);
        return array("fields" => $fields, "returns" => $returns, "definition" => $match[15]);
 }
+
+function grant($grant, $privileges, $columns, $on) {
+       if (!$privileges) {
+               return true;
+       }
+       if ($privileges == array("ALL PRIVILEGES", "GRANT OPTION")) {
+               // can't be granted or revoked together
+               return ($grant == "GRANT"
+                       ? queries("$grant ALL PRIVILEGES$on WITH GRANT OPTION")
+                       : queries("$grant ALL PRIVILEGES$on") && queries("$grant GRANT OPTION$on")
+               );
+       }
+       return queries("$grant " . preg_replace('~(GRANT OPTION)\\([^)]*\\)~', '\\1', implode("$columns, ", $privileges) . $columns) . $on);
+}
index 6f2d68d44d60af3341f535c9a5194875b80d6aa9..c02122dd74023039cee79aad28c0828e15bde8bc 100644 (file)
@@ -1,4 +1,29 @@
 <?php
+function tar_file($filename, $contents) {
+       $return = pack("a100a8a8a8a12a12", $filename, 644, 0, 0, decoct(strlen($contents)), decoct(time()));
+       $checksum = 8*32; // space for checksum itself
+       for ($i=0; $i < strlen($return); $i++) {
+               $checksum += ord($return{$i});
+       }
+       $return .= sprintf("%06o", $checksum) . "\0 ";
+       return $return . str_repeat("\0", 512 - strlen($return)) . $contents . str_repeat("\0", 511 - (strlen($contents) + 511) % 512);
+}
+
+function dump_triggers($table, $style) {
+       global $dbh;
+       if ($_POST["format"] == "sql" && $style && $dbh->server_info >= 5) {
+               $result = $dbh->query("SHOW TRIGGERS LIKE " . $dbh->quote(addcslashes($table, "%_")));
+               if ($result->num_rows) {
+                       $s = "\nDELIMITER ;;\n";
+                       while ($row = $result->fetch_assoc()) {
+                               $s .= "\n" . ($style == 'CREATE+ALTER' ? "DROP TRIGGER IF EXISTS " . idf_escape($row["Trigger"]) . ";;\n" : "")
+                               . "CREATE TRIGGER " . idf_escape($row["Trigger"]) . " $row[Timing] $row[Event] ON " . idf_escape($row["Table"]) . " FOR EACH ROW\n$row[Statement];;\n";
+                       }
+                       dump("$s\nDELIMITER ;\n");
+               }
+       }
+}
+
 function dump_table($table, $style, $is_view = false) {
        global $dbh;
        if ($_POST["format"] == "csv") {
index e663030737cb3ae8d2b3eea4ecdcd0d6a239a620..4a17848feef14b3b1c2d58eb7a7a2b7cdc1fed3c 100644 (file)
@@ -19,20 +19,6 @@ foreach ($privileges["Tables"] as $key => $val) {
        unset($privileges["Databases"][$key]);
 }
 
-function grant($grant, $privileges, $columns, $on) {
-       if (!$privileges) {
-               return true;
-       }
-       if ($privileges == array("ALL PRIVILEGES", "GRANT OPTION")) {
-               // can't be granted or revoked together
-               return ($grant == "GRANT"
-                       ? queries("$grant ALL PRIVILEGES$on WITH GRANT OPTION")
-                       : queries("$grant ALL PRIVILEGES$on") && queries("$grant GRANT OPTION$on")
-               );
-       }
-       return queries("$grant " . preg_replace('~(GRANT OPTION)\\([^)]*\\)~', '\\1', implode("$columns, ", $privileges) . $columns) . $on);
-}
-
 $new_grants = array();
 if ($_POST) {
        foreach ($_POST["objects"] as $key => $val) {
index 4aee407e29c18edd400af59878094af6014b11a9..781dfe7f65337d2f50ff4c068499a40c65ab4b0a 100644 (file)
@@ -5,6 +5,7 @@ Compress export and import
 Display column comments in table overview
 Use ON DUPLICATE KEY UPDATE for CSV import
 Click on row selects it
+Print ALTER export instead of executing it
 Fix Editor date format
 Fix long SQL query crash (bug #2839231)
 Traditional Chinese translation
index 10105a35a2d141de20225dfc501e9dce1c1c3652..05604acb53a59977d25a8ca1c5681a131c998c11 100644 (file)
@@ -355,3 +355,5 @@ ORDER BY ORDINAL_POSITION"); //! requires MySQL 5
        }
        
 }
+
+$adminer = (function_exists('adminer_object') ? adminer_object() : new Adminer);