2009-07-03 06:26:01 +00:00
|
|
|
<?php
|
2009-07-27 11:25:37 +00:00
|
|
|
class Adminer {
|
2009-09-25 13:48:00 +00:00
|
|
|
var $operators = array("<=", ">=");
|
2010-04-21 12:01:32 +00:00
|
|
|
var $_values = array();
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2009-07-27 11:25:37 +00:00
|
|
|
function name() {
|
2018-01-23 11:53:22 +00:00
|
|
|
return "<a href='https://www.adminer.org/editor/'" . target_blank() . " id='h1'>" . lang('Editor') . "</a>";
|
2009-07-27 11:25:37 +00:00
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2010-05-06 13:45:34 +00:00
|
|
|
//! driver, ns
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2009-07-27 11:25:37 +00:00
|
|
|
function credentials() {
|
2013-08-11 02:06:21 +00:00
|
|
|
return array(SERVER, $_GET["username"], get_password());
|
2009-07-27 11:25:37 +00:00
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2018-02-07 11:13:58 +00:00
|
|
|
function connectSsl() {
|
|
|
|
}
|
|
|
|
|
2013-06-11 09:02:17 +00:00
|
|
|
function permanentLogin($create = false) {
|
|
|
|
return password_file($create);
|
2009-12-18 17:39:48 +00:00
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2014-03-22 05:47:34 +00:00
|
|
|
function bruteForceKey() {
|
|
|
|
return $_SERVER["REMOTE_ADDR"];
|
|
|
|
}
|
2018-02-08 13:27:44 +00:00
|
|
|
|
|
|
|
function serverName($server) {
|
|
|
|
}
|
2014-03-22 05:47:34 +00:00
|
|
|
|
2009-07-27 11:25:37 +00:00
|
|
|
function database() {
|
2009-09-22 10:51:40 +00:00
|
|
|
global $connection;
|
2013-06-13 05:46:12 +00:00
|
|
|
if ($connection) {
|
|
|
|
$databases = $this->databases(false);
|
|
|
|
return (!$databases
|
|
|
|
? $connection->result("SELECT SUBSTRING_INDEX(CURRENT_USER, '@', 1)") // username without the database list
|
|
|
|
: $databases[(information_schema($databases[0]) ? 1 : 0)] // first available database
|
|
|
|
);
|
|
|
|
}
|
2009-07-27 11:25:37 +00:00
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2013-10-25 05:16:24 +00:00
|
|
|
function schemas() {
|
|
|
|
return schemas();
|
|
|
|
}
|
|
|
|
|
2012-02-24 06:54:48 +00:00
|
|
|
function databases($flush = true) {
|
|
|
|
return get_databases($flush);
|
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2012-08-20 06:25:23 +00:00
|
|
|
function queryTimeout() {
|
|
|
|
return 5;
|
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2010-10-17 20:13:32 +00:00
|
|
|
function headers() {
|
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2018-01-09 17:53:17 +00:00
|
|
|
function csp() {
|
|
|
|
return csp();
|
|
|
|
}
|
|
|
|
|
2011-03-23 10:57:35 +00:00
|
|
|
function head() {
|
|
|
|
return true;
|
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2018-01-23 11:15:38 +00:00
|
|
|
function css() {
|
|
|
|
$return = array();
|
|
|
|
$filename = "adminer.css";
|
|
|
|
if (file_exists($filename)) {
|
|
|
|
$return[] = $filename;
|
|
|
|
}
|
|
|
|
return $return;
|
|
|
|
}
|
|
|
|
|
2010-04-21 12:01:32 +00:00
|
|
|
function loginForm() {
|
2018-02-22 10:36:11 +00:00
|
|
|
echo "<table cellspacing='0'>\n";
|
2018-02-22 11:38:22 +00:00
|
|
|
echo $this->loginFormField('username', '<tr><th>' . lang('Username') . '<td>', '<input type="hidden" name="auth[driver]" value="server"><input name="auth[username]" id="username" value="' . h($_GET["username"]) . '" autocapitalize="off">' . script("focus(qs('#username'));"));
|
|
|
|
echo $this->loginFormField('password', '<tr><th>' . lang('Password') . '<td>', '<input type="password" name="auth[password]">' . "\n");
|
2018-02-22 10:36:11 +00:00
|
|
|
echo "</table>\n";
|
2009-12-18 17:49:21 +00:00
|
|
|
echo "<p><input type='submit' value='" . lang('Login') . "'>\n";
|
2012-05-14 07:08:32 +00:00
|
|
|
echo checkbox("auth[permanent]", 1, $_COOKIE["adminer_permanent"], lang('Permanent login')) . "\n";
|
2009-07-21 12:19:25 +00:00
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2018-02-22 11:38:22 +00:00
|
|
|
function loginFormField($name, $heading, $value) {
|
|
|
|
return $heading . $value;
|
2018-02-22 10:36:11 +00:00
|
|
|
}
|
|
|
|
|
2009-07-27 11:25:37 +00:00
|
|
|
function login($login, $password) {
|
|
|
|
return true;
|
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2009-07-27 11:25:37 +00:00
|
|
|
function tableName($tableStatus) {
|
2010-01-09 23:33:41 +00:00
|
|
|
return h($tableStatus["Comment"] != "" ? $tableStatus["Comment"] : $tableStatus["Name"]);
|
2009-07-27 11:25:37 +00:00
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2009-07-27 16:51:40 +00:00
|
|
|
function fieldName($field, $order = 0) {
|
2017-10-01 15:45:17 +00:00
|
|
|
return h(preg_replace('~\s+\[.*\]$~', '', ($field["comment"] != "" ? $field["comment"] : $field["field"])));
|
2009-07-27 11:25:37 +00:00
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2009-09-20 07:31:46 +00:00
|
|
|
function selectLinks($tableStatus, $set = "") {
|
|
|
|
$TABLE = $tableStatus["Name"];
|
2012-05-14 06:54:07 +00:00
|
|
|
if ($set !== null) {
|
2009-10-28 12:21:21 +00:00
|
|
|
echo '<p class="tabs"><a href="' . h(ME . 'edit=' . urlencode($TABLE) . $set) . '">' . lang('New item') . "</a>\n";
|
2009-09-20 07:31:46 +00:00
|
|
|
}
|
2009-07-27 11:25:37 +00:00
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2010-10-29 11:58:08 +00:00
|
|
|
function foreignKeys($table) {
|
|
|
|
return foreign_keys($table);
|
2009-07-27 11:25:37 +00:00
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2009-09-23 14:28:06 +00:00
|
|
|
function backwardKeys($table, $tableName) {
|
2009-07-27 11:25:37 +00:00
|
|
|
$return = array();
|
2010-10-13 15:53:59 +00:00
|
|
|
foreach (get_rows("SELECT TABLE_NAME, CONSTRAINT_NAME, COLUMN_NAME, REFERENCED_COLUMN_NAME
|
2009-07-22 11:36:27 +00:00
|
|
|
FROM information_schema.KEY_COLUMN_USAGE
|
2010-10-13 16:04:40 +00:00
|
|
|
WHERE TABLE_SCHEMA = " . q($this->database()) . "
|
|
|
|
AND REFERENCED_TABLE_SCHEMA = " . q($this->database()) . "
|
|
|
|
AND REFERENCED_TABLE_NAME = " . q($table) . "
|
2010-10-13 16:59:15 +00:00
|
|
|
ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5
|
2010-10-13 15:53:59 +00:00
|
|
|
$return[$row["TABLE_NAME"]]["keys"][$row["CONSTRAINT_NAME"]][$row["COLUMN_NAME"]] = $row["REFERENCED_COLUMN_NAME"];
|
|
|
|
}
|
|
|
|
foreach ($return as $key => $val) {
|
2013-04-27 03:04:57 +00:00
|
|
|
$name = $this->tableName(table_status($key, true));
|
2010-10-13 15:53:59 +00:00
|
|
|
if ($name != "") {
|
|
|
|
$search = preg_quote($tableName);
|
|
|
|
$separator = "(:|\\s*-)?\\s+";
|
2011-01-18 10:25:53 +00:00
|
|
|
$return[$key]["name"] = (preg_match("(^$search$separator(.+)|^(.+?)$separator$search\$)iu", $name, $match) ? $match[2] . $match[3] : $name);
|
2010-10-13 15:53:59 +00:00
|
|
|
} else {
|
|
|
|
unset($return[$key]);
|
2009-07-27 11:25:37 +00:00
|
|
|
}
|
2009-07-22 11:04:03 +00:00
|
|
|
}
|
2009-07-27 11:25:37 +00:00
|
|
|
return $return;
|
2009-07-22 11:04:03 +00:00
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2009-09-23 14:28:06 +00:00
|
|
|
function backwardKeysPrint($backwardKeys, $row) {
|
2011-01-18 16:29:40 +00:00
|
|
|
foreach ($backwardKeys as $table => $backwardKey) {
|
|
|
|
foreach ($backwardKey["keys"] as $cols) {
|
|
|
|
$link = ME . 'select=' . urlencode($table);
|
|
|
|
$i = 0;
|
|
|
|
foreach ($cols as $column => $val) {
|
|
|
|
$link .= where_link($i++, $column, $row[$val]);
|
2009-09-23 14:28:06 +00:00
|
|
|
}
|
2011-01-18 16:29:40 +00:00
|
|
|
echo "<a href='" . h($link) . "'>" . h($backwardKey["name"]) . "</a>";
|
|
|
|
$link = ME . 'edit=' . urlencode($table);
|
|
|
|
foreach ($cols as $column => $val) {
|
|
|
|
$link .= "&set" . urlencode("[" . bracket_escape($column) . "]") . "=" . urlencode($row[$val]);
|
|
|
|
}
|
|
|
|
echo "<a href='" . h($link) . "' title='" . lang('New item') . "'>+</a> ";
|
2009-09-23 14:28:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2018-02-01 12:12:05 +00:00
|
|
|
function selectQuery($query, $start, $failed = false) {
|
2018-02-01 10:54:39 +00:00
|
|
|
return "<!--\n" . str_replace("--", "--><!-- ", $query) . "\n(" . format_time($start) . ")\n-->\n";
|
2009-07-27 11:25:37 +00:00
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2009-07-27 11:25:37 +00:00
|
|
|
function rowDescription($table) {
|
|
|
|
// first varchar column
|
|
|
|
foreach (fields($table) as $field) {
|
2013-07-24 23:26:41 +00:00
|
|
|
if (preg_match("~varchar|character varying~", $field["type"])) {
|
2009-07-30 15:37:20 +00:00
|
|
|
return idf_escape($field["field"]);
|
2009-07-27 11:25:37 +00:00
|
|
|
}
|
2009-07-23 14:42:38 +00:00
|
|
|
}
|
2009-07-30 15:37:20 +00:00
|
|
|
return "";
|
2009-07-23 14:42:38 +00:00
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2009-07-27 11:25:37 +00:00
|
|
|
function rowDescriptions($rows, $foreignKeys) {
|
|
|
|
$return = $rows;
|
|
|
|
foreach ($rows[0] as $key => $val) {
|
2011-04-08 06:50:33 +00:00
|
|
|
if (list($table, $id, $name) = $this->_foreignColumn($foreignKeys, $key)) {
|
|
|
|
// find all used ids
|
|
|
|
$ids = array();
|
|
|
|
foreach ($rows as $row) {
|
2013-06-05 02:40:17 +00:00
|
|
|
$ids[$row[$key]] = q($row[$key]);
|
2011-04-08 06:50:33 +00:00
|
|
|
}
|
|
|
|
// uses constant number of queries to get the descriptions, join would be complex, multiple queries would be slow
|
|
|
|
$descriptions = $this->_values[$table];
|
|
|
|
if (!$descriptions) {
|
|
|
|
$descriptions = get_key_vals("SELECT $id, $name FROM " . table($table) . " WHERE $id IN (" . implode(", ", $ids) . ")");
|
|
|
|
}
|
|
|
|
// use the descriptions
|
|
|
|
foreach ($rows as $n => $row) {
|
|
|
|
if (isset($row[$key])) {
|
|
|
|
$return[$n][$key] = (string) $descriptions[$row[$key]];
|
2009-07-23 14:42:38 +00:00
|
|
|
}
|
2009-07-20 15:34:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-07-27 11:25:37 +00:00
|
|
|
return $return;
|
2009-07-20 15:34:05 +00:00
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2013-01-11 01:59:43 +00:00
|
|
|
function selectLink($val, $field) {
|
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2014-01-11 05:32:07 +00:00
|
|
|
function selectVal($val, $link, $field, $original) {
|
2018-02-20 15:02:25 +00:00
|
|
|
$return = $val;
|
2012-12-05 23:29:57 +00:00
|
|
|
$link = h($link);
|
2013-07-24 23:26:41 +00:00
|
|
|
if (preg_match('~blob|bytea~', $field["type"]) && !is_utf8($val)) {
|
2014-01-11 05:32:07 +00:00
|
|
|
$return = lang('%d byte(s)', strlen($original));
|
|
|
|
if (preg_match("~^(GIF|\xFF\xD8\xFF|\x89PNG\x0D\x0A\x1A\x0A)~", $original)) { // GIF|JPG|PNG, getimagetype() works with filename
|
2009-07-30 14:55:09 +00:00
|
|
|
$return = "<img src='$link' alt='$return'>";
|
2009-07-27 11:25:37 +00:00
|
|
|
}
|
2009-07-24 10:14:36 +00:00
|
|
|
}
|
2018-02-20 15:02:25 +00:00
|
|
|
if (like_bool($field) && $return != "") { // bool
|
2018-02-19 22:09:46 +00:00
|
|
|
$return = (preg_match('~^(1|t|true|y|yes|on)$~i', $val) ? lang('yes') : lang('no'));
|
2009-07-28 10:09:05 +00:00
|
|
|
}
|
2009-09-25 14:52:30 +00:00
|
|
|
if ($link) {
|
2018-01-30 18:12:49 +00:00
|
|
|
$return = "<a href='$link'" . (is_url($link) ? target_blank() : "") . ">$return</a>";
|
2009-09-25 14:52:30 +00:00
|
|
|
}
|
2018-02-06 13:52:12 +00:00
|
|
|
if (!$link && !like_bool($field) && preg_match(number_type(), $field["type"])) {
|
2009-09-25 14:52:30 +00:00
|
|
|
$return = "<div class='number'>$return</div>"; // Firefox doesn't support <colgroup>
|
2013-07-24 23:26:41 +00:00
|
|
|
} elseif (preg_match('~date~', $field["type"])) {
|
2009-11-19 09:29:06 +00:00
|
|
|
$return = "<div class='datetime'>$return</div>";
|
2009-09-25 14:52:30 +00:00
|
|
|
}
|
|
|
|
return $return;
|
2009-07-24 10:14:36 +00:00
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2009-07-27 16:32:56 +00:00
|
|
|
function editVal($val, $field) {
|
2013-07-24 23:26:41 +00:00
|
|
|
if (preg_match('~date|timestamp~', $field["type"]) && $val !== null) {
|
2018-02-20 15:27:40 +00:00
|
|
|
return preg_replace('~^(\d{2}(\d+))-(0?(\d+))-(0?(\d+))~', lang('$1-$3-$5'), $val);
|
2009-07-27 16:32:56 +00:00
|
|
|
}
|
2012-09-09 05:56:34 +00:00
|
|
|
return $val;
|
2009-07-27 16:32:56 +00:00
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2009-07-27 14:40:55 +00:00
|
|
|
function selectColumnsPrint($select, $columns) {
|
2010-04-21 12:01:32 +00:00
|
|
|
// can allow grouping functions by indexes
|
2009-07-27 14:40:55 +00:00
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2009-07-27 14:40:55 +00:00
|
|
|
function selectSearchPrint($where, $columns, $indexes) {
|
2010-04-21 12:01:32 +00:00
|
|
|
$where = (array) $_GET["where"];
|
2012-08-05 05:52:50 +00:00
|
|
|
echo '<fieldset id="fieldset-search"><legend>' . lang('Search') . "</legend><div>\n";
|
2009-11-12 15:02:34 +00:00
|
|
|
$keys = array();
|
2010-04-21 12:01:32 +00:00
|
|
|
foreach ($where as $key => $val) {
|
2009-11-12 15:02:34 +00:00
|
|
|
$keys[$val["col"]] = $key;
|
|
|
|
}
|
2010-04-21 12:01:32 +00:00
|
|
|
$i = 0;
|
2011-02-24 14:04:38 +00:00
|
|
|
$fields = fields($_GET["select"]);
|
2011-08-24 14:43:11 +00:00
|
|
|
foreach ($columns as $name => $desc) {
|
|
|
|
$field = $fields[$name];
|
2013-07-24 23:26:41 +00:00
|
|
|
if (preg_match("~enum~", $field["type"]) || like_bool($field)) { //! set - uses 1 << $i and FIND_IN_SET()
|
2010-04-21 12:01:32 +00:00
|
|
|
$key = $keys[$name];
|
|
|
|
$i--;
|
|
|
|
echo "<div>" . h($desc) . "<input type='hidden' name='where[$i][col]' value='" . h($name) . "'>:";
|
2011-08-24 14:50:44 +00:00
|
|
|
echo (like_bool($field)
|
|
|
|
? " <select name='where[$i][val]'>" . optionlist(array("" => "", lang('no'), lang('yes')), $where[$key]["val"], true) . "</select>"
|
|
|
|
: enum_input("checkbox", " name='where[$i][val][]'", $field, (array) $where[$key]["val"], ($field["null"] ? 0 : null))
|
|
|
|
);
|
2010-04-21 12:01:32 +00:00
|
|
|
echo "</div>\n";
|
|
|
|
unset($columns[$name]);
|
2011-08-24 14:43:11 +00:00
|
|
|
} elseif (is_array($options = $this->_foreignKeyOptions($_GET["select"], $name))) {
|
2011-02-24 14:04:38 +00:00
|
|
|
if ($fields[$name]["null"]) {
|
|
|
|
$options[0] = '(' . lang('empty') . ')';
|
|
|
|
}
|
2010-04-21 12:01:32 +00:00
|
|
|
$key = $keys[$name];
|
2009-11-16 11:06:07 +00:00
|
|
|
$i--;
|
2010-04-21 12:01:32 +00:00
|
|
|
echo "<div>" . h($desc) . "<input type='hidden' name='where[$i][col]' value='" . h($name) . "'><input type='hidden' name='where[$i][op]' value='='>: <select name='where[$i][val]'>" . optionlist($options, $where[$key]["val"], true) . "</select></div>\n";
|
2009-11-12 15:02:34 +00:00
|
|
|
unset($columns[$name]);
|
|
|
|
}
|
|
|
|
}
|
2009-07-27 14:40:55 +00:00
|
|
|
$i = 0;
|
2010-04-21 12:01:32 +00:00
|
|
|
foreach ($where as $val) {
|
2010-06-01 23:44:06 +00:00
|
|
|
if (($val["col"] == "" || $columns[$val["col"]]) && "$val[col]$val[val]" != "") {
|
2010-04-21 12:01:32 +00:00
|
|
|
echo "<div><select name='where[$i][col]'><option value=''>(" . lang('anywhere') . ")" . optionlist($columns, $val["col"], true) . "</select>";
|
2009-10-02 13:21:34 +00:00
|
|
|
echo html_select("where[$i][op]", array(-1 => "") + $this->operators, $val["op"]);
|
2018-01-12 22:42:20 +00:00
|
|
|
echo "<input type='search' name='where[$i][val]' value='" . h($val["val"]) . "'>" . script("mixin(qsl('input'), {onkeydown: selectSearchKeydown, onsearch: selectSearchSearch});", "") . "</div>\n";
|
2009-07-27 14:40:55 +00:00
|
|
|
$i++;
|
|
|
|
}
|
|
|
|
}
|
2018-01-13 07:58:01 +00:00
|
|
|
echo "<div><select name='where[$i][col]'><option value=''>(" . lang('anywhere') . ")" . optionlist($columns, null, true) . "</select>";
|
|
|
|
echo script("qsl('select').onchange = selectAddRow;", "");
|
2009-10-02 13:21:34 +00:00
|
|
|
echo html_select("where[$i][op]", array(-1 => "") + $this->operators);
|
2018-01-13 07:58:01 +00:00
|
|
|
echo "<input type='search' name='where[$i][val]'></div>";
|
|
|
|
echo script("mixin(qsl('input'), {onchange: function () { this.parentNode.firstChild.onchange(); }, onsearch: selectSearchSearch});");
|
2009-07-27 14:40:55 +00:00
|
|
|
echo "</div></fieldset>\n";
|
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2009-07-27 14:40:55 +00:00
|
|
|
function selectOrderPrint($order, $columns, $indexes) {
|
|
|
|
//! desc
|
|
|
|
$orders = array();
|
2009-07-28 14:21:05 +00:00
|
|
|
foreach ($indexes as $key => $index) {
|
2009-07-27 14:40:55 +00:00
|
|
|
$order = array();
|
|
|
|
foreach ($index["columns"] as $val) {
|
2010-12-28 11:32:47 +00:00
|
|
|
$order[] = $columns[$val];
|
2009-07-27 14:40:55 +00:00
|
|
|
}
|
2009-07-28 14:21:05 +00:00
|
|
|
if (count(array_filter($order, 'strlen')) > 1 && $key != "PRIMARY") {
|
|
|
|
$orders[$key] = implode(", ", $order);
|
2009-07-27 14:40:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($orders) {
|
|
|
|
echo '<fieldset><legend>' . lang('Sort') . "</legend><div>";
|
2011-03-19 13:47:44 +00:00
|
|
|
echo "<select name='index_order'>" . optionlist(array("" => "") + $orders, ($_GET["order"][0] != "" ? "" : $_GET["index_order"]), true) . "</select>";
|
2009-07-27 14:40:55 +00:00
|
|
|
echo "</div></fieldset>\n";
|
|
|
|
}
|
2011-03-19 13:47:44 +00:00
|
|
|
if ($_GET["order"]) {
|
|
|
|
echo "<div style='display: none;'>" . hidden_fields(array(
|
|
|
|
"order" => array(1 => reset($_GET["order"])),
|
|
|
|
"desc" => ($_GET["desc"] ? array(1 => 1) : array()),
|
|
|
|
)) . "</div>\n";
|
|
|
|
}
|
2009-07-27 14:40:55 +00:00
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2009-07-27 14:40:55 +00:00
|
|
|
function selectLimitPrint($limit) {
|
|
|
|
echo "<fieldset><legend>" . lang('Limit') . "</legend><div>"; // <div> for easy styling
|
2013-04-15 21:45:49 +00:00
|
|
|
echo html_select("limit", array("", "50", "100"), $limit);
|
2009-07-27 14:40:55 +00:00
|
|
|
echo "</div></fieldset>\n";
|
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2009-07-27 14:40:55 +00:00
|
|
|
function selectLengthPrint($text_length) {
|
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2012-05-17 06:54:56 +00:00
|
|
|
function selectActionPrint($indexes) {
|
2009-07-27 14:40:55 +00:00
|
|
|
echo "<fieldset><legend>" . lang('Action') . "</legend><div>";
|
|
|
|
echo "<input type='submit' value='" . lang('Select') . "'>";
|
|
|
|
echo "</div></fieldset>\n";
|
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2011-05-24 15:16:13 +00:00
|
|
|
function selectCommandPrint() {
|
|
|
|
return true;
|
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2011-05-24 15:16:13 +00:00
|
|
|
function selectImportPrint() {
|
|
|
|
return true;
|
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2009-09-09 20:47:42 +00:00
|
|
|
function selectEmailPrint($emailFields, $columns) {
|
2009-07-28 11:18:08 +00:00
|
|
|
if ($emailFields) {
|
2011-02-18 18:37:39 +00:00
|
|
|
print_fieldset("email", lang('E-mail'), $_POST["email_append"]);
|
2018-01-13 07:58:01 +00:00
|
|
|
echo "<div>";
|
|
|
|
echo script("qsl('div').onkeydown = partialArg(bodyKeydown, 'email');");
|
2009-09-09 20:49:30 +00:00
|
|
|
echo "<p>" . lang('From') . ": <input name='email_from' value='" . h($_POST ? $_POST["email_from"] : $_COOKIE["adminer_email"]) . "'>\n";
|
2009-09-09 20:47:42 +00:00
|
|
|
echo lang('Subject') . ": <input name='email_subject' value='" . h($_POST["email_subject"]) . "'>\n";
|
2012-05-14 09:16:10 +00:00
|
|
|
echo "<p><textarea name='email_message' rows='15' cols='75'>" . h($_POST["email_message"] . ($_POST["email_append"] ? '{$' . "$_POST[email_addition]}" : "")) . "</textarea>\n";
|
2018-01-13 07:58:01 +00:00
|
|
|
echo "<p>" . script("qsl('p').onkeydown = partialArg(bodyKeydown, 'email_append');", "") . html_select("email_addition", $columns, $_POST["email_addition"]) . "<input type='submit' name='email_append' value='" . lang('Insert') . "'>\n"; //! JavaScript
|
|
|
|
echo "<p>" . lang('Attachments') . ": <input type='file' name='email_files[]'>" . script("qsl('input').onchange = emailFileChange;");
|
2009-10-02 13:21:34 +00:00
|
|
|
echo "<p>" . (count($emailFields) == 1 ? '<input type="hidden" name="email_field" value="' . h(key($emailFields)) . '">' : html_select("email_field", $emailFields));
|
2018-01-13 08:21:21 +00:00
|
|
|
echo "<input type='submit' name='email' value='" . lang('Send') . "'>" . confirm();
|
2011-05-04 09:42:46 +00:00
|
|
|
echo "</div>\n";
|
2009-07-28 11:18:08 +00:00
|
|
|
echo "</div></fieldset>\n";
|
|
|
|
}
|
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2009-07-27 14:40:55 +00:00
|
|
|
function selectColumnsProcess($columns, $indexes) {
|
|
|
|
return array(array(), array());
|
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2009-07-28 14:21:05 +00:00
|
|
|
function selectSearchProcess($fields, $indexes) {
|
2009-07-27 14:40:55 +00:00
|
|
|
$return = array();
|
2010-04-21 12:01:32 +00:00
|
|
|
foreach ((array) $_GET["where"] as $key => $where) {
|
|
|
|
$col = $where["col"];
|
|
|
|
$op = $where["op"];
|
|
|
|
$val = $where["val"];
|
|
|
|
if (($key < 0 ? "" : $col) . $val != "") {
|
2009-09-01 14:24:08 +00:00
|
|
|
$conds = array();
|
2010-01-09 23:33:41 +00:00
|
|
|
foreach (($col != "" ? array($col => $fields[$col]) : $fields) as $name => $field) {
|
2018-02-06 13:52:12 +00:00
|
|
|
if ($col != "" || is_numeric($val) || !preg_match(number_type(), $field["type"])) {
|
2011-02-24 14:04:38 +00:00
|
|
|
$name = idf_escape($name);
|
2010-04-21 12:01:32 +00:00
|
|
|
if ($col != "" && $field["type"] == "enum") {
|
2011-02-24 14:04:38 +00:00
|
|
|
$conds[] = (in_array(0, $val) ? "$name IS NULL OR " : "") . "$name IN (" . implode(", ", array_map('intval', $val)) . ")";
|
2010-04-21 12:01:32 +00:00
|
|
|
} else {
|
2013-07-24 23:26:41 +00:00
|
|
|
$text_type = preg_match('~char|text|enum|set~', $field["type"]);
|
|
|
|
$value = $this->processInput($field, (!$op && $text_type && preg_match('~^[^%]+$~', $val) ? "%$val%" : $val));
|
2011-02-24 14:04:38 +00:00
|
|
|
$conds[] = $name . ($value == "NULL" ? " IS" . ($op == ">=" ? " NOT" : "") . " $value"
|
2011-01-06 08:41:27 +00:00
|
|
|
: (in_array($op, $this->operators) || $op == "=" ? " $op $value"
|
|
|
|
: ($text_type ? " LIKE $value"
|
|
|
|
: " IN (" . str_replace(",", "', '", $value) . ")"
|
|
|
|
))); //! can issue "Illegal mix of collations" for columns in other character sets - solve by CONVERT($name using utf8)
|
2011-02-24 14:04:38 +00:00
|
|
|
if ($key < 0 && $val == "0") {
|
|
|
|
$conds[] = "$name IS NULL";
|
|
|
|
}
|
2010-04-21 12:01:32 +00:00
|
|
|
}
|
2009-07-27 14:40:55 +00:00
|
|
|
}
|
|
|
|
}
|
2018-02-06 11:43:10 +00:00
|
|
|
$return[] = ($conds ? "(" . implode(" OR ", $conds) . ")" : "1 = 0");
|
2009-07-27 14:40:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return $return;
|
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2009-07-28 14:21:05 +00:00
|
|
|
function selectOrderProcess($fields, $indexes) {
|
2011-03-19 13:47:44 +00:00
|
|
|
$index_order = $_GET["index_order"];
|
|
|
|
if ($index_order != "") {
|
|
|
|
unset($_GET["order"][1]);
|
|
|
|
}
|
2009-07-28 11:04:49 +00:00
|
|
|
if ($_GET["order"]) {
|
2011-03-19 13:47:44 +00:00
|
|
|
return array(idf_escape(reset($_GET["order"])) . ($_GET["desc"] ? " DESC" : ""));
|
2009-07-28 11:04:49 +00:00
|
|
|
}
|
2010-01-09 23:33:41 +00:00
|
|
|
foreach (($index_order != "" ? array($indexes[$index_order]) : $indexes) as $index) {
|
|
|
|
if ($index_order != "" || $index["type"] == "INDEX") {
|
2013-06-25 16:42:47 +00:00
|
|
|
$has_desc = array_filter($index["descs"]);
|
2009-07-28 14:31:03 +00:00
|
|
|
$desc = false;
|
|
|
|
foreach ($index["columns"] as $val) {
|
2013-07-24 23:26:41 +00:00
|
|
|
if (preg_match('~date|timestamp~', $fields[$val]["type"])) {
|
2009-07-28 14:31:03 +00:00
|
|
|
$desc = true;
|
|
|
|
break;
|
|
|
|
}
|
2009-07-28 14:21:05 +00:00
|
|
|
}
|
2009-07-28 14:31:03 +00:00
|
|
|
$return = array();
|
2013-06-25 16:42:47 +00:00
|
|
|
foreach ($index["columns"] as $key => $val) {
|
|
|
|
$return[] = idf_escape($val) . (($has_desc ? $index["descs"][$key] : $desc) ? " DESC" : "");
|
2009-07-28 14:31:03 +00:00
|
|
|
}
|
|
|
|
return $return;
|
2009-07-28 14:21:05 +00:00
|
|
|
}
|
|
|
|
}
|
2009-07-28 14:31:03 +00:00
|
|
|
return array();
|
2009-07-27 14:40:55 +00:00
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2009-07-27 14:40:55 +00:00
|
|
|
function selectLimitProcess() {
|
2013-04-15 21:45:49 +00:00
|
|
|
return (isset($_GET["limit"]) ? $_GET["limit"] : "50");
|
2009-07-27 14:40:55 +00:00
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2009-07-27 14:40:55 +00:00
|
|
|
function selectLengthProcess() {
|
|
|
|
return "100";
|
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2009-09-09 20:19:27 +00:00
|
|
|
function selectEmailProcess($where, $foreignKeys) {
|
2009-09-09 20:47:42 +00:00
|
|
|
if ($_POST["email_append"]) {
|
|
|
|
return true;
|
|
|
|
}
|
2009-07-27 11:25:37 +00:00
|
|
|
if ($_POST["email"]) {
|
|
|
|
$sent = 0;
|
|
|
|
if ($_POST["all"] || $_POST["check"]) {
|
|
|
|
$field = idf_escape($_POST["email_field"]);
|
2009-09-09 15:54:02 +00:00
|
|
|
$subject = $_POST["email_subject"];
|
2010-04-21 12:01:32 +00:00
|
|
|
$message = $_POST["email_message"];
|
2018-02-20 15:27:40 +00:00
|
|
|
preg_match_all('~\{\$([a-z0-9_]+)\}~i', "$subject.$message", $matches); // allows {$name} in subject or message
|
2011-02-24 13:48:40 +00:00
|
|
|
$rows = get_rows("SELECT DISTINCT $field" . ($matches[1] ? ", " . implode(", ", array_map('idf_escape', array_unique($matches[1]))) : "") . " FROM " . table($_GET["select"])
|
2009-07-27 11:25:37 +00:00
|
|
|
. " WHERE $field IS NOT NULL AND $field != ''"
|
|
|
|
. ($where ? " AND " . implode(" AND ", $where) : "")
|
|
|
|
. ($_POST["all"] ? "" : " AND ((" . implode(") OR (", array_map('where_check', (array) $_POST["check"])) . "))")
|
|
|
|
);
|
2009-11-26 14:19:09 +00:00
|
|
|
$fields = fields($_GET["select"]);
|
2009-09-09 20:19:27 +00:00
|
|
|
foreach ($this->rowDescriptions($rows, $foreignKeys) as $row) {
|
2010-04-21 12:01:32 +00:00
|
|
|
$replace = array('{\\' => '{'); // allow literal {$name}
|
2009-09-09 15:54:02 +00:00
|
|
|
foreach ($matches[1] as $val) {
|
2010-04-21 12:01:32 +00:00
|
|
|
$replace['{$' . "$val}"] = $this->editVal($row[$val], $fields[$val]);
|
2009-09-09 15:54:02 +00:00
|
|
|
}
|
|
|
|
$email = $row[$_POST["email_field"]];
|
2010-10-16 13:47:51 +00:00
|
|
|
if (is_mail($email) && send_mail($email, strtr($subject, $replace), strtr($message, $replace), $_POST["email_from"], $_FILES["email_files"])) {
|
2009-07-27 11:25:37 +00:00
|
|
|
$sent++;
|
|
|
|
}
|
2009-07-24 10:55:01 +00:00
|
|
|
}
|
2009-07-24 10:52:24 +00:00
|
|
|
}
|
2009-09-09 20:49:30 +00:00
|
|
|
cookie("adminer_email", $_POST["email_from"]);
|
2009-07-27 11:25:37 +00:00
|
|
|
redirect(remove_from_uri(), lang('%d e-mail(s) have been sent.', $sent));
|
2009-07-24 10:52:24 +00:00
|
|
|
}
|
2009-07-27 11:25:37 +00:00
|
|
|
return false;
|
2009-07-24 10:52:24 +00:00
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2012-08-24 05:17:44 +00:00
|
|
|
function selectQueryBuild($select, $where, $group, $order, $limit, $page) {
|
|
|
|
return "";
|
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2018-02-01 12:12:05 +00:00
|
|
|
function messageQuery($query, $time, $failed = false) {
|
2014-03-07 17:33:37 +00:00
|
|
|
return " <span class='time'>" . @date("H:i:s") . "</span><!--\n" . str_replace("--", "--><!-- ", $query) . "\n" . ($time ? "($time)\n" : "") . "-->";
|
2009-07-27 11:25:37 +00:00
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2009-07-27 11:25:37 +00:00
|
|
|
function editFunctions($field) {
|
2011-01-10 15:56:51 +00:00
|
|
|
$return = array();
|
2013-07-24 23:26:41 +00:00
|
|
|
if ($field["null"] && preg_match('~blob~', $field["type"])) {
|
2011-01-10 15:56:51 +00:00
|
|
|
$return["NULL"] = lang('empty');
|
|
|
|
}
|
2011-03-24 10:37:05 +00:00
|
|
|
$return[""] = ($field["null"] || $field["auto_increment"] || like_bool($field) ? "" : "*");
|
2010-04-21 12:01:32 +00:00
|
|
|
//! respect driver
|
2013-07-24 23:26:41 +00:00
|
|
|
if (preg_match('~date|time~', $field["type"])) {
|
2010-06-18 14:38:55 +00:00
|
|
|
$return["now"] = lang('now');
|
2009-08-04 13:55:29 +00:00
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
if (preg_match('~_(md5|sha1)$~i', $field["field"], $match)) {
|
2009-09-22 09:59:53 +00:00
|
|
|
$return[] = strtolower($match[1]);
|
2009-09-19 19:58:12 +00:00
|
|
|
}
|
2009-08-04 13:55:29 +00:00
|
|
|
return $return;
|
2009-07-27 11:25:37 +00:00
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2009-07-28 10:09:05 +00:00
|
|
|
function editInput($table, $field, $attrs, $value) {
|
2009-11-12 15:25:21 +00:00
|
|
|
if ($field["type"] == "enum") {
|
2010-10-22 22:28:48 +00:00
|
|
|
return (isset($_GET["select"]) ? "<label><input type='radio'$attrs value='-1' checked><i>" . lang('original') . "</i></label> " : "")
|
2011-01-21 16:36:56 +00:00
|
|
|
. enum_input("radio", $attrs, $field, ($value || isset($_GET["select"]) ? $value : 0), ($field["null"] ? "" : null))
|
2010-10-22 22:28:48 +00:00
|
|
|
;
|
2009-11-12 15:25:21 +00:00
|
|
|
}
|
2011-05-04 13:53:26 +00:00
|
|
|
$options = $this->_foreignKeyOptions($table, $field["field"], $value);
|
2012-05-14 06:54:07 +00:00
|
|
|
if ($options !== null) {
|
2011-05-04 13:53:26 +00:00
|
|
|
return (is_array($options)
|
|
|
|
? "<select$attrs>" . optionlist($options, $value, true) . "</select>"
|
2018-01-22 12:51:47 +00:00
|
|
|
: "<input value='" . h($value) . "'$attrs class='hidden'>"
|
2018-01-13 08:07:18 +00:00
|
|
|
. "<input value='" . h($options) . "' class='jsonly'>"
|
|
|
|
. "<div></div>"
|
|
|
|
. script("qsl('input').oninput = partial(whisper, '" . ME . "script=complete&source=" . urlencode($table) . "&field=" . urlencode($field["field"]) . "&value=');
|
|
|
|
qsl('div').onclick = whisperClick;", "")
|
2011-05-04 13:53:26 +00:00
|
|
|
);
|
2009-07-23 14:42:38 +00:00
|
|
|
}
|
2011-03-24 10:37:05 +00:00
|
|
|
if (like_bool($field)) {
|
2018-05-06 09:26:43 +00:00
|
|
|
return '<input type="checkbox" value="' . h($value ? $value : 1) . '"' . (preg_match('~^(1|t|true|y|yes|on)$~i', $value) ? ' checked' : '') . "$attrs>";
|
2009-07-28 10:09:05 +00:00
|
|
|
}
|
2011-03-18 13:29:36 +00:00
|
|
|
$hint = "";
|
2013-07-24 23:26:41 +00:00
|
|
|
if (preg_match('~time~', $field["type"])) {
|
2011-03-18 13:29:36 +00:00
|
|
|
$hint = lang('HH:MM:SS');
|
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
if (preg_match('~date|timestamp~', $field["type"])) {
|
2011-03-18 13:29:36 +00:00
|
|
|
$hint = lang('[yyyy]-mm-dd') . ($hint ? " [$hint]" : "");
|
|
|
|
}
|
|
|
|
if ($hint) {
|
|
|
|
return "<input value='" . h($value) . "'$attrs> ($hint)"; //! maxlength
|
2009-08-18 09:36:32 +00:00
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
if (preg_match('~_(md5|sha1)$~i', $field["field"])) {
|
2011-01-25 15:40:33 +00:00
|
|
|
return "<input type='password' value='" . h($value) . "'$attrs>";
|
|
|
|
}
|
2009-07-28 10:09:05 +00:00
|
|
|
return '';
|
2009-07-23 14:42:38 +00:00
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2017-10-01 15:45:17 +00:00
|
|
|
function editHint($table, $field, $value) {
|
|
|
|
return (preg_match('~\s+(\[.*\])$~', ($field["comment"] != "" ? $field["comment"] : $field["field"]), $match) ? h(" $match[1]") : '');
|
|
|
|
}
|
|
|
|
|
2009-07-27 16:32:56 +00:00
|
|
|
function processInput($field, $value, $function = "") {
|
2009-08-04 13:55:29 +00:00
|
|
|
if ($function == "now") {
|
|
|
|
return "$function()";
|
|
|
|
}
|
2009-11-12 13:40:46 +00:00
|
|
|
$return = $value;
|
2018-02-20 15:27:40 +00:00
|
|
|
if (preg_match('~date|timestamp~', $field["type"]) && preg_match('(^' . str_replace('\$1', '(?P<p1>\d*)', preg_replace('~(\\\\\\$([2-6]))~', '(?P<p\2>\d{1,2})', preg_quote(lang('$1-$3-$5')))) . '(.*))', $value, $match)) {
|
2010-01-09 23:33:41 +00:00
|
|
|
$return = ($match["p1"] != "" ? $match["p1"] : ($match["p2"] != "" ? ($match["p2"] < 70 ? 20 : 19) . $match["p2"] : gmdate("Y"))) . "-$match[p3]$match[p4]-$match[p5]$match[p6]" . end($match);
|
2009-11-12 13:40:46 +00:00
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
$return = ($field["type"] == "bit" && preg_match('~^[0-9]+$~', $value) ? $return : q($return));
|
2012-08-12 05:59:20 +00:00
|
|
|
if ($value == "" && like_bool($field)) {
|
|
|
|
$return = "0";
|
2013-07-24 23:26:41 +00:00
|
|
|
} elseif ($value == "" && ($field["null"] || !preg_match('~char|text~', $field["type"]))) {
|
2009-07-27 11:25:37 +00:00
|
|
|
$return = "NULL";
|
2013-07-24 23:26:41 +00:00
|
|
|
} elseif (preg_match('~^(md5|sha1)$~', $function)) {
|
2010-04-21 12:01:32 +00:00
|
|
|
$return = "$function($return)";
|
2009-07-27 11:25:37 +00:00
|
|
|
}
|
2012-09-09 05:56:34 +00:00
|
|
|
return unconvert_field($field, $return);
|
2009-07-27 11:25:37 +00:00
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2010-10-29 15:11:00 +00:00
|
|
|
function dumpOutput() {
|
|
|
|
return array();
|
2009-10-02 12:21:55 +00:00
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2010-10-29 15:11:00 +00:00
|
|
|
function dumpFormat() {
|
2010-10-29 16:02:20 +00:00
|
|
|
return array('csv' => 'CSV,', 'csv;' => 'CSV;', 'tsv' => 'TSV');
|
2009-10-02 12:21:55 +00:00
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2013-04-04 01:49:05 +00:00
|
|
|
function dumpDatabase($db) {
|
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2010-10-29 15:03:02 +00:00
|
|
|
function dumpTable() {
|
|
|
|
echo "\xef\xbb\xbf"; // UTF-8 byte order mark
|
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2010-10-29 15:11:00 +00:00
|
|
|
function dumpData($table, $style, $query) {
|
2010-10-29 15:03:02 +00:00
|
|
|
global $connection;
|
2010-10-29 15:11:00 +00:00
|
|
|
$result = $connection->query($query, 1); // 1 - MYSQLI_USE_RESULT
|
2010-10-29 15:03:02 +00:00
|
|
|
if ($result) {
|
|
|
|
while ($row = $result->fetch_assoc()) {
|
2011-03-09 12:11:21 +00:00
|
|
|
if ($style == "table") {
|
|
|
|
dump_csv(array_keys($row));
|
|
|
|
$style = "INSERT";
|
|
|
|
}
|
2010-10-29 15:03:02 +00:00
|
|
|
dump_csv($row);
|
|
|
|
}
|
|
|
|
}
|
2009-10-02 12:21:55 +00:00
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2012-06-29 21:41:47 +00:00
|
|
|
function dumpFilename($identifier) {
|
|
|
|
return friendly_url($identifier);
|
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2011-02-17 10:43:21 +00:00
|
|
|
function dumpHeaders($identifier, $multi_table = false) {
|
2010-10-29 15:03:02 +00:00
|
|
|
$ext = "csv";
|
|
|
|
header("Content-Type: text/csv; charset=utf-8");
|
|
|
|
return $ext;
|
2009-10-02 12:21:55 +00:00
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2017-09-27 16:09:14 +00:00
|
|
|
function importServerPath() {
|
|
|
|
}
|
|
|
|
|
2011-01-06 08:30:07 +00:00
|
|
|
function homepage() {
|
|
|
|
return true;
|
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2009-07-27 11:25:37 +00:00
|
|
|
function navigation($missing) {
|
2013-07-09 06:34:17 +00:00
|
|
|
global $VERSION;
|
2009-09-19 20:16:15 +00:00
|
|
|
?>
|
|
|
|
<h1>
|
2011-04-03 15:27:34 +00:00
|
|
|
<?php echo $this->name(); ?> <span class="version"><?php echo $VERSION; ?></span>
|
2018-01-23 11:53:22 +00:00
|
|
|
<a href="https://www.adminer.org/editor/#download"<?php echo target_blank(); ?> id="version"><?php echo (version_compare($VERSION, $_COOKIE["adminer_version"]) < 0 ? h($_COOKIE["adminer_version"]) : ""); ?></a>
|
2009-09-19 20:16:15 +00:00
|
|
|
</h1>
|
|
|
|
<?php
|
2010-05-06 12:21:22 +00:00
|
|
|
if ($missing == "auth") {
|
|
|
|
$first = true;
|
2013-08-11 01:57:12 +00:00
|
|
|
foreach ((array) $_SESSION["pwds"] as $vendor => $servers) {
|
|
|
|
foreach ($servers[""] as $username => $password) {
|
|
|
|
if ($password !== null) {
|
|
|
|
if ($first) {
|
2018-01-13 08:21:21 +00:00
|
|
|
echo "<p id='logins'>";
|
|
|
|
echo script("mixin(qs('#logins'), {onmouseover: menuOver, onmouseout: menuOut});");
|
2013-08-11 01:57:12 +00:00
|
|
|
$first = false;
|
|
|
|
}
|
|
|
|
echo "<a href='" . h(auth_url($vendor, "", $username)) . "'>" . ($username != "" ? h($username) : "<i>" . lang('empty') . "</i>") . "</a><br>\n";
|
2010-05-06 12:21:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2012-08-21 05:03:39 +00:00
|
|
|
$this->databasesPrint($missing);
|
2010-10-18 00:15:58 +00:00
|
|
|
if ($missing != "db" && $missing != "ns") {
|
2013-04-27 03:04:57 +00:00
|
|
|
$table_status = table_status('', true);
|
2009-09-23 15:01:17 +00:00
|
|
|
if (!$table_status) {
|
|
|
|
echo "<p class='message'>" . lang('No tables.') . "\n";
|
|
|
|
} else {
|
|
|
|
$this->tablesPrint($table_status);
|
|
|
|
}
|
|
|
|
}
|
2009-09-19 20:16:15 +00:00
|
|
|
}
|
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2012-08-21 05:03:39 +00:00
|
|
|
function databasesPrint($missing) {
|
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2009-09-23 15:01:17 +00:00
|
|
|
function tablesPrint($tables) {
|
2018-01-20 22:54:11 +00:00
|
|
|
echo "<ul id='tables'>";
|
2018-01-13 08:21:21 +00:00
|
|
|
echo script("mixin(qs('#tables'), {onmouseover: menuOver, onmouseout: menuOut});");
|
2009-09-23 15:01:17 +00:00
|
|
|
foreach ($tables as $row) {
|
2018-01-20 22:54:11 +00:00
|
|
|
echo '<li>';
|
2009-09-23 15:01:17 +00:00
|
|
|
$name = $this->tableName($row);
|
2010-01-09 23:33:41 +00:00
|
|
|
if (isset($row["Engine"]) && $name != "") { // ignore views and tables without name
|
2014-06-26 10:59:04 +00:00
|
|
|
echo "<a href='" . h(ME) . 'select=' . urlencode($row["Name"]) . "'"
|
|
|
|
. bold($_GET["select"] == $row["Name"] || $_GET["edit"] == $row["Name"], "select")
|
2018-01-20 22:54:11 +00:00
|
|
|
. " title='" . lang('Select data') . "'>$name</a>\n"
|
2014-06-26 10:59:04 +00:00
|
|
|
;
|
2009-07-03 06:26:01 +00:00
|
|
|
}
|
|
|
|
}
|
2018-01-20 22:54:11 +00:00
|
|
|
echo "</ul>\n";
|
2009-07-03 06:26:01 +00:00
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2011-04-08 06:50:33 +00:00
|
|
|
function _foreignColumn($foreignKeys, $column) {
|
2009-11-16 11:06:07 +00:00
|
|
|
foreach ((array) $foreignKeys[$column] as $foreignKey) {
|
|
|
|
if (count($foreignKey["source"]) == 1) {
|
|
|
|
$name = $this->rowDescription($foreignKey["table"]);
|
2010-01-09 23:33:41 +00:00
|
|
|
if ($name != "") {
|
2011-04-08 06:50:33 +00:00
|
|
|
$id = idf_escape($foreignKey["target"][0]);
|
|
|
|
return array($foreignKey["table"], $id, $name);
|
2009-11-16 11:06:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-07-24 23:26:41 +00:00
|
|
|
|
2011-05-04 13:53:26 +00:00
|
|
|
function _foreignKeyOptions($table, $column, $value = null) {
|
|
|
|
global $connection;
|
2011-06-23 20:08:08 +00:00
|
|
|
if (list($target, $id, $name) = $this->_foreignColumn(column_foreign_keys($table), $column)) {
|
|
|
|
$return = &$this->_values[$target];
|
2012-05-14 06:54:07 +00:00
|
|
|
if ($return === null) {
|
2011-06-23 20:08:08 +00:00
|
|
|
$table_status = table_status($target);
|
|
|
|
$return = ($table_status["Rows"] > 1000 ? "" : array("" => "") + get_key_vals("SELECT $id, $name FROM " . table($target) . " ORDER BY 2"));
|
2011-05-05 05:46:36 +00:00
|
|
|
}
|
2012-05-14 06:54:07 +00:00
|
|
|
if (!$return && $value !== null) {
|
2011-06-23 20:08:08 +00:00
|
|
|
return $connection->result("SELECT $name FROM " . table($target) . " WHERE $id = " . q($value));
|
2011-04-08 06:50:33 +00:00
|
|
|
}
|
|
|
|
return $return;
|
|
|
|
}
|
|
|
|
}
|
2010-04-21 12:01:32 +00:00
|
|
|
|
2009-07-03 06:26:01 +00:00
|
|
|
}
|
2009-09-09 11:03:03 +00:00
|
|
|
|
|
|
|
$adminer = (function_exists('adminer_object') ? adminer_object() : new Adminer);
|