", "<=", ">=", "!=", "LIKE", "REGEXP", "IN", "IS NULL"); if ($table_status["Engine"] == "MyISAM") { $operators[] = "AGAINST"; } $fields = fields($_GET["select"]); $rights = array(); $columns = array(); unset($text_length); foreach ($fields as $key => $field) { if (isset($field["privileges"]["select"])) { $columns[] = $key; if (preg_match('~text|blob~', $field["type"])) { $text_length = (isset($_GET["text_length"]) ? $_GET["text_length"] : "100"); } } $rights += $field["privileges"]; } $where = array(); foreach ($indexes as $i => $index) { if ($index["type"] == "FULLTEXT" && 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" : "") . ")"; } } foreach ((array) $_GET["where"] as $val) { if (strlen($val["col"]) && in_array($val["op"], $operators)) { if ($val["op"] == "IN") { $in = process_length($val["val"]); $where[] = (strlen($in) ? idf_escape($val["col"]) . " IN ($in)" : "0"); } elseif ($val["op"] == "AGAINST") { $where[] = "MATCH (" . idf_escape($val["col"]) . ") AGAINST ('" . $mysql->escape_string($val["val"]) . "' IN BOOLEAN MODE)"; } else { $where[] = idf_escape($val["col"]) . " $val[op]" . ($val["op"] == "IS NULL" ? "" : " '" . $mysql->escape_string($val["val"]) . "'"); } } } $order = array(); foreach ((array) $_GET["order"] as $key => $val) { if (in_array($val, $columns, true)) { $order[] = idf_escape($val) . (isset($_GET["desc"][$key]) ? " DESC" : ""); } } $limit = (isset($_GET["limit"]) ? $_GET["limit"] : "30"); $from = "FROM " . idf_escape($_GET["select"]) . ($where ? " WHERE " . implode(" AND ", $where) : "") . ($order ? " ORDER BY " . implode(", ", $order) : "") . (strlen($limit) ? " LIMIT " . intval($limit) . (intval($_GET["page"]) ? " OFFSET " . ($limit * $_GET["page"]) : "") : ""); if ($_POST && !$error) { $result = true; $deleted = 0; if (isset($_POST["truncate"])) { $result = $mysql->query("TRUNCATE " . idf_escape($_GET["select"])); $deleted = $mysql->affected_rows; } elseif (is_array($_POST["delete"])) { foreach ($_POST["delete"] as $val) { parse_str($val, $delete); $result = $mysql->query("DELETE FROM " . idf_escape($_GET["select"]) . " WHERE " . implode(" AND ", where($delete)) . " LIMIT 1"); if (!$result) { break; } $deleted += $mysql->affected_rows; } } elseif ($_POST["delete_selected"]) { if (!$_GET["page"]) { $result = $mysql->query("DELETE $from"); $deleted = $mysql->affected_rows; } else { $result1 = $mysql->query("SELECT * $from"); while ($row1 = $result1->fetch_assoc()) { parse_str(implode("&", unique_idf($row1, $indexes)), $delete); $result = $mysql->query("DELETE FROM " . idf_escape($_GET["select"]) . " WHERE " . implode(" AND ", where($delete)) . " LIMIT 1"); if (!$result) { break; } $deleted += $mysql->affected_rows; } $result1->free(); } } if ($result) { redirect(remove_from_uri("page"), lang('%d item(s) have been deleted.', $deleted)); } $error = $mysql->error; } page_header(lang('Select') . ": " . htmlspecialchars($_GET["select"])); if ($_POST) { echo "
" . lang('Error during deleting') . ": " . htmlspecialchars($error) . "
\n"; } if (isset($rights["insert"])) { //! pass search values forth and back echo '\n"; } if (!$columns) { echo "" . lang('Unable to select the table') . ($fields ? "" : ": " . $mysql->error) . ".
\n"; } else { echo "\n"; echo "" . lang('Error in query') . ": " . htmlspecialchars($mysql->error) . "
\n"; } else { if (!$result->num_rows) { echo " \n"; } else { $found_rows = $mysql->result($mysql->query(" SELECT FOUND_ROWS()")); // space for mysql.trace_mode $foreign_keys = array(); foreach (foreign_keys($_GET["select"]) as $foreign_key) { foreach ($foreign_key["source"] as $val) { $foreign_keys[$val][] = $foreign_key; } } echo "\n"; if (intval($limit) && $found_rows > $limit) { $max_page = floor(($found_rows - 1) / $limit); function print_page($page) { echo " " . ($page == $_GET["page"] ? $page + 1 : '' . ($page + 1) . ""); } echo "" . lang('Page') . ":"; print_page(0); if ($_GET["page"] > 3) { echo " ..."; } for ($i = max(1, $_GET["page"] - 2); $i < min($max_page, $_GET["page"] + 3); $i++) { print_page($i); } if ($_GET["page"] + 3 < $max_page) { echo " ..."; } print_page($max_page); echo "
\n"; } } $result->free(); } }