remove_from_uri()

git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@277 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
jakubvrana 2007-07-27 11:43:44 +00:00
parent ea1bb7dd5b
commit d41d44606e
5 changed files with 11 additions and 4 deletions

View file

@ -10,7 +10,7 @@ if (isset($_POST["server"])) {
$_SESSION["passwords"][$_POST["server"]] = $_POST["password"];
if (count($_POST) == count($ignore)) {
if ((string) $_GET["server"] === $_POST["server"]) {
$location = preg_replace('~(\\?)' . urlencode(session_name()) . '=[^&]*&|[&?]' . urlencode(session_name()) . '=[^&]*~', '\\1', $_SERVER["REQUEST_URI"]);
$location = remove_from_uri();
} else {
$location = preg_replace('~^[^?]*/([^?]*).*~', '\\1', $_SERVER["REQUEST_URI"]) . (strlen($_POST["server"]) ? '?server=' . urlencode($_POST["server"]) : '');
}

View file

@ -9,7 +9,7 @@ if ($_POST && !$error) {
if ($mysql->query("CREATE DATABASE " . idf_escape($_POST["name"]) . ($_POST["collation"] ? " COLLATE '" . $mysql->escape_string($_POST["collation"]) . "'" : ""))) {
unset($_SESSION["databases"][$_GET["server"]]);
if (!strlen($_GET["db"])) {
redirect(preg_replace('~db=[^&]*&~', '', $SELF) . "db=" . urlencode($_POST["name"]), lang('Database has been created.'));
redirect($SELF . "db=" . urlencode($_POST["name"]), lang('Database has been created.'));
}
$result = $mysql->query("SHOW TABLES");
while ($row = $result->fetch_row()) {

View file

@ -193,6 +193,13 @@ function redirect($location, $message = null) {
exit;
}
function remove_from_uri($param = "") {
if (!isset($_COOKIE[session_name()])) {
$param = "($param|" . session_name() . ")";
}
return preg_replace("~\\?$param=[^&]*&~", '?', preg_replace("~\\?$param=[^&]*\$|&$param=[^&]*~", '', $_SERVER["REQUEST_URI"]));
}
function get_file($key) {
if (isset($_POST["files"][$key])) {
$length = strlen($_POST["files"][$key]);

View file

@ -24,7 +24,7 @@ function lang($idf, $number = null) {
function switch_lang() {
global $translations;
echo "<p>" . lang('Language') . ":";
$base = preg_replace('~(\\?)lang=[^&]*&|[&?]lang=[^&]*~', '\\1', $_SERVER["REQUEST_URI"]);
$base = remove_from_uri("lang");
foreach ($translations as $lang => $val) {
echo ' <a href="' . htmlspecialchars($base . (strpos($base, "?") !== false ? "&" : "?")) . "lang=$lang\">$lang</a>";
}

View file

@ -176,7 +176,7 @@ function add_row(field) {
if (intval($limit) && $found_rows > $limit) {
$max_page = floor($found_rows / $limit);
function print_page($page) {
echo " " . ($page == $_GET["page"] ? $page + 1 : '<a href="' . htmlspecialchars(preg_replace('~(\\?)page=[^&]*&|&page=[^&]*~', '\\1', $_SERVER["REQUEST_URI"]) . ($page ? "&page=$page" : "")) . '">' . ($page + 1) . "</a>");
echo " " . ($page == $_GET["page"] ? $page + 1 : '<a href="' . htmlspecialchars(remove_from_uri("page") . ($page ? "&page=$page" : "")) . '">' . ($page + 1) . "</a>");
}
echo "<p>" . lang('Page') . ":";
print_page(0);