function doboard($board) { global $global_locale, $config, $main_js, $options; $config['mask_db_error'] = false; if (!$options['api']) { $config['api']['enabled'] = false; } echo "Opening board /{$board['uri']}/...\n"; // Reset locale to global locale $config['locale'] = $global_locale; init_locale($config['locale'], 'error'); openBoard($board['uri']); $config['try_smarter'] = false; if ($config['file_script'] != $main_js && $options['js']) { // different javascript file echo "(/{$board['uri']}/) Generating Javascript file...\n"; buildJavascript(); } if ($options['indexes']) { echo "(/{$board['uri']}/) Creating index pages...\n"; buildIndex(); } if ($options['postmarkup']) { $query = query(sprintf("SELECT `id` FROM ``posts_%s``", $board['uri'])) or error(db_error()); while ($post = $query->fetch()) { echo "(/{$board['uri']}/) Rebuilding #{$post['id']}...\n"; rebuildPost($post['id']); } } if ($options['threads']) { $query = query(sprintf("SELECT `id` FROM ``posts_%s`` WHERE `thread` IS NULL", $board['uri'])) or error(db_error()); while ($post = $query->fetch()) { echo "(/{$board['uri']}/) Rebuilding #{$post['id']}...\n"; @buildThread($post['id']); } } }
header('Location: ?step=4', true, $config['redirect_http']); } else { $page['title'] = 'Manual installation required'; $page['body'] = ' <p>I couldn\'t write to <strong>inc/instance-config.php</strong> with the new configuration, probably due to a permissions error.</p> <p>Please complete the installation manually by copying and pasting the following code into the contents of <strong>inc/instance-config.php</strong>:</p> <textarea style="width:700px;height:370px;margin:auto;display:block;background:white;color:black">' . htmlentities($instance_config) . '</textarea> <p style="text-align:center"> <a href="?step=4">Once complete, click here to complete installation.</a> </p> '; echo Element('page.html', $page); } } elseif ($step == 4) { // SQL installation buildJavascript(); $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) {
function mod_rebuild() { global $config, $twig; if (!hasPermission($config['mod']['rebuild'])) { error($config['error']['noaccess']); } if (isset($_POST['rebuild'])) { @set_time_limit($config['mod']['rebuild_timelimit']); $log = array(); $boards = listBoards(); $rebuilt_scripts = array(); if (isset($_POST['rebuild_cache'])) { if ($config['cache']['enabled']) { $log[] = 'Flushing cache'; Cache::flush(); } $log[] = 'Clearing template cache'; load_twig(); $twig->clearCacheFiles(); } if (isset($_POST['rebuild_themes'])) { $log[] = 'Regenerating theme files'; rebuildThemes('all'); } if (isset($_POST['rebuild_javascript'])) { $log[] = 'Rebuilding <strong>' . $config['file_script'] . '</strong>'; buildJavascript(); $rebuilt_scripts[] = $config['file_script']; } foreach ($boards as $board) { if (!(isset($_POST['boards_all']) || isset($_POST['board_' . $board['uri']]))) { continue; } openBoard($board['uri']); $config['try_smarter'] = false; if (isset($_POST['rebuild_index'])) { buildIndex(); $log[] = '<strong>' . sprintf($config['board_abbreviation'], $board['uri']) . '</strong>: Creating index pages'; } if (isset($_POST['rebuild_javascript']) && !in_array($config['file_script'], $rebuilt_scripts)) { $log[] = '<strong>' . sprintf($config['board_abbreviation'], $board['uri']) . '</strong>: Rebuilding <strong>' . $config['file_script'] . '</strong>'; buildJavascript(); $rebuilt_scripts[] = $config['file_script']; } if (isset($_POST['rebuild_thread'])) { $query = query(sprintf("SELECT `id` FROM ``posts_%s`` WHERE `thread` IS NULL", $board['uri'])) or error(db_error()); while ($post = $query->fetch(PDO::FETCH_ASSOC)) { $log[] = '<strong>' . sprintf($config['board_abbreviation'], $board['uri']) . '</strong>: Rebuilding thread #' . $post['id']; buildThread($post['id']); } } } mod_page(_('Rebuild'), 'mod/rebuilt.html', array('logs' => $log)); return; } mod_page(_('Rebuild'), 'mod/rebuild.html', array('boards' => listBoards(), 'token' => make_secure_link_token('rebuild'))); }