require '../structure/base.php';
require '../structure/forum.php';
require '../structure/forum.thread.php';
require '../structure/user.php';
$base = new base();
$database = new database($db_host, $db_name, $db_user, $db_password);
$user = new user($database);
$forum = new forum($database);
$thread_obj = new thread($database);
$user->updateLastActive();
//get the user's rank and username, and set the forum variable (less typing)
$username = $user->getUsername($_COOKIE['user'], 0);
$rank = $user->getRank($username);
$f = $_GET['forum'];
//let's also make sure they have the right permissions to view the forum
if ($forum->canView($f, $rank) == false) {
    $base->redirect('index.php');
}
//check if a moderator is taking action against threads
if (isset($_POST['action']) && isset($_POST['selection']) && $rank > 2) {
    //get all the threads we're going to update
    foreach ($_POST['selection'] as $object) {
        $threads .= $object . '-';
    }
    //now send them off to action.php to update all the threads selected
    $base->redirect('action.php?forum=' . $f . '&action=' . $_POST['action'] . '&threads=' . $threads);
}
$forum_details = $database->processQuery("SELECT `icon`,`title`,`type` FROM `forums` WHERE `id` = ? LIMIT 1", array($f), true);
//Check existence of the specified forum
if ($database->getRowCount() == 0) {
    $base->redirect('index.php');
			<table>
				<tbody>
					<tr>
						<td width="4%"></td>
						<td width="45%" class="title"></td>
						<td width="10%" class="title num">Threads</td>
						<td width="10%" class="title num">Posts</td>
						<td width="26%" class="title">Last Post</td>
					</tr>
                                        
                                        <?php 
//retrieve our categories
foreach ($forum_index->retrieveCategories($rank) as $category) {
    echo '<tr><td class="groupname" colspan="5">' . $category['title'] . '</td></tr>';
    foreach ($forum_index->retrieveSubForums($category['id']) as $s_forum) {
        if ($forum->canView($s_forum['id'], $rank)) {
            //retrieve the forum's statistics
            $statistics = $forum_index->retrieveFStatistics($s_forum['id']);
            //get appropriate icon for the section
            if ($s_forum['type'] > 3) {
                $icon = $s_forum['type'] == 4 ? '<img src="../img/forum/icons/mod.png" border="0" alt="">' : '<img src="../img/forum/icons/a_mod.png" border="0" alt="">';
            } else {
                $icon = $forum->getIcon($s_forum['icon']);
            }
            ?>

                                                            <tr class="border item">
                                                                <td class="icon lefttd"><a href="viewforum.php?forum=<?php 
            echo $s_forum['id'];
            ?>
"><?php 
require '../structure/user.php';
$database = new database($db_host, $db_name, $db_user, $db_password);
$base = new base($database);
$user = new user($database);
$forum = new forum($database);
$user->updateLastActive();
//make sure the user is logged in and required data is set
if (!ctype_digit($_REQUEST['forum']) || !$user->isLoggedIn()) {
    $base->redirect('index.php');
}
//set some variables that are used a lot throughout the page
$username = $user->getUsername($_COOKIE['user'], 2);
$rank = $user->getRank($username);
$f = $_REQUEST['forum'];
//make sure they are posting in a forum where they have permission
if ($user->checkMute($username) || !$forum->canView($f, $rank) || !$forum->canCreate($f, $rank)) {
    $base->redirect('index.php');
}
//floodlimit time
$flood_limit = $database->processQuery("SELECT `floodlimit` FROM `config` LIMIT 1", array(), true);
//get the user's last post (time)
$last_post = $database->processQuery("SELECT `lastpost` FROM `users` WHERE `username` = ? LIMIT 1", array($username), true);
if (isset($_POST['cancel'])) {
    $base->redirect('viewforum.php?forum=' . $f);
}
if (isset($_POST['message']) && isset($_POST['title'])) {
    $message = nl2br($_POST['message']);
    $title = $_POST['title'];
    //make sure the title and message meet the standards
    if (strlen($message) > 2000 && $rank < 3) {
        $content = '<div class="frame e">Your post can\'t be larger than 2000 characters.</div>';