lainchan/tools/rebuild.php
2012-03-15 01:44:29 +11:00

60 lines
1.3 KiB
PHP
Executable File

#!/usr/bin/php
<?php
require dirname(__FILE__) . '/inc/cli.php';
$mod = Array(
'id' => -1,
'type' => ADMIN,
'username' => '?',
'boards' => Array('*')
);
$start = microtime(true);
echo "== Tinyboard {$config['version']} ==\n";
if(!is_writable($config['file_script'])) {
get_httpd_privileges();
}
echo "Clearing template cache...\n";
$twig = new Twig_Environment($loader, Array(
'cache' => "{$config['dir']['template']}/cache"
));
$twig->clearCacheFiles();
echo "Regenerating theme files...\n";
rebuildThemes('all');
echo "Generating Javascript file...\n";
buildJavascript();
$main_js = $config['file_script'];
$boards = listBoards();
foreach($boards as &$board) {
echo "Opening board /{$board['uri']}/...\n";
openBoard($board['uri']);
echo "Creating index pages...\n";
buildIndex();
if($config['file_script'] != $main_js) {
// different javascript file
echo "Generating Javascript file...\n";
buildJavascript();
}
$query = query(sprintf("SELECT `id` FROM `posts_%s` WHERE `thread` IS NULL", $board['uri'])) or error(db_error());
while($post = $query->fetch()) {
echo "Rebuilding #{$post['id']}...\n";
buildThread($post['id']);
}
}
printf("Complete! Took %g seconds\n", microtime(true) - $start);
modLog('Rebuilt everything using tools/rebuild.php');