Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 520 lines (481 sloc) 18.343 kb
2c445a86 »
2009-07-03 Extensibility basics
1 <?php
c64c4fd1 »
2009-07-27 Adminer class
2 class Adminer {
d24ad780 »
2009-07-27 Select boxes customization
3 var $functions = array("char_length", "from_unixtime", "hex", "lower", "round", "sec_to_time", "time_to_sec", "unix_timestamp", "upper");
e0fbf333 »
2009-08-18 Rename distinct to count distinct
4 var $grouping = array("avg", "count", "count distinct", "group_concat", "max", "min", "sum");
d24ad780 »
2009-07-27 Select boxes customization
5 var $operators = array("=", "<", ">", "<=", ">=", "!=", "LIKE", "REGEXP", "IN", "IS NULL", "NOT LIKE", "NOT REGEXP", "NOT IN", "IS NOT NULL");
c64c4fd1 »
2009-07-27 Adminer class
6
7 /** Name in title and navigation
8 * @return string
9 */
10 function name() {
b3496120 »
2009-08-25 Remove useless translations
11 return "Adminer";
c64c4fd1 »
2009-07-27 Adminer class
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() {
3022dcb8 »
2009-08-29 Define DB
25 // should be used everywhere instead of DB
26 return DB;
c64c4fd1 »
2009-07-27 Adminer class
27 }
28
29 /** Print login form
30 * @param string
31 * @return null
32 */
33 function loginForm($username) {
2faa08cd »
2009-07-21 Customize login and login form
34 ?>
02054404 »
2009-07-21 HTML whitespace
35 <table cellspacing="0">
689699aa »
2009-07-28 Shortcut for htmlspecialchars
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); ?>">
02054404 »
2009-07-21 HTML whitespace
38 <tr><th><?php echo lang('Password'); ?><td><input type="password" name="password">
39 </table>
2faa08cd »
2009-07-21 Customize login and login form
40 <?php
41 }
c64c4fd1 »
2009-07-27 Adminer class
42
43 /** Authorize the user
44 * @param string
45 * @param string
46 * @return bool
47 */
48 function login($login, $password) {
49 return true;
97b8c7b6 »
2009-07-24 Display images in Editor
50 }
c64c4fd1 »
2009-07-27 Adminer class
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) {
689699aa »
2009-07-28 Shortcut for htmlspecialchars
57 return h($tableStatus["Name"]);
c64c4fd1 »
2009-07-27 Adminer class
58 }
59
60 /** Field caption used in select and edit
61 * @param array single field returned from fields()
6c97b806 »
2009-07-27 Display only first five columns in Editor example
62 * @param int order of column in select
c64c4fd1 »
2009-07-27 Adminer class
63 * @return string
64 */
6c97b806 »
2009-07-27 Display only first five columns in Editor example
65 function fieldName($field, $order = 0) {
689699aa »
2009-07-28 Shortcut for htmlspecialchars
66 return '<span title="' . h($field["full_type"]) . '">' . h($field["field"]) . '</span>';
c64c4fd1 »
2009-07-27 Adminer class
67 }
68
f2ed2379 »
2009-09-20 Display table links above table structure
69 /** Print links after select heading
c64c4fd1 »
2009-07-27 Adminer class
70 * @param array result of SHOW TABLE STATUS
f2ed2379 »
2009-09-20 Display table links above table structure
71 * @param strin new item options, NULL for no new item
72 * @return null
c64c4fd1 »
2009-07-27 Adminer class
73 */
f2ed2379 »
2009-09-20 Display table links above table structure
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";
c64c4fd1 »
2009-07-27 Adminer class
87 }
88
89 /** Find backward keys for table
90 * @param string
09e93ded »
2009-09-23 Move backward keys to Editor
91 * @param string
92 * @return array $return[$target_table]["keys"][$key_name][$target_column] = $source_column; $return[$target_table]["name"] = $this->tableName($target_table);
c64c4fd1 »
2009-07-27 Adminer class
93 */
09e93ded »
2009-09-23 Move backward keys to Editor
94 function backwardKeys($table, $tableName) {
c64c4fd1 »
2009-07-27 Adminer class
95 return array();
96 }
97
09e93ded »
2009-09-23 Move backward keys to Editor
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
c64c4fd1 »
2009-07-27 Adminer class
106 /** Query printed in select before execution
107 * @param string query to be executed
108 * @return string
109 */
110 function selectQuery($query) {
9c09ebe1 »
2009-09-11 End element for IE
111 return "<p><code class='jush-sql'>" . h($query) . "</code> <a href='" . h(ME) . "sql=" . urlencode($query) . "'>" . lang('Edit') . "</a></p>\n";
c64c4fd1 »
2009-07-27 Adminer class
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
a0def479 »
2009-07-27 Date localization
132 * @param string HTML-escaped value to print
c64c4fd1 »
2009-07-27 Adminer class
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));
49212350 »
2009-07-23 Hide edit functions in Editor
141 }
12c042ce »
2009-07-30 Function htmlspecialchars now uses ENT_QUOTES
142 return ($link ? "<a href='$link'>$return</a>" : $return);
c64c4fd1 »
2009-07-27 Adminer class
143 }
144
a0def479 »
2009-07-27 Date localization
145 /** Value conversion used in select and edit
146 * @param string
147 * @param array single field returned from fields()
20114285 »
2009-07-28 Use LIKE operator in Editor
148 * @return string
a0def479 »
2009-07-27 Date localization
149 */
150 function editVal($val, $field) {
151 return $val;
152 }
153
d24ad780 »
2009-07-27 Select boxes customization
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) {
dc667ea1 »
2009-09-11 Hide select export and import
160 print_fieldset("select", lang('Select'), $select);
d24ad780 »
2009-07-27 Select boxes customization
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];
06984091 »
2009-10-02 Utilize html_select
165 echo "<div>" . html_select("columns[$i][fun]", array(-1 => "") + $fun_group, $val["fun"]);
d24ad780 »
2009-07-27 Select boxes customization
166 echo "<select name='columns[$i][col]'><option>" . optionlist($columns, $val["col"], true) . "</select></div>\n";
167 $i++;
168 }
06984091 »
2009-10-02 Utilize html_select
169 echo "<div>" . html_select("columns[$i][fun]", array(-1 => "") + $fun_group, "", "this.nextSibling.onchange();");
d24ad780 »
2009-07-27 Select boxes customization
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) {
dc667ea1 »
2009-09-11 Hide select export and import
181 print_fieldset("search", lang('Search'), $where);
d24ad780 »
2009-07-27 Select boxes customization
182 foreach ($indexes as $i => $index) {
183 if ($index["type"] == "FULLTEXT") {
689699aa »
2009-07-28 Shortcut for htmlspecialchars
184 echo "(<i>" . implode("</i>, <i>", array_map('h', $index["columns"])) . "</i>) AGAINST";
185 echo " <input name='fulltext[$i]' value='" . h($_GET["fulltext"][$i]) . "'>";
6b30cfa7 »
2009-09-25 Separate checkbox
186 echo checkbox("boolean[$i]", 1, isset($_GET["boolean"][$i]), "BOOL");
d24ad780 »
2009-07-27 Select boxes customization
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>";
06984091 »
2009-10-02 Utilize html_select
194 echo html_select("where[$i][op]", $this->operators, $val["op"]);
689699aa »
2009-07-28 Shortcut for htmlspecialchars
195 echo "<input name='where[$i][val]' value='" . h($val["val"]) . "'></div>\n";
d24ad780 »
2009-07-27 Select boxes customization
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>";
06984091 »
2009-10-02 Utilize html_select
200 echo html_select("where[$i][op]", $this->operators);
d24ad780 »
2009-07-27 Select boxes customization
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) {
dc667ea1 »
2009-09-11 Hide select export and import
212 print_fieldset("sort", lang('Sort'), $order);
d24ad780 »
2009-07-27 Select boxes customization
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>";
6b30cfa7 »
2009-09-25 Separate checkbox
217 echo checkbox("desc[$i]", 1, isset($_GET["desc"][$key]), lang('descending')) . "</div>\n";
d24ad780 »
2009-07-27 Select boxes customization
218 $i++;
219 }
220 }
221 echo "<div><select name='order[$i]' onchange='select_add_row(this);'><option>" . optionlist($columns, null, true) . "</select>";
6b30cfa7 »
2009-09-25 Separate checkbox
222 echo checkbox("desc[$i]", 1, 0, lang('descending')) . "</div>\n";
d24ad780 »
2009-07-27 Select boxes customization
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
689699aa »
2009-07-28 Shortcut for htmlspecialchars
232 echo "<input name='limit' size='3' value='" . h($limit) . "'>";
d24ad780 »
2009-07-27 Select boxes customization
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>";
689699aa »
2009-07-28 Shortcut for htmlspecialchars
243 echo '<input name="text_length" size="3" value="' . h($text_length) . '">';
d24ad780 »
2009-07-27 Select boxes customization
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
1a6a73ad »
2009-07-28 Rename selectExtra to selectEmail
257 /** Print extra text in the end of a select form
258 * @param array fields holding e-mails
1e55d475 »
2009-09-09 User interface for e-mail {$name}
259 * @param array selectable columns
1a6a73ad »
2009-07-28 Rename selectExtra to selectEmail
260 * @return null
261 */
1e55d475 »
2009-09-09 User interface for e-mail {$name}
262 function selectEmailPrint($emailFields, $columns) {
1a6a73ad »
2009-07-28 Rename selectExtra to selectEmail
263 }
264
d24ad780 »
2009-07-27 Select boxes customization
265 /** Process columns box in select
266 * @param array selectable columns
1e55d475 »
2009-09-09 User interface for e-mail {$name}
267 * @param array
d24ad780 »
2009-07-27 Select boxes customization
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 */
07e1ae10 »
2009-07-28 FOUND_ROWS only with GROUP BY
289 function selectSearchProcess($fields, $indexes) {
64d616c0 »
2009-09-22 Rename get_dbh to connection
290 global $connection;
d24ad780 »
2009-07-27 Select boxes customization
291 $return = array();
292 foreach ($indexes as $i => $index) {
293 if ($index["type"] == "FULLTEXT" && strlen($_GET["fulltext"][$i])) {
64d616c0 »
2009-09-22 Rename get_dbh to connection
294 $return[] = "MATCH (" . implode(", ", array_map('idf_escape', $index["columns"])) . ") AGAINST (" . $connection->quote($_GET["fulltext"][$i]) . (isset($_GET["boolean"][$i]) ? " IN BOOLEAN MODE" : "") . ")";
d24ad780 »
2009-07-27 Select boxes customization
295 }
296 }
297 foreach ((array) $_GET["where"] as $val) {
298 if (strlen("$val[col]$val[val]") && in_array($val["op"], $this->operators)) {
98b88eb1 »
2009-07-28 Remove fulltext search without index
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;
d24ad780 »
2009-07-27 Select boxes customization
303 } else {
98b88eb1 »
2009-07-28 Remove fulltext search without index
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;
d24ad780 »
2009-07-27 Select boxes customization
309 }
310 }
98b88eb1 »
2009-07-28 Remove fulltext search without index
311 $return[] = ($cols ? "(" . implode("$cond OR ", array_map('idf_escape', $cols)) . "$cond)" : "0");
d24ad780 »
2009-07-27 Select boxes customization
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 */
07e1ae10 »
2009-07-28 FOUND_ROWS only with GROUP BY
323 function selectOrderProcess($fields, $indexes) {
d24ad780 »
2009-07-27 Select boxes customization
324 $return = array();
325 foreach ((array) $_GET["order"] as $key => $val) {
821d040d »
2009-08-24 Order by COUNT (thanks to paranoiq)
326 if (isset($fields[$val]) || preg_match('~^((COUNT\\(DISTINCT |[A-Z0-9_]+\\()`(?:[^`]|``)+`\\)|COUNT\\(\\*\\))$~', $val)) {
d24ad780 »
2009-07-27 Select boxes customization
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
c64c4fd1 »
2009-07-27 Adminer class
347 /** Process extras in select form
348 * @param array AND conditions
dea345cb »
2009-09-09 Substitute foreign keys in e-mail fields
349 * @param array
c64c4fd1 »
2009-07-27 Adminer class
350 * @return bool true if processed, false to process other parts of form
351 */
dea345cb »
2009-09-09 Substitute foreign keys in e-mail fields
352 function selectEmailProcess($where, $foreignKeys) {
c64c4fd1 »
2009-07-27 Adminer class
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"]);
3022dcb8 »
2009-08-29 Define DB
362 $_SESSION["history"][$_GET["server"]][DB][] = $query;
11982f17 »
2009-09-24 Shorten printed SQL query
363 return " <a href='#$id' onclick=\"return !toggle('$id');\">" . lang('SQL command') . "</a><div id='$id' class='hidden'><pre class='jush-sql'>" . shorten_utf8($query, 1000) . '</pre><a href="' . h(ME . 'sql=&history=' . (count($_SESSION["history"][$_GET["server"]][DB]) - 1)) . '">' . lang('Edit') . '</a></div>';
c64c4fd1 »
2009-07-27 Adminer class
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("");
4cead560 »
2009-08-21 Edit default values directly in table creation
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("", "+", "-");
49212350 »
2009-07-23 Hide edit functions in Editor
379 }
4cead560 »
2009-08-21 Edit default values directly in table creation
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";
49212350 »
2009-07-23 Hide edit functions in Editor
387 }
309f6813 »
2009-08-28 Relative function concat
388 if (ereg('char|text', $field["type"])) {
389 $return[] = "concat";
390 }
49212350 »
2009-07-23 Hide edit functions in Editor
391 }
4cead560 »
2009-08-21 Edit default values directly in table creation
392 if ($field["null"]) {
c64c4fd1 »
2009-07-27 Adminer class
393 array_unshift($return, "NULL");
394 }
9fc052b7 »
2009-07-28 Unselect original after value input
395 return $return;
49212350 »
2009-07-23 Hide edit functions in Editor
396 }
c64c4fd1 »
2009-07-27 Adminer class
397
398 /** Get options to display edit field
399 * @param string table name
400 * @param array single field from fields()
e1abcda0 »
2009-07-28 Treat tinyint(1) as boolean
401 * @param string attributes to use inside the tag
402 * @param string
403 * @return string custom input field or empty string for default
c64c4fd1 »
2009-07-27 Adminer class
404 */
e1abcda0 »
2009-07-28 Treat tinyint(1) as boolean
405 function editInput($table, $field, $attrs, $value) {
406 return '';
49212350 »
2009-07-23 Hide edit functions in Editor
407 }
c64c4fd1 »
2009-07-27 Adminer class
408
409 /** Process sent input
410 * @param array single field from fields()
a0def479 »
2009-07-27 Date localization
411 * @param string
412 * @param string
c64c4fd1 »
2009-07-27 Adminer class
413 * @return string expression to use in a query
414 */
a0def479 »
2009-07-27 Date localization
415 function processInput($field, $value, $function = "") {
64d616c0 »
2009-09-22 Rename get_dbh to connection
416 global $connection;
a0def479 »
2009-07-27 Date localization
417 $name = $field["field"];
64d616c0 »
2009-09-22 Rename get_dbh to connection
418 $return = $connection->quote($value);
c64c4fd1 »
2009-07-27 Adminer class
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);
309f6813 »
2009-08-28 Relative function concat
425 } elseif (ereg('^(addtime|subtime|concat)$', $function)) {
c64c4fd1 »
2009-07-27 Adminer class
426 $return = "$function(" . idf_escape($name) . ", $return)";
427 } elseif (ereg('^(md5|sha1|password)$', $function)) {
428 $return = "$function($return)";
429 }
430 return $return;
a78c941c »
2009-07-23 Empty value in Editor as NULL
431 }
c64c4fd1 »
2009-07-27 Adminer class
432
e40612a4 »
2009-10-02 Use radio in export
433 /** Returns export output options
434 * @param bool generate select (otherwise radio)
435 * @return string
436 */
437 function dumpOutput($select) {
438 $return = array('text' => lang('open'), 'file' => lang('save'));
439 if (function_exists('gzencode')) {
440 $return['gz'] = 'gzip';
441 }
442 if (function_exists('bzcompress')) {
443 $return['bz2'] = 'bzip2';
444 }
445 // ZipArchive requires temporary file, ZIP can be created by gzcompress - see PEAR File_Archive
446 return html_select("output", $return, "text", $select);
447 }
448
449 /** Returns export format options
450 * @param bool generate select (otherwise radio)
451 * @return string
452 */
453 function dumpFormat($select) {
454 return html_select("format", array('sql' => 'SQL', 'csv' => 'CSV'), "sql", $select);
455 }
456
c64c4fd1 »
2009-07-27 Adminer class
457 /** Prints navigation after Adminer title
458 * @param string can be "auth" if there is no database connection or "db" if there is no database selected
459 * @return null
460 */
461 function navigation($missing) {
df0c4bba »
2009-09-23 Simplify tablesPrint
462 global $VERSION, $connection;
d3227c96 »
2009-09-19 Move <h1> to $adminer->navigation
463 ?>
464 <h1>
465 <a href="http://www.adminer.org/" id="h1"><?php echo $this->name(); ?></a>
466 <span class="version"><?php echo $VERSION; ?></span>
467 <a href="http://www.adminer.org/#download" id="version"><?php echo (version_compare($VERSION, $_COOKIE["adminer_version"]) < 0 ? h($_COOKIE["adminer_version"]) : ""); ?></a>
468 </h1>
469 <?php
c64c4fd1 »
2009-07-27 Adminer class
470 if ($missing != "auth") {
471 $databases = get_databases();
472 ?>
b95f24ea »
2009-07-03 Editor: User friendly data editor
473 <form action="" method="post">
474 <p>
98507da3 »
2009-07-30 Function verify_version doesn't use version parameter
475 <a href="<?php echo h(ME); ?>sql="><?php echo lang('SQL command'); ?></a>
476 <a href="<?php echo h(ME); ?>dump=<?php echo urlencode(isset($_GET["table"]) ? $_GET["table"] : $_GET["select"]); ?>"><?php echo lang('Dump'); ?></a>
ace55ed1 »
2009-07-11 HTML instead of XHTML
477 <input type="hidden" name="token" value="<?php echo $_SESSION["tokens"][$_GET["server"]]; ?>">
478 <input type="submit" name="logout" value="<?php echo lang('Logout'); ?>">
d2ba5938 »
2009-07-14 Browsers interpret <form><p></form> as <form><p></form></p>
479 </p>
b95f24ea »
2009-07-03 Editor: User friendly data editor
480 </form>
481 <form action="">
25cef1ff »
2009-08-30 Disable session.use_trans_sid to preserve export result
482 <p>
483 <?php if (SID) { ?><input type="hidden" name="<?php echo session_name(); ?>" value="<?php echo h(session_id()); ?>"><?php } ?>
484 <?php if (strlen($_GET["server"])) { ?><input type="hidden" name="server" value="<?php echo h($_GET["server"]); ?>"><?php } ?>
06984091 »
2009-10-02 Utilize html_select
485 <?php echo ($databases ? html_select("db", array("" => "(" . lang('database') . ")") + $databases, DB, "this.form.submit();") : '<input name="db" value="' . h(DB) . '">'); ?>
ace55ed1 »
2009-07-11 HTML instead of XHTML
486 <?php if (isset($_GET["sql"])) { ?><input type="hidden" name="sql" value=""><?php } ?>
487 <?php if (isset($_GET["schema"])) { ?><input type="hidden" name="schema" value=""><?php } ?>
488 <?php if (isset($_GET["dump"])) { ?><input type="hidden" name="dump" value=""><?php } ?>
489 <input type="submit" value="<?php echo lang('Use'); ?>"<?php echo ($databases ? " class='hidden'" : ""); ?>>
d2ba5938 »
2009-07-14 Browsers interpret <form><p></form> as <form><p></form></p>
490 </p>
b95f24ea »
2009-07-03 Editor: User friendly data editor
491 </form>
492 <?php
df0c4bba »
2009-09-23 Simplify tablesPrint
493 if ($missing != "db" && strlen(DB) && $connection->select_db(DB)) {
5e01a627 »
2009-10-16 Prepare for SQLite
494 $tables = tables_list();
df0c4bba »
2009-09-23 Simplify tablesPrint
495 if (!$tables) {
496 echo "<p class='message'>" . lang('No tables.') . "\n";
497 } else {
498 $this->tablesPrint($tables);
499 }
500 echo '<p><a href="' . h(ME) . 'create=">' . lang('Create new table') . "</a>\n";
501 }
d3227c96 »
2009-09-19 Move <h1> to $adminer->navigation
502 }
503 }
504
505 /** Prints table list in menu
df0c4bba »
2009-09-23 Simplify tablesPrint
506 * @param array
d3227c96 »
2009-09-19 Move <h1> to $adminer->navigation
507 * @return null
508 */
df0c4bba »
2009-09-23 Simplify tablesPrint
509 function tablesPrint($tables) {
510 echo "<p id='tables'>\n";
511 foreach ($tables as $table) {
512 echo '<a href="' . h(ME) . 'select=' . urlencode($table) . '">' . lang('select') . '</a> ';
513 echo '<a href="' . h(ME) . 'table=' . urlencode($table) . '">' . $this->tableName(array("Name" => $table)) . "</a><br>\n"; //! Adminer::tableName may work with full table status
b95f24ea »
2009-07-03 Editor: User friendly data editor
514 }
515 }
c64c4fd1 »
2009-07-27 Adminer class
516
2c445a86 »
2009-07-03 Extensibility basics
517 }
464d84af »
2009-09-09 Define functions unconditionally
518
519 $adminer = (function_exists('adminer_object') ? adminer_object() : new Adminer);
Something went wrong with that request. Please try again.