Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 162 lines (149 sloc) 6.393 kb
2c445a86 »
2009-07-03 Extensibility basics
1 <?php
c16c57b1 »
2009-07-11 E-mail sending
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
2faa08cd »
2009-07-21 Customize login and login form
24 /** Print login form
25 * @param string
26 * @return bool whether to display default login form
27 */
28 function adminer_login_form($username) {
29 if (call_adminer('login_form', true, $username)) {
30 ?>
02054404 »
2009-07-21 HTML whitespace
31 <table cellspacing="0">
32 <tr><th><?php echo lang('Server'); ?><td><input name="server" value="<?php echo htmlspecialchars($_GET["server"]); ?>">
33 <tr><th><?php echo lang('Username'); ?><td><input name="username" value="<?php echo htmlspecialchars($username); ?>">
34 <tr><th><?php echo lang('Password'); ?><td><input type="password" name="password">
35 </table>
2faa08cd »
2009-07-21 Customize login and login form
36 <?php
37 }
38 }
39
40 /** Authorize the user
41 * @param string
42 * @param string
43 * @return bool
44 */
45 function adminer_login($login, $password) {
46 return call_adminer('login', true, $login, $password);
47 }
48
c16c57b1 »
2009-07-11 E-mail sending
49 /** Table caption used in navigation and headings
50 * @param array result of SHOW TABLE STATUS
51 * @return string
52 */
53 function adminer_table_name($row) {
54 return call_adminer('table_name', htmlspecialchars($row["Name"]), $row);
55 }
56
57 /** Field caption used in select and edit
58 * @param array all fields in table, result of fields()
59 * @param string column identifier, function calls are not contained in $fields
60 * @return string
61 */
62 function adminer_field_name($fields, $key) {
cb2c9571 »
2009-07-13 Show type by field name (thanks to Jakub Sochor)
63 return call_adminer('field_name', '<span title="' . htmlspecialchars($fields[$key]["full_type"]) . '">' . htmlspecialchars($key) . '</span>', $fields, $key);
c16c57b1 »
2009-07-11 E-mail sending
64 }
65
66 /** Links after select heading
67 * @param array result of SHOW TABLE STATUS
68 * @return string
69 */
70 function adminer_select_links($table_status) {
71 global $SELF;
72 return call_adminer('select_links', '<a href="' . htmlspecialchars($SELF) . (isset($table_status["Engine"]) ? 'table=' : 'view=') . urlencode($_GET['select']) . '">' . lang('Table structure') . '</a>', $table_status);
73 }
74
c74c06ad »
2009-07-11 Don't modify $query by adminer_select_query
75 /** Query printed in select before execution
c16c57b1 »
2009-07-11 E-mail sending
76 * @param string query to be executed
77 * @return string
78 */
79 function adminer_select_query($query) {
80 global $SELF;
81 // 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
ace55ed1 »
2009-07-11 HTML instead of XHTML
82 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);
c16c57b1 »
2009-07-11 E-mail sending
83 }
84
228e43a0 »
2009-07-20 Row descriptions in select
85 /** Descriptions of selected data
86 * @param array all data to print
87 * @param array foreign keys
88 * @return array
89 */
90 function adminer_row_descriptions($rows, $foreign_keys) {
91 return call_adminer('row_descriptions', $rows, $rows, $foreign_keys);
92 }
93
ba90d60b »
2009-07-14 Introduce adminer_select_val
94 /** Value printed in select table
95 * @param string escaped value to print
791ea4ff »
2009-07-15 Comment
96 * @param string link to foreign key
97 * @return string
ba90d60b »
2009-07-14 Introduce adminer_select_val
98 */
99 function adminer_select_val($val, $link) {
100 return call_adminer('select_val', ($link ? '<a href="' . $link . '">' . $val . '</a>' : $val), $val, $link);
101 }
102
c16c57b1 »
2009-07-11 E-mail sending
103 /** Query printed after execution in the message
104 * @param string executed query
105 * @return string
106 */
107 function adminer_message_query($query) {
108 global $SELF;
109 $id = "sql-" . count($_SESSION["messages"]);
04a3f5b3 »
2009-07-16 Save history in adminer_message_query
110 $_SESSION["history"][$_GET["server"]][$_GET["db"]][] = $query;
111 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"]]) - 1)) . '">' . lang('Edit') . '</a></div>', $query);
c16c57b1 »
2009-07-11 E-mail sending
112 }
113
114 /** Prints navigation after Adminer title
115 * @param string can be "auth" if there is no database connection or "db" if there is no database selected
116 * @return bool true if default navigation should be printed
117 */
118 function adminer_navigation($missing) {
119 global $SELF;
120 if (call_adminer('navigation', true, $missing) && $missing != "auth") {
4a014a6d »
2009-07-16 Always flush in navigation because table_status can take long
121 ob_flush();
122 flush();
c16c57b1 »
2009-07-11 E-mail sending
123 $databases = get_databases();
124 ?>
b95f24ea »
2009-07-03 Editor: User friendly data editor
125 <form action="" method="post">
126 <p>
127 <a href="<?php echo htmlspecialchars($SELF); ?>sql="><?php echo lang('SQL command'); ?></a>
128 <a href="<?php echo htmlspecialchars($SELF); ?>dump=<?php echo urlencode(isset($_GET["table"]) ? $_GET["table"] : $_GET["select"]); ?>"><?php echo lang('Dump'); ?></a>
ace55ed1 »
2009-07-11 HTML instead of XHTML
129 <input type="hidden" name="token" value="<?php echo $_SESSION["tokens"][$_GET["server"]]; ?>">
130 <input type="submit" name="logout" value="<?php echo lang('Logout'); ?>">
d2ba5938 »
2009-07-14 Browsers interpret <form><p></form> as <form><p></form></p>
131 </p>
b95f24ea »
2009-07-03 Editor: User friendly data editor
132 </form>
133 <form action="">
ace55ed1 »
2009-07-11 HTML instead of XHTML
134 <p><?php if (strlen($_GET["server"])) { ?><input type="hidden" name="server" value="<?php echo htmlspecialchars($_GET["server"]); ?>"><?php } ?>
b95f24ea »
2009-07-03 Editor: User friendly data editor
135 <?php if ($databases) { ?>
ace55ed1 »
2009-07-11 HTML instead of XHTML
136 <select name="db" onchange="this.form.submit();"><option value="">(<?php echo lang('database'); ?>)<?php echo optionlist($databases, $_GET["db"]); ?></select>
b95f24ea »
2009-07-03 Editor: User friendly data editor
137 <?php } else { ?>
ace55ed1 »
2009-07-11 HTML instead of XHTML
138 <input name="db" value="<?php echo htmlspecialchars($_GET["db"]); ?>">
b95f24ea »
2009-07-03 Editor: User friendly data editor
139 <?php } ?>
ace55ed1 »
2009-07-11 HTML instead of XHTML
140 <?php if (isset($_GET["sql"])) { ?><input type="hidden" name="sql" value=""><?php } ?>
141 <?php if (isset($_GET["schema"])) { ?><input type="hidden" name="schema" value=""><?php } ?>
142 <?php if (isset($_GET["dump"])) { ?><input type="hidden" name="dump" value=""><?php } ?>
143 <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>
144 </p>
b95f24ea »
2009-07-03 Editor: User friendly data editor
145 </form>
146 <?php
c16c57b1 »
2009-07-11 E-mail sending
147 if ($missing != "db" && strlen($_GET["db"])) {
148 $table_status = table_status();
149 if (!$table_status) {
ace55ed1 »
2009-07-11 HTML instead of XHTML
150 echo "<p class='message'>" . lang('No tables.') . "\n";
c16c57b1 »
2009-07-11 E-mail sending
151 } else {
152 echo "<p>\n";
153 foreach ($table_status as $row) {
154 echo '<a href="' . htmlspecialchars($SELF) . 'select=' . urlencode($row["Name"]) . '">' . lang('select') . '</a> ';
ace55ed1 »
2009-07-11 HTML instead of XHTML
155 echo '<a href="' . htmlspecialchars($SELF) . (isset($row["Rows"]) ? 'table' : 'view') . '=' . urlencode($row["Name"]) . '">' . adminer_table_name($row) . "</a><br>\n";
b95f24ea »
2009-07-03 Editor: User friendly data editor
156 }
157 }
ace55ed1 »
2009-07-11 HTML instead of XHTML
158 echo '<p><a href="' . htmlspecialchars($SELF) . 'create=">' . lang('Create new table') . "</a>\n";
b95f24ea »
2009-07-03 Editor: User friendly data editor
159 }
160 }
2c445a86 »
2009-07-03 Extensibility basics
161 }
Something went wrong with that request. Please try again.