diff options
| author | Michael <savetheinternet@tinyboard.org> | 2013-06-18 10:46:25 -0700 |
|---|---|---|
| committer | Michael <savetheinternet@tinyboard.org> | 2013-06-18 10:46:25 -0700 |
| commit | 9b0c31daa68c7ab96bc25e09b70ffea77ba23590 (patch) | |
| tree | b76caac312977437540e5e2513409e4046e2ecd9 /inc | |
| parent | 0ac9dd5f25ffd9969786567cf7f3081c39f4e0c7 (diff) | |
| parent | 3eda5b054361f7312b40a14728b76841c01628d2 (diff) | |
Merge pull request #116 from Macil/hardlimits
Adds image_hard_limit and reply_hard_limit options
Diffstat (limited to 'inc')
| -rw-r--r-- | inc/config.php | 7 | ||||
| -rw-r--r-- | inc/functions.php | 19 |
2 files changed, 17 insertions, 9 deletions
diff --git a/inc/config.php b/inc/config.php index 900d540a..da9309e8 100644 --- a/inc/config.php +++ b/inc/config.php @@ -311,6 +311,11 @@ // Reply limit (stops bumping thread when this is reached) $config['reply_limit'] = 250; + // Image hard limit (stops allowing new image replies when this is reached if not zero) + $config['image_hard_limit'] = 0; + // Reply hard limit (stops allowing new replies when this is reached if not zero) + $config['reply_hard_limit'] = 0; + // Strip repeating characters when making hashes $config['robot_enable'] = false; $config['robot_strip_repeating'] = true; @@ -659,6 +664,8 @@ $config['error']['noboard'] = _('Invalid board!'); $config['error']['nonexistant'] = _('Thread specified does not exist.'); $config['error']['locked'] = _('Thread locked. You may not reply at this time.'); + $config['error']['reply_hard_limit'] = _('Thread has reached its maximum reply limit.'); + $config['error']['image_hard_limit'] = _('Thread has reached its maximum image limit.'); $config['error']['nopost'] = _('You didn\'t make a post.'); $config['error']['flood'] = _('Flood detected; Post discarded.'); $config['error']['spam'] = _('Your request looks automated; Post discarded.'); diff --git a/inc/functions.php b/inc/functions.php index 64a3ca88..70848468 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -983,12 +983,8 @@ function index($page, $mod=false) { $replies = array_reverse($posts->fetchAll(PDO::FETCH_ASSOC)); if (count($replies) == ($th['sticky'] ? $config['threads_preview_sticky'] : $config['threads_preview'])) { - $count = prepare(sprintf("SELECT COUNT(`id`) as `num` FROM `posts_%s` WHERE `thread` = :thread UNION ALL SELECT COUNT(`id`) FROM `posts_%s` WHERE `file` IS NOT NULL AND `thread` = :thread", $board['uri'], $board['uri'])); - $count->bindValue(':thread', $th['id'], PDO::PARAM_INT); - $count->execute() or error(db_error($count)); - $count = $count->fetchAll(PDO::FETCH_COLUMN); - - $omitted = array('post_count' => $count[0], 'image_count' => $count[1]); + $count = numPosts($th['id']); + $omitted = array('post_count' => $count['replies'], 'image_count' => $count['images']); } else { $omitted = false; } @@ -1131,14 +1127,19 @@ function checkRobot($body) { return false; } +// Returns an associative array with 'replies' and 'images' keys function numPosts($id) { global $board; - $query = prepare(sprintf("SELECT COUNT(*) as `count` FROM `posts_%s` WHERE `thread` = :thread", $board['uri'])); + $query = prepare(sprintf("SELECT COUNT(*) as `num` 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->bindValue(':thread', $id, PDO::PARAM_INT); $query->execute() or error(db_error($query)); - $result = $query->fetch(); - return $result['count']; + $num_posts = $query->fetch(); + $num_posts = $num_posts['num']; + $num_images = $query->fetch(); + $num_images = $num_images['num']; + + return array('replies' => $num_posts, 'images' => $num_images); } function muteTime() { |
