From fd9196f036c17a11bc793525a082d16a3e198f5a Mon Sep 17 00:00:00 2001 From: czaks Date: Wed, 24 Sep 2014 03:43:14 +0200 Subject: tools/stats.php: restore php 5.3 compatibility; fixes vichan-devel#85 --- tools/stats.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'tools') diff --git a/tools/stats.php b/tools/stats.php index 0f05d6a8..cec8d2ab 100755 --- a/tools/stats.php +++ b/tools/stats.php @@ -2,11 +2,12 @@ fetch()) { printf("%10s || ", $f['uri']); - foreach ($variants as list($term, $time)) { + foreach ($variants as $iter) { + list($term, $time) = $iter; $qq = query(sprintf("SELECT COUNT(*) as count FROM ``posts_%s`` WHERE time > %d", $f['uri'], time()-$time)); $c = $qq->fetch()['count']; -- cgit v1.3 From f294af104bfc27d03168942670ea8fef3e64ada6 Mon Sep 17 00:00:00 2001 From: 8chan Date: Mon, 29 Sep 2014 07:17:39 +0000 Subject: Reset to global locale before openBoard --- tools/rebuild.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tools') diff --git a/tools/rebuild.php b/tools/rebuild.php index 3501f8f6..82df3e19 100755 --- a/tools/rebuild.php +++ b/tools/rebuild.php @@ -26,6 +26,7 @@ $start = microtime(true); // parse command line $opts = getopt('qfb:', Array('board:', 'quick', 'full', 'quiet')); $options = Array(); +$global_locale = $config['locale']; $options['board'] = isset($opts['board']) ? $opts['board'] : (isset($opts['b']) ? $opts['b'] : false); $options['quiet'] = isset($opts['q']) || isset($opts['quiet']); @@ -59,6 +60,8 @@ foreach($boards as &$board) { if(!$options['quiet']) echo "Opening board /{$board['uri']}/...\n"; + // Reset locale to global locale + $config['locale'] = $global_locale; openBoard($board['uri']); $config['try_smarter'] = false; -- cgit v1.3 From 61371f77ceed2184aef4e1494d2b9e625afd9e90 Mon Sep 17 00:00:00 2001 From: 8chan Date: Thu, 19 Feb 2015 19:14:24 -0800 Subject: rebuild2 - multithreaded rebuild script --- tools/rebuild2.php | 140 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100755 tools/rebuild2.php (limited to 'tools') diff --git a/tools/rebuild2.php b/tools/rebuild2.php new file mode 100755 index 00000000..2945460c --- /dev/null +++ b/tools/rebuild2.php @@ -0,0 +1,140 @@ +#!/usr/bin/php +clearCacheFiles(); +} + +if($options['themes']) { + echo "Regenerating theme files...\n"; + rebuildThemes('all'); +} + +if($options['js']) { + echo "Generating Javascript file...\n"; + buildJavascript(); +} + +$main_js = $config['file_script']; + +$boards = listBoards(); +//$boards = array(array('uri'=>'test'), array('uri'=>'tester'), array('uri'=>'testing')); +$boards_m = array_chunk($boards, floor(sizeof($boards)/$options['processes'])); + +function doboard($board) { + global $global_locale, $config, $main_js, $options; + $config['mask_db_error'] = false; + if (!$options['api']) $config['api']['enabled'] = false; + + echo "Opening board /{$board['uri']}/...\n"; + // Reset locale to global locale + $config['locale'] = $global_locale; + init_locale($config['locale'], 'error'); + openBoard($board['uri']); + $config['try_smarter'] = false; + + if($config['file_script'] != $main_js && $options['js']) { + // different javascript file + echo "(/{$board['uri']}/) Generating Javascript file...\n"; + buildJavascript(); + } + + + if ($options['indexes']) { + echo "(/{$board['uri']}/) Creating index pages...\n"; + buildIndex(); + } + + if($options['postmarkup']) { + $query = query(sprintf("SELECT `id` FROM ``posts_%s``", $board['uri'])) or error(db_error()); + while($post = $query->fetch()) { + echo "(/{$board['uri']}/) Rebuilding #{$post['id']}...\n"; + rebuildPost($post['id']); + } + } + + if ($options['threads']) { + $query = query(sprintf("SELECT `id` FROM ``posts_%s`` WHERE `thread` IS NULL", $board['uri'])) or error(db_error()); + while($post = $query->fetch()) { + echo "(/{$board['uri']}/) Rebuilding #{$post['id']}...\n"; + @buildThread($post['id']); + } + } +} + +$children = array(); +foreach ($boards_m as $i => $bb) { + $pid = pcntl_fork(); + + if ($pid == -1) { + die('Fork failed?'); + } else if ($pid) { + echo "Started PID #$pid...\n"; + $children[] = $pid; + } else { + unset($pdo); + $i = 0; + $total = sizeof($bb); + sql_open(); + foreach ($bb as $i => $b) { + $i++; + doboard($b); + echo "I'm on board $i/$total\n"; + } + break; + } +} + + +printf("Complete! Took %g seconds\n", microtime(true) - $start); + +unset($board); + +foreach ($children as $child) { + pcntl_waitpid($child, $status); + unset($children[$child]); +} + +//modLog('Rebuilt everything using tools/rebuild.php'); -- cgit v1.3 From aadbf4852f51a1fee02dfee9708d5b1d67eedf6d Mon Sep 17 00:00:00 2001 From: czaks Date: Sun, 5 Apr 2015 18:50:16 +0200 Subject: tools/rebuild.php: fix for bans.php not included by default and public_banlist --- tools/rebuild.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tools') diff --git a/tools/rebuild.php b/tools/rebuild.php index 82df3e19..289523a1 100755 --- a/tools/rebuild.php +++ b/tools/rebuild.php @@ -21,6 +21,8 @@ require dirname(__FILE__) . '/inc/cli.php'; +require_once("inc/bans.php"); + $start = microtime(true); // parse command line -- cgit v1.3