global $LANG, $langs;
    echo "<form action='' method='post'>\n<div id='lang'>";
    echo lang('Language') . ": " . html_select("lang", $langs, $LANG, "this.form.submit();");
    echo " <input type='submit' value='" . lang('Use') . "' class='hidden'>\n";
    echo "<input type='hidden' name='token' value='" . get_token() . "'>\n";
    // $token may be empty in auth.inc.php
    echo "</div>\n</form>\n";
}
if (isset($_POST["lang"]) && verify_token()) {
    // $error not yet available
    cookie("adminer_lang", $_POST["lang"]);
    $_SESSION["lang"] = $_POST["lang"];
    // cookies may be disabled
    $_SESSION["translations"] = array();
    // used in compiled version
    adminer_redirect(remove_from_uri());
}
$LANG = "en";
if (isset($langs[$_COOKIE["adminer_lang"]])) {
    cookie("adminer_lang", $_COOKIE["adminer_lang"]);
    $LANG = $_COOKIE["adminer_lang"];
} elseif (isset($langs[$_SESSION["lang"]])) {
    $LANG = $_SESSION["lang"];
} else {
    $accept_language = array();
    preg_match_all('~([-a-z]+)(;q=([0-9.]+))?~', str_replace("_", "-", strtolower($_SERVER["HTTP_ACCEPT_LANGUAGE"])), $matches, PREG_SET_ORDER);
    foreach ($matches as $match) {
        $accept_language[$match[1]] = isset($match[3]) ? $match[3] : 1;
    }
    arsort($accept_language);
    foreach ($accept_language as $key => $q) {
Beispiel #2
0
<?php

if (!$error && $_POST["export"]) {
    dump_headers("sql");
    $adminer->dumpTable("", "");
    $adminer->dumpData("", "table", $_POST["query"]);
    exit;
}
restart_session();
$history_all =& get_session("queries");
$history =& $history_all[DB];
if (!$error && $_POST["clear"]) {
    $history = array();
    adminer_redirect(remove_from_uri("history"));
}
page_header(isset($_GET["import"]) ? lang('Import') : lang('SQL command'), $error);
if (!$error && $_POST) {
    $fp = false;
    if (!isset($_GET["import"])) {
        $query = $_POST["query"];
    } elseif ($_POST["webfile"]) {
        $fp = @fopen(file_exists("adminer.sql") ? "adminer.sql" : "compress.zlib://adminer.sql.gz", "rb");
        $query = $fp ? fread($fp, 1000000.0) : false;
    } else {
        $query = get_file("sql_file", true);
    }
    if (is_string($query)) {
        // get_file() returns error as number, fread() as false
        if (function_exists('memory_get_usage')) {
            @ini_set("memory_limit", max(ini_bytes("memory_limit"), 2 * strlen($query) + memory_get_usage() + 8000000.0));
            // @ - may be disabled, 2 - substr and trim, 8e6 - other variables
Beispiel #3
0
                    $exact_count = false;
                }
            }
            echo "<p class='pages'>";
            if (+$limit && ($found_rows === false || $found_rows > $limit)) {
                // display first, previous 4, next 4 and last page
                $max_page = $found_rows === false ? $page + (count($rows) >= $limit ? 2 : 1) : floor(($found_rows - 1) / $limit);
                echo '<a href="' . h(remove_from_uri("page")) . "\" onclick=\"pageClick(this.href, +prompt('" . lang('Page') . "', '" . ($page + 1) . "'), event); return false;\">" . lang('Page') . "</a>:";
                echo pagination(0, $page) . ($page > 5 ? " ..." : "");
                for ($i = max(1, $page - 4); $i < min($max_page, $page + 5); $i++) {
                    echo pagination($i, $page);
                }
                echo ($page + 5 < $max_page ? " ..." : "") . ($exact_count && $found_rows !== false ? pagination($max_page, $page) : ' <a href="' . h(remove_from_uri("page") . "&page=last") . '">' . lang('last') . "</a>");
            }
            echo $found_rows !== false ? " (" . ($exact_count ? "" : "~ ") . lang('%d row(s)', $found_rows) . ")" : "";
            echo +$limit && ($found_rows === false ? count($rows) + 1 : $found_rows - $page * $limit) > $limit ? ' <a href="' . h(remove_from_uri("page") . "&page=" . ($page + 1)) . '" onclick="return !selectLoadMore(this, ' . +$limit . ', \'' . lang('Loading') . '\');">' . lang('Load more data') . '</a>' : '';
            echo " " . checkbox("all", 1, 0, lang('whole result')) . "\n";
            if ($adminer->selectCommandPrint()) {
                ?>
<fieldset><legend><?php 
                echo lang('Edit');
                ?>
</legend><div>
<input type="submit" value="<?php 
                echo lang('Save');
                ?>
"<?php 
                echo $_GET["modify"] ? '' : ' title="' . lang('Double click on a value to modify it.') . '" class="jsonly"';
                ?>
>
<input type="submit" name="edit" value="<?php 
Beispiel #4
0
    global $LANG, $langs;
    echo "<form action='' method='post'>\n<div id='lang'>";
    echo lang('Language') . ": " . html_select("lang", $langs, $LANG, "this.form.submit();");
    echo " <input type='submit' value='" . lang('Use') . "' class='hidden'>\n";
    echo "<input type='hidden' name='token' value='" . get_token() . "'>\n";
    // $token may be empty in auth.inc.php
    echo "</div>\n</form>\n";
}
if (isset($_POST["lang"]) && verify_token()) {
    // $error not yet available
    cookie("adminer_lang", $_POST["lang"]);
    $_SESSION["lang"] = $_POST["lang"];
    // cookies may be disabled
    $_SESSION["translations"] = array();
    // used in compiled version
    redirect(remove_from_uri());
}
$LANG = "en";
if (isset($langs[$_COOKIE["adminer_lang"]])) {
    cookie("adminer_lang", $_COOKIE["adminer_lang"]);
    $LANG = $_COOKIE["adminer_lang"];
} elseif (isset($langs[$_SESSION["lang"]])) {
    $LANG = $_SESSION["lang"];
} else {
    $accept_language = array();
    preg_match_all('~([-a-z]+)(;q=([0-9.]+))?~', str_replace("_", "-", strtolower($_SERVER["HTTP_ACCEPT_LANGUAGE"])), $matches, PREG_SET_ORDER);
    foreach ($matches as $match) {
        $accept_language[$match[1]] = isset($match[3]) ? $match[3] : 1;
    }
    arsort($accept_language);
    foreach ($accept_language as $key => $q) {
Beispiel #5
0
/** Generate page number for pagination
* @param int
* @param int
* @return string
*/
function pagination($page, $current)
{
    return " " . ($page == $current ? $page + 1 : '<a href="' . h(remove_from_uri("page") . ($page ? "&page={$page}" . ($_GET["next"] ? "&next=" . urlencode($_GET["next"]) : "") : "")) . '">' . ($page + 1) . "</a>");
}
Beispiel #6
0
<?php

$row = $_POST;
if ($_POST && !$error && !isset($_POST["add_x"])) {
    // add is an image and PHP changes add.x to add_x
    restart_session();
    $name = trim($row["name"]);
    if ($_POST["drop"]) {
        $_GET["db"] = "";
        // to save in global history
        queries_adminer_redirect(remove_from_uri("db|database"), lang('Database has been dropped.'), drop_databases(array(DB)));
    } elseif (DB !== $name) {
        // create or rename database
        if (DB != "") {
            $_GET["db"] = $name;
            queries_adminer_redirect(preg_replace('~\\bdb=[^&]*&~', '', ME) . "db=" . urlencode($name), lang('Database has been renamed.'), rename_database($name, $row["collation"]));
        } else {
            $databases = explode("\n", str_replace("\r", "", $name));
            $success = true;
            $last = "";
            foreach ($databases as $db) {
                if (count($databases) == 1 || $db != "") {
                    // ignore empty lines but always try to create single database
                    if (!create_database($db, $row["collation"])) {
                        $success = false;
                    }
                    $last = $db;
                }
            }
            queries_adminer_redirect(ME . "db=" . urlencode($last), lang('Database has been created.'), $success);
        }
Beispiel #7
0
 function print_page($page)
 {
     echo " " . ($page == $_GET["page"] ? $page + 1 : '<a href="' . htmlspecialchars(remove_from_uri("page") . ($page ? "&page={$page}" : "")) . '">' . ($page + 1) . "</a>");
 }
                    flush();
                    $found_rows = $connection->result("SELECT COUNT(*) FROM " . table($TABLE) . ($where ? " WHERE " . implode(" AND ", $where) : ""));
                } else {
                    $exact_count = false;
                }
            }
            echo "<p class='pages'>";
            if (+$limit && $found_rows > $limit) {
                // display first, previous 4, next 4 and last page
                $max_page = floor(($found_rows - 1) / $limit);
                echo '<a href="' . h(remove_from_uri("page")) . "\" onclick=\"pageClick(this.href, +prompt('" . lang('Page') . "', '" . ($page + 1) . "'), event); return false;\">" . lang('Page') . "</a>:";
                echo pagination(0, $page) . ($page > 5 ? " ..." : "");
                for ($i = max(1, $page - 4); $i < min($max_page, $page + 5); $i++) {
                    echo pagination($i, $page);
                }
                echo ($page + 5 < $max_page ? " ..." : "") . ($exact_count ? pagination($max_page, $page) : ' <a href="' . h(remove_from_uri() . "&page=last") . '">' . lang('last') . "</a>");
            }
            echo " (" . ($exact_count ? "" : "~ ") . lang('%d row(s)', $found_rows) . ") " . checkbox("all", 1, 0, lang('whole result')) . "\n";
            if ($adminer->selectCommandPrint()) {
                ?>
<fieldset><legend><?php 
                echo lang('Edit');
                ?>
</legend><div>
<input type="submit" value="<?php 
                echo lang('Save');
                ?>
"<?php 
                echo $_GET["modify"] ? '' : ' title="' . lang('Double click on a value to modify it.') . '" class="jsonly"';
                ?>
>
 /** Query printed in select before execution
  * @param string query to be executed
  * @return string
  */
 function selectQuery($query)
 {
     global $jush;
     return "<p><a href='" . h(remove_from_uri("page")) . "&amp;page=last' title='" . lang('Last page') . "'>&gt;&gt;</a> <code class='jush-{$jush}'>" . h(str_replace("\n", " ", $query)) . "</code> <a href='" . h(ME) . "sql=" . urlencode($query) . "'>" . lang('Edit') . "</a></p>\n";
     // </p> - required for IE9 inline edit
 }
/** Generate page number for pagination
* @param int
* @return string
*/
function pagination($page, $current)
{
    return " " . ($page == $current ? $page + 1 : '<a href="' . h(remove_from_uri("page") . ($page ? "&page={$page}" : "")) . '">' . ($page + 1) . "</a>");
}