From c596d457112bb3288c0d650884022f72a9d7f35c Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Tue, 12 Apr 2011 21:08:54 +1000 Subject: New `capcode` field for posts and custom capcodes (run install.php to upgrade tables) --- install.php | 46 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 5 deletions(-) (limited to 'install.php') diff --git a/install.php b/install.php index fc25999d..d5098499 100644 --- a/install.php +++ b/install.php @@ -1,4 +1,9 @@ -It appears that Tinyboard is already installed! Delete ' . $config['has_installed'] . ' to reinstall.

'; + // 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']); + + // 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()); + } + + 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.

'; + } + + + die(Element('page.html', $page)); } @@ -332,7 +368,7 @@ if(!empty($sql_errors)) { $page['body'] .= '

SQL errors

SQL errors were encountered when trying to install the database. This may be the result of using a database which is already occupied with a Tinyboard installation; if so, you can probably ignore this.

The errors encountered were:

Ignore errors and complete installation.

'; } else { - touch($config['has_installed'], 0777); + file_put_contents($config['has_installed'], VERSION); if(!@unlink(__FILE__)) { $page['body'] .= '

Delete install.php!

I couldn\'t remove install.php. You will have to remove it manually.

'; } @@ -343,7 +379,7 @@ $page['title'] = 'Installation complete'; $page['body'] = '

Thank you for using Tinyboard. Please remember to report any bugs you discover.

'; - touch($config['has_installed'], 0777); + file_put_contents($config['has_installed'], VERSION); if(!@unlink(__FILE__)) { $page['body'] .= '

Delete install.php!

I couldn\'t remove install.php. You will have to remove it manually.

'; } -- cgit v1.3