Skip to content
Newer
Older
100644 312 lines (296 sloc) 13.4 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);
64ba924 Comments
jakubvrana authored
6 $rights = array(); // privilege => 0
7 $columns = array(); // selectable columns
02a851c Shorten texts in PHP
jakubvrana authored
8 unset($text_length);
ffcea8b Rights
jakubvrana authored
9 foreach ($fields as $key => $field) {
c64c4fd Adminer class
jakubvrana authored
10 $name = $adminer->fieldName($field);
116c873 Ignore tables and fields with empty name
jakubvrana authored
11 if (isset($field["privileges"]["select"]) && strlen($name)) {
1e4d11e Select from foreign keys in Editor
jakubvrana authored
12 $columns[$key] = html_entity_decode(strip_tags($name));
5abd943 Change simple preg_match to ereg
jakubvrana authored
13 if (ereg('text|blob', $field["type"])) {
d24ad78 Select boxes customization
jakubvrana authored
14 $text_length = $adminer->selectLengthProcess();
16c4ddb Single faster POST query with primary key
jakubvrana authored
15 }
ffcea8b Rights
jakubvrana authored
16 }
430034c Cottage homework
jakubvrana authored
17 $rights += $field["privileges"];
18 }
19
d24ad78 Select boxes customization
jakubvrana authored
20 list($select, $group) = $adminer->selectColumnsProcess($columns, $indexes);
07e1ae1 FOUND_ROWS only with GROUP BY
jakubvrana authored
21 $where = $adminer->selectSearchProcess($fields, $indexes);
22 $order = $adminer->selectOrderProcess($fields, $indexes);
d24ad78 Select boxes customization
jakubvrana authored
23 $limit = $adminer->selectLimitProcess();
79d1902 Substitute table name to $TABLE
jakubvrana authored
24 $from = ($select ? implode(", ", $select) : "*") . " FROM " . idf_escape($TABLE) . ($where ? " WHERE " . implode(" AND ", $where) : "");
4c736a0 Use group by in export
jakubvrana authored
25 $group_by = ($group && count($group) < count($select) ? " GROUP BY " . implode(", ", $group) : "") . ($order ? " ORDER BY " . implode(", ", $order) : "");
116faf2 Mass delete
jakubvrana authored
26
27 if ($_POST && !$error) {
56948c9 $_POST[check] may be empty
jakubvrana authored
28 $where_check = "(" . implode(") OR (", array_map('where_check', (array) $_POST["check"])) . ")";
a3d2266 Order by first index in Editor by default
jakubvrana authored
29 $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
30 foreach ($select as $key => $val) {
31 $val = $_GET["columns"][$key];
32 if (!$val["fun"]) {
33 unset($primary[$val["col"]]);
34 }
35 }
78639a9 Function results in edit
jakubvrana authored
36 if ($_POST["export"]) {
79d1902 Substitute table name to $TABLE
jakubvrana authored
37 dump_headers($TABLE);
38 dump_table($TABLE, "");
e4f5d17 Dump column names in CSV select export
jakubvrana authored
39 if ($_POST["format"] != "sql") { // Editor doesn't send format
40 dump_csv($select ? $select : array_keys($fields));
41 }
16c4ddb Single faster POST query with primary key
jakubvrana authored
42 if (!is_array($_POST["check"]) || $primary === array()) {
79d1902 Substitute table name to $TABLE
jakubvrana authored
43 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
44 } else {
fa5c952 Use extended INSERT in select export
jakubvrana authored
45 $union = array();
f7452ad Import and export
jakubvrana authored
46 foreach ($_POST["check"] as $val) {
16c4ddb Single faster POST query with primary key
jakubvrana authored
47 // where is not unique so OR can't be used
c16c57b E-mail sending
jakubvrana authored
48 $union[] = "(SELECT $from " . ($where ? "AND " : "WHERE ") . where_check($val) . $group_by . " LIMIT 1)";
116faf2 Mass delete
jakubvrana authored
49 }
79d1902 Substitute table name to $TABLE
jakubvrana authored
50 dump_data($TABLE, "INSERT", implode(" UNION ALL ", $union));
116faf2 Mass delete
jakubvrana authored
51 }
702e949 Bzip2 compression
jakubvrana authored
52 dump();
78639a9 Function results in edit
jakubvrana authored
53 exit;
54 }
1a6a73a Rename selectExtra to selectEmail
jakubvrana authored
55 if (!$adminer->selectEmailProcess($where)) {
00d9b36 E-mail sending only in Editor
jakubvrana authored
56 if (!$_POST["import"]) { // edit
57 $result = true;
58 $affected = 0;
79d1902 Substitute table name to $TABLE
jakubvrana authored
59 $command = ($_POST["delete"] ? ($_POST["all"] && !$where ? "TRUNCATE " : "DELETE FROM ") : ($_POST["clone"] ? "INSERT INTO " : "UPDATE ")) . idf_escape($TABLE);
28b2b8d Readable variable initialization
jakubvrana authored
60 $set = array();
00d9b36 E-mail sending only in Editor
jakubvrana authored
61 if (!$_POST["delete"]) {
62 foreach ($columns as $name => $val) { //! should check also for edit or insert privileges
a0def47 Date localization
jakubvrana authored
63 $val = process_input($fields[$name]);
00d9b36 E-mail sending only in Editor
jakubvrana authored
64 if ($_POST["clone"]) {
65 $set[] = ($val !== false ? $val : idf_escape($name));
66 } elseif ($val !== false) {
67 $set[] = idf_escape($name) . " = $val";
68 }
e7eb28d CSV import
jakubvrana authored
69 }
79d1902 Substitute table name to $TABLE
jakubvrana authored
70 $command .= ($_POST["clone"] ? "\nSELECT " . implode(", ", $set) . "\nFROM " . idf_escape($TABLE) : " SET\n" . implode(",\n", $set));
e7eb28d CSV import
jakubvrana authored
71 }
00d9b36 E-mail sending only in Editor
jakubvrana authored
72 if ($_POST["delete"] || $set) {
73 if ($_POST["all"] || ($primary === array() && $_POST["check"])) {
74 $result = queries($command . ($_POST["all"] ? ($where ? "\nWHERE " . implode(" AND ", $where) : "") : "\nWHERE $where_check"));
75 $affected = $dbh->affected_rows;
76 } else {
77 foreach ((array) $_POST["check"] as $val) {
78 // where is not unique so OR can't be used
988a29f Don't use aggregation functions in unique_idf
jakubvrana authored
79 $result = queries($command . "\nWHERE " . where_check($val) . (count($group) < count($select) ? "" : "\nLIMIT 1"));
00d9b36 E-mail sending only in Editor
jakubvrana authored
80 if (!$result) {
81 break;
82 }
83 $affected += $dbh->affected_rows;
38059b6 Remove empty if
jakubvrana authored
84 }
e7eb28d CSV import
jakubvrana authored
85 }
78639a9 Function results in edit
jakubvrana authored
86 }
00d9b36 E-mail sending only in Editor
jakubvrana authored
87 query_redirect(queries(), remove_from_uri("page"), lang('%d item(s) have been affected.', $affected), $result, false, !$result);
88 //! display edit page in case of an error
25f01d3 Compress export and import
jakubvrana authored
89 } elseif (is_string($file = get_file("csv_file", true))) {
00d9b36 E-mail sending only in Editor
jakubvrana authored
90 $file = preg_replace("~^\xEF\xBB\xBF~", '', $file); //! character set
cb370a8 Respect max_allowed_packet in CSV import
jakubvrana authored
91 $affected = 0;
92 $length = 0;
93 $result = true;
b6fb546 Use REPLACE in CSV import
jakubvrana authored
94 $dbh->query("SET foreign_key_checks = 0");
79d1902 Substitute table name to $TABLE
jakubvrana authored
95 $query = "REPLACE " . idf_escape($TABLE); // ON DUPLICATE KEY UPDATE would require one query per record
cb370a8 Respect max_allowed_packet in CSV import
jakubvrana authored
96 $packet_size = $dbh->result($dbh->query("SELECT @@max_allowed_packet"));
97 $rows = array();
98 preg_match_all('~("[^"]*"|[^"\\n])+~', $file, $matches);
00d9b36 E-mail sending only in Editor
jakubvrana authored
99 foreach ($matches[0] as $key => $val) {
100 $row = array();
cb370a8 Respect max_allowed_packet in CSV import
jakubvrana authored
101 preg_match_all('~(("[^"]*")+|[^,]*),~', "$val,", $matches2);
00d9b36 E-mail sending only in Editor
jakubvrana authored
102 if (!$key && !array_diff($matches2[1], array_keys($fields))) { //! doesn't work with column names containing ",\n
103 // first row corresponds to column names - use it for table structure
cb370a8 Respect max_allowed_packet in CSV import
jakubvrana authored
104 $query .= " (" . implode(", ", array_map('idf_escape', $matches2[1])) . ")";
00d9b36 E-mail sending only in Editor
jakubvrana authored
105 } else {
106 foreach ($matches2[1] as $col) {
107 $row[] = (!strlen($col) ? "NULL" : $dbh->quote(str_replace('""', '"', preg_replace('~^"|"$~', '', $col))));
108 }
cb370a8 Respect max_allowed_packet in CSV import
jakubvrana authored
109 $s = "\n(" . implode(", ", $row) . ")";
110 $length += 1 + strlen($s); // 1 - separator length
111 if ($rows && $length > $packet_size) {
112 $result = queries($query . implode(",", $rows));
113 if (!$result) {
114 break;
115 }
b6fb546 Use REPLACE in CSV import
jakubvrana authored
116 $affected += count($rows);
cb370a8 Respect max_allowed_packet in CSV import
jakubvrana authored
117 $length = strlen($query);
118 $rows = array();
119 }
120 $rows[] = $s;
d83b654 Detect import errors
jakubvrana authored
121 }
cb370a8 Respect max_allowed_packet in CSV import
jakubvrana authored
122 if (!$key) {
123 $query .= " VALUES";
124 $length += strlen($query);
125 }
126 }
127 if ($result) {
128 $result = queries($query . implode(",", $rows));
b6fb546 Use REPLACE in CSV import
jakubvrana authored
129 $affected += count($rows);
d83b654 Detect import errors
jakubvrana authored
130 }
cb370a8 Respect max_allowed_packet in CSV import
jakubvrana authored
131 query_redirect(queries(), remove_from_uri("page"), lang('%d row(s) have been imported.', $affected), $result, false, !$result);
00d9b36 E-mail sending only in Editor
jakubvrana authored
132 } else {
133 $error = upload_error($file);
d83b654 Detect import errors
jakubvrana authored
134 }
ec23248 Exportable select
jakubvrana authored
135 }
116faf2 Mass delete
jakubvrana authored
136 }
c16c57b E-mail sending
jakubvrana authored
137
c64c4fd Adminer class
jakubvrana authored
138 page_header(lang('Select') . ": " . $adminer->tableName($table_status), $error);
116faf2 Mass delete
jakubvrana authored
139
79d1902 Substitute table name to $TABLE
jakubvrana authored
140 $foreign_keys = column_foreign_keys($TABLE);
4099271 Cross links to select and table (bug #2236232)
jakubvrana authored
141 echo "<p>";
430034c Cottage homework
jakubvrana authored
142 if (isset($rights["insert"])) {
98507da Function verify_version doesn't use version parameter
jakubvrana authored
143 $set = "";
144 foreach ((array) $_GET["where"] as $val) {
145 if (count($foreign_keys[$val["col"]]) == 1 && ($val["op"] == "="
146 || ($val["op"] == "" && !ereg('[_%]', $val["val"])) // LIKE in Editor
147 )) {
148 $set .= "&set" . urlencode("[" . bracket_escape($val["col"]) . "]") . "=" . urlencode($val["val"]);
149 }
150 }
79d1902 Substitute table name to $TABLE
jakubvrana authored
151 echo '<a href="' . h(ME . 'edit=' . urlencode($TABLE) . $set) . '">' . lang('New item') . '</a> ';
667bfec Decomposition
jakubvrana authored
152 }
c64c4fd Adminer class
jakubvrana authored
153 echo $adminer->selectLinks($table_status);
667bfec Decomposition
jakubvrana authored
154
ffcea8b Rights
jakubvrana authored
155 if (!$columns) {
689699a Shortcut for htmlspecialchars
jakubvrana authored
156 echo "<p class='error'>" . lang('Unable to select the table') . ($fields ? "" : ": " . h($dbh->error)) . ".\n";
ffcea8b Rights
jakubvrana authored
157 } else {
5ee29cb Select columns, aggregation
jakubvrana authored
158 echo "<form action='' id='form'>\n";
d24ad78 Select boxes customization
jakubvrana authored
159 echo "<div style='display: none;'>";
689699a Shortcut for htmlspecialchars
jakubvrana authored
160 echo (strlen($_GET["server"]) ? '<input type="hidden" name="server" value="' . h($_GET["server"]) . '">' : "");
3022dcb Define DB
jakubvrana authored
161 echo (strlen(DB) ? '<input type="hidden" name="db" value="' . h(DB) . '">' : ""); // not used in Editor
79d1902 Substitute table name to $TABLE
jakubvrana authored
162 echo '<input type="hidden" name="select" value="' . h($TABLE) . '">';
d24ad78 Select boxes customization
jakubvrana authored
163 echo "</div>\n";
164 $adminer->selectColumnsPrint($select, $columns);
165 $adminer->selectSearchPrint($where, $columns, $indexes);
166 $adminer->selectOrderPrint($order, $columns, $indexes);
167 $adminer->selectLimitPrint($limit);
168 $adminer->selectLengthPrint($text_length);
169 $adminer->selectActionPrint($text_length);
ffcea8b Rights
jakubvrana authored
170 echo "</form>\n";
171
07e1ae1 FOUND_ROWS only with GROUP BY
jakubvrana authored
172 $query = "SELECT " . (intval($limit) && $group && count($group) < count($select) ? "SQL_CALC_FOUND_ROWS " : "") . $from . $group_by . (strlen($limit) ? " LIMIT " . intval($limit) . (intval($_GET["page"]) ? " OFFSET " . ($limit * $_GET["page"]) : "") : "");
c64c4fd Adminer class
jakubvrana authored
173 echo $adminer->selectQuery($query);
8b74511 Print SQL query (fixes #2082448)
jakubvrana authored
174
5f16c75 Prepare for version 2
jakubvrana authored
175 $result = $dbh->query($query);
21ea4ae Check errors
jakubvrana authored
176 if (!$result) {
689699a Shortcut for htmlspecialchars
jakubvrana authored
177 echo "<p class='error'>" . h($dbh->error) . "\n";
ffcea8b Rights
jakubvrana authored
178 } else {
f2365d0 Typo
jakubvrana authored
179 $email_fields = array();
e7eb28d CSV import
jakubvrana authored
180 echo "<form action='' method='post' enctype='multipart/form-data'>\n";
21ea4ae Check errors
jakubvrana authored
181 if (!$result->num_rows) {
ace55ed HTML instead of XHTML
jakubvrana authored
182 echo "<p class='message'>" . lang('No rows.') . "\n";
21ea4ae Check errors
jakubvrana authored
183 } else {
ba90d60 Introduce adminer_select_val
jakubvrana authored
184 $rows = array();
185 while ($row = $result->fetch_assoc()) {
186 $rows[] = $row;
187 }
4cdc459 FOUND_ROWS works with last SELECT
jakubvrana authored
188 // use count($rows) without LIMIT, COUNT(*) without grouping, FOUND_ROWS otherwise (slowest)
07e1ae1 FOUND_ROWS only with GROUP BY
jakubvrana authored
189 $found_rows = (intval($limit) && $group && count($group) < count($select)
4cdc459 FOUND_ROWS works with last SELECT
jakubvrana authored
190 ? $dbh->result($dbh->query(" SELECT FOUND_ROWS()")) // space to allow mysql.trace_mode
191 : count($rows)
192 );
ba90d60 Introduce adminer_select_val
jakubvrana authored
193
c64c4fd Adminer class
jakubvrana authored
194 $descriptions = $adminer->rowDescriptions($rows, $foreign_keys);
21ea4ae Check errors
jakubvrana authored
195
79d1902 Substitute table name to $TABLE
jakubvrana authored
196 $backward_keys = $adminer->backwardKeys($TABLE);
dc4fcf4 PHP 4 compatibility
jakubvrana authored
197 $table_names = array();
198 if ($backward_keys) {
199 foreach ($backward_keys as $key => $val) {
200 $val = $adminer->tableName(table_status($key));
201 if (strlen($val)) {
202 $table_names[$key] = $val;
203 }
204 }
336f521 Get table names of backward keys only once
jakubvrana authored
205 }
c42c46a Table relations
jakubvrana authored
206
bcff025 Click on row selects it (fixes #2844098)
jakubvrana authored
207 echo "<table cellspacing='0' class='nowrap' onclick='table_click(event);'>\n";
ba90d60 Introduce adminer_select_val
jakubvrana authored
208 echo "<thead><tr><td><input type='checkbox' id='all-page' onclick='form_check(this, /check/);'>";
5034123 Apply field name with functions
jakubvrana authored
209 $names = array();
210 reset($select);
23df820 Distinguish no column order in fieldName
jakubvrana authored
211 $order = 1;
ba90d60 Introduce adminer_select_val
jakubvrana authored
212 foreach ($rows[0] as $key => $val) {
5034123 Apply field name with functions
jakubvrana authored
213 $val = $_GET["columns"][key($select)];
ba9c9a5 Display SQL function with braces in select heading
jakubvrana authored
214 $field = $fields[$select ? $val["col"] : $key];
6c97b80 Display only first five columns in Editor example
jakubvrana authored
215 $name = ($field ? $adminer->fieldName($field, $order) : "*");
116c873 Ignore tables and fields with empty name
jakubvrana authored
216 if (strlen($name)) {
6c97b80 Display only first five columns in Editor example
jakubvrana authored
217 $order++;
5034123 Apply field name with functions
jakubvrana authored
218 $names[$key] = $name;
689699a Shortcut for htmlspecialchars
jakubvrana authored
219 echo '<th><a href="' . h(remove_from_uri('(order|desc)[^=]*') . '&order%5B0%5D=' . urlencode($key) . ($_GET["order"] == array($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
220 }
5034123 Apply field name with functions
jakubvrana authored
221 next($select);
ba90d60 Introduce adminer_select_val
jakubvrana authored
222 }
8f525c4 Hide empty table names in Relations
jakubvrana authored
223 echo ($table_names ? "<th>" . lang('Relations') : "") . "</thead>\n";
228e43a Row descriptions in select
jakubvrana authored
224 foreach ($descriptions as $n => $row) {
988a29f Don't use aggregation functions in unique_idf
jakubvrana authored
225 $unique_idf = implode('&amp;', unique_idf($rows[$n], $indexes));
79d1902 Substitute table name to $TABLE
jakubvrana authored
226 echo "<tr" . odd() . "><td><input type='checkbox' name='check[]' value='$unique_idf' onclick=\"this.form['all'].checked = false; form_uncheck('all-page');\">" . (count($select) != count($group) || information_schema(DB) ? '' : " <a href='" . h(ME) . "edit=" . urlencode($TABLE) . "&amp;$unique_idf'>" . lang('edit') . "</a>");
21ea4ae Check errors
jakubvrana authored
227 foreach ($row as $key => $val) {
78e49f0 Pass $field to select_val
jakubvrana authored
228 if (isset($names[$key])) {
d6e3fc7 Link e-mails
jakubvrana authored
229 if (strlen($val) && (!isset($email_fields[$key]) || strlen($email_fields[$key]))) {
5034123 Apply field name with functions
jakubvrana authored
230 $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
231 }
5911cf1 Always call select_val
jakubvrana authored
232 $link = "";
a0def47 Date localization
jakubvrana authored
233 $val = $adminer->editVal($val, $fields[$key]);
116c873 Ignore tables and fields with empty name
jakubvrana authored
234 if (!isset($val)) {
235 $val = "<i>NULL</i>";
21ea4ae Check errors
jakubvrana authored
236 } else {
97b8c7b Display images in Editor
jakubvrana authored
237 if (ereg('blob|binary', $fields[$key]["type"]) && strlen($val)) {
79d1902 Substitute table name to $TABLE
jakubvrana authored
238 $link = h(ME . 'download=' . urlencode($TABLE) . '&field=' . urlencode($key) . '&') . $unique_idf;
97b8c7b Display images in Editor
jakubvrana authored
239 }
116c873 Ignore tables and fields with empty name
jakubvrana authored
240 if (!strlen(trim($val, " \t"))) {
241 $val = "&nbsp;";
97b8c7b Display images in Editor
jakubvrana authored
242 } elseif (strlen($text_length) && ereg('blob|text', $fields[$key]["type"]) && is_utf8($val)) {
35c8c6b Respect zero text length
jakubvrana authored
243 $val = nl2br(shorten_utf8($val, max(0, intval($text_length)))); // usage of LEFT() would reduce traffic but complicate query
116c873 Ignore tables and fields with empty name
jakubvrana authored
244 } else {
689699a Shortcut for htmlspecialchars
jakubvrana authored
245 $val = nl2br(h($val));
21ea4ae Check errors
jakubvrana authored
246 }
116c873 Ignore tables and fields with empty name
jakubvrana authored
247
db46fc2 Maintain insert prefill value
jakubvrana authored
248 if (!$link) { // link related items
249 foreach ((array) $foreign_keys[$key] as $foreign_key) {
250 if (count($foreign_keys[$key]) == 1 || count($foreign_key["source"]) == 1) {
251 foreach ($foreign_key["source"] as $i => $source) {
252 $link .= where_link($i, $foreign_key["target"][$i], $rows[$n][$source]);
253 }
254 $link = h((strlen($foreign_key["db"]) ? preg_replace('~([?&]db=)[^&]+~', '\\1' . urlencode($foreign_key["db"]), ME) : ME) . 'select=' . urlencode($foreign_key["table"]) . $link); // InnoDB supports non-UNIQUE keys
255 break;
116c873 Ignore tables and fields with empty name
jakubvrana authored
256 }
21ea4ae Check errors
jakubvrana authored
257 }
ffcea8b Rights
jakubvrana authored
258 }
fa3dd55 Parent
jakubvrana authored
259 }
d6e3fc7 Link e-mails
jakubvrana authored
260 if (!$link && is_email($val)) {
261 $link = "mailto:$val";
262 }
c64c4fd Adminer class
jakubvrana authored
263 $val = $adminer->selectVal($val, $link, $fields[$key]);
116c873 Ignore tables and fields with empty name
jakubvrana authored
264 echo "<td>$val";
667bfec Decomposition
jakubvrana authored
265 }
266 }
8f525c4 Hide empty table names in Relations
jakubvrana authored
267 if ($table_names) {
c42c46a Table relations
jakubvrana authored
268 echo "<td>";
8f525c4 Hide empty table names in Relations
jakubvrana authored
269 foreach ($table_names as $table => $name) {
270 foreach ($backward_keys[$table] as $columns) {
db46fc2 Maintain insert prefill value
jakubvrana authored
271 $link = ME . 'select=' . urlencode($table);
c42c46a Table relations
jakubvrana authored
272 $i = 0;
273 foreach ($columns as $column => $val) {
db46fc2 Maintain insert prefill value
jakubvrana authored
274 $link .= where_link($i++, $column, $rows[$n][$val]);
c42c46a Table relations
jakubvrana authored
275 }
db46fc2 Maintain insert prefill value
jakubvrana authored
276 echo " <a href='" . h($link) . "'>$name</a>";
c42c46a Table relations
jakubvrana authored
277 }
278 }
279 }
ba90d60 Introduce adminer_select_val
jakubvrana authored
280 echo "\n";
5ab708a Compact pages
jakubvrana authored
281 }
21ea4ae Check errors
jakubvrana authored
282 echo "</table>\n";
e4b188c Display found rows
jakubvrana authored
283
4cdc459 FOUND_ROWS works with last SELECT
jakubvrana authored
284 if (intval($limit) && count($group) >= count($select)) {
285 // slow with big tables
286 ob_flush();
287 flush();
79d1902 Substitute table name to $TABLE
jakubvrana authored
288 $found_rows = $dbh->result($dbh->query("SELECT COUNT(*) FROM " . idf_escape($TABLE) . ($where ? " WHERE " . implode(" AND ", $where) : "")));
4cdc459 FOUND_ROWS works with last SELECT
jakubvrana authored
289 }
e4b188c Display found rows
jakubvrana authored
290 echo "<p>";
291 if (intval($limit) && $found_rows > $limit) {
64ba924 Comments
jakubvrana authored
292 // display first, previous 3, next 3 and last page
21ea4ae Check errors
jakubvrana authored
293 $max_page = floor(($found_rows - 1) / $limit);
c565c54 Let pagination function return
jakubvrana authored
294 echo lang('Page') . ":" . pagination(0) . ($_GET["page"] > 3 ? " ..." : "");
21ea4ae Check errors
jakubvrana authored
295 for ($i = max(1, $_GET["page"] - 2); $i < min($max_page, $_GET["page"] + 3); $i++) {
c565c54 Let pagination function return
jakubvrana authored
296 echo pagination($i);
21ea4ae Check errors
jakubvrana authored
297 }
c565c54 Let pagination function return
jakubvrana authored
298 echo ($_GET["page"] + 3 < $max_page ? " ..." : "") . pagination($max_page);
5ab708a Compact pages
jakubvrana authored
299 }
ace55ed HTML instead of XHTML
jakubvrana authored
300 echo " (" . lang('%d row(s)', $found_rows) . ') <label><input type="checkbox" name="all" value="1">' . lang('whole result') . "</label>\n";
8b74511 Print SQL query (fixes #2082448)
jakubvrana authored
301
3022dcb Define DB
jakubvrana authored
302 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') . "'$confirm></div></fieldset>\n");
25f01d3 Compress export and import
jakubvrana authored
303 echo "<fieldset><legend>" . lang('Export') . "</legend><div>$dump_output $dump_format $dump_compress <input type='submit' name='export' value='" . lang('Export') . "'></div></fieldset>\n";
667bfec Decomposition
jakubvrana authored
304 }
ace55ed HTML instead of XHTML
jakubvrana authored
305 echo "<fieldset><legend>" . lang('CSV Import') . "</legend><div><input type='hidden' name='token' value='$token'><input type='file' name='csv_file'> <input type='submit' name='import' value='" . lang('Import') . "'></div></fieldset>\n";
c16c57b E-mail sending
jakubvrana authored
306
1a6a73a Rename selectExtra to selectEmail
jakubvrana authored
307 $adminer->selectEmailPrint(array_filter($email_fields, 'strlen'));
c16c57b E-mail sending
jakubvrana authored
308
e7eb28d CSV import
jakubvrana authored
309 echo "</form>\n";
667bfec Decomposition
jakubvrana authored
310 }
311 }
Something went wrong with that request. Please try again.