Beispiel #1
0
    echo $_POST ? "" : "<script type='text/javascript'>focus(document.getElementsByTagName('textarea')[0]);</script>\n";
    echo "<p>{$execute}\n";
} else {
    echo "<fieldset><legend>" . lang('File upload') . "</legend><div>";
    echo ini_bool("file_uploads") ? '<input type="file" name="sql_file[]" multiple> (&lt; ' . ini_get("upload_max_filesize") . 'B)' : lang('File uploads are disabled.');
    echo "\n{$execute}";
    echo "</div></fieldset>\n";
    echo "<fieldset><legend>" . lang('From server') . "</legend><div>";
    echo lang('Webserver file %s', "<code>adminer.sql" . (extension_loaded("zlib") ? "[.gz]" : "") . "</code>");
    echo ' <input type="submit" name="webfile" value="' . lang('Run file') . '">';
    echo "</div></fieldset>\n";
    echo "<p>";
}
echo adminer_checkbox("error_stops", 1, $_POST ? $_POST["error_stops"] : isset($_GET["import"]), lang('Stop on error')) . "\n";
echo adminer_checkbox("only_errors", 1, $_POST ? $_POST["only_errors"] : isset($_GET["import"]), lang('Show only errors')) . "\n";
echo "<input type='hidden' name='token' value='{$token}'>\n";
if (!isset($_GET["import"]) && $history) {
    print_fieldset("history", lang('History'), $_GET["history"] != "");
    for ($val = end($history); $val; $val = prev($history)) {
        // not array_reverse() to save memory
        $key = key($history);
        list($q, $time, $elapsed) = $val;
        echo '<a href="' . h(ME . "sql=&history={$key}") . '">' . lang('Edit') . "</a>" . " <span class='time' title='" . @date('Y-m-d', $time) . "'>" . @date("H:i:s", $time) . "</span>" . " <code class='jush-{$jush}'>" . shorten_utf8(ltrim(str_replace("\n", " ", str_replace("\r", "", preg_replace('~^(#|-- ).*~m', '', $q)))), 80, "</code>") . ($elapsed ? " <span class='time'>({$elapsed})</span>" : "") . "<br>\n";
    }
    echo "<input type='submit' name='clear' value='" . lang('Clear') . "'>\n";
    echo "<a href='" . h(ME . "sql=&history=all") . "'>" . lang('Edit all') . "</a>\n";
    echo "</div></fieldset>\n";
}
?>
</form>
Beispiel #2
0
 if ($val != "" && (!isset($email_fields[$key]) || $email_fields[$key] != "")) {
     $email_fields[$key] = is_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 != "" && ereg('text|lob|geometry|point|linestring|polygon', $field["type"])) {
             $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);
                 // InnoDB supports non-UNIQUE keys
Beispiel #3
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);
}
Beispiel #4
0
 /** Query printed after execution in the message
  * @param string executed query
  * @param string elapsed time
  * @return string
  */
 function messageQuery($query, $time)
 {
     global $jush;
     restart_session();
     $history =& get_session("queries");
     $id = "sql-" . count($history[$_GET["db"]]);
     if (strlen($query) > 1000000.0) {
         $query = preg_replace('~[\\x80-\\xFF]+$~', '', substr($query, 0, 1000000.0)) . "\n...";
         // [\x80-\xFF] - valid UTF-8, \n - can end by one-line comment
     }
     $history[$_GET["db"]][] = array($query, time(), $time);
     // not DB - $_GET["db"] is changed in database.inc.php //! respect $_GET["ns"]
     return " <span class='time'>" . @date("H:i:s") . "</span> <a href='#{$id}' onclick=\"return !toggle('{$id}');\">" . lang('SQL command') . "</a>" . "<div id='{$id}' class='hidden'><pre><code class='jush-{$jush}'>" . shorten_utf8($query, 1000) . '</code></pre>' . ($time ? " <span class='time'>({$time})</span>" : '') . (support("sql") ? '<p><a href="' . h(str_replace("db=" . urlencode(DB), "db=" . urlencode($_GET["db"]), ME) . 'sql=&history=' . (count($history[$_GET["db"]]) - 1)) . '">' . lang('Edit') . '</a>' : '') . '</div>';
 }
<form action="" method="post">
<table cellspacing="0" onclick="tableClick(event);" ondblclick="tableClick(event, true);" class="nowrap checkable">
<?php 
// HTML valid because there is always at least one process
$i = -1;
foreach (process_list() as $i => $row) {
    if (!$i) {
        echo "<thead><tr lang='en'>" . (support("kill") ? "<th>&nbsp;" : "");
        foreach ($row as $key => $val) {
            echo "<th>{$key}" . doc_link(array('sql' => "show-processlist.html#processlist_" . strtolower($key), 'pgsql' => "monitoring-stats.html#PG-STAT-ACTIVITY-VIEW", 'oracle' => "../b14237/dynviews_2088.htm"));
        }
        echo "</thead>\n";
    }
    echo "<tr" . odd() . ">" . (support("kill") ? "<td>" . checkbox("kill[]", $row[$jush == "sql" ? "Id" : "pid"], 0) : "");
    foreach ($row as $key => $val) {
        echo "<td>" . ($jush == "sql" && $key == "Info" && preg_match("~Query|Killed~", $row["Command"]) && $val != "" || $jush == "pgsql" && $key == "current_query" && $val != "<IDLE>" || $jush == "oracle" && $key == "sql_text" && $val != "" ? "<code class='jush-{$jush}'>" . shorten_utf8($val, 100, "</code>") . ' <a href="' . h(ME . ($row["db"] != "" ? "db=" . urlencode($row["db"]) . "&" : "") . "sql=" . urlencode($val)) . '">' . lang('Clone') . '</a>' : nbsp($val));
    }
    echo "\n";
}
?>
</table>
<script type='text/javascript'>tableCheck();</script>
<p>
<?php 
if (support("kill")) {
    echo $i + 1 . "/" . lang('%d in total', max_connections());
    echo "<p><input type='submit' value='" . lang('Kill') . "'>\n";
}
?>
<input type="hidden" name="token" value="<?php 
echo $token;
Beispiel #6
0
 for ($j = 0; $row = $result->fetch_assoc(); $j++) {
     if (!$j) {
         echo '<thead><tr><td><label><input type="checkbox" name="delete_selected" value="1" onclick="var elems = this.form.elements; for (var i=0; i < elems.length; i++) if (elems[i].name == \'delete[]\') elems[i].checked = this.checked;" />' . lang('all') . '</label></td><th>' . implode("</th><th>", array_map('htmlspecialchars', array_keys($row))) . "</th></tr></thead>\n";
     }
     $unique_idf = implode('&amp;', unique_idf($row, $indexes));
     echo '<tr><td><input type="checkbox" name="delete[]" value="' . $unique_idf . '" /> <a href="' . htmlspecialchars($SELF) . 'edit=' . urlencode($_GET['select']) . '&amp;' . $unique_idf . '">' . lang('edit') . "</a></td>";
     foreach ($row as $key => $val) {
         if (!isset($val)) {
             $val = "<i>NULL</i>";
         } elseif (preg_match('~blob|binary~', $fields[$key]["type"]) && preg_match('~[\\x80-\\xFF]~', $val)) {
             $val = '<a href="' . htmlspecialchars($SELF) . 'download=' . urlencode($_GET["select"]) . '&amp;field=' . urlencode($key) . '&amp;' . $unique_idf . '">' . lang('%d byte(s)', strlen($val)) . '</a>';
         } else {
             if (!strlen(trim($val))) {
                 $val = "&nbsp;";
             } elseif (intval($text_length) > 0 && preg_match('~blob|text~', $fields[$key]["type"]) && strlen($val) > intval($text_length)) {
                 $val = preg_match('~blob~', $fields[$key]["type"]) ? nl2br(htmlspecialchars(substr($val, 0, intval($text_length)))) . "<em>...</em>" : shorten_utf8($val, intval($text_length));
             } else {
                 $val = nl2br(htmlspecialchars($val));
                 if ($fields[$key]["type"] == "char") {
                     $val = "<code>{$val}</code>";
                 }
             }
             foreach ((array) $foreign_keys[$key] as $foreign_key) {
                 if (count($foreign_keys[$key]) == 1 || count($foreign_key["source"]) == 1) {
                     $val = "\">{$val}</a>";
                     foreach ($foreign_key["source"] as $i => $source) {
                         $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;
                     }
                     $val = '<a href="' . htmlspecialchars(strlen($foreign_key["db"]) ? preg_replace('~([?&]db=)[^&]+~', '\\1' . urlencode($foreign_key["db"]), $SELF) : $SELF) . 'select=' . htmlspecialchars($foreign_key["table"]) . $val;
                     break;
                 }
}
page_header(lang('Process list'), $error);
?>

<form action="" method="post">
<table cellspacing="0" onclick="tableClick(event);" class="nowrap checkable">
<?php 
// HTML valid because there is always at least one process
$i = -1;
foreach (process_list() as $i => $row) {
    if (!$i) {
        echo "<thead><tr lang='en'>" . (support("kill") ? "<th>&nbsp;" : "") . "<th>" . implode("<th>", array_keys($row)) . "</thead>\n";
    }
    echo "<tr" . odd() . ">" . (support("kill") ? "<td>" . checkbox("kill[]", $row["Id"], 0) : "");
    foreach ($row as $key => $val) {
        echo "<td>" . ($jush == "sql" ? $key == "Info" && $val != "" : $key == "current_query" && $val != "<IDLE>" ? "<code class='jush-{$jush}'>" . shorten_utf8($val, 100, "</code>") . ' <a href="' . h(ME . ($row["db"] != "" ? "db=" . urlencode($row["db"]) . "&" : "") . "sql=" . urlencode($val)) . '">' . lang('Edit') . '</a>' : nbsp($val));
    }
    echo "\n";
}
?>
</table>
<script type='text/javascript'>tableCheck();</script>
<p>
<?php 
if (support("kill")) {
    echo $i + 1 . "/" . lang('%d in total', $connection->result("SELECT @@max_connections"));
    echo "<p><input type='submit' value='" . lang('Kill') . "'>\n";
}
?>
<input type="hidden" name="token" value="<?php 
echo $token;
<input type="hidden" name="token" value="<?php 
echo $token;
?>
">
<?php 
echo checkbox("error_stops", 1, $_POST["error_stops"], lang('Stop on error')) . "\n";
echo checkbox("only_errors", 1, $_POST["only_errors"], lang('Show only errors')) . "\n";
print_fieldset("webfile", lang('From server'), $_POST["webfile"], "document.getElementById('form')['only_errors'].checked = true; ");
$compress = array();
foreach (array("gz" => "zlib", "bz2" => "bz2") as $key => $val) {
    if (extension_loaded($val)) {
        $compress[] = ".{$key}";
    }
}
echo lang('Webserver file %s', "<code>adminer.sql" . ($compress ? "[" . implode("|", $compress) . "]" : "") . "</code>");
echo ' <input type="submit" name="webfile" value="' . lang('Run file') . '">';
echo "</div></fieldset>\n";
if ($history) {
    print_fieldset("history", lang('History'), $_GET["history"] != "");
    foreach ($history as $key => $val) {
        //! save and display timestamp
        echo '<a href="' . h(ME . "sql=&history={$key}") . '">' . lang('Edit') . "</a> <code class='jush-{$jush}'>" . shorten_utf8(ltrim(str_replace("\n", " ", str_replace("\r", "", preg_replace('~^(#|-- ).*~m', '', $val)))), 80, "</code>") . "<br>\n";
    }
    echo "<input type='submit' name='clear' value='" . lang('Clear') . "'>\n";
    echo "<a href='" . h(ME . "sql=&history=all") . "'>" . lang('Edit all') . "</a>\n";
    echo "</div></fieldset>\n";
}
?>

</form>
 /** Query printed after execution in the message
  * @param string executed query
  * @return string
  */
 function messageQuery($query)
 {
     global $jush;
     static $count = 0;
     restart_session();
     $id = "sql-" . $count++;
     $history =& get_session("queries");
     if (strlen($query) > 1000000.0) {
         // not DB - reset in drop database
         $query = ereg_replace('[\\x80-\\xFF]+$', '', substr($query, 0, 1000000.0)) . "\n...";
         // [\x80-\xFF] - valid UTF-8, \n - can end by one-line comment
     }
     $history[$_GET["db"]][] = $query;
     // not DB - $_GET["db"] is changed in database.inc.php //! respect $_GET["ns"]
     return " <a href='#{$id}' onclick=\"return !toggle('{$id}');\">" . lang('SQL command') . "</a><div id='{$id}' class='hidden'><pre><code class='jush-{$jush}'>" . shorten_utf8($query, 1000) . '</code></pre><p><a href="' . h(str_replace("db=" . urlencode(DB), "db=" . urlencode($_GET["db"]), ME) . 'sql=&history=' . (count($history[$_GET["db"]]) - 1)) . '">' . lang('Edit') . '</a></div>';
 }