Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 316 lines (301 sloc) 16.491 kb
667bfec Decomposition
jakubvrana authored
1 <?php
d72bf4c Select specific variables
jakubvrana authored
2 $functions = array("char_length", "from_unixtime", "hex", "lower", "round", "sec_to_time", "time_to_sec", "unix_timestamp", "upper");
3 $grouping = array("avg", "count", "distinct", "group_concat", "max", "min", "sum");
116faf2 Mass delete
jakubvrana authored
4 $table_status = table_status($_GET["select"]);
5 $indexes = indexes($_GET["select"]);
26c2ff0 NOT operators
jakubvrana authored
6 $operators = array("=", "<", ">", "<=", ">=", "!=", "LIKE", "REGEXP", "IN", "IS NULL", "NOT LIKE", "NOT REGEXP", "NOT IN", "IS NOT NULL");
f78779b Maria engine supports fulltext
jakubvrana authored
7 if (eregi('^(MyISAM|Maria)$', $table_status["Engine"])) {
116faf2 Mass delete
jakubvrana authored
8 $operators[] = "AGAINST";
9 }
ffcea8b Rights
jakubvrana authored
10 $fields = fields($_GET["select"]);
430034c Cottage homework
jakubvrana authored
11 $rights = array();
ffcea8b Rights
jakubvrana authored
12 $columns = array();
02a851c Shorten texts in PHP
jakubvrana authored
13 unset($text_length);
ffcea8b Rights
jakubvrana authored
14 foreach ($fields as $key => $field) {
430034c Cottage homework
jakubvrana authored
15 if (isset($field["privileges"]["select"])) {
ffcea8b Rights
jakubvrana authored
16 $columns[] = $key;
02a851c Shorten texts in PHP
jakubvrana authored
17 if (preg_match('~text|blob~', $field["type"])) {
18 $text_length = (isset($_GET["text_length"]) ? $_GET["text_length"] : "100");
19 }
ffcea8b Rights
jakubvrana authored
20 }
430034c Cottage homework
jakubvrana authored
21 $rights += $field["privileges"];
22 }
23
5ee29cb Select columns, aggregation
jakubvrana authored
24 $select = array();
25 $group = array();
26 foreach ((array) $_GET["columns"] as $key => $val) {
27 if ($val["fun"] == "count" || (in_array($val["col"], $columns, true) && (!$val["fun"] || in_array($val["fun"], $functions) || in_array($val["fun"], $grouping)))) {
28 $select[$key] = (in_array($val["col"], $columns, true) ? (!$val["fun"] ? idf_escape($val["col"]) : ($val["fun"] == "distinct" ? "COUNT(DISTINCT " : strtoupper("$val[fun](")) . idf_escape($val["col"]) . ")") : "COUNT(*)");
29 if (!in_array($val["fun"], $grouping)) {
30 $group[] = $select[$key];
31 }
32 }
33 }
116faf2 Mass delete
jakubvrana authored
34 $where = array();
35 foreach ($indexes as $i => $index) {
36 if ($index["type"] == "FULLTEXT" && strlen($_GET["fulltext"][$i])) {
5f16c75 Prepare for version 2
jakubvrana authored
37 $where[] = "MATCH (" . implode(", ", array_map('idf_escape', $index["columns"])) . ") AGAINST ('" . $dbh->escape_string($_GET["fulltext"][$i]) . "'" . (isset($_GET["boolean"][$i]) ? " IN BOOLEAN MODE" : "") . ")";
116faf2 Mass delete
jakubvrana authored
38 }
39 }
40 foreach ((array) $_GET["where"] as $val) {
25bc058 Search in any column
jakubvrana authored
41 if (strlen("$val[col]$val[val]") && in_array($val["op"], $operators)) {
42 if ($val["op"] == "AGAINST") {
5f16c75 Prepare for version 2
jakubvrana authored
43 $where[] = "MATCH (" . idf_escape($val["col"]) . ") AGAINST ('" . $dbh->escape_string($val["val"]) . "' IN BOOLEAN MODE)";
25bc058 Search in any column
jakubvrana authored
44 } elseif (ereg('IN$', $val["op"]) && !strlen($in = process_length($val["val"]))) {
45 $where[] = "0";
116faf2 Mass delete
jakubvrana authored
46 } else {
5f16c75 Prepare for version 2
jakubvrana authored
47 $cond = " $val[op]" . (ereg('NULL$', $val["op"]) ? "" : (ereg('IN$', $val["op"]) ? " ($in)" : " '" . $dbh->escape_string($val["val"]) . "'")); //! this searches in numeric values too
25bc058 Search in any column
jakubvrana authored
48 if (strlen($val["col"])) {
49 $where[] = idf_escape($val["col"]) . $cond;
50 } else {
51 $cols = array();
52 foreach ($fields as $name => $field) {
53 if (is_numeric($val["val"]) || !ereg('int|float|double|decimal', $field["type"])) {
54 $cols[] = $name;
55 }
56 }
57 $where[] = ($cols ? "(" . implode("$cond OR ", array_map('idf_escape', $cols)) . "$cond)" : "0");
58 }
116faf2 Mass delete
jakubvrana authored
59 }
60 }
61 }
62 $order = array();
63 foreach ((array) $_GET["order"] as $key => $val) {
5805eba Remove order of not used functions
jakubvrana authored
64 if (in_array($val, $columns, true) || in_array($val, $select, true)) {
116faf2 Mass delete
jakubvrana authored
65 $order[] = idf_escape($val) . (isset($_GET["desc"][$key]) ? " DESC" : "");
66 }
67 }
68 $limit = (isset($_GET["limit"]) ? $_GET["limit"] : "30");
5ee29cb Select columns, aggregation
jakubvrana authored
69 $from = "FROM " . idf_escape($_GET["select"]) . ($where ? " WHERE " . implode(" AND ", $where) : "") . ($group && count($group) < count($select) ? " GROUP BY " . implode(", ", $group) : "") . ($order ? " ORDER BY " . implode(", ", $order) : "") . (strlen($limit) ? " LIMIT " . intval($limit) . (intval($_GET["page"]) ? " OFFSET " . ($limit * $_GET["page"]) : "") : "");
116faf2 Mass delete
jakubvrana authored
70
71 if ($_POST && !$error) {
78639a9 Function results in edit
jakubvrana authored
72 if ($_POST["export"]) {
9890b6c Export Output in select.inc.php
jakubvrana authored
73 dump_headers($_GET["select"]);
f48161b CSV Byte-order-mark
jakubvrana authored
74 dump_table($_GET["select"], "");
5b70b5b Change variable name
jakubvrana authored
75 $query = "SELECT " . ($select ? implode(", ", $select) : "*") . " FROM " . idf_escape($_GET["select"]);
f7452ad Import and export
jakubvrana authored
76 if (is_array($_POST["check"])) {
fa5c952 Use extended INSERT in select export
jakubvrana authored
77 $union = array();
f7452ad Import and export
jakubvrana authored
78 foreach ($_POST["check"] as $val) {
fa5c952 Use extended INSERT in select export
jakubvrana authored
79 $union[] = "($query WHERE " . implode(" AND ", where_check($val)) . " LIMIT 1)";
116faf2 Mass delete
jakubvrana authored
80 }
fa5c952 Use extended INSERT in select export
jakubvrana authored
81 dump_data($_GET["select"], "INSERT", implode(" UNION ALL ", $union));
f7452ad Import and export
jakubvrana authored
82 } else {
5b70b5b Change variable name
jakubvrana authored
83 dump_data($_GET["select"], "INSERT", $query . ($where ? " WHERE " . implode(" AND ", $where) : ""));
116faf2 Mass delete
jakubvrana authored
84 }
78639a9 Function results in edit
jakubvrana authored
85 exit;
86 }
d83b654 Detect import errors
jakubvrana authored
87 if (!$_POST["import"]) { // edit
e7eb28d CSV import
jakubvrana authored
88 $result = true;
89 $affected = 0;
90 $command = ($_POST["delete"] ? ($_POST["all"] && !$where ? "TRUNCATE " : "DELETE FROM ") : ($_POST["clone"] ? "INSERT INTO " : "UPDATE ")) . idf_escape($_GET["select"]);
91 if (!$_POST["delete"]) {
92 $set = array();
93 foreach ($fields as $name => $field) {
94 $val = process_input($name, $field);
95 if ($_POST["clone"]) {
96 $set[] = ($val !== false ? $val : idf_escape($name));
97 } elseif ($val !== false) {
0cd2afb Remove single item clone
jakubvrana authored
98 $set[] = "\n" . idf_escape($name) . " = $val";
e7eb28d CSV import
jakubvrana authored
99 }
100 }
0cd2afb Remove single item clone
jakubvrana authored
101 $command .= ($_POST["clone"] ? "\nSELECT " . implode(", ", $set) . " FROM " . idf_escape($_GET["select"]) : " SET" . implode(",", $set));
e7eb28d CSV import
jakubvrana authored
102 }
103 if (!$_POST["delete"] && !$set) {
104 // nothing
105 } elseif ($_POST["all"]) {
106 $result = queries($command . ($where ? " WHERE " . implode(" AND ", $where) : ""));
5f16c75 Prepare for version 2
jakubvrana authored
107 $affected = $dbh->affected_rows;
e7eb28d CSV import
jakubvrana authored
108 } else {
109 foreach ((array) $_POST["check"] as $val) {
110 parse_str($val, $check);
111 $result = queries($command . " WHERE " . implode(" AND ", where($check)) . " LIMIT 1");
112 if (!$result) {
113 break;
114 }
5f16c75 Prepare for version 2
jakubvrana authored
115 $affected += $dbh->affected_rows;
78639a9 Function results in edit
jakubvrana authored
116 }
117 }
e7eb28d CSV import
jakubvrana authored
118 query_redirect(queries(), remove_from_uri("page"), lang('%d item(s) have been affected.', $affected), $result, false, !$result);
119 //! display edit page in case of an error
d83b654 Detect import errors
jakubvrana authored
120 } elseif (is_string($file = get_file("csv_file"))) {
121 $file = preg_replace("~^\xEF\xBB\xBF~", '', $file); //! character set
122 $cols = "";
123 $rows = array(); //! packet size
124 preg_match_all('~("[^"]*"|[^"\\n]+)+~', $file, $matches);
125 foreach ($matches[0] as $key => $val) {
126 $row = array();
127 preg_match_all('~(("[^"]*")+|[^,]*),~', "$val,", $matches2);
128 if (!$key && !array_diff($matches2[1], array_keys($fields))) { //! doesn't work with column names containing ",\n
129 $cols = " (" . implode(", ", array_map('idf_escape', $matches2[1])) . ")";
130 } else {
131 foreach ($matches2[1] as $col) {
5f16c75 Prepare for version 2
jakubvrana authored
132 $row[] = (!strlen($col) ? "NULL" : "'" . $dbh->escape_string(str_replace('""', '"', preg_replace('~^".*"$~s', '', $col))) . "'");
d83b654 Detect import errors
jakubvrana authored
133 }
134 $rows[] = "(" . implode(", ", $row) . ")";
135 }
136 }
137 $result = queries("INSERT INTO " . idf_escape($_GET["select"]) . "$cols VALUES " . implode(", ", $rows));
5f16c75 Prepare for version 2
jakubvrana authored
138 query_redirect(queries(), remove_from_uri("page"), lang('%d row(s) has been imported.', $dbh->affected_rows), $result, false, !$result);
d83b654 Detect import errors
jakubvrana authored
139 } else {
140 $error = lang('Unable to upload a file.');
ec23248 Exportable select
jakubvrana authored
141 }
116faf2 Mass delete
jakubvrana authored
142 }
820c882 Bulk clone
jakubvrana authored
143 page_header(lang('Select') . ": " . htmlspecialchars($_GET["select"]), $error);
116faf2 Mass delete
jakubvrana authored
144
4099271 Cross links to select and table (bug #2236232)
jakubvrana authored
145 echo "<p>";
430034c Cottage homework
jakubvrana authored
146 if (isset($rights["insert"])) {
3d254a3 TODO
jakubvrana authored
147 //! pass search values forth and back
4099271 Cross links to select and table (bug #2236232)
jakubvrana authored
148 echo '<a href="' . htmlspecialchars($SELF) . 'edit=' . urlencode($_GET['select']) . '">' . lang('New item') . '</a> ';
667bfec Decomposition
jakubvrana authored
149 }
4099271 Cross links to select and table (bug #2236232)
jakubvrana authored
150 echo '<a href="' . htmlspecialchars($SELF) . 'table=' . urlencode($_GET['select']) . '">' . lang('Table structure') . '</a>';
151 echo "</p>\n";
667bfec Decomposition
jakubvrana authored
152
ffcea8b Rights
jakubvrana authored
153 if (!$columns) {
5f16c75 Prepare for version 2
jakubvrana authored
154 echo "<p class='error'>" . lang('Unable to select the table') . ($fields ? "" : ": " . htmlspecialchars($dbh->error)) . ".</p>\n";
ffcea8b Rights
jakubvrana authored
155 } else {
5ee29cb Select columns, aggregation
jakubvrana authored
156 echo "<form action='' id='form'>\n";
b142000 Hide fieldsets in select
jakubvrana authored
157 echo '<fieldset><legend><a href="#fieldset-select" onclick="return !toggle(\'fieldset-select\');">' . lang('Select') . "</a></legend><div id='fieldset-select'" . ($select ? "" : " class='hidden'") . ">\n";
ffcea8b Rights
jakubvrana authored
158 if (strlen($_GET["server"])) {
159 echo '<input type="hidden" name="server" value="' . htmlspecialchars($_GET["server"]) . '" />';
667bfec Decomposition
jakubvrana authored
160 }
ffcea8b Rights
jakubvrana authored
161 echo '<input type="hidden" name="db" value="' . htmlspecialchars($_GET["db"]) . '" />';
162 echo '<input type="hidden" name="select" value="' . htmlspecialchars($_GET["select"]) . '" />';
163 echo "\n";
5ee29cb Select columns, aggregation
jakubvrana authored
164 $i = 0;
165 $fun_group = array(lang('Functions') => $functions, lang('Aggregation') => $grouping);
166 foreach ($select as $key => $val) {
167 $val = $_GET["columns"][$key];
168 echo "<div><select name='columns[$i][fun]'><option></option>" . optionlist($fun_group, $val["fun"]) . "</select>";
169 echo "<select name='columns[$i][col]'><option></option>" . optionlist($columns, $val["col"]) . "</select></div>\n";
170 $i++;
171 }
172 echo "<div><select name='columns[$i][fun]' onchange='this.nextSibling.onchange();'><option></option>" . optionlist($fun_group) . "</select>";
540e217 Separate JavaScript
jakubvrana authored
173 echo "<select name='columns[$i][col]' onchange='select_add_row(this);'><option></option>" . optionlist($columns) . "</select></div>\n";
b142000 Hide fieldsets in select
jakubvrana authored
174 echo "</div></fieldset>\n";
ffcea8b Rights
jakubvrana authored
175
b142000 Hide fieldsets in select
jakubvrana authored
176 echo '<fieldset><legend><a href="#fieldset-search" onclick="return !toggle(\'fieldset-search\');">' . lang('Search') . "</a></legend><div id='fieldset-search'" . ($where ? "" : " class='hidden'") . ">\n";
430034c Cottage homework
jakubvrana authored
177 foreach ($indexes as $i => $index) {
178 if ($index["type"] == "FULLTEXT") {
9e2848d Escape fulltext columns
jakubvrana authored
179 echo "(<i>" . implode("</i>, <i>", array_map('htmlspecialchars', $index["columns"])) . "</i>) AGAINST";
430034c Cottage homework
jakubvrana authored
180 echo ' <input name="fulltext[' . $i . ']" value="' . htmlspecialchars($_GET["fulltext"][$i]) . '" />';
78639a9 Function results in edit
jakubvrana authored
181 echo "<label><input type='checkbox' name='boolean[$i]' value='1'" . (isset($_GET["boolean"][$i]) ? " checked='checked'" : "") . " />" . lang('BOOL') . "</label>";
430034c Cottage homework
jakubvrana authored
182 echo "<br />\n";
183 }
184 }
ffcea8b Rights
jakubvrana authored
185 $i = 0;
186 foreach ((array) $_GET["where"] as $val) {
25bc058 Search in any column
jakubvrana authored
187 if (strlen("$val[col]$val[val]") && in_array($val["op"], $operators)) {
a96dfd0 Promote search anywhere
jakubvrana authored
188 echo "<div><select name='where[$i][col]'><option value=''>" . lang('(anywhere)') . "</option>" . optionlist($columns, $val["col"]) . "</select>";
71430ee IE fixes
jakubvrana authored
189 echo "<select name='where[$i][op]' onchange='where_change(this);'>" . optionlist($operators, $val["op"]) . "</select>";
540e217 Separate JavaScript
jakubvrana authored
190 echo "<input name='where[$i][val]' value=\"" . htmlspecialchars($val["val"]) . '"' . (ereg('NULL$', $val["op"]) ? " class='hidden'" : "") . " /></div>\n";
ffcea8b Rights
jakubvrana authored
191 $i++;
192 }
193 }
540e217 Separate JavaScript
jakubvrana authored
194 echo "<div><select name='where[$i][col]' onchange='select_add_row(this);'><option value=''>" . lang('(anywhere)') . "</option>" . optionlist($columns) . "</select>";
71430ee IE fixes
jakubvrana authored
195 echo "<select name='where[$i][op]' onchange='where_change(this);'>" . optionlist($operators) . "</select>";
4f6f2d4 JavaScript for adding where and order
jakubvrana authored
196 echo "<input name='where[$i][val]' /></div>\n";
b142000 Hide fieldsets in select
jakubvrana authored
197 echo "</div></fieldset>\n";
198
199 echo '<fieldset><legend><a href="#fieldset-sort" onclick="return !toggle(\'fieldset-sort\');">' . lang('Sort') . "</a></legend><div id='fieldset-sort'" . (count($order) > 1 ? "" : " class='hidden'") . ">\n";
200 $i = 0;
201 foreach ((array) $_GET["order"] as $key => $val) {
202 if (in_array($val, $columns, true)) {
203 echo "<div><select name='order[$i]'><option></option>" . optionlist($columns, $val) . "</select>";
204 echo "<label><input type='checkbox' name='desc[$i]' value='1'" . (isset($_GET["desc"][$key]) ? " checked='checked'" : "") . " />" . lang('DESC') . "</label></div>\n";
205 $i++;
206 }
207 }
208 echo "<div><select name='order[$i]' onchange='select_add_row(this);'><option></option>" . optionlist($columns) . "</select>";
209 echo "<label><input type='checkbox' name='desc[$i]' value='1' />" . lang('DESC') . "</label></div>\n";
210 echo "</div></fieldset>\n";
ffcea8b Rights
jakubvrana authored
211
c9e999f Simplify order in select
jakubvrana authored
212 echo "<fieldset><legend>" . lang('Limit') . "</legend><div>";
b142000 Hide fieldsets in select
jakubvrana authored
213 echo "<input name='limit' size='3' value=\"" . htmlspecialchars($limit) . "\" />";
214 echo "</div></fieldset>\n";
ffcea8b Rights
jakubvrana authored
215
63441b1 Max text length
jakubvrana authored
216 if (isset($text_length)) {
b142000 Hide fieldsets in select
jakubvrana authored
217 echo "<fieldset><legend>" . lang('Text length') . "</legend><div>";
218 echo "<input name='text_length' size='3' value=\"" . htmlspecialchars($text_length) . "\" />";
219 echo "</div></fieldset>\n";
63441b1 Max text length
jakubvrana authored
220 }
221
b142000 Hide fieldsets in select
jakubvrana authored
222 echo "<fieldset><legend>" . lang('Action') . "</legend><div>";
223 echo "<input type='submit' value='" . lang('Select') . "' />";
224 echo "</div></fieldset>\n";
ffcea8b Rights
jakubvrana authored
225 echo "</form>\n";
226
8b74511 Print SQL query (fixes #2082448)
jakubvrana authored
227 $query = "SELECT " . ($select ? (count($group) < count($select) ? "SQL_CALC_FOUND_ROWS " : "") . implode(", ", $select) : "*") . " $from";
06faef2 Print SQL query by messages
jakubvrana authored
228 echo "<p><code class='jush-sql'>" . htmlspecialchars($query) . "</code> <a href='" . htmlspecialchars($SELF) . "sql=" . urlencode($query) . "'>" . lang('Edit') . "</a></p>\n";
8b74511 Print SQL query (fixes #2082448)
jakubvrana authored
229
5f16c75 Prepare for version 2
jakubvrana authored
230 $result = $dbh->query($query);
21ea4ae Check errors
jakubvrana authored
231 if (!$result) {
5f16c75 Prepare for version 2
jakubvrana authored
232 echo "<p class='error'>" . htmlspecialchars($dbh->error) . "</p>\n";
ffcea8b Rights
jakubvrana authored
233 } else {
e7eb28d CSV import
jakubvrana authored
234 echo "<form action='' method='post' enctype='multipart/form-data'>\n";
21ea4ae Check errors
jakubvrana authored
235 if (!$result->num_rows) {
236 echo "<p class='message'>" . lang('No rows.') . "</p>\n";
237 } else {
238 $foreign_keys = array();
239 foreach (foreign_keys($_GET["select"]) as $foreign_key) {
240 foreach ($foreign_key["source"] as $val) {
241 $foreign_keys[$val][] = $foreign_key;
242 }
ffcea8b Rights
jakubvrana authored
243 }
21ea4ae Check errors
jakubvrana authored
244
d30face Remove useless table attributes (thanks to Juraj Krivda)
jakubvrana authored
245 echo "<table cellspacing='0' class='nowrap'>\n";
21ea4ae Check errors
jakubvrana authored
246 for ($j=0; $row = $result->fetch_assoc(); $j++) {
247 if (!$j) {
d5a4d14 Separate page and whole result check
jakubvrana authored
248 echo '<thead><tr><td><input type="checkbox" id="all-page" onclick="form_check(this, /check/);" /></td>';
e4089af Order rows by clicking on table heading
jakubvrana authored
249 foreach ($row as $key => $val) {
b142000 Hide fieldsets in select
jakubvrana authored
250 echo '<th><a href="' . htmlspecialchars(remove_from_uri('(order|desc)[^=]*') . '&order%5B0%5D=' . urlencode($key) . ($_GET["order"] == array($key) && !$_GET["desc"][0] ? '&desc%5B0%5D=1' : '')) . '">' . htmlspecialchars($key) . '</a></th>';
e4089af Order rows by clicking on table heading
jakubvrana authored
251 }
252 echo "</tr></thead>\n";
21ea4ae Check errors
jakubvrana authored
253 }
116faf2 Mass delete
jakubvrana authored
254 $unique_idf = implode('&amp;', unique_idf($row, $indexes));
0cd2afb Remove single item clone
jakubvrana authored
255 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) && $_GET["db"] != "information_schema" ? ' <a href="' . htmlspecialchars($SELF) . 'edit=' . urlencode($_GET['select']) . '&amp;' . $unique_idf . '">' . lang('edit') . '</a></td>' : '');
21ea4ae Check errors
jakubvrana authored
256 foreach ($row as $key => $val) {
257 if (!isset($val)) {
258 $val = "<i>NULL</i>";
017ffb5 Better UTF-8 detection
jakubvrana authored
259 } elseif (preg_match('~blob|binary~', $fields[$key]["type"]) && !is_utf8($val)) {
116faf2 Mass delete
jakubvrana authored
260 $val = '<a href="' . htmlspecialchars($SELF) . 'download=' . urlencode($_GET["select"]) . '&amp;field=' . urlencode($key) . '&amp;' . $unique_idf . '">' . lang('%d byte(s)', strlen($val)) . '</a>';
02a851c Shorten texts in PHP
jakubvrana authored
261 } else {
4c75d84 Use &nbsp;
jakubvrana authored
262 if (!strlen(trim($val))) {
263 $val = "&nbsp;";
264 } elseif (intval($text_length) > 0 && preg_match('~blob|text~', $fields[$key]["type"])) {
33e8015 Shorten displayed SQL query
jakubvrana authored
265 $val = nl2br(shorten_utf8($val, intval($text_length)));
21ea4ae Check errors
jakubvrana authored
266 } else {
267 $val = nl2br(htmlspecialchars($val));
268 if ($fields[$key]["type"] == "char") {
269 $val = "<code>$val</code>";
270 }
02a851c Shorten texts in PHP
jakubvrana authored
271 }
21ea4ae Check errors
jakubvrana authored
272 foreach ((array) $foreign_keys[$key] as $foreign_key) {
273 if (count($foreign_keys[$key]) == 1 || count($foreign_key["source"]) == 1) {
274 $val = "\">$val</a>";
275 foreach ($foreign_key["source"] as $i => $source) {
276 $val = "&amp;where%5B$i%5D%5Bcol%5D=" . urlencode($foreign_key["target"][$i]) . "&amp;where%5B$i%5D%5Bop%5D=%3D&amp;where%5B$i%5D%5Bval%5D=" . urlencode($row[$source]) . $val;
277 }
278 $val = '<a href="' . htmlspecialchars(strlen($foreign_key["db"]) ? preg_replace('~([?&]db=)[^&]+~', '\\1' . urlencode($foreign_key["db"]), $SELF) : $SELF) . 'select=' . htmlspecialchars($foreign_key["table"]) . $val; // InnoDB supports non-UNIQUE keys
279 break;
ffcea8b Rights
jakubvrana authored
280 }
fa3dd55 Parent
jakubvrana authored
281 }
667bfec Decomposition
jakubvrana authored
282 }
21ea4ae Check errors
jakubvrana authored
283 echo "<td>$val</td>";
667bfec Decomposition
jakubvrana authored
284 }
21ea4ae Check errors
jakubvrana authored
285 echo "</tr>\n";
5ab708a Compact pages
jakubvrana authored
286 }
21ea4ae Check errors
jakubvrana authored
287 echo "</table>\n";
e4b188c Display found rows
jakubvrana authored
288
289 echo "<p>";
5f16c75 Prepare for version 2
jakubvrana authored
290 $found_rows = (intval($limit) ? $dbh->result($dbh->query(count($group) < count($select) ? " SELECT FOUND_ROWS()" : "SELECT COUNT(*) FROM " . idf_escape($_GET["select"]) . ($where ? " WHERE " . implode(" AND ", $where) : ""))) : $result->num_rows);
e4b188c Display found rows
jakubvrana authored
291 if (intval($limit) && $found_rows > $limit) {
21ea4ae Check errors
jakubvrana authored
292 $max_page = floor(($found_rows - 1) / $limit);
e4b188c Display found rows
jakubvrana authored
293 echo lang('Page') . ":";
21ea4ae Check errors
jakubvrana authored
294 print_page(0);
295 if ($_GET["page"] > 3) {
296 echo " ...";
297 }
298 for ($i = max(1, $_GET["page"] - 2); $i < min($max_page, $_GET["page"] + 3); $i++) {
299 print_page($i);
300 }
301 if ($_GET["page"] + 3 < $max_page) {
302 echo " ...";
303 }
304 print_page($max_page);
5ab708a Compact pages
jakubvrana authored
305 }
d5a4d14 Separate page and whole result check
jakubvrana authored
306 echo " (" . lang('%d row(s)', $found_rows) . ') <label><input type="checkbox" name="all" value="1" />' . lang('whole result') . "</label></p>\n";
8b74511 Print SQL query (fixes #2082448)
jakubvrana authored
307
4f59613 Don't allow editing in information_schema
jakubvrana authored
308 echo ($_GET["db"] != "information_schema" ? "<fieldset><legend>" . lang('Edit') . "</legend><div><input type='submit' value='" . lang('Edit') . "' /> <input type='submit' name='clone' value='" . lang('Clone') . "' /> <input type='submit' name='delete' value='" . lang('Delete') . "'$confirm /></div></fieldset>\n" : "");
fb8a36b Compact export options
jakubvrana authored
309 echo "<fieldset><legend>" . lang('Export') . "</legend><div>$dump_output $dump_format <input type='submit' name='export' value='" . lang('Export') . "' /></div></fieldset>\n";
667bfec Decomposition
jakubvrana authored
310 }
21ea4ae Check errors
jakubvrana authored
311 $result->free();
e7eb28d CSV import
jakubvrana authored
312 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";
313 echo "</form>\n";
667bfec Decomposition
jakubvrana authored
314 }
315 }
Something went wrong with that request. Please try again.