From f7ed681eac34d6015425ad26cb7de383969d6cae Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Wed, 20 Apr 2011 02:37:44 +1000 Subject: [PATCH] updated install file for v0.9.2.1-dev --- install.php | 66 +++++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 38 insertions(+), 28 deletions(-) diff --git a/install.php b/install.php index d5098499..93b98af7 100644 --- a/install.php +++ b/install.php @@ -2,7 +2,7 @@ // Installation/upgrade file // Current version: 0.9.2 (or 0.9.1-dev) - define('VERSION', 'v0.9.2-dev'); + define('VERSION', 'v0.9.2.1-dev'); require 'inc/functions.php'; require 'inc/display.php'; @@ -18,38 +18,48 @@ if(file_exists($config['has_installed'])) { + sql_open(); + // Check the version number $version = file_get_contents($config['has_installed']); - if(empty($version)) { - // v0.9 or v0.9.1 - // Upgrading to v0.9.2 - - sql_open(); - - $boards = listBoards(); - foreach($boards as &$_board) { - openBoard($_board['uri']); + switch($version) { + case '': + case 'v0.9': + case 'v0.9.1': + // Upgrading to v0.9.2-dev - // Add `capcode` field after `trip` - query(sprintf("ALTER TABLE `posts_%s` ADD `capcode` VARCHAR( 50 ) NULL AFTER `trip`", $board['uri'])) or error(db_error()); + $boards = listBoards(); + foreach($boards as &$_board) { + openBoard($_board['uri']); + + // Add `capcode` field after `trip` + query(sprintf("ALTER TABLE `posts_%s` ADD `capcode` VARCHAR( 50 ) NULL AFTER `trip`", $board['uri'])) or error(db_error()); + + // Resize `trip` to 15 characters + query(sprintf("ALTER TABLE `posts_%s` CHANGE `trip` `trip` VARCHAR( 15 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL", $board['uri'])) or error(db_error()); + } + case 'v0.9.2-dev': + // Upgrade to v0.9.2.1-dev - // Resize `trip` to 15 characters - query(sprintf("ALTER TABLE `posts_%s` CHANGE `trip` `trip` VARCHAR( 15 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL", $board['uri'])) or error(db_error()); - } - - file_put_contents($config['has_installed'], VERSION); - - $page['title'] = 'Upgraded'; - $page['body'] = '

Successfully upgraded from v0.9 (or v0.9.1) to ' . VERSION . '.

'; - } elseif($version == VERSION) { - $page['title'] = 'Already installed'; - $page['body'] = '

It appears that Tinyboard is already installed! Delete ' . $config['has_installed'] . ' to reinstall.

'; - } else { - $page['title'] = 'Unknown version'; - $page['body'] = '

Tinyboard was unable to determine what version is currently installed.

'; + // New table: `theme_settings` + query(sprintf("CREATE TABLE IF NOT EXISTS `theme_settings` ( `name` varchar(40) NOT NULL, `value` text, UNIQUE KEY `name` (`name`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;", $board['uri'])) or error(db_error()); + + // New table: `news` + query(sprintf("CREATE TABLE IF NOT EXISTS `news` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` text NOT NULL, `time` int(11) NOT NULL, `subject` text NOT NULL, `body` text NOT NULL, UNIQUE KEY `id` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;", $board['uri'])) or error(db_error()); + + $page['title'] = 'Upgraded'; + $page['body'] = '

Successfully upgraded from v0.9 (or v0.9.1) to ' . VERSION . '.

'; + break; + default: + $page['title'] = 'Unknown version'; + $page['body'] = '

Tinyboard was unable to determine what version is currently installed.

'; + case VERSION: + $page['title'] = 'Already installed'; + $page['body'] = '

It appears that Tinyboard is already installed! Delete ' . $config['has_installed'] . ' to reinstall.

'; + break; } - - + file_put_contents($config['has_installed'], VERSION); + die(Element('page.html', $page)); }