diff --git a/inc/config.php b/inc/config.php index 092b1005..fff3341c 100644 --- a/inc/config.php +++ b/inc/config.php @@ -240,6 +240,8 @@ $config['mod']['ban'] = MOD; // Ban and delete (one click; instant) $config['mod']['bandelete'] = MOD; + // Remove bans + $config['mod']['unban'] = MOD; // Delete file (and keep post) $config['mod']['deletefile'] = JANITOR; // Delete all posts by IP @@ -269,6 +271,8 @@ $config['mod']['view_banquestionmark'] = false; // Show expired bans in the ban list (they are kept in cache until the culprit returns) $config['mod']['view_banexpired'] = true; + // View ban for IP address + $config['mod']['view_ban'] = $config['mod']['view_banlist']; // Create a new board $config['mod']['newboard'] = ADMIN; diff --git a/inc/functions.php b/inc/functions.php index 08b1ff25..d0929eef 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -650,7 +650,7 @@ } else { // Use a pre-defined confusing name $name = $config['spam']['hidden_input_names'][$hidden_input_names_x++]; - if($hidden_input_names_x > count($config['spam']['hidden_input_names'])) + if($hidden_input_names_x >= count($config['spam']['hidden_input_names'])) $hidden_input_names_x = -1; } diff --git a/mod.php b/mod.php index 86ae4b5d..bc162a9a 100644 --- a/mod.php +++ b/mod.php @@ -105,7 +105,7 @@ } elseif(preg_match('/^\/bans$/', $query)) { if($mod['type'] < $config['mod']['view_banlist']) error($config['error']['noaccess']); - if($config['mod']['view_banexpired']) { + if($mod['type'] >= $config['mod']['view_banexpired']) { $query = prepare("SELECT * FROM `bans` INNER JOIN `mods` ON `mod` = `id` GROUP BY `ip` ORDER BY `expires` < :time, `set` DESC"); $query->bindValue(':time', time(), PDO::PARAM_INT); $query->execute() or error(db_error($query)); @@ -186,6 +186,29 @@ 'mod'=>true ) ); + } elseif(preg_match('/^\/rebuild$/', $query)) { + // For debugging + set_time_limit(0); + + header('Content-Type: text/plain'); + if($mod['type'] != ADMIN) die('Admins only!'); + + $boards = listBoards(); + + foreach($boards as &$board) { + echo "Opening board /{$board['uri']}/\n"; + openBoard($board['uri']); + + echo "Creating index pages\n"; + buildIndex(); + + $query = query(sprintf("SELECT `id` FROM `posts_%s` WHERE `thread` IS NULL", $board['uri'])) or error(db_error()); + while($post = $query->fetch()) { + echo "Rebuilding #{$post['id']}\n"; + buildThread($post['id']); + } + } + echo "Complete!\n"; } elseif(preg_match('/^\/config$/', $query)) { if($mod['type'] < $config['mod']['show_config']) error($config['error']['noaccess']); @@ -571,8 +594,12 @@ // Redirect if(isset($_POST['continue'])) header('Location: ' . $_POST['continue'], true, $config['redirect_http']); + elseif(isset($board)) + header('Location: ?/' . sprintf($config['board_path'], $boardName) . $config['file_index'], true, $config['redirect_http']); + elseif(isset($_SERVER['HTTP_REFERER'])) + header('Location: ' . $_SERVER['HTTP_REFERER'], true, $config['redirect_http']); else - header('Location: ?/' . sprintf($config['board_path'], $boardName) . $config['file_index'], true, $config['redirect_http']); + header('Location: ?/', true, $config['redirect_http']); } } elseif(preg_match('/^\/' . $regex['board'] . 'ban(&delete)?\/(\d+)$/', $query, $matches)) { if($mod['type'] < $config['mod']['delete']) error($config['error']['noaccess']); @@ -610,6 +637,13 @@ $ip = $matches[1]; $host = $config['mod']['dns_lookup'] ? gethostbyaddr($ip) : false; + if($mod['type'] >= $config['mod']['unban'] && isset($_POST['unban'])) { + $query = prepare("DELETE FROM `bans` WHERE `ip` = :ip"); + $query->bindValue(':ip', $ip); + $query->execute() or error(db_error($query)); + } + + $body = ''; $boards = listBoards(); foreach($boards as &$_board) { @@ -633,7 +667,65 @@ '' . $temp . ''; } - if($config['mod']['ip_banform']) + if($mod['type'] >= $config['mod']['view_ban']) { + $query = prepare("SELECT * FROM `bans` INNER JOIN `mods` ON `mod` = `id` WHERE `ip` = :ip"); + $query->bindValue(':ip', $ip); + $query->execute() or error(db_error($query)); + + if($query->rowCount() > 0) { + $body .= '
Ban' . ($query->rowCount() == 1 ? '' : 's') . ' on record
'; + + while($ban = $query->fetch()) { + $body .= '' . + + // IP + '' . + + // Reason + '' . + + // Set + '' . + + // Expires + '' . + + // Staff + '' . + + '
Status' . + ($config['mod']['view_banexpired'] && $ban['expires'] != 0 && $ban['expires'] < time() ? + 'Expired' + : 'Active') . + '
IP' . $ban['ip'] . '
Reason' . $ban['reason'] . '
Set' . date($config['post_date'], $ban['set']) . '
Expires' . + ($ban['expires'] == 0 ? + 'Never' + : + date($config['post_date'], $ban['expires']) + ) . + '
Staff' . + ($mod['type'] < $config['mod']['view_banstaff'] ? + ($config['mod']['view_banquestionmark'] ? + '?' + : + ($ban['type'] == JANITOR ? 'Janitor' : + ($ban['type'] == MOD ? 'Mod' : + ($ban['type'] == ADMIN ? 'Admin' : + '?'))) + ) + : + $ban['username'] + ) . + '
'; + } + + $body .= '
'; + } + } + + if($mod['type'] >= $config['mod']['ip_banform']) $body .= form_newBan($ip, null, isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : false); echo Element('page.html', Array( diff --git a/style.css b/style.css index 5813ec57..b7550664 100644 --- a/style.css +++ b/style.css @@ -172,6 +172,7 @@ div.post.reply p.body { margin-top: 0.8em; padding-right: 3em; padding-bottom: 0.3em; + word-wrap: break-word; } div.post.reply.highlighted { background: #D6BAD0; @@ -187,6 +188,7 @@ div.post.reply { border-width: 1px; border-style: none solid solid none; border-color: #B7C5D9; + max-width: 97%; } span.trip { color: #228854;