Пример #1
0
$oid = "";
if ($table_status["Oid"]) {
    $oid = $jush == "sqlite" ? "rowid" : "oid";
    $indexes[] = array("type" => "PRIMARY", "columns" => array($oid));
}
parse_str($_COOKIE["adminer_import"], $adminer_import);
$rights = array();
// privilege => 0
$columns = array();
// selectable columns
$text_length = null;
foreach ($fields as $key => $field) {
    $name = $adminer->fieldName($field);
    if (isset($field["privileges"]["select"]) && $name != "") {
        $columns[$key] = html_entity_decode(strip_tags($name), ENT_QUOTES);
        if (is_shortable($field)) {
            $text_length = $adminer->selectLengthProcess();
        }
    }
    $rights += $field["privileges"];
}
list($select, $group) = $adminer->selectColumnsProcess($columns, $indexes);
$is_group = count($group) < count($select);
$where = $adminer->selectSearchProcess($fields, $indexes);
$order = $adminer->selectOrderProcess($fields, $indexes);
$limit = $adminer->selectLimitProcess();
$from = ($select ? implode(", ", $select) : "*" . ($oid ? ", {$oid}" : "")) . convert_fields($columns, $fields, $select) . "\nFROM " . adminer_table($TABLE);
$group_by = ($group && $is_group ? "\nGROUP BY " . implode(", ", $group) : "") . ($order ? "\nORDER BY " . implode(", ", $order) : "");
if ($_GET["val"] && is_adminer_ajax()) {
    header("Content-Type: text/plain; charset=utf-8");
    foreach ($_GET["val"] as $unique_idf => $row) {
Пример #2
0
/** 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_mail($val)) {
            $link = "mailto:{$val}";
        }
        if ($protocol = is_url($val)) {
            $link = $protocol == "http" && $HTTPS || preg_match('~WebKit~i', $_SERVER["HTTP_USER_AGENT"]) ? $val : "https://www.adminer.org/redirect/?url=" . urlencode($val);
        }
    }
    $return = $adminer->editVal($val, $field);
    if ($return !== null) {
        if ($return === "") {
            // === - may be int
            $return = "&nbsp;";
        } elseif (!is_utf8($return)) {
            $return = "";
            // htmlspecialchars of binary data returns an empty string
        } elseif ($text_length != "" && is_shortable($field)) {
            $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);
}
Пример #3
0
 $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 = "";
 $val = $adminer->editVal($val, $field);
 if ($val !== null) {
     if (ereg('blob|bytea|raw|file', $field["type"]) && $val != "") {
         $link = h(ME . 'download=' . urlencode($TABLE) . '&field=' . urlencode($key) . $unique_idf);
     }
     if ($val === "") {
         // === - may be int
         $val = "&nbsp;";
     } elseif (is_utf8($val)) {
         if ($text_length != "" && is_shortable($field)) {
             $val = shorten_utf8($val, 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 {
             $val = h($val);
         }
     }
     if (!$link) {
         // 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 = h(($foreign_key["db"] != "" ? preg_replace('~([?&]db=)[^&]+~', '\\1' . urlencode($foreign_key["db"]), ME) : ME) . 'select=' . urlencode($foreign_key["table"]) . $link);