function openBoard($uri) { global $config, $build_pages; if ($config['try_smarter']) { $build_pages = array(); } $board = getBoardInfo($uri); if ($board) { setupBoard($board); if (function_exists('after_open_board')) { after_open_board(); } return true; } return false; }
$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]; $queries[] = Element('posts.sql', array('board' => 'b')); $sql_errors = ''; foreach ($queries as &$query) { if (!query($query)) { $sql_errors .= '<li>' . db_error() . '</li>'; } } $boards = listBoards(); foreach ($boards as &$_board) { setupBoard($_board); buildIndex(); } $page['title'] = 'Installation complete'; $page['body'] = '<p style="text-align:center">Thank you for using Tinyboard. Please remember to report any bugs you discover. <a href="http://tinyboard.org/docs/?p=Config">How do I edit the config files?</a></p>'; if (!empty($sql_errors)) { $page['body'] .= '<div class="ban"><h2>SQL errors</h2><p>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.</p><p>The errors encountered were:</p><ul>' . $sql_errors . '</ul><p><a href="?step=5">Ignore errors and complete installation.</a></p></div>'; } else { file_write($config['has_installed'], VERSION); if (!file_unlink(__FILE__)) { $page['body'] .= '<div class="ban"><h2>Delete install.php!</h2><p>I couldn\'t remove <strong>install.php</strong>. You will have to remove it manually.</p></div>'; } } echo Element('page.html', $page); } elseif ($step == 5) { $page['title'] = 'Installation complete';
function openBoard($uri) { global $config; if ($config['cache']['enabled'] && ($board = cache::get('board_' . $uri))) { setupBoard($board); return true; } $query = prepare("SELECT * FROM `boards` WHERE `uri` = :uri LIMIT 1"); $query->bindValue(':uri', $uri); $query->execute() or error(db_error($query)); if ($board = $query->fetch()) { if ($config['cache']['enabled']) { cache::set('board_' . $uri, $board); } setupBoard($board); return true; } return false; }