= $targetVersion) die('Up to date :-)'); while ($currentVersion < $targetVersion) { $function = 'update_' . $currentVersion; if (!function_exists($function)) fatal("Don't know how to update from version $currentVersion to $targetVersion :-("); if (!$function()) fatal("Update from $currentVersion to $targetVersion failed! :-("); $currentVersion++; $ret = Database::exec("INSERT INTO property (name, value) VALUES ('webif-version', :version) ON DUPLICATE KEY UPDATE value = VALUES(value)", array('version' => $currentVersion), false); if ($ret === false) fatal('Writing version information back to DB failed. Next update will probably break.'); if ($currentVersion < $targetVersion) { echo("Updated to $currentVersion...\n"); } } // TEMPORARY HACK; Rebuild AD configs.. move somewhere else $list = ConfigModule::getAll('AdAuth'); if ($list === false) { Message::addError('ad-config-failed'); } else { foreach ($list as $ad) { $ad->generate(false); } } Message::addSuccess('db-update-done'); if (tableExists('eventlog')) EventLog::info("Database updated to version $currentVersion"); Util::redirect('index.php?do=Main');