" . adminer()->fieldName($field);
79 | $value = idx($_POST["fields"], $name);
80 | if ($value != "") {
81 | if ($field["type"] == "set") {
82 | $value = implode(",", $value);
83 | }
84 | }
85 | input($field, $value, idx($_POST["function"], $name, "")); // param name can be empty
86 | echo "\n";
87 | }
88 | echo "\n";
89 | }
90 | ?>
91 |
92 |
93 |
94 |
95 |
96 |
97 | ', preg_replace('~\|~', '', preg_replace('~\|$~m', "", rtrim($s))));
103 | }
104 |
105 | $table = '(\+--[-+]+\+\n)';
106 | $row = '(\| .* \|\n)';
107 | echo preg_replace_callback(
108 | "~^$table?$row$table?($row*)$table?~m",
109 | function ($match) {
110 | $first_row = pre_tr($match[2]);
111 | return "\n" . ($match[1] ? "$first_row\n" : $first_row) . pre_tr($match[4]) . "\n ";
112 | },
113 | preg_replace(
114 | '~(\n( -|mysql)> )(.+)~',
115 | "\\1\\3 ",
116 | preg_replace('~(.+)\n---+\n~', "\\1\n", h($routine['comment']))
117 | )
118 | );
119 | ?>
120 |
121 |
--------------------------------------------------------------------------------
/adminer/check.inc.php:
--------------------------------------------------------------------------------
1 | $TABLE));
25 |
26 | if (!$row) {
27 | $checks = driver()->checkConstraints($TABLE);
28 | $row = array("name" => $name, "clause" => $checks[$name]);
29 | }
30 | ?>
31 |
32 |
52 |
--------------------------------------------------------------------------------
/adminer/database.inc.php:
--------------------------------------------------------------------------------
1 |
59 |
60 |
82 |
--------------------------------------------------------------------------------
/adminer/designs.php:
--------------------------------------------------------------------------------
1 | select($TABLE, $select, array(where($_GET, $fields)), $select);
10 | $row = ($result ? $result->fetch_row() : array());
11 | echo driver()->value($row[0], $fields[$_GET["field"]]);
12 | exit; // don't output footer
13 |
--------------------------------------------------------------------------------
/adminer/edit.inc.php:
--------------------------------------------------------------------------------
1 | $field) {
12 | if (!isset($field["privileges"][$update ? "update" : "insert"]) || adminer()->fieldName($field) == "" || $field["generated"]) {
13 | unset($fields[$name]);
14 | }
15 | }
16 |
17 | if ($_POST && !$error && !isset($_GET["select"])) {
18 | $location = $_POST["referer"];
19 | if ($_POST["insert"]) { // continue edit or insert
20 | $location = ($update ? null : $_SERVER["REQUEST_URI"]);
21 | } elseif (!preg_match('~^.+&select=.+$~', $location)) {
22 | $location = ME . "select=" . urlencode($TABLE);
23 | }
24 |
25 | $indexes = indexes($TABLE);
26 | $unique_array = unique_array($_GET["where"], $indexes);
27 | $query_where = "\nWHERE $where";
28 |
29 | if (isset($_POST["delete"])) {
30 | queries_redirect(
31 | $location,
32 | lang('Item has been deleted.'),
33 | driver()->delete($TABLE, $query_where, $unique_array ? 0 : 1)
34 | );
35 |
36 | } else {
37 | $set = array();
38 | foreach ($fields as $name => $field) {
39 | $val = process_input($field);
40 | if ($val !== false && $val !== null) {
41 | $set[idf_escape($name)] = $val;
42 | }
43 | }
44 |
45 | if ($update) {
46 | if (!$set) {
47 | redirect($location);
48 | }
49 | queries_redirect(
50 | $location,
51 | lang('Item has been updated.'),
52 | driver()->update($TABLE, $set, $query_where, $unique_array ? 0 : 1)
53 | );
54 | if (is_ajax()) {
55 | page_headers();
56 | page_messages($error);
57 | exit;
58 | }
59 | } else {
60 | $result = driver()->insert($TABLE, $set);
61 | $last_id = ($result ? last_id($result) : 0);
62 | queries_redirect($location, lang('Item%s has been inserted.', ($last_id ? " $last_id" : "")), $result); //! link
63 | }
64 | }
65 | }
66 |
67 | $row = null;
68 | if ($_POST["save"]) {
69 | $row = (array) $_POST["fields"];
70 | } elseif ($where) {
71 | $select = array();
72 | foreach ($fields as $name => $field) {
73 | if (isset($field["privileges"]["select"])) {
74 | $as = ($_POST["clone"] && $field["auto_increment"] ? "''" : convert_field($field));
75 | $select[] = ($as ? "$as AS " : "") . idf_escape($name);
76 | }
77 | }
78 | $row = array();
79 | if (!support("table")) {
80 | $select = array("*");
81 | }
82 | if ($select) {
83 | $result = driver()->select($TABLE, $select, array($where), $select, array(), (isset($_GET["select"]) ? 2 : 1));
84 | if (!$result) {
85 | $error = error();
86 | } else {
87 | $row = $result->fetch_assoc();
88 | if (!$row) { // MySQLi returns null
89 | $row = false;
90 | }
91 | }
92 | if (isset($_GET["select"]) && (!$row || $result->fetch_assoc())) { // $result->num_rows != 1 isn't available in all drivers
93 | $row = null;
94 | }
95 | }
96 | }
97 |
98 | if (!support("table") && !$fields) { // used by Mongo and SimpleDB
99 | if (!$where) { // insert
100 | $result = driver()->select($TABLE, array("*"), array(), array("*"));
101 | $row = ($result ? $result->fetch_assoc() : false);
102 | if (!$row) {
103 | $row = array(driver()->primary => "");
104 | }
105 | }
106 | if ($row) {
107 | foreach ($row as $key => $val) {
108 | if (!$where) {
109 | $row[$key] = null;
110 | }
111 | $fields[$key] = array("field" => $key, "null" => ($key != driver()->primary), "auto_increment" => ($key == driver()->primary));
112 | }
113 | }
114 | }
115 |
116 | edit_form($TABLE, $fields, $row, $update, $error);
117 |
--------------------------------------------------------------------------------
/adminer/elastic.php:
--------------------------------------------------------------------------------
1 | "ENABLE", "DISABLED" => "DISABLE", "SLAVESIDE_DISABLED" => "DISABLE ON SLAVE");
7 | $row = $_POST;
8 |
9 | if ($_POST && !$error) {
10 | if ($_POST["drop"]) {
11 | query_redirect("DROP EVENT " . idf_escape($EVENT), substr(ME, 0, -1), lang('Event has been dropped.'));
12 | } elseif (in_array($row["INTERVAL_FIELD"], $intervals) && isset($statuses[$row["STATUS"]])) {
13 | $schedule = "\nON SCHEDULE " . ($row["INTERVAL_VALUE"]
14 | ? "EVERY " . q($row["INTERVAL_VALUE"]) . " $row[INTERVAL_FIELD]"
15 | . ($row["STARTS"] ? " STARTS " . q($row["STARTS"]) : "")
16 | . ($row["ENDS"] ? " ENDS " . q($row["ENDS"]) : "") //! ALTER EVENT doesn't drop ENDS - MySQL bug #39173
17 | : "AT " . q($row["STARTS"])
18 | ) . " ON COMPLETION" . ($row["ON_COMPLETION"] ? "" : " NOT") . " PRESERVE"
19 | ;
20 |
21 | queries_redirect(
22 | substr(ME, 0, -1),
23 | ($EVENT != "" ? lang('Event has been altered.') : lang('Event has been created.')),
24 | queries(
25 | ($EVENT != ""
26 | ? "ALTER EVENT " . idf_escape($EVENT) . $schedule . ($EVENT != $row["EVENT_NAME"] ? "\nRENAME TO " . idf_escape($row["EVENT_NAME"]) : "")
27 | : "CREATE EVENT " . idf_escape($row["EVENT_NAME"]) . $schedule
28 | ) . "\n" . $statuses[$row["STATUS"]] . " COMMENT " . q($row["EVENT_COMMENT"])
29 | . rtrim(" DO\n$row[EVENT_DEFINITION]", ";") . ";"
30 | )
31 | );
32 | }
33 | }
34 |
35 | page_header(($EVENT != "" ? lang('Alter event') . ": " . h($EVENT) : lang('Create event')), $error);
36 |
37 | if (!$row && $EVENT != "") {
38 | $rows = get_rows("SELECT * FROM information_schema.EVENTS WHERE EVENT_SCHEMA = " . q(DB) . " AND EVENT_NAME = " . q($EVENT));
39 | $row = reset($rows);
40 | }
41 | ?>
42 |
43 |
61 |
--------------------------------------------------------------------------------
/adminer/file.inc.php:
--------------------------------------------------------------------------------
1 | $val) {
14 | $target[$key] = $row["target"][$key];
15 | }
16 | $row["target"] = $target;
17 | }
18 |
19 | if (JUSH == "sqlite") {
20 | $result = recreate_table($TABLE, $TABLE, array(), array(), array(" $name" => ($row["drop"] ? "" : " " . format_foreign_key($row))));
21 | } else {
22 | $alter = "ALTER TABLE " . table($TABLE);
23 | $result = ($name == "" || queries("$alter DROP " . (JUSH == "sql" ? "FOREIGN KEY " : "CONSTRAINT ") . idf_escape($name)));
24 | if (!$row["drop"]) {
25 | $result = queries("$alter ADD" . format_foreign_key($row));
26 | }
27 | }
28 | queries_redirect(
29 | ME . "table=" . urlencode($TABLE),
30 | ($row["drop"] ? lang('Foreign key has been dropped.') : ($name != "" ? lang('Foreign key has been altered.') : lang('Foreign key has been created.'))),
31 | $result
32 | );
33 | if (!$row["drop"]) {
34 | $error = lang('Source and target columns must have the same data type, there must be an index on the target columns and referenced data must exist.'); //! no partitioning
35 | }
36 | }
37 |
38 | page_header(lang('Foreign key'), $error, array("table" => $TABLE), h($TABLE));
39 |
40 | if ($_POST) {
41 | ksort($row["source"]);
42 | if ($_POST["add"]) {
43 | $row["source"][] = "";
44 | } elseif ($_POST["change"] || $_POST["change-js"]) {
45 | $row["target"] = array();
46 | }
47 | } elseif ($name != "") {
48 | $foreign_keys = foreign_keys($TABLE);
49 | $row = $foreign_keys[$name];
50 | $row["source"][] = "";
51 | } else {
52 | $row["table"] = $TABLE;
53 | $row["source"] = array("");
54 | }
55 | ?>
56 |
57 |
121 |
--------------------------------------------------------------------------------
/adminer/include/bootstrap.inc.php:
--------------------------------------------------------------------------------
1 | $_POST["signature"], "version" => $_POST["version"])));
38 | }
39 | exit;
40 | }
41 |
42 | // Adminer doesn't use any global variables; they used to be declared here
43 |
44 | if (!$_SERVER["REQUEST_URI"]) { // IIS 5 compatibility
45 | $_SERVER["REQUEST_URI"] = $_SERVER["ORIG_PATH_INFO"];
46 | }
47 | if (!strpos($_SERVER["REQUEST_URI"], '?') && $_SERVER["QUERY_STRING"] != "") { // IIS 7 compatibility
48 | $_SERVER["REQUEST_URI"] .= "?$_SERVER[QUERY_STRING]";
49 | }
50 | if ($_SERVER["HTTP_X_FORWARDED_PREFIX"]) {
51 | $_SERVER["REQUEST_URI"] = $_SERVER["HTTP_X_FORWARDED_PREFIX"] . $_SERVER["REQUEST_URI"];
52 | }
53 | define('Adminer\HTTPS', ($_SERVER["HTTPS"] && strcasecmp($_SERVER["HTTPS"], "off")) || ini_bool("session.cookie_secure")); // session.cookie_secure could be set on HTTP if we are behind a reverse proxy
54 |
55 | @ini_set("session.use_trans_sid", '0'); // protect links in export, @ - may be disabled
56 | if (!defined("SID")) {
57 | session_cache_limiter(""); // to allow restarting session
58 | session_name("adminer_sid"); // use specific session name to get own namespace
59 | session_set_cookie_params(0, preg_replace('~\?.*~', '', $_SERVER["REQUEST_URI"]), "", HTTPS, true); // ini_set() may be disabled
60 | session_start();
61 | }
62 |
63 | // disable magic quotes to be able to use database escaping function
64 | remove_slashes(array(&$_GET, &$_POST, &$_COOKIE), $filter);
65 | if (function_exists("get_magic_quotes_runtime") && get_magic_quotes_runtime()) {
66 | set_magic_quotes_runtime(false);
67 | }
68 | @set_time_limit(0); // @ - can be disabled
69 | @ini_set("precision", '15'); // @ - can be disabled, 15 - internal PHP precision
70 |
71 | include "../adminer/include/lang.inc.php";
72 | include "../adminer/lang/" . LANG . ".inc.php";
73 | include "../adminer/include/db.inc.php";
74 | include "../adminer/include/pdo.inc.php";
75 | include "../adminer/include/driver.inc.php";
76 | include "../adminer/drivers/sqlite.inc.php";
77 | include "../adminer/drivers/pgsql.inc.php";
78 | include "../adminer/drivers/oracle.inc.php";
79 | include "../adminer/drivers/mssql.inc.php";
80 | include "./include/adminer.inc.php";
81 | include "../adminer/include/plugins.inc.php";
82 | include "../adminer/include/plugin.inc.php";
83 |
84 | Adminer::$instance =
85 | (function_exists('adminer_object') ? adminer_object() :
86 | (is_dir("adminer-plugins") || file_exists("adminer-plugins.php") ? new Plugins(null) :
87 | new Adminer
88 | ));
89 |
90 | // this is matched by compile.php
91 | include "../adminer/drivers/mysql.inc.php"; // must be included as last driver
92 |
93 | define('Adminer\JUSH', Driver::$jush);
94 | define('Adminer\SERVER', $_GET[DRIVER]); // read from pgsql=localhost, '' means default server, null means no server
95 | define('Adminer\DB', $_GET["db"]); // for the sake of speed and size
96 | define(
97 | 'Adminer\ME',
98 | preg_replace('~\?.*~', '', relative_uri()) . '?'
99 | . (sid() ? SID . '&' : '')
100 | . (SERVER !== null ? DRIVER . "=" . urlencode(SERVER) . '&' : '')
101 | . ($_GET["ext"] ? "ext=" . urlencode($_GET["ext"]) . '&' : '')
102 | . (isset($_GET["username"]) ? "username=" . urlencode($_GET["username"]) . '&' : '')
103 | . (DB != "" ? 'db=' . urlencode(DB) . '&' . (isset($_GET["ns"]) ? "ns=" . urlencode($_GET["ns"]) . "&" : "") : '')
104 | );
105 |
106 | include "../adminer/include/design.inc.php";
107 | include "../adminer/include/xxtea.inc.php";
108 | include "../adminer/include/auth.inc.php";
109 | include "./include/editing.inc.php";
110 | include "./include/connect.inc.php";
111 |
--------------------------------------------------------------------------------
/adminer/include/coverage.inc.php:
--------------------------------------------------------------------------------
1 | $lines) {
10 | foreach ($lines as $l => $val) {
11 | if (!idx($coverage[$filename], $l) || $val > 0) {
12 | $coverage[$filename][$l] = $val;
13 | }
14 | }
15 | file_put_contents($coverage_filename, serialize($coverage));
16 | }
17 | }
18 | xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE);
19 | register_shutdown_function('Adminer\save_coverage');
20 | }
21 |
--------------------------------------------------------------------------------
/adminer/include/db.inc.php:
--------------------------------------------------------------------------------
1 | multi = $this->query($query);
43 | }
44 |
45 | /** Get current resultset
46 | * @return Result|bool
47 | */
48 | function store_result() {
49 | return $this->multi;
50 | }
51 |
52 | /** Fetch next resultset */
53 | function next_result(): bool {
54 | return false;
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/adminer/include/errors.inc.php:
--------------------------------------------------------------------------------
1 | pdo = new \PDO($dsn, $username, $password, $options);
18 | } catch (\Exception $ex) {
19 | return $ex->getMessage();
20 | }
21 | $this->server_info = @$this->pdo->getAttribute(\PDO::ATTR_SERVER_VERSION);
22 | return '';
23 | }
24 |
25 | function quote(string $string): string {
26 | return $this->pdo->quote($string);
27 | }
28 |
29 | function query(string $query, bool $unbuffered = false) {
30 | /** @var Result|bool */
31 | $result = $this->pdo->query($query);
32 | $this->error = "";
33 | if (!$result) {
34 | list(, $this->errno, $this->error) = $this->pdo->errorInfo();
35 | if (!$this->error) {
36 | $this->error = lang('Unknown error.');
37 | }
38 | return false;
39 | }
40 | $this->store_result($result);
41 | return $result;
42 | }
43 |
44 | function store_result($result = null) {
45 | if (!$result) {
46 | $result = $this->multi;
47 | if (!$result) {
48 | return false;
49 | }
50 | }
51 | if ($result->columnCount()) {
52 | $result->num_rows = $result->rowCount(); // is not guaranteed to work with all drivers
53 | return $result;
54 | }
55 | $this->affected_rows = $result->rowCount();
56 | return true;
57 | }
58 |
59 | function next_result(): bool {
60 | /** @var PdoResult|bool */
61 | $result = $this->multi;
62 | if (!is_object($result)) {
63 | return false;
64 | }
65 | $result->_offset = 0;
66 | return @$result->nextRowset(); // @ - PDO_PgSQL doesn't support it
67 | }
68 | }
69 |
70 | class PdoResult extends \PDOStatement {
71 | public $_offset = 0, $num_rows;
72 |
73 | function fetch_assoc() {
74 | return $this->fetch_array(\PDO::FETCH_ASSOC);
75 | }
76 |
77 | function fetch_row() {
78 | return $this->fetch_array(\PDO::FETCH_NUM);
79 | }
80 |
81 | private function fetch_array(int $mode) {
82 | $return = $this->fetch($mode);
83 | return ($return ? array_map(array($this, 'unresource'), $return) : $return);
84 | }
85 |
86 | private function unresource($val) {
87 | return (is_resource($val) ? stream_get_contents($val) : $val);
88 | }
89 |
90 | function fetch_field(): \stdClass {
91 | $row = (object) $this->getColumnMeta($this->_offset++);
92 | $type = $row->pdo_type;
93 | $row->type = ($type == \PDO::PARAM_INT ? 0 : 15);
94 | $row->charsetnr = ($type == \PDO::PARAM_LOB || (isset($row->flags) && in_array("blob", (array) $row->flags)) ? 63 : 0);
95 | return $row;
96 | }
97 |
98 | function seek($offset) {
99 | for ($i=0; $i < $offset; $i++) {
100 | $this->fetch();
101 | }
102 | }
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/adminer/include/plugin.inc.php:
--------------------------------------------------------------------------------
1 | >[] */ protected $translations = array(); // key is language code
7 |
8 | /** Get plain text plugin description; empty string means to use the first line of class doc-comment
9 | * @return string
10 | */
11 | function description() {
12 | return $this->lang('');
13 | }
14 |
15 | /** Get URL of plugin screenshot
16 | * @return string
17 | */
18 | function screenshot() {
19 | return "";
20 | }
21 |
22 | /** Translate a string from $this->translations; Adminer\lang() doesn't work for single language versions
23 | * @param literal-string $idf
24 | * @param float|string $number
25 | */
26 | protected function lang(string $idf, $number = null): string {
27 | $args = func_get_args();
28 | $args[0] = idx($this->translations[LANG], $idf) ?: $idf;
29 | return call_user_func_array('Adminer\lang_format', $args);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/adminer/include/plugins.inc.php:
--------------------------------------------------------------------------------
1 | true, 'dumpOutput' => true, 'editRowPrint' => true, 'editFunctions' => true, 'config' => true); // these hooks expect the value to be appended to the result
6 |
7 | /** @var list | |