diff --git a/auth.inc.php b/auth.inc.php index 461280df..484ecbf5 100644 --- a/auth.inc.php +++ b/auth.inc.php @@ -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"]) : ''); } diff --git a/database.inc.php b/database.inc.php index 68546964..b7243fef 100644 --- a/database.inc.php +++ b/database.inc.php @@ -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()) { diff --git a/functions.inc.php b/functions.inc.php index 86a36c0e..8485d057 100644 --- a/functions.inc.php +++ b/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]); diff --git a/lang.inc.php b/lang.inc.php index b9114703..73898ac4 100644 --- a/lang.inc.php +++ b/lang.inc.php @@ -24,7 +24,7 @@ function lang($idf, $number = null) { function switch_lang() { global $translations; echo "
" . lang('Language') . ":"; - $base = preg_replace('~(\\?)lang=[^&]*&|[&?]lang=[^&]*~', '\\1', $_SERVER["REQUEST_URI"]); + $base = remove_from_uri("lang"); foreach ($translations as $lang => $val) { echo ' $lang"; } diff --git a/select.inc.php b/select.inc.php index 1d76a7d3..7e71cf08 100644 --- a/select.inc.php +++ b/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 : '' . ($page + 1) . ""); + echo " " . ($page == $_GET["page"] ? $page + 1 : '' . ($page + 1) . ""); } echo "
" . lang('Page') . ":"; print_page(0);