forked from leftypol/leftypol
Adds delete by IP excluded IP array, and config to exclude threads from delete by IP
This commit is contained in:
parent
09a79093bd
commit
e11c12bef5
|
@ -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;
|
||||
|
|
|
@ -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…
Reference in New Issue
Block a user