In ban form, display the post so we can select which parts of it to mark as spam (for spamnoticer)
This commit is contained in:
parent
0f16b9bf93
commit
16286aa62b
|
@ -6,8 +6,6 @@
|
|||
|
||||
defined('TINYBOARD') or exit;
|
||||
|
||||
require_once 'inc/anti-bot.php'; // DELETE ME THIS IS FOR print_err function only!
|
||||
|
||||
function mod_page($title, $template, $args, $subtitle = false) {
|
||||
global $config, $mod;
|
||||
|
||||
|
@ -1755,7 +1753,7 @@ function mod_merge($originBoard, $postID) {
|
|||
mod_page(_('Merge thread'), 'mod/merge.html', array('post' => $postID, 'board' => $originBoard, 'boards' => $boards, 'token' => $security_token));
|
||||
}
|
||||
|
||||
function mod_ban_post($board, $delete, $post, $token = false) {
|
||||
function mod_ban_post($board, $delete, $post_num, $token = false) {
|
||||
global $config, $mod;
|
||||
|
||||
if (!openBoard($board))
|
||||
|
@ -1764,17 +1762,17 @@ function mod_ban_post($board, $delete, $post, $token = false) {
|
|||
if (!hasPermission($config['mod']['delete'], $board))
|
||||
error($config['error']['noaccess']);
|
||||
|
||||
$security_token = make_secure_link_token($board . '/ban/' . $post);
|
||||
$security_token = make_secure_link_token($board . '/ban/' . $post_num);
|
||||
|
||||
$query = prepare(sprintf('SELECT ' . ($config['ban_show_post'] ? '*' : '`ip`, `thread`') .
|
||||
$query = prepare(sprintf('SELECT *' .
|
||||
' FROM ``posts_%s`` WHERE `id` = :id', $board));
|
||||
$query->bindValue(':id', $post);
|
||||
$query->bindValue(':id', $post_num);
|
||||
$query->execute() or error(db_error($query));
|
||||
if (!$_post = $query->fetch(PDO::FETCH_ASSOC))
|
||||
if (!$post = $query->fetch(PDO::FETCH_ASSOC))
|
||||
error($config['error']['404']);
|
||||
|
||||
$thread = $_post['thread'];
|
||||
$ip = $_post['ip'];
|
||||
$thread = $post['thread'];
|
||||
$ip = $post['ip'];
|
||||
|
||||
if (isset($_POST['new_ban'], $_POST['reason'], $_POST['length'], $_POST['board'])) {
|
||||
require_once 'inc/mod/ban.php';
|
||||
|
@ -1783,7 +1781,7 @@ function mod_ban_post($board, $delete, $post, $token = false) {
|
|||
$ip = $_POST['ip'];
|
||||
|
||||
Bans::new_ban($_POST['ip'], $_POST['reason'], $_POST['length'], $_POST['board'] == '*' ? false : $_POST['board'],
|
||||
false, $config['ban_show_post'] ? $_post : false);
|
||||
false, $config['ban_show_post'] ? $post : false);
|
||||
|
||||
if (isset($_POST['public_message'], $_POST['message'])) {
|
||||
// public ban message
|
||||
|
@ -1792,19 +1790,19 @@ function mod_ban_post($board, $delete, $post, $token = false) {
|
|||
$_POST['message'] = str_replace('%length%', $length_english, $_POST['message']);
|
||||
$_POST['message'] = str_replace('%LENGTH%', strtoupper($length_english), $_POST['message']);
|
||||
$query = prepare(sprintf('UPDATE ``posts_%s`` SET `body_nomarkup` = CONCAT(`body_nomarkup`, :body_nomarkup) WHERE `id` = :id', $board));
|
||||
$query->bindValue(':id', $post);
|
||||
$query->bindValue(':id', $post_num);
|
||||
$query->bindValue(':body_nomarkup', sprintf("\n<tinyboard ban message>%s</tinyboard>", utf8tohtml($_POST['message'])));
|
||||
$query->execute() or error(db_error($query));
|
||||
rebuildPost($post);
|
||||
|
||||
modLog("Attached a public ban message to post #{$post}: " . utf8tohtml($_POST['message']));
|
||||
buildThread($thread ? $thread : $post);
|
||||
modLog("Attached a public ban message to post #{$post_num}: " . utf8tohtml($_POST['message']));
|
||||
buildThread($thread ? $thread : $post_num);
|
||||
buildIndex();
|
||||
} elseif (isset($_POST['delete']) && (int) $_POST['delete']) {
|
||||
// Delete post
|
||||
if ($config['autotagging']){
|
||||
$query = prepare(sprintf("SELECT * FROM ``posts_%s`` WHERE id = :id", $board));
|
||||
$query->bindValue(':id', $post );
|
||||
$query->bindValue(':id', $post_num );
|
||||
$query->execute() or error(db_error($query));
|
||||
$ip = "";
|
||||
$time = "";
|
||||
|
@ -1843,8 +1841,8 @@ function mod_ban_post($board, $delete, $post, $token = false) {
|
|||
modLog("Added a note for <a href=\"?/IP/{$ip}\">{$ip}</a>");
|
||||
}
|
||||
}
|
||||
deletePost($post);
|
||||
modLog("Deleted post #{$post}");
|
||||
deletePost($post_num);
|
||||
modLog("Deleted post #{$post_num}");
|
||||
// Rebuild board
|
||||
buildIndex();
|
||||
// Rebuild themes
|
||||
|
@ -1860,14 +1858,22 @@ function mod_ban_post($board, $delete, $post, $token = false) {
|
|||
}
|
||||
}
|
||||
|
||||
if (!$post['thread']) {
|
||||
$post = new Thread($post, '?/', false, false);
|
||||
} else {
|
||||
$post = new Post($post, '?/', false);
|
||||
}
|
||||
|
||||
$args = array(
|
||||
'ip' => $ip,
|
||||
'hide_ip' => !hasPermission($config['mod']['show_ip'], $board),
|
||||
'post_num' => $post_num,
|
||||
'post' => $post,
|
||||
'board' => $board,
|
||||
'delete' => (bool)$delete,
|
||||
'delete' => (bool) $delete,
|
||||
'boards' => listBoards(),
|
||||
'token' => $security_token
|
||||
'token' => $security_token,
|
||||
'spamnoticer' => $config['spam_noticer']['enabled']
|
||||
);
|
||||
|
||||
if(isset($_GET['thread']) && $_GET['thread']) {
|
||||
|
@ -2691,7 +2697,6 @@ function clearCacheFiles($cacheLocation) {
|
|||
|
||||
function mod_rebuild() {
|
||||
global $config, $twig;
|
||||
print_err("mod_rebuild");
|
||||
|
||||
if (!hasPermission($config['mod']['rebuild']))
|
||||
error($config['error']['noaccess']);
|
||||
|
@ -2716,9 +2721,7 @@ function mod_rebuild() {
|
|||
|
||||
if (isset($_POST['rebuild_themes'])) {
|
||||
$log[] = 'Regenerating theme files';
|
||||
print_err("mod_rebuild calling rebuildThemes");
|
||||
rebuildThemes('all');
|
||||
print_err("mod_rebuild calling rebuildThemes ok");
|
||||
}
|
||||
|
||||
if (isset($_POST['rebuild_javascript'])) {
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
/* Show the table when "Ban" checkbox is checked */
|
||||
input[type="checkbox"]#checkbox-ban:checked ~ .ban-form {
|
||||
/* display: table; */
|
||||
filter: grayscale(0%);
|
||||
}
|
||||
|
||||
/* Hide the table by default */
|
||||
.ban-form {
|
||||
filter: grayscale(100%);
|
||||
}
|
||||
|
||||
.ban_delete_action_form {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.ban-form {
|
||||
flex-basis: 100%;
|
||||
}
|
||||
|
||||
.ban-form-action--input {
|
||||
margin: 1em;
|
||||
}
|
||||
|
||||
.ban-form-action--label {
|
||||
margin-right: 2em;
|
||||
margin-left: 0em;
|
||||
margin-top: 1em;
|
||||
margin-bottom: 1em;
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
{% apply remove_whitespace %}
|
||||
{# tabs and new lines will be ignored #}
|
||||
<div class="postcontainer" id="pc{{ post.id }}" data-board="{{ board.uri }}">
|
||||
{% if post.thread %}
|
||||
<div class="post reply" id="reply_{{ post.id }}">
|
||||
{% else %}
|
||||
<div class="post op" id="thread_{{ post.id }}">
|
||||
{% endif %}
|
||||
<p class="intro">
|
||||
<label for="delete_{{ post.id }}">
|
||||
{% include 'post/subject.html' %}
|
||||
{% include 'post/name.html' %}
|
||||
{% include 'post/ip.html' %}
|
||||
{% include 'post/flag.html' %}
|
||||
{% include 'post/time.html' %}
|
||||
</label>
|
||||
{% include 'post/poster_id.html' %}
|
||||
<a class="post_no" id="post_no_{{ post.id }}" onclick="highlightReply({{ post.id }})" href="{% if isnoko50 %}{{ post.link('', config.file_page50) }}{% else %}{{ post.link }}{% endif %}">No.</a>
|
||||
<a class="post_no" onclick="citeReply({{ post.id }})" href="{% if isnoko50 %}{{ post.link('q', config.file_page50) }}{% else %}{{ post.link('q') }}{% endif %}">{{ post.id }}</a>
|
||||
</p>
|
||||
{% set mod=false %}
|
||||
{% include 'post/fileinfo.html' %}
|
||||
<div class="body" {% if post.files|length > 1 %}style="clear:both"{% endif %}>
|
||||
{% endapply %}{% if index %}{{ post.body|truncate_body(post.link) }}{% else %}{{ post.body }}{% endif %}{% apply remove_whitespace %}
|
||||
{% if post.modifiers['ban message'] %}
|
||||
{{ config.mod.ban_message|sprintf(post.modifiers['ban message']) }}
|
||||
{% endif %}
|
||||
{% if post.modifiers['warning message'] %}
|
||||
{{ config.mod.warning_message|sprintf(post.modifiers['warning message']) }}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endapply %}
|
|
@ -1,95 +1,116 @@
|
|||
{% if post and board %}
|
||||
{% set action = '?/' ~ board ~ '/ban/' ~ post %}
|
||||
{% if post_num and board %}
|
||||
{% set action = '?/' ~ board ~ '/ban/' ~ post_num %}
|
||||
{% else %}
|
||||
{% set action = '?/ban' %}
|
||||
{% endif %}
|
||||
|
||||
<form action="{{ action }}" method="post">
|
||||
<input type="hidden" name="token" value="{{ token }}">
|
||||
{% if redirect %}
|
||||
<input type="hidden" name="redirect" value="{{ redirect|e }}">
|
||||
{% endif %}
|
||||
{% if post and board %}
|
||||
<input type="hidden" name="delete" value="{% if delete %}1{% else %}0{% endif %}">
|
||||
{% endif %}
|
||||
{% if thread %}
|
||||
<input type="hidden" name="thread" value="{{ thread }}">
|
||||
{% endif %}
|
||||
|
||||
<table>
|
||||
|
||||
<tr>
|
||||
<th>
|
||||
<label for="ip">{% trans 'IP' %} <span class="unimportant">{% trans '(or subnet)' %}</span></label>
|
||||
</th>
|
||||
<td>
|
||||
{% if not hide_ip %}
|
||||
<input type="text" name="ip" id="ip" size="30" maxlength="43" value="{{ ip|e }}">
|
||||
{% else %}
|
||||
<em>{% trans 'hidden' %}</em>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<label for="reason">{% trans 'Reason' %}</label>
|
||||
</th>
|
||||
<td>
|
||||
<textarea name="reason" id="reason" rows="5" cols="30">{{ reason|e }}</textarea>
|
||||
</td>
|
||||
</tr>
|
||||
{% if post and board and not delete %}
|
||||
<tr>
|
||||
<th>
|
||||
<label for="reason">{% trans 'Message' %}</label>
|
||||
</th>
|
||||
<td>
|
||||
<input type="checkbox" id="public_message" name="public_message"{% if config.mod.check_ban_message %} checked{% endif %}>
|
||||
<input type="text" name="message" id="message" size="35" maxlength="200" value="{{ config.mod.default_ban_message|e }}">
|
||||
<span class="unimportant">({% trans 'public; attached to post' %})</span>
|
||||
<script type="text/javascript">
|
||||
document.getElementById('message').disabled = !document.getElementById('public_message').checked;
|
||||
document.getElementById('public_message').onchange = function() {
|
||||
document.getElementById('message').disabled = !this.checked;
|
||||
}
|
||||
</script>
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
<tr>
|
||||
<th>
|
||||
<label for="length">{% trans 'Length' %}</label>
|
||||
</th>
|
||||
<td>
|
||||
<input type="text" name="length" id="length" size="20" maxlength="43">
|
||||
<span class="unimportant">(eg. "2d1h30m" or "2 days")</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{% trans 'Board' %}</th>
|
||||
<td>
|
||||
<ul style="list-style:none;padding:2px 5px">
|
||||
<li>
|
||||
<input type="radio" name="board" value="*" id="ban-allboards" checked>
|
||||
<label style="display:inline" for="ban-allboards">
|
||||
<em>{% trans 'all boards' %}</em>
|
||||
</label>
|
||||
</li>
|
||||
|
||||
{% for board in boards %}
|
||||
<li>
|
||||
<input type="radio" name="board" value="{{ board.uri }}" id="ban-board-{{ board.uri }}">
|
||||
<label style="display:inline" for="ban-board-{{ board.uri }}">
|
||||
{{ config.board_abbreviation|sprintf(board.uri) }} - {{ board.title|e }}
|
||||
</label>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><input name="new_ban" type="submit" value="{% trans 'New Ban' %}"></td>
|
||||
</tr>
|
||||
</table>
|
||||
{% if spamnoticer %}
|
||||
<link rel="stylesheet" media="screen" href="/stylesheets/ban_form.css">
|
||||
{% endif %}
|
||||
|
||||
<form class="ban_delete_action_form" action="{{ action }}" method="post">
|
||||
<input type="hidden" name="token" value="{{ token }}">
|
||||
{% if redirect %}
|
||||
<input type="hidden" name="redirect" value="{{ redirect|e }}">
|
||||
{% endif %}
|
||||
{% if post_num and board %}
|
||||
<input type="hidden" name="delete" value="{% if delete %}1{% else %}0{% endif %}">
|
||||
{% endif %}
|
||||
{% if thread %}
|
||||
<input type="hidden" name="thread" value="{{ thread }}">
|
||||
{% endif %}
|
||||
|
||||
{% if spamnoticer %}
|
||||
<input class="ban-form-action--input" type="checkbox" id="checkbox-ban" checked>
|
||||
<label class="ban-form-action--label" for="checkbox-ban">Ban</label>
|
||||
|
||||
<input class="ban-form-action--input" type="checkbox" id="checkbox-delete" checked>
|
||||
<label class="ban-form-action--label" for="checkbox-delete">Delete</label>
|
||||
|
||||
<input class="ban-form-action--input" type="checkbox" id="checkbox-ban-content">
|
||||
<label class="ban-form-action--label" for="checkbox-ban-content">Ban Content</label>
|
||||
{% endif %}
|
||||
|
||||
<table class="ban-form">
|
||||
<tr>
|
||||
<th>
|
||||
<label for="ip">{% trans 'IP' %} <span class="unimportant">{% trans '(or subnet)' %}</span></label>
|
||||
</th>
|
||||
<td>
|
||||
{% if not hide_ip %}
|
||||
<input type="text" name="ip" id="ip" size="30" maxlength="43" value="{{ ip|e }}">
|
||||
{% else %}
|
||||
<em>{% trans 'hidden' %}</em>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<label for="reason">{% trans 'Reason' %}</label>
|
||||
</th>
|
||||
<td>
|
||||
<textarea name="reason" id="reason" rows="5" cols="30">{{ reason|e }}</textarea>
|
||||
</td>
|
||||
</tr>
|
||||
{% if post_num and board and not delete %}
|
||||
<tr>
|
||||
<th>
|
||||
<label for="reason">{% trans 'Message' %}</label>
|
||||
</th>
|
||||
<td>
|
||||
<input type="checkbox" id="public_message" name="public_message"{% if config.mod.check_ban_message %} checked{% endif %}>
|
||||
<input type="text" name="message" id="message" size="35" maxlength="200" value="{{ config.mod.default_ban_message|e }}">
|
||||
<span class="unimportant">({% trans 'public; attached to post' %})</span>
|
||||
<script type="text/javascript">
|
||||
document.getElementById('message').disabled = !document.getElementById('public_message').checked;
|
||||
document.getElementById('public_message').onchange = function() {
|
||||
document.getElementById('message').disabled = !this.checked;
|
||||
}
|
||||
</script>
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
<tr>
|
||||
<th>
|
||||
<label for="length">{% trans 'Length' %}</label>
|
||||
</th>
|
||||
<td>
|
||||
<input type="text" name="length" id="length" size="20" maxlength="43">
|
||||
<span class="unimportant">(eg. "2d1h30m" or "2 days")</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{% trans 'Board' %}</th>
|
||||
<td>
|
||||
<ul style="list-style:none;padding:2px 5px">
|
||||
<li>
|
||||
<input type="radio" name="board" value="*" id="ban-allboards" checked>
|
||||
<label style="display:inline" for="ban-allboards">
|
||||
<em>{% trans 'all boards' %}</em>
|
||||
</label>
|
||||
</li>
|
||||
|
||||
{% for board in boards %}
|
||||
<li>
|
||||
<input type="radio" name="board" value="{{ board.uri }}" id="ban-board-{{ board.uri }}">
|
||||
<label style="display:inline" for="ban-board-{{ board.uri }}">
|
||||
{{ config.board_abbreviation|sprintf(board.uri) }} - {{ board.title|e }}
|
||||
</label>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</td>
|
||||
</table>
|
||||
{% if spamnoticer %}
|
||||
<p>If you selected "Ban Content" above, please select which files and whether or not the body should be considered spam:</p>
|
||||
{% include 'ban_post_content_form.html' %}
|
||||
{% endif %}
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<input name="new_ban" type="submit" value="{% trans 'New Ban' %}" id="new_ban">
|
||||
<label class="ban-form-action--label" for="new_ban">Submit</label>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
|
|
Loading…
Reference in New Issue