diff --git a/inc/cache.php b/inc/cache.php index fd89be13..2f3c746c 100644 --- a/inc/cache.php +++ b/inc/cache.php @@ -66,7 +66,7 @@ class Cache { return $data; } public static function set($key, $value, $expires = false) { - global $config; + global $config, $debug; $key = $config['cache']['prefix'] . $key; diff --git a/inc/config.php b/inc/config.php index 1d3321ce..fddeae9a 100644 --- a/inc/config.php +++ b/inc/config.php @@ -88,12 +88,12 @@ $config['db']['database'] = ''; // Table prefix (optional) $config['db']['prefix'] = ''; - // Use a persistent connection (experimental; benefits unknown) + // Use a persistent database connection when possible $config['db']['persistent'] = false; // Anything more to add to the DSN string (eg. port=xxx;foo=bar) $config['db']['dsn'] = ''; - // Timeout duration in seconds (not all drivers support this) - $config['db']['timeout'] = 5; + // Connection timeout duration in seconds + $config['db']['timeout'] = 30; /* * ==================== diff --git a/inc/database.php b/inc/database.php index 8daa20b4..55e1ff81 100644 --- a/inc/database.php +++ b/inc/database.php @@ -28,13 +28,13 @@ class PreparedQueryDebug { $return = call_user_func_array(array($this->query, $function), $args); if ($config['debug'] && $function == 'execute') { - $time = round((microtime(true) - $start) * 1000, 2) . 'ms'; - + $time = microtime(true) - $start; $debug['sql'][] = array( 'query' => $this->query->queryString, 'rows' => $this->query->rowCount(), - 'time' => '~' . $time + 'time' => '~' . round($time * 1000, 2) . 'ms' ); + $debug['time']['db_queries'] += $time; } return $return; @@ -42,10 +42,14 @@ class PreparedQueryDebug { } function sql_open() { - global $pdo, $config; + global $pdo, $config, $debug; if ($pdo) return true; + + if ($config['debug']) + $start = microtime(true); + if (isset($config['db']['server'][0]) && $config['db']['server'][0] == ':') $unix_socket = substr($config['db']['server'], 1); else @@ -64,6 +68,10 @@ function sql_open() { if ($config['db']['persistent']) $options[PDO::ATTR_PERSISTENT] = true; $pdo = new PDO($dsn, $config['db']['user'], $config['db']['password'], $options); + + if ($config['debug']) + $debug['time']['db_connect'] = '~' . round((microtime(true) - $start) * 1000, 2) . 'ms'; + if (mysql_version() >= 50503) query('SET NAMES utf8mb4') or error(db_error()); else @@ -117,12 +125,13 @@ function query($query) { $query = $pdo->query($query); if (!$query) return false; - $time = round((microtime(true) - $start) * 1000, 2) . 'ms'; + $time = microtime(true) - $start; $debug['sql'][] = array( 'query' => $query->queryString, 'rows' => $query->rowCount(), - 'time' => '~' . $time + 'time' => '~' . round($time * 1000, 2) . 'ms' ); + $debug['time']['db_queries'] += $time; return $query; } diff --git a/inc/display.php b/inc/display.php index 4988cbf5..736fdc03 100644 --- a/inc/display.php +++ b/inc/display.php @@ -126,7 +126,7 @@ function pm_snippet($body, $len=null) { $len = &$config['mod']['snippet_length']; // Replace line breaks with some whitespace - $body = str_replace('
', ' ', $body); + $body = preg_replace('@
@i', ' ', $body); // Strip tags $body = strip_tags($body); diff --git a/inc/functions.php b/inc/functions.php index 379f1cbe..40053133 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -81,14 +81,6 @@ function loadConfig() { $__version = file_exists('.installed') ? trim(file_get_contents('.installed')) : false; $config['version'] = $__version; - if ($config['debug']) { - if (!isset($debug)) { - $debug = array('sql' => array(), 'exec' => array(), 'purge' => array(), 'cached' => array(), 'write' => array()); - $debug['start'] = $microtime_start; - $debug['start_debug'] = microtime(true);; - } - } - date_default_timezone_set($config['timezone']); if (!isset($config['global_message'])) @@ -179,21 +171,21 @@ function loadConfig() { if (preg_match('/^\:\:(ffff\:)?(\d+\.\d+\.\d+\.\d+)$/', $__ip, $m)) $_SERVER['REMOTE_ADDR'] = $m[2]; - if (_setlocale(LC_ALL, $config['locale']) === false) { - $error('The specified locale (' . $config['locale'] . ') does not exist on your platform!'); - } - - if (extension_loaded('gettext')) { - bindtextdomain('tinyboard', './inc/locale'); - bind_textdomain_codeset('tinyboard', 'UTF-8'); - textdomain('tinyboard'); - } else { - _bindtextdomain('tinyboard', './inc/locale'); - _bind_textdomain_codeset('tinyboard', 'UTF-8'); - _textdomain('tinyboard'); + if ($config['locale'] != 'en') { + if (_setlocale(LC_ALL, $config['locale']) === false) { + $error('The specified locale (' . $config['locale'] . ') does not exist on your platform!'); + } + if (extension_loaded('gettext')) { + bindtextdomain('tinyboard', './inc/locale'); + bind_textdomain_codeset('tinyboard', 'UTF-8'); + textdomain('tinyboard'); + } else { + _bindtextdomain('tinyboard', './inc/locale'); + _bind_textdomain_codeset('tinyboard', 'UTF-8'); + _textdomain('tinyboard'); + } } - if ($config['syslog']) openlog('tinyboard', LOG_ODELAY, LOG_SYSLOG); // open a connection to sysem logger @@ -202,6 +194,25 @@ function loadConfig() { if ($config['cache']['enabled']) require_once 'inc/cache.php'; event('load-config'); + + if ($config['debug']) { + if (!isset($debug)) { + $debug = array( + 'sql' => array(), + 'exec' => array(), + 'purge' => array(), + 'cached' => array(), + 'write' => array(), + 'time' => array( + 'db_queries' => 0, + 'exec' => 0, + ), + 'start' => $microtime_start, + 'start_debug' => microtime(true) + ); + $debug['start'] = $microtime_start; + } + } } function basic_error_function_because_the_other_isnt_loaded_yet($message, $priority = true) { @@ -565,15 +576,20 @@ function listBoards() { function checkFlood($post) { global $board, $config; - $query = prepare(sprintf("SELECT * FROM ``posts_%s`` WHERE (`ip` = :ip AND `time` >= :floodtime) OR (`ip` = :ip AND `body` != '' AND `body` = :body AND `time` >= :floodsameiptime) OR (`body` != '' AND `body` = :body AND `time` >= :floodsametime) LIMIT 1", $board['uri'])); + $query = prepare(sprintf("SELECT COUNT(*) FROM ``posts_%s`` WHERE + (`ip` = :ip AND `time` >= :floodtime) + OR + (`ip` = :ip AND :body != '' AND `body_nomarkup` = :body AND `time` >= :floodsameiptime) + OR + (:body != '' AND `body_nomarkup` = :body AND `time` >= :floodsametime) LIMIT 1", $board['uri'])); $query->bindValue(':ip', $_SERVER['REMOTE_ADDR']); $query->bindValue(':body', $post['body']); $query->bindValue(':floodtime', time()-$config['flood_time'], PDO::PARAM_INT); $query->bindValue(':floodsameiptime', time()-$config['flood_time_ip'], PDO::PARAM_INT); $query->bindValue(':floodsametime', time()-$config['flood_time_same'], PDO::PARAM_INT); $query->execute() or error(db_error($query)); - - $flood = (bool) $query->fetch(PDO::FETCH_ASSOC); + + $flood = (bool) $query->fetchColumn(); if (event('check-flood', $post)) return true; @@ -650,12 +666,12 @@ function checkBan($board = 0) { if (event('check-ban', $board)) return true; - $query = prepare("SELECT `set`, `expires`, `reason`, `board`, `seen`, ``bans``.`id` FROM ``bans`` WHERE (`board` IS NULL OR `board` = :board) AND `ip` = :ip ORDER BY `expires` IS NULL DESC, `expires` DESC LIMIT 1"); + $query = prepare("SELECT `set`, `expires`, `reason`, `board`, `seen`, `id` FROM ``bans`` WHERE (`board` IS NULL OR `board` = :board) AND `ip` = :ip ORDER BY `expires` IS NULL DESC, `expires` DESC LIMIT 1"); $query->bindValue(':ip', $_SERVER['REMOTE_ADDR']); $query->bindValue(':board', $board); $query->execute() or error(db_error($query)); if ($query->rowCount() < 1 && $config['ban_range']) { - $query = prepare("SELECT `set`, `expires`, `reason`, `board`, `seen`, ``bans``.`id` FROM ``bans`` WHERE (`board` IS NULL OR `board` = :board) AND :ip LIKE REPLACE(REPLACE(`ip`, '%', '!%'), '*', '%') ESCAPE '!' ORDER BY `expires` IS NULL DESC, `expires` DESC LIMIT 1"); + $query = prepare("SELECT `set`, `expires`, `reason`, `board`, `seen`, `id` FROM ``bans`` WHERE (`board` IS NULL OR `board` = :board) AND :ip LIKE REPLACE(REPLACE(`ip`, '%', '!%'), '*', '%') ESCAPE '!' ORDER BY `expires` IS NULL DESC, `expires` DESC LIMIT 1"); $query->bindValue(':ip', $_SERVER['REMOTE_ADDR']); $query->bindValue(':board', $board); $query->execute() or error(db_error($query)); @@ -990,7 +1006,7 @@ function deletePost($id, $error_if_doesnt_exist=true, $rebuild_after=true) { $query->bindValue(':id', $id, PDO::PARAM_INT); $query->execute() or error(db_error($query)); - $query = prepare("SELECT `board`, `post` FROM ``cites`` WHERE `target_board` = :board AND (`target` = " . implode(' OR `target` = ', $ids) . ")"); + $query = prepare("SELECT `board`, `post` FROM ``cites`` WHERE `target_board` = :board AND (`target` = " . implode(' OR `target` = ', $ids) . ") ORDER BY `board`"); $query->bindValue(':board', $board['uri']); $query->execute() or error(db_error($query)); while ($cite = $query->fetch(PDO::FETCH_ASSOC)) { @@ -1005,10 +1021,10 @@ function deletePost($id, $error_if_doesnt_exist=true, $rebuild_after=true) { if (isset($tmp_board)) openBoard($tmp_board); - $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 = 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->execute() or error(db_error($query)); - + if (isset($rebuild) && $rebuild_after) { buildThread($rebuild); buildIndex(); @@ -1224,14 +1240,11 @@ function checkRobot($body) { // Returns an associative array with 'replies' and 'images' keys function numPosts($id) { global $board; - $query = prepare(sprintf("SELECT COUNT(*) FROM ``posts_%s`` WHERE `thread` = :thread UNION ALL SELECT COUNT(*) FROM ``posts_%s`` WHERE `file` IS NOT NULL AND `thread` = :thread", $board['uri'], $board['uri'])); + $query = prepare(sprintf("SELECT COUNT(*) AS `replies`, COUNT(NULLIF(`file`, 0)) AS `images` FROM ``posts_%s`` WHERE `thread` = :thread", $board['uri'], $board['uri'])); $query->bindValue(':thread', $id, PDO::PARAM_INT); $query->execute() or error(db_error($query)); - $num_posts = $query->fetchColumn(); - $num_images = $query->fetchColumn(); - - return array('replies' => $num_posts, 'images' => $num_images); + return $query->fetch(PDO::FETCH_ASSOC); } function muteTime() { @@ -1577,9 +1590,6 @@ function markup(&$body, $track_cites = false) { } } - // replace tabs with 8 spaces - $body = str_replace("\t", ' ', $body); - $tracked_cites = array(); // Cites @@ -1745,6 +1755,7 @@ function markup(&$body, $track_cites = false) { if ($config['markup_repair_tidy']) { $tidy = new tidy(); + $body = str_replace("\t", ' ', $body); $body = $tidy->repairString($body, array( 'doctype' => 'omit', 'bare' => true, @@ -1756,10 +1767,12 @@ function markup(&$body, $track_cites = false) { 'output-html' => true, 'newline' => 'LF', 'quiet' => true, - ), 'utf8'); $body = str_replace("\n", '', $body); } + + // replace tabs with 8 spaces + $body = str_replace("\t", ' ', $body); return $tracked_cites; } @@ -2154,12 +2167,13 @@ function shell_exec_error($command, $suppress_stdout = false) { $return = preg_replace('/TB_SUCCESS$/', '', $return); if ($config['debug']) { - $time = round((microtime(true) - $start) * 1000, 2) . 'ms'; + $time = microtime(true) - $start; $debug['exec'][] = array( 'command' => $command, - 'time' => '~' . $time, + 'time' => '~' . round($time * 1000, 2) . 'ms', 'response' => $return ? $return : null ); + $debug['time']['exec'] += $time; } return $return === 'TB_SUCCESS' ? false : $return; diff --git a/inc/mod/pages.php b/inc/mod/pages.php index 31f1960d..2bd33926 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -92,7 +92,7 @@ function mod_dashboard() { } } - if (!$config['cache']['enabled'] || ($args['unread_pms'] = cache::get('pm_unreadcount_' . $mod['id'])) == false) { + if (!$config['cache']['enabled'] || ($args['unread_pms'] = cache::get('pm_unreadcount_' . $mod['id'])) === false) { $query = prepare('SELECT COUNT(*) FROM ``pms`` WHERE `to` = :id AND `unread` = 1'); $query->bindValue(':id', $mod['id']); $query->execute() or error(db_error($query)); @@ -1109,7 +1109,7 @@ function mod_move_reply($originBoard, $postID) { } function mod_move($originBoard, $postID) { - global $board, $config, $mod; + global $board, $config, $mod, $pdo; if (!openBoard($originBoard)) error($config['error']['noboard']); @@ -1226,13 +1226,14 @@ function mod_move($originBoard, $postID) { $clone($post['file_thumb'], sprintf($config['board_path'], $board['uri']) . $config['dir']['thumb'] . $post['thumb']); } - foreach ($post['tracked_cites'] as $cite) { - $query = prepare('INSERT INTO ``cites`` VALUES (:board, :post, :target_board, :target)'); - $query->bindValue(':board', $board['uri']); - $query->bindValue(':post', $newPostID, PDO::PARAM_INT); - $query->bindValue(':target_board',$cite[0]); - $query->bindValue(':target', $cite[1], PDO::PARAM_INT); - $query->execute() or error(db_error($query)); + if (!empty($post['tracked_cites'])) { + $insert_rows = array(); + foreach ($post['tracked_cites'] as $cite) { + $insert_rows[] = '(' . + $pdo->quote($board['uri']) . ', ' . $newPostID . ', ' . + $pdo->quote($cite[0]) . ', ' . (int)$cite[1] . ')'; + } + query('INSERT INTO ``cites`` VALUES ' . implode(', ', $insert_rows)) or error(db_error()); } } @@ -1424,6 +1425,8 @@ function mod_edit_post($board, $edit_raw_html, $postID) { $post['body'] = str_replace("\n", ' ', utf8tohtml($post['body'])); $post['body_nomarkup'] = str_replace("\r", '', $post['body_nomarkup']); $post['body'] = str_replace("\r", '', $post['body']); + $post['body_nomarkup'] = str_replace("\t", ' ', $post['body_nomarkup']); + $post['body'] = str_replace("\t", ' ', $post['body']); } mod_page(_('Edit post'), 'mod/edit_post_form.html', array('token' => $security_token, 'board' => $board, 'raw' => $edit_raw_html, 'post' => $post)); diff --git a/inc/template.php b/inc/template.php index 6d417631..378f36d0 100644 --- a/inc/template.php +++ b/inc/template.php @@ -45,19 +45,23 @@ function Element($templateFile, array $options) { } if (isset($options['body']) && $config['debug']) { + $_debug = $debug; + if (isset($debug['start'])) { - $debug['time'] = '~' . round((microtime(true) - $debug['start']) * 1000, 2) . 'ms'; - $debug['time (initialization)'] = '~' . round(($debug['start_debug'] - $debug['start']) * 1000, 2) . 'ms'; - unset($debug['start']); - unset($debug['start_debug']); + $_debug['time']['total'] = '~' . round((microtime(true) - $_debug['start']) * 1000, 2) . 'ms'; + $_debug['time']['init'] = '~' . round(($_debug['start_debug'] - $_debug['start']) * 1000, 2) . 'ms'; + unset($_debug['start']); + unset($_debug['start_debug']); } if ($config['try_smarter'] && isset($build_pages) && !empty($build_pages)) - $debug['build_pages'] = $build_pages; - $debug['included'] = get_included_files(); - $debug['memory'] = round(memory_get_usage(true) / (1024 * 1024), 2) . ' MiB'; + $_debug['build_pages'] = $build_pages; + $_debug['included'] = get_included_files(); + $_debug['memory'] = round(memory_get_usage(true) / (1024 * 1024), 2) . ' MiB'; + $_debug['time']['db_queries'] = '~' . round($_debug['time']['db_queries'] * 1000, 2) . 'ms'; + $_debug['time']['exec'] = '~' . round($_debug['time']['exec'] * 1000, 2) . 'ms'; $options['body'] .= '

Debug

' .
-				str_replace("\n", '
', utf8tohtml(print_r($debug, true))) . + str_replace("\n", '
', utf8tohtml(print_r($_debug, true))) . '
'; } diff --git a/install.php b/install.php index e3e8a3e2..808529ab 100644 --- a/install.php +++ b/install.php @@ -1,7 +1,7 @@ vichan-devel-4.0.12'); +define('VERSION', 'v0.9.6-dev-16 + vichan-devel-4.0.13'); require 'inc/functions.php'; @@ -384,6 +384,23 @@ if (file_exists($config['has_installed'])) { case 'v0.9.6-dev-13': query("ALTER TABLE ``antispam`` ADD INDEX `expires` (`expires`)") or error(db_error()); case 'v0.9.6-dev-14': + case 'v0.9.6-dev-14 + vichan-devel-4.0.12': + foreach ($boards as &$board) { + query(sprintf("ALTER TABLE ``posts_%s`` + DROP INDEX `body`, + ADD INDEX `filehash` (`filehash`(40))", $board['uri'])) or error(db_error()); + } + query("ALTER TABLE ``modlogs`` ADD INDEX `mod` (`mod`)") or error(db_error()); + query("ALTER TABLE ``bans`` DROP INDEX `ip`") or error(db_error()); + query("ALTER TABLE ``bans`` ADD INDEX `ip` (`ip`)") or error(db_error()); + query("ALTER TABLE ``noticeboard`` ADD INDEX `time` (`time`)") or error(db_error()); + query("ALTER TABLE ``pms`` ADD INDEX `to` (`to`, `unread`)") or error(db_error()); + case 'v0.9.6-dev-15': + foreach ($boards as &$board) { + query(sprintf("ALTER TABLE ``posts_%s`` + ADD INDEX `list_threads` (`thread`, `sticky`, `bump`)", $board['uri'])) or error(db_error()); + } + case 'v0.9.6-dev-16': case false: // Update version number file_write($config['has_installed'], VERSION); diff --git a/install.sql b/install.sql index 02787984..6952b540 100644 --- a/install.sql +++ b/install.sql @@ -49,7 +49,7 @@ CREATE TABLE IF NOT EXISTS `bans` ( `board` varchar(58) CHARACTER SET utf8 DEFAULT NULL, `seen` tinyint(1) NOT NULL, PRIMARY KEY (`id`), - FULLTEXT KEY `ip` (`ip`) + KEY `ip` (`ip`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=1 ; -- -------------------------------------------------------- @@ -115,7 +115,8 @@ CREATE TABLE IF NOT EXISTS `modlogs` ( `board` varchar(58) CHARACTER SET utf8 DEFAULT NULL, `time` int(11) NOT NULL, `text` text NOT NULL, - KEY `time` (`time`) + KEY `time` (`time`), + KEY `mod`(`mod`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4; -- -------------------------------------------------------- @@ -182,7 +183,8 @@ CREATE TABLE IF NOT EXISTS `noticeboard` ( `time` int(11) NOT NULL, `subject` text NOT NULL, `body` text NOT NULL, - UNIQUE KEY `id` (`id`) + UNIQUE KEY `id` (`id`), + KEY `time` (`time`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=1 ; -- -------------------------------------------------------- @@ -198,7 +200,8 @@ CREATE TABLE IF NOT EXISTS `pms` ( `message` text NOT NULL, `time` int(11) NOT NULL, `unread` tinyint(1) NOT NULL, - PRIMARY KEY (`id`) + PRIMARY KEY (`id`), + KEY `to` (`to`, `unread`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=1 ; -- -------------------------------------------------------- diff --git a/js/download-original.js b/js/download-original.js new file mode 100644 index 00000000..b7c98c35 --- /dev/null +++ b/js/download-original.js @@ -0,0 +1,35 @@ +/* + * download-original.js + * https://github.com/savetheinternet/Tinyboard/blob/master/js/download-original.js + * + * Makes image filenames clickable, allowing users to download and save files as their original filename. + * Only works in newer browsers. http://caniuse.com/#feat=download + * + * Released under the MIT license + * Copyright (c) 2012-2013 Michael Save + * + * Usage: + * $config['additional_javascript'][] = 'js/jquery.min.js'; + * $config['additional_javascript'][] = 'js/download-original.js'; + * + */ + +onready(function(){ + $('.postfilename').each(function() { + var filename, truncated; + if ($(this).attr('title')) { + filename = $(this).attr('title'); + truncated = true; + } else { + filename = $(this).text(); + } + + $(this).replaceWith( + $('') + .attr('download', filename) + .append($(this).contents()) + .attr('href', $(this).parent().parent().find('a').attr('href')) + .attr('title', _('Save as original filename') + (truncated ? ' (' + filename + ')' : '')) + ); + }); +}); diff --git a/mod.php b/mod.php index dca13dfe..ab5de9e7 100644 --- a/mod.php +++ b/mod.php @@ -8,6 +8,9 @@ require 'inc/functions.php'; require 'inc/mod/pages.php'; require 'inc/mod/auth.php'; +if ($config['debug']) + $parse_start_time = microtime(true); + // Fix for magic quotes if (get_magic_quotes_gpc()) { function strip_array($var) { @@ -159,8 +162,9 @@ foreach ($pages as $uri => $handler) { $debug['mod_page'] = array( 'req' => $query, 'match' => $uri, - 'handler' => $handler + 'handler' => $handler, ); + $debug['time']['parse_mod_req'] = '~' . round((microtime(true) - $parse_start_time) * 1000, 2) . 'ms'; } if (is_string($handler)) { diff --git a/post.php b/post.php index 9fc4be66..e45ad967 100644 --- a/post.php +++ b/post.php @@ -429,6 +429,12 @@ if (isset($_POST['delete'])) { error(sprintf($config['error']['toolong'], 'password')); wordfilters($post['body']); + + // Check for a flood + if (!hasPermission($config['mod']['flood'], $board['uri']) && checkFlood($post)) { + error($config['error']['flood']); + } + $post['body'] = escape_markup_modifiers($post['body']); if ($mod && isset($post['raw']) && $post['raw']) { @@ -465,11 +471,6 @@ if (isset($_POST['delete'])) { $post['tracked_cites'] = markup($post['body'], true); - // Check for a flood - if (!hasPermission($config['mod']['flood'], $board['uri']) && checkFlood($post)) { - error($config['error']['flood']); - } - require_once 'inc/filters.php'; do_filters($post); @@ -691,7 +692,7 @@ if (isset($_POST['delete'])) { $pdo->quote($board['uri']) . ', ' . (int)$id . ', ' . $pdo->quote($cite[0]) . ', ' . (int)$cite[1] . ')'; } - query('INSERT INTO ``cites`` VALUES ' . implode(', ', $insert_rows)) or error(db_error());; + query('INSERT INTO ``cites`` VALUES ' . implode(', ', $insert_rows)) or error(db_error()); } if (!$post['op'] && strtolower($post['email']) != 'sage' && !$thread['sage'] && ($config['reply_limit'] == 0 || $numposts['replies']+1 < $config['reply_limit'])) { diff --git a/templates/posts.sql b/templates/posts.sql index e41a7f38..c1f491f2 100644 --- a/templates/posts.sql +++ b/templates/posts.sql @@ -27,8 +27,9 @@ CREATE TABLE IF NOT EXISTS ``posts_{{ board }}`` ( `embed` text, UNIQUE KEY `id` (`id`), KEY `thread_id` (`thread`,`id`), + KEY `filehash` (`filehash`(40)), KEY `time` (`time`), - FULLTEXT KEY `body` (`body`), - KEY `ip` (`ip`) + KEY `ip` (`ip`), + KEY `list_threads` (`thread`, `sticky`, `bump`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=1 ; \ No newline at end of file