ARI Adminer – WordPress Database Manager - Version 1.0.1

Version Description

  • Added PostgreSQL support
Download this release

Release Info

Developer arisoft
Plugin Icon 128x128 ARI Adminer – WordPress Database Manager
Version 1.0.1
Comparing to
See all releases

Version 1.0.1

Files changed (111) hide show
  1. adminer/adminer/.htaccess +4 -0
  2. adminer/adminer/adminer/call.inc.php +85 -0
  3. adminer/adminer/adminer/create.inc.php +226 -0
  4. adminer/adminer/adminer/database.inc.php +79 -0
  5. adminer/adminer/adminer/db.inc.php +228 -0
  6. adminer/adminer/adminer/download.inc.php +10 -0
  7. adminer/adminer/adminer/drivers/elastic.inc.php +374 -0
  8. adminer/adminer/adminer/drivers/firebird.inc.php +320 -0
  9. adminer/adminer/adminer/drivers/mongo.inc.php +357 -0
  10. adminer/adminer/adminer/drivers/mssql.inc.php +641 -0
  11. adminer/adminer/adminer/drivers/mysql.inc.php +1057 -0
  12. adminer/adminer/adminer/drivers/oracle.inc.php +430 -0
  13. adminer/adminer/adminer/drivers/pgsql.inc.php +674 -0
  14. adminer/adminer/adminer/drivers/simpledb.inc.php +473 -0
  15. adminer/adminer/adminer/drivers/sqlite.inc.php +784 -0
  16. adminer/adminer/adminer/dump.inc.php +220 -0
  17. adminer/adminer/adminer/edit.inc.php +113 -0
  18. adminer/adminer/adminer/event.inc.php +52 -0
  19. adminer/adminer/adminer/file.inc.php +32 -0
  20. adminer/adminer/adminer/foreign.inc.php +89 -0
  21. adminer/adminer/adminer/include/adminer.inc.php +907 -0
  22. adminer/adminer/adminer/include/auth.inc.php +204 -0
  23. adminer/adminer/adminer/include/bootstrap.inc.php +95 -0
  24. adminer/adminer/adminer/include/connect.inc.php +98 -0
  25. adminer/adminer/adminer/include/coverage.inc.php +18 -0
  26. adminer/adminer/adminer/include/design.inc.php +137 -0
  27. adminer/adminer/adminer/include/driver.inc.php +110 -0
  28. adminer/adminer/adminer/include/editing.inc.php +539 -0
  29. adminer/adminer/adminer/include/functions.inc.php +1393 -0
  30. adminer/adminer/adminer/include/lang.inc.php +123 -0
  31. adminer/adminer/adminer/include/pdo.inc.php +96 -0
  32. adminer/adminer/adminer/include/tmpfile.inc.php +22 -0
  33. adminer/adminer/adminer/include/version.inc.php +2 -0
  34. adminer/adminer/adminer/include/xxtea.inc.php +107 -0
  35. adminer/adminer/adminer/index.php +79 -0
  36. adminer/adminer/adminer/indexes.inc.php +140 -0
  37. adminer/adminer/adminer/lang/ar.inc.php +268 -0
  38. adminer/adminer/adminer/lang/bg.inc.php +338 -0
  39. adminer/adminer/adminer/lang/bn.inc.php +268 -0
  40. adminer/adminer/adminer/lang/bs.inc.php +322 -0
  41. adminer/adminer/adminer/lang/ca.inc.php +269 -0
  42. adminer/adminer/adminer/lang/cs.inc.php +340 -0
  43. adminer/adminer/adminer/lang/da.inc.php +283 -0
  44. adminer/adminer/adminer/lang/de.inc.php +289 -0
  45. adminer/adminer/adminer/lang/el.inc.php +338 -0
  46. adminer/adminer/adminer/lang/en.inc.php +15 -0
  47. adminer/adminer/adminer/lang/es.inc.php +269 -0
  48. adminer/adminer/adminer/lang/et.inc.php +269 -0
  49. adminer/adminer/adminer/lang/fa.inc.php +336 -0
  50. adminer/adminer/adminer/lang/fi.inc.php +338 -0
  51. adminer/adminer/adminer/lang/fr.inc.php +293 -0
  52. adminer/adminer/adminer/lang/gl.inc.php +293 -0
  53. adminer/adminer/adminer/lang/hu.inc.php +268 -0
  54. adminer/adminer/adminer/lang/id.inc.php +317 -0
  55. adminer/adminer/adminer/lang/it.inc.php +269 -0
  56. adminer/adminer/adminer/lang/ja.inc.php +268 -0
  57. adminer/adminer/adminer/lang/ko.inc.php +268 -0
  58. adminer/adminer/adminer/lang/lt.inc.php +313 -0
  59. adminer/adminer/adminer/lang/nl.inc.php +269 -0
  60. adminer/adminer/adminer/lang/no.inc.php +283 -0
  61. adminer/adminer/adminer/lang/pl.inc.php +336 -0
  62. adminer/adminer/adminer/lang/pt-br.inc.php +264 -0
  63. adminer/adminer/adminer/lang/pt.inc.php +264 -0
  64. adminer/adminer/adminer/lang/ro.inc.php +269 -0
  65. adminer/adminer/adminer/lang/ru.inc.php +269 -0
  66. adminer/adminer/adminer/lang/sk.inc.php +269 -0
  67. adminer/adminer/adminer/lang/sl.inc.php +308 -0
  68. adminer/adminer/adminer/lang/sr.inc.php +320 -0
  69. adminer/adminer/adminer/lang/ta.inc.php +268 -0
  70. adminer/adminer/adminer/lang/th.inc.php +269 -0
  71. adminer/adminer/adminer/lang/tr.inc.php +320 -0
  72. adminer/adminer/adminer/lang/uk.inc.php +317 -0
  73. adminer/adminer/adminer/lang/vi.inc.php +329 -0
  74. adminer/adminer/adminer/lang/xx.inc.php +340 -0
  75. adminer/adminer/adminer/lang/zh-tw.inc.php +268 -0
  76. adminer/adminer/adminer/lang/zh.inc.php +268 -0
  77. adminer/adminer/adminer/plugin.php +43 -0
  78. adminer/adminer/adminer/privileges.inc.php +29 -0
  79. adminer/adminer/adminer/procedure.inc.php +54 -0
  80. adminer/adminer/adminer/processlist.inc.php +56 -0
  81. adminer/adminer/adminer/schema.inc.php +110 -0
  82. adminer/adminer/adminer/scheme.inc.php +38 -0
  83. adminer/adminer/adminer/script.inc.php +45 -0
  84. adminer/adminer/adminer/select.inc.php +540 -0
  85. adminer/adminer/adminer/sequence.inc.php +35 -0
  86. adminer/adminer/adminer/sql.inc.php +250 -0
  87. adminer/adminer/adminer/static/arrow.gif +0 -0
  88. adminer/adminer/adminer/static/cross.gif +0 -0
  89. adminer/adminer/adminer/static/default.css +99 -0
  90. adminer/adminer/adminer/static/down.gif +0 -0
  91. adminer/adminer/adminer/static/editing.js +616 -0
  92. adminer/adminer/adminer/static/favicon.ico +0 -0
  93. adminer/adminer/adminer/static/functions.js +795 -0
  94. adminer/adminer/adminer/static/plus.gif +0 -0
  95. adminer/adminer/adminer/static/up.gif +0 -0
  96. adminer/adminer/adminer/table.inc.php +89 -0
  97. adminer/adminer/adminer/trigger.inc.php +49 -0
  98. adminer/adminer/adminer/type.inc.php +33 -0
  99. adminer/adminer/adminer/user.inc.php +185 -0
  100. adminer/adminer/adminer/variables.inc.php +16 -0
  101. adminer/adminer/adminer/view.inc.php +59 -0
  102. adminer/adminer/editor/db.inc.php +26 -0
  103. adminer/adminer/editor/include/adminer.inc.php +625 -0
  104. adminer/adminer/editor/include/connect.inc.php +2 -0
  105. adminer/adminer/editor/include/editing.inc.php +53 -0
  106. adminer/adminer/editor/index.php +30 -0
  107. adminer/adminer/editor/script.inc.php +16 -0
  108. adminer/adminer/editor/static/editing.js +40 -0
  109. adminer/adminer/externals/JsShrink/jsShrink.php +49 -0
  110. adminer/adminer/externals/jush/jush.css +33 -0
  111. adminer/adminer/externals/jush/modules/jush-cnf.js +19 -0
adminer/adminer/.htaccess ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <FilesMatch ".*\.php$">
2
+ Order Allow,Deny
3
+ Deny from all
4
+ </FilesMatch>
adminer/adminer/adminer/call.inc.php ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $PROCEDURE = $_GET["call"];
3
+ page_header(lang('Call') . ": " . h($PROCEDURE), $error);
4
+
5
+ $routine = routine($PROCEDURE, (isset($_GET["callf"]) ? "FUNCTION" : "PROCEDURE"));
6
+ $in = array();
7
+ $out = array();
8
+ foreach ($routine["fields"] as $i => $field) {
9
+ if (substr($field["inout"], -3) == "OUT") {
10
+ $out[$i] = "@" . idf_escape($field["field"]) . " AS " . idf_escape($field["field"]);
11
+ }
12
+ if (!$field["inout"] || substr($field["inout"], 0, 2) == "IN") {
13
+ $in[] = $i;
14
+ }
15
+ }
16
+
17
+ if (!$error && $_POST) {
18
+ $call = array();
19
+ foreach ($routine["fields"] as $key => $field) {
20
+ if (in_array($key, $in)) {
21
+ $val = process_input($field);
22
+ if ($val === false) {
23
+ $val = "''";
24
+ }
25
+ if (isset($out[$key])) {
26
+ $connection->query("SET @" . idf_escape($field["field"]) . " = $val");
27
+ }
28
+ }
29
+ $call[] = (isset($out[$key]) ? "@" . idf_escape($field["field"]) : $val);
30
+ }
31
+
32
+ $query = (isset($_GET["callf"]) ? "SELECT" : "CALL") . " " . idf_escape($PROCEDURE) . "(" . implode(", ", $call) . ")";
33
+ echo "<p><code class='jush-$jush'>" . h($query) . "</code> <a href='" . h(ME) . "sql=" . urlencode($query) . "'>" . lang('Edit') . "</a>\n";
34
+
35
+ if (!$connection->multi_query($query)) {
36
+ echo "<p class='error'>" . error() . "\n";
37
+ } else {
38
+ $connection2 = connect();
39
+ if (is_object($connection2)) {
40
+ $connection2->select_db(DB);
41
+ }
42
+
43
+ do {
44
+ $result = $connection->store_result();
45
+ if (is_object($result)) {
46
+ select($result, $connection2);
47
+ } else {
48
+ echo "<p class='message'>" . lang('Routine has been called, %d row(s) affected.', $connection->affected_rows) . "\n";
49
+ }
50
+ } while ($connection->next_result());
51
+
52
+ if ($out) {
53
+ select($connection->query("SELECT " . implode(", ", $out)));
54
+ }
55
+ }
56
+ }
57
+ ?>
58
+
59
+ <form action="" method="post">
60
+ <?php
61
+ if ($in) {
62
+ echo "<table cellspacing='0'>\n";
63
+ foreach ($in as $key) {
64
+ $field = $routine["fields"][$key];
65
+ $name = $field["field"];
66
+ echo "<tr><th>" . $adminer->fieldName($field);
67
+ $value = $_POST["fields"][$name];
68
+ if ($value != "") {
69
+ if ($field["type"] == "enum") {
70
+ $value = +$value;
71
+ }
72
+ if ($field["type"] == "set") {
73
+ $value = array_sum($value);
74
+ }
75
+ }
76
+ input($field, $value, (string) $_POST["function"][$name]); // param name can be empty
77
+ echo "\n";
78
+ }
79
+ echo "</table>\n";
80
+ }
81
+ ?>
82
+ <p>
83
+ <input type="submit" value="<?php echo lang('Call'); ?>">
84
+ <input type="hidden" name="token" value="<?php echo $token; ?>">
85
+ </form>
adminer/adminer/adminer/create.inc.php ADDED
@@ -0,0 +1,226 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $TABLE = $_GET["create"];
3
+ $partition_by = array();
4
+ foreach (array('HASH', 'LINEAR HASH', 'KEY', 'LINEAR KEY', 'RANGE', 'LIST') as $key) {
5
+ $partition_by[$key] = $key;
6
+ }
7
+
8
+ $referencable_primary = referencable_primary($TABLE);
9
+ $foreign_keys = array();
10
+ foreach ($referencable_primary as $table_name => $field) {
11
+ $foreign_keys[str_replace("`", "``", $table_name) . "`" . str_replace("`", "``", $field["field"])] = $table_name; // not idf_escape() - used in JS
12
+ }
13
+
14
+ $orig_fields = array();
15
+ $table_status = array();
16
+ if ($TABLE != "") {
17
+ $orig_fields = fields($TABLE);
18
+ $table_status = table_status($TABLE);
19
+ if (!$table_status) {
20
+ $error = lang('No tables.');
21
+ }
22
+ }
23
+
24
+ $row = $_POST;
25
+ $row["fields"] = (array) $row["fields"];
26
+ if ($row["auto_increment_col"]) {
27
+ $row["fields"][$row["auto_increment_col"]]["auto_increment"] = true;
28
+ }
29
+
30
+ if ($_POST && !process_fields($row["fields"]) && !$error) {
31
+ if ($_POST["drop"]) {
32
+ queries_redirect(substr(ME, 0, -1), lang('Table has been dropped.'), drop_tables(array($TABLE)));
33
+ } else {
34
+ $fields = array();
35
+ $all_fields = array();
36
+ $use_all_fields = false;
37
+ $foreign = array();
38
+ ksort($row["fields"]);
39
+ $orig_field = reset($orig_fields);
40
+ $after = " FIRST";
41
+
42
+ foreach ($row["fields"] as $key => $field) {
43
+ $foreign_key = $foreign_keys[$field["type"]];
44
+ $type_field = ($foreign_key !== null ? $referencable_primary[$foreign_key] : $field); //! can collide with user defined type
45
+ if ($field["field"] != "") {
46
+ if (!$field["has_default"]) {
47
+ $field["default"] = null;
48
+ }
49
+ if ($key == $row["auto_increment_col"]) {
50
+ $field["auto_increment"] = true;
51
+ }
52
+ $process_field = process_field($field, $type_field);
53
+ $all_fields[] = array($field["orig"], $process_field, $after);
54
+ if ($process_field != process_field($orig_field, $orig_field)) {
55
+ $fields[] = array($field["orig"], $process_field, $after);
56
+ if ($field["orig"] != "" || $after) {
57
+ $use_all_fields = true;
58
+ }
59
+ }
60
+ if ($foreign_key !== null) {
61
+ $foreign[idf_escape($field["field"])] = ($TABLE != "" && $jush != "sqlite" ? "ADD" : " ") . format_foreign_key(array(
62
+ 'table' => $foreign_keys[$field["type"]],
63
+ 'source' => array($field["field"]),
64
+ 'target' => array($type_field["field"]),
65
+ 'on_delete' => $field["on_delete"],
66
+ ));
67
+ }
68
+ $after = " AFTER " . idf_escape($field["field"]);
69
+ } elseif ($field["orig"] != "") {
70
+ $use_all_fields = true;
71
+ $fields[] = array($field["orig"]);
72
+ }
73
+ if ($field["orig"] != "") {
74
+ $orig_field = next($orig_fields);
75
+ if (!$orig_field) {
76
+ $after = "";
77
+ }
78
+ }
79
+ }
80
+
81
+ $partitioning = "";
82
+ if ($partition_by[$row["partition_by"]]) {
83
+ $partitions = array();
84
+ if ($row["partition_by"] == 'RANGE' || $row["partition_by"] == 'LIST') {
85
+ foreach (array_filter($row["partition_names"]) as $key => $val) {
86
+ $value = $row["partition_values"][$key];
87
+ $partitions[] = "\n PARTITION " . idf_escape($val) . " VALUES " . ($row["partition_by"] == 'RANGE' ? "LESS THAN" : "IN") . ($value != "" ? " ($value)" : " MAXVALUE"); //! SQL injection
88
+ }
89
+ }
90
+ $partitioning .= "\nPARTITION BY $row[partition_by]($row[partition])" . ($partitions // $row["partition"] can be expression, not only column
91
+ ? " (" . implode(",", $partitions) . "\n)"
92
+ : ($row["partitions"] ? " PARTITIONS " . (+$row["partitions"]) : "")
93
+ );
94
+ } elseif (support("partitioning") && preg_match("~partitioned~", $table_status["Create_options"])) {
95
+ $partitioning .= "\nREMOVE PARTITIONING";
96
+ }
97
+
98
+ $message = lang('Table has been altered.');
99
+ if ($TABLE == "") {
100
+ cookie("adminer_engine", $row["Engine"]);
101
+ $message = lang('Table has been created.');
102
+ }
103
+ $name = trim($row["name"]);
104
+
105
+ queries_redirect(ME . (support("table") ? "table=" : "select=") . urlencode($name), $message, alter_table(
106
+ $TABLE,
107
+ $name,
108
+ ($jush == "sqlite" && ($use_all_fields || $foreign) ? $all_fields : $fields),
109
+ $foreign,
110
+ ($row["Comment"] != $table_status["Comment"] ? $row["Comment"] : null),
111
+ ($row["Engine"] && $row["Engine"] != $table_status["Engine"] ? $row["Engine"] : ""),
112
+ ($row["Collation"] && $row["Collation"] != $table_status["Collation"] ? $row["Collation"] : ""),
113
+ ($row["Auto_increment"] != "" ? number($row["Auto_increment"]) : ""),
114
+ $partitioning
115
+ ));
116
+ }
117
+ }
118
+
119
+ page_header(($TABLE != "" ? lang('Alter table') : lang('Create table')), $error, array("table" => $TABLE), h($TABLE));
120
+
121
+ if (!$_POST) {
122
+ $row = array(
123
+ "Engine" => $_COOKIE["adminer_engine"],
124
+ "fields" => array(array("field" => "", "type" => (isset($types["int"]) ? "int" : (isset($types["integer"]) ? "integer" : "")))),
125
+ "partition_names" => array(""),
126
+ );
127
+
128
+ if ($TABLE != "") {
129
+ $row = $table_status;
130
+ $row["name"] = $TABLE;
131
+ $row["fields"] = array();
132
+ if (!$_GET["auto_increment"]) { // don't prefill by original Auto_increment for the sake of performance and not reusing deleted ids
133
+ $row["Auto_increment"] = "";
134
+ }
135
+ foreach ($orig_fields as $field) {
136
+ $field["has_default"] = isset($field["default"]);
137
+ $row["fields"][] = $field;
138
+ }
139
+
140
+ if (support("partitioning")) {
141
+ $from = "FROM information_schema.PARTITIONS WHERE TABLE_SCHEMA = " . q(DB) . " AND TABLE_NAME = " . q($TABLE);
142
+ $result = $connection->query("SELECT PARTITION_METHOD, PARTITION_ORDINAL_POSITION, PARTITION_EXPRESSION $from ORDER BY PARTITION_ORDINAL_POSITION DESC LIMIT 1");
143
+ list($row["partition_by"], $row["partitions"], $row["partition"]) = $result->fetch_row();
144
+ $partitions = get_key_vals("SELECT PARTITION_NAME, PARTITION_DESCRIPTION $from AND PARTITION_NAME != '' ORDER BY PARTITION_ORDINAL_POSITION");
145
+ $partitions[""] = "";
146
+ $row["partition_names"] = array_keys($partitions);
147
+ $row["partition_values"] = array_values($partitions);
148
+ }
149
+ }
150
+ }
151
+
152
+ $collations = collations();
153
+ $engines = engines();
154
+ // case of engine may differ
155
+ foreach ($engines as $engine) {
156
+ if (!strcasecmp($engine, $row["Engine"])) {
157
+ $row["Engine"] = $engine;
158
+ break;
159
+ }
160
+ }
161
+ ?>
162
+
163
+ <form action="" method="post" id="form">
164
+ <p>
165
+ <?php if (support("columns") || $TABLE == "") { ?>
166
+ <?php echo lang('Table name'); ?>: <input name="name" maxlength="64" value="<?php echo h($row["name"]); ?>" autocapitalize="off">
167
+ <?php if ($TABLE == "" && !$_POST) { ?><script type='text/javascript'>focus(document.getElementById('form')['name']);</script><?php } ?>
168
+ <?php echo ($engines ? "<select name='Engine' onchange='helpClose();'" . on_help("getTarget(event).value", 1) . ">" . optionlist(array("" => "(" . lang('engine') . ")") + $engines, $row["Engine"]) . "</select>" : ""); ?>
169
+ <?php echo ($collations && !preg_match("~sqlite|mssql~", $jush) ? html_select("Collation", array("" => "(" . lang('collation') . ")") + $collations, $row["Collation"]) : ""); ?>
170
+ <input type="submit" value="<?php echo lang('Save'); ?>">
171
+ <?php } ?>
172
+
173
+ <?php if (support("columns")) { ?>
174
+ <table cellspacing="0" id="edit-fields" class="nowrap">
175
+ <?php
176
+ $comments = ($_POST ? $_POST["comments"] : $row["Comment"] != "");
177
+ if (!$_POST && !$comments) {
178
+ foreach ($row["fields"] as $field) {
179
+ if ($field["comment"] != "") {
180
+ $comments = true;
181
+ break;
182
+ }
183
+ }
184
+ }
185
+ edit_fields($row["fields"], $collations, "TABLE", $foreign_keys, $comments);
186
+ ?>
187
+ </table>
188
+ <p>
189
+ <?php echo lang('Auto Increment'); ?>: <input type="number" name="Auto_increment" size="6" value="<?php echo h($row["Auto_increment"]); ?>">
190
+ <?php echo checkbox("defaults", 1, true, lang('Default values'), "columnShow(this.checked, 5)", "jsonly"); ?>
191
+ <?php if (!$_POST["defaults"]) { ?><script type="text/javascript">editingHideDefaults()</script><?php } ?>
192
+ <?php echo (support("comment")
193
+ ? "<label><input type='checkbox' name='comments' value='1' class='jsonly' onclick=\"columnShow(this.checked, 6); toggle('Comment'); if (this.checked) this.form['Comment'].focus();\"" . ($comments ? " checked" : "") . ">" . lang('Comment') . "</label>"
194
+ . ' <input name="Comment" id="Comment" value="' . h($row["Comment"]) . '" maxlength="' . ($connection->server_info >= 5.5 ? 2048 : 60) . '"' . ($comments ? '' : ' class="hidden"') . '>'
195
+ : '')
196
+ ; ?>
197
+ <p>
198
+ <input type="submit" value="<?php echo lang('Save'); ?>">
199
+ <?php } ?>
200
+
201
+ <?php if ($TABLE != "") { ?><input type="submit" name="drop" value="<?php echo lang('Drop'); ?>"<?php echo confirm(); ?>><?php } ?>
202
+ <?php
203
+ if (support("partitioning")) {
204
+ $partition_table = preg_match('~RANGE|LIST~', $row["partition_by"]);
205
+ print_fieldset("partition", lang('Partition by'), $row["partition_by"]);
206
+ ?>
207
+ <p>
208
+ <?php echo "<select name='partition_by' onchange='partitionByChange(this);'" . on_help("getTarget(event).value.replace(/./, 'PARTITION BY \$&')", 1) . ">" . optionlist(array("" => "") + $partition_by, $row["partition_by"]) . "</select>"; ?>
209
+ (<input name="partition" value="<?php echo h($row["partition"]); ?>">)
210
+ <?php echo lang('Partitions'); ?>: <input type="number" name="partitions" class="size<?php echo ($partition_table || !$row["partition_by"] ? " hidden" : ""); ?>" value="<?php echo h($row["partitions"]); ?>">
211
+ <table cellspacing="0" id="partition-table"<?php echo ($partition_table ? "" : " class='hidden'"); ?>>
212
+ <thead><tr><th><?php echo lang('Partition name'); ?><th><?php echo lang('Values'); ?></thead>
213
+ <?php
214
+ foreach ($row["partition_names"] as $key => $val) {
215
+ echo '<tr>';
216
+ echo '<td><input name="partition_names[]" value="' . h($val) . '"' . ($key == count($row["partition_names"]) - 1 ? ' onchange="partitionNameChange(this);"' : '') . ' autocapitalize="off">';
217
+ echo '<td><input name="partition_values[]" value="' . h($row["partition_values"][$key]) . '">';
218
+ }
219
+ ?>
220
+ </table>
221
+ </div></fieldset>
222
+ <?php
223
+ }
224
+ ?>
225
+ <input type="hidden" name="token" value="<?php echo $token; ?>">
226
+ </form>
adminer/adminer/adminer/database.inc.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $row = $_POST;
3
+
4
+ if ($_POST && !$error && !isset($_POST["add_x"])) { // add is an image and PHP changes add.x to add_x
5
+ $name = trim($row["name"]);
6
+ if ($_POST["drop"]) {
7
+ $_GET["db"] = ""; // to save in global history
8
+ queries_redirect(remove_from_uri("db|database"), lang('Database has been dropped.'), drop_databases(array(DB)));
9
+ } elseif (DB !== $name) {
10
+ // create or rename database
11
+ if (DB != "") {
12
+ $_GET["db"] = $name;
13
+ queries_redirect(preg_replace('~\bdb=[^&]*&~', '', ME) . "db=" . urlencode($name), lang('Database has been renamed.'), rename_database($name, $row["collation"]));
14
+ } else {
15
+ $databases = explode("\n", str_replace("\r", "", $name));
16
+ $success = true;
17
+ $last = "";
18
+ foreach ($databases as $db) {
19
+ if (count($databases) == 1 || $db != "") { // ignore empty lines but always try to create single database
20
+ if (!create_database($db, $row["collation"])) {
21
+ $success = false;
22
+ }
23
+ $last = $db;
24
+ }
25
+ }
26
+ restart_session();
27
+ set_session("dbs", null);
28
+ queries_redirect(ME . "db=" . urlencode($last), lang('Database has been created.'), $success);
29
+ }
30
+ } else {
31
+ // alter database
32
+ if (!$row["collation"]) {
33
+ redirect(substr(ME, 0, -1));
34
+ }
35
+ query_redirect("ALTER DATABASE " . idf_escape($name) . (preg_match('~^[a-z0-9_]+$~i', $row["collation"]) ? " COLLATE $row[collation]" : ""), substr(ME, 0, -1), lang('Database has been altered.'));
36
+ }
37
+ }
38
+
39
+ page_header(DB != "" ? lang('Alter database') : lang('Create database'), $error, array(), h(DB));
40
+
41
+ $collations = collations();
42
+ $name = DB;
43
+ if ($_POST) {
44
+ $name = $row["name"];
45
+ } elseif (DB != "") {
46
+ $row["collation"] = db_collation(DB, $collations);
47
+ } elseif ($jush == "sql") {
48
+ // propose database name with limited privileges
49
+ foreach (get_vals("SHOW GRANTS") as $grant) {
50
+ if (preg_match('~ ON (`(([^\\\\`]|``|\\\\.)*)%`\\.\\*)?~', $grant, $match) && $match[1]) {
51
+ $name = stripcslashes(idf_unescape("`$match[2]`"));
52
+ break;
53
+ }
54
+ }
55
+ }
56
+ ?>
57
+
58
+ <form action="" method="post">
59
+ <p>
60
+ <?php
61
+ echo ($_POST["add_x"] || strpos($name, "\n")
62
+ ? '<textarea id="name" name="name" rows="10" cols="40">' . h($name) . '</textarea><br>'
63
+ : '<input name="name" id="name" value="' . h($name) . '" maxlength="64" autocapitalize="off">'
64
+ ) . "\n" . ($collations ? html_select("collation", array("" => "(" . lang('collation') . ")") + $collations, $row["collation"]) . doc_link(array(
65
+ 'sql' => "charset-charsets.html",
66
+ 'mssql' => "ms187963.aspx",
67
+ )) : "");
68
+ ?>
69
+ <script type='text/javascript'>focus(document.getElementById('name'));</script>
70
+ <input type="submit" value="<?php echo lang('Save'); ?>">
71
+ <?php
72
+ if (DB != "") {
73
+ echo "<input type='submit' name='drop' value='" . lang('Drop') . "'" . confirm() . ">\n";
74
+ } elseif (!$_POST["add_x"] && $_GET["db"] == "") {
75
+ echo "<input type='image' class='icon' name='add' src='../adminer/static/plus.gif' alt='+' title='" . lang('Add next') . "'>\n";
76
+ }
77
+ ?>
78
+ <input type="hidden" name="token" value="<?php echo $token; ?>">
79
+ </form>
adminer/adminer/adminer/db.inc.php ADDED
@@ -0,0 +1,228 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $tables_views = array_merge((array) $_POST["tables"], (array) $_POST["views"]);
3
+
4
+ if ($tables_views && !$error && !$_POST["search"]) {
5
+ $result = true;
6
+ $message = "";
7
+ if ($jush == "sql" && count($_POST["tables"]) > 1 && ($_POST["drop"] || $_POST["truncate"] || $_POST["copy"])) {
8
+ queries("SET foreign_key_checks = 0"); // allows to truncate or drop several tables at once
9
+ }
10
+
11
+ if ($_POST["truncate"]) {
12
+ if ($_POST["tables"]) {
13
+ $result = truncate_tables($_POST["tables"]);
14
+ }
15
+ $message = lang('Tables have been truncated.');
16
+ } elseif ($_POST["move"]) {
17
+ $result = move_tables((array) $_POST["tables"], (array) $_POST["views"], $_POST["target"]);
18
+ $message = lang('Tables have been moved.');
19
+ } elseif ($_POST["copy"]) {
20
+ $result = copy_tables((array) $_POST["tables"], (array) $_POST["views"], $_POST["target"]);
21
+ $message = lang('Tables have been copied.');
22
+ } elseif ($_POST["drop"]) {
23
+ if ($_POST["views"]) {
24
+ $result = drop_views($_POST["views"]);
25
+ }
26
+ if ($result && $_POST["tables"]) {
27
+ $result = drop_tables($_POST["tables"]);
28
+ }
29
+ $message = lang('Tables have been dropped.');
30
+ } elseif ($jush != "sql") {
31
+ $result = ($jush == "sqlite"
32
+ ? queries("VACUUM")
33
+ : apply_queries("VACUUM" . ($_POST["optimize"] ? "" : " ANALYZE"), $_POST["tables"])
34
+ );
35
+ $message = lang('Tables have been optimized.');
36
+ } elseif (!$_POST["tables"]) {
37
+ $message = lang('No tables.');
38
+ } elseif ($result = queries(($_POST["optimize"] ? "OPTIMIZE" : ($_POST["check"] ? "CHECK" : ($_POST["repair"] ? "REPAIR" : "ANALYZE"))) . " TABLE " . implode(", ", array_map('idf_escape', $_POST["tables"])))) {
39
+ while ($row = $result->fetch_assoc()) {
40
+ $message .= "<b>" . h($row["Table"]) . "</b>: " . h($row["Msg_text"]) . "<br>";
41
+ }
42
+ }
43
+
44
+ queries_redirect(substr(ME, 0, -1), $message, $result);
45
+ }
46
+
47
+ page_header(($_GET["ns"] == "" ? lang('Database') . ": " . h(DB) : lang('Schema') . ": " . h($_GET["ns"])), $error, true);
48
+
49
+ if ($adminer->homepage()) {
50
+ if ($_GET["ns"] !== "") {
51
+ echo "<h3 id='tables-views'>" . lang('Tables and views') . "</h3>\n";
52
+ $tables_list = tables_list();
53
+ if (!$tables_list) {
54
+ echo "<p class='message'>" . lang('No tables.') . "\n";
55
+ } else {
56
+ echo "<form action='' method='post'>\n";
57
+ if (support("table")) {
58
+ echo "<fieldset><legend>" . lang('Search data in tables') . " <span id='selected2'></span></legend><div>";
59
+ echo "<input type='search' name='query' value='" . h($_POST["query"]) . "'> <input type='submit' name='search' value='" . lang('Search') . "'>\n";
60
+ echo "</div></fieldset>\n";
61
+ if ($_POST["search"] && $_POST["query"] != "") {
62
+ search_tables();
63
+ }
64
+ }
65
+ echo "<table cellspacing='0' class='nowrap checkable' onclick='tableClick(event);' ondblclick='tableClick(event, true);'>\n";
66
+
67
+ echo '<thead><tr class="wrap"><td><input id="check-all" type="checkbox" onclick="formCheck(this, /^(tables|views)\[/);">';
68
+ $doc_link = doc_link(array('sql' => 'show-table-status.html'));
69
+ echo '<th>' . lang('Table');
70
+ echo '<td>' . lang('Engine') . doc_link(array('sql' => 'storage-engines.html'));
71
+ echo '<td>' . lang('Collation') . doc_link(array('sql' => 'charset-mysql.html'));
72
+ echo '<td>' . lang('Data Length') . $doc_link;
73
+ echo '<td>' . lang('Index Length') . $doc_link;
74
+ echo '<td>' . lang('Data Free') . $doc_link;
75
+ echo '<td>' . lang('Auto Increment') . doc_link(array('sql' => 'example-auto-increment.html'));
76
+ echo '<td>' . lang('Rows') . $doc_link;
77
+ echo (support("comment") ? '<td>' . lang('Comment') . $doc_link : '');
78
+ echo "</thead>\n";
79
+
80
+ $tables = 0;
81
+ foreach ($tables_list as $name => $type) {
82
+ $view = ($type !== null && !preg_match('~table~i', $type));
83
+ echo '<tr' . odd() . '><td>' . checkbox(($view ? "views[]" : "tables[]"), $name, in_array($name, $tables_views, true), "", "formUncheck('check-all');");
84
+ echo '<th>' . (support("table") || support("indexes") ? '<a href="' . h(ME) . 'table=' . urlencode($name) . '" title="' . lang('Show structure') . '">' . h($name) . '</a>' : h($name));
85
+ if ($view) {
86
+ echo '<td colspan="6"><a href="' . h(ME) . "view=" . urlencode($name) . '" title="' . lang('Alter view') . '">' . (preg_match('~materialized~i', $type) ? lang('Materialized View') : lang('View')) . '</a>';
87
+ echo '<td align="right"><a href="' . h(ME) . "select=" . urlencode($name) . '" title="' . lang('Select data') . '">?</a>';
88
+ } else {
89
+ foreach (array(
90
+ "Engine" => array(),
91
+ "Collation" => array(),
92
+ "Data_length" => array("create", lang('Alter table')),
93
+ "Index_length" => array("indexes", lang('Alter indexes')),
94
+ "Data_free" => array("edit", lang('New item')),
95
+ "Auto_increment" => array("auto_increment=1&create", lang('Alter table')),
96
+ "Rows" => array("select", lang('Select data')),
97
+ ) as $key => $link) {
98
+ $id = " id='$key-" . h($name) . "'";
99
+ echo ($link ? "<td align='right'>" . (support("table") || $key == "Rows" || (support("indexes") && $key != "Data_length")
100
+ ? "<a href='" . h(ME . "$link[0]=") . urlencode($name) . "'$id title='$link[1]'>?</a>"
101
+ : "<span$id>?</span>"
102
+ ) : "<td id='$key-" . h($name) . "'>&nbsp;");
103
+ }
104
+ $tables++;
105
+ }
106
+ echo (support("comment") ? "<td id='Comment-" . h($name) . "'>&nbsp;" : "");
107
+ }
108
+
109
+ echo "<tr><td>&nbsp;<th>" . lang('%d in total', count($tables_list));
110
+ echo "<td>" . nbsp($jush == "sql" ? $connection->result("SELECT @@storage_engine") : "");
111
+ echo "<td>" . nbsp(db_collation(DB, collations()));
112
+ foreach (array("Data_length", "Index_length", "Data_free") as $key) {
113
+ echo "<td align='right' id='sum-$key'>&nbsp;";
114
+ }
115
+
116
+ echo "</table>\n";
117
+ if (!information_schema(DB)) {
118
+ $vacuum = "<input type='submit' value='" . lang('Vacuum') . "'" . on_help("'VACUUM'") . "> ";
119
+ $optimize = "<input type='submit' name='optimize' value='" . lang('Optimize') . "'" . on_help($jush == "sql" ? "'OPTIMIZE TABLE'" : "'VACUUM OPTIMIZE'") . "> ";
120
+ echo "<fieldset><legend>" . lang('Selected') . " <span id='selected'></span></legend><div>"
121
+ . ($jush == "sqlite" ? $vacuum
122
+ : ($jush == "pgsql" ? $vacuum . $optimize
123
+ : ($jush == "sql" ? "<input type='submit' value='" . lang('Analyze') . "'" . on_help("'ANALYZE TABLE'") . "> " . $optimize
124
+ . "<input type='submit' name='check' value='" . lang('Check') . "'" . on_help("'CHECK TABLE'") . "> "
125
+ . "<input type='submit' name='repair' value='" . lang('Repair') . "'" . on_help("'REPAIR TABLE'") . "> "
126
+ : "")))
127
+ . "<input type='submit' name='truncate' value='" . lang('Truncate') . "'" . confirm() . on_help($jush == "sqlite" ? "'DELETE'" : "'TRUNCATE" . ($jush == "pgsql" ? "'" : " TABLE'")) . "> "
128
+ . "<input type='submit' name='drop' value='" . lang('Drop') . "'" . confirm() . on_help("'DROP TABLE'") . ">\n";
129
+ $databases = (support("scheme") ? $adminer->schemas() : $adminer->databases());
130
+ if (count($databases) != 1 && $jush != "sqlite") {
131
+ $db = (isset($_POST["target"]) ? $_POST["target"] : (support("scheme") ? $_GET["ns"] : DB));
132
+ echo "<p>" . lang('Move to other database') . ": ";
133
+ echo ($databases ? html_select("target", $databases, $db) : '<input name="target" value="' . h($db) . '" autocapitalize="off">');
134
+ echo " <input type='submit' name='move' value='" . lang('Move') . "'>";
135
+ echo (support("copy") ? " <input type='submit' name='copy' value='" . lang('Copy') . "'>" : "");
136
+ echo "\n";
137
+ }
138
+ echo "<input type='hidden' name='all' value='' onclick=\"selectCount('selected', formChecked(this, /^(tables|views)\[/));" . (support("table") ? " selectCount('selected2', formChecked(this, /^tables\[/) || $tables);" : "") . "\">\n"; // used by trCheck()
139
+ echo "<input type='hidden' name='token' value='$token'>\n";
140
+ echo "</div></fieldset>\n";
141
+ }
142
+ echo "</form>\n";
143
+ echo "<script type='text/javascript'>tableCheck();</script>\n";
144
+ }
145
+
146
+ echo '<p class="links"><a href="' . h(ME) . 'create=">' . lang('Create table') . "</a>\n";
147
+ echo (support("view") ? '<a href="' . h(ME) . 'view=">' . lang('Create view') . "</a>\n" : "");
148
+ echo (support("materializedview") ? '<a href="' . h(ME) . 'view=&amp;materialized=1">' . lang('Create materialized view') . "</a>\n" : "");
149
+
150
+ if (support("routine")) {
151
+ echo "<h3 id='routines'>" . lang('Routines') . "</h3>\n";
152
+ $routines = routines();
153
+ if ($routines) {
154
+ echo "<table cellspacing='0'>\n";
155
+ echo '<thead><tr><th>' . lang('Name') . '<td>' . lang('Type') . '<td>' . lang('Return type') . "<td>&nbsp;</thead>\n";
156
+ odd('');
157
+ foreach ($routines as $row) {
158
+ echo '<tr' . odd() . '>';
159
+ echo '<th><a href="' . h(ME) . ($row["ROUTINE_TYPE"] != "PROCEDURE" ? 'callf=' : 'call=') . urlencode($row["ROUTINE_NAME"]) . '">' . h($row["ROUTINE_NAME"]) . '</a>';
160
+ echo '<td>' . h($row["ROUTINE_TYPE"]);
161
+ echo '<td>' . h($row["DTD_IDENTIFIER"]);
162
+ echo '<td><a href="' . h(ME) . ($row["ROUTINE_TYPE"] != "PROCEDURE" ? 'function=' : 'procedure=') . urlencode($row["ROUTINE_NAME"]) . '">' . lang('Alter') . "</a>";
163
+ }
164
+ echo "</table>\n";
165
+ }
166
+ echo '<p class="links">'
167
+ . (support("procedure") ? '<a href="' . h(ME) . 'procedure=">' . lang('Create procedure') . '</a>' : '')
168
+ . '<a href="' . h(ME) . 'function=">' . lang('Create function') . "</a>\n"
169
+ ;
170
+ }
171
+
172
+ if (support("sequence")) {
173
+ echo "<h3 id='sequences'>" . lang('Sequences') . "</h3>\n";
174
+ $sequences = get_vals("SELECT sequence_name FROM information_schema.sequences WHERE sequence_schema = current_schema() ORDER BY sequence_name");
175
+ if ($sequences) {
176
+ echo "<table cellspacing='0'>\n";
177
+ echo "<thead><tr><th>" . lang('Name') . "</thead>\n";
178
+ odd('');
179
+ foreach ($sequences as $val) {
180
+ echo "<tr" . odd() . "><th><a href='" . h(ME) . "sequence=" . urlencode($val) . "'>" . h($val) . "</a>\n";
181
+ }
182
+ echo "</table>\n";
183
+ }
184
+ echo "<p class='links'><a href='" . h(ME) . "sequence='>" . lang('Create sequence') . "</a>\n";
185
+ }
186
+
187
+ if (support("type")) {
188
+ echo "<h3 id='user-types'>" . lang('User types') . "</h3>\n";
189
+ $user_types = types();
190
+ if ($user_types) {
191
+ echo "<table cellspacing='0'>\n";
192
+ echo "<thead><tr><th>" . lang('Name') . "</thead>\n";
193
+ odd('');
194
+ foreach ($user_types as $val) {
195
+ echo "<tr" . odd() . "><th><a href='" . h(ME) . "type=" . urlencode($val) . "'>" . h($val) . "</a>\n";
196
+ }
197
+ echo "</table>\n";
198
+ }
199
+ echo "<p class='links'><a href='" . h(ME) . "type='>" . lang('Create type') . "</a>\n";
200
+ }
201
+
202
+ if (support("event")) {
203
+ echo "<h3 id='events'>" . lang('Events') . "</h3>\n";
204
+ $rows = get_rows("SHOW EVENTS");
205
+ if ($rows) {
206
+ echo "<table cellspacing='0'>\n";
207
+ echo "<thead><tr><th>" . lang('Name') . "<td>" . lang('Schedule') . "<td>" . lang('Start') . "<td>" . lang('End') . "<td></thead>\n";
208
+ foreach ($rows as $row) {
209
+ echo "<tr>";
210
+ echo "<th>" . h($row["Name"]);
211
+ echo "<td>" . ($row["Execute at"] ? lang('At given time') . "<td>" . $row["Execute at"] : lang('Every') . " " . $row["Interval value"] . " " . $row["Interval field"] . "<td>$row[Starts]");
212
+ echo "<td>$row[Ends]";
213
+ echo '<td><a href="' . h(ME) . 'event=' . urlencode($row["Name"]) . '">' . lang('Alter') . '</a>';
214
+ }
215
+ echo "</table>\n";
216
+ $event_scheduler = $connection->result("SELECT @@event_scheduler");
217
+ if ($event_scheduler && $event_scheduler != "ON") {
218
+ echo "<p class='error'><code class='jush-sqlset'>event_scheduler</code>: " . h($event_scheduler) . "\n";
219
+ }
220
+ }
221
+ echo '<p class="links"><a href="' . h(ME) . 'event=">' . lang('Create event') . "</a>\n";
222
+ }
223
+
224
+ if ($tables_list) {
225
+ echo "<script type='text/javascript'>ajaxSetHtml('" . js_escape(ME) . "script=db');</script>\n";
226
+ }
227
+ }
228
+ }
adminer/adminer/adminer/download.inc.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $TABLE = $_GET["download"];
3
+ $fields = fields($TABLE);
4
+ header("Content-Type: application/octet-stream");
5
+ header("Content-Disposition: attachment; filename=" . friendly_url("$TABLE-" . implode("_", $_GET["where"])) . "." . friendly_url($_GET["field"]));
6
+ $select = array(idf_escape($_GET["field"]));
7
+ $result = $driver->select($TABLE, $select, array(where($_GET, $fields)), $select);
8
+ $row = ($result ? $result->fetch_row() : array());
9
+ echo $row[0];
10
+ exit; // don't output footer
adminer/adminer/adminer/drivers/elastic.inc.php ADDED
@@ -0,0 +1,374 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $drivers["elastic"] = "Elasticsearch (beta)";
3
+
4
+ if (isset($_GET["elastic"])) {
5
+ $possible_drivers = array("json");
6
+ define("DRIVER", "elastic");
7
+
8
+ if (function_exists('json_decode')) {
9
+ class Min_DB {
10
+ var $extension = "JSON", $server_info, $errno, $error, $_url;
11
+
12
+ /** Performs query
13
+ * @param string
14
+ * @param array
15
+ * @param string
16
+ * @return mixed
17
+ */
18
+ function rootQuery($path, $content = array(), $method = 'GET') {
19
+ @ini_set('track_errors', 1); // @ - may be disabled
20
+ $file = @file_get_contents($this->_url . '/' . ltrim($path, '/'), false, stream_context_create(array('http' => array(
21
+ 'method' => $method,
22
+ 'content' => json_encode($content),
23
+ 'ignore_errors' => 1, // available since PHP 5.2.10
24
+ ))));
25
+ if (!$file) {
26
+ $this->error = $php_errormsg;
27
+ return $file;
28
+ }
29
+ if (!preg_match('~^HTTP/[0-9.]+ 2~i', $http_response_header[0])) {
30
+ $this->error = $file;
31
+ return false;
32
+ }
33
+ $return = json_decode($file, true);
34
+ if ($return === null) {
35
+ $this->errno = json_last_error();
36
+ if (function_exists('json_last_error_msg')) {
37
+ $this->error = json_last_error_msg();
38
+ } else {
39
+ $constants = get_defined_constants(true);
40
+ foreach ($constants['json'] as $name => $value) {
41
+ if ($value == $this->errno && preg_match('~^JSON_ERROR_~', $name)) {
42
+ $this->error = $name;
43
+ break;
44
+ }
45
+ }
46
+ }
47
+ }
48
+ return $return;
49
+ }
50
+
51
+ /** Performs query relative to actual selected DB
52
+ * @param string
53
+ * @param array
54
+ * @param string
55
+ * @return mixed
56
+ */
57
+ function query($path, $content = array(), $method = 'GET') {
58
+ return $this->rootQuery(($this->_db != "" ? "$this->_db/" : "/") . ltrim($path, '/'), $content, $method);
59
+ }
60
+
61
+ function connect($server, $username, $password) {
62
+ $this->_url = "http://$username:$password@$server/";
63
+ $return = $this->query('');
64
+ if ($return) {
65
+ $this->server_info = $return['version']['number'];
66
+ }
67
+ return (bool) $return;
68
+ }
69
+
70
+ function select_db($database) {
71
+ $this->_db = $database;
72
+ return true;
73
+ }
74
+
75
+ function quote($string) {
76
+ return $string;
77
+ }
78
+
79
+ }
80
+
81
+ class Min_Result {
82
+ var $num_rows, $_rows;
83
+
84
+ function __construct($rows) {
85
+ $this->num_rows = count($this->_rows);
86
+ $this->_rows = $rows;
87
+ reset($this->_rows);
88
+ }
89
+
90
+ function fetch_assoc() {
91
+ $return = current($this->_rows);
92
+ next($this->_rows);
93
+ return $return;
94
+ }
95
+
96
+ function fetch_row() {
97
+ return array_values($this->fetch_assoc());
98
+ }
99
+
100
+ }
101
+
102
+ }
103
+
104
+
105
+
106
+ class Min_Driver extends Min_SQL {
107
+
108
+ function select($table, $select, $where, $group, $order = array(), $limit = 1, $page = 0, $print = false) {
109
+ global $adminer;
110
+ $data = array();
111
+ $query = "$table/_search";
112
+ if ($select != array("*")) {
113
+ $data["fields"] = $select;
114
+ }
115
+ if ($order) {
116
+ $sort = array();
117
+ foreach ($order as $col) {
118
+ $col = preg_replace('~ DESC$~', '', $col, 1, $count);
119
+ $sort[] = ($count ? array($col => "desc") : $col);
120
+ }
121
+ $data["sort"] = $sort;
122
+ }
123
+ if ($limit) {
124
+ $data["size"] = +$limit;
125
+ if ($page) {
126
+ $data["from"] = ($page * $limit);
127
+ }
128
+ }
129
+ foreach ($where as $val) {
130
+ list($col,$op,$val) = explode(" ",$val,3);
131
+ if ($col == "_id") {
132
+ $data["query"]["ids"]["values"][] = $val;
133
+ }
134
+ elseif ($col . $val != "") {
135
+ $term = array("term" => array(($col != "" ? $col : "_all") => $val));
136
+ if ($op == "=") {
137
+ $data["query"]["filtered"]["filter"]["and"][] = $term;
138
+ } else {
139
+ $data["query"]["filtered"]["query"]["bool"]["must"][] = $term;
140
+ }
141
+ }
142
+ }
143
+ if ($data["query"] && !$data["query"]["filtered"]["query"] && !$data["query"]["ids"]) {
144
+ $data["query"]["filtered"]["query"] = array("match_all" => array());
145
+ }
146
+ $start = microtime(true);
147
+ $search = $this->_conn->query($query, $data);
148
+ if ($print) {
149
+ echo $adminer->selectQuery("$query: " . print_r($data, true), format_time($start));
150
+ }
151
+ if (!$search) {
152
+ return false;
153
+ }
154
+ $return = array();
155
+ foreach ($search['hits']['hits'] as $hit) {
156
+ $row = array();
157
+ if ($select == array("*")) {
158
+ $row["_id"] = $hit["_id"];
159
+ }
160
+ $fields = $hit['_source'];
161
+ if ($select != array("*")) {
162
+ $fields = array();
163
+ foreach ($select as $key) {
164
+ $fields[$key] = $hit['fields'][$key];
165
+ }
166
+ }
167
+ foreach ($fields as $key => $val) {
168
+ if ($data["fields"]) {
169
+ $val = $val[0];
170
+ }
171
+ $row[$key] = (is_array($val) ? json_encode($val) : $val); //! display JSON and others differently
172
+ }
173
+ $return[] = $row;
174
+ }
175
+ return new Min_Result($return);
176
+ }
177
+
178
+ }
179
+
180
+
181
+
182
+ function connect() {
183
+ global $adminer;
184
+ $connection = new Min_DB;
185
+ $credentials = $adminer->credentials();
186
+ if ($connection->connect($credentials[0], $credentials[1], $credentials[2])) {
187
+ return $connection;
188
+ }
189
+ return $connection->error;
190
+ }
191
+
192
+ function support($feature) {
193
+ return preg_match("~database|table|columns~", $feature);
194
+ }
195
+
196
+ function logged_user() {
197
+ global $adminer;
198
+ $credentials = $adminer->credentials();
199
+ return $credentials[1];
200
+ }
201
+
202
+ function get_databases() {
203
+ global $connection;
204
+ $return = $connection->rootQuery('_aliases');
205
+ if ($return) {
206
+ $return = array_keys($return);
207
+ sort($return, SORT_STRING);
208
+ }
209
+ return $return;
210
+ }
211
+
212
+ function collations() {
213
+ return array();
214
+ }
215
+
216
+ function db_collation($db, $collations) {
217
+ }
218
+
219
+ function engines() {
220
+ return array();
221
+ }
222
+
223
+ function count_tables($databases) {
224
+ global $connection;
225
+ $return = $connection->query('_mapping');
226
+ if ($return) {
227
+ $return = array_map('count', $return);
228
+ }
229
+ return $return;
230
+ }
231
+
232
+ function tables_list() {
233
+ global $connection;
234
+ $return = $connection->query('_mapping');
235
+ if ($return) {
236
+ $return = array_fill_keys(array_keys($return[$connection->_db]["mappings"]), 'table');
237
+ }
238
+ return $return;
239
+ }
240
+
241
+ function table_status($name = "", $fast = false) {
242
+ global $connection;
243
+ $search = $connection->query("_search?search_type=count", array(
244
+ "facets" => array(
245
+ "count_by_type" => array(
246
+ "terms" => array(
247
+ "field" => "_type",
248
+ )
249
+ )
250
+ )
251
+ ), "POST");
252
+ $return = array();
253
+ if ($search) {
254
+ foreach ($search["facets"]["count_by_type"]["terms"] as $table) {
255
+ $return[$table["term"]] = array(
256
+ "Name" => $table["term"],
257
+ "Engine" => "table",
258
+ "Rows" => $table["count"],
259
+ );
260
+ }
261
+ if ($name != "" && $name == $table["term"]) {
262
+ return $return[$name];
263
+ }
264
+ }
265
+ return $return;
266
+ }
267
+
268
+ function error() {
269
+ global $connection;
270
+ return h($connection->error);
271
+ }
272
+
273
+ function information_schema() {
274
+ }
275
+
276
+ function is_view($table_status) {
277
+ }
278
+
279
+ function indexes($table, $connection2 = null) {
280
+ return array(
281
+ array("type" => "PRIMARY", "columns" => array("_id")),
282
+ );
283
+ }
284
+
285
+ function fields($table) {
286
+ global $connection;
287
+ $result = $connection->query("$table/_mapping");
288
+ $return = array();
289
+ if ($result) {
290
+ $mappings = $result[$table]['properties'];
291
+ if (!$mappings) {
292
+ $mappings = $result[$connection->_db]['mappings'][$table]['properties'];
293
+ }
294
+ if ($mappings) {
295
+ foreach ($mappings as $name => $field) {
296
+ $return[$name] = array(
297
+ "field" => $name,
298
+ "full_type" => $field["type"],
299
+ "type" => $field["type"],
300
+ "privileges" => array("insert" => 1, "select" => 1, "update" => 1),
301
+ );
302
+ if ($field["properties"]) { // only leaf fields can be edited
303
+ unset($return[$name]["privileges"]["insert"]);
304
+ unset($return[$name]["privileges"]["update"]);
305
+ }
306
+ }
307
+ }
308
+ }
309
+ return $return;
310
+ }
311
+
312
+ function foreign_keys($table) {
313
+ return array();
314
+ }
315
+
316
+ function table($idf) {
317
+ return $idf;
318
+ }
319
+
320
+ function idf_escape($idf) {
321
+ return $idf;
322
+ }
323
+
324
+ function convert_field($field) {
325
+ }
326
+
327
+ function unconvert_field($field, $return) {
328
+ return $return;
329
+ }
330
+
331
+ function fk_support($table_status) {
332
+ }
333
+
334
+ function found_rows($table_status, $where) {
335
+ return null;
336
+ }
337
+
338
+ /** Create database
339
+ * @param string
340
+ * @return mixed
341
+ */
342
+ function create_database($db) {
343
+ global $connection;
344
+ return $connection->rootQuery(urlencode($db), array(), 'PUT');
345
+ }
346
+
347
+ /** Drop databases
348
+ * @param array
349
+ * @return mixed
350
+ */
351
+ function drop_databases($databases) {
352
+ global $connection;
353
+ return $connection->rootQuery(urlencode(implode(',', $databases)), array(), 'DELETE');
354
+ }
355
+
356
+ /** Drop tables
357
+ * @param array
358
+ * @return bool
359
+ */
360
+ function drop_tables($tables) {
361
+ global $connection;
362
+ $return = true;
363
+ foreach ($tables as $table) { //! convert to bulk api
364
+ $return = $return && $connection->query(urlencode($table), array(), 'DELETE');
365
+ }
366
+ return $return;
367
+ }
368
+
369
+ $jush = "elastic";
370
+ $operators = array("=", "query");
371
+ $functions = array();
372
+ $grouping = array();
373
+ $edit_functions = array(array("json"));
374
+ }
adminer/adminer/adminer/drivers/firebird.inc.php ADDED
@@ -0,0 +1,320 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Steve Krämer
4
+ */
5
+
6
+ $drivers['firebird'] = 'Firebird (alpha)';
7
+
8
+ if (isset($_GET["firebird"])) {
9
+ $possible_drivers = array("interbase");
10
+ define("DRIVER", "firebird");
11
+
12
+ if (extension_loaded("interbase") ) {
13
+ class Min_DB {
14
+ var
15
+ $extension = "Firebird",
16
+ $server_info,
17
+ $affected_rows,
18
+ $errno,
19
+ $error,
20
+ $_link, $_result
21
+ ;
22
+
23
+ function connect($server, $username, $password) {
24
+ $this->_link = ibase_connect($server, $username, $password);
25
+ if ($this->_link) {
26
+ $url_parts = explode(':', $server);
27
+ $this->service_link = ibase_service_attach($url_parts[0], $username, $password);
28
+ $this->server_info = ibase_server_info($this->service_link, IBASE_SVC_SERVER_VERSION);
29
+ } else {
30
+ $this->errno = ibase_errcode();
31
+ $this->error = ibase_errmsg();
32
+ }
33
+ return (bool) $this->_link;
34
+ }
35
+
36
+ function quote($string) {
37
+ return "'" . str_replace("'", "''", $string) . "'";
38
+ }
39
+
40
+ function select_db($database) {
41
+ return ($database == "domain");
42
+ }
43
+
44
+ function query($query, $unbuffered = false) {
45
+ $result = ibase_query($query, $this->_link);
46
+ if (!$result) {
47
+ $this->errno = ibase_errcode();
48
+ $this->error = ibase_errmsg();
49
+ return false;
50
+ }
51
+ $this->error = "";
52
+ if ($result === true) {
53
+ $this->affected_rows = ibase_affected_rows($this->_link);
54
+ return true;
55
+ }
56
+ return new Min_Result($result);
57
+ }
58
+
59
+ function multi_query($query) {
60
+ return $this->_result = $this->query($query);
61
+ }
62
+
63
+ function store_result() {
64
+ return $this->_result;
65
+ }
66
+
67
+ function next_result() {
68
+ return false;
69
+ }
70
+
71
+ function result($query, $field = 0) {
72
+ $result = $this->query($query);
73
+ if (!$result || !$result->num_rows) {
74
+ return false;
75
+ }
76
+ $row = $result->fetch_row();
77
+ return $row[$field];
78
+ }
79
+ }
80
+
81
+ class Min_Result {
82
+ var $num_rows, $_result, $_offset = 0;
83
+
84
+ function __construct($result) {
85
+ $this->_result = $result;
86
+ // $this->num_rows = ibase_num_rows($result);
87
+ }
88
+
89
+ function fetch_assoc() {
90
+ return ibase_fetch_assoc($this->_result);
91
+ }
92
+
93
+ function fetch_row() {
94
+ return ibase_fetch_row($this->_result);
95
+ }
96
+
97
+ function fetch_field() {
98
+ $field = ibase_field_info($this->_result, $this->_offset++);
99
+ return (object) array(
100
+ 'name' => $field['name'],
101
+ 'orgname' => $field['name'],
102
+ 'type' => $field['type'],
103
+ 'charsetnr' => $field['length'],
104
+ );
105
+ }
106
+
107
+ function __destruct() {
108
+ ibase_free_result($this->_result);
109
+ }
110
+ }
111
+
112
+ }
113
+
114
+
115
+
116
+ class Min_Driver extends Min_SQL {
117
+ }
118
+
119
+
120
+
121
+ function idf_escape($idf) {
122
+ return '"' . str_replace('"', '""', $idf) . '"';
123
+ }
124
+
125
+ function table($idf) {
126
+ return idf_escape($idf);
127
+ }
128
+
129
+ function connect() {
130
+ global $adminer;
131
+ $connection = new Min_DB;
132
+ $credentials = $adminer->credentials();
133
+ if ($connection->connect($credentials[0], $credentials[1], $credentials[2])) {
134
+ return $connection;
135
+ }
136
+ return $connection->error;
137
+ }
138
+
139
+ function get_databases($flush) {
140
+ return array("domain");
141
+ }
142
+
143
+ function limit($query, $where, $limit, $offset = 0, $separator = " ") {
144
+ $return = '';
145
+ $return .= ($limit !== null ? $separator . "FIRST $limit" . ($offset ? " SKIP $offset" : "") : "");
146
+ $return .= " $query$where";
147
+ return $return;
148
+ }
149
+
150
+ function limit1($query, $where) {
151
+ return limit($query, $where, 1);
152
+ }
153
+
154
+ function db_collation($db, $collations) {
155
+ }
156
+
157
+ function engines() {
158
+ return array();
159
+ }
160
+
161
+ function logged_user() {
162
+ global $adminer;
163
+ $credentials = $adminer->credentials();
164
+ return $credentials[1];
165
+ }
166
+
167
+ function tables_list() {
168
+ global $connection;
169
+ $query = 'SELECT RDB$RELATION_NAME FROM rdb$relations WHERE rdb$system_flag = 0';
170
+ $result = ibase_query($connection->_link, $query);
171
+ $return = array();
172
+ while ($row = ibase_fetch_assoc($result)) {
173
+ $return[$row['RDB$RELATION_NAME']] = 'table';
174
+ }
175
+ ksort($return);
176
+ return $return;
177
+ }
178
+
179
+ function count_tables($databases) {
180
+ return array();
181
+ }
182
+
183
+ function table_status($name = "", $fast = false) {
184
+ global $connection;
185
+ $return = array();
186
+ $data = tables_list();
187
+ foreach ($data as $index => $val) {
188
+ $index = trim($index);
189
+ $return[$index] = array(
190
+ 'Name' => $index,
191
+ 'Engine' => 'standard',
192
+ );
193
+ if ($name == $index) {
194
+ return $return[$index];
195
+ }
196
+ }
197
+ return $return;
198
+ }
199
+
200
+ function is_view($table_status) {
201
+ return false;
202
+ }
203
+
204
+ function fk_support($table_status) {
205
+ return preg_match('~InnoDB|IBMDB2I~i', $table_status["Engine"]);
206
+ }
207
+
208
+ function fields($table) {
209
+ global $connection;
210
+ $return = array();
211
+ $query = 'SELECT r.RDB$FIELD_NAME AS field_name,
212
+ r.RDB$DESCRIPTION AS field_description,
213