/** * Check if an upgrade is needed * */ function yourls_upgrade_is_needed() { // check YOURLS_DB_VERSION exist && match values stored in YOURLS_DB_TABLE_OPTIONS list($currentver, $currentsql) = yourls_get_current_version_from_sql(); if ($currentsql < YOURLS_DB_VERSION) { return true; } return false; }
// Check if upgrade is needed if (!yourls_upgrade_is_needed()) { echo '<p>' . yourls_s('Upgrade not required. Go <a href="%s">back to play</a>!', yourls_admin_url('index.php')) . '</p>'; } else { /* step 1: create new tables and populate them, update old tables structure, step 2: convert each row of outdated tables if needed step 3: - if applicable finish updating outdated tables (indexes etc) - update version & db_version in options, this is all done! */ // From what are we upgrading? if (isset($_GET['oldver']) && isset($_GET['oldsql'])) { $oldver = yourls_sanitize_version($_GET['oldver']); $oldsql = yourls_sanitize_version($_GET['oldsql']); } else { list($oldver, $oldsql) = yourls_get_current_version_from_sql(); } // To what are we upgrading ? $newver = YOURLS_VERSION; $newsql = YOURLS_DB_VERSION; // Verbose & ugly details $ydb->show_errors = true; // Let's go $step = isset($_GET['step']) ? intval($_GET['step']) : 0; switch ($step) { default: case 0: ?> <p><?php yourls_e('Your current installation needs to be upgraded.'); ?>