diff options
| author | Marcin Ćabanowski <marcin@6irc.net> | 2012-03-02 22:41:04 +0100 |
|---|---|---|
| committer | Michael Save <savetheinternet@tinyboard.org> | 2012-03-14 15:31:01 +1100 |
| commit | ff697004b08630d16d55f699f353147dc7e60f0c (patch) | |
| tree | fb7794ffbd9080b2b850d8b976a3ea1d23da3de4 | |
| parent | 40b59c36da5e07c649336ec374337d1114c7118b (diff) | |
a command-line tool for rebuilding js, html, etc.; based on mod.php; also introduced dynamic main.js names in order to prevent aggressive caching, based on filemtime of templates/main.js
| -rwxr-xr-x | tools/rebuild.php | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/tools/rebuild.php b/tools/rebuild.php new file mode 100755 index 00000000..8be13f27 --- /dev/null +++ b/tools/rebuild.php @@ -0,0 +1,67 @@ +#!/usr/bin/php +<?php + error_reporting(0); + require 'inc/functions.php'; + require 'inc/display.php'; + require 'inc/template.php'; + require 'inc/database.php'; + require 'inc/user.php'; + require 'inc/mod.php'; + error_reporting(E_ALL ^ E_DEPRECATED); + + set_time_limit($config['mod']['rebuild_timelimit']); + + echo '== Tinyboard '.$config['version'].' =='."\n"; + $start = microtime(true); + echo 'Rebuilding...'."\n"; + + if (!is_writable ("main.js")) { + echo 'Dropping priviledges... (I can\'t operate as user, I need httpd rights)'."\n"; + $filename = ".".rand().".".rand().".php"; + echo 'Copying rebuilder...'."\n"; + copy($_SERVER['PHP_SELF'], $filename); + chmod($filename, 0666); + echo 'Connecting...!'."\n\n"; + + // REPLACE http://0/Tinyboard/ WITH YOUR OWN PATH + passthru("curl -s -N http://0/Tinyboard/$filename"); + + echo "\n".'Cleaning up afterwards...'."\n"; + unlink($filename); + echo "Bye!\n"; + exit; + } + + 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(); + + $boards = listBoards(); + + foreach($boards as &$board) { + echo "Opening board /{$board['uri']}/...\n"; + openBoard($board['uri']); + + echo 'Creating index pages...'+"\n"; + buildIndex(); + + $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']); + } + } + echo 'Complete!'."\n"; + + printf('Took %g seconds.'."\n", microtime(true) - $start); + + //modLog('Rebuilt everything using tools/rebuild.php'); +?> |
