feat: edit pre-existing bans (#528)
* feat: edit pre-existing bans * change default permission * theres no need for elseif here. related: d34f083a6b33185927c6b79a38477f4ea4ce49b5 * quote href param * changes made
This commit is contained in:
11
inc/bans.php
11
inc/bans.php
@@ -113,20 +113,22 @@ class Bans {
|
||||
return array($ipstart, $ipend);
|
||||
}
|
||||
|
||||
static public function find($ip, $board = false, $get_mod_info = false) {
|
||||
static public function find($ip, $board = false, $get_mod_info = false, $banid = null) {
|
||||
global $config;
|
||||
|
||||
|
||||
$query = prepare('SELECT ``bans``.*' . ($get_mod_info ? ', `username`' : '') . ' FROM ``bans``
|
||||
' . ($get_mod_info ? 'LEFT JOIN ``mods`` ON ``mods``.`id` = `creator`' : '') . '
|
||||
WHERE
|
||||
(' . ($board !== false ? '(`board` IS NULL OR `board` = :board) AND' : '') . '
|
||||
(`ipstart` = :ip OR (:ip >= `ipstart` AND :ip <= `ipend`)))
|
||||
(`ipstart` = :ip OR (:ip >= `ipstart` AND :ip <= `ipend`)) OR (``bans``.id = :id))
|
||||
ORDER BY `expires` IS NULL, `expires` DESC');
|
||||
|
||||
if ($board !== false)
|
||||
$query->bindValue(':board', $board, PDO::PARAM_STR);
|
||||
|
||||
$query->bindValue(':id', $banid);
|
||||
$query->bindValue(':ip', inet_pton($ip));
|
||||
|
||||
$query->execute() or error(db_error($query));
|
||||
|
||||
$ban_list = array();
|
||||
@@ -289,6 +291,9 @@ class Bans {
|
||||
$query->bindValue(':board', null, PDO::PARAM_NULL);
|
||||
|
||||
if ($post) {
|
||||
if (!isset($board['uri']))
|
||||
openBoard($post['board']);
|
||||
|
||||
$post['board'] = $board['uri'];
|
||||
$query->bindValue(':post', json_encode($post));
|
||||
} else
|
||||
|
||||
Reference in New Issue
Block a user