$field) { if (isset($field["privileges"]["select"])) { $columns[] = $key; } $rights += $field["privileges"]; } if (isset($rights["insert"])) { echo '

' . lang('New item') . "

\n"; } if (!$columns) { echo "

" . lang('Unable to select the table') . ($fields ? "" : ": " . $mysql->error) . ".

\n"; } else { $indexes = indexes($_GET["select"]); echo "
\n
" . lang('Search') . "\n"; if (strlen($_GET["server"])) { echo ''; } echo ''; echo ''; echo "\n"; $where = array(); foreach ($indexes as $i => $index) { if ($index["type"] == "FULLTEXT") { if (strlen($_GET["fulltext"][$i])) { $where[] = "MATCH (" . implode(", ", array_map('idf_escape', $index["columns"])) . ") AGAINST ('" . $mysql->escape_string($_GET["fulltext"][$i]) . "'" . (isset($_GET["boolean"][$i]) ? " IN BOOLEAN MODE" : "") . ")"; } echo "(" . implode(", ", $index["columns"]) . ") AGAINST"; echo ' '; echo ""; echo "
\n"; } } $operators = array("=", "<", ">", "<=", ">=", "!=", "LIKE", "REGEXP", "IS NULL"); $i = 0; foreach ((array) $_GET["where"] as $val) { if (strlen($val["col"]) && in_array($val["op"], $operators)) { $where[] = idf_escape($val["col"]) . " $val[op]" . ($val["op"] != "IS NULL" ? " '" . $mysql->escape_string($val["val"]) . "'" : ""); echo "
"; echo ""; echo "
\n"; $i++; } } ?> "; echo ""; echo "\n"; //! JavaScript for adding next echo "
\n"; echo "
" . lang('Sort') . "\n"; $order = array(); $i = 0; foreach ((array) $_GET["order"] as $key => $val) { if (in_array($val, $columns, true)) { $order[] = idf_escape($val) . (isset($_GET["desc"][$key]) ? " DESC" : ""); echo "
"; echo "
\n"; $i++; } } echo "
"; echo "
\n"; echo "
\n"; echo "
" . lang('Limit') . "\n"; $limit = (isset($_GET["limit"]) ? $_GET["limit"] : "30"); echo '
'; echo "
\n"; echo "
" . lang('Action') . "
\n"; echo "
\n"; echo "
\n"; $result = $mysql->query("SELECT SQL_CALC_FOUND_ROWS " . implode(", ", array_map('idf_escape', $columns)) . " FROM " . idf_escape($_GET["select"]) . ($where ? " WHERE " . implode(" AND ", $where) : "") . ($order ? " ORDER BY " . implode(", ", $order) : "") . (strlen($limit) ? " LIMIT " . intval($limit) . " OFFSET " . ($limit * $_GET["page"]) : "")); if (!$result->num_rows) { echo "

" . lang('No rows.') . "

\n"; } else { $found_rows = $mysql->result($mysql->query(" SELECT FOUND_ROWS()"), 0); // space for mysql.trace_mode $foreign_keys = array(); foreach (foreign_keys($_GET["select"]) as $foreign_key) { foreach ($foreign_key[2] as $val) { $foreign_keys[$val][] = $foreign_key; } } $childs = array(); if ($mysql->server_info >= 5) { // would be possible in earlier versions too, but only by examining all tables (in all databases) $result1 = $mysql->query("SELECT * FROM information_schema.KEY_COLUMN_USAGE WHERE REFERENCED_TABLE_SCHEMA = '" . $mysql->escape_string($_GET["db"]) . "' AND REFERENCED_TABLE_NAME = '" . $mysql->escape_string($_GET["select"]) . "' ORDER BY ORDINAL_POSITION"); while ($row1 = $result1->fetch_assoc()) { $childs[$row1["CONSTRAINT_NAME"]][0] = $row1["TABLE_SCHEMA"]; $childs[$row1["CONSTRAINT_NAME"]][1] = $row1["TABLE_NAME"]; $childs[$row1["CONSTRAINT_NAME"]][2][] = $row1["REFERENCED_COLUMN_NAME"]; $childs[$row1["CONSTRAINT_NAME"]][3][] = $row1["COLUMN_NAME"]; } $result1->free(); } echo "\n"; for ($j=0; $row = $result->fetch_assoc(); $j++) { if (!$j) { echo "\n"; } echo ""; $unique_idf = '&' . implode('&', unique_idf($row, $indexes)); foreach ($row as $key => $val) { if (!isset($val)) { $val = "NULL"; } elseif (preg_match('~blob|binary~', $fields[$key]["type"]) && preg_match('~[\\x80-\\xFF]~', $val)) { $val = '' . lang('%d byte(s)', strlen($val)) . ''; } else { $val = (strlen(trim($val)) ? nl2br(htmlspecialchars($val)) : " "); foreach ((array) $foreign_keys[$key] as $foreign_key) { if (count($foreign_keys[$key]) == 1 || count($foreign_key[2]) == 1) { $val = '">' . "$val"; foreach ($foreign_key[2] as $i => $source) { $val = "&where%5B$i%5D%5Bcol%5D=" . urlencode($foreign_key[3][$i]) . "&where%5B$i%5D%5Bop%5D=%3D&where%5B$i%5D%5Bval%5D=" . urlencode($row[$source]) . $val; } $val = '$val"; } echo ''; echo "\n"; } echo "
" . implode("", array_map('htmlspecialchars', array_keys($row))) . "" . lang('Action') . "
' . lang('edit') . ''; foreach ($childs as $child) { echo ' ' . htmlspecialchars($child[1]) . ''; } echo '
\n"; if (intval($limit) && $found_rows > $limit) { echo "

" . lang('Page') . ":\n"; for ($i=0; $i < $found_rows / $limit; $i++) { echo ($i == $_GET["page"] ? $i + 1 : '' . ($i + 1) . "") . "\n"; } echo "

\n"; } } $result->free(); }