From 81596c6612ed98ea2d648300e28bbe1661d97165 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 1 Mar 2007 09:54:55 +0100 Subject: [PATCH] fix indent --- update.php | 243 ++++++++++++++++++++++++++--------------------------- 1 file changed, 121 insertions(+), 122 deletions(-) diff --git a/update.php b/update.php index 5b91bde3..1e6a44b4 100644 --- a/update.php +++ b/update.php @@ -1,27 +1,27 @@ @@ -43,115 +43,114 @@ function confirmOP() {

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"; + + $op = $_POST["op"]; + + $result = db_query($link, "SELECT schema_version FROM ttrss_version"); + $version = db_fetch_result($result, 0, "schema_version"); + + $update_files = glob("schema/versions/".DB_TYPE."/*sql"); + $update_versions = array(); + + foreach ($update_files as $f) { + $m = array(); + preg_match_all("/schema\/versions\/".DB_TYPE."\/(\d*)\.sql/", $f, $m, + PREG_PATTERN_ORDER); + + if ($m[1][0]) { + $update_versions[$m[1][0]] = $f; } - } */ - - print "

"; - - print "
- - -
"; - -} else if ($op == "do") { - - print "

Performing updates (from 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); + } + + ksort($update_versions, SORT_NUMERIC); + + $latest_version = max(array_keys($update_versions)); + + if ($version == $latest_version) { + print "

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"; + } + } */ + + print "

"; + + print "
+ + +
"; + + } else if ($op == "do") { + + print "

Performing updates (from 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); + } } } + 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! ($version)"; + } else { + print "ERROR!"; + return; + } + + $num_updates++; } - 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! ($version)"; - } else { - print "ERROR!"; - return; - } - - $num_updates++; } + + print "

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

"; + + print "

Return to Tiny Tiny RSS

"; + } - - print "

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

"; - - print "

Return to Tiny Tiny RSS

"; - -} - + ?> - -- 2.39.2