1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2024-11-28 01:10:51 +01:00
Conflicts:
	inc/config.php
	inc/functions.php
	install.php
	stylesheets/dark_roach.css
This commit is contained in:
czaks 2013-08-28 12:41:36 -04:00
commit 8503e65858
21 changed files with 231 additions and 50 deletions

View File

@ -178,11 +178,14 @@ class AntiBot {
} }
function _create_antibot($board, $thread) { function _create_antibot($board, $thread) {
global $config; global $config, $purged_old_antispam;
$antibot = new AntiBot(array($board, $thread)); $antibot = new AntiBot(array($board, $thread));
if (!isset($purged_old_antispam)) {
$purged_old_antispam = true;
query('DELETE FROM ``antispam`` WHERE `expires` < UNIX_TIMESTAMP()') or error(db_error()); query('DELETE FROM ``antispam`` WHERE `expires` < UNIX_TIMESTAMP()') or error(db_error());
}
if ($thread) if ($thread)
$query = prepare('UPDATE ``antispam`` SET `expires` = UNIX_TIMESTAMP() + :expires WHERE `board` = :board AND `thread` = :thread AND `expires` IS NULL'); $query = prepare('UPDATE ``antispam`` SET `expires` = UNIX_TIMESTAMP() + :expires WHERE `board` = :board AND `thread` = :thread AND `expires` IS NULL');

View File

@ -77,16 +77,18 @@
// Database driver (http://www.php.net/manual/en/pdo.drivers.php) // Database driver (http://www.php.net/manual/en/pdo.drivers.php)
// Only MySQL is supported by Tinyboard at the moment, sorry. // Only MySQL is supported by Tinyboard at the moment, sorry.
$config['db']['type'] = 'mysql'; $config['db']['type'] = 'mysql';
// Hostname or IP address // Hostname, IP address or Unix socket (prefixed with ":")
$config['db']['server'] = 'localhost'; $config['db']['server'] = 'localhost';
// Example: Unix socket
// $config['db']['server'] = ':/tmp/mysql.sock';
// Login // Login
$config['db']['user'] = ''; $config['db']['user'] = '';
$config['db']['password'] = ''; $config['db']['password'] = '';
// Tinyboard database // Tinyboard database
$config['db']['database'] = ''; $config['db']['database'] = '';
// Table prefix // Table prefix (optional)
$config['db']['prefix'] = ''; $config['db']['prefix'] = '';
// Use a persistent connection (experimental) // Use a persistent connection (experimental; benefits unknown)
$config['db']['persistent'] = false; $config['db']['persistent'] = false;
// Anything more to add to the DSN string (eg. port=xxx;foo=bar) // Anything more to add to the DSN string (eg. port=xxx;foo=bar)
$config['db']['dsn'] = ''; $config['db']['dsn'] = '';
@ -1350,14 +1352,14 @@
* ============= * =============
*/ */
// Whether or not to use the API, disabled by default. // Whether or not to enable the 4chan-compatible API, disabled by default. See
// https://github.com/4chan/4chan-API for API specification.
$config['api']['enabled'] = false; $config['api']['enabled'] = false;
// Extra fields in to be shown in the array that are not 4chan API compatible. // Extra fields in to be shown in the array that are not in the 4chan-API. You can get these by taking a
// You canget these by taking a look at the schema for posts_ tables. The array should be formatted as $db_name => $translated_name. // look at the schema for posts_ tables. The array should be formatted as $db_column => $translated_name.
// For example: // Example: Adding the pre-markup post body to the API as "com_nomarkup".
// $config['api']['extra_fields'] = array('body_nomarkup' => 'com_nomarkup');
// $config['api']['extra_fields'] = array('body_nomarkup'=>'com_nomarkup');
/* /*
* ==================== * ====================

View File

@ -43,9 +43,17 @@ class PreparedQueryDebug {
function sql_open() { function sql_open() {
global $pdo, $config; global $pdo, $config;
if ($pdo) return true; if ($pdo)
return true;
$dsn = $config['db']['type'] . ':host=' . $config['db']['server'] . ';dbname=' . $config['db']['database']; if (isset($config['db']['server'][0]) && $config['db']['server'][0] == ':')
$unix_socket = substr($config['db']['server'], 1);
else
$unix_socket = false;
$dsn = $config['db']['type'] . ':' .
($unix_socket ? 'unix_socket=' . $unix_socket : 'host=' . $config['db']['server']) .
';dbname=' . $config['db']['database'];
if (!empty($config['db']['dsn'])) if (!empty($config['db']['dsn']))
$dsn .= ';' . $config['db']['dsn']; $dsn .= ';' . $config['db']['dsn'];
try { try {

View File

@ -35,6 +35,7 @@ function loadConfig() {
$arrays = array( $arrays = array(
'db', 'db',
'api',
'cache', 'cache',
'cookies', 'cookies',
'error', 'error',
@ -1001,9 +1002,8 @@ function deletePost($id, $error_if_doesnt_exist=true, $rebuild_after=true) {
if (isset($tmp_board)) if (isset($tmp_board))
openBoard($tmp_board); openBoard($tmp_board);
$query = prepare("DELETE FROM ``cites`` WHERE (`target_board` = :board AND `target` = :id) OR (`board` = :board AND `post` = :id)"); $query = prepare("DELETE FROM ``cites`` WHERE (`target_board` = :board AND `target` = (" . implode(' OR `target` = ', $ids) . ")) OR (`board` = :board AND (`post` = " . implode(' OR `post` = ', $ids) . "))");
$query->bindValue(':board', $board['uri']); $query->bindValue(':board', $board['uri']);
$query->bindValue(':id', $id, PDO::PARAM_INT);
$query->execute() or error(db_error($query)); $query->execute() or error(db_error($query));
if (isset($rebuild) && $rebuild_after) { if (isset($rebuild) && $rebuild_after) {
@ -1309,7 +1309,8 @@ function buildIndex() {
for ($page = 1; $page <= $config['max_pages']; $page++) { for ($page = 1; $page <= $config['max_pages']; $page++) {
$filename = $board['dir'] . ($page == 1 ? $config['file_index'] : sprintf($config['file_page'], $page)); $filename = $board['dir'] . ($page == 1 ? $config['file_index'] : sprintf($config['file_page'], $page));
if ($config['try_smarter'] && isset($build_pages) && count($build_pages) && !in_array($page, $build_pages) && is_file($filename)) if ($config['try_smarter'] && isset($build_pages) && count($build_pages)
&& !in_array($page, $build_pages) && is_file($filename))
continue; continue;
$content = index($page); $content = index($page);
if (!$content) if (!$content)
@ -1331,19 +1332,20 @@ function buildIndex() {
if ($config['api']['enabled']) { if ($config['api']['enabled']) {
$threads = $content['threads']; $threads = $content['threads'];
$json = json_encode($api->translatePage($threads)); $json = json_encode($api->translatePage($threads));
$jsonFilename = $board['dir'] . ($page-1) . ".json"; // pages should start from 0 $jsonFilename = $board['dir'] . ($page - 1) . '.json'; // pages should start from 0
file_write($jsonFilename, $json); file_write($jsonFilename, $json);
$catalog[$page-1] = $threads; $catalog[$page-1] = $threads;
} }
} }
if ($page < $config['max_pages']) { if ($page < $config['max_pages']) {
for (;$page<=$config['max_pages'];$page++) { for (;$page<=$config['max_pages'];$page++) {
$filename = $board['dir'] . ($page==1 ? $config['file_index'] : sprintf($config['file_page'], $page)); $filename = $board['dir'] . ($page==1 ? $config['file_index'] : sprintf($config['file_page'], $page));
file_unlink($filename); file_unlink($filename);
if ($config['api']['enabled']) { if ($config['api']['enabled']) {
$jsonFilename = $board['dir'] . ($page-1) . ".json"; $jsonFilename = $board['dir'] . ($page - 1) . '.json';
file_unlink($jsonFilename); file_unlink($jsonFilename);
} }
} }
@ -1352,7 +1354,7 @@ function buildIndex() {
// json api catalog // json api catalog
if ($config['api']['enabled']) { if ($config['api']['enabled']) {
$json = json_encode($api->translateCatalog($catalog)); $json = json_encode($api->translateCatalog($catalog));
$jsonFilename = $board['dir'] . "catalog.json"; $jsonFilename = $board['dir'] . 'catalog.json';
file_write($jsonFilename, $json); file_write($jsonFilename, $json);
} }
} }
@ -1779,7 +1781,7 @@ function buildThread($id, $return = false, $mod = false) {
if ($config['api']['enabled']) { if ($config['api']['enabled']) {
$api = new Api(); $api = new Api();
$json = json_encode($api->translateThread($thread)); $json = json_encode($api->translateThread($thread));
$jsonFilename = $board['dir'] . $config['dir']['res'] . $id . ".json"; $jsonFilename = $board['dir'] . $config['dir']['res'] . $id . '.json';
file_write($jsonFilename, $json); file_write($jsonFilename, $json);
} }
@ -1874,7 +1876,7 @@ function buildThread50($id, $return = false, $mod = false, $thread = null, $anti
} }
} }
function rrmdir($dir) { function rrmdir($dir) {
if (is_dir($dir)) { if (is_dir($dir)) {
$objects = scandir($dir); $objects = scandir($dir);
foreach ($objects as $object) { foreach ($objects as $object) {
@ -2029,7 +2031,7 @@ function DNS($host) {
global $config; global $config;
if ($config['cache']['enabled'] && ($ip_addr = cache::get('dns_' . $host))) { if ($config['cache']['enabled'] && ($ip_addr = cache::get('dns_' . $host))) {
return $ip_addr; return $ip_addr != '?' ? $ip_addr : false;
} }
if (!$config['dns_system']) { if (!$config['dns_system']) {
@ -2045,7 +2047,7 @@ function DNS($host) {
} }
if ($config['cache']['enabled']) if ($config['cache']['enabled'])
cache::set('dns_' . $host, $ip_addr, 3600); cache::set('dns_' . $host, $ip_addr !== false ? $ip_addr : '?', 3600);
return $ip_addr; return $ip_addr;
} }

View File

@ -314,7 +314,7 @@ class ImageConvert extends ImageBase {
$this->destroy(); $this->destroy();
} }
$this->temp = tempnam($config['tmp'], 'imagick'); $this->temp = tempnam($config['tmp'], 'convert');
$config['thumb_keep_animation_frames'] = (int)$config['thumb_keep_animation_frames']; $config['thumb_keep_animation_frames'] = (int)$config['thumb_keep_animation_frames'];
@ -322,8 +322,10 @@ class ImageConvert extends ImageBase {
if ($this->gifsicle) { if ($this->gifsicle) {
if (($error = shell_exec("gifsicle -w --unoptimize -O2 --resize {$this->width}x{$this->height} < " . if (($error = shell_exec("gifsicle -w --unoptimize -O2 --resize {$this->width}x{$this->height} < " .
escapeshellarg($this->src . '') . " \"#0-{$config['thumb_keep_animation_frames']}\" -o " . escapeshellarg($this->src . '') . " \"#0-{$config['thumb_keep_animation_frames']}\" -o " .
escapeshellarg($this->temp))) || !file_exists($this->temp)) escapeshellarg($this->temp))) || !file_exists($this->temp)) {
$this->destroy();
error('Failed to resize image!', null, $error); error('Failed to resize image!', null, $error);
}
} else { } else {
if ($config['convert_manual_orient'] && ($this->format == 'jpg' || $this->format == 'jpeg')) if ($config['convert_manual_orient'] && ($this->format == 'jpg' || $this->format == 'jpeg'))
$convert_args = str_replace('-auto-orient', ImageConvert::jpeg_exif_orientation($this->src), $config['convert_args']); $convert_args = str_replace('-auto-orient', ImageConvert::jpeg_exif_orientation($this->src), $config['convert_args']);
@ -338,8 +340,10 @@ class ImageConvert extends ImageBase {
escapeshellarg($this->src), escapeshellarg($this->src),
$this->width, $this->width,
$this->height, $this->height,
escapeshellarg($this->temp)))) || !file_exists($this->temp)) escapeshellarg($this->temp)))) || !file_exists($this->temp)) {
$this->destroy();
error('Failed to resize image!', null, $error); error('Failed to resize image!', null, $error);
}
if ($size = $this->get_size($this->temp)) { if ($size = $this->get_size($this->temp)) {
$this->width = $size[0]; $this->width = $size[0];
$this->height = $size[1]; $this->height = $size[1];
@ -359,8 +363,10 @@ class ImageConvert extends ImageBase {
escapeshellarg($this->src . '[0]'), escapeshellarg($this->src . '[0]'),
$this->width, $this->width,
$this->height, $this->height,
escapeshellarg($this->temp)))) || !file_exists($this->temp)) escapeshellarg($this->temp)))) || !file_exists($this->temp)) {
$this->destroy();
error('Failed to resize image!', null, $error); error('Failed to resize image!', null, $error);
}
if ($size = $this->get_size($this->temp)) { if ($size = $this->get_size($this->temp)) {
$this->width = $size[0]; $this->width = $size[0];
$this->height = $size[1]; $this->height = $size[1];

View File

@ -379,7 +379,7 @@ function mod_edit_board($boardName) {
$query->bindValue(':uri', $board['uri'], PDO::PARAM_INT); $query->bindValue(':uri', $board['uri'], PDO::PARAM_INT);
$query->execute() or error(db_error($query)); $query->execute() or error(db_error($query));
$query = prepare("SELECT `board`, `post` FROM ``cites`` WHERE `target_board` = :board"); $query = prepare("SELECT `board`, `post` FROM ``cites`` WHERE `target_board` = :board ORDER BY `board`");
$query->bindValue(':board', $board['uri']); $query->bindValue(':board', $board['uri']);
$query->execute() or error(db_error($query)); $query->execute() or error(db_error($query));
while ($cite = $query->fetch(PDO::FETCH_ASSOC)) { while ($cite = $query->fetch(PDO::FETCH_ASSOC)) {
@ -391,6 +391,9 @@ function mod_edit_board($boardName) {
} }
} }
if (isset($tmp_board))
$board = $tmp_board;
$query = prepare('DELETE FROM ``cites`` WHERE `board` = :board OR `target_board` = :board'); $query = prepare('DELETE FROM ``cites`` WHERE `board` = :board OR `target_board` = :board');
$query->bindValue(':board', $board['uri']); $query->bindValue(':board', $board['uri']);
$query->execute() or error(db_error($query)); $query->execute() or error(db_error($query));
@ -1156,7 +1159,7 @@ function mod_move($originBoard, $postID) {
if ($post['has_file']) { if ($post['has_file']) {
// copy image // copy image
$clone($file_src, sprintf($config['board_path'], $board['uri']) . $config['dir']['img'] . $post['file']); $clone($file_src, sprintf($config['board_path'], $board['uri']) . $config['dir']['img'] . $post['file']);
if (!in_array($post['thumb'], array('spoiler', 'deleted'))) if (!in_array($post['thumb'], array('spoiler', 'deleted', 'file')))
$clone($file_thumb, sprintf($config['board_path'], $board['uri']) . $config['dir']['thumb'] . $post['thumb']); $clone($file_thumb, sprintf($config['board_path'], $board['uri']) . $config['dir']['thumb'] . $post['thumb']);
} }
@ -1346,6 +1349,8 @@ function mod_ban_post($board, $delete, $post, $token = false) {
modLog("Deleted post #{$post}"); modLog("Deleted post #{$post}");
// Rebuild board // Rebuild board
buildIndex(); buildIndex();
// Rebuild themes
rebuildThemes('post-delete', $board['uri']);
} }
header('Location: ?/' . sprintf($config['board_path'], $board) . $config['file_index'], true, $config['redirect_http']); header('Location: ?/' . sprintf($config['board_path'], $board) . $config['file_index'], true, $config['redirect_http']);
@ -1410,6 +1415,8 @@ function mod_edit_post($board, $edit_raw_html, $postID) {
buildIndex(); buildIndex();
rebuildThemes('post', $board);
header('Location: ?/' . sprintf($config['board_path'], $board) . $config['dir']['res'] . sprintf($config['file_page'], $post['thread'] ? $post['thread'] : $postID) . '#' . $postID, true, $config['redirect_http']); header('Location: ?/' . sprintf($config['board_path'], $board) . $config['dir']['res'] . sprintf($config['file_page'], $post['thread'] ? $post['thread'] : $postID) . '#' . $postID, true, $config['redirect_http']);
} else { } else {
if ($config['minify_html']) { if ($config['minify_html']) {
@ -1438,7 +1445,8 @@ function mod_delete($board, $post) {
modLog("Deleted post #{$post}"); modLog("Deleted post #{$post}");
// Rebuild board // Rebuild board
buildIndex(); buildIndex();
// Rebuild themes
rebuildThemes('post-delete', $board['uri']);
// Redirect // Redirect
header('Location: ?/' . sprintf($config['board_path'], $board) . $config['file_index'], true, $config['redirect_http']); header('Location: ?/' . sprintf($config['board_path'], $board) . $config['file_index'], true, $config['redirect_http']);
} }
@ -1459,6 +1467,8 @@ function mod_deletefile($board, $post) {
// Rebuild board // Rebuild board
buildIndex(); buildIndex();
// Rebuild themes
rebuildThemes('post-delete', $board['uri']);
// Redirect // Redirect
header('Location: ?/' . sprintf($config['board_path'], $board) . $config['file_index'], true, $config['redirect_http']); header('Location: ?/' . sprintf($config['board_path'], $board) . $config['file_index'], true, $config['redirect_http']);
@ -1498,6 +1508,9 @@ function mod_spoiler_image($board, $post) {
// Rebuild board // Rebuild board
buildIndex(); buildIndex();
// Rebuild themes
rebuildThemes('post-delete', $board['uri']);
// Redirect // Redirect
header('Location: ?/' . sprintf($config['board_path'], $board) . $config['file_index'], true, $config['redirect_http']); header('Location: ?/' . sprintf($config['board_path'], $board) . $config['file_index'], true, $config['redirect_http']);
} }
@ -1547,6 +1560,8 @@ function mod_deletebyip($boardName, $post, $global = false) {
deletePost($post['id'], false, false); deletePost($post['id'], false, false);
rebuildThemes('post-delete', $board['uri']);
if ($post['thread']) if ($post['thread'])
$threads_to_rebuild[$post['board']][$post['thread']] = true; $threads_to_rebuild[$post['board']][$post['thread']] = true;
else else

View File

@ -26,7 +26,8 @@ function load_twig() {
$loader->setPaths($config['dir']['template']); $loader->setPaths($config['dir']['template']);
$twig = new Twig_Environment($loader, array( $twig = new Twig_Environment($loader, array(
'autoescape' => false, 'autoescape' => false,
'cache' => "{$config['dir']['template']}/cache", 'cache' => is_writable('templates') && (!is_dir('templates/cache') || is_writable('templates/cache')) ?
"{$config['dir']['template']}/cache" : false,
'debug' => $config['debug'] 'debug' => $config['debug']
)); ));
$twig->addExtension(new Twig_Extensions_Extension_Tinyboard()); $twig->addExtension(new Twig_Extensions_Extension_Tinyboard());

View File

@ -1,7 +1,7 @@
<?php <?php
// Installation/upgrade file // Installation/upgrade file
define('VERSION', 'v0.9.6-dev-12 + <a href="https://int.vichan.net/devel/">vichan-devel-4.0.11-gold</a>'); define('VERSION', 'v0.9.6-dev-14 + <a href="https://int.vichan.net/devel/">vichan-devel-4.0.12</a>');
require 'inc/functions.php'; require 'inc/functions.php';
@ -377,6 +377,12 @@ if (file_exists($config['has_installed'])) {
} }
case 'v0.9.6-dev-12': case 'v0.9.6-dev-12':
case 'v0.9.6-dev-12 + <a href="https://int.vichan.net/devel/">vichan-devel-4.0.10</a>': case 'v0.9.6-dev-12 + <a href="https://int.vichan.net/devel/">vichan-devel-4.0.10</a>':
case 'v0.9.6-dev-12 + <a href="https://int.vichan.net/devel/">vichan-devel-4.0.11-gold</a>':
foreach ($boards as &$board) {
query(sprintf("ALTER TABLE ``posts_%s`` ADD INDEX `ip` (`ip`)", $board['uri'])) or error(db_error());
}
case 'v0.9.6-dev-13':
query("ALTER TABLE ``antispam`` ADD INDEX `expires` (`expires`)") or error(db_error());
case false: case false:
// Update version number // Update version number
file_write($config['has_installed'], VERSION); file_write($config['has_installed'], VERSION);
@ -525,6 +531,13 @@ if ($step == 0) {
'required' => false, 'required' => false,
'message' => '(Optional) `identify` was not found or executable; command-line ImageMagick image processing cannot be enabled.', 'message' => '(Optional) `identify` was not found or executable; command-line ImageMagick image processing cannot be enabled.',
), ),
array(
'category' => 'Image processing',
'name' => '`gm` (command-line GraphicsMagick)',
'result' => $can_exec && shell_exec('which gm'),
'required' => false,
'message' => '(Optional) `gm` was not found or executable; command-line GraphicsMagick (faster than ImageMagick) cannot be enabled.',
),
array( array(
'category' => 'Image processing', 'category' => 'Image processing',
'name' => '`gifsicle` (command-line animted GIF thumbnailing)', 'name' => '`gifsicle` (command-line animted GIF thumbnailing)',
@ -539,12 +552,27 @@ if ($step == 0) {
'required' => true, 'required' => true,
'message' => 'Tinyboard does not have permission to create directories (boards) here. You will need to <code>chmod</code> (or operating system equivalent) appropriately.' 'message' => 'Tinyboard does not have permission to create directories (boards) here. You will need to <code>chmod</code> (or operating system equivalent) appropriately.'
), ),
array(
'category' => 'File permissions',
'name' => getcwd() . '/templates/cache',
'result' => is_writable('templates') && (!is_dir('templates/cache') || is_writable('templates/cache')),
'required' => true,
'message' => 'You must give Tinyboard permission to create (and write to) the <code>templates/cache</code> directory or performance will be drastically reduced.'
),
array( array(
'category' => 'File permissions', 'category' => 'File permissions',
'name' => getcwd() . '/inc/instance-config.php', 'name' => getcwd() . '/inc/instance-config.php',
'result' => is_writable('inc/instance-config.php'), 'result' => is_writable('inc/instance-config.php'),
'required' => false, 'required' => false,
'message' => 'Tinyboard does not have permission to make changes to inc/instance-config.php. To complete the installation, you will be asked to manually copy and paste code into the file instead.' 'message' => 'Tinyboard does not have permission to make changes to <code>inc/instance-config.php</code>. To complete the installation, you will be asked to manually copy and paste code into the file instead.'
),
array(
'category' => 'Misc',
'name' => 'Caching available (APC, XCache, Memcached or Redis)',
'result' => extension_loaded('apc') || extension_loaded('xcache')
|| extension_loaded('memcached') || extension_loaded('redis'),
'required' => false,
'message' => 'You will not be able to enable the additional caching system, designed to minimize SQL queries and significantly improve performance. <a href="http://php.net/manual/en/book.apc.php">APC</a> is the recommended method of caching, but <a href="http://xcache.lighttpd.net/">XCache</a>, <a href="http://www.php.net/manual/en/intro.memcached.php">Memcached</a> and <a href="http://pecl.php.net/package/redis">Redis</a> are also supported.'
), ),
array( array(
'category' => 'Misc', 'category' => 'Misc',

View File

@ -29,7 +29,8 @@ CREATE TABLE IF NOT EXISTS `antispam` (
`expires` int(11) DEFAULT NULL, `expires` int(11) DEFAULT NULL,
`passed` smallint(6) NOT NULL, `passed` smallint(6) NOT NULL,
PRIMARY KEY (`hash`), PRIMARY KEY (`hash`),
KEY `board` (`board`,`thread`) KEY `board` (`board`,`thread`),
KEY `expires` (`expires`)
) ENGINE=MyISAM DEFAULT CHARSET=ascii COLLATE=ascii_bin; ) ENGINE=MyISAM DEFAULT CHARSET=ascii COLLATE=ascii_bin;
-- -------------------------------------------------------- -- --------------------------------------------------------

View File

@ -76,6 +76,9 @@ if (isset($_POST['delete'])) {
buildIndex(); buildIndex();
rebuildThemes('post-delete', $board['uri']);
$is_mod = isset($_POST['mod']) && $_POST['mod']; $is_mod = isset($_POST['mod']) && $_POST['mod'];
$root = $is_mod ? $config['root'] . $config['file_mod'] . '?/' : $config['root']; $root = $is_mod ? $config['root'] . $config['file_mod'] . '?/' : $config['root'];
@ -275,14 +278,19 @@ if (isset($_POST['delete'])) {
if (!preg_match($config['url_regex'], $post['file_url'])) if (!preg_match($config['url_regex'], $post['file_url']))
error($config['error']['invalidimg']); error($config['error']['invalidimg']);
if (mb_strpos($post['file_url'], '?') !== false)
$url_without_params = mb_substr($post['file_url'], 0, mb_strpos($post['file_url'], '?'));
else
$url_without_params = $post['file_url'];
$post['extension'] = strtolower(mb_substr($post['file_url'], mb_strrpos($post['file_url'], '.') + 1)); $post['extension'] = strtolower(mb_substr($url_without_params, mb_strrpos($url_without_params, '.') + 1));
if (!in_array($post['extension'], $config['allowed_ext']) && !in_array($post['extension'], $config['allowed_ext_files'])) if (!in_array($post['extension'], $config['allowed_ext']) && !in_array($post['extension'], $config['allowed_ext_files']))
error($config['error']['unknownext']); error($config['error']['unknownext']);
$post['file_tmp'] = tempnam($config['tmp'], 'url'); $post['file_tmp'] = tempnam($config['tmp'], 'url');
function unlink_tmp_file($file) { function unlink_tmp_file($file) {
@unlink($file); @unlink($file);
fatal_error_handler();
} }
register_shutdown_function('unlink_tmp_file', $post['file_tmp']); register_shutdown_function('unlink_tmp_file', $post['file_tmp']);
@ -307,7 +315,7 @@ if (isset($_POST['delete'])) {
fclose($fp); fclose($fp);
$_FILES['file'] = array( $_FILES['file'] = array(
'name' => basename($post['file_url']), 'name' => basename($url_without_params),
'tmp_name' => $post['file_tmp'], 'tmp_name' => $post['file_tmp'],
'error' => 0, 'error' => 0,
'size' => filesize($post['file_tmp']) 'size' => filesize($post['file_tmp'])
@ -520,7 +528,8 @@ if (isset($_POST['delete'])) {
escapeshellarg($upload)); escapeshellarg($upload));
if ($config['use_exiftool'] && !$config['strip_exif']) { if ($config['use_exiftool'] && !$config['strip_exif']) {
if ($exiftool_error = shell_exec_error( if ($exiftool_error = shell_exec_error(
'exiftool -q -orientation=1 -n ' . escapeshellarg($upload))) 'exiftool -overwrite_original -q -q -orientation=1 -n ' .
escapeshellarg($upload)))
error('exiftool failed!', null, $exiftool_error); error('exiftool failed!', null, $exiftool_error);
} else { } else {
// TODO: Find another way to remove the Orientation tag from the EXIF profile // TODO: Find another way to remove the Orientation tag from the EXIF profile
@ -583,7 +592,8 @@ if (isset($_POST['delete'])) {
if ($config['redraw_image'] || (!@$post['exif_stripped'] && $config['strip_exif'] && ($post['extension'] == 'jpg' || $post['extension'] == 'jpeg'))) { if ($config['redraw_image'] || (!@$post['exif_stripped'] && $config['strip_exif'] && ($post['extension'] == 'jpg' || $post['extension'] == 'jpeg'))) {
if (!$config['redraw_image'] && $config['use_exiftool']) { if (!$config['redraw_image'] && $config['use_exiftool']) {
if($error = shell_exec_error('exiftool -ignoreMinorErrors -q -q -all= ' . escapeshellarg($upload))) if($error = shell_exec_error('exiftool -overwrite_original -ignoreMinorErrors -q -q -all= ' .
escapeshellarg($upload)))
error('Could not strip EXIF metadata!', null, $error); error('Could not strip EXIF metadata!', null, $error);
} else { } else {
$image->to($post['file']); $image->to($post['file']);

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

0
stylesheets/img/rect820.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 37 KiB

0
stylesheets/img/rect821.png Executable file → Normal file
View File

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 38 KiB

88
stylesheets/notsuba.css Normal file
View File

@ -0,0 +1,88 @@
/**
* notsuba.css
* Tagechan is the best
* you are forbidden by law from making any unauthorized edits to this file. I-I'll sue! ;_;
*/
body {
background: #f2edd0
}
a:link, a:visited {
text-decoration: none;
color: #608673;
}
a:link:hover, a:visited:hover {
color: #DD0000;
}
a.post_no {
color: #000033;
}
p.intro a.email span.name {
color: #608673;
}
p.intro a.email:hover span.name {
color: #DD0000;
}
h2, div.title, h1 {
color: #800000;
}
form table tr th {
background: #ded8b7;
}
div.banner {
background-color: #E04000;
}
div.post.op hr {
border-color: #608673;
}
p.intro span.subject {
color: #8a2e2e;
font-weight: 800;
}
p.intro span.name {
color: #117743;
font-weight: 800;
}
div.post.reply.highlighted {
background: #dcae9b;
}
div.post.reply {
background: #e9d1be;
border-color: #dcae9b;
}
div.ban {
border: 1px solid #B0C2B9;
}
div.ban h2 {
background: #e9d1be;
color: #608673;
}
div.pages {
color: #8899AA;
background: #e9d1be;
border-right: 1px solid #8FCCCD;
border-bottom: 1px solid #8FCCCD;
}
hr {
border-color: #B0C2B9;
}
div.boardlist {
color: #608673;
}

View File

@ -28,6 +28,7 @@ CREATE TABLE IF NOT EXISTS ``posts_{{ board }}`` (
UNIQUE KEY `id` (`id`), UNIQUE KEY `id` (`id`),
KEY `thread_id` (`thread`,`id`), KEY `thread_id` (`thread`,`id`),
KEY `time` (`time`), KEY `time` (`time`),
FULLTEXT KEY `body` (`body`) FULLTEXT KEY `body` (`body`),
KEY `ip` (`ip`),
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=1 ; ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=1 ;

View File

@ -20,7 +20,7 @@
$b = new Catalog(); $b = new Catalog();
$b->build($settings, $board); $b->build($settings, $board);
} }
} elseif ($action == 'post-thread' || ($settings['update_on_posts'] && $action == 'post') && in_array($board, $boards)) { } elseif ($action == 'post-thread' || ($settings['update_on_posts'] && $action == 'post') || ($settings['update_on_posts'] && $action == 'post-delete') && in_array($board, $boards)) {
$b = new Catalog(); $b = new Catalog();
$b->build($settings, $board); $b->build($settings, $board);
} }

View File

@ -24,7 +24,7 @@
$this->excluded = explode(' ', $settings['exclude']); $this->excluded = explode(' ', $settings['exclude']);
if ($action == 'all' || $action == 'post' || $action == 'post-thread') if ($action == 'all' || $action == 'post' || $action == 'post-thread' || $action == 'post-delete')
file_write($config['dir']['home'] . $settings['html'], $this->homepage($settings)); file_write($config['dir']['home'] . $settings['html'], $this->homepage($settings));
} }

View File

@ -36,6 +36,15 @@
'size' => '20' 'size' => '20'
); );
$theme['config'][] = Array(
'title' => 'Minimum time between regenerating',
'name' => 'regen_time',
'type' => 'text',
'comment' => '(in seconds)',
'default' => '0',
'size' => '8'
);
$__boards = listBoards(); $__boards = listBoards();
$__default_boards = Array(); $__default_boards = Array();
foreach ($__boards as $__board) foreach ($__boards as $__board)

View File

@ -11,9 +11,16 @@
// - post (a post has been made) // - post (a post has been made)
// - thread (a thread has been made) // - thread (a thread has been made)
if ($action != 'post' && $action != 'post-thread') if ($action != 'post-thread' && $action != 'post-delete')
return; return;
if ($settings['regen_time'] > 0) {
if ($last_gen = @filemtime($settings['path'])) {
if (time() - $last_gen < (int)$settings['regen_time'])
return; // Too soon
}
}
$boards = explode(' ', $settings['boards']); $boards = explode(' ', $settings['boards']);
$threads = array(); $threads = array();