lainchan/tools/rebuild.php

60 lines
1.3 KiB
PHP
Raw Normal View History

#!/usr/bin/php
<?php
2012-03-14 01:45:59 -04:00
require dirname(__FILE__) . '/inc/cli.php';
$mod = Array(
'id' => -1,
'type' => ADMIN,
'username' => '?',
'boards' => Array('*')
);
2012-03-14 00:55:12 -04:00
$start = microtime(true);
2012-03-14 00:55:12 -04:00
echo "== Tinyboard {$config['version']} ==\n";
if(!is_writable($config['file_script'])) {
get_httpd_privileges();
}
2012-03-14 00:55:12 -04:00
echo "Clearing template cache...\n";
$twig = new Twig_Environment($loader, Array(
'cache' => "{$config['dir']['template']}/cache"
));
$twig->clearCacheFiles();
2012-03-14 00:55:12 -04:00
echo "Regenerating theme files...\n";
rebuildThemes('all');
2012-03-14 00:55:12 -04:00
echo "Generating Javascript file...\n";
buildJavascript();
2012-03-14 00:55:12 -04:00
2012-03-14 06:55:22 -04:00
$main_js = $config['file_script'];
$boards = listBoards();
2012-03-14 00:55:12 -04:00
foreach($boards as &$board) {
echo "Opening board /{$board['uri']}/...\n";
openBoard($board['uri']);
2012-03-14 00:55:12 -04:00
echo "Creating index pages...\n";
buildIndex();
2012-03-14 00:55:12 -04:00
2012-03-14 06:55:22 -04:00
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']);
}
}
2012-03-14 00:55:12 -04:00
printf("Complete! Took %g seconds\n", microtime(true) - $start);
2012-03-14 01:45:59 -04:00
modLog('Rebuilt everything using tools/rebuild.php');