1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-08 15:47:00 +02:00

Use namespaces in plugins

This commit is contained in:
Jakub Vrana
2025-03-05 11:40:56 +01:00
parent 52c5392089
commit 50e7a65e6e
32 changed files with 105 additions and 105 deletions

View 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

View 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";
}
}
}

View 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";
}

View 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
}

View 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()"));
}
}

View 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 "]";
}

View 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()) {

View 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";
}

View 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 })"

View 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>";
}
}
}

View 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>';
}
}

View 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];

View 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
}
}

View 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>";
}
}

View 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);
}
}

View 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 {

View 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;
}
}

View 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));
}

View 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";
}
}

View 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)));
}
}

View 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();
}
}

View 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;

View 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()

View 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");

View 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>';
}
}

View 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" : "")
;

View 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";

View 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
}
}

View 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();

View 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;
}

View File

@@ -9,7 +9,7 @@
class AdminerVersionNoverify {
function head() {
echo script("verifyVersion = function () {};");
echo Adminer\script("verifyVersion = function () {};");
}
}

View 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" : "") . " });
");
}
}