From 40399300745f83cce81d3109abd4e7b15aea5595 Mon Sep 17 00:00:00 2001 From: Michael Save Date: Sat, 31 Mar 2012 11:03:12 +1100 Subject: Merge scripts from Tinyboard-Tools --- tools/benchmark.php | 52 -------------------------- tools/inc/cli.php | 104 --------------------------------------------------- tools/rebuild.php | 105 ---------------------------------------------------- 3 files changed, 261 deletions(-) delete mode 100755 tools/benchmark.php delete mode 100644 tools/inc/cli.php delete mode 100755 tools/rebuild.php (limited to 'tools') diff --git a/tools/benchmark.php b/tools/benchmark.php deleted file mode 100755 index 60aba638..00000000 --- a/tools/benchmark.php +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/php -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); - } - - benchmark('gd'); - benchmark('imagick'); - benchmark('convert'); - diff --git a/tools/inc/cli.php b/tools/inc/cli.php deleted file mode 100644 index 4dc19412..00000000 --- a/tools/inc/cli.php +++ /dev/null @@ -1,104 +0,0 @@ - -1, - 'type' => ADMIN, - 'username' => '?', - 'boards' => Array('*') -); - -function get_httpd_privileges() { - global $config, $shell_path, $argv; - - if(php_sapi_name() != 'cli') - die("get_httpd_privileges(): invoked from HTTP client.\n"); - - echo "Dropping priviledges...\n"; - - if(!is_writable('.')) - die("get_httpd_privileges(): web directory is not writable\n"); - - $filename = '.' . md5(rand()) . '.php'; - $inc_filename = '.' . md5(rand()) . '.php'; - - echo "Copying rebuilder to web directory...\n"; - - // replace "/inc/cli.php" with its new filename - passthru("cat " . escapeshellarg($shell_path . '/' . $_SERVER['PHP_SELF']) . " | sed \"s/'\/inc\/cli\.php'/'\/{$inc_filename}'/\" > {$filename}"); - - $inc_header = " - * Rebuild only the specified board. - * - * -f, --full - * Rebuild replies as well as threads (re-markup). - * - */ - - 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"; - $twig = new Twig_Environment($loader, Array( - 'cache' => "{$config['dir']['template']}/cache" - )); - $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(!$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()) { - if(!$options['quiet']) - echo "Rebuilding #{$post['id']}...\n"; - buildThread($post['id']); - } - } - - if(!$options['quiet']) - printf("Complete! Took %g seconds\n", microtime(true) - $start); - - unset($board); - modLog('Rebuilt everything using tools/rebuild.php'); - -- cgit v1.3