summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
authorMacil Tech <maciltech@gmail.com>2012-09-04 00:21:04 -0600
committerMacil Tech <maciltech@gmail.com>2013-01-19 00:39:29 -0600
commit5628f789702d9bdbd573f1833f6258b4f26a47b4 (patch)
treea432e1666f1f03ee9507447e6b1954eb8af4bfa6 /inc
parent0092fc62ab48bb9abc84a9f0641f253e5e9f1d35 (diff)
Made deleting posts by IP more efficient.
No longer rebuilds same thread multiple times.
Diffstat (limited to 'inc')
-rw-r--r--inc/mod/pages.php23
1 files changed, 16 insertions, 7 deletions
diff --git a/inc/mod/pages.php b/inc/mod/pages.php
index 91ae8046..e90e9ff0 100644
--- a/inc/mod/pages.php
+++ b/inc/mod/pages.php
@@ -1052,7 +1052,7 @@ function mod_deletebyip($boardName, $post, $global = false) {
$query = '';
foreach ($boards as $_board) {
- $query .= sprintf("SELECT `id`, '%s' AS `board` FROM `posts_%s` WHERE `ip` = :ip UNION ALL ", $_board['uri'], $_board['uri']);
+ $query .= sprintf("SELECT `thread`, `id`, '%s' AS `board` FROM `posts_%s` WHERE `ip` = :ip UNION ALL ", $_board['uri'], $_board['uri']);
}
$query = preg_replace('/UNION ALL $/', '', $query);
@@ -1063,18 +1063,27 @@ function mod_deletebyip($boardName, $post, $global = false) {
if ($query->rowCount() < 1)
error($config['error']['invalidpost']);
- $boards = array();
+ set_time_limit($config['mod']['rebuild_timelimit']);
+
+ $threads_to_rebuild = array();
+ $threads_deleted = array();
while ($post = $query->fetch()) {
openBoard($post['board']);
- $boards[] = $post['board'];
- deletePost($post['id'], false);
+ deletePost($post['id'], false, false);
+
+ if ($post['thread'])
+ $threads_to_rebuild[$post['board']][$post['thread']] = true;
+ else
+ $threads_deleted[$post['board']][$post['id']] = true;
}
- $boards = array_unique($boards);
-
- foreach ($boards as $_board) {
+ foreach ($threads_to_rebuild as $_board => $_threads) {
openBoard($_board);
+ foreach ($_threads as $_thread => $_dummy) {
+ if ($_dummy && !isset($threads_deleted[$_board][$_thread]))
+ buildThread($_thread);
+ }
buildIndex();
}