made D+ (delete posts by IP) global

This commit is contained in:
Savetheinternet 2011-10-10 21:07:59 +11:00
parent 85d37a55c3
commit f6a4997780

23
mod.php
View File

@ -1774,6 +1774,9 @@
// Create the posts table // Create the posts table
query(Element('posts.sql', Array('board' => $board['uri']))) or error(db_error()); query(Element('posts.sql', Array('board' => $board['uri']))) or error(db_error());
if($config['cache']['enabled'])
cache::delete('all_boards');
// Build the board // Build the board
buildIndex(); buildIndex();
@ -1952,21 +1955,35 @@
$ip = $post['ip']; $ip = $post['ip'];
// Record the action $boards = listBoards();
modLog("Deleted all posts by IP address: {$ip}"); $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->bindValue(':ip', $ip);
$query->execute() or error(db_error($query)); $query->execute() or error(db_error($query));
if($query->rowCount() < 1) if($query->rowCount() < 1)
error($config['error']['invalidpost']); error($config['error']['invalidpost']);
$boards = Array();
while($post = $query->fetch()) { while($post = $query->fetch()) {
openBoard($post['board']);
$boards[] = $post['board'];
deletePost($post['id'], false); deletePost($post['id'], false);
} }
foreach($boards as &$_board) {
openBoard($_board);
buildIndex(); 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']); header('Location: ?/' . sprintf($config['board_path'], $boardName) . $config['file_index'], true, $config['redirect_http']);
} elseif(preg_match('/^\/ban$/', $query)) { } elseif(preg_match('/^\/ban$/', $query)) {