diff --git a/inc/mod/ban.php b/inc/mod/ban.php new file mode 100644 index 00000000..236b2b14 --- /dev/null +++ b/inc/mod/ban.php @@ -0,0 +1,77 @@ +bindValue(':ip', $mask); + $query->bindValue(':mod', $mod['id']); + if ($reason !== '') + $query->bindValue(':reason', $reason); + else + $query->bindValue(':reason', null, PDO::PARAM_NULL); + + if ($length > 0) + $query->bindValue(':expires', time() + $length); + else + $query->bindValue(':expires', null, PDO::PARAM_NULL); + + if ($board) + $query->bindValue(':board', $board); + else + $query->bindValue(':board', null, PDO::PARAM_NULL); + + $query->execute() or error(db_error($query)); +} diff --git a/inc/mod/pages.php b/inc/mod/pages.php index 9d154181..c00cd672 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -94,12 +94,17 @@ function mod_view_thread($boardName, $thread) { function mod_page_ip($ip) { global $config, $mod; + if(filter_var($ip, FILTER_VALIDATE_IP) === false) + error("Invalid IP address."); + $args = array(); $args['ip'] = $ip; $args['posts'] = array(); $boards = listBoards(); foreach ($boards as $board) { + openBoard($board['uri']); + $query = prepare(sprintf('SELECT * FROM `posts_%s` WHERE `ip` = :ip ORDER BY `sticky` DESC, `id` DESC LIMIT :limit', $board['uri'])); $query->bindValue(':ip', $ip); $query->bindValue(':limit', $config['mod']['ip_recentposts'], PDO::PARAM_INT); @@ -122,11 +127,30 @@ function mod_page_ip($ip) { } if (!isset($args['posts'][$board['uri']])) - $args['posts'][$board['uri']] = array(); - $args['posts'][$board['uri']][] = $po->build(true); + $args['posts'][$board['uri']] = array('board' => $board, 'posts' => array()); + $args['posts'][$board['uri']]['posts'][] = $po->build(true); } } + $args['boards'] = $boards; + mod_page("IP: $ip", 'mod/view_ip.html', $args); } +function mod_page_ban() { + if(!isset($_POST['ip'], $_POST['reason'], $_POST['length'], $_POST['board'])) + error($config['error']['missedafield']); + + $ip = $_POST['ip']; + + require_once 'inc/mod/ban.php'; + + ban($_POST['ip'], $_POST['reason'], parse_time($_POST['length']), $_POST['board'] == '*' ? false : $_POST['board']); + + + if(isset($_POST['redirect'])) + header('Location: ' . $_POST['redirect'], true, $config['redirect_http']); + else + header('Location: ?/', true, $config['redirect_http']); +} + diff --git a/mod.php b/mod.php index 0ac83f46..5f2cad56 100644 --- a/mod.php +++ b/mod.php @@ -25,10 +25,11 @@ $pages = array( '!^/$!' => 'dashboard', // dashboard '!^/IP/(.+)$!' => 'ip', // view ip address + '!^/ban$!' => 'ban', // new ban // This should always be at the end: '!^/(\w+)/' . preg_quote($config['file_index'], '!') . '?$!' => 'view_board', - '!^/(\w+)/' . str_replace('%d', '(\d+)', preg_quote($config['file_page'], '!')) . '$!/' => 'view_board', + '!^/(\w+)/' . str_replace('%d', '(\d+)', preg_quote($config['file_page'], '!')) . '$!' => 'view_board', '!^/(\w+)/' . preg_quote($config['dir']['res'], '!') . str_replace('%d', '(\d+)', preg_quote($config['file_page'], '!')) . '$!' => 'view_thread', ); diff --git a/templates/mod/ban_form.html b/templates/mod/ban_form.html new file mode 100644 index 00000000..1b94e725 --- /dev/null +++ b/templates/mod/ban_form.html @@ -0,0 +1,59 @@ +
+ {% if redirect %} + + {% endif %} + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + +
+ + + + (eg. "2d1h30m" or "2 days")
Board +
    +
  • + + +
  • + + {% for board in boards %} +
  • + + +
  • + {% endfor %} +
+
+
+ diff --git a/templates/mod/dashboard.html b/templates/mod/dashboard.html new file mode 100644 index 00000000..2a90d709 --- /dev/null +++ b/templates/mod/dashboard.html @@ -0,0 +1,81 @@ +
+ Boards + + +
+ +{% if mod|hasPermission(config.mod.noticeboard) %} +
+ Noticeboard + + {# TODO #} +
+{% endif %} + +
+ Administration + + +
+ +{% if mod|hasPermission(config.mod.themes) %} +
+ Themes + + {# TODO #} +
+{% endif %} + +
+ Search + + {# TODO #} +
diff --git a/templates/mod/login.html b/templates/mod/login.html new file mode 100644 index 00000000..5ac308a3 --- /dev/null +++ b/templates/mod/login.html @@ -0,0 +1,26 @@ +{% if error %}

{{ error }}

{% endif %} +
+ + + + + + + + + + + + +
+ {% trans %}Username{% endtrans %} + + +
+ {% trans %}Password{% endtrans %} + + +
+ +
+
diff --git a/templates/mod/view_ip.html b/templates/mod/view_ip.html new file mode 100644 index 00000000..3b558e4b --- /dev/null +++ b/templates/mod/view_ip.html @@ -0,0 +1,18 @@ +{% for board_posts in posts %} +
+ + {{ config.board_abbreviation|sprintf(board_posts.board.uri) }} + - + {{ board_posts.board.title }} + + {{ board_posts.posts|join('
') }} +
+{% endfor %} + +{% set redirect = '?/IP/' ~ ip %} + +
+ New ban + {% include 'mod/ban_form.html' %} +
+