Invalid forum id.

'); } $row = mysql_fetch_array($result); echo '

' . htmlspecialchars($row['FORUM_NAME']) . '

'; if ($msg_id) { // link back to thread view echo '

Back to forum ' . 'threads.

'; } else { // link back to forum list echo '

Back to forum list.

'; // display option to add new post if user is logged in if (isset($_SESSION['access'])) { echo '

Post new ' . 'message.

'; } } mysql_free_result($result); } else { echo '

Forums

'; if (isset($_SESSION['userId'])) { // display link to create new forum if user has permissions to do so $user = User::getById($_SESSION['userId']); if ($user->permission & User::CREATE_FORUM) { echo '

Create new forum.

'; } } } // generate message view if ($forum_id && $msg_id) { $query = <<'; while ($row = mysql_fetch_array($result)) { echo ''; echo ''; if (file_exists('avatars/' . $row['USERNAME'] . '.jpg')) { echo ''; } else { echo ''; } echo '
' . $row['USERNAME'] . '
'; echo date('m/d/Y<\b\r/>H:i:s', $row['MESSAGE_DATE']) . ''; echo ''; echo '
' . htmlspecialchars($row['SUBJECT']) . '
'; echo '
' . htmlspecialchars($row['MESSAGE_TEXT']) . '
'; echo '
'; echo 'Reply
'; echo ''; } echo ''; mysql_free_result($result); } // generate thread view else if ($forum_id) { $query = sprintf('SELECT MESSAGE_ID, SUBJECT, ' . 'UNIX_TIMESTAMP(MESSAGE_DATE) AS MESSAGE_DATE FROM %sFORUM_MESSAGE ' . 'WHERE PARENT_MESSAGE_ID = 0 AND FORUM_ID = %d ORDER BY ' . 'MESSAGE_DATE DESC', DB_TBL_PREFIX, $forum_id); $result = mysql_query($query, $GLOBALS['DB']); if ($total = mysql_num_rows($result)) { // accept the display offset $start = (isset($_GET['start']) && ctype_digit($_GET['start']) && $_GET['start'] <= $total) ? $_GET['start'] : 0; // move the data pointer to the appropriate starting record mysql_data_seek($result, $start); // display 25 entries echo ''; // Generate the paginiation menu. echo '

'; if ($start > 0) { echo '<PREV'; } if ($total > $start + 25) { echo 'NEXT>'; } echo '

'; } else { echo '

This forum contains no messages.

'; } mysql_free_result($result); } // generate forums view else { $query = sprintf('SELECT FORUM_ID, FORUM_NAME, DESCRIPTION FROM %sFORUM ' . 'ORDER BY FORUM_NAME ASC, FORUM_ID ASC', DB_TBL_PREFIX); $result = mysql_query($query, $GLOBALS['DB']); echo ''; mysql_free_result($result); } $GLOBALS['TEMPLATE']['content'] = ob_get_contents(); ob_end_clean(); // display the page include '../templates/template-page.php'; ?>