From 99a51ddca9270b030620f5e62bb6744418b053cc Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Sun, 27 Mar 2011 02:35:54 +1100 Subject: [PATCH] Added/completed "rebuild" page --- mod.php | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/mod.php b/mod.php index 37a86c4a..fd69691a 100644 --- a/mod.php +++ b/mod.php @@ -96,6 +96,9 @@ if($mod['type'] >= $config['mod']['modlog']) { $fieldset['Administration'] .= '
  • Moderation log
  • '; } + if($mod['type'] >= $config['mod']['rebuild']) { + $fieldset['Administration'] .= '
  • Rebuild static files
  • '; + } if($mod['type'] >= $config['mod']['show_config']) { $fieldset['Administration'] .= '
  • Show configuration
  • '; } @@ -728,28 +731,38 @@ ) ); } elseif(preg_match('/^\/rebuild$/', $query)) { - // For debugging - set_time_limit(0); + if($mod['type'] < $config['mod']['rebuild']) error($config['error']['noaccess']); + + set_time_limit($config['mod']['rebuild_timelimit']); + + $body = '

    Rebuildingā€¦

    '; - header('Content-Type: text/plain'); - if($mod['type'] != ADMIN) die('Admins only!'); + $body .= 'Generating Javascript fileā€¦
    '; + buildJavascript(); $boards = listBoards(); foreach($boards as &$board) { - echo "Opening board /{$board['uri']}/\n"; + $body .= "Opening board /{$board['uri']}/
    "; openBoard($board['uri']); - echo "Creating index pages\n"; + $body .= 'Creating index pages
    '; 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"; + $body .= "Rebuilding #{$post['id']}
    "; buildThread($post['id']); } } - echo "Complete!\n"; + $body .= 'Complete!

    '; + + echo Element('page.html', Array( + 'config'=>$config, + 'title'=>'Rebuilt', + 'body'=>$body, + 'mod'=>true + )); } elseif(preg_match('/^\/config$/', $query)) { if($mod['type'] < $config['mod']['show_config']) error($config['error']['noaccess']);