1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2024-11-29 01:34:31 +01:00
Conflicts:
	README.md
	js/auto-reload.js
	js/fix-report-delete-submit.js
	js/forced-anon.js
	js/local-time.js
	js/post-hover.js
	js/quick-post-controls.js
	js/quick-reply.js
	js/show-backlinks.js
	js/smartphone-spoiler.js
	migration/kusabax.php
	stylesheets/dark.css
	stylesheets/futaba+vichan.css
	stylesheets/miku.css
	stylesheets/testorange.css
	stylesheets/wasabi.css
	tools/benchmark.php
	tools/i18n_extract.php
	tools/inc/cli.php
	tools/rebuild.php
This commit is contained in:
czaks 2013-09-17 15:08:41 -04:00
commit 00b42a614a
6 changed files with 76 additions and 9 deletions

View File

@ -73,6 +73,11 @@ find support from a variety of sources:
[irc.datnode.net #tinyboard](irc://irc.datnode.net/tinyboard). [irc.datnode.net #tinyboard](irc://irc.datnode.net/tinyboard).
* You may find help at [tinyboard.org](http://tinyboard.org/#help). * You may find help at [tinyboard.org](http://tinyboard.org/#help).
Tinyboard-Tools:
-----------------
## Directories
* ```tools/``` -- Command-line management scripts for Tinyboard. These should not be publicly executable.
License License
-------- --------
See [LICENSE.md](http://github.com/savetheinternet/Tinyboard/blob/master/LICENSE.md). See [LICENSE.md](http://github.com/savetheinternet/Tinyboard/blob/master/LICENSE.md).

4
js/jquery.min.js vendored

File diff suppressed because one or more lines are too long

9
tools/benchmark.php Normal file → Executable file
View File

@ -47,6 +47,11 @@ function benchmark($method) {
} }
benchmark('gd'); benchmark('gd');
benchmark('imagick'); if (extension_loaded('imagick')) {
benchmark('imagick');
} else {
echo "Imagick extension not loaded... skipping.\n";
}
benchmark('convert'); benchmark('convert');
benchmark('gm');
becnhmark('convert+gifsicle');

60
tools/delete-stray-images.php Executable file
View File

@ -0,0 +1,60 @@
#!/usr/bin/php
<?php
/*
* delete-stray-images.php - there was a period when undoImage() was not working at all. This meant that
* if an error occured while uploading an image, the uploaded images might not have been deleted.
*
* This script iterates through every board and deletes any stray files in src/ or thumb/ that don't
* exist in the database.
*
*/
require dirname(__FILE__) . '/inc/cli.php';
$boards = listBoards();
foreach ($boards as $board) {
echo "/{$board['uri']}/... ";
openBoard($board['uri']);
$query = query(sprintf("SELECT `file`, `thumb` FROM ``posts_%s`` WHERE `file` IS NOT NULL", $board['uri']));
$valid_src = array();
$valid_thumb = array();
while ($post = $query->fetch(PDO::FETCH_ASSOC)) {
$valid_src[] = $post['file'];
$valid_thumb[] = $post['thumb'];
}
$files_src = array_map('basename', glob($board['dir'] . $config['dir']['img'] . '*'));
$files_thumb = array_map('basename', glob($board['dir'] . $config['dir']['thumb'] . '*'));
$stray_src = array_diff($files_src, $valid_src);
$stray_thumb = array_diff($files_thumb, $valid_thumb);
$stats = array(
'deleted' => 0,
'size' => 0
);
foreach ($stray_src as $src) {
$stats['deleted']++;
$stats['size'] = filesize($board['dir'] . $config['dir']['img'] . $src);
if (!file_unlink($board['dir'] . $config['dir']['img'] . $src)) {
$er = error_get_last();
die("error: " . $er['message'] . "\n");
}
}
foreach ($stray_thumb as $thumb) {
$stats['deleted']++;
$stats['size'] = filesize($board['dir'] . $config['dir']['thumb'] . $thumb);
if (!file_unlink($board['dir'] . $config['dir']['thumb'] . $thumb)) {
$er = error_get_last();
die("error: " . $er['message'] . "\n");
}
}
echo sprintf("deleted %s files (%s)\n", $stats['deleted'], format_bytes($stats['size']));
}

View File

@ -33,7 +33,7 @@ if(!getenv('TINYBOARD_PATH')) {
putenv('TINYBOARD_PATH=' . getcwd()); putenv('TINYBOARD_PATH=' . getcwd());
require 'inc/functions.php'; require 'inc/functions.php';
require 'inc/mod.php'; require 'inc/mod/auth.php';
$mod = Array( $mod = Array(
'id' => -1, 'id' => -1,

View File

@ -64,6 +64,7 @@ foreach($boards as &$board) {
if(!$options['quiet']) if(!$options['quiet'])
echo "Opening board /{$board['uri']}/...\n"; echo "Opening board /{$board['uri']}/...\n";
openBoard($board['uri']); openBoard($board['uri']);
$config['try_smarter'] = false;
if($config['file_script'] != $main_js) { if($config['file_script'] != $main_js) {
// different javascript file // different javascript file
@ -81,7 +82,7 @@ foreach($boards as &$board) {
continue; // do no more continue; // do no more
if($options['full']) { if($options['full']) {
$query = query(sprintf("SELECT `id` FROM `posts_%s`", $board['uri'])) or error(db_error()); $query = query(sprintf("SELECT `id` FROM ``posts_%s``", $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";
@ -89,7 +90,7 @@ foreach($boards as &$board) {
} }
} }
$query = query(sprintf("SELECT `id` FROM `posts_%s` WHERE `thread` IS NULL", $board['uri'])) or error(db_error()); $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";