mirror of
https://github.com/vichan-devel/vichan.git
synced 2025-01-18 09:04:44 +01:00
Merge branch 'master' of https://github.com/savetheinternet/Tinyboard into vichan-devel-4.5
Conflicts: inc/config.php
This commit is contained in:
commit
8ca495e5b8
24
inc/bans.php
24
inc/bans.php
@ -33,7 +33,7 @@ class Bans {
|
|||||||
return array(inet_pton($range[0]), inet_pton($range[1]));
|
return array(inet_pton($range[0]), inet_pton($range[1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function parse_time($str) {
|
public static function parse_time($str) {
|
||||||
if (empty($str))
|
if (empty($str))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -137,10 +137,10 @@ class Bans {
|
|||||||
|
|
||||||
while ($ban = $query->fetch(PDO::FETCH_ASSOC)) {
|
while ($ban = $query->fetch(PDO::FETCH_ASSOC)) {
|
||||||
if ($ban['expires'] && ($ban['seen'] || !$config['require_ban_view']) && $ban['expires'] < time()) {
|
if ($ban['expires'] && ($ban['seen'] || !$config['require_ban_view']) && $ban['expires'] < time()) {
|
||||||
$query = prepare("DELETE FROM ``bans`` WHERE `id` = :id");
|
self::delete($ban['id']);
|
||||||
$query->bindValue(':id', $ban['id'], PDO::PARAM_INT);
|
|
||||||
$query->execute() or error(db_error($query));
|
|
||||||
} else {
|
} else {
|
||||||
|
if ($ban['post'])
|
||||||
|
$ban['post'] = json_decode($ban['post'], true);
|
||||||
$ban['mask'] = self::range_to_string(array($ban['ipstart'], $ban['ipend']));
|
$ban['mask'] = self::range_to_string(array($ban['ipstart'], $ban['ipend']));
|
||||||
$ban_list[] = $ban;
|
$ban_list[] = $ban;
|
||||||
}
|
}
|
||||||
@ -197,8 +197,8 @@ class Bans {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function new_ban($mask, $reason, $length = false, $board = false, $mod_id = false) {
|
static public function new_ban($mask, $reason, $length = false, $ban_board = false, $mod_id = false, $post = false) {
|
||||||
global $mod, $pdo;
|
global $mod, $pdo, $board;
|
||||||
|
|
||||||
if ($mod_id === false) {
|
if ($mod_id === false) {
|
||||||
$mod_id = isset($mod['id']) ? $mod['id'] : -1;
|
$mod_id = isset($mod['id']) ? $mod['id'] : -1;
|
||||||
@ -207,7 +207,7 @@ class Bans {
|
|||||||
$range = self::parse_range($mask);
|
$range = self::parse_range($mask);
|
||||||
$mask = self::range_to_string($range);
|
$mask = self::range_to_string($range);
|
||||||
|
|
||||||
$query = prepare("INSERT INTO ``bans`` VALUES (NULL, :ipstart, :ipend, :time, :expires, :board, :mod, :reason, 0, NULL)");
|
$query = prepare("INSERT INTO ``bans`` VALUES (NULL, :ipstart, :ipend, :time, :expires, :board, :mod, :reason, 0, :post)");
|
||||||
|
|
||||||
$query->bindValue(':ipstart', $range[0]);
|
$query->bindValue(':ipstart', $range[0]);
|
||||||
if ($range[1] !== false && $range[1] != $range[0])
|
if ($range[1] !== false && $range[1] != $range[0])
|
||||||
@ -236,11 +236,17 @@ class Bans {
|
|||||||
$query->bindValue(':expires', null, PDO::PARAM_NULL);
|
$query->bindValue(':expires', null, PDO::PARAM_NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($board)
|
if ($ban_board)
|
||||||
$query->bindValue(':board', $board);
|
$query->bindValue(':board', $ban_board);
|
||||||
else
|
else
|
||||||
$query->bindValue(':board', null, PDO::PARAM_NULL);
|
$query->bindValue(':board', null, PDO::PARAM_NULL);
|
||||||
|
|
||||||
|
if ($post) {
|
||||||
|
$post['board'] = $board['uri'];
|
||||||
|
$query->bindValue(':post', json_encode($post));
|
||||||
|
} else
|
||||||
|
$query->bindValue(':post', null, PDO::PARAM_NULL);
|
||||||
|
|
||||||
$query->execute() or error(db_error($query));
|
$query->execute() or error(db_error($query));
|
||||||
|
|
||||||
if (isset($mod['id']) && $mod['id'] == $mod_id) {
|
if (isset($mod['id']) && $mod['id'] == $mod_id) {
|
||||||
|
@ -854,14 +854,17 @@
|
|||||||
// 'bottom' => '',
|
// 'bottom' => '',
|
||||||
// );
|
// );
|
||||||
|
|
||||||
|
// Show the post the user was banned for on the "You are banned" page.
|
||||||
|
$config['ban_show_post'] = false;
|
||||||
|
|
||||||
// Optional HTML to append to "You are banned" pages. For example, you could include instructions and/or
|
// Optional HTML to append to "You are banned" pages. For example, you could include instructions and/or
|
||||||
// a link to an email address or IRC chat room to appeal the ban.
|
// a link to an email address or IRC chat room to appeal the ban.
|
||||||
$config['ban_page_extra'] = '';
|
$config['ban_page_extra'] = '';
|
||||||
|
|
||||||
// Display flags (when available). This config option has no effect unless poster flags are enabled (see
|
// Display flags (when available). This config option has no effect unless poster flags are enabled (see
|
||||||
// $config['country_flags']). Disable this if you want all previously-assigned flags to be hidden.
|
// $config['country_flags']). Disable this if you want all previously-assigned flags to be hidden.
|
||||||
$config['display_flags'] = true;
|
$config['display_flags'] = true;
|
||||||
|
|
||||||
// Location of post flags/icons (where "%s" is the flag name). Defaults to static/flags/%s.png.
|
// Location of post flags/icons (where "%s" is the flag name). Defaults to static/flags/%s.png.
|
||||||
// $config['uri_flags'] = 'http://static.example.org/flags/%s.png';
|
// $config['uri_flags'] = 'http://static.example.org/flags/%s.png';
|
||||||
|
|
||||||
|
@ -620,22 +620,41 @@ function ago($timestamp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function displayBan($ban) {
|
function displayBan($ban) {
|
||||||
global $config;
|
global $config, $board;
|
||||||
|
|
||||||
if (!$ban['seen']) {
|
if (!$ban['seen']) {
|
||||||
Bans::seen($ban['id']);
|
Bans::seen($ban['id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$ban['ip'] = $_SERVER['REMOTE_ADDR'];
|
$ban['ip'] = $_SERVER['REMOTE_ADDR'];
|
||||||
|
if ($ban['post'] && isset($ban['post']['board'], $ban['post']['id'])) {
|
||||||
|
openBoard($ban['post']['board']);
|
||||||
|
|
||||||
|
$query = query(sprintf("SELECT `thumb`, `file` FROM ``posts_%s`` WHERE `id` = " . (int)$ban['post']['id'], $board['uri']));
|
||||||
|
if ($_post = $query->fetch(PDO::FETCH_ASSOC)) {
|
||||||
|
$ban['post'] = array_merge($ban['post'], $_post);
|
||||||
|
} else {
|
||||||
|
$ban['post']['file'] = 'deleted';
|
||||||
|
$ban['post']['thumb'] = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($ban['post']['thread']) {
|
||||||
|
$post = new Post($ban['post']);
|
||||||
|
} else {
|
||||||
|
$post = new Thread($ban['post'], null, false, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
// Show banned page and exit
|
// Show banned page and exit
|
||||||
die(
|
die(
|
||||||
Element('page.html', array(
|
Element('page.html', array(
|
||||||
'title' => _('Banned!'),
|
'title' => _('Banned!'),
|
||||||
'config' => $config,
|
'config' => $config,
|
||||||
|
'nojavascript' => true,
|
||||||
'body' => Element('banned.html', array(
|
'body' => Element('banned.html', array(
|
||||||
'config' => $config,
|
'config' => $config,
|
||||||
'ban' => $ban
|
'ban' => $ban,
|
||||||
|
'board' => $board,
|
||||||
|
'post' => isset($post) ? $post->build(true) : false
|
||||||
)
|
)
|
||||||
))
|
))
|
||||||
));
|
));
|
||||||
|
@ -1275,7 +1275,8 @@ function mod_ban_post($board, $delete, $post, $token = false) {
|
|||||||
|
|
||||||
$security_token = make_secure_link_token($board . '/ban/' . $post);
|
$security_token = make_secure_link_token($board . '/ban/' . $post);
|
||||||
|
|
||||||
$query = prepare(sprintf('SELECT `ip`, `thread` FROM ``posts_%s`` WHERE `id` = :id', $board));
|
$query = prepare(sprintf('SELECT ' . ($config['ban_show_post'] ? '*' : '`ip`, `thread`') .
|
||||||
|
' FROM ``posts_%s`` WHERE `id` = :id', $board));
|
||||||
$query->bindValue(':id', $post);
|
$query->bindValue(':id', $post);
|
||||||
$query->execute() or error(db_error($query));
|
$query->execute() or error(db_error($query));
|
||||||
if (!$_post = $query->fetch(PDO::FETCH_ASSOC))
|
if (!$_post = $query->fetch(PDO::FETCH_ASSOC))
|
||||||
@ -1290,11 +1291,12 @@ function mod_ban_post($board, $delete, $post, $token = false) {
|
|||||||
if (isset($_POST['ip']))
|
if (isset($_POST['ip']))
|
||||||
$ip = $_POST['ip'];
|
$ip = $_POST['ip'];
|
||||||
|
|
||||||
Bans::new_ban($_POST['ip'], $_POST['reason'], $_POST['length'], $_POST['board'] == '*' ? false : $_POST['board']);
|
Bans::new_ban($_POST['ip'], $_POST['reason'], $_POST['length'], $_POST['board'] == '*' ? false : $_POST['board'],
|
||||||
|
false, $config['ban_show_post'] ? $_post : false);
|
||||||
|
|
||||||
if (isset($_POST['public_message'], $_POST['message'])) {
|
if (isset($_POST['public_message'], $_POST['message'])) {
|
||||||
// public ban message
|
// public ban message
|
||||||
$length_english = parse_time($_POST['length']) ? 'for ' . until(parse_time($_POST['length'])) : 'permanently';
|
$length_english = Bans::parse_time($_POST['length']) ? 'for ' . until(Bans::parse_time($_POST['length'])) : 'permanently';
|
||||||
$_POST['message'] = preg_replace('/[\r\n]/', '', $_POST['message']);
|
$_POST['message'] = preg_replace('/[\r\n]/', '', $_POST['message']);
|
||||||
$_POST['message'] = str_replace('%length%', $length_english, $_POST['message']);
|
$_POST['message'] = str_replace('%length%', $length_english, $_POST['message']);
|
||||||
$_POST['message'] = str_replace('%LENGTH%', strtoupper($length_english), $_POST['message']);
|
$_POST['message'] = str_replace('%LENGTH%', strtoupper($length_english), $_POST['message']);
|
||||||
|
@ -77,6 +77,13 @@
|
|||||||
</p>
|
</p>
|
||||||
<p>{% trans %}Your IP address is{% endtrans %} <strong>{{ ban.ip }}</strong>.</p>
|
<p>{% trans %}Your IP address is{% endtrans %} <strong>{{ ban.ip }}</strong>.</p>
|
||||||
|
|
||||||
|
{% if post %}
|
||||||
|
<hr>
|
||||||
|
<p>You were banned for the following post on {{ board.url }}:</p>
|
||||||
|
{{ post }}
|
||||||
|
<br>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% if config.ban_page_extra %}
|
{% if config.ban_page_extra %}
|
||||||
<p>{{ config.ban_page_extra }}</p>
|
<p>{{ config.ban_page_extra }}</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user