Browse Source

Adds delete by IP excluded IP array, and config to exclude threads from delete by IP

block_mass_delete_threads
Your Name 2 years ago
parent
commit
e11c12bef5
  1. 5
      inc/config.php
  2. 14
      inc/mod/pages.php

5
inc/config.php

@ -1375,6 +1375,11 @@
* Mod settings
* ====================
*/
// Exclude these IPs from "delete by IP", meaning clicking D+ or D++ won't affect these IPs.
$config['deletebyip_excluded_ips'] = array();
// If true, D+ and D++ won't affect threads. This means threads will need to be deleted manually (using D).
$config['deletebyip_exclude_threads'] = false;
// Limit how many bans can be removed via the ban list. Set to false (or zero) for no limit.
$config['mod']['unban_limit'] = false;

14
inc/mod/pages.php

@ -2214,14 +2214,22 @@ function mod_deletebyip($boardName, $post, $global = false) {
if (!$ip = $query->fetchColumn())
error($config['error']['invalidpost']);
// HACK: Prevent D+ or D++ deletion of Tor node or migration placeholder IP
if ($ip == "127.0.0.1" || $ip == "127.0.0.2") {error("Don't nuke ".$ip);}
if (in_array($ip, $config['deletebyip_excluded_ips'])) {
error("The following IP is protected by the deletebyip_excluded_ips configuration ".$ip);
}
$threadFilter = $config['deletebyip_exclude_threads'] ? "" : "AND `thread` IS NOT NULL";
$boards = $global ? listBoards() : array(array('uri' => $boardName));
$query = '';
foreach ($boards as $_board) {
$query .= sprintf("SELECT `thread`, `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 %s UNION ALL ",
$_board['uri'],
$_board['uri'],
$threadFilter
);
}
$query = preg_replace('/UNION ALL $/', '', $query);

Loading…
Cancel
Save