2012-03-02 16:41:04 -05:00
|
|
|
#!/usr/bin/php
|
|
|
|
<?php
|
|
|
|
require 'inc/functions.php';
|
|
|
|
require 'inc/display.php';
|
|
|
|
require 'inc/template.php';
|
|
|
|
require 'inc/database.php';
|
|
|
|
require 'inc/user.php';
|
|
|
|
require 'inc/mod.php';
|
2012-03-14 00:55:12 -04:00
|
|
|
|
2012-03-02 16:41:04 -05:00
|
|
|
set_time_limit($config['mod']['rebuild_timelimit']);
|
2012-03-14 00:55:12 -04:00
|
|
|
|
2012-03-02 16:41:04 -05:00
|
|
|
$start = microtime(true);
|
2012-03-14 00:55:12 -04:00
|
|
|
|
|
|
|
echo "== Tinyboard {$config['version']} ==\n";
|
|
|
|
|
|
|
|
if(!is_writable($config['file_script'])) {
|
|
|
|
echo "Dropping priviledges... (I can't operate as user; I need PHP's rights.)\n";
|
|
|
|
|
|
|
|
$filename = '.' . md5(rand()) . '.php';
|
|
|
|
|
|
|
|
echo "Copying rebuilder to web directory...\n";
|
|
|
|
copy(__FILE__, $filename);
|
2012-03-02 16:41:04 -05:00
|
|
|
chmod($filename, 0666);
|
|
|
|
|
2012-03-14 00:55:12 -04:00
|
|
|
if(preg_match('/^https?:\/\//', $config['root'])) {
|
|
|
|
$url = $config['root'] . $filename;
|
|
|
|
} else {
|
|
|
|
// assume localhost
|
|
|
|
$url = 'http://localhost' . $config['root'] . $filename;
|
|
|
|
}
|
|
|
|
|
|
|
|
echo "Downloading $url\n";
|
|
|
|
|
|
|
|
passthru('curl -s -N ' . escapeshellarg($url));
|
2012-03-02 16:41:04 -05:00
|
|
|
|
|
|
|
echo "\n".'Cleaning up afterwards...'."\n";
|
2012-03-14 00:55:12 -04:00
|
|
|
|
2012-03-02 16:41:04 -05:00
|
|
|
unlink($filename);
|
2012-03-14 00:55:12 -04:00
|
|
|
|
2012-03-02 16:41:04 -05:00
|
|
|
echo "Bye!\n";
|
|
|
|
exit;
|
|
|
|
}
|
2012-03-14 00:55:12 -04:00
|
|
|
|
|
|
|
echo "Clearing template cache...\n";
|
2012-03-02 16:41:04 -05:00
|
|
|
$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";
|
2012-03-02 16:41:04 -05:00
|
|
|
rebuildThemes('all');
|
2012-03-14 00:55:12 -04:00
|
|
|
|
|
|
|
echo "Generating Javascript file...\n";
|
2012-03-02 16:41:04 -05:00
|
|
|
buildJavascript();
|
2012-03-14 00:55:12 -04:00
|
|
|
|
2012-03-02 16:41:04 -05:00
|
|
|
$boards = listBoards();
|
2012-03-14 00:55:12 -04:00
|
|
|
|
2012-03-02 16:41:04 -05: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";
|
2012-03-02 16:41:04 -05:00
|
|
|
buildIndex();
|
2012-03-14 00:55:12 -04:00
|
|
|
|
2012-03-02 16:41:04 -05:00
|
|
|
$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);
|
|
|
|
|
|
|
|
// modLog('Rebuilt everything using tools/rebuild.php');
|
2012-03-02 16:41:04 -05:00
|
|
|
|