]> git.wh0rd.org - tt-rss.git/blobdiff - db-updater.php
api, also hide uncategorized if empty
[tt-rss.git] / db-updater.php
index 8590ee82a01a70874dcfc3f3a8fa1e66fd885586..2726110639aad6af7fd29864037a894bf12d7078 100644 (file)
@@ -1,4 +1,7 @@
 <?php
+       set_include_path(dirname(__FILE__) ."/include" . PATH_SEPARATOR .
+               get_include_path());
+
        require_once "functions.php";
        require_once "sessions.php";
        require_once "sanity_check.php";
@@ -7,7 +10,7 @@
 
        $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
 
-       init_connection($link);
+       if (!init_connection($link)) return;
        login_sequence($link);
 
        $owner_uid = $_SESSION["uid"];
@@ -36,10 +39,12 @@ function confirmOP() {
 }
 </script>
 
-<div class="floatingLogo"><img src="images/logo.png"></div>
+<div class="floatingLogo"><img src="images/logo_small.png"></div>
 
 <h1><?php echo __("Database Updater") ?></h1>
 
+<div class="content">
+
 <?php
        function getline($fp, $delim) {
                $result = "";
@@ -87,15 +92,13 @@ function confirmOP() {
 
                } else {
                        print_notice(__("Tiny Tiny RSS database is up to date."));
-                       print "<form method=\"GET\" action=\"tt-rss.php\">
+                       print "<form method=\"GET\" action=\"index.php\">
                                <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
                                </form>";
                }
 
-               return;
-       }
+       } else if ($version <= $latest_version && !$op) {
 
-       if (!$op) {
                print_warning(__("Please backup your database before proceeding."));
 
                print "<p>" . T_sprintf("Your Tiny Tiny RSS database needs update to the latest version (<b>%d</b> to <b>%d</b>).", $version, $latest_version) . "</p>";
@@ -124,6 +127,7 @@ function confirmOP() {
                foreach (array_keys($update_versions) as $v) {
                        if ($v == $version + 1) {
                                print "<p>".T_sprintf("Updating to version %d...", $v)."</p>";
+                               db_query($link, "BEGIN");
                                $fp = fopen($update_versions[$v], "r");
                                if ($fp) {
                                        while (!feof($fp)) {
@@ -135,6 +139,7 @@ function confirmOP() {
                                        }
                                }
                                fclose($fp);
+                               db_query($link, "COMMIT");
 
                                print "<p>".__("Checking version... ");
 
@@ -152,18 +157,34 @@ function confirmOP() {
                        }
                }
 
-               print "<p>".T_sprintf("Finished. Performed <b>%d</b> update(s) up to schema
-                       version <b>%d</b>.", $num_updates, $version)."</p>";
+               print "<p>".sprintf(ngettext("Finished. Performed <b>%d</b> update up to schema version <b>%d</b>.",
+                       "Finished. Performed <b>%d</b> updates up to schema version <b>%d</b>.", $num_updates), $num_updates, $version)."</p>";
+
+               print "<form method=\"GET\" action=\"backend.php\">
+                       <input type=\"hidden\" name=\"op\" value=\"logout\">
+                       <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
+                       </form>";
+
+       } else if ($version >= $latest_version) {
+
+               print_error(__("Your database schema is from a newer version of Tiny Tiny RSS."));
+
+               print "<p>" . T_sprintf("Found schema version: <b>%d</b>, required: <b>%d</b>.", $version, $latest_version) . "</p>";
+
+               print "<p>" . __("Schema upgrade impossible. Please update Tiny Tiny RSS files to the newer version and continue.") . "</p>";
 
                print "<form method=\"GET\" action=\"backend.php\">
                        <input type=\"hidden\" name=\"op\" value=\"logout\">
                        <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
                        </form>";
 
+
        }
 
 ?>
 
+</div>
+
 </body>
 </html>