Permalink
Browse files

remove_from_uri()

git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@277 7c3ca157-0c34-0410-bff1-cbf682f78f5c
  • Loading branch information...
1 parent ea1bb7d commit d41d44606eae25d1bdef9e245bab3aa86a52c231 jakubvrana committed Jul 27, 2007
Showing with 11 additions and 4 deletions.
  1. +1 −1 auth.inc.php
  2. +1 −1 database.inc.php
  3. +7 −0 functions.inc.php
  4. +1 −1 lang.inc.php
  5. +1 −1 select.inc.php
View
2 auth.inc.php
@@ -10,7 +10,7 @@
$_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
2 database.inc.php
@@ -9,7 +9,7 @@
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
7 functions.inc.php
@@ -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
2 lang.inc.php
@@ -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
2 select.inc.php
@@ -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);

0 comments on commit d41d446

Please sign in to comment.