Skip to content
Newer
Older
100644 310 lines (294 sloc) 13.8 KB
667bfec Decomposition
jakubvrana authored
1 <?php
79d1902 Substitute table name to $TABLE
jakubvrana authored
2 $TABLE = $_GET["select"];
3 $table_status = table_status($TABLE);
4 $indexes = indexes($TABLE);
5 $fields = fields($TABLE);
dea345c Substitute foreign keys in e-mail fields
jakubvrana authored
6 $foreign_keys = column_foreign_keys($TABLE);
7
64ba924 Comments
jakubvrana authored
8 $rights = array(); // privilege => 0
9 $columns = array(); // selectable columns
02a851c Shorten texts in PHP
jakubvrana authored
10 unset($text_length);
ffcea8b Rights
jakubvrana authored
11 foreach ($fields as $key => $field) {
c64c4fd Adminer class
jakubvrana authored
12 $name = $adminer->fieldName($field);
7352c28 Replace strlen() by != ""
jakubvrana authored
13 if (isset($field["privileges"]["select"]) && $name != "") {
1e4d11e Select from foreign keys in Editor
jakubvrana authored
14 $columns[$key] = html_entity_decode(strip_tags($name));
5abd943 Change simple preg_match to ereg
jakubvrana authored
15 if (ereg('text|blob', $field["type"])) {
d24ad78 Select boxes customization
jakubvrana authored
16 $text_length = $adminer->selectLengthProcess();
16c4ddb Single faster POST query with primary key
jakubvrana authored
17 }
ffcea8b Rights
jakubvrana authored
18 }
430034c Cottage homework
jakubvrana authored
19 $rights += $field["privileges"];
20 }
21
d24ad78 Select boxes customization
jakubvrana authored
22 list($select, $group) = $adminer->selectColumnsProcess($columns, $indexes);
07e1ae1 FOUND_ROWS only with GROUP BY
jakubvrana authored
23 $where = $adminer->selectSearchProcess($fields, $indexes);
24 $order = $adminer->selectOrderProcess($fields, $indexes);
d24ad78 Select boxes customization
jakubvrana authored
25 $limit = $adminer->selectLimitProcess();
e44fbc2 Wrap SQL query
jakubvrana authored
26 $from = ($select ? implode(", ", $select) : "*") . "\nFROM " . idf_escape($TABLE) . ($where ? "\nWHERE " . implode(" AND ", $where) : "");
27 $group_by = ($group && count($group) < count($select) ? "\nGROUP BY " . implode(", ", $group) : "") . ($order ? "\nORDER BY " . implode(", ", $order) : "");
116faf2 Mass delete
jakubvrana authored
28
29 if ($_POST && !$error) {
56948c9 $_POST[check] may be empty
jakubvrana authored
30 $where_check = "(" . implode(") OR (", array_map('where_check', (array) $_POST["check"])) . ")";
a3d2266 Order by first index in Editor by default
jakubvrana authored
31 $primary = ($indexes["PRIMARY"] ? ($select ? array_flip($indexes["PRIMARY"]["columns"]) : array()) : null); // empty array means that all primary fields are selected
d24ad78 Select boxes customization
jakubvrana authored
32 foreach ($select as $key => $val) {
33 $val = $_GET["columns"][$key];
34 if (!$val["fun"]) {
35 unset($primary[$val["col"]]);
36 }
37 }
78639a9 Function results in edit
jakubvrana authored
38 if ($_POST["export"]) {
79d1902 Substitute table name to $TABLE
jakubvrana authored
39 dump_headers($TABLE);
40 dump_table($TABLE, "");
e4f5d17 Dump column names in CSV select export
jakubvrana authored
41 if ($_POST["format"] != "sql") { // Editor doesn't send format
b79ef09 Don't dump backticks in CSV column names
jakubvrana authored
42 $row = array_keys($fields);
43 if ($select) {
44 $row = array();
45 foreach ($select as $val) {
46 $row[] = (ereg('^`(.*)`$', $val, $match) ? idf_unescape($match[1]) : $val); //! columns looking like functions
47 }
48 }
49 dump_csv($row);
e4f5d17 Dump column names in CSV select export
jakubvrana authored
50 }
16c4ddb Single faster POST query with primary key
jakubvrana authored
51 if (!is_array($_POST["check"]) || $primary === array()) {
79d1902 Substitute table name to $TABLE
jakubvrana authored
52 dump_data($TABLE, "INSERT", "SELECT $from" . (is_array($_POST["check"]) ? ($where ? " AND " : " WHERE ") . "($where_check)" : "") . $group_by);
16c4ddb Single faster POST query with primary key
jakubvrana authored
53 } else {
fa5c952 Use extended INSERT in select export
jakubvrana authored
54 $union = array();
f7452ad Import and export
jakubvrana authored
55 foreach ($_POST["check"] as $val) {
16c4ddb Single faster POST query with primary key
jakubvrana authored
56 // where is not unique so OR can't be used
c16c57b E-mail sending
jakubvrana authored
57 $union[] = "(SELECT $from " . ($where ? "AND " : "WHERE ") . where_check($val) . $group_by . " LIMIT 1)";
116faf2 Mass delete
jakubvrana authored
58 }
79d1902 Substitute table name to $TABLE
jakubvrana authored
59 dump_data($TABLE, "INSERT", implode(" UNION ALL ", $union));
116faf2 Mass delete
jakubvrana authored
60 }
78639a9 Function results in edit
jakubvrana authored
61 exit;
62 }
dea345c Substitute foreign keys in e-mail fields
jakubvrana authored
63 if (!$adminer->selectEmailProcess($where, $foreign_keys)) {
00d9b36 E-mail sending only in Editor
jakubvrana authored
64 if (!$_POST["import"]) { // edit
65 $result = true;
66 $affected = 0;
a705b66 Truncate requires DROP privilege since MySQL 5.1.16 and is available …
jakubvrana authored
67 $command = ($_POST["delete"] ? "DELETE FROM " : ($_POST["clone"] ? "INSERT INTO " : "UPDATE ")) . idf_escape($TABLE);
28b2b8d Readable variable initialization
jakubvrana authored
68 $set = array();
00d9b36 E-mail sending only in Editor
jakubvrana authored
69 if (!$_POST["delete"]) {
70 foreach ($columns as $name => $val) { //! should check also for edit or insert privileges
a0def47 Date localization
jakubvrana authored
71 $val = process_input($fields[$name]);
00d9b36 E-mail sending only in Editor
jakubvrana authored
72 if ($_POST["clone"]) {
45e0de7 Include columns list in clone
jakubvrana authored
73 $set[idf_escape($name)] = ($val !== false ? $val : idf_escape($name));
00d9b36 E-mail sending only in Editor
jakubvrana authored
74 } elseif ($val !== false) {
75 $set[] = idf_escape($name) . " = $val";
76 }
e7eb28d CSV import
jakubvrana authored
77 }
45e0de7 Include columns list in clone
jakubvrana authored
78 $command .= ($_POST["clone"] ? " (" . implode(", ", array_keys($set)) . ")\nSELECT " . implode(", ", $set) . "\nFROM " . idf_escape($TABLE) : " SET\n" . implode(",\n", $set));
e7eb28d CSV import
jakubvrana authored
79 }
00d9b36 E-mail sending only in Editor
jakubvrana authored
80 if ($_POST["delete"] || $set) {
81 if ($_POST["all"] || ($primary === array() && $_POST["check"])) {
82 $result = queries($command . ($_POST["all"] ? ($where ? "\nWHERE " . implode(" AND ", $where) : "") : "\nWHERE $where_check"));
64d616c Rename get_dbh to connection
jakubvrana authored
83 $affected = $connection->affected_rows;
00d9b36 E-mail sending only in Editor
jakubvrana authored
84 } else {
85 foreach ((array) $_POST["check"] as $val) {
86 // where is not unique so OR can't be used
988a29f Don't use aggregation functions in unique_idf
jakubvrana authored
87 $result = queries($command . "\nWHERE " . where_check($val) . (count($group) < count($select) ? "" : "\nLIMIT 1"));
00d9b36 E-mail sending only in Editor
jakubvrana authored
88 if (!$result) {
89 break;
90 }
64d616c Rename get_dbh to connection
jakubvrana authored
91 $affected += $connection->affected_rows;
38059b6 Remove empty if
jakubvrana authored
92 }
e7eb28d CSV import
jakubvrana authored
93 }
78639a9 Function results in edit
jakubvrana authored
94 }
dbdd40a Introduce queries_redirect function
jakubvrana authored
95 queries_redirect(remove_from_uri("page"), lang('%d item(s) have been affected.', $affected), $result);
00d9b36 E-mail sending only in Editor
jakubvrana authored
96 //! display edit page in case of an error
25f01d3 Compress export and import
jakubvrana authored
97 } elseif (is_string($file = get_file("csv_file", true))) {
00d9b36 E-mail sending only in Editor
jakubvrana authored
98 $file = preg_replace("~^\xEF\xBB\xBF~", '', $file); //! character set
cb370a8 Respect max_allowed_packet in CSV import
jakubvrana authored
99 $result = true;
e895368 Use ON DUPLICATE KEY UPDATE for CSV import
jakubvrana authored
100 $cols = array_keys($fields);
8a04897 Use atomic group for CSV regexp
jakubvrana authored
101 preg_match_all('~(?>"[^"]*"|[^"\\r\\n]+)+~', $file, $matches);
e895368 Use ON DUPLICATE KEY UPDATE for CSV import
jakubvrana authored
102 $affected = count($matches[0]);
96ee5db Import CSV in transaction
jakubvrana authored
103 queries("START TRANSACTION");
00d9b36 E-mail sending only in Editor
jakubvrana authored
104 foreach ($matches[0] as $key => $val) {
cb370a8 Respect max_allowed_packet in CSV import
jakubvrana authored
105 preg_match_all('~(("[^"]*")+|[^,]*),~', "$val,", $matches2);
e895368 Use ON DUPLICATE KEY UPDATE for CSV import
jakubvrana authored
106 if (!$key && !array_diff($matches2[1], $cols)) { //! doesn't work with column names containing ",\n
00d9b36 E-mail sending only in Editor
jakubvrana authored
107 // first row corresponds to column names - use it for table structure
e895368 Use ON DUPLICATE KEY UPDATE for CSV import
jakubvrana authored
108 $cols = $matches2[1];
109 $affected--;
00d9b36 E-mail sending only in Editor
jakubvrana authored
110 } else {
e895368 Use ON DUPLICATE KEY UPDATE for CSV import
jakubvrana authored
111 $set = "";
112 foreach ($matches2[1] as $i => $col) {
7352c28 Replace strlen() by != ""
jakubvrana authored
113 $set .= ", " . idf_escape($cols[$i]) . " = " . ($col == "" && $fields[$cols[$i]]["null"] ? "NULL" : $connection->quote(str_replace('""', '"', preg_replace('~^"|"$~', '', $col))));
00d9b36 E-mail sending only in Editor
jakubvrana authored
114 }
2c76578 Reduce size
jakubvrana authored
115 $set = substr($set, 1);
116 $result = queries("INSERT INTO " . idf_escape($_GET["select"]) . " SET$set ON DUPLICATE KEY UPDATE$set");
e895368 Use ON DUPLICATE KEY UPDATE for CSV import
jakubvrana authored
117 if (!$result) {
118 break;
cb370a8 Respect max_allowed_packet in CSV import
jakubvrana authored
119 }
120 }
121 }
6ba224b Rollback unsuccessful CSV import
jakubvrana authored
122 if ($result) {
123 queries("COMMIT");
124 }
dbdd40a Introduce queries_redirect function
jakubvrana authored
125 queries_redirect(remove_from_uri("page"), lang('%d row(s) have been imported.', $affected), $result);
6ba224b Rollback unsuccessful CSV import
jakubvrana authored
126 queries("ROLLBACK");
00d9b36 E-mail sending only in Editor
jakubvrana authored
127 } else {
128 $error = upload_error($file);
d83b654 Detect import errors
jakubvrana authored
129 }
ec23248 Exportable select
jakubvrana authored
130 }
116faf2 Mass delete
jakubvrana authored
131 }
c16c57b E-mail sending
jakubvrana authored
132
b9ffd64 Remove common prefix in backward key
jakubvrana authored
133 $table_name = $adminer->tableName($table_status);
134 page_header(lang('Select') . ": $table_name", $error);
116faf2 Mass delete
jakubvrana authored
135
f2ed237 Display table links above table structure
jakubvrana authored
136 $set = null;
430034c Cottage homework
jakubvrana authored
137 if (isset($rights["insert"])) {
98507da Function verify_version doesn't use version parameter
jakubvrana authored
138 $set = "";
139 foreach ((array) $_GET["where"] as $val) {
140 if (count($foreign_keys[$val["col"]]) == 1 && ($val["op"] == "="
a1609c7 Align numbers to right in select
jakubvrana authored
141 || (!$val["op"] && !ereg('[_%]', $val["val"])) // LIKE in Editor
98507da Function verify_version doesn't use version parameter
jakubvrana authored
142 )) {
143 $set .= "&set" . urlencode("[" . bracket_escape($val["col"]) . "]") . "=" . urlencode($val["val"]);
144 }
145 }
667bfec Decomposition
jakubvrana authored
146 }
f2ed237 Display table links above table structure
jakubvrana authored
147 $adminer->selectLinks($table_status, $set);
667bfec Decomposition
jakubvrana authored
148
ffcea8b Rights
jakubvrana authored
149 if (!$columns) {
c1130ed Simplify SQL syntax errors everywhere
jakubvrana authored
150 echo "<p class='error'>" . lang('Unable to select the table') . ($fields ? "" : ": " . error()) . ".\n";
ffcea8b Rights
jakubvrana authored
151 } else {
5ee29cb Select columns, aggregation
jakubvrana authored
152 echo "<form action='' id='form'>\n";
d24ad78 Select boxes customization
jakubvrana authored
153 echo "<div style='display: none;'>";
7352c28 Replace strlen() by != ""
jakubvrana authored
154 echo ($_GET["server"] != "" ? '<input type="hidden" name="server" value="' . h($_GET["server"]) . '">' : "");
155 echo (DB != "" ? '<input type="hidden" name="db" value="' . h(DB) . '">' : ""); // not used in Editor
79d1902 Substitute table name to $TABLE
jakubvrana authored
156 echo '<input type="hidden" name="select" value="' . h($TABLE) . '">';
d24ad78 Select boxes customization
jakubvrana authored
157 echo "</div>\n";
158 $adminer->selectColumnsPrint($select, $columns);
159 $adminer->selectSearchPrint($where, $columns, $indexes);
160 $adminer->selectOrderPrint($order, $columns, $indexes);
161 $adminer->selectLimitPrint($limit);
162 $adminer->selectLengthPrint($text_length);
163 $adminer->selectActionPrint($text_length);
ffcea8b Rights
jakubvrana authored
164 echo "</form>\n";
165
e44fbc2 Wrap SQL query
jakubvrana authored
166 $query = "SELECT " . (intval($limit) && $group && count($group) < count($select) ? "SQL_CALC_FOUND_ROWS " : "") . $from . $group_by . ($limit != "" ? "\nLIMIT " . intval($limit) . ($_GET["page"] ? " OFFSET " . ($limit * $_GET["page"]) : "") : "");
c64c4fd Adminer class
jakubvrana authored
167 echo $adminer->selectQuery($query);
8b74511 Print SQL query (fixes #2082448)
jakubvrana authored
168
64d616c Rename get_dbh to connection
jakubvrana authored
169 $result = $connection->query($query);
21ea4ae Check errors
jakubvrana authored
170 if (!$result) {
c1130ed Simplify SQL syntax errors everywhere
jakubvrana authored
171 echo "<p class='error'>" . error() . "\n";
ffcea8b Rights
jakubvrana authored
172 } else {
f2365d0 Typo
jakubvrana authored
173 $email_fields = array();
e7eb28d CSV import
jakubvrana authored
174 echo "<form action='' method='post' enctype='multipart/form-data'>\n";
21ea4ae Check errors
jakubvrana authored
175 if (!$result->num_rows) {
ace55ed HTML instead of XHTML
jakubvrana authored
176 echo "<p class='message'>" . lang('No rows.') . "\n";
21ea4ae Check errors
jakubvrana authored
177 } else {
ba90d60 Introduce adminer_select_val
jakubvrana authored
178 $rows = array();
179 while ($row = $result->fetch_assoc()) {
180 $rows[] = $row;
181 }
4cdc459 FOUND_ROWS works with last SELECT
jakubvrana authored
182 // use count($rows) without LIMIT, COUNT(*) without grouping, FOUND_ROWS otherwise (slowest)
07e1ae1 FOUND_ROWS only with GROUP BY
jakubvrana authored
183 $found_rows = (intval($limit) && $group && count($group) < count($select)
64d616c Rename get_dbh to connection
jakubvrana authored
184 ? $connection->result($connection->query(" SELECT FOUND_ROWS()")) // space to allow mysql.trace_mode
4cdc459 FOUND_ROWS works with last SELECT
jakubvrana authored
185 : count($rows)
186 );
ba90d60 Introduce adminer_select_val
jakubvrana authored
187
09e93de Move backward keys to Editor
jakubvrana authored
188 $backward_keys = $adminer->backwardKeys($TABLE, $table_name);
c42c46a Table relations
jakubvrana authored
189
3c5c0f0 Use camelCase in JavaScript
jakubvrana authored
190 echo "<table cellspacing='0' class='nowrap' onclick='tableClick(event);'>\n";
191 echo "<thead><tr><td><input type='checkbox' id='all-page' onclick='formCheck(this, /check/);'>";
5034123 Apply field name with functions
jakubvrana authored
192 $names = array();
193 reset($select);
23df820 Distinguish no column order in fieldName
jakubvrana authored
194 $order = 1;
ba90d60 Introduce adminer_select_val
jakubvrana authored
195 foreach ($rows[0] as $key => $val) {
5034123 Apply field name with functions
jakubvrana authored
196 $val = $_GET["columns"][key($select)];
ba9c9a5 Display SQL function with braces in select heading
jakubvrana authored
197 $field = $fields[$select ? $val["col"] : $key];
6c97b80 Display only first five columns in Editor example
jakubvrana authored
198 $name = ($field ? $adminer->fieldName($field, $order) : "*");
7352c28 Replace strlen() by != ""
jakubvrana authored
199 if ($name != "") {
6c97b80 Display only first five columns in Editor example
jakubvrana authored
200 $order++;
5034123 Apply field name with functions
jakubvrana authored
201 $names[$key] = $name;
305a055 Go to first page after sorting (thanks to Jan Cerny)
jakubvrana authored
202 echo '<th><a href="' . h(remove_from_uri('(order|desc)[^=]*|page') . '&order%5B0%5D=' . urlencode($key) . ($_GET["order"][0] == $key && !$_GET["desc"][0] ? '&desc%5B0%5D=1' : '')) . '">' . apply_sql_function($val["fun"], $name) . "</a>"; //! columns looking like functions
116c873 Ignore tables and fields with empty name
jakubvrana authored
203 }
5034123 Apply field name with functions
jakubvrana authored
204 next($select);
ba90d60 Introduce adminer_select_val
jakubvrana authored
205 }
09e93de Move backward keys to Editor
jakubvrana authored
206 echo ($backward_keys ? "<th>" . lang('Relations') : "") . "</thead>\n";
dea345c Substitute foreign keys in e-mail fields
jakubvrana authored
207 foreach ($adminer->rowDescriptions($rows, $foreign_keys) as $n => $row) {
16290b0 Respect where in COUNT(*) link
jakubvrana authored
208 $unique_array = unique_array($row, $indexes);
209 $unique_idf = "";
210 foreach ($unique_array as $key => $val) {
211 $unique_idf .= "&" . (isset($val) ? urlencode("where[" . bracket_escape($key) . "]") . "=" . urlencode($val) : "null%5B%5D=" . urlencode($key));
212 }
35ec64c Link COUNT(*) result to listing
jakubvrana authored
213 echo "<tr" . odd() . "><td>" . checkbox("check[]", substr($unique_idf, 1), in_array(substr($unique_idf, 1), (array) $_POST["check"]), "", "this.form['all'].checked = false; formUncheck('all-page');") . (count($select) != count($group) || information_schema(DB) ? '' : " <a href='" . h(ME . "edit=" . urlencode($TABLE) . $unique_idf) . "'>" . lang('edit') . "</a>");
21ea4ae Check errors
jakubvrana authored
214 foreach ($row as $key => $val) {
78e49f0 Pass $field to select_val
jakubvrana authored
215 if (isset($names[$key])) {
a1609c7 Align numbers to right in select
jakubvrana authored
216 $field = $fields[$key];
7352c28 Replace strlen() by != ""
jakubvrana authored
217 if ($val != "" && (!isset($email_fields[$key]) || $email_fields[$key] != "")) {
5034123 Apply field name with functions
jakubvrana authored
218 $email_fields[$key] = (is_email($val) ? $names[$key] : ""); //! filled e-mails may be contained on other pages
116c873 Ignore tables and fields with empty name
jakubvrana authored
219 }
5911cf1 Always call select_val
jakubvrana authored
220 $link = "";
a1609c7 Align numbers to right in select
jakubvrana authored
221 $val = $adminer->editVal($val, $field);
116c873 Ignore tables and fields with empty name
jakubvrana authored
222 if (!isset($val)) {
223 $val = "<i>NULL</i>";
21ea4ae Check errors
jakubvrana authored
224 } else {
7352c28 Replace strlen() by != ""
jakubvrana authored
225 if (ereg('blob|binary', $field["type"]) && $val != "") {
35ec64c Link COUNT(*) result to listing
jakubvrana authored
226 $link = h(ME . 'download=' . urlencode($TABLE) . '&field=' . urlencode($key) . $unique_idf);
97b8c7b Display images in Editor
jakubvrana authored
227 }
7352c28 Replace strlen() by != ""
jakubvrana authored
228 if ($val == "") {
116c873 Ignore tables and fields with empty name
jakubvrana authored
229 $val = "&nbsp;";
7352c28 Replace strlen() by != ""
jakubvrana authored
230 } elseif ($text_length != "" && ereg('text|blob', $field["type"]) && is_utf8($val)) {
1859adc Comments
jakubvrana authored
231 $val = shorten_utf8($val, max(0, intval($text_length))); // usage of LEFT() would reduce traffic but complicate query - expected average speedup: .001 s VS .01 s on local network
116c873 Ignore tables and fields with empty name
jakubvrana authored
232 } else {
50881f8 Move whitespace to CSS
jakubvrana authored
233 $val = h($val);
21ea4ae Check errors
jakubvrana authored
234 }
116c873 Ignore tables and fields with empty name
jakubvrana authored
235
db46fc2 Maintain insert prefill value
jakubvrana authored
236 if (!$link) { // link related items
237 foreach ((array) $foreign_keys[$key] as $foreign_key) {
238 if (count($foreign_keys[$key]) == 1 || count($foreign_key["source"]) == 1) {
239 foreach ($foreign_key["source"] as $i => $source) {
240 $link .= where_link($i, $foreign_key["target"][$i], $rows[$n][$source]);
241 }
7352c28 Replace strlen() by != ""
jakubvrana authored
242 $link = h(($foreign_key["db"] != "" ? preg_replace('~([?&]db=)[^&]+~', '\\1' . urlencode($foreign_key["db"]), ME) : ME) . 'select=' . urlencode($foreign_key["table"]) . $link); // InnoDB supports non-UNIQUE keys
db46fc2 Maintain insert prefill value
jakubvrana authored
243 break;
116c873 Ignore tables and fields with empty name
jakubvrana authored
244 }
21ea4ae Check errors
jakubvrana authored
245 }
ffcea8b Rights
jakubvrana authored
246 }
35ec64c Link COUNT(*) result to listing
jakubvrana authored
247 if ($key == "COUNT(*)") { //! columns looking like functions
248 $link = h(ME . "select=" . urlencode($TABLE));
249 $i = 0;
16290b0 Respect where in COUNT(*) link
jakubvrana authored
250 foreach ((array) $_GET["where"] as $v) {
251 if (!array_key_exists($v["col"], $unique_array)) {
252 $link .= h("&where[$i][col]=" . urlencode($v["col"]) . "&where[$i][op]=" . urlencode($v["op"]) . "&where[$i][val]=" . urlencode($v["val"]));
253 $i++;
254 }
255 }
256 foreach ($unique_array as $k => $v) {
35ec64c Link COUNT(*) result to listing
jakubvrana authored
257 $link .= h("&where[$i][col]=" . urlencode($k) . "&where[$i][op]=" . (isset($v) ? "%3D&where[$i][val]=" . urlencode($v) : "IS+NULL"));
258 $i++;
259 }
260 }
fa3dd55 Parent
jakubvrana authored
261 }
d6e3fc7 Link e-mails
jakubvrana authored
262 if (!$link && is_email($val)) {
263 $link = "mailto:$val";
264 }
ecb56e6 Link unescaped URL
jakubvrana authored
265 if (!$link && is_url($row[$key])) {
266 $link = "http://www.adminer.org/redirect/?url=" . urlencode($row[$key]); // intermediate page to hide Referer
bc78866 Link URLs in select
jakubvrana authored
267 }
a1609c7 Align numbers to right in select
jakubvrana authored
268 $val = $adminer->selectVal($val, $link, $field);
116c873 Ignore tables and fields with empty name
jakubvrana authored
269 echo "<td>$val";
667bfec Decomposition
jakubvrana authored
270 }
271 }
09e93de Move backward keys to Editor
jakubvrana authored
272 $adminer->backwardKeysPrint($backward_keys, $rows[$n]);
26e8ab9 Close </tr> because of white-space: pre
jakubvrana authored
273 echo "</tr>\n"; // close to allow white-space: pre
5ab708a Compact pages
jakubvrana authored
274 }
21ea4ae Check errors
jakubvrana authored
275 echo "</table>\n";
e4b188c Display found rows
jakubvrana authored
276
4cdc459 FOUND_ROWS works with last SELECT
jakubvrana authored
277 if (intval($limit) && count($group) >= count($select)) {
278 // slow with big tables
279 ob_flush();
280 flush();
64d616c Rename get_dbh to connection
jakubvrana authored
281 $found_rows = $connection->result($connection->query("SELECT COUNT(*) FROM " . idf_escape($TABLE) . ($where ? " WHERE " . implode(" AND ", $where) : "")));
4cdc459 FOUND_ROWS works with last SELECT
jakubvrana authored
282 }
fde1171 Add CSS classes (thanks to cvicebni ubor)
jakubvrana authored
283 echo "<p class='pages'>";
e4b188c Display found rows
jakubvrana authored
284 if (intval($limit) && $found_rows > $limit) {
64ba924 Comments
jakubvrana authored
285 // display first, previous 3, next 3 and last page
21ea4ae Check errors
jakubvrana authored
286 $max_page = floor(($found_rows - 1) / $limit);
c565c54 Let pagination function return
jakubvrana authored
287 echo lang('Page') . ":" . pagination(0) . ($_GET["page"] > 3 ? " ..." : "");
21ea4ae Check errors
jakubvrana authored
288 for ($i = max(1, $_GET["page"] - 2); $i < min($max_page, $_GET["page"] + 3); $i++) {
c565c54 Let pagination function return
jakubvrana authored
289 echo pagination($i);
21ea4ae Check errors
jakubvrana authored
290 }
c565c54 Let pagination function return
jakubvrana authored
291 echo ($_GET["page"] + 3 < $max_page ? " ..." : "") . pagination($max_page);
5ab708a Compact pages
jakubvrana authored
292 }
6b30cfa Separate checkbox
jakubvrana authored
293 echo " (" . lang('%d row(s)', $found_rows) . ") " . checkbox("all", 1, 0, lang('whole result')) . "\n";
8b74511 Print SQL query (fixes #2082448)
jakubvrana authored
294
3c5c0f0 Use camelCase in JavaScript
jakubvrana authored
295 echo (information_schema(DB) ? "" : "<fieldset><legend>" . lang('Edit') . "</legend><div><input type='submit' name='edit' value='" . lang('Edit') . "'> <input type='submit' name='clone' value='" . lang('Clone') . "'> <input type='submit' name='delete' value='" . lang('Delete') . "' onclick=\"return confirm('" . lang('Are you sure?') . " (' + (this.form['all'].checked ? $found_rows : formChecked(this, /check/)) + ')');\"></div></fieldset>\n");
dc667ea Hide select export and import
jakubvrana authored
296 print_fieldset("export", lang('Export'));
e40612a Use radio in export
jakubvrana authored
297 echo $adminer->dumpOutput(1) . " " . $adminer->dumpFormat(1); // 1 - select
298 echo " <input type='submit' name='export' value='" . lang('Export') . "'>\n";
dc667ea Hide select export and import
jakubvrana authored
299 echo "</div></fieldset>\n";
667bfec Decomposition
jakubvrana authored
300 }
dc667ea Hide select export and import
jakubvrana authored
301 print_fieldset("import", lang('CSV Import'), !$result->num_rows);
302 echo "<input type='hidden' name='token' value='$token'><input type='file' name='csv_file'> <input type='submit' name='import' value='" . lang('Import') . "'>\n";
303 echo "</div></fieldset>\n";
c16c57b E-mail sending
jakubvrana authored
304
1e55d47 User interface for e-mail {$name}
jakubvrana authored
305 $adminer->selectEmailPrint(array_filter($email_fields, 'strlen'), $columns);
c16c57b E-mail sending
jakubvrana authored
306
e7eb28d CSV import
jakubvrana authored
307 echo "</form>\n";
667bfec Decomposition
jakubvrana authored
308 }
309 }
Something went wrong with that request. Please try again.