|
@ -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) { |
|
|