* * * * This script displays the contents for the 'View Threads' page. Don't * * forget the 12 space indent for all content pages. * * * * Last modified : September 13th, 2002 (JJS) * \******************************************************************************/ /* Redirect if this file is called directly */ $file_name = "view_forums.php"; /* Get the negative length of $file_name */ $file_name_length = -(strlen($file_name)); /* Check if the values match, if so, redirect */ if (substr($_SERVER['SCRIPT_NAME'], $file_name_length) == $file_name) header("Location: ../index.php"); /* Pull the forum id list from the database */ $SQL = "SELECT forum_id FROM " . TABLE_PREFIX . "forums;"; $results = ExeSQL($SQL); /* Grab the data and load it into an array */ while ($row = mysql_fetch_array($results)) $forum_list[] = $row["forum_id"]; /* If the forum doesn't exist, then halt */ if (!in_array($forum_id, $forum_list)) { /* Tell the user what's up */ echo "
Malformed request detected!

\n"; require ("./content/view_forums.php"); return; } /* Start the table */ echo " \n" . " \n"; /* Pull the forum name from the database */ $SQL = "SELECT * FROM " . TABLE_PREFIX . "forums WHERE forum_id='$forum_id';"; $results = ExeSQL($SQL); /* Grab the data and display it */ while ($row = mysql_fetch_array($results)) echo " \n"; /* Count the number of threads for the named forum */ $SQL = "SELECT COUNT(*) AS any_threads FROM " . TABLE_PREFIX . "threads WHERE forum_id='$forum_id';"; $results = ExeSQL($SQL); /* Grab the data, and load it in a variable */ while ($row = mysql_fetch_array($results)) $any_threads = $row["any_threads"]; /* If there are threads then display them */ if ($any_threads != 0) { /* Display the Post new thread link */ echo " \n" . " \n" . "
" . BOARD_NAME . " > " . $row["forum_name"]."Post New Thread
\n" . "
\n"; /* Build the HTML table (column headings) */ echo " \n" . " \n" . " \n" . " \n" . " \n" . " \n" . " \n"; /* Pull each thread title and date/time in a nice format in time order */ $SQL = "SELECT *, DATE_FORMAT(thread_time, '%W, %M %e, %Y %r') AS nice_time, DATE_FORMAT(thread_time, '%Y-%m-%d') AS post_date FROM " . TABLE_PREFIX . "threads WHERE forum_id='$forum_id' ORDER BY thread_time DESC;"; $results = ExeSQL($SQL); /* Grab the data, and display it in the table */ while ($row = mysql_fetch_array($results)) { /* Get the current date */ $current_date = strftime ("%Y-%m-%d", time()); /* Grab the Thread ID and the User ID */ $thread_id = $row["thread_id"]; $user_id = $row["user_id"]; /* Pull the total number of replies for each thread */ $SQL = "SELECT COUNT(*) AS total_items FROM " . TABLE_PREFIX . "replies WHERE thread_id='$thread_id';"; $results2 = ExeSQL($SQL); /* Grab the data, and load it in an array */ while ($row2 = mysql_fetch_array($results2)) $total_items = $row2["total_items"]; /* Grab the total number of threads */ if ($total_items == "") $total_replies = "--"; else $total_replies = $total_items; /* Pull each user name from the database */ $SQL = "SELECT * FROM " . TABLE_PREFIX . "users WHERE user_id='$user_id';"; $results2 = ExeSQL($SQL); /* Grab the data and load it into an array */ while ($row2 = mysql_fetch_array($results2)) $the_user = $row2["user_name"]; /* Set which image to show for the thread */ if ( $row["post_date"] == $current_date && $total_replies >= 25 ) $which_image = "folder-blue-fire"; else if ( $row["post_date"] == $current_date ) $which_image = "folder-blue"; else if ( $total_replies >= 25 ) $which_image = "folder-yellow-fire"; else $which_image = "folder-yellow"; /* Spit out the rest of the HTML */ echo " \n" . " \n" . " \n" . " \n" . " \n" . " \n"; } /* Close off the table, and display the key */ echo "
ThreadAuthorRepliesPosted on
\n" . " " . $row["thread_title"] . "\n" . " \n" . " " . $the_user . "\n" . " \n" . " " . $total_replies . "\n" . " \n" . " " . $row["nice_time"] . "\n" . "
\n" . "
\n" . " \n" . " = Older threads
\n" . " = Today's threads
\n" . " = Hot thread with 25+ replies
\n" . " = Hot thread from today
\n" . "
\n"; } else { /* If there are no active threads, display this stuff */ echo " \n" . " \n" . "
\n" . "
\n" . " There are no active threads in this forum.
\n" . " Click here if you'd like to post a new thread.\n" . "
\n"; } ?>