diff --git a/imgboard.php b/imgboard.php index 7597a80..5939087 100644 --- a/imgboard.php +++ b/imgboard.php @@ -160,7 +160,9 @@ if (isset($_POST['message']) || isset($_POST['file'])) { rebuildThread($post['parent']); if (strtolower($post['email']) != 'sage') { - bumpThreadByID($post['parent']); + if (TINYIB_MAXREPLIES == 0 || numRepliesToThreadByID($id) > TINYIB_MAXREPLIES) { + bumpThreadByID($post['parent']); + } } } else { rebuildThread($post['id']); diff --git a/inc/database_flatfile.php b/inc/database_flatfile.php index 886e97f..80e5cdd 100644 --- a/inc/database_flatfile.php +++ b/inc/database_flatfile.php @@ -141,6 +141,11 @@ function allThreads() { return convertPostsToSQLStyle($rows); } +function numRepliesToThreadByID($id) { + $rows = $GLOBALS['db']->selectWhere(POSTS_FILE, new SimpleWhereClause(POST_PARENT, '=', $id, INTEGER_COMPARISON)); + return count($rows); +} + function postsInThreadByID($id) { $compClause = new OrWhereClause(); $compClause->add(new SimpleWhereClause(POST_ID, '=', $id, INTEGER_COMPARISON)); diff --git a/inc/database_mysql.php b/inc/database_mysql.php index ea13084..08deef9 100644 --- a/inc/database_mysql.php +++ b/inc/database_mysql.php @@ -82,7 +82,7 @@ function bumpThreadByID($id) { mysql_query("UPDATE `" . TINYIB_DBPOSTS . "` SET `bumped` = " . time() . " WHERE `id` = " . $id . " LIMIT 1"); } -function countThreads() { +function countThreads() { return mysql_result(mysql_query("SELECT COUNT(*) FROM `" . TINYIB_DBPOSTS . "` WHERE `parent` = 0"), 0, 0); } @@ -97,6 +97,10 @@ function allThreads() { return $threads; } +function numRepliesToThreadByID($id) { + return mysql_result(mysql_query("SELECT COUNT(*) FROM `" . TINYIB_DBPOSTS . "` WHERE `parent` = " . $id), 0, 0); +} + function postsInThreadByID($id) { $posts = array(); $result = mysql_query("SELECT * FROM `" . TINYIB_DBPOSTS . "` WHERE `id` = " . $id . " OR `parent` = " . $id . " ORDER BY `id` ASC"); diff --git a/inc/database_sqlite.php b/inc/database_sqlite.php index 470121f..f72bd31 100644 --- a/inc/database_sqlite.php +++ b/inc/database_sqlite.php @@ -84,6 +84,10 @@ function allThreads() { return $threads; } +function numRepliesToThreadByID($id) { + return sqlite_fetch_single(sqlite_query($GLOBALS["db"], "SELECT COUNT(*) FROM " . TINYIB_DBPOSTS . " WHERE parent = " . $id)); +} + function postsInThreadByID($id) { $posts = array(); $result = sqlite_fetch_all(sqlite_query($GLOBALS["db"], "SELECT * FROM " . TINYIB_DBPOSTS . " WHERE id = " . $id . " OR parent = " . $id . " ORDER BY id ASC"), SQLITE_ASSOC); diff --git a/inc/defines.php b/inc/defines.php index 832d607..3478041 100644 --- a/inc/defines.php +++ b/inc/defines.php @@ -4,4 +4,8 @@ if (!defined('TINYIB_BOARD')) { die(''); } define('TINYIB_NEWTHREAD', '0'); define('TINYIB_INDEXPAGE', false); define('TINYIB_RESPAGE', true); + +// The following are provided for backward compatibility and should not be relied upon +// Copy new settings from settings.default.php to settings.php +if (!defined('TINYIB_MAXREPLIES')) { define('TINYIB_MAXREPLIES', 0); } ?> \ No newline at end of file diff --git a/settings.default.php b/settings.default.php index 08800fe..89791a1 100644 --- a/settings.default.php +++ b/settings.default.php @@ -5,6 +5,7 @@ define('TINYIB_THREADSPERPAGE', 10); // Amount of threads shown per index page define('TINYIB_MAXTHREADS', 100); // Oldest threads are discarded over this limit [0 to disable] define('TINYIB_TRUNCATE', 15); // Messages are truncated to this many lines on board index pages [0 to disable] define('TINYIB_PREVIEWREPLIES', 3); // Amount of replies previewed on index pages +define('TINYIB_MAXREPLIES', 0); // Maximum replies before a thread stops bumping [0 to disable] define('TINYIB_MAXKB', 2048); // Maximum file size in kilobytes [0 to disable] define('TINYIB_MAXKBDESC', "2 MB"); // Human-readable representation of the maximum file size define('TINYIB_MAXW', 250); // Maximum image width