From 05d6795abaaf4d8d3c3ead1af10916cb68b70461 Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Mon, 10 Oct 2011 21:07:59 +1100 Subject: [PATCH] made D+ (delete posts by IP) global --- mod.php | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/mod.php b/mod.php index 4ec672c7..e4b10cce 100644 --- a/mod.php +++ b/mod.php @@ -1774,6 +1774,9 @@ // Create the posts table query(Element('posts.sql', Array('board' => $board['uri']))) or error(db_error()); + if($config['cache']['enabled']) + cache::delete('all_boards'); + // Build the board buildIndex(); @@ -1952,21 +1955,35 @@ $ip = $post['ip']; - // Record the action - modLog("Deleted all posts by IP address: {$ip}"); + $boards = listBoards(); + $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 = preg_replace('/UNION ALL $/', '', $query); - $query = prepare(sprintf("SELECT `id` FROM `posts_%s` WHERE `ip` = :ip", $board['uri'])); + $query = prepare($query); $query->bindValue(':ip', $ip); $query->execute() or error(db_error($query)); if($query->rowCount() < 1) error($config['error']['invalidpost']); + $boards = Array(); while($post = $query->fetch()) { + openBoard($post['board']); + $boards[] = $post['board']; + deletePost($post['id'], false); } - buildIndex(); + foreach($boards as &$_board) { + openBoard($_board); + buildIndex(); + } + + // Record the action + modLog("Deleted all posts by IP address: {$ip}"); header('Location: ?/' . sprintf($config['board_path'], $boardName) . $config['file_index'], true, $config['redirect_http']); } elseif(preg_match('/^\/ban$/', $query)) {