$unique_idf = ""; foreach ($unique_array as $key => $val) { if (($jush == "sql" || $jush == "pgsql") && strlen($val) > 64) { $key = strpos($key, '(') ? $key : idf_escape($key); //! columns looking like functions $key = "MD5(" . ($jush == 'sql' && preg_match("~^utf8_~", $fields[$key]["collation"]) ? $key : "CONVERT({$key} USING " . charset($connection) . ")") . ")"; $val = md5($val); } $unique_idf .= "&" . ($val !== null ? urlencode("where[" . bracket_escape($key) . "]") . "=" . urlencode($val) : "null%5B%5D=" . urlencode($key)); } echo "<tr" . odd() . ">" . (!$group && $select ? "" : "<td>" . adminer_checkbox("check[]", substr($unique_idf, 1), in_array(substr($unique_idf, 1), (array) $_POST["check"]), "", "this.form['all'].checked = false; formUncheck('all-page');") . ($is_group || information_schema(DB) ? "" : " <a href='" . h(ME . "edit=" . urlencode($TABLE) . $unique_idf) . "'>" . lang('edit') . "</a>")); foreach ($row as $key => $val) { if (isset($names[$key])) { $field = $fields[$key]; if ($val != "" && (!isset($email_fields[$key]) || $email_fields[$key] != "")) { $email_fields[$key] = is_adminer_mail($val) ? $names[$key] : ""; //! filled e-mails can be contained on other pages } $link = ""; if (preg_match('~blob|bytea|raw|file~', $field["type"]) && $val != "") { $link = ME . 'download=' . urlencode($TABLE) . '&field=' . urlencode($key) . $unique_idf; } if (!$link && $val !== null) { // link related items foreach ((array) $foreign_keys[$key] as $foreign_key) { if (count($foreign_keys[$key]) == 1 || end($foreign_key["source"]) == $key) { $link = ""; foreach ($foreign_key["source"] as $i => $source) { $link .= where_link($i, $foreign_key["target"][$i], $rows[$n][$source]); } $link = ($foreign_key["db"] != "" ? preg_replace('~([?&]db=)[^&]+~', '\\1' . urlencode($foreign_key["db"]), ME) : ME) . 'select=' . urlencode($foreign_key["table"]) . $link;
/** Format value to use in select * @param string * @param string * @param array * @param int * @return string HTML */ function select_value($val, $link, $field, $text_length) { global $adminer, $HTTPS; if (is_array($val)) { $return = ""; foreach ($val as $k => $v) { $return .= "<tr>" . ($val != array_values($val) ? "<th>" . h($k) : "") . "<td>" . select_value($v, $link, $field, $text_length); } return "<table cellspacing='0'>{$return}</table>"; } if (!$link) { $link = $adminer->selectLink($val, $field); } if ($link === null) { if (is_adminer_mail($val)) { $link = "mailto:{$val}"; } if ($protocol = is_url($val)) { $link = $protocol == "http" && $HTTPS || preg_match('~WebKit~i', $_SERVER["HTTP_USER_AGENT"]) ? $val : "{$protocol}://www.adminer.org/redirect/?url=" . urlencode($val); } } $return = $adminer->editVal($val, $field); if ($return !== null) { if ($return === "") { // === - may be int $return = " "; } elseif ($text_length != "" && is_shortable($field) && is_utf8($return)) { $return = shorten_utf8($return, max(0, +$text_length)); // usage of LEFT() would reduce traffic but complicate query - expected average speedup: .001 s VS .01 s on local network } else { $return = h($return); } } return $adminer->selectVal($return, $link, $field, $val); }
if ($key == "COUNT(*)") { //! columns looking like functions $link = h(ME . "select=" . urlencode($TABLE)); $i = 0; foreach ((array) $_GET["where"] as $v) { if (!array_key_exists($v["col"], $unique_array)) { $link .= h(where_link($i++, $v["col"], $v["val"], $v["op"])); } } foreach ($unique_array as $k => $v) { $link .= h(where_link($i++, $k, $v)); } } } if (!$link) { if (is_adminer_mail($val)) { $link = "mailto:{$val}"; } if ($protocol = is_url($row[$key])) { $link = $protocol == "http" && $HTTPS ? $row[$key] : "{$protocol}://www.adminer.org/redirect/?url=" . urlencode($row[$key]); } } $id = h("val[{$unique_idf}][" . bracket_escape($key) . "]"); $value = $_POST["val"][$unique_idf][bracket_escape($key)]; $h_value = h(isset($value) ? $value : $row[$key]); $long = strpos($val, "<i>...</i>"); $editable = is_utf8($val) && $rows[$n][$key] == $row[$key] && !$functions[$key]; $text = ereg('text|lob', $field["type"]); echo $_GET["modify"] && $editable || isset($value) ? "<td>" . ($text ? "<textarea name='{$id}' cols='30' rows='" . (substr_count($row[$key], "\n") + 1) . "'>{$h_value}</textarea>" : "<input name='{$id}' value='{$h_value}' size='{$lengths[$key]}'>") : "<td id='{$id}' ondblclick=\"" . ($editable ? "selectDblClick(this, event" . ($long ? ", 2" : ($text ? ", 1" : "")) . ")" : "alert('" . h(lang('Use edit link to modify this value.')) . "')") . ";\">" . $adminer->selectVal($val, $link, $field); } }