Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 501 lines (464 sloc) 18.036 kb
2c445a8 Extensibility basics
jakubvrana authored
1 <?php
c64c4fd Adminer class
jakubvrana authored
2 class Adminer {
d24ad78 Select boxes customization
jakubvrana authored
3 var $functions = array("char_length", "from_unixtime", "hex", "lower", "round", "sec_to_time", "time_to_sec", "unix_timestamp", "upper");
e0fbf33 Rename distinct to count distinct
jakubvrana authored
4 var $grouping = array("avg", "count", "count distinct", "group_concat", "max", "min", "sum");
d24ad78 Select boxes customization
jakubvrana authored
5 var $operators = array("=", "<", ">", "<=", ">=", "!=", "LIKE", "REGEXP", "IN", "IS NULL", "NOT LIKE", "NOT REGEXP", "NOT IN", "IS NOT NULL");
c64c4fd Adminer class
jakubvrana authored
6
7 /** Name in title and navigation
8 * @return string
9 */
10 function name() {
b349612 Remove useless translations
jakubvrana authored
11 return "Adminer";
c64c4fd Adminer class
jakubvrana authored
12 }
13
14 /** Connection parameters
15 * @return array ($server, $username, $password)
16 */
17 function credentials() {
18 return array($_GET["server"], $_SESSION["usernames"][$_GET["server"]], $_SESSION["passwords"][$_GET["server"]]);
19 }
20
21 /** Identifier of selected database
22 * @return string
23 */
24 function database() {
3022dcb Define DB
jakubvrana authored
25 // should be used everywhere instead of DB
26 return DB;
c64c4fd Adminer class
jakubvrana authored
27 }
28
29 /** Print login form
30 * @param string
31 * @return null
32 */
33 function loginForm($username) {
2faa08c Customize login and login form
jakubvrana authored
34 ?>
0205440 HTML whitespace
jakubvrana authored
35 <table cellspacing="0">
689699a Shortcut for htmlspecialchars
jakubvrana authored
36 <tr><th><?php echo lang('Server'); ?><td><input name="server" value="<?php echo h($_GET["server"]); ?>">
37 <tr><th><?php echo lang('Username'); ?><td><input name="username" value="<?php echo h($username); ?>">
0205440 HTML whitespace
jakubvrana authored
38 <tr><th><?php echo lang('Password'); ?><td><input type="password" name="password">
39 </table>
2faa08c Customize login and login form
jakubvrana authored
40 <?php
41 }
c64c4fd Adminer class
jakubvrana authored
42
43 /** Authorize the user
44 * @param string
45 * @param string
46 * @return bool
47 */
48 function login($login, $password) {
49 return true;
97b8c7b Display images in Editor
jakubvrana authored
50 }
c64c4fd Adminer class
jakubvrana authored
51
52 /** Table caption used in navigation and headings
53 * @param array result of SHOW TABLE STATUS
54 * @return string
55 */
56 function tableName($tableStatus) {
689699a Shortcut for htmlspecialchars
jakubvrana authored
57 return h($tableStatus["Name"]);
c64c4fd Adminer class
jakubvrana authored
58 }
59
60 /** Field caption used in select and edit
61 * @param array single field returned from fields()
6c97b80 Display only first five columns in Editor example
jakubvrana authored
62 * @param int order of column in select
c64c4fd Adminer class
jakubvrana authored
63 * @return string
64 */
6c97b80 Display only first five columns in Editor example
jakubvrana authored
65 function fieldName($field, $order = 0) {
689699a Shortcut for htmlspecialchars
jakubvrana authored
66 return '<span title="' . h($field["full_type"]) . '">' . h($field["field"]) . '</span>';
c64c4fd Adminer class
jakubvrana authored
67 }
68
f2ed237 Display table links above table structure
jakubvrana authored
69 /** Print links after select heading
c64c4fd Adminer class
jakubvrana authored
70 * @param array result of SHOW TABLE STATUS
f2ed237 Display table links above table structure
jakubvrana authored
71 * @param strin new item options, NULL for no new item
72 * @return null
c64c4fd Adminer class
jakubvrana authored
73 */
f2ed237 Display table links above table structure
jakubvrana authored
74 function selectLinks($tableStatus, $set = "") {
75 $TABLE = $tableStatus["Name"];
76 echo '<p><a href="' . h(ME) . 'select=' . urlencode($TABLE) . '">' . lang('Select table') . '</a>';
77 echo ' <a href="' . h(ME) . 'table=' . urlencode($TABLE) . '">' . lang('Table structure') . '</a>';
78 if (isset($tableStatus["Rows"])) {
79 echo ' <a href="' . h(ME) . 'create=' . urlencode($TABLE) . '">' . lang('Alter table') . '</a>';
80 } else {
81 echo ' <a href="' . h(ME) . 'view=' . urlencode($TABLE) . '">' . lang('Alter view') . '</a>';
82 }
83 if (isset($set)) {
84 echo ' <a href="' . h(ME . 'edit=' . urlencode($TABLE) . $set) . '">' . lang('New item') . '</a>';
85 }
86 echo "\n";
c64c4fd Adminer class
jakubvrana authored
87 }
88
89 /** Find backward keys for table
90 * @param string
09e93de Move backward keys to Editor
jakubvrana authored
91 * @param string
92 * @return array $return[$target_table]["keys"][$key_name][$target_column] = $source_column; $return[$target_table]["name"] = $this->tableName($target_table);
c64c4fd Adminer class
jakubvrana authored
93 */
09e93de Move backward keys to Editor
jakubvrana authored
94 function backwardKeys($table, $tableName) {
c64c4fd Adminer class
jakubvrana authored
95 return array();
96 }
97
09e93de Move backward keys to Editor
jakubvrana authored
98 /** Print backward keys for row
99 * @param array result of $this->backwardKeys()
100 * @param array
101 * @return null
102 */
103 function backwardKeysPrint($backwardKeys, $row) {
104 }
105
c64c4fd Adminer class
jakubvrana authored
106 /** Query printed in select before execution
107 * @param string query to be executed
108 * @return string
109 */
110 function selectQuery($query) {
9c09ebe End element for IE
jakubvrana authored
111 return "<p><code class='jush-sql'>" . h($query) . "</code> <a href='" . h(ME) . "sql=" . urlencode($query) . "'>" . lang('Edit') . "</a></p>\n";
c64c4fd Adminer class
jakubvrana authored
112 }
113
114 /** Description of a row in a table
115 * @param string
116 * @return string SQL expression, empty string for no description
117 */
118 function rowDescription($table) {
119 return "";
120 }
121
122 /** Get descriptions of selected data
123 * @param array all data to print
124 * @param array
125 * @return array
126 */
127 function rowDescriptions($rows, $foreignKeys) {
128 return $rows;
129 }
130
131 /** Value printed in select table
a0def47 Date localization
jakubvrana authored
132 * @param string HTML-escaped value to print
c64c4fd Adminer class
jakubvrana authored
133 * @param string link to foreign key
134 * @param array single field returned from fields()
135 * @return string
136 */
137 function selectVal($val, $link, $field) {
138 $return = ($field["type"] == "char" ? "<code>$val</code>" : $val);
139 if (ereg('blob|binary', $field["type"]) && !is_utf8($val)) {
140 $return = lang('%d byte(s)', strlen($val));
4921235 Hide edit functions in Editor
jakubvrana authored
141 }
12c042c Function htmlspecialchars now uses ENT_QUOTES
jakubvrana authored
142 return ($link ? "<a href='$link'>$return</a>" : $return);
c64c4fd Adminer class
jakubvrana authored
143 }
144
a0def47 Date localization
jakubvrana authored
145 /** Value conversion used in select and edit
146 * @param string
147 * @param array single field returned from fields()
2011428 Use LIKE operator in Editor
jakubvrana authored
148 * @return string
a0def47 Date localization
jakubvrana authored
149 */
150 function editVal($val, $field) {
151 return $val;
152 }
153
d24ad78 Select boxes customization
jakubvrana authored
154 /** Print columns box in select
155 * @param array result of selectColumnsProcess()
156 * @param array selectable columns
157 * @return null
158 */
159 function selectColumnsPrint($select, $columns) {
dc667ea Hide select export and import
jakubvrana authored
160 print_fieldset("select", lang('Select'), $select);
d24ad78 Select boxes customization
jakubvrana authored
161 $i = 0;
162 $fun_group = array(lang('Functions') => $this->functions, lang('Aggregation') => $this->grouping);
163 foreach ($select as $key => $val) {
164 $val = $_GET["columns"][$key];
165 echo "<div><select name='columns[$i][fun]'><option>" . optionlist($fun_group, $val["fun"]) . "</select>";
166 echo "<select name='columns[$i][col]'><option>" . optionlist($columns, $val["col"], true) . "</select></div>\n";
167 $i++;
168 }
169 echo "<div><select name='columns[$i][fun]' onchange='this.nextSibling.onchange();'><option>" . optionlist($fun_group) . "</select>";
170 echo "<select name='columns[$i][col]' onchange='select_add_row(this);'><option>" . optionlist($columns, null, true) . "</select></div>\n";
171 echo "</div></fieldset>\n";
172 }
173
174 /** Print search box in select
175 * @param array result of selectSearchProcess()
176 * @param array selectable columns
177 * @param array
178 * @return null
179 */
180 function selectSearchPrint($where, $columns, $indexes) {
dc667ea Hide select export and import
jakubvrana authored
181 print_fieldset("search", lang('Search'), $where);
d24ad78 Select boxes customization
jakubvrana authored
182 foreach ($indexes as $i => $index) {
183 if ($index["type"] == "FULLTEXT") {
689699a Shortcut for htmlspecialchars
jakubvrana authored
184 echo "(<i>" . implode("</i>, <i>", array_map('h', $index["columns"])) . "</i>) AGAINST";
185 echo " <input name='fulltext[$i]' value='" . h($_GET["fulltext"][$i]) . "'>";
b349612 Remove useless translations
jakubvrana authored
186 echo "<label><input type='checkbox' name='boolean[$i]' value='1'" . (isset($_GET["boolean"][$i]) ? " checked" : "") . ">BOOL</label>";
d24ad78 Select boxes customization
jakubvrana authored
187 echo "<br>\n";
188 }
189 }
190 $i = 0;
191 foreach ((array) $_GET["where"] as $val) {
192 if (strlen("$val[col]$val[val]") && in_array($val["op"], $this->operators)) {
193 echo "<div><select name='where[$i][col]'><option value=''>" . lang('(anywhere)') . optionlist($columns, $val["col"], true) . "</select>";
194 echo "<select name='where[$i][op]'>" . optionlist($this->operators, $val["op"]) . "</select>";
689699a Shortcut for htmlspecialchars
jakubvrana authored
195 echo "<input name='where[$i][val]' value='" . h($val["val"]) . "'></div>\n";
d24ad78 Select boxes customization
jakubvrana authored
196 $i++;
197 }
198 }
199 echo "<div><select name='where[$i][col]' onchange='select_add_row(this);'><option value=''>" . lang('(anywhere)') . optionlist($columns, null, true) . "</select>";
200 echo "<select name='where[$i][op]'>" . optionlist($this->operators) . "</select>";
201 echo "<input name='where[$i][val]'></div>\n";
202 echo "</div></fieldset>\n";
203 }
204
205 /** Print order box in select
206 * @param array result of selectOrderProcess()
207 * @param array selectable columns
208 * @param array
209 * @return null
210 */
211 function selectOrderPrint($order, $columns, $indexes) {
dc667ea Hide select export and import
jakubvrana authored
212 print_fieldset("sort", lang('Sort'), $order);
d24ad78 Select boxes customization
jakubvrana authored
213 $i = 0;
214 foreach ((array) $_GET["order"] as $key => $val) {
215 if (isset($columns[$val])) {
216 echo "<div><select name='order[$i]'><option>" . optionlist($columns, $val, true) . "</select>";
cb6d36c HTML instead of XHTML
jakubvrana authored
217 echo "<label><input type='checkbox' name='desc[$i]' value='1'" . (isset($_GET["desc"][$key]) ? " checked" : "") . ">" . lang('descending') . "</label></div>\n";
d24ad78 Select boxes customization
jakubvrana authored
218 $i++;
219 }
220 }
221 echo "<div><select name='order[$i]' onchange='select_add_row(this);'><option>" . optionlist($columns, null, true) . "</select>";
222 echo "<label><input type='checkbox' name='desc[$i]' value='1'>" . lang('descending') . "</label></div>\n";
223 echo "</div></fieldset>\n";
224 }
225
226 /** Print limit box in select
227 * @param string result of selectLimitProcess()
228 * @return null
229 */
230 function selectLimitPrint($limit) {
231 echo "<fieldset><legend>" . lang('Limit') . "</legend><div>"; // <div> for easy styling
689699a Shortcut for htmlspecialchars
jakubvrana authored
232 echo "<input name='limit' size='3' value='" . h($limit) . "'>";
d24ad78 Select boxes customization
jakubvrana authored
233 echo "</div></fieldset>\n";
234 }
235
236 /** Print text length box in select
237 * @param string result of selectLengthProcess()
238 * @return null
239 */
240 function selectLengthPrint($text_length) {
241 if (isset($text_length)) {
242 echo "<fieldset><legend>" . lang('Text length') . "</legend><div>";
689699a Shortcut for htmlspecialchars
jakubvrana authored
243 echo '<input name="text_length" size="3" value="' . h($text_length) . '">';
d24ad78 Select boxes customization
jakubvrana authored
244 echo "</div></fieldset>\n";
245 }
246 }
247
248 /** Print action box in select
249 * @return null
250 */
251 function selectActionPrint() {
252 echo "<fieldset><legend>" . lang('Action') . "</legend><div>";
253 echo "<input type='submit' value='" . lang('Select') . "'>";
254 echo "</div></fieldset>\n";
255 }
256
1a6a73a Rename selectExtra to selectEmail
jakubvrana authored
257 /** Print extra text in the end of a select form
258 * @param array fields holding e-mails
1e55d47 User interface for e-mail {$name}
jakubvrana authored
259 * @param array selectable columns
1a6a73a Rename selectExtra to selectEmail
jakubvrana authored
260 * @return null
261 */
1e55d47 User interface for e-mail {$name}
jakubvrana authored
262 function selectEmailPrint($emailFields, $columns) {
1a6a73a Rename selectExtra to selectEmail
jakubvrana authored
263 }
264
d24ad78 Select boxes customization
jakubvrana authored
265 /** Process columns box in select
266 * @param array selectable columns
1e55d47 User interface for e-mail {$name}
jakubvrana authored
267 * @param array
d24ad78 Select boxes customization
jakubvrana authored
268 * @return array (array(select_expressions), array(group_expressions))
269 */
270 function selectColumnsProcess($columns, $indexes) {
271 $select = array(); // select expressions, empty for *
272 $group = array(); // expressions without aggregation - will be used for GROUP BY if an aggregation function is used
273 foreach ((array) $_GET["columns"] as $key => $val) {
274 if ($val["fun"] == "count" || (isset($columns[$val["col"]]) && (!$val["fun"] || in_array($val["fun"], $this->functions) || in_array($val["fun"], $this->grouping)))) {
275 $select[$key] = apply_sql_function($val["fun"], (isset($columns[$val["col"]]) ? idf_escape($val["col"]) : "*"));
276 if (!in_array($val["fun"], $this->grouping)) {
277 $group[] = $select[$key];
278 }
279 }
280 }
281 return array($select, $group);
282 }
283
284 /** Process search box in select
285 * @param array
286 * @param array
287 * @return array expressions to join by AND
288 */
07e1ae1 FOUND_ROWS only with GROUP BY
jakubvrana authored
289 function selectSearchProcess($fields, $indexes) {
64d616c Rename get_dbh to connection
jakubvrana authored
290 global $connection;
d24ad78 Select boxes customization
jakubvrana authored
291 $return = array();
292 foreach ($indexes as $i => $index) {
293 if ($index["type"] == "FULLTEXT" && strlen($_GET["fulltext"][$i])) {
64d616c Rename get_dbh to connection
jakubvrana authored
294 $return[] = "MATCH (" . implode(", ", array_map('idf_escape', $index["columns"])) . ") AGAINST (" . $connection->quote($_GET["fulltext"][$i]) . (isset($_GET["boolean"][$i]) ? " IN BOOLEAN MODE" : "") . ")";
d24ad78 Select boxes customization
jakubvrana authored
295 }
296 }
297 foreach ((array) $_GET["where"] as $val) {
298 if (strlen("$val[col]$val[val]") && in_array($val["op"], $this->operators)) {
98b88eb Remove fulltext search without index
jakubvrana authored
299 $in = process_length($val["val"]);
300 $cond = " $val[op]" . (ereg('NULL$', $val["op"]) ? "" : (ereg('IN$', $val["op"]) ? " (" . (strlen($in) ? $in : "NULL") . ")" : " " . $this->processInput($fields[$val["col"]], $val["val"])));
301 if (strlen($val["col"])) {
302 $return[] = idf_escape($val["col"]) . $cond;
d24ad78 Select boxes customization
jakubvrana authored
303 } else {
98b88eb Remove fulltext search without index
jakubvrana authored
304 // find anywhere
305 $cols = array();
306 foreach ($fields as $name => $field) {
307 if (is_numeric($val["val"]) || !ereg('int|float|double|decimal', $field["type"])) {
308 $cols[] = $name;
d24ad78 Select boxes customization
jakubvrana authored
309 }
310 }
98b88eb Remove fulltext search without index
jakubvrana authored
311 $return[] = ($cols ? "(" . implode("$cond OR ", array_map('idf_escape', $cols)) . "$cond)" : "0");
d24ad78 Select boxes customization
jakubvrana authored
312 }
313 }
314 }
315 return $return;
316 }
317
318 /** Process order box in select
319 * @param array
320 * @param array
321 * @return array expressions to join by comma
322 */
07e1ae1 FOUND_ROWS only with GROUP BY
jakubvrana authored
323 function selectOrderProcess($fields, $indexes) {
d24ad78 Select boxes customization
jakubvrana authored
324 $return = array();
325 foreach ((array) $_GET["order"] as $key => $val) {
821d040 Order by COUNT (thanks to paranoiq)
jakubvrana authored
326 if (isset($fields[$val]) || preg_match('~^((COUNT\\(DISTINCT |[A-Z0-9_]+\\()`(?:[^`]|``)+`\\)|COUNT\\(\\*\\))$~', $val)) {
d24ad78 Select boxes customization
jakubvrana authored
327 $return[] = idf_escape($val) . (isset($_GET["desc"][$key]) ? " DESC" : "");
328 }
329 }
330 return $return;
331 }
332
333 /** Process limit box in select
334 * @return string expression to use in LIMIT, will be escaped
335 */
336 function selectLimitProcess() {
337 return (isset($_GET["limit"]) ? $_GET["limit"] : "30");
338 }
339
340 /** Process length box in select
341 * @return string number of characters to shorten texts, will be escaped
342 */
343 function selectLengthProcess() {
344 return (isset($_GET["text_length"]) ? $_GET["text_length"] : "100");
345 }
346
c64c4fd Adminer class
jakubvrana authored
347 /** Process extras in select form
348 * @param array AND conditions
dea345c Substitute foreign keys in e-mail fields
jakubvrana authored
349 * @param array
c64c4fd Adminer class
jakubvrana authored
350 * @return bool true if processed, false to process other parts of form
351 */
dea345c Substitute foreign keys in e-mail fields
jakubvrana authored
352 function selectEmailProcess($where, $foreignKeys) {
c64c4fd Adminer class
jakubvrana authored
353 return false;
354 }
355
356 /** Query printed after execution in the message
357 * @param string executed query
358 * @return string
359 */
360 function messageQuery($query) {
361 $id = "sql-" . count($_SESSION["messages"]);
3022dcb Define DB
jakubvrana authored
362 $_SESSION["history"][$_GET["server"]][DB][] = $query;
363 return " <a href='#$id' onclick=\"return !toggle('$id');\">" . lang('SQL command') . "</a><div id='$id' class='hidden'><pre class='jush-sql'>" . h($query) . '</pre><a href="' . h(ME . 'sql=&history=' . (count($_SESSION["history"][$_GET["server"]][DB]) - 1)) . '">' . lang('Edit') . '</a></div>';
c64c4fd Adminer class
jakubvrana authored
364 }
365
366 /** Functions displayed in edit form
367 * @param array single field from fields()
368 * @return array
369 */
370 function editFunctions($field) {
371 $return = array("");
4cead56 Edit default values directly in table creation
jakubvrana authored
372 if (ereg('char|date|time', $field["type"])) {
373 $return = (ereg('char', $field["type"]) ? array("", "md5", "sha1", "password", "uuid") : array("", "now")); //! JavaScript for disabling maxlength
374 }
375 if (!isset($_GET["call"]) && (isset($_GET["select"]) || where($_GET))) {
376 // relative functions
377 if (ereg('int|float|double|decimal', $field["type"])) {
378 $return = array("", "+", "-");
4921235 Hide edit functions in Editor
jakubvrana authored
379 }
4cead56 Edit default values directly in table creation
jakubvrana authored
380 if (ereg('date', $field["type"])) {
381 $return[] = "+ interval";
382 $return[] = "- interval";
383 }
384 if (ereg('time', $field["type"])) {
385 $return[] = "addtime";
386 $return[] = "subtime";
4921235 Hide edit functions in Editor
jakubvrana authored
387 }
309f681 Relative function concat
jakubvrana authored
388 if (ereg('char|text', $field["type"])) {
389 $return[] = "concat";
390 }
4921235 Hide edit functions in Editor
jakubvrana authored
391 }
4cead56 Edit default values directly in table creation
jakubvrana authored
392 if ($field["null"]) {
c64c4fd Adminer class
jakubvrana authored
393 array_unshift($return, "NULL");
394 }
9fc052b Unselect original after value input
jakubvrana authored
395 return $return;
4921235 Hide edit functions in Editor
jakubvrana authored
396 }
c64c4fd Adminer class
jakubvrana authored
397
398 /** Get options to display edit field
399 * @param string table name
400 * @param array single field from fields()
e1abcda Treat tinyint(1) as boolean
jakubvrana authored
401 * @param string attributes to use inside the tag
402 * @param string
403 * @return string custom input field or empty string for default
c64c4fd Adminer class
jakubvrana authored
404 */
e1abcda Treat tinyint(1) as boolean
jakubvrana authored
405 function editInput($table, $field, $attrs, $value) {
406 return '';
4921235 Hide edit functions in Editor
jakubvrana authored
407 }
c64c4fd Adminer class
jakubvrana authored
408
409 /** Process sent input
410 * @param array single field from fields()
a0def47 Date localization
jakubvrana authored
411 * @param string
412 * @param string
c64c4fd Adminer class
jakubvrana authored
413 * @return string expression to use in a query
414 */
a0def47 Date localization
jakubvrana authored
415 function processInput($field, $value, $function = "") {
64d616c Rename get_dbh to connection
jakubvrana authored
416 global $connection;
a0def47 Date localization
jakubvrana authored
417 $name = $field["field"];
64d616c Rename get_dbh to connection
jakubvrana authored
418 $return = $connection->quote($value);
c64c4fd Adminer class
jakubvrana authored
419 if (ereg('^(now|uuid)$', $function)) {
420 $return = "$function()";
421 } elseif (ereg('^[+-]$', $function)) {
422 $return = idf_escape($name) . " $function $return";
423 } elseif (ereg('^[+-] interval$', $function)) {
424 $return = idf_escape($name) . " $function " . (preg_match("~^([0-9]+|'[0-9.: -]') [A-Z_]+$~i", $value) ? $value : $return);
309f681 Relative function concat
jakubvrana authored
425 } elseif (ereg('^(addtime|subtime|concat)$', $function)) {
c64c4fd Adminer class
jakubvrana authored
426 $return = "$function(" . idf_escape($name) . ", $return)";
427 } elseif (ereg('^(md5|sha1|password)$', $function)) {
428 $return = "$function($return)";
429 }
430 return $return;
a78c941 Empty value in Editor as NULL
jakubvrana authored
431 }
c64c4fd Adminer class
jakubvrana authored
432
433 /** Prints navigation after Adminer title
434 * @param string can be "auth" if there is no database connection or "db" if there is no database selected
435 * @return null
436 */
437 function navigation($missing) {
d3227c9 Move <h1> to $adminer->navigation
jakubvrana authored
438 global $VERSION;
439 ?>
440 <h1>
441 <a href="http://www.adminer.org/" id="h1"><?php echo $this->name(); ?></a>
442 <span class="version"><?php echo $VERSION; ?></span>
443 <a href="http://www.adminer.org/#download" id="version"><?php echo (version_compare($VERSION, $_COOKIE["adminer_version"]) < 0 ? h($_COOKIE["adminer_version"]) : ""); ?></a>
444 </h1>
445 <?php
c64c4fd Adminer class
jakubvrana authored
446 if ($missing != "auth") {
447 $databases = get_databases();
448 ?>
b95f24e Editor: User friendly data editor
jakubvrana authored
449 <form action="" method="post">
450 <p>
98507da Function verify_version doesn't use version parameter
jakubvrana authored
451 <a href="<?php echo h(ME); ?>sql="><?php echo lang('SQL command'); ?></a>
452 <a href="<?php echo h(ME); ?>dump=<?php echo urlencode(isset($_GET["table"]) ? $_GET["table"] : $_GET["select"]); ?>"><?php echo lang('Dump'); ?></a>
ace55ed HTML instead of XHTML
jakubvrana authored
453 <input type="hidden" name="token" value="<?php echo $_SESSION["tokens"][$_GET["server"]]; ?>">
454 <input type="submit" name="logout" value="<?php echo lang('Logout'); ?>">
d2ba593 Browsers interpret <form><p></form> as <form><p></form></p>
jakubvrana authored
455 </p>
b95f24e Editor: User friendly data editor
jakubvrana authored
456 </form>
457 <form action="">
25cef1f Disable session.use_trans_sid to preserve export result
jakubvrana authored
458 <p>
459 <?php if (SID) { ?><input type="hidden" name="<?php echo session_name(); ?>" value="<?php echo h(session_id()); ?>"><?php } ?>
460 <?php if (strlen($_GET["server"])) { ?><input type="hidden" name="server" value="<?php echo h($_GET["server"]); ?>"><?php } ?>
b95f24e Editor: User friendly data editor
jakubvrana authored
461 <?php if ($databases) { ?>
3022dcb Define DB
jakubvrana authored
462 <select name="db" onchange="this.form.submit();"><option value="">(<?php echo lang('database'); ?>)<?php echo optionlist($databases, DB); ?></select>
b95f24e Editor: User friendly data editor
jakubvrana authored
463 <?php } else { ?>
3022dcb Define DB
jakubvrana authored
464 <input name="db" value="<?php echo h(DB); ?>">
b95f24e Editor: User friendly data editor
jakubvrana authored
465 <?php } ?>
ace55ed HTML instead of XHTML
jakubvrana authored
466 <?php if (isset($_GET["sql"])) { ?><input type="hidden" name="sql" value=""><?php } ?>
467 <?php if (isset($_GET["schema"])) { ?><input type="hidden" name="schema" value=""><?php } ?>
468 <?php if (isset($_GET["dump"])) { ?><input type="hidden" name="dump" value=""><?php } ?>
469 <input type="submit" value="<?php echo lang('Use'); ?>"<?php echo ($databases ? " class='hidden'" : ""); ?>>
d2ba593 Browsers interpret <form><p></form> as <form><p></form></p>
jakubvrana authored
470 </p>
b95f24e Editor: User friendly data editor
jakubvrana authored
471 </form>
472 <?php
09e93de Move backward keys to Editor
jakubvrana authored
473 $this->tablesPrint($missing);
d3227c9 Move <h1> to $adminer->navigation
jakubvrana authored
474 }
475 }
476
477 /** Prints table list in menu
478 * @param string can be "db" if there is no database selected
479 * @return null
480 */
09e93de Move backward keys to Editor
jakubvrana authored
481 function tablesPrint($missing) {
64d616c Rename get_dbh to connection
jakubvrana authored
482 global $connection;
483 if ($missing != "db" && strlen(DB) && $connection->select_db(DB)) {
484 $result = $connection->query("SHOW TABLES");
d3227c9 Move <h1> to $adminer->navigation
jakubvrana authored
485 if (!$result->num_rows) {
486 echo "<p class='message'>" . lang('No tables.') . "\n";
487 } else {
488 echo "<p id='tables'>\n";
489 while ($row = $result->fetch_row()) {
490 echo '<a href="' . h(ME) . 'select=' . urlencode($row[0]) . '">' . lang('select') . '</a> ';
491 echo '<a href="' . h(ME) . 'table=' . urlencode($row[0]) . '">' . $this->tableName(array("Name" => $row[0])) . "</a><br>\n"; //! Adminer::tableName may work with full table status
b95f24e Editor: User friendly data editor
jakubvrana authored
492 }
493 }
d3227c9 Move <h1> to $adminer->navigation
jakubvrana authored
494 echo '<p><a href="' . h(ME) . 'create=">' . lang('Create new table') . "</a>\n";
b95f24e Editor: User friendly data editor
jakubvrana authored
495 }
496 }
c64c4fd Adminer class
jakubvrana authored
497
2c445a8 Extensibility basics
jakubvrana authored
498 }
464d84a Define functions unconditionally
jakubvrana authored
499
500 $adminer = (function_exists('adminer_object') ? adminer_object() : new Adminer);
Something went wrong with that request. Please try again.