Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 114 lines (105 sloc) 5.024 kB
2c445a8 Extensibility basics
jakubvrana authored
1 <?php
c16c57b E-mail sending
jakubvrana authored
2 /** Name in title and navigation
3 * @return string
4 */
5 function adminer_name() {
6 return call_adminer('name', lang('Adminer'));
7 }
8
9 /** Connection parameters
10 * @return array ($server, $username, $password)
11 */
12 function adminer_credentials() {
13 return call_adminer('credentials', array($_GET["server"], $_SESSION["usernames"][$_GET["server"]], $_SESSION["passwords"][$_GET["server"]]));
14 }
15
16 /** Identifier of selected database
17 * @return string
18 */
19 function adminer_database() {
20 // should be used everywhere instead of $_GET["db"]
21 return call_adminer('database', $_GET["db"]);
22 }
23
24 /** Table caption used in navigation and headings
25 * @param array result of SHOW TABLE STATUS
26 * @return string
27 */
28 function adminer_table_name($row) {
29 return call_adminer('table_name', htmlspecialchars($row["Name"]), $row);
30 }
31
32 /** Field caption used in select and edit
33 * @param array all fields in table, result of fields()
34 * @param string column identifier, function calls are not contained in $fields
35 * @return string
36 */
37 function adminer_field_name($fields, $key) {
cb2c957 Show type by field name (thanks to Jakub Sochor)
jakubvrana authored
38 return call_adminer('field_name', '<span title="' . htmlspecialchars($fields[$key]["full_type"]) . '">' . htmlspecialchars($key) . '</span>', $fields, $key);
c16c57b E-mail sending
jakubvrana authored
39 }
40
41 /** Links after select heading
42 * @param array result of SHOW TABLE STATUS
43 * @return string
44 */
45 function adminer_select_links($table_status) {
46 global $SELF;
47 return call_adminer('select_links', '<a href="' . htmlspecialchars($SELF) . (isset($table_status["Engine"]) ? 'table=' : 'view=') . urlencode($_GET['select']) . '">' . lang('Table structure') . '</a>', $table_status);
48 }
49
c74c06a Don't modify $query by adminer_select_query
jakubvrana authored
50 /** Query printed in select before execution
c16c57b E-mail sending
jakubvrana authored
51 * @param string query to be executed
52 * @return string
53 */
54 function adminer_select_query($query) {
55 global $SELF;
56 // it would be nice if $query can be passed by reference and printed value would be returned but call_user() doesn't allow reference parameters
ace55ed HTML instead of XHTML
jakubvrana authored
57 return call_adminer('select_query', "<p><code class='jush-sql'>" . htmlspecialchars($query) . "</code> <a href='" . htmlspecialchars($SELF) . "sql=" . urlencode($query) . "'>" . lang('Edit') . "</a>\n", $query);
c16c57b E-mail sending
jakubvrana authored
58 }
59
60 /** Query printed after execution in the message
61 * @param string executed query
62 * @return string
63 */
64 function adminer_message_query($query) {
65 global $SELF;
66 $id = "sql-" . count($_SESSION["messages"]);
67 return call_adminer('message_query', " <a href='#$id' onclick=\"return !toggle('$id');\">" . lang('SQL command') . "</a><div id='$id' class='hidden'><pre class='jush-sql'>" . htmlspecialchars($query) . '</pre><a href="' . htmlspecialchars($SELF . 'sql=&history=' . count($_SESSION["history"][$_GET["server"]][$_GET["db"]])) . '">' . lang('Edit') . '</a></div>', $query);
68 }
69
70 /** Prints navigation after Adminer title
71 * @param string can be "auth" if there is no database connection or "db" if there is no database selected
72 * @return bool true if default navigation should be printed
73 */
74 function adminer_navigation($missing) {
75 global $SELF;
76 if (call_adminer('navigation', true, $missing) && $missing != "auth") {
77 $databases = get_databases();
78 ?>
b95f24e Editor: User friendly data editor
jakubvrana authored
79 <form action="" method="post">
80 <p>
81 <a href="<?php echo htmlspecialchars($SELF); ?>sql="><?php echo lang('SQL command'); ?></a>
82 <a href="<?php echo htmlspecialchars($SELF); ?>dump=<?php echo urlencode(isset($_GET["table"]) ? $_GET["table"] : $_GET["select"]); ?>"><?php echo lang('Dump'); ?></a>
ace55ed HTML instead of XHTML
jakubvrana authored
83 <input type="hidden" name="token" value="<?php echo $_SESSION["tokens"][$_GET["server"]]; ?>">
84 <input type="submit" name="logout" value="<?php echo lang('Logout'); ?>">
b95f24e Editor: User friendly data editor
jakubvrana authored
85 </form>
86 <form action="">
ace55ed HTML instead of XHTML
jakubvrana authored
87 <p><?php if (strlen($_GET["server"])) { ?><input type="hidden" name="server" value="<?php echo htmlspecialchars($_GET["server"]); ?>"><?php } ?>
b95f24e Editor: User friendly data editor
jakubvrana authored
88 <?php if ($databases) { ?>
ace55ed HTML instead of XHTML
jakubvrana authored
89 <select name="db" onchange="this.form.submit();"><option value="">(<?php echo lang('database'); ?>)<?php echo optionlist($databases, $_GET["db"]); ?></select>
b95f24e Editor: User friendly data editor
jakubvrana authored
90 <?php } else { ?>
ace55ed HTML instead of XHTML
jakubvrana authored
91 <input name="db" value="<?php echo htmlspecialchars($_GET["db"]); ?>">
b95f24e Editor: User friendly data editor
jakubvrana authored
92 <?php } ?>
ace55ed HTML instead of XHTML
jakubvrana authored
93 <?php if (isset($_GET["sql"])) { ?><input type="hidden" name="sql" value=""><?php } ?>
94 <?php if (isset($_GET["schema"])) { ?><input type="hidden" name="schema" value=""><?php } ?>
95 <?php if (isset($_GET["dump"])) { ?><input type="hidden" name="dump" value=""><?php } ?>
96 <input type="submit" value="<?php echo lang('Use'); ?>"<?php echo ($databases ? " class='hidden'" : ""); ?>>
b95f24e Editor: User friendly data editor
jakubvrana authored
97 </form>
98 <?php
c16c57b E-mail sending
jakubvrana authored
99 if ($missing != "db" && strlen($_GET["db"])) {
100 $table_status = table_status();
101 if (!$table_status) {
ace55ed HTML instead of XHTML
jakubvrana authored
102 echo "<p class='message'>" . lang('No tables.') . "\n";
c16c57b E-mail sending
jakubvrana authored
103 } else {
104 echo "<p>\n";
105 foreach ($table_status as $row) {
106 echo '<a href="' . htmlspecialchars($SELF) . 'select=' . urlencode($row["Name"]) . '">' . lang('select') . '</a> ';
ace55ed HTML instead of XHTML
jakubvrana authored
107 echo '<a href="' . htmlspecialchars($SELF) . (isset($row["Rows"]) ? 'table' : 'view') . '=' . urlencode($row["Name"]) . '">' . adminer_table_name($row) . "</a><br>\n";
b95f24e Editor: User friendly data editor
jakubvrana authored
108 }
109 }
ace55ed HTML instead of XHTML
jakubvrana authored
110 echo '<p><a href="' . htmlspecialchars($SELF) . 'create=">' . lang('Create new table') . "</a>\n";
b95f24e Editor: User friendly data editor
jakubvrana authored
111 }
112 }
2c445a8 Extensibility basics
jakubvrana authored
113 }
Something went wrong with that request. Please try again.