From b4c27af79aa9924b31959153622032d3c83ddc82 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 24 Feb 2007 18:16:33 +0100 Subject: [PATCH] misc updater tweaks --- db-prefs.php | 2 +- errors.php | 2 +- functions.js | 9 ++- tt-rss.css | 9 +++ update.php | 209 +++++++++++++++++++++++++++------------------------ 5 files changed, 128 insertions(+), 103 deletions(-) diff --git a/db-prefs.php b/db-prefs.php index 07c4548d3..0858c2ce4 100644 --- a/db-prefs.php +++ b/db-prefs.php @@ -7,7 +7,7 @@ $_SESSION["prefs_cache"] = array(); } - function get_pref($link, $pref_name, $user_id = false, $die_on_error = true) { + function get_pref($link, $pref_name, $user_id = false, $die_on_error = false) { $pref_name = db_escape_string($pref_name); diff --git a/errors.php b/errors.php index 967bb4e33..bab8647d0 100644 --- a/errors.php +++ b/errors.php @@ -11,7 +11,7 @@ $ERRORS[4] = _("Frontend sanity check failed."); - $ERRORS[5] = _("Incorrect database schema version. Please update."); + $ERRORS[5] = _("Incorrect database schema version. <a href='update.php'>Please update</a>."); $ERRORS[6] = _("Request not authorized."); diff --git a/functions.js b/functions.js index 194d83157..de88e4e49 100644 --- a/functions.js +++ b/functions.js @@ -1526,16 +1526,17 @@ function storeInitParams(params, is_client) { function fatalError(code, message) { try { - if (code != 6) { - + if (code == 6) { + window.location.href = "login.php?rt=none"; + } else if (code == 5) { + window.location.href = "update.php"; + } else { var fe = document.getElementById("fatal_error"); var fc = document.getElementById("fatal_error_msg"); fc.innerHTML = "Code " + code + ": " + message; fe.style.display = "block"; - } else { - window.location.href = "login.php?rt=none"; } } catch (e) { diff --git a/tt-rss.css b/tt-rss.css index 2a131247f..37c222810 100644 --- a/tt-rss.css +++ b/tt-rss.css @@ -1061,6 +1061,15 @@ a.cdmToggleLink:hover { font-weight : normal; } +#fatal_error_msg a { + color : red; +} + +#fatal_error_msg a:hover { + color : red; + text-decoration : underline; +} + #noDaemonWarning { position : absolute; background-color : #ecf4ff; diff --git a/update.php b/update.php index 964626d7f..5b91bde32 100644 --- a/update.php +++ b/update.php @@ -1,139 +1,154 @@ - Database Updater - - +Database Updater + + + +

Database Updater

Tiny Tiny RSS database is up to date (version $version).

"; + print "

Return to Tiny Tiny RSS

"; + return; +} + +if (!$op) { + print "

Warning: Please backup your database before proceeding.

"; + + print "

Your Tiny Tiny RSS database needs update to the latest + version ($version —> $latest_version).

"; + +/* print "

Available incremental updates:"; + + foreach (array_keys($update_versions) as $v) { + if ($v > $version) { + print " $v"; } - } + } */ - ksort($update_versions, SORT_NUMERIC); + print "

"; - $latest_version = max(array_keys($update_versions)); + print "
+ + +
"; - if ($version == $latest_version) { - print "Database schema is up to date (version $version)."; - return; - } +} else if ($op == "do") { - if (!$op) { - print "

Warning: Please backup your database before proceeding.

"; + print "

Performing updates (from version $version)...

"; - print "

Your database schema version is $version. Latest version is ". - "$latest_version.

"; + $num_updates = 0; - print "

Available incremental updates:"; - - foreach (array_keys($update_versions) as $v) { - if ($v > $version) { - print " $v"; - } - } - - print "

"; - print "Click here to perform updates."; - - } else if ($op == "do") { - - print "

Performing updates (version: $version)...

"; - - $num_updates = 0; - - foreach (array_keys($update_versions) as $v) { - if ($v == $version + 1) { - print "

Updating to version $v...

"; - $fp = fopen($update_versions[$v], "r"); - if ($fp) { - while (!feof($fp)) { - $query = trim(getline($fp, ";")); - if ($query != "") { - print "

QUERY: $query

"; - db_query($link, $query); - } + foreach (array_keys($update_versions) as $v) { + if ($v == $version + 1) { + print "

Updating to version $v...

"; + $fp = fopen($update_versions[$v], "r"); + if ($fp) { + while (!feof($fp)) { + $query = trim(getline($fp, ";")); + if ($query != "") { + print "

QUERY: $query

"; + db_query($link, $query); } } - fclose($fp); - - print "

Checking version... "; - - $result = db_query($link, "SELECT schema_version FROM ttrss_version"); - $version = db_fetch_result($result, 0, "schema_version"); - - if ($version == $v) { - print "OK!"; - } else { - print "ERROR!"; - return; - } - - $num_updates++; } - } + fclose($fp); - print "

Finished. Performed $num_updates updates up to schema - version $version.

"; + print "

Checking version... "; + + $result = db_query($link, "SELECT schema_version FROM ttrss_version"); + $version = db_fetch_result($result, 0, "schema_version"); + + if ($version == $v) { + print "OK! ($version)"; + } else { + print "ERROR!"; + return; + } + + $num_updates++; + } } + + print "

Finished. Performed $num_updates updates up to schema + version $version.

"; + + print "

Return to Tiny Tiny RSS

"; + +} + ?>