]> git.joonet.de Git - adminer.git/commitdiff
Use namespaces in plugins
authorJakub Vrana <jakub@vrana.cz>
Wed, 5 Mar 2025 10:40:56 +0000 (11:40 +0100)
committerJakub Vrana <jakub@vrana.cz>
Wed, 5 Mar 2025 12:10:40 +0000 (13:10 +0100)
32 files changed:
editor/example.php
plugins/adminer.js.php
plugins/designs.php
plugins/dump-alter.php
plugins/dump-date.php
plugins/dump-json.php
plugins/dump-php.php
plugins/dump-xml.php
plugins/edit-calendar.php
plugins/edit-foreign.php
plugins/edit-textarea.php
plugins/email-table.php
plugins/enum-option.php
plugins/enum-types.php
plugins/file-upload.php
plugins/json-column.php
plugins/login-otp.php
plugins/login-password-less.php
plugins/login-servers.php
plugins/login-table.php
plugins/master-slave.php
plugins/plugin.php
plugins/slugify.php
plugins/sql-log.php
plugins/struct-comments.php
plugins/table-indexes-structure.php
plugins/table-structure.php
plugins/tables-filter.php
plugins/tinymce.php
plugins/translation.php
plugins/version-noverify.php
plugins/wymeditor.php

index 9874536dbc8e3c4cde114a1c71d6b176924d86fa..ce752ff67ecdfa2a34b974ff48efaa12a80aaa50 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 function adminer_object() {
 
-       class AdminerCds extends Adminer {
+       class AdminerCds extends Adminer\Adminer {
 
                function name() {
                        // custom name in title and heading
index ad346927f19c5c871c42665e460ac37e8e8b7915..7b7a427dcd70797c9e419c59677f9169c5fb3f90 100644 (file)
@@ -13,7 +13,7 @@ class AdminerDotJs {
 
        function head() {
                if (file_exists(self::FILENAME)) {
-                       echo script_src(self::FILENAME . "?v=" . crc32(file_get_contents(self::FILENAME))), "\n";
+                       echo Adminer\script_src(self::FILENAME . "?v=" . crc32(file_get_contents(self::FILENAME))), "\n";
                }
        }
 }
index 3cacf5aa067ff9193d85e6d892f7b0aa6d38a374..c4e66faa41362cc32c6e2dd7d1762b1bd3f7077e 100644 (file)
@@ -18,10 +18,10 @@ class AdminerDesigns {
        }
 
        function headers() {
-               if (isset($_POST["design"]) && verify_token()) {
-                       restart_session();
+               if (isset($_POST["design"]) && Adminer\verify_token()) {
+                       Adminer\restart_session();
                        $_SESSION["design"] = $_POST["design"];
-                       redirect($_SERVER["REQUEST_URI"]);
+                       Adminer\redirect($_SERVER["REQUEST_URI"]);
                }
        }
 
@@ -35,8 +35,8 @@ class AdminerDesigns {
 
        function navigation($missing) {
                echo "<form action='' method='post' style='position: fixed; bottom: .5em; right: .5em;'>";
-               echo html_select("design", array("" => "(design)") + $this->designs, $_SESSION["design"], "this.form.submit();");
-               echo '<input type="hidden" name="token" value="' . get_token() . '">';
+               echo Adminer\html_select("design", array("" => "(design)") + $this->designs, $_SESSION["design"], "this.form.submit();");
+               echo '<input type="hidden" name="token" value="' . Adminer\get_token() . '">';
                echo "</form>\n";
        }
 
index 65ecead67a3047fc0f21d9f3d61b3624206a4f6a..3ebdf8bade83a36897b03b72132a1545b17a6551 100644 (file)
@@ -29,10 +29,10 @@ CREATE PROCEDURE adminer_alter (INOUT alter_command text) BEGIN
                FETCH tables INTO _table_name, _engine, _table_collation, _table_comment;
                IF NOT done THEN
                        CASE _table_name";
-               foreach (get_rows($query) as $row) {
-                       $comment = q($row["ENGINE"] == "InnoDB" ? preg_replace('~(?:(.+); )?InnoDB free: .*~', '\1', $row["TABLE_COMMENT"]) : $row["TABLE_COMMENT"]);
+               foreach (Adminer\get_rows($query) as $row) {
+                       $comment = Adminer\q($row["ENGINE"] == "InnoDB" ? preg_replace('~(?:(.+); )?InnoDB free: .*~', '\1', $row["TABLE_COMMENT"]) : $row["TABLE_COMMENT"]);
                        echo "
-                       WHEN " . q($row["TABLE_NAME"]) . " THEN
+                       WHEN " . Adminer\q($row["TABLE_NAME"]) . " THEN
                                " . (isset($row["ENGINE"]) ? "IF _engine != '$row[ENGINE]' OR _table_collation != '$row[TABLE_COLLATION]' OR _table_comment != $comment THEN
                                        ALTER TABLE " . idf_escape($row["TABLE_NAME"]) . " ENGINE=$row[ENGINE] COLLATE=$row[TABLE_COLLATION] COMMENT=$comment;
                                END IF" : "BEGIN END") . ";";
@@ -75,7 +75,7 @@ SELECT @adminer_alter;
                        } else {
                                echo substr_replace($create, " IF NOT EXISTS", 12, 0) . ";\n\n";
                                // create procedure which iterates over original columns and adds new and removes old
-                               $query = "SELECT COLUMN_NAME, COLUMN_DEFAULT, IS_NULLABLE, COLLATION_NAME, COLUMN_TYPE, EXTRA, COLUMN_COMMENT FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = " . q($table) . " ORDER BY ORDINAL_POSITION";
+                               $query = "SELECT COLUMN_NAME, COLUMN_DEFAULT, IS_NULLABLE, COLLATION_NAME, COLUMN_TYPE, EXTRA, COLUMN_COMMENT FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = " . Adminer\q($table) . " ORDER BY ORDINAL_POSITION";
                                echo "DELIMITER ;;
 CREATE PROCEDURE adminer_alter (INOUT alter_command text) BEGIN
        DECLARE _column_name, _collation_name, after varchar(64) DEFAULT '';
@@ -87,17 +87,17 @@ CREATE PROCEDURE adminer_alter (INOUT alter_command text) BEGIN
        DECLARE add_columns text DEFAULT '";
                                $fields = array();
                                $after = "";
-                               foreach (get_rows($query) as $row) {
+                               foreach (Adminer\get_rows($query) as $row) {
                                        $default = $row["COLUMN_DEFAULT"];
-                                       $row["default"] = ($default !== null ? q($default) : "NULL");
-                                       $row["after"] = q($after); //! rgt AFTER lft, lft AFTER id doesn't work
-                                       $row["alter"] = escape_string(idf_escape($row["COLUMN_NAME"])
+                                       $row["default"] = ($default !== null ? Adminer\q($default) : "NULL");
+                                       $row["after"] = Adminer\q($after); //! rgt AFTER lft, lft AFTER id doesn't work
+                                       $row["alter"] = Adminer\escape_string(idf_escape($row["COLUMN_NAME"])
                                                . " $row[COLUMN_TYPE]"
                                                . ($row["COLLATION_NAME"] ? " COLLATE $row[COLLATION_NAME]" : "")
                                                . ($default !== null ? " DEFAULT " . ($default == "CURRENT_TIMESTAMP" ? $default : $row["default"]) : "")
                                                . ($row["IS_NULLABLE"] == "YES" ? "" : " NOT NULL")
                                                . ($row["EXTRA"] ? " $row[EXTRA]" : "")
-                                               . ($row["COLUMN_COMMENT"] ? " COMMENT " . q($row["COLUMN_COMMENT"]) : "")
+                                               . ($row["COLUMN_COMMENT"] ? " COMMENT " . Adminer\q($row["COLUMN_COMMENT"]) : "")
                                                . ($after ? " AFTER " . idf_escape($after) : " FIRST")
                                        );
                                        echo ", ADD $row[alter]";
@@ -116,14 +116,14 @@ CREATE PROCEDURE adminer_alter (INOUT alter_command text) BEGIN
                        CASE _column_name";
                                foreach ($fields as $row) {
                                        echo "
-                               WHEN " . q($row["COLUMN_NAME"]) . " THEN
+                               WHEN " . Adminer\q($row["COLUMN_NAME"]) . " THEN
                                        SET add_columns = REPLACE(add_columns, ', ADD $row[alter]', IF(
                                                _column_default <=> $row[default]
                                                AND _is_nullable = '$row[IS_NULLABLE]'
                                                AND _collation_name <=> " . (isset($row["COLLATION_NAME"]) ? "'$row[COLLATION_NAME]'" : "NULL") . "
-                                               AND _column_type = " . q($row["COLUMN_TYPE"]) . "
+                                               AND _column_type = " . Adminer\q($row["COLUMN_TYPE"]) . "
                                                AND _extra = '$row[EXTRA]'
-                                               AND _column_comment = " . q($row["COLUMN_COMMENT"]) . "
+                                               AND _column_comment = " . Adminer\q($row["COLUMN_COMMENT"]) . "
                                                AND after = $row[after]
                                        , '', ', MODIFY $row[alter]'));"; //! don't replace in comment
                                }
index a5cf3afb41d4b556b7df43dc412c9d7312e3a826..4c540af1cc956c7248aeac31f2b0b9ab27fff379 100644 (file)
@@ -9,8 +9,8 @@
 class AdminerDumpDate {
 
        function dumpFilename($identifier) {
-               $connection = connection();
-               return friendly_url(($identifier != "" ? $identifier : (SERVER != "" ? SERVER : "localhost")) . "-" . $connection->result("SELECT NOW()"));
+               $connection = Adminer\connection();
+               return Adminer\friendly_url(($identifier != "" ? $identifier : (SERVER != "" ? SERVER : "localhost")) . "-" . $connection->result("SELECT NOW()"));
        }
 
 }
index 35316a6f78c1642eae390fca518c8b1b1f6cc077..127a1c2ecd989fb1f19a4fca24672d3165f67bb6 100644 (file)
@@ -33,7 +33,7 @@ class AdminerDumpJson {
                                echo "{\n";
                                register_shutdown_function(array($this, '_database'));
                        }
-                       $connection = connection();
+                       $connection = Adminer\connection();
                        $result = $connection->query($query, 1);
                        if ($result) {
                                echo '"' . addcslashes($table, "\r\n\"\\") . "\": [\n";
@@ -42,9 +42,9 @@ class AdminerDumpJson {
                                        echo ($first ? "" : ", ");
                                        $first = false;
                                        foreach ($row as $key => $val) {
-                                               json_row($key, $val);
+                                               Adminer\json_row($key, $val);
                                        }
-                                       json_row("");
+                                       Adminer\json_row("");
                                }
                                echo "]";
                        }
index 1c13fabf093951e96e3f3fc1f0d29d4d2bdd4b2a..e0ef30fa7da549f5f09a565299e946b28b28e02c 100644 (file)
@@ -33,7 +33,7 @@ class AdminerDumpPhp {
 
        function dumpData($table, $style, $query) {
                if ($_POST['format'] == 'php') {
-                       $connection = connection();
+                       $connection = Adminer\connection();
                        $result = $connection->query($query, 1);
                        if ($result) {
                                while ($row = $result->fetch_assoc()) {
index cd07a3ac538f5ae091c50d901d0cfc3cf718df69..da2d69399ae852e971bfc5a63f5802b74826ae59 100644 (file)
@@ -28,16 +28,16 @@ class AdminerDumpXml {
                if ($_POST["format"] == "xml") {
                        if (!$this->database) {
                                $this->database = true;
-                               echo "<database name='" . h(DB) . "'>\n";
+                               echo "<database name='" . Adminer\h(DB) . "'>\n";
                                register_shutdown_function(array($this, '_database'));
                        }
-                       $connection = connection();
+                       $connection = Adminer\connection();
                        $result = $connection->query($query, 1);
                        if ($result) {
                                while ($row = $result->fetch_assoc()) {
-                                       echo "\t<table name='" . h($table) . "'>\n";
+                                       echo "\t<table name='" . Adminer\h($table) . "'>\n";
                                        foreach ($row as $key => $val) {
-                                               echo "\t\t<column name='" . h($key) . "'" . (isset($val) ? "" : " null='null'") . ">" . h($val) . "</column>\n";
+                                               echo "\t\t<column name='" . Adminer\h($key) . "'" . (isset($val) ? "" : " null='null'") . ">" . Adminer\h($val) . "</column>\n";
                                        }
                                        echo "\t</table>\n";
                                }
index 1e7574128a085d8e8d963f329e12075d484d57e3..789014382d58eb0479b0b5a86a46f7cef01498a4 100644 (file)
@@ -19,9 +19,9 @@ class AdminerEditCalendar {
        function __construct($prepend = null, $langPath = "jquery-ui/i18n/jquery.ui.datepicker-%s.js") {
                if ($prepend === null) {
                        $prepend = "<link rel='stylesheet' type='text/css' href='jquery-ui/jquery-ui.css'>\n"
-                               . script_src("jquery-ui/jquery.js")
-                               . script_src("jquery-ui/jquery-ui.js")
-                               . script_src("jquery-ui/jquery-ui-timepicker-addon.js")
+                               . Adminer\script_src("jquery-ui/jquery.js")
+                               . Adminer\script_src("jquery-ui/jquery-ui.js")
+                               . Adminer\script_src("jquery-ui/jquery-ui-timepicker-addon.js")
                        ;
                }
                $this->prepend = $prepend;
@@ -31,11 +31,11 @@ class AdminerEditCalendar {
        function head() {
                echo $this->prepend;
                if ($this->langPath) {
-                       $lang = get_lang();
+                       $lang = Adminer\get_lang();
                        $lang = ($lang == "zh" ? "zh-CN" : ($lang == "zh-tw" ? "zh-TW" : $lang));
                        if ($lang != "en" && file_exists(sprintf($this->langPath, $lang))) {
-                               echo script_src(sprintf($this->langPath, $lang));
-                               echo script("jQuery(function () { jQuery.timepicker.setDefaults(jQuery.datepicker.regional['$lang']); });");
+                               echo Adminer\script_src(sprintf($this->langPath, $lang));
+                               echo Adminer\script("jQuery(function () { jQuery.timepicker.setDefaults(jQuery.datepicker.regional['$lang']); });");
                        }
                }
        }
@@ -44,8 +44,8 @@ class AdminerEditCalendar {
                if (preg_match("~date|time~", $field["type"])) {
                        $dateFormat = "changeYear: true, dateFormat: 'yy-mm-dd'"; //! yy-mm-dd regional
                        $timeFormat = "showSecond: true, timeFormat: 'HH:mm:ss', timeInput: true";
-                       return "<input id='fields-" . h($field["field"]) . "' value='" . h($value) . "'" . (@+$field["length"] ? " data-maxlength='" . (+$field["length"]) . "'" : "") . "$attrs>" . script(
-                               "jQuery('#fields-" . js_escape($field["field"]) . "')."
+                       return "<input id='fields-" . Adminer\h($field["field"]) . "' value='" . Adminer\h($value) . "'" . (@+$field["length"] ? " data-maxlength='" . (+$field["length"]) . "'" : "") . "$attrs>" . Adminer\script(
+                               "jQuery('#fields-" . Adminer\js_escape($field["field"]) . "')."
                                . ($field["type"] == "time" ? "timepicker({ $timeFormat })"
                                        : (preg_match("~time~", $field["type"]) ? "datetimepicker({ $dateFormat, $timeFormat })"
                                                : "datepicker({ $dateFormat })"
index 365cb7be87380cbfcf0c5a1009a69d5327d96f3f..90655bacd749ed3a90d60d77842485cd33b1390f 100644 (file)
@@ -18,7 +18,7 @@ class AdminerEditForeign {
                static $values = array();
                $foreignKeys = &$foreignTables[$table];
                if ($foreignKeys === null) {
-                       $foreignKeys = column_foreign_keys($table);
+                       $foreignKeys = Adminer\column_foreign_keys($table);
                }
                foreach ((array) $foreignKeys[$field["field"]] as $foreignKey) {
                        if (count($foreignKey["source"]) == 1) {
@@ -30,12 +30,12 @@ class AdminerEditForeign {
                                        if (preg_match('~binary~', $field["type"])) {
                                                $column = "HEX($column)";
                                        }
-                                       $options = array("" => "") + get_vals("SELECT $column FROM " . table($target) . " ORDER BY 1" . ($this->_limit ? " LIMIT " . ($this->_limit + 1) : ""));
+                                       $options = array("" => "") + Adminer\get_vals("SELECT $column FROM " . table($target) . " ORDER BY 1" . ($this->_limit ? " LIMIT " . ($this->_limit + 1) : ""));
                                        if ($this->_limit && count($options) - 1 > $this->_limit) {
                                                return;
                                        }
                                }
-                               return "<select$attrs>" . optionlist($options, $value) . "</select>";
+                               return "<select$attrs>" . Adminer\optionlist($options, $value) . "</select>";
                        }
                }
        }
index 5dbe31e603258a9b959cc06c38d32ca0f84d4e4c..45aa11f9b482cda889e91a342aaf46760860f028 100644 (file)
@@ -10,7 +10,7 @@ class AdminerEditTextarea {
 
        function editInput($table, $field, $attrs, $value) {
                if (preg_match('~char~', $field["type"])) {
-                       return "<textarea cols='30' rows='1' style='height: 1.2em;'$attrs>" . h($value) . '</textarea>';
+                       return "<textarea cols='30' rows='1' style='height: 1.2em;'$attrs>" . Adminer\h($value) . '</textarea>';
                }
        }
 
index 1f1459573df75cd18d3b97eccaf6fae651ca1b81..f6f2590644efa1708b2017cd0f1df1b369ec7d5f 100644 (file)
@@ -27,20 +27,20 @@ class AdminerEmailTable {
 
        function selectEmailPrint($emailFields, $columns) {
                if ($emailFields) {
-                       print_fieldset("email", ('E-mail'));
+                       Adminer\print_fieldset("email", ('E-mail'));
                        echo "<div>\n";
-                       echo script("qsl('div').onkeydown = partial(bodyKeydown, 'email');");
-                       echo "<p>" . ('From') . ": <input name='email_from' value='" . h($_POST ? $_POST["email_from"] : $_COOKIE["adminer_email"]) . "'>\n";
-                       echo ('Subject') . ": <select name='email_id'><option>" . optionlist(get_key_vals("SELECT $this->id, $this->title FROM $this->table ORDER BY $this->title"), $_POST["email_id"], true) . "</select>\n";
+                       echo Adminer\script("qsl('div').onkeydown = partial(bodyKeydown, 'email');");
+                       echo "<p>" . ('From') . ": <input name='email_from' value='" . Adminer\h($_POST ? $_POST["email_from"] : $_COOKIE["adminer_email"]) . "'>\n";
+                       echo ('Subject') . ": <select name='email_id'><option>" . Adminer\optionlist(Adminer\get_key_vals("SELECT $this->id, $this->title FROM $this->table ORDER BY $this->title"), $_POST["email_id"], true) . "</select>\n";
                        echo "<p>" . ('Attachments') . ": <input type='file' name='email_files[]'>";
-                       echo script("qsl('input').onchange = function () {
+                       echo Adminer\script("qsl('input').onchange = function () {
        this.onchange = function () { };
        var el = this.cloneNode(true);
        el.value = '';
        this.parentNode.appendChild(el);
 };");
-                       echo "<p>" . (count($emailFields) == 1 ? '<input type="hidden" name="email_field" value="' . h(key($emailFields)) . '">' : html_select("email_field", $emailFields));
-                       echo "<input type='submit' name='email' value='" . ('Send') . "'>" . confirm();
+                       echo "<p>" . (count($emailFields) == 1 ? '<input type="hidden" name="email_field" value="' . Adminer\h(key($emailFields)) . '">' : Adminer\html_select("email_field", $emailFields));
+                       echo "<input type='submit' name='email' value='" . ('Send') . "'>" . Adminer\confirm();
                        echo "</div>\n";
                        echo "</div></fieldset>\n";
                        return true;
@@ -48,9 +48,9 @@ class AdminerEmailTable {
        }
 
        function selectEmailProcess($where, $foreignKeys) {
-               $connection = connection();
+               $connection = Adminer\connection();
                if ($_POST["email_id"]) {
-                       $result = $connection->query("SELECT $this->subject, $this->message FROM $this->table WHERE $this->id = " . q($_POST["email_id"]));
+                       $result = $connection->query("SELECT $this->subject, $this->message FROM $this->table WHERE $this->id = " . Adminer\q($_POST["email_id"]));
                        $row = $result->fetch_row();
                        $_POST["email_subject"] = $row[0];
                        $_POST["email_message"] = $row[1];
index bcede82600e6438d977806a644e49453f11d8cd1..65917ff1b8f6fde023ac81cdbe773e1b0efa17cf 100644 (file)
@@ -13,7 +13,7 @@ class AdminerEnumOption {
                        $options = array();
                        $selected = $value;
                        if (isset($_GET["select"])) {
-                               $options[-1] = lang('original');
+                               $options[-1] = Adminer\lang('original');
                                if ($selected === null) {
                                        $selected = -1;
                                }
@@ -24,7 +24,7 @@ class AdminerEnumOption {
                                        $selected = "";
                                }
                        }
-                       $options[0] = lang('empty');
+                       $options[0] = Adminer\lang('empty');
                        preg_match_all("~'((?:[^']|'')*)'~", $field["length"], $matches);
                        foreach ($matches[1] as $i => $val) {
                                $val = stripcslashes(str_replace("''", "'", $val));
@@ -33,7 +33,7 @@ class AdminerEnumOption {
                                        $selected = $i + 1;
                                }
                        }
-                       return "<select$attrs>" . optionlist($options, (string) $selected, 1) . "</select>"; // 1 - use keys
+                       return "<select$attrs>" . Adminer\optionlist($options, (string) $selected, 1) . "</select>"; // 1 - use keys
                }
        }
 
index 15a8fc2496716e87301a595b1e3c7819caf87c25..0a72ef8dbae1c69c0c7aff0f00ea6f92261fd4ad 100644 (file)
@@ -11,7 +11,7 @@ class AdminerEnumTypes {
 
        function editInput($table, $field, $attrs, $value) {
                // PostgreSQL only
-               if (!in_array(strtolower(connection()->extension), array('pgsql', 'pdo_pgsql'))) {
+               if (!in_array(strtolower(Adminer\connection()->extension), array('pgsql', 'pdo_pgsql'))) {
                        return;
                }
 
@@ -21,7 +21,7 @@ class AdminerEnumTypes {
                        $this->_types = array();
 
                        foreach ($types as $type) {
-                               $values = get_vals("SELECT unnest(enum_range(NULL::$type))::text AS value");
+                               $values = Adminer\get_vals("SELECT unnest(enum_range(NULL::$type))::text AS value");
                                if (!empty($values) && is_array($values)) {
                                        $this->_types[$type] = $values;
                                }
@@ -40,10 +40,10 @@ class AdminerEnumTypes {
                                }
                        }
                        if (isset($_GET["select"])) {
-                               $options = array("" => array(-1 => lang('original'))) + $options;
+                               $options = array("" => array(-1 => Adminer\lang('original'))) + $options;
                        }
 
-                       return "<select$attrs>" . optionlist($options, (string) $selected, 1) . "</select>";
+                       return "<select$attrs>" . Adminer\optionlist($options, (string) $selected, 1) . "</select>";
                }
        }
 
index 6c40f624dca019da020566286e2ec4699c22811b..e1a2b17b61da93c87d466dc9f81d9b7fcf247892 100644 (file)
@@ -40,7 +40,7 @@ class AdminerFileUpload {
                        if (!move_uploaded_file($_FILES[$name]["tmp_name"], "$this->uploadPath$table/$regs[1]-$filename")) {
                                return false;
                        }
-                       return q($filename);
+                       return Adminer\q($filename);
                }
        }
 
index d0af98bbf89b039cd73a5e31732856c43b43b4b2..4d145fcb16e34486769b4b8b47f3ba0193cd9043 100644 (file)
@@ -19,7 +19,7 @@ class AdminerJsonColumn {
                echo '<table style="margin:2px; font-size:100%;">';
                foreach ($json as $key => $val) {
                        echo '<tr>';
-                       echo '<th>' . h($key) . '</th>';
+                       echo '<th>' . Adminer\h($key) . '</th>';
                        echo '<td>';
                        if (is_scalar($val) || $val === null) {
                                if (is_bool($val)) {
@@ -27,7 +27,7 @@ class AdminerJsonColumn {
                                } elseif ($val === null) {
                                        $val = 'null';
                                } elseif (!is_numeric($val)) {
-                                       $val = '"' . h(addcslashes($val, "\r\n\"")) . '"';
+                                       $val = '"' . Adminer\h(addcslashes($val, "\r\n\"")) . '"';
                                }
                                echo '<code class="jush-js">' . $val . '</code>';
                        } else {
index 7000df9e1f1b33fb14d35802f349a10e9d2a127a..b25ea1d909856eec8e90e50c40109737a3761768 100644 (file)
@@ -24,7 +24,7 @@ class AdminerLoginOtp {
                if ($name == 'password') {
                        return $heading . $value . "\n"
                                . "<tr><th><acronym title='One Time Password' lang='en'>OTP</acronym>"
-                               . "<td><input type='number' name='auth[otp]' value='" . h($_SESSION["otp"]) . "' size='6' autocomplete='one-time-code' inputmode='numeric' maxlength='6' pattern='\d{6}'>\n"
+                               . "<td><input type='number' name='auth[otp]' value='" . Adminer\h($_SESSION["otp"]) . "' size='6' autocomplete='one-time-code' inputmode='numeric' maxlength='6' pattern='\d{6}'>\n"
                        ;
                }
        }
@@ -34,9 +34,9 @@ class AdminerLoginOtp {
                        $timeSlot = floor(time() / 30);
                        foreach (array(0, -1, 1) as $skew) {
                                if ($_SESSION["otp"] == $this->getOtp($timeSlot + $skew)) {
-                                       restart_session();
+                                       Adminer\restart_session();
                                        unset($_SESSION["otp"]);
-                                       stop_session();
+                                       Adminer\stop_session();
                                        return;
                                }
                        }
index f501b3e954103e389a3854b6dcac9b06285007d9..ee67d9e176da7dea93a9fa29f072ee14a9cfb037 100644 (file)
@@ -18,7 +18,7 @@ class AdminerLoginPasswordLess {
        }
 
        function credentials() {
-               $password = get_password();
+               $password = Adminer\get_password();
                return array(SERVER, $_GET["username"], (password_verify($password, $this->password_hash) ? "" : $password));
        }
 
index d8ee2ca098a0400f5798aea56656826284dbb060..d2650a46ece969d8617ba73c51c23e522d7ab246 100644 (file)
@@ -22,7 +22,7 @@ class AdminerLoginServers {
        }
 
        function credentials() {
-               return array($this->servers[SERVER]["server"], $_GET["username"], get_password());
+               return array($this->servers[SERVER]["server"], $_GET["username"], Adminer\get_password());
        }
 
        function login($login, $password) {
@@ -35,7 +35,7 @@ class AdminerLoginServers {
                if ($name == 'driver') {
                        return '';
                } elseif ($name == 'server') {
-                       return $heading . "<select name='auth[server]'>" . optionlist(array_keys($this->servers), SERVER) . "</select>\n";
+                       return $heading . "<select name='auth[server]'>" . Adminer\optionlist(array_keys($this->servers), SERVER) . "</select>\n";
                }
        }
 
index efc6e358e9f9b9471913bdbf425a0ea3c9fcb642..e46f7144ef0842e68e53474d6879eeb4d3952fbb 100644 (file)
@@ -27,8 +27,8 @@ class AdminerLoginTable {
        }
 
        function login($login, $password) {
-               $connection = connection();
-               return (bool) $connection->result("SELECT COUNT(*) FROM " . idf_escape($this->database) . ".login WHERE login = " . q($login) . " AND password_sha1 = " . q(sha1($password)));
+               $connection = Adminer\connection();
+               return (bool) $connection->result("SELECT COUNT(*) FROM " . idf_escape($this->database) . ".login WHERE login = " . Adminer\q($login) . " AND password_sha1 = " . Adminer\q(sha1($password)));
        }
 
 }
index e76bb047eb0840688ba1a2e37b6a62308f34a4f8..90524da8f04cbb283b662eeec52dd151e723650d 100644 (file)
@@ -24,18 +24,18 @@ class AdminerMasterSlave {
 
        function login($login, $password) {
                if (!$_POST && ($master = &$_SESSION["master"])) {
-                       $connection = connection();
-                       $connection->query("DO MASTER_POS_WAIT('" . q($master['File']) . "', $master[Position])");
+                       $connection = Adminer\connection();
+                       $connection->query("DO MASTER_POS_WAIT('" . Adminer\q($master['File']) . "', $master[Position])");
                        $master = null;
                }
        }
 
        function messageQuery($query, $time, $failed = false) {
                //! doesn't work with sql.inc.php
-               $connection = connection();
+               $connection = Adminer\connection();
                $result = $connection->query('SHOW MASTER STATUS');
                if ($result) {
-                       restart_session();
+                       Adminer\restart_session();
                        $_SESSION["master"] = $result->fetch_assoc();
                }
        }
index 03f6b5fd26f22f4974aec884650b7f79b68ed08f..8f71a0307f6d53b1450a29f598654e2bb9ab85de 100644 (file)
@@ -6,7 +6,7 @@
 * @license https://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
 * @license https://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
 */
-class AdminerPlugin extends Adminer {
+class AdminerPlugin extends Adminer\Adminer {
        /** @access protected */
        var $plugins;
 
index 094d4d1e1b1a44ce35b6f186704ac04187417938..13ad7a8c545cf4b9f163d388b438ba2e6560b16e 100644 (file)
@@ -34,8 +34,8 @@ class AdminerSlugify {
                        }
                        $slug = $slugify[$field["field"]];
                        if ($slug !== null) {
-                               return "<input value='" . h($value) . "' data-maxlength='$field[length]' size='40'$attrs>"
-                                       . script("qsl('input').onchange = function () {
+                               return "<input value='" . Adminer\h($value) . "' data-maxlength='$field[length]' size='40'$attrs>"
+                                       . Adminer\script("qsl('input').onchange = function () {
        var find = '$this->from';
        var repl = '$this->to';
        this.form['fields[$slug]'].value = this.value.toLowerCase()
index d4891d81d6d58b2e513e4dcfee9854370f0048d1..1babed22a9abd9e2bddbab750f307c8a95375cb3 100644 (file)
@@ -27,7 +27,7 @@ class AdminerSqlLog {
 
        function _log($query) {
                if ($this->filename == "") {
-                       $adminer = adminer();
+                       $adminer = Adminer\adminer();
                        $this->filename = $adminer->database() . ".sql"; // no database goes to ".sql" to avoid collisions
                }
                $fp = fopen($this->filename, "a");
index 05380ca8d1d5dea9e54b240fbd07c397789a5fdc..80c216df2a992b26e49d3e912ec1893f4fcf53e3 100644 (file)
@@ -9,6 +9,6 @@
 class AdminerStructComments {
 
        function fieldName(&$field, $order = 0) {
-               return '<span title="' . h($field["full_type"]) . (!empty($field["comment"]) ? ': ' . $field["comment"] : '') . '">' . h($field["field"]) . '</span>';
+               return '<span title="' . Adminer\h($field["full_type"]) . (!empty($field["comment"]) ? ': ' . $field["comment"] : '') . '">' . Adminer\h($field["field"]) . '</span>';
        }
 }
index e0d2b71472be282eb416dcd7a35454b044b16aaf..e00e0404fa3f5cf564c6dc3274bf00ce573371c4 100644 (file)
@@ -14,13 +14,13 @@ class AdminerTableIndexesStructure {
        */
        function tableIndexesPrint($indexes) {
                echo "<table>\n";
-               echo "<thead><tr><th>" . lang('Name') . "<th>" . lang('Type') . "<th>" . lang('Columns') . "</thead>\n";
+               echo "<thead><tr><th>" . Adminer\lang('Name') . "<th>" . Adminer\lang('Type') . "<th>" . Adminer\lang('Columns') . "</thead>\n";
                foreach ($indexes as $name => $index) {
-                       echo "<tr><th>" . h($name) . "<td>" . $index['type'];
+                       echo "<tr><th>" . Adminer\h($name) . "<td>" . $index['type'];
                        ksort($index["columns"]); // enforce correct columns order
                        $print = array();
                        foreach ($index["columns"] as $key => $val) {
-                               $print[] = "<i>" . h($val) . "</i>"
+                               $print[] = "<i>" . Adminer\h($val) . "</i>"
                                        . ($index["lengths"][$key] ? "(" . $index["lengths"][$key] . ")" : "")
                                        . ($index["descs"][$key] ? " DESC" : "")
                                ;
index 1db0b0d6119d64a583b0980aee45dcbc15e1cfcb..e75c3eb0ae46d8a432b3ff89d62da3fc1aafdbbc 100644 (file)
@@ -15,15 +15,15 @@ class AdminerTableStructure {
        function tableStructurePrint($fields) {
                echo "<div class='scrollable'>\n";
                echo "<table class='nowrap odds'>\n";
-               echo "<thead><tr><th>" . lang('Column') . "<th>" . lang('Type') . "<th>" . lang('Collation') . "<th>" . lang('Nullable') . "<th>" . lang('Default') . (support("comment") ? "<th>" . lang('Comment') : "") . "</thead>\n";
+               echo "<thead><tr><th>" . Adminer\lang('Column') . "<th>" . Adminer\lang('Type') . "<th>" . Adminer\lang('Collation') . "<th>" . Adminer\lang('Nullable') . "<th>" . Adminer\lang('Default') . (support("comment") ? "<th>" . Adminer\lang('Comment') : "") . "</thead>\n";
                foreach ($fields as $field) {
-                       echo "<tr><th>" . h($field["field"]) . ($field["primary"] ? " (PRIMARY)" : "");
-                       echo "<td><span>" . h($field["full_type"]) . "</span>";
-                       echo ($field["auto_increment"] ? " <i>" . lang('Auto Increment') . "</i>" : "");
-                       echo "<td>" . ($field["collation"] ? " <i>" . h($field["collation"]) . "</i>" : "");
-                       echo "<td>" . ($field["null"] ? lang('Yes') : lang('No'));
-                       echo "<td>" . h($field["default"]);
-                       echo (support("comment") ? "<td>" . h($field["comment"]) : "");
+                       echo "<tr><th>" . Adminer\h($field["field"]) . ($field["primary"] ? " (PRIMARY)" : "");
+                       echo "<td><span>" . Adminer\h($field["full_type"]) . "</span>";
+                       echo ($field["auto_increment"] ? " <i>" . Adminer\lang('Auto Increment') . "</i>" : "");
+                       echo "<td>" . ($field["collation"] ? " <i>" . Adminer\h($field["collation"]) . "</i>" : "");
+                       echo "<td>" . ($field["null"] ? Adminer\lang('Yes') : Adminer\lang('No'));
+                       echo "<td>" . Adminer\h($field["default"]);
+                       echo (support("comment") ? "<td>" . Adminer\h($field["comment"]) : "");
                        echo "\n";
                }
                echo "</table>\n";
index 879a392475d69f42daf92a48ae056d91ceb9c1c1..5d35379932cb48602de03195dbc10d2b6f03e594 100644 (file)
@@ -9,7 +9,7 @@
 class AdminerTablesFilter {
        function tablesPrint($tables) {
                ?>
-<script<?php echo nonce(); ?>>
+<script<?php echo Adminer\nonce(); ?>>
 var tablesFilterTimeout = null;
 var tablesFilterValue = '';
 
@@ -64,7 +64,7 @@ sessionStorage && document.addEventListener('DOMContentLoaded', function () {
        sessionStorage.setItem('adminer_tables_filter_db', db);
 });
 </script>
-<p class="jsonly"><input id="filter-field" autocomplete="off" type="search"><?php echo script("qs('#filter-field').oninput = tablesFilterInput;"); ?>
+<p class="jsonly"><input id="filter-field" autocomplete="off" type="search"><?php echo Adminer\script("qs('#filter-field').oninput = tablesFilterInput;"); ?>
 <?php
        }
 }
index d9ef91b46dd582c956e8184d9ae2b8fd5c0e4ac2..6b6f7477d6c0d774e83283a1537d2e8781f35f9a 100644 (file)
@@ -19,14 +19,14 @@ class AdminerTinymce {
        }
 
        function head() {
-               $lang = get_lang();
+               $lang = Adminer\get_lang();
                $lang = ($lang == "zh" ? "zh-cn" : ($lang == "zh-tw" ? "zh" : $lang));
                if (!file_exists(dirname($this->path) . "/langs/$lang.js")) {
                        $lang = "en";
                }
-               echo script_src($this->path);
+               echo Adminer\script_src($this->path);
                ?>
-<script<?php echo nonce(); ?>>
+<script<?php echo Adminer\nonce(); ?>>
 tinyMCE.init({
        entity_encoding: 'raw',
        language: '<?php echo $lang; ?>'
@@ -59,9 +59,9 @@ tinyMCE.init({
 
        function editInput($table, $field, $attrs, $value) {
                if (preg_match("~text~", $field["type"]) && preg_match("~_html~", $field["field"])) {
-                       return "<textarea$attrs id='fields-" . h($field["field"]) . "' rows='12' cols='50'>" . h($value) . "</textarea>" . script("
-tinyMCE.remove(tinyMCE.get('fields-" . js_escape($field["field"]) . "') || { });
-tinyMCE.EditorManager.execCommand('mceAddControl', true, 'fields-" . js_escape($field["field"]) . "');
+                       return "<textarea$attrs id='fields-" . Adminer\h($field["field"]) . "' rows='12' cols='50'>" . Adminer\h($value) . "</textarea>" . Adminer\script("
+tinyMCE.remove(tinyMCE.get('fields-" . Adminer\js_escape($field["field"]) . "') || { });
+tinyMCE.EditorManager.execCommand('mceAddControl', true, 'fields-" . Adminer\js_escape($field["field"]) . "');
 qs('#form').onsubmit = function () {
        tinyMCE.each(tinyMCE.editors, function (ed) {
                ed.remove();
index e4824342584ce9a9474b7a12c5c273586f203ebd..b25f9e262e7d07be65ff1be58ea5e6fff2006297 100644 (file)
@@ -21,19 +21,19 @@ class AdminerTranslation {
        function _translate($idf) {
                static $translations, $lang;
                if ($lang === null) {
-                       $lang = get_lang();
+                       $lang = Adminer\get_lang();
                }
                if ($idf == "" || $lang == "en") {
                        return $idf;
                }
                if ($translations === null) {
-                       $translations = get_key_vals("SELECT idf, translation FROM translation WHERE language_id = " . q($lang));
+                       $translations = Adminer\get_key_vals("SELECT idf, translation FROM translation WHERE language_id = " . Adminer\q($lang));
                }
                $return = &$translations[$idf];
                if ($return === null) {
                        $return = $idf;
-                       $connection = connection();
-                       $connection->query("INSERT INTO translation (language_id, idf, translation) VALUES (" . q($lang) . ", " . q($idf) . ", " . q($idf) . ")");
+                       $connection = Adminer\connection();
+                       $connection->query("INSERT INTO translation (language_id, idf, translation) VALUES (" . Adminer\q($lang) . ", " . Adminer\q($idf) . ", " . Adminer\q($idf) . ")");
                }
                return $return;
        }
index cbf79d8ea1815ac782ac033578d5a636e3cc43d4..154ec6db59de4d7aba9a312797cb4ca88a10bab2 100644 (file)
@@ -9,7 +9,7 @@
 class AdminerVersionNoverify {
 
        function head() {
-               echo script("verifyVersion = function () {};");
+               echo Adminer\script("verifyVersion = function () {};");
        }
 
 }
index b8c82af76c848acff69b536b353f1c0a091296d2..5a3b3d3ab33232d03ec5292dd2862d85047969bd 100644 (file)
@@ -22,7 +22,7 @@ class AdminerWymeditor {
 
        function head() {
                foreach ($this->scripts as $script) {
-                       echo script_src($script);
+                       echo Adminer\script_src($script);
                }
        }
 
@@ -52,10 +52,10 @@ class AdminerWymeditor {
        function editInput($table, $field, $attrs, $value) {
                static $lang = "";
                if (!$lang && preg_match("~text~", $field["type"]) && preg_match("~_html~", $field["field"])) {
-                       $lang = get_lang();
+                       $lang = Adminer\get_lang();
                        $lang = ($lang == "zh" || $lang == "zh-tw" ? "zh_cn" : $lang);
-                       return "<textarea$attrs id='fields-" . h($field["field"]) . "' rows='12' cols='50'>" . h($value) . "</textarea>" . script("
-jQuery('#fields-" . js_escape($field["field"]) . "').wymeditor({ updateSelector: '#form [type=\"submit\"]', lang: '$lang'" . ($this->options ? ", $this->options" : "") . " });
+                       return "<textarea$attrs id='fields-" . Adminer\h($field["field"]) . "' rows='12' cols='50'>" . Adminer\h($value) . "</textarea>" . Adminer\script("
+jQuery('#fields-" . Adminer\js_escape($field["field"]) . "').wymeditor({ updateSelector: '#form [type=\"submit\"]', lang: '$lang'" . ($this->options ? ", $this->options" : "") . " });
 ");
                }
        }