Minimize the chance of displaying message on different page (thanks to Tomas Brukner)

This commit is contained in:
Jakub Vrana 2011-01-30 20:37:22 +01:00
parent ceef6bc6d3
commit 79fa7dab3b
4 changed files with 9 additions and 6 deletions

View file

@ -404,8 +404,9 @@ username.form['driver'].onchange();
*/
function messageQuery($query) {
global $jush;
static $count = 0;
restart_session();
$id = "sql-" . count($_SESSION["messages"]);
$id = "sql-" . ($count++);
$history = &get_session("queries");
$history[$_GET["db"]][] = (strlen($query) > 1e6 // not DB - reset in drop database
? ereg_replace('[\x80-\xFF]+$', '', substr($query, 0, 1e6)) . "\n..." // [\x80-\xFF] - valid UTF-8, \n - can end by one-line comment

View file

@ -64,9 +64,11 @@ function page_header($title, $error = "", $breadcrumb = array(), $title2 = "") {
}
echo "<h2>$title_all</h2>\n";
restart_session();
if ($_SESSION["messages"]) {
echo "<div class='message'>" . implode("</div>\n<div class='message'>", $_SESSION["messages"]) . "</div>\n";
$_SESSION["messages"] = array();
$uri = preg_replace('~^[^?]*/~', '', $_SERVER["REQUEST_URI"]);
$messages = $_SESSION["messages"][$uri];
if ($messages) {
echo "<div class='message'>" . implode("</div>\n<div class='message'>", $messages) . "</div>\n";
unset($_SESSION["messages"][$uri]);
}
$databases = &get_session("dbs");
if (DB != "" && $databases && !in_array(DB, $databases, true)) {

View file

@ -349,7 +349,7 @@ function drop_create($drop, $create, $location, $message_drop, $message_alter, $
$created = queries($create);
if (!queries_redirect($location, ($name != "" ? $message_alter : $message_create), $created) && $dropped) {
restart_session();
$_SESSION["messages"][] = $message_drop;
$_SESSION["messages"][preg_replace('~^[^?]*/~', '', $_SERVER["REQUEST_URI"])][] = $message_drop;
}
return $dropped;
}

View file

@ -384,7 +384,7 @@ function is_ajax() {
function redirect($location, $message = null) {
if (isset($message)) {
restart_session();
$_SESSION["messages"][] = $message;
$_SESSION["messages"][preg_replace('~^[^?]*/~', '', $location)][] = $message;
}
if (isset($location)) {
if ($location == "") {