Multiple improvements: ?/ban/<post> & ?/ban&delete/<post>
This commit is contained in:
parent
4fcf9c2c91
commit
de84ca6f75
@ -374,13 +374,54 @@ function mod_ban_post($board, $delete, $post) {
|
||||
if (!hasPermission($config['mod']['delete'], $board))
|
||||
error($config['error']['noaccess']);
|
||||
|
||||
$query = prepare(sprintf('SELECT `ip` FROM `posts_%s` WHERE `id` = :id', $board));
|
||||
$query = prepare(sprintf('SELECT `ip`, `thread` FROM `posts_%s` WHERE `id` = :id', $board));
|
||||
$query->bindValue(':id', $post);
|
||||
$query->execute() or error(db_error($query));
|
||||
if(!$ip = $query->fetchColumn(0))
|
||||
if(!$_post = $query->fetch(PDO::FETCH_ASSOC))
|
||||
error($config['error']['404']);
|
||||
|
||||
mod_page("New ban", 'mod/ban_form.html', array());
|
||||
$thread = $_post['thread'];
|
||||
$ip = $_post['ip'];
|
||||
|
||||
if (isset($_POST['new_ban'], $_POST['reason'], $_POST['length'], $_POST['board'])) {
|
||||
require_once 'inc/mod/ban.php';
|
||||
|
||||
if (isset($_POST['ip']))
|
||||
$ip = $_POST['ip'];
|
||||
|
||||
ban($ip, $_POST['reason'], parse_time($_POST['length']), $_POST['board'] == '*' ? false : $_POST['board']);
|
||||
|
||||
if (isset($_POST['public_message'], $_POST['message'])) {
|
||||
// public ban message
|
||||
$query = prepare(sprintf('UPDATE `posts_%s` SET `body` = CONCAT(`body`, :body) WHERE `id` = :id', $board));
|
||||
$query->bindValue(':id', $post);
|
||||
$query->bindValue(':body', sprintf($config['mod']['ban_message'], utf8tohtml($_POST['message'])));
|
||||
$query->execute() or error(db_error($query));
|
||||
|
||||
modLog("Attached a public ban message to post #{$post}: " . utf8tohtml($_POST['message']));
|
||||
buildThread($thread ? $thread : $post);
|
||||
buildIndex();
|
||||
} elseif (isset($_POST['delete'])) {
|
||||
// Delete post
|
||||
deletePost($post);
|
||||
modLog("Deleted post #{$post}");
|
||||
// Rebuild board
|
||||
buildIndex();
|
||||
}
|
||||
|
||||
header('Location: ?/' . sprintf($config['board_path'], $board) . $config['file_index'], true, $config['redirect_http']);
|
||||
}
|
||||
|
||||
$args = array(
|
||||
'ip' => $ip,
|
||||
'hide_ip' => !hasPermission($config['mod']['show_ip'], $board),
|
||||
'post' => $post,
|
||||
'board' => $board,
|
||||
'delete' => (bool)$delete,
|
||||
'boards' => listBoards()
|
||||
);
|
||||
|
||||
mod_page("New ban", 'mod/ban_form.html', $args);
|
||||
}
|
||||
|
||||
function mod_delete($board, $post) {
|
||||
|
2
mod.php
2
mod.php
@ -44,7 +44,7 @@ $pages = array(
|
||||
'!^/bans/(\d+)$!' => 'bans', // ban list
|
||||
|
||||
'!^/(\w+)/delete/(\d+)$!' => 'delete', // delete post
|
||||
'!^/(\w+)/ban/(&delete/)?(\d+)$!' => 'ban_post', // ban poster
|
||||
'!^/(\w+)/ban(&delete)?/(\d+)$!' => 'ban_post', // ban poster
|
||||
'!^/(\w+)/(un)?lock/(\d+)$!' => 'lock', // lock thread
|
||||
'!^/(\w+)/(un)?sticky/(\d+)$!' => 'sticky', // sticky thread
|
||||
'!^/(\w+)/bump(un)?lock/(\d+)$!' => 'bumplock', // "bumplock" thread
|
||||
|
@ -1,15 +1,29 @@
|
||||
<form action="?/ban" method="post">
|
||||
{% if post and board %}
|
||||
{% set action = '?/' ~ board ~ '/ban/' ~ post %}
|
||||
{% else %}
|
||||
{% set action = '?/ban' %}
|
||||
{% endif %}
|
||||
|
||||
<form action="{{ action }}" method="post">
|
||||
{% 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 %}
|
||||
|
||||
<table>
|
||||
|
||||
<tr>
|
||||
<th>
|
||||
<label for="ip">IP <span class="unimportant">(or subnet)</span></label>
|
||||
</th>
|
||||
<td>
|
||||
<input type="text" name="ip" id="ip" size="30" maxlength="40" value="{{ ip }}">
|
||||
{% if not hide_ip %}
|
||||
<input type="text" name="ip" id="ip" size="30" maxlength="40" value="{{ ip }}">
|
||||
{% else %}
|
||||
<em>hidden</em>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@ -20,6 +34,24 @@
|
||||
<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">Message</label>
|
||||
</th>
|
||||
<td>
|
||||
<input type="checkbox" id="public_message" name="public_message">
|
||||
<input type="text" name="message" id="message" size="35" maxlength="200" value="{{ config.mod.default_ban_message|e }}">
|
||||
<span class="unimportant">(public; attached to post)</span>
|
||||
<script type="text/javascript">
|
||||
document.getElementById('message').disabled = true;
|
||||
document.getElementById('public_message').onchange = function() {
|
||||
document.getElementById('message').disabled = !this.checked;
|
||||
}
|
||||
</script>
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
<tr>
|
||||
<th>
|
||||
<label for="length">Length</label>
|
||||
|
Loading…
Reference in New Issue
Block a user