]> git.joonet.de Git - adminer.git/commitdiff
fix logger for SQL commands
authorMathieu Rochette <mathieu.rochette@prelinker.com>
Wed, 11 Mar 2015 16:52:11 +0000 (17:52 +0100)
committerJakub Vrana <jakub@vrana.cz>
Sun, 19 Feb 2017 10:00:07 +0000 (11:00 +0100)
adminer/include/adminer.inc.php
adminer/sql.inc.php
plugins/plugin.php
plugins/sql-log.php

index 3028e7d5c476f9020bdc1891cd51e041c93b2c46..c6ceedd786c27509de2b9e9f6b29e1b731a88a0b 100644 (file)
@@ -197,6 +197,15 @@ focus(document.getElementById('username'));
                ;
        }
 
+       /** Query printed in SQL command before execution
+       * @param string query to be executed
+       * @return string escaped query to be printed
+       */
+       function sqlCommandQuery($query)
+       {
+               return shorten_utf8(trim($query), 1000);
+       }
+
        /** Description of a row in a table
        * @param string
        * @return string SQL expression, empty string for no description
index fbecbfb2268ff69d333a03d72804d2ba3d3f174f..296cfc56e6894e4a4b4daa42561d9d8d2cb2cd19 100644 (file)
@@ -93,7 +93,7 @@ if (!$error && $_POST) {
                                                $empty = false;
                                                $q = substr($query, 0, $pos);
                                                $commands++;
-                                               $print = "<pre id='sql-$commands'><code class='jush-$jush'>" . shorten_utf8(trim($q), 1000) . "</code></pre>\n";
+                                               $print = "<pre id='sql-$commands'><code class='jush-$jush'>" . $adminer->sqlCommandQuery($q) . "</code></pre>\n";
                                                if ($jush == "sqlite" && preg_match("~^$space*+ATTACH\\b~i", $q, $match)) {
                                                        // PHP doesn't support setting SQLITE_LIMIT_ATTACHED
                                                        echo $print;
index aae72c35a4dbfc617bc1a0f61355f0293b52082c..de26f4dcf8060be9ad1bb477e418fe8f82cf20dc 100644 (file)
@@ -177,6 +177,11 @@ class AdminerPlugin extends Adminer {
                return $this->_applyPlugin(__FUNCTION__, $args);
        }
 
+       function sqlCommandQuery($query) {
+               $args = func_get_args();
+               return $this->_applyPlugin(__FUNCTION__, $args);
+       }
+
        function rowDescription($table) {
                $args = func_get_args();
                return $this->_applyPlugin(__FUNCTION__, $args);
index 2c5f2d5fbbfc9081b7123e87cf7463252bf58aab..757adc0d777dcd013809853784b32497c2f21dc3 100644 (file)
@@ -18,6 +18,14 @@ class AdminerSqlLog {
        }
        
        function messageQuery($query, $time) {
+               $this->_log($query);
+       }
+
+       function sqlCommandQuery($query) {
+               $this->_log($query);
+       }
+
+       function _log($query) {
                if ($this->filename == "") {
                        $adminer = adminer();
                        $this->filename = $adminer->database() . ".sql"; // no database goes to ".sql" to avoid collisions