Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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