summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorMichael Save <savetheinternet@tinyboard.org>2012-03-14 15:55:12 +1100
committerMichael Save <savetheinternet@tinyboard.org>2012-03-14 15:55:12 +1100
commita2d29860e6773b181e1c0670e2458e43321e2cd2 (patch)
tree599b7c2c4e1205e5d249e82e6e0f1150a6eba620 /tools
parentff697004b08630d16d55f699f353147dc7e60f0c (diff)
rebuild.php revision
Diffstat (limited to 'tools')
-rwxr-xr-xtools/rebuild.php70
1 files changed, 39 insertions, 31 deletions
diff --git a/tools/rebuild.php b/tools/rebuild.php
index 8be13f27..8bb8373b 100755
--- a/tools/rebuild.php
+++ b/tools/rebuild.php
@@ -1,67 +1,75 @@
#!/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);
+
+ 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);
chmod($filename, 0666);
- echo 'Connecting...!'."\n\n";
- // REPLACE http://0/Tinyboard/ WITH YOUR OWN PATH
- passthru("curl -s -N http://0/Tinyboard/$filename");
+ 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));
echo "\n".'Cleaning up afterwards...'."\n";
+
unlink($filename);
+
echo "Bye!\n";
exit;
}
-
- echo 'Clearing template cache...'."\n";
+
+ echo "Clearing template cache...\n";
$twig = new Twig_Environment($loader, Array(
'cache' => "{$config['dir']['template']}/cache"
));
$twig->clearCacheFiles();
-
- echo 'Regenerating theme files...'."\n";
+
+ echo "Regenerating theme files...\n";
rebuildThemes('all');
-
- echo 'Generating Javascript file...'."\n";
+
+ 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";
+
+ 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("Complete! Took %g seconds\n", microtime(true) - $start);
+
+ // modLog('Rebuilt everything using tools/rebuild.php');
- printf('Took %g seconds.'."\n", microtime(true) - $start);
-
- //modLog('Rebuilt everything using tools/rebuild.php');
-?>