forked from GithubBackups/vichan
Ban appeals: limit by board, make more efficient, enable in infinity
This commit is contained in:
parent
437ff83696
commit
0a2dfedb0e
@ -355,7 +355,7 @@ class Post {
|
||||
}
|
||||
|
||||
if (isset($this->files) && $this->files) {
|
||||
$this->files = json_decode($this->files);
|
||||
$this->files = is_string($this->files) ? json_decode($this->files) : $this->files;
|
||||
// Compatibility for posts before individual file hashing
|
||||
foreach ($this->files as $i => &$file) {
|
||||
if (empty($file)) {
|
||||
@ -453,7 +453,7 @@ class Thread extends Post {
|
||||
}
|
||||
|
||||
if (isset($this->files))
|
||||
$this->files = json_decode($this->files);
|
||||
$this->files = is_string($this->files) ? json_decode($this->files) : $this->files;
|
||||
|
||||
$this->subject = utf8tohtml($this->subject);
|
||||
$this->name = utf8tohtml($this->name);
|
||||
|
@ -228,6 +228,7 @@ $config['early_404_page'] = 5;
|
||||
$config['early_404_replies'] = 10;
|
||||
$config['cron_bans'] = true;
|
||||
$config['mask_db_error'] = true;
|
||||
$config['ban_appeals'] = true;
|
||||
// 8chan specific mod pages
|
||||
require '8chan-mod-pages.php';
|
||||
|
||||
|
@ -1046,7 +1046,7 @@ function mod_bans_json() {
|
||||
}
|
||||
|
||||
function mod_ban_appeals() {
|
||||
global $config, $board;
|
||||
global $config, $board, $mod;
|
||||
|
||||
if (!hasPermission($config['mod']['view_ban_appeals']))
|
||||
error($config['error']['noaccess']);
|
||||
@ -1066,6 +1066,9 @@ function mod_ban_appeals() {
|
||||
error(_('Ban appeal not found!'));
|
||||
}
|
||||
|
||||
if (!in_array($ban['board'], $mod['boards']))
|
||||
error($config['error']['noaccess']);
|
||||
|
||||
$ban['mask'] = Bans::range_to_string(array($ban['ipstart'], $ban['ipend']));
|
||||
|
||||
if (isset($_POST['unban'])) {
|
||||
@ -1081,10 +1084,17 @@ function mod_ban_appeals() {
|
||||
return;
|
||||
}
|
||||
|
||||
$query = query("SELECT *, ``ban_appeals``.`id` AS `id` FROM ``ban_appeals``
|
||||
$local = ($mod['type'] == MOD || $mod["type"] == BOARDVOLUNTEER);
|
||||
|
||||
$query = prepare("SELECT *, ``ban_appeals``.`id` AS `id` FROM ``ban_appeals``
|
||||
LEFT JOIN ``bans`` ON `ban_id` = ``bans``.`id`
|
||||
LEFT JOIN ``mods`` ON ``bans``.`creator` = ``mods``.`id`
|
||||
WHERE `denied` != 1 ORDER BY `time`") or error(db_error());
|
||||
WHERE `denied` != 1 ".($local ? " AND ``bans``.`board` = :board " : "")." ORDER BY `time`");
|
||||
if ($local) {
|
||||
$query->bindValue(':board', $mod['boards'][0]);
|
||||
}
|
||||
$query->execute() or error(db_error());
|
||||
|
||||
$ban_appeals = $query->fetchAll(PDO::FETCH_ASSOC);
|
||||
foreach ($ban_appeals as &$ban) {
|
||||
if ($ban['post'])
|
||||
@ -1092,29 +1102,14 @@ function mod_ban_appeals() {
|
||||
$ban['mask'] = Bans::range_to_string(array($ban['ipstart'], $ban['ipend']));
|
||||
|
||||
if ($ban['post'] && isset($ban['post']['board'], $ban['post']['id'])) {
|
||||
if (openBoard($ban['post']['board'])) {
|
||||
$query = query(sprintf("SELECT `num_files`, `files` FROM ``posts_%s`` WHERE `id` = " .
|
||||
(int)$ban['post']['id'], $board['uri']));
|
||||
if ($_post = $query->fetch(PDO::FETCH_ASSOC)) {
|
||||
$_post['files'] = $_post['files'] ? json_decode($_post['files']) : array();
|
||||
$ban['post'] = array_merge($ban['post'], $_post);
|
||||
} else {
|
||||
$ban['post']['files'] = array(array());
|
||||
$ban['post']['files'][0]['file'] = 'deleted';
|
||||
$ban['post']['files'][0]['thumb'] = false;
|
||||
$ban['post']['num_files'] = 1;
|
||||
}
|
||||
} else {
|
||||
$ban['post']['files'] = array(array());
|
||||
$ban['post']['files'][0]['file'] = 'deleted';
|
||||
$ban['post']['files'][0]['thumb'] = false;
|
||||
$ban['post']['num_files'] = 1;
|
||||
}
|
||||
openBoard($ban['post']['board']);
|
||||
|
||||
if ($ban['post']['thread']) {
|
||||
$ban['post'] = new Post($ban['post']);
|
||||
$po = new Post($ban['post']);
|
||||
$ban['post'] = $po->build(true);
|
||||
} else {
|
||||
$ban['post'] = new Thread($ban['post'], null, false, false);
|
||||
$po = new Thread($ban['post'], null, false, false);
|
||||
$ban['post'] = $po->build(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,11 @@
|
||||
<th>{% trans 'IP' %}</th>
|
||||
<td>{{ ban.mask }}</td>
|
||||
</tr>
|
||||
{% elseif mod|hasPermission(config.mod.show_ip_less, board.uri) %}
|
||||
<tr>
|
||||
<th>{% trans 'IP' %}</th>
|
||||
<td>{{ ban.mask|less_ip }}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
<tr>
|
||||
<th>{% trans 'Reason' %}</th>
|
||||
@ -98,7 +103,7 @@
|
||||
|
||||
{% if ban.post %}
|
||||
<div style="">
|
||||
{{ ban.post.build(true) }}
|
||||
{{ ban.post }}
|
||||
</div>
|
||||
{% endif %}
|
||||
</form>
|
||||
|
Loading…
x
Reference in New Issue
Block a user