fix fatal errors. works with v0.9.6
This commit is contained in:
parent
1758f750fd
commit
e056b1eb70
@ -4,49 +4,49 @@
|
|||||||
* benchmark.php - benchmarks thumbnailing methods
|
* benchmark.php - benchmarks thumbnailing methods
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require dirname(__FILE__) . '/inc/cli.php';
|
require dirname(__FILE__) . '/inc/cli.php';
|
||||||
require 'inc/image.php';
|
require 'inc/image.php';
|
||||||
|
|
||||||
|
// move back to this directory
|
||||||
|
chdir(dirname(__FILE__));
|
||||||
|
|
||||||
|
if(count($argv) != 2)
|
||||||
|
die("Usage: {$argv[0]} [file]\n");
|
||||||
|
|
||||||
|
$file = $argv[1];
|
||||||
|
$extension = strtolower(substr($file, strrpos($file, '.') + 1));
|
||||||
|
$out = tempnam($config['tmp'], 'thumb');
|
||||||
|
$count = 300;
|
||||||
|
|
||||||
|
function benchmark($method) {
|
||||||
|
global $config, $file, $extension, $out, $count;
|
||||||
|
|
||||||
// move back to this directory
|
$config['thumb_method'] = $method;
|
||||||
chdir(dirname(__FILE__));
|
|
||||||
|
|
||||||
if(count($argv) != 2)
|
printf("Method: %s\nThumbnailing %d times... ", $method, $count);
|
||||||
die("Usage: {$argv[0]} [file]\n");
|
|
||||||
|
|
||||||
$file = $argv[1];
|
$start = microtime(true);
|
||||||
$extension = strtolower(substr($file, strrpos($file, '.') + 1));
|
for($i = 0; $i < $count; $i++) {
|
||||||
$out = tempnam($config['tmp'], 'thumb');
|
$image = new Image($file, $extension);
|
||||||
$count = 300;
|
$thumb = $image->resize(
|
||||||
|
$config['thumb_ext'] ? $config['thumb_ext'] : $extension,
|
||||||
function benchmark($method) {
|
$config['thumb_width'],
|
||||||
global $config, $file, $extension, $out, $count;
|
$config['thumb_height']
|
||||||
|
);
|
||||||
|
|
||||||
$config['thumb_method'] = $method;
|
$thumb->to($out);
|
||||||
|
$thumb->_destroy();
|
||||||
printf("Method: %s\nThumbnailing %d times... ", $method, $count);
|
$image->destroy();
|
||||||
|
|
||||||
$start = microtime(true);
|
|
||||||
for($i = 0; $i < $count; $i++) {
|
|
||||||
$image = new Image($file, $extension);
|
|
||||||
$thumb = $image->resize(
|
|
||||||
$config['thumb_ext'] ? $config['thumb_ext'] : $extension,
|
|
||||||
$config['thumb_width'],
|
|
||||||
$config['thumb_height']
|
|
||||||
);
|
|
||||||
|
|
||||||
$thumb->to($out);
|
|
||||||
$thumb->_destroy();
|
|
||||||
$image->destroy();
|
|
||||||
}
|
|
||||||
$end = microtime(true);
|
|
||||||
|
|
||||||
printf("Took %.2f seconds (%.2f/second; %.2f ms)\n", $end - $start, $rate = ($count / ($end - $start)), 1000 / $rate);
|
|
||||||
|
|
||||||
unlink($out);
|
|
||||||
}
|
}
|
||||||
|
$end = microtime(true);
|
||||||
|
|
||||||
benchmark('gd');
|
printf("Took %.2f seconds (%.2f/second; %.2f ms)\n", $end - $start, $rate = ($count / ($end - $start)), 1000 / $rate);
|
||||||
benchmark('imagick');
|
|
||||||
benchmark('convert');
|
|
||||||
|
|
||||||
|
unlink($out);
|
||||||
|
}
|
||||||
|
|
||||||
|
benchmark('gd');
|
||||||
|
benchmark('imagick');
|
||||||
|
benchmark('convert');
|
||||||
|
|
||||||
|
@ -33,10 +33,6 @@ if(!getenv('TINYBOARD_PATH')) {
|
|||||||
putenv('TINYBOARD_PATH=' . getcwd());
|
putenv('TINYBOARD_PATH=' . getcwd());
|
||||||
|
|
||||||
require 'inc/functions.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';
|
require 'inc/mod.php';
|
||||||
|
|
||||||
$mod = Array(
|
$mod = Array(
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/php
|
#!/usr/bin/php
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* rebuild.php - rebuilds all static files
|
* rebuild.php - rebuilds all static files
|
||||||
*
|
*
|
||||||
@ -17,89 +18,88 @@
|
|||||||
* Rebuild replies as well as threads (re-markup).
|
* Rebuild replies as well as threads (re-markup).
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require dirname(__FILE__) . '/inc/cli.php';
|
require dirname(__FILE__) . '/inc/cli.php';
|
||||||
|
|
||||||
|
if(!is_writable($config['file_script'])) {
|
||||||
|
get_httpd_privileges();
|
||||||
|
}
|
||||||
|
|
||||||
|
$start = microtime(true);
|
||||||
|
|
||||||
|
// parse command line
|
||||||
|
$opts = getopt('qfb:', Array('board:', 'quick', 'full', 'quiet'));
|
||||||
|
$options = Array();
|
||||||
|
|
||||||
|
$options['board'] = isset($opts['board']) ? $opts['board'] : (isset($opts['b']) ? $opts['b'] : false);
|
||||||
|
$options['quiet'] = isset($opts['q']) || isset($opts['quiet']);
|
||||||
|
$options['quick'] = isset($opts['quick']);
|
||||||
|
$options['full'] = isset($opts['full']) || isset($opts['f']);
|
||||||
|
|
||||||
|
if(!$options['quiet'])
|
||||||
|
echo "== Tinyboard {$config['version']} ==\n";
|
||||||
|
|
||||||
|
if(!$options['quiet'])
|
||||||
|
echo "Clearing template cache...\n";
|
||||||
|
|
||||||
|
load_twig();
|
||||||
|
$twig->clearCacheFiles();
|
||||||
|
|
||||||
|
if(!$options['quiet'])
|
||||||
|
echo "Regenerating theme files...\n";
|
||||||
|
rebuildThemes('all');
|
||||||
|
|
||||||
|
if(!$options['quiet'])
|
||||||
|
echo "Generating Javascript file...\n";
|
||||||
|
buildJavascript();
|
||||||
|
|
||||||
|
$main_js = $config['file_script'];
|
||||||
|
|
||||||
|
$boards = listBoards();
|
||||||
|
|
||||||
|
foreach($boards as &$board) {
|
||||||
|
if($options['board'] && $board['uri'] != $options['board'])
|
||||||
|
continue;
|
||||||
|
|
||||||
if(!is_writable($config['file_script'])) {
|
if(!$options['quiet'])
|
||||||
get_httpd_privileges();
|
echo "Opening board /{$board['uri']}/...\n";
|
||||||
|
openBoard($board['uri']);
|
||||||
|
|
||||||
|
if($config['file_script'] != $main_js) {
|
||||||
|
// different javascript file
|
||||||
|
if(!$options['quiet'])
|
||||||
|
echo "Generating Javascript file...\n";
|
||||||
|
buildJavascript();
|
||||||
}
|
}
|
||||||
|
|
||||||
$start = microtime(true);
|
|
||||||
|
|
||||||
// parse command line
|
|
||||||
$opts = getopt('qfb:', Array('board:', 'quick', 'full', 'quiet'));
|
|
||||||
$options = Array();
|
|
||||||
|
|
||||||
$options['board'] = isset($opts['board']) ? $opts['board'] : (isset($opts['b']) ? $opts['b'] : false);
|
|
||||||
$options['quiet'] = isset($opts['q']) || isset($opts['quiet']);
|
|
||||||
$options['quick'] = isset($opts['quick']);
|
|
||||||
$options['full'] = isset($opts['full']) || isset($opts['f']);
|
|
||||||
|
|
||||||
if(!$options['quiet'])
|
if(!$options['quiet'])
|
||||||
echo "== Tinyboard {$config['version']} ==\n";
|
echo "Creating index pages...\n";
|
||||||
|
buildIndex();
|
||||||
|
|
||||||
if(!$options['quiet'])
|
if($options['quick'])
|
||||||
echo "Clearing template cache...\n";
|
continue; // do no more
|
||||||
$twig = new Twig_Environment($loader, Array(
|
|
||||||
'cache' => "{$config['dir']['template']}/cache"
|
|
||||||
));
|
|
||||||
$twig->clearCacheFiles();
|
|
||||||
|
|
||||||
if(!$options['quiet'])
|
if($options['full']) {
|
||||||
echo "Regenerating theme files...\n";
|
$query = query(sprintf("SELECT `id` FROM `posts_%s`", $board['uri'])) or error(db_error());
|
||||||
rebuildThemes('all');
|
|
||||||
|
|
||||||
if(!$options['quiet'])
|
|
||||||
echo "Generating Javascript file...\n";
|
|
||||||
buildJavascript();
|
|
||||||
|
|
||||||
$main_js = $config['file_script'];
|
|
||||||
|
|
||||||
$boards = listBoards();
|
|
||||||
|
|
||||||
foreach($boards as &$board) {
|
|
||||||
if($options['board'] && $board['uri'] != $options['board'])
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if(!$options['quiet'])
|
|
||||||
echo "Opening board /{$board['uri']}/...\n";
|
|
||||||
openBoard($board['uri']);
|
|
||||||
|
|
||||||
if($config['file_script'] != $main_js) {
|
|
||||||
// different javascript file
|
|
||||||
if(!$options['quiet'])
|
|
||||||
echo "Generating Javascript file...\n";
|
|
||||||
buildJavascript();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if(!$options['quiet'])
|
|
||||||
echo "Creating index pages...\n";
|
|
||||||
buildIndex();
|
|
||||||
|
|
||||||
if($options['quick'])
|
|
||||||
continue; // do no more
|
|
||||||
|
|
||||||
if($options['full']) {
|
|
||||||
$query = query(sprintf("SELECT `id` FROM `posts_%s`", $board['uri'])) or error(db_error());
|
|
||||||
while($post = $query->fetch()) {
|
|
||||||
if(!$options['quiet'])
|
|
||||||
echo "Rebuilding #{$post['id']}...\n";
|
|
||||||
rebuildPost($post['id']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$query = query(sprintf("SELECT `id` FROM `posts_%s` WHERE `thread` IS NULL", $board['uri'])) or error(db_error());
|
|
||||||
while($post = $query->fetch()) {
|
while($post = $query->fetch()) {
|
||||||
if(!$options['quiet'])
|
if(!$options['quiet'])
|
||||||
echo "Rebuilding #{$post['id']}...\n";
|
echo "Rebuilding #{$post['id']}...\n";
|
||||||
buildThread($post['id']);
|
rebuildPost($post['id']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$options['quiet'])
|
$query = query(sprintf("SELECT `id` FROM `posts_%s` WHERE `thread` IS NULL", $board['uri'])) or error(db_error());
|
||||||
printf("Complete! Took %g seconds\n", microtime(true) - $start);
|
while($post = $query->fetch()) {
|
||||||
|
if(!$options['quiet'])
|
||||||
unset($board);
|
echo "Rebuilding #{$post['id']}...\n";
|
||||||
modLog('Rebuilt everything using tools/rebuild.php');
|
buildThread($post['id']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$options['quiet'])
|
||||||
|
printf("Complete! Took %g seconds\n", microtime(true) - $start);
|
||||||
|
|
||||||
|
unset($board);
|
||||||
|
modLog('Rebuilt everything using tools/rebuild.php');
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user