$config, 'title' => 'Install', 'body' => '' ); if(file_exists($config['has_installed'])) { sql_open(); // Check the version number $version = trim(file_get_contents($config['has_installed'])); if(empty($version)) $version = 'v0.9.1'; switch($version) { case 'v0.9': case 'v0.9.1': // Upgrade to v0.9.2-dev $boards = listBoards(); foreach($boards as &$_board) { // 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-dev-1 // New table: `theme_settings` query("CREATE TABLE IF NOT EXISTS `theme_settings` ( `name` varchar(40) NOT NULL, `value` text, UNIQUE KEY `name` (`name`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;") or error(db_error()); // New table: `news` query("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;") or error(db_error()); case 'v0.9.2.1-dev': case 'v0.9.2-dev-1': // Fix broken version number/mistake $version = 'v0.9.2-dev-1'; // Upgrade to v0.9.2-dev-2 $boards = listBoards(); foreach($boards as &$_board) { // Increase field sizes query(sprintf("ALTER TABLE `posts_%s` CHANGE `subject` `subject` VARCHAR( 50 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL", $_board['uri'])) or error(db_error()); query(sprintf("ALTER TABLE `posts_%s` CHANGE `name` `name` VARCHAR( 35 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL", $_board['uri'])) or error(db_error()); } case 'v0.9.2-dev-2': // Upgrade to v0.9.2-dev-3 $boards = listBoards(); foreach($boards as &$_board) { // Add `custom_fields` field query(sprintf("ALTER TABLE `posts_%s` ADD `embed` TEXT NULL", $_board['uri'])) or error(db_error()); } // Update version number file_write($config['has_installed'], VERSION); $page['title'] = 'Upgraded'; $page['body'] = '
Successfully upgraded from ' . $version . ' to ' . VERSION . '.
'; break; default: $page['title'] = 'Unknown version'; $page['body'] = 'Tinyboard was unable to determine what version is currently installed.
'; break; case VERSION: $page['title'] = 'Already installed'; $page['body'] = 'It appears that Tinyboard is already installed (' . $version . ') and there is nothing to upgrade! Delete ' . $config['has_installed'] . ' to reinstall.
'; break; } sql_close(); die(Element('page.html', $page)); } if($step == 0) { // Agreeement $page['body'] = 'I have read and understood the agreement. Proceed to installation.
'; echo Element('page.html', $page); } elseif($step == 1) { $page['title'] = 'Pre-installation test'; $page['body'] = '' . $item . ' | |
---|---|
' . $item . ' |
I couldn\'t write to inc/instance-config.php with the new configuration, probably due to a permissions error.
Please complete the installation manually by copying and pasting the following code into the contents of inc/instance-config.php:
Once complete, click here to complete installation.
'; echo Element('page.html', $page); } } elseif($step == 4) { // SQL installation buildJavascript(); sql_open(); $sql = @file_get_contents('install.sql') or error("Couldn't load install.sql."); // This code is probably horrible, but what I'm trying // to do is find all of the SQL queires and put them // in an array. preg_match_all("/(^|\n)((SET|CREATE|INSERT).+)\n\n/msU", $sql, $queries); $queries = $queries[2]; $sql_errors = ''; foreach($queries as &$query) { if(!query($query)) $sql_errors .= 'Thank you for using Tinyboard. Please remember to report any bugs you discover.
'; if(!empty($sql_errors)) { $page['body'] .= '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:
I couldn\'t remove install.php. You will have to remove it manually.
Thank you for using Tinyboard. Please remember to report any bugs you discover.
'; file_write($config['has_installed'], VERSION); if(!file_unlink(__FILE__)) { $page['body'] .= 'I couldn\'t remove install.php. You will have to remove it manually.