Example #1
0
                $tc_db->Execute("UPDATE `" . KU_DBPREFIX . "posts` SET `bumped` = '" . time() . "' WHERE `boardid` = " . $board_class->board['id'] . " AND `id` = '" . $thread_replyto . "'");
            }
        }
        // If the user replied to a thread he is watching, update it so it doesn't count his reply as unread
        if (KU_WATCHTHREADS && $thread_replyto != '0') {
            $viewing_thread_is_watched = $tc_db->GetOne("SELECT COUNT(*) FROM `" . KU_DBPREFIX . "watchedthreads` WHERE `ip` = '" . $_SERVER['REMOTE_ADDR'] . "' AND `board` = '" . $board_class->board['name'] . "' AND `threadid` = '" . $thread_replyto . "'");
            if ($viewing_thread_is_watched > 0) {
                $newestreplyid = $tc_db->GetOne('SELECT `id` FROM `' . KU_DBPREFIX . 'posts` WHERE `boardid` = ' . $board_class->board['id'] . ' AND `IS_DELETED` = 0 AND `parentid` = ' . $thread_replyto . ' ORDER BY `id` DESC LIMIT 1');
                $tc_db->Execute("UPDATE `" . KU_DBPREFIX . "watchedthreads` SET `lastsawreplyid` = " . $newestreplyid . " WHERE `ip` = '" . $_SERVER['REMOTE_ADDR'] . "' AND `board` = '" . $board_class->board['name'] . "' AND `threadid` = '" . $thread_replyto . "'");
            }
        }
        $tc_db->Execute("COMMIT");
        // Trim any threads which have been pushed past the limit, or exceed the maximum age limit
        TrimToPageLimit($board_class->board);
        // Regenerate board pages
        $board_class->RegeneratePages();
        if ($thread_replyto == '0') {
            // Regenerate the thread
            $board_class->RegenerateThreads($post_id);
        } else {
            // Regenerate the thread
            $board_class->RegenerateThreads($thread_replyto);
        }
    } else {
        exitWithErrorPage(_gettext('Sorry, this board is locked and can not be posted in.'));
    }
} elseif ((isset($_POST['deletepost']) || isset($_POST['reportpost']) || isset($_POST['moddelete']) || isset($_POST['edit'])) && isset($_POST['post'])) {
    $ismod = false;
    // Initialize the post class
    foreach ($_POST['post'] as $val) {
        $post_class = new Post($val, $board_class->board['name'], $board_class->board['id']);
Example #2
0
    function bans()
    {
        global $tc_db, $tpl_page, $bans_class;
        $this->ModeratorsOnly();
        $reason = KU_BANREASON;
        $ban_ip = '';
        $ban_hash = '';
        $ban_parentid = 0;
        $multiban = array();
        if (isset($_POST['modban']) && is_array($_POST['post']) && $_POST['board']) {
            $ban_board_id = $tc_db->GetOne("SELECT HIGH_PRIORITY `id` FROM `" . KU_DBPREFIX . "boards` WHERE `name` = " . $tc_db->qstr($_POST['board']) . "");
            if (!empty($ban_board_id)) {
                foreach ($_POST['post'] as $post) {
                    $results = $tc_db->GetAll("SELECT HIGH_PRIORITY * FROM `" . KU_DBPREFIX . "posts` WHERE `boardid` = '" . $ban_board_id . "' AND `id` = " . intval($post) . "");
                    if (count($results) > 0) {
                        $multiban[] = md5_decrypt($results[0]['ip'], KU_RANDOMSEED);
                        $multiban_hash[] = $results[0]['file_md5'];
                        $multiban_parentid[] = $results[0]['parentid'];
                    }
                }
            }
        }
        if (isset($_GET['banboard']) && isset($_GET['banpost'])) {
            $ban_board_id = $tc_db->GetOne("SELECT HIGH_PRIORITY `id` FROM `" . KU_DBPREFIX . "boards` WHERE `name` = " . $tc_db->qstr($_GET['banboard']) . "");
            $ban_board = $_GET['banboard'];
            $ban_post_id = $_GET['banpost'];
            if (!empty($ban_board_id)) {
                $results = $tc_db->GetAll("SELECT HIGH_PRIORITY * FROM `" . KU_DBPREFIX . "posts` WHERE `boardid` = '" . $ban_board_id . "' AND `id` = " . $tc_db->qstr($_GET['banpost']) . "");
                if (count($results) > 0) {
                    $ban_ip = md5_decrypt($results[0]['ip'], KU_RANDOMSEED);
                    $ban_hash = $results[0]['file_md5'];
                    $ban_parentid = $results[0]['parentid'];
                } else {
                    $tpl_page .= _gettext('A post with that ID does not exist.') . '<hr />';
                }
            }
        }
        $instantban = false;
        if ((isset($_GET['instant']) || isset($_GET['cp'])) && $ban_ip) {
            if (isset($_GET['cp'])) {
                $ban_reason = "You have been banned for posting Child Pornography. Your IP has been logged, and the proper authorities will be notified.";
            } else {
                if ($_GET['reason']) {
                    $ban_reason = urldecode($_GET['reason']);
                } else {
                    $ban_Reason = KU_BANREASON;
                }
            }
            $instantban = true;
        }
        $tpl_page .= '<h2>' . _gettext('Bans') . '</h2><br />';
        if ((isset($_POST['ip']) || isset($_POST['multiban'])) && isset($_POST['seconds']) && (!empty($_POST['ip']) || empty($_POST['ip']) && !empty($_POST['multiban'])) || $instantban) {
            if ($_POST['seconds'] >= 0 || $instantban) {
                $banning_boards = array();
                $ban_boards = '';
                if (isset($_POST['banfromall']) || $instantban) {
                    $results = $tc_db->GetAll("SELECT HIGH_PRIORITY `name` FROM `" . KU_DBPREFIX . "boards`");
                    foreach ($results as $line) {
                        if (!$this->CurrentUserIsModeratorOfBoard($line['name'], $_SESSION['manageusername'])) {
                            exitWithErrorPage('/' . $line['name'] . '/: ' . _gettext('You can only make bans applying to boards you moderate.'));
                        }
                    }
                } else {
                    if (empty($_POST['bannedfrom'])) {
                        exitWithErrorPage(_gettext('Please select a board.'));
                    }
                    if (isset($_POST['deleteposts'])) {
                        $_POST['deletefrom'] = $_POST['bannedfrom'];
                    }
                    foreach ($_POST['bannedfrom'] as $board) {
                        if (!$this->CurrentUserIsModeratorOfBoard($board, $_SESSION['manageusername'])) {
                            exitWithErrorPage('/' . $board . '/: ' . _gettext('You can only make bans applying to boards you moderate.'));
                        }
                    }
                    $ban_boards = implode('|', $_POST['bannedfrom']);
                }
                $ban_globalban = isset($_POST['banfromall']) || $instantban ? 1 : 0;
                $ban_allowread = ($_POST['allowread'] = 0 || $instantban) ? 0 : 1;
                if (isset($_POST['quickbanboardid'])) {
                    $ban_board_id = $_POST['quickbanboardid'];
                }
                if (isset($_POST['quickbanboard'])) {
                    $ban_board = $_POST['quickbanboard'];
                }
                if (isset($_POST['quickbanpostid'])) {
                    $ban_post_id = $_POST['quickbanpostid'];
                }
                $ban_ip = $instantban ? $ban_ip : $_POST['ip'];
                $ban_duration = $_POST['seconds'] == 0 || $instantban ? 0 : $_POST['seconds'];
                $ban_type = $_POST['type'] <= 2 && $_POST['type'] >= 0 ? $_POST['type'] : 0;
                $ban_reason = $instantban ? $ban_reason : $_POST['reason'];
                $ban_note = $instantban ? '' : $_POST['staffnote'];
                $ban_appealat = 0;
                if (KU_APPEAL != '' && !$instantban) {
                    $ban_appealat = intval($_POST['appealdays'] * 86400);
                    if ($ban_appealat > 0) {
                        $ban_appealat += time();
                    }
                }
                if (isset($_POST['multiban'])) {
                    $ban_ips = unserialize($_POST['multiban']);
                } else {
                    $ban_ips = array($ban_ip);
                }
                foreach ($ban_ips as $ban_ip) {
                    $whitelist = $tc_db->GetAll("SELECT `ipmd5` FROM `" . KU_DBPREFIX . "banlist` WHERE `type` = 2");
                    if (in_array(md5($ban_ip), $whitelist)) {
                        exitWithErrorPage(_gettext('That IP is on the whitelist'));
                    }
                    if ($bans_class->BanUser($ban_ip, $_SESSION['manageusername'], $ban_globalban, $ban_duration, $ban_boards, $ban_reason, $ban_note, $ban_appealat, $ban_type, $ban_allowread)) {
                        if ((KU_BANMSG != '' || $_POST['banmsg'] != '') && isset($_POST['addbanmsg']) && (isset($_POST['quickbanpostid']) || isset($_POST['quickmultibanpostid'])) || $instantban) {
                            $ban_msg = KU_BANMSG == $_POST['banmsg'] || empty($_POST['banmsg']) ? KU_BANMSG : $_POST['banmsg'];
                            if (isset($ban_post_id)) {
                                $postids = array($ban_post_id);
                            } else {
                                $postids = unserialize($_POST['quickmultibanpostid']);
                            }
                            foreach ($postids as $ban_post_id) {
                                $results = $tc_db->GetAll("SELECT HIGH_PRIORITY `parentid`, `message` FROM `" . KU_DBPREFIX . "posts` WHERE `boardid` = " . $tc_db->qstr($ban_board_id) . " AND `id` = " . $tc_db->qstr($ban_post_id) . " LIMIT 1");
                                foreach ($results as $line) {
                                    $tc_db->Execute("UPDATE `" . KU_DBPREFIX . "posts` SET `message` = " . $tc_db->qstr($line['message'] . $ban_msg) . " WHERE `boardid` = " . $tc_db->qstr($ban_board_id) . " AND `id` = " . $tc_db->qstr($ban_post_id));
                                    clearPostCache($ban_post_id, $ban_board_id);
                                    $board_class = new Board($ban_board);
                                    if ($line['parentid'] == 0) {
                                        $board_class->RegenerateThreads($ban_post_id);
                                    } else {
                                        $board_class->RegenerateThreads($line['parentid']);
                                    }
                                    $board_class->RegeneratePages();
                                    unset($board_class);
                                }
                            }
                        }
                        $tpl_page .= _gettext('Ban successfully placed.') . "<br />";
                    } else {
                        exitWithErrorPage(_gettext('Sorry, a generic error has occurred.'));
                    }
                    $logentry = _gettext('Banned') . ' ' . $ban_ip;
                    $logentry .= $ban_duration == 0 ? ' ' . _gettext('without expiration') : ' ' . _gettext('until') . ' ' . date('F j, Y, g:i a', time() + $ban_duration);
                    $logentry .= ' - ' . _gettext('Reason') . ': ' . $ban_reason . ($ban_note ? " (" . $ban_note . ")" : "") . ' - ' . _gettext('Banned from') . ': ';
                    $logentry .= $ban_globalban == 1 ? _gettext('All boards') . ' ' : '/' . implode('/, /', explode('|', $ban_boards)) . '/ ';
                    management_addlogentry($logentry, 8);
                    $ban_ip = '';
                }
                if (isset($_POST['deleteposts'])) {
                    $tpl_page .= '<br />';
                    $this->deletepostsbyip(true);
                }
                if (isset($_GET['instant']) && !isset($_GET['cp'])) {
                    die("success");
                }
                if (isset($_POST['banhashtime']) && $_POST['banhashtime'] !== '' && ($_POST['hash'] !== '' || isset($_POST['multibanhashes'])) && $_POST['banhashtime'] >= 0) {
                    if (isset($_POST['multibanhashes'])) {
                        $banhashes = unserialize($_POST['multibanhashes']);
                    } else {
                        $banhashes = array($_POST['hash']);
                    }
                    foreach ($banhashes as $banhash) {
                        $results = $tc_db->GetOne("SELECT HIGH_PRIORITY COUNT(*) FROM `" . KU_DBPREFIX . "bannedhashes` WHERE `md5` = " . $tc_db->qstr($banhash) . " LIMIT 1");
                        if ($results == 0) {
                            $tc_db->Execute("INSERT INTO `" . KU_DBPREFIX . "bannedhashes` ( `md5` , `bantime` , `description` ) VALUES ( " . $tc_db->qstr($banhash) . " , " . $tc_db->qstr($_POST['banhashtime']) . " , " . $tc_db->qstr($_POST['banhashdesc']) . " )");
                            management_addlogentry('Banned md5 hash ' . $banhash . ' with a description of ' . $_POST['banhashdesc'], 8);
                        }
                    }
                }
                if (!empty($_POST['quickbanboard']) && !empty($_POST['quickbanthreadid'])) {
                    $tpl_page .= '<br /><br /><meta http-equiv="refresh" content="1;url=' . KU_BOARDSPATH . '/' . $_POST['quickbanboard'] . '/';
                    if ($_POST['quickbanthreadid'] != '0') {
                        $tpl_page .= 'res/' . $_POST['quickbanthreadid'] . '.html';
                    }
                    $tpl_page .= '"><a href="' . KU_BOARDSPATH . '/' . $_POST['quickbanboard'] . '/';
                    if ($_POST['quickbanthreadid'] != '0') {
                        $tpl_page .= 'res/' . $_POST['quickbanthreadid'] . '.html';
                    }
                    $tpl_page .= '">' . _gettext('Redirecting') . '</a>...';
                }
            } else {
                $tpl_page .= _gettext('Please enter a positive amount of seconds, or zero for a permanent ban.');
            }
            $tpl_page .= '<hr />';
        } elseif (isset($_GET['delban']) && $_GET['delban'] > 0) {
            $results = $tc_db->GetAll("SELECT HIGH_PRIORITY * FROM `" . KU_DBPREFIX . "banlist` WHERE `id` = " . $tc_db->qstr($_GET['delban']) . "");
            if (count($results) > 0) {
                $unban_ip = md5_decrypt($results[0]['ip'], KU_RANDOMSEED);
                $tc_db->Execute("DELETE FROM `" . KU_DBPREFIX . "banlist` WHERE `id` = " . $tc_db->qstr($_GET['delban']) . "");
                $bans_class->UpdateHtaccess();
                $tpl_page .= _gettext('Ban successfully removed.');
                management_addlogentry(_gettext('Unbanned') . ' ' . $unban_ip, 8);
            } else {
                $tpl_page .= _gettext('Invalid ban ID');
            }
            $tpl_page .= '<br /><hr />';
        } elseif (isset($_GET['delhashid'])) {
            $results = $tc_db->GetAll("SELECT HIGH_PRIORITY * FROM `" . KU_DBPREFIX . "bannedhashes` WHERE `id` = " . $tc_db->qstr($_GET['delhashid']) . "");
            if (count($results) > 0) {
                $tc_db->Execute("DELETE FROM `" . KU_DBPREFIX . "bannedhashes` WHERE `id` = " . $tc_db->qstr($_GET['delhashid']) . "");
                $tpl_page .= _gettext('Hash removed from ban list.') . '<br /><hr />';
            }
        }
        flush();
        $isquickban = false;
        $tpl_page .= '<form action="manage_page.php?action=bans" method="post" name="banform">';
        if (!empty($ban_ip) && isset($_GET['banboard']) && isset($_GET['banpost']) || !empty($multiban) && isset($_POST['board']) && isset($_POST['post'])) {
            $isquickban = true;
            $tpl_page .= '<input type="hidden" name="quickbanboard" value="' . (isset($_GET['banboard']) ? $_GET['banboard'] : $_POST['board']) . '" />';
            if (!empty($multiban)) {
                $tpl_page .= '<input type="hidden" name="quickbanboardid" value="' . $ban_board_id . '" /><input type="hidden" name="quickmultibanthreadid" value="' . htmlspecialchars(serialize($multiban_parentid)) . '" /><input type="hidden" name="quickmultibanpostid" value="' . htmlspecialchars(serialize($_POST['post'])) . '" />';
            } else {
                $tpl_page .= '<input type="hidden" name="quickbanboardid" value="' . $ban_board_id . '" /><input type="hidden" name="quickbanthreadid" value="' . $ban_parentid . '" /><input type="hidden" name="quickbanpostid" value="' . $_GET['banpost'] . '" />';
            }
        } elseif (isset($_GET['ip'])) {
            $ban_ip = $_GET['ip'];
        }
        $tpl_page .= '<fieldset>
		<legend>' . _gettext('IP address and ban type') . '</legend>
		<label for="ip">' . _gettext('IP') . ':</label>';
        if (!$multiban) {
            $tpl_page .= '<input type="text" name="ip" id="ip" value="' . $ban_ip . '" />
			<br /><label for="deleteposts">' . _gettext('Delete all posts by this IP') . ':</label>
			<input type="checkbox" name="deleteposts" id="deleteposts" />';
        } else {
            $tpl_page .= '<input type="hidden" name="multiban" value="' . htmlspecialchars(serialize($multiban)) . '">
			<input type="hidden" name="multibanhashes" value="' . htmlspecialchars(serialize($multiban_hash)) . '">	Multiple IPs
			<br /><label for="deleteposts">' . _gettext('Delete all posts by these IPs') . ':</label>
			<input type="checkbox" name="deleteposts" id="deleteposts" />';
        }
        $tpl_page .= '<br />
		<label for="allowread">' . _gettext('Allow read') . ':</label>
		<select name="allowread" id="allowread"><option value="1">' . _gettext('Yes') . '</option><option value="0">' . _gettext('No') . '</option></select>
		<div class="desc">' . _gettext('Whether or not the user(s) affected by this ban will be allowed to read the boards.') . '<br /><strong>' . _gettext('Warning') . ':</strong> ' . _gettext('Selecting "No" will prevent any reading of any page on the level of the boards on the server. It will also act as a global ban.') . '</div><br />

		<label for="type">' . _gettext('Type') . ':</label>
		<select name="type" id="type"><option value="0">' . _gettext('Single IP') . '</option><option value="1">' . _gettext('IP Range') . '</option><option value="2">' . _gettext('Whitelist') . '</option></select>
		<div class="desc">' . _gettext('The type of ban. A single IP can be banned by providing the full address. A whitelist ban prevents that IP from being banned. An IP range can be banned by providing the IP range you would like to ban, in this format: 123.123.12') . '</div><br />';
        if ($isquickban && KU_BANMSG != '') {
            $tpl_page .= '<label for="addbanmsg">' . _gettext('Add ban message') . ':</label>
			<input type="checkbox" name="addbanmsg" id="addbanmsg" checked="checked" />
			<div class="desc">' . _gettext('If checked, the configured ban message will be added to the end of the post.') . '</div><br />
			<label for="banmsg">' . _gettext('Ban message') . ':</label>
			<input type="text" name="banmsg" id="banmsg" value="' . htmlspecialchars(KU_BANMSG) . '" size=' . strlen(KU_BANMSG) . '" />';
        }
        $tpl_page .= '</fieldset>
		<fieldset>
		<legend> ' . _gettext('Ban from') . '</legend>
		<label for="banfromall"><strong>' . _gettext('All boards') . '</strong></label>
		<input type="checkbox" name="banfromall" id="banfromall" /><br /><hr /><br />' . $this->MakeBoardListCheckboxes('bannedfrom', $this->BoardList($_SESSION['manageusername'])) . '</fieldset>';
        if (isset($ban_hash)) {
            $tpl_page .= '<fieldset>
			<legend>' . _gettext('Ban file') . '</legend>
			<input type="hidden" name="hash" value="' . $ban_hash . '" />

			<label for="banhashtime">' . _gettext('Ban file hash for') . ':</label>
			<input type="text" name="banhashtime" id="banhashtime" />
			<div class="desc">' . _gettext('The amount of time to ban the hash of the image which was posted under this ID. Leave blank to not ban the image, 0 for an infinite global ban, or any number of seconds for that duration of a global ban.') . '</div><br />

			<label for="banhashdesc">' . _gettext('Ban file hash description') . ':</label>
			<input type="text" name="banhashdesc" id="banhashdesc" />
			<div class=desc">' . _gettext('The description of the image being banned. Not applicable if the above box is blank.') . '</div>
			</fieldset>';
        }
        $tpl_page .= '<fieldset>
		<legend>' . _gettext('Ban duration, reason, and appeal information') . '</legend>
		<label for="seconds">' . _gettext('Seconds') . ':</label>
		<input type="text" name="seconds" id="seconds" />
		<div class="desc">' . _gettext('Presets') . ':&nbsp;<a href="#" onclick="document.banform.seconds.value=\'3600\';return false;">1hr</a>&nbsp;<a href="#" onclick="document.banform.seconds.value=\'86400\';return false;">1d</a>&nbsp;<a href="#" onclick="document.banform.seconds.value=\'259200\';return false;">3d</a>&nbsp;<a href="#" onclick="document.banform.seconds.value=\'604800\';return false;">1w</a>&nbsp;<a href="#" onclick="document.banform.seconds.value=\'1209600\';return false;">2w</a>&nbsp;<a href="#" onclick="document.banform.seconds.value=\'2592000\';return false;">30d</a>&nbsp;<a href="#" onclick="document.banform.seconds.value=\'31536000\';return false;">1yr</a>&nbsp;<a href="#" onclick="document.banform.seconds.value=\'0\';return false;">' . _gettext('never') . '</a></div><br />

		<label for="reason">' . _gettext('Reason') . ':</label>
		<input type="text" name="reason" id="reason" value="' . $reason . '" />
		<div class="desc">' . _gettext('Presets') . ':&nbsp;<a href="#" onclick="document.banform.reason.value=\'' . _gettext('Child Pornography') . '\';return false;">CP</a>&nbsp;<a href="#" onclick="document.banform.reason.value=\'' . _gettext('Proxy') . '\';return false;">' . _gettext('Proxy') . '</a></div><br />

		<label for="staffnote">' . _gettext('Staff Note') . '</label>
		<input type="text" name="staffnote" id="staffnote" />
		<div class="desc">' . _gettext('Presets') . ':&nbsp;<a href="#" onclick="document.banform.staffnote.value=\'' . _gettext('Child Pornography') . '\';return false;">CP</a> || ' . _gettext('This message will be shown only on this page and only to staff, not to the user.') . '</div><br />';
        if (KU_APPEAL != '') {
            $tpl_page .= '<label for="appealdays">' . _gettext('Appeal (days)') . ':</label>
			<input type="text" name="appealdays" id="appealdays" value="5" />
			<div class="desc">' . _gettext('Presets') . ':&nbsp;<a href="#" onclick="document.banform.appealdays.value=\'0\';return false;">' . _gettext('No Appeal') . '</a>&nbsp;<a href="#" onclick="document.banform.appealdays.value=\'5\';return false;">5 ' . _gettext('days') . '</a>&nbsp;<a href="#" onclick="document.banform.appealdays.value=\'10\';return false;">10 ' . _gettext('days') . '</a>&nbsp;<a href="#" onclick="document.banform.appealdays.value=\'30\';return false;">30 ' . _gettext('days') . '</a></div><br />';
        }
        $tpl_page .= '</fieldset>
		<input type="submit" value="' . _gettext('Add ban') . '" /><img src="clear.gif" />

		</form>
		<hr /><br />';
        for ($i = 2; $i >= 0; $i--) {
            switch ($i) {
                case 2:
                    $tpl_page .= '<strong>' . _gettext('Whitelisted IPs') . ':</strong><br />';
                    break;
                case 1:
                    $tpl_page .= '<br /><strong>' . _gettext('IP Range Bans') . ':</strong><br />';
                    break;
                case 0:
                    if (!empty($ban_ip)) {
                        $tpl_page .= '<br /><strong>' . _gettext('Previous bans on this IP') . ':</strong><br />';
                    } else {
                        $tpl_page .= '<br /><strong>' . _gettext('Single IP Bans') . ':</strong><br />';
                    }
                    break;
            }
            if (isset($_GET['allbans'])) {
                $results = $tc_db->GetAll("SELECT HIGH_PRIORITY * FROM `" . KU_DBPREFIX . "banlist` WHERE `type` = '" . $i . "' AND `by` != 'SERVER' ORDER BY `id` DESC");
                $hiddenbans = 0;
            } elseif (isset($_GET['limit'])) {
                $results = $tc_db->GetAll("SELECT HIGH_PRIORITY * FROM `" . KU_DBPREFIX . "banlist` WHERE `type` = '" . $i . "' ORDER BY `id` DESC LIMIT " . intval($_GET['limit']));
                $hiddenbans = 0;
            } else {
                if (!empty($ban_ip) && $i == 0) {
                    $results = $tc_db->GetAll("SELECT HIGH_PRIORITY * FROM `" . KU_DBPREFIX . "banlist` WHERE `ipmd5` = '" . md5($ban_ip) . "' AND `type` = '" . $i . "' AND `by` != 'SERVER' ORDER BY `id` DESC");
                } else {
                    $results = $tc_db->GetAll("SELECT HIGH_PRIORITY * FROM `" . KU_DBPREFIX . "banlist` WHERE `type` = '" . $i . "' AND `by` != 'SERVER' ORDER BY `id` DESC LIMIT 15");
                    // Get the number of bans in the database of this type
                    $hiddenbans = $tc_db->GetAll("SELECT HIGH_PRIORITY COUNT(*) FROM `" . KU_DBPREFIX . "banlist` WHERE `type` = '" . $i . "'");
                    // Subtract 15 from the count, since we only want the number not shown
                    $hiddenbans = $hiddenbans[0][0] - 15;
                }
            }
            if (count($results) > 0) {
                $tpl_page .= '<table border="1" width="100%"><tr><th>';
                $tpl_page .= $i == 1 ? _gettext('IP Range') : _gettext('IP Address');
                $tpl_page .= '</th><th>' . _gettext('Boards') . '</th><th>' . _gettext('Reason') . '</th><th>' . _gettext('Staff Note') . '</th><th>' . _gettext('Date added') . '</th><th>' . _gettext('Expires/Expired') . '</th><th>' . _gettext('Added By') . '</th><th>&nbsp;</th></tr>';
                foreach ($results as $line) {
                    $tpl_page .= '<tr><td><a href="?action=bans&ip=' . md5_decrypt($line['ip'], KU_RANDOMSEED) . '">' . md5_decrypt($line['ip'], KU_RANDOMSEED) . '</a></td><td>';
                    if ($line['globalban'] == 1) {
                        $tpl_page .= '<strong>' . _gettext('All boards') . '</strong>';
                    } elseif (!empty($line['boards'])) {
                        $tpl_page .= '<strong>/' . implode('/</strong>, <strong>/', explode('|', $line['boards'])) . '/</strong>&nbsp;';
                    }
                    $tpl_page .= '</td><td>';
                    $tpl_page .= !empty($line['reason']) ? htmlentities(stripslashes($line['reason'])) : '&nbsp;';
                    $tpl_page .= '</td><td>';
                    $tpl_page .= !empty($line['staffnote']) ? htmlentities(stripslashes($line['staffnote'])) : '&nbsp;';
                    $tpl_page .= '</td><td>' . date("F j, Y, g:i a", $line['at']) . '</td><td>';
                    $tpl_page .= $line['until'] == 0 ? '<strong>' . _gettext('Does not expire') . '</strong>' : date("F j, Y, g:i a", $line['until']);
                    $tpl_page .= '</td><td>' . $line['by'] . '</td><td>[<a href="manage_page.php?action=bans&delban=' . $line['id'] . '">' . _gettext('Delete') . '</a>]</td></tr>';
                }
                $tpl_page .= '</table>';
                if ($hiddenbans > 0) {
                    $tpl_page .= sprintf(_gettext('%s bans not shown.'), $hiddenbans) . ' <a href="?action=bans&allbans=1">' . _gettext('View all bans') . '</a>' . ' <a href="?action=bans&limit=100">View last 100 bans</a>';
                }
            } else {
                $tpl_page .= _gettext('There are currently no bans');
            }
        }
        $tpl_page .= '<br /><br /><strong>' . _gettext('File hash bans') . ':</strong><br /><table border="1" width="100%"><tr><th>' . _gettext('Hash') . '</th><th>' . _gettext('Description') . '</th><th>' . _gettext('Ban time') . '</th><th>&nbsp;</th></tr>';
        $results = $tc_db->GetAll("SELECT HIGH_PRIORITY * FROM `" . KU_DBPREFIX . "bannedhashes` " . (!isset($_GET['allbans']) ? "LIMIT 5" : ""));
        if (count($results) == 0) {
            $tpl_page .= '<tr><td colspan="4">' . _gettext('None') . '</td></tr>';
        } else {
            foreach ($results as $line) {
                $tpl_page .= '<tr><td>' . $line['md5'] . '</td><td>' . $line['description'] . '</td><td>';
                $tpl_page .= $line['bantime'] == 0 ? '<strong>' . _gettext('Does not expire') . '</strong>' : $line['bantime'] . ' seconds';
                $tpl_page .= '</td><td>[<a href="?action=bans&delhashid=' . $line['id'] . '">x</a>]</td></tr>';
            }
        }
        $tpl_page .= '</table>';
    }