1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2024-11-15 03:17:38 +01:00

Merge pull request #136 from PupperWoff/master

Added function - Ban & Delete all post by IP in one go
This commit is contained in:
PupperWoff 2017-07-25 20:28:09 +02:00 committed by GitHub
commit c1215b4897
5 changed files with 41 additions and 15 deletions

View File

@ -1600,6 +1600,7 @@ $config['nicenotice_reasons'][] = "We care, and we hope you feel better soon. We
$config['mod']['link_warningdelete'] = '[W&D]'; $config['mod']['link_warningdelete'] = '[W&D]';
$config['mod']['link_ban'] = '[B]'; $config['mod']['link_ban'] = '[B]';
$config['mod']['link_bandelete'] = '[B&D]'; $config['mod']['link_bandelete'] = '[B&D]';
$config['mod']['link_bandeletebyip'] = '[B&D+]';
$config['mod']['link_deletefile'] = '[F]'; $config['mod']['link_deletefile'] = '[F]';
$config['mod']['link_deletefilepermaban'] = '[FPb]'; $config['mod']['link_deletefilepermaban'] = '[FPb]';
$config['mod']['link_spoilerimage'] = '[S]'; $config['mod']['link_spoilerimage'] = '[S]';
@ -1782,6 +1783,8 @@ $config['nicenotice_reasons'][] = "We care, and we hope you feel better soon. We
$config['mod']['ban_all_boards'] = MOD; $config['mod']['ban_all_boards'] = MOD;
// Ban and delete (one click; instant) // Ban and delete (one click; instant)
$config['mod']['bandelete'] = MOD; $config['mod']['bandelete'] = MOD;
// Ban and delete all by ip on board (one click; instant)
$config['mod']['bandeletebyip'] = MOD;
// Remove bans // Remove bans
$config['mod']['unban'] = JANITOR; $config['mod']['unban'] = JANITOR;
// Remove a Ban on all boards even if mod isnt moderator of all boards // Remove a Ban on all boards even if mod isnt moderator of all boards

View File

@ -1909,14 +1909,23 @@ function mod_move($originBoard, $postID) {
function mod_ban_post($board, $delete, $post, $token = false) { function mod_ban_post($board, $delete, $post, $token = false) {
global $config, $mod; global $config, $mod;
if (!openBoard($board)) if (!openBoard($board))
error($config['error']['noboard']); error($config['error']['noboard']);
if (!hasPermission($config['mod']['delete'], $board)) switch($delete) {
error($config['error']['noaccess']); case '&deletebyip':
if (!hasPermission($config['mod']['deletebyip'], $board))
$security_token = make_secure_link_token($board . '/ban/' . $post); error($config['error']['noaccess']);
case '&delete':
case '':
default:
if (!hasPermission($config['mod']['delete'], $board))
error($config['error']['noaccess']);
break;
}
$security_token = make_secure_link_token($board . '/ban' . $delete . '/' . $post);
$query = prepare(sprintf('SELECT ' . ($config['ban_show_post'] ? '*' : '`ip`, `cookie`, `thread`') . $query = prepare(sprintf('SELECT ' . ($config['ban_show_post'] ? '*' : '`ip`, `cookie`, `thread`') .
' FROM ``posts_%s`` WHERE `id` = :id', $board)); ' FROM ``posts_%s`` WHERE `id` = :id', $board));
@ -1956,13 +1965,23 @@ function mod_ban_post($board, $delete, $post, $token = false) {
buildThread($thread ? $thread : $post); buildThread($thread ? $thread : $post);
buildIndex(); buildIndex();
} elseif (isset($_POST['delete']) && (int) $_POST['delete']) { } elseif (isset($_POST['delete']) && (int) $_POST['delete']) {
// Delete post
deletePostShadow($post); switch($delete) {
modLog("Deleted post #{$post}"); case '&delete':
// Rebuild board // Delete post
buildIndex(); deletePostShadow($post);
// Rebuild themes modLog("Deleted post #{$post}");
rebuildThemes('post-delete', $board); // Rebuild board
buildIndex();
// Rebuild themes
rebuildThemes('post-delete', $board);
case '&deletebyip':
mod_deletebyip($board, $post, false);
case '':
default:
break;
}
} }
header('Location: ?/' . sprintf($config['board_path'], $board) . $config['file_index'], true, $config['redirect_http']); header('Location: ?/' . sprintf($config['board_path'], $board) . $config['file_index'], true, $config['redirect_http']);
@ -1974,6 +1993,7 @@ function mod_ban_post($board, $delete, $post, $token = false) {
'uusercookie' => $cookie, 'uusercookie' => $cookie,
'post' => $post, 'post' => $post,
'board' => $board, 'board' => $board,
'delete_str' => "" . $delete,
'delete' => (bool)$delete, 'delete' => (bool)$delete,
'boards' => listBoards(), 'boards' => listBoards(),
'reasons' => $config['ban_reasons'], 'reasons' => $config['ban_reasons'],

View File

@ -100,7 +100,7 @@ $pages = array(
'/(\%b)/shadow_purge/(\d+)' => 'secure_POST shadow_purge', // permanent delete all shadow deleted post that have timed out '/(\%b)/shadow_purge/(\d+)' => 'secure_POST shadow_purge', // permanent delete all shadow deleted post that have timed out
'/(\%b)/ban(&delete)?/(\d+)' => 'secure_POST ban_post', // ban poster '/(\%b)/ban(&delete|&deletebyip)?/(\d+)' => 'secure_POST ban_post', // ban poster
'/(\%b)/move/(\d+)' => 'secure_POST move', // move thread '/(\%b)/move/(\d+)' => 'secure_POST move', // move thread
'/(\%b)/move_reply/(\d+)' => 'secure_POST move_reply', // move reply '/(\%b)/move_reply/(\d+)' => 'secure_POST move_reply', // move reply
'/(\%b)/edit(_raw)?/(\d+)' => 'secure_POST edit_post', // edit post '/(\%b)/edit(_raw)?/(\d+)' => 'secure_POST edit_post', // edit post

View File

@ -1,5 +1,5 @@
{% if post and board %} {% if post and board %}
{% set action = '?/' ~ board ~ '/ban/' ~ post %} {% set action = '?/' ~ board ~ '/ban' ~ delete_str ~ '/' ~ post %}
{% else %} {% else %}
{% set action = '?/ban' %} {% set action = '?/ban' %}
{% endif %} {% endif %}

View File

@ -35,6 +35,9 @@
{% if mod|hasPermission(config.mod.bandelete, board.uri) %} {% if mod|hasPermission(config.mod.bandelete, board.uri) %}
<a title="{% trans %}Ban & Delete{% endtrans %}" href="?/{{ board.dir }}ban&amp;delete/{{ post.id }}">{{ config.mod.link_bandelete }}</a>&nbsp; <a title="{% trans %}Ban & Delete{% endtrans %}" href="?/{{ board.dir }}ban&amp;delete/{{ post.id }}">{{ config.mod.link_bandelete }}</a>&nbsp;
{% endif %} {% endif %}
{% if mod|hasPermission(config.mod.bandeletebyip, board.uri) %}
<a title="{% trans %}Ban & Delete all post by IP{% endtrans %}" href="?/{{ board.dir }}ban&amp;deletebyip/{{ post.id }}">{{ config.mod.link_bandeletebyip }}</a>&nbsp;
{% endif %}
<br/> <br/>