]> git.wh0rd.org - tt-rss.git/blobdiff - update.php
code cleanup, test for db_escape() crazyness in DB sanity check
[tt-rss.git] / update.php
index 4f7a097c02e67c421050887dc28c4ba8fcfacdd2..76e3088567128eb19375742248f1cc347515b354 100644 (file)
@@ -9,23 +9,18 @@
        require_once "db.php";
        
        $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); 
-       
-       if (DB_TYPE == "pgsql") {
-               pg_query($link, "set client_encoding = 'utf-8'");
-               pg_set_client_encoding("UNICODE");
-       }
-       
+
+       init_connection($link); 
        login_sequence($link);
        
        $owner_uid = $_SESSION["uid"];
        
-       if ($_SESSION["access_level"] < 10) { 
-               print "<p>".
-                       __("Error: your access level is insufficient to run this script.")."</p>";
+       if (!SINGLE_USER_MODE && $_SESSION["access_level"] < 10) { 
+               $_SESSION["login_error_msg"] = __("Your access level is insufficient to run this script.");
+               render_login_form($link);
                exit;
        }
-       
-       define('SCHEMA_VERSION', 14);
+
 
 ?>
 
@@ -83,18 +78,28 @@ function confirmOP() {
        ksort($update_versions, SORT_NUMERIC);
        
        $latest_version = max(array_keys($update_versions));
-       
+
        if ($version == $latest_version) {
-               print "<p>".__("Tiny Tiny RSS database is up to date.")."</p>";
-               print "<form method=\"GET\" action=\"tt-rss.php\">
-                       <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
-                       </form>";
+
+               if ($version != SCHEMA_VERSION) {
+                       print_error(__("Could not update database"));
+
+                       print "<p>" . 
+                               __("Could not find necessary schema file, need version:") .
+                               " " . SCHEMA_VERSION . __(", found: ") . $latest_version . "</p>";
+
+               } else {
+                       print "<p>".__("Tiny Tiny RSS database is up to date.")."</p>";
+                       print "<form method=\"GET\" action=\"tt-rss.php\">
+                               <input type=\"submit\" value=\"".__("Return to Tiny Tiny RSS")."\">
+                               </form>";
+               }
 
                return;
        }
        
        if (!$op) {
-               print "<p class='warning'>".__("<b>Warning:</b> Please backup your database before proceeding.")."</p>";
+               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>";