".$row1['name']."

Topic
By
Last Active Thread
"; // fetch_array all info while(($row = mysql_fetch_array($retQuery))) { // $query2 = "SELECT `name` FROM `threads` WHERE `thread_id`='".$row['last_active_thread_id']."'"; // retQuery2 = querySelect($query2); // output all info in respectable manner echo "
".$row['name']."
" .$row['desc']."
".$row['by']."
" .""."
      "; } echo ""; if(isset($_SESSION['alive'])) { if($_SESSION['rank'] <= 2) outputCreateTopicBox(); } } } function outputThreadsByTopicID($id) { // Grab the topic ID and name $query = "SELECT `id`,`name` FROM `topics` WHERE `id`='$id'"; $retQuery = querySelect($query); if(mysql_num_rows($retQuery) == 0) { echo "No Topics To Display"; exit(); } else { $row1 = mysql_fetch_row($retQuery); // Begin table and output topic id,name echo " "; // Grab all thread info where topic_group_id=$id $query2 = "SELECT * FROM `threads` WHERE `topic_group_id`='$id'"; $retQuery2 = querySelect($query2); if(mysql_num_rows($retQuery2) == 0) { echo "

".$row1[1]."


Threads
By
Last Active User
"; echo "No Threads For Current Topic ID"; exit(); } else { // fetch_array all thread info while(($row = mysql_fetch_array($retQuery2))) { echo "
".$row['name']."
".$row['desc']."
".$row['by']."
" .grabUserFromID($row['last_active_user_id'])."

"; } // End Table echo ""; if(isset($_SESSION['alive'])) { if($_SESSION['rank'] >= 2) { echo "

"; outputCreateThreadBox($id); } } } } } // End of Function function outputPostsByThreadID($id) { // Grab the Thread ID and name. $query = "SELECT `thread_id`,`name` FROM `threads` WHERE `thread_id`='$id'"; $retQuery = querySelect($query); if(mysql_num_rows($retQuery) == 0) { echo "No Threads To To Display"; exit(); } else { $row1 = mysql_fetch_row($retQuery); // Begin table and output thread id, name echo " "; // Grab all post info where thread_id=$'id' $query2 = "SELECT * FROM `posts` WHERE `thread_group_id`='$id'"; $retQuery2 = querySelect($query2); if($retQuery2 == 0) { echo "

".$row1[1]."


"; echo "No Threads For Current Topic ID"; exit(); } else { // fetch_array all posts info while(($row = mysql_fetch_array($retQuery2))) { echo "
By: ".grabUserFromID($row['by'])."
On: ".$row['post_time']."
".nl2br($row['content'])." "; } echo ""; if(isset($_SESSION['alive'])) { echo "
"; outputReplyBox($id); } } } } // End of Function function outputReplyBox($thread_id) { echo "
 
"; } function replyToPost($id) { if(isset($_POST['postReplyBox'])) { if(isset($_POST['postReplyBoxContent'])) { if(empty($_POST['postReplyBoxContent'])) { echo "Error: No Content For Reply
"; exit; }else { $content = $_POST['postReplyBoxContent']; $content = strip_tags($content); $content = escape($content); $by = grabIDFromUser($_SESSION['name']); $post_time = date("j F y, g:i a"); $thread_group_id = $id; $query = "SELECT `thread_id` FROM `threads` WHERE `thread_id`='$thread_group_id'"; $ret = queryCheckIfExists($query); if($ret==0) { echo "Hacking Attempt Detected; Thread ID for this specific post, doesnt exist."; exit(); } $query = "INSERT INTO `posts` (`thread_group_id`,`by`,`post_time`,`content`) VALUES ('$thread_group_id','$by','$post_time','$content')"; $retInsert = queryInsert($query); if($retInsert==0) { echo "Error Adding Post To Database !"; exit; } updateLastActivePostUser($id); } } } } function updateLastActivePostUser($thread_id) { $user_id = grabIDFromUser($_SESSION['name']); $query = "SELECT `last_active_user_id` FROM `threads` WHERE `last_active_user_id`='$user_id'"; $ret = queryCheckIfExists($query); if($ret==0) { $query2 = "UPDATE `threads` SET `last_active_user_id`='$user_id' WHERE `thread_id`='$thread_id'"; queryUpdate($query2); } } function outputCreateThreadBox($topic_id) { echo "

Create New Thread

Description
Thread Name
"; } function createNewThread($topic_id) { if(isset($_POST['createNewThread'])) { if(isset($_SESSION['rank'])) { if(!isset($_POST['threadName'])) { echo "Thread Name Not Entered"; exit(); } if(!isset($_POST['threadDesc'])) { echo "Thread Desc Not Entered"; exit(); } $name = $_POST['threadName']; $name = strip_tags($name); $name = escape($name); $by = $_SESSION['name']; $desc = $_POST['threadDesc']; $desc = strip_tags($desc); $desc = escape($desc); $last_active_date = date("j F y, g:i a"); $query = "SELECT `id` FROM `topics` WHERE `id`='$topic_id'"; $ret = queryCheckIfExists($query); if($ret==0) { echo "Hacking Attempt Detected; Topic ID for this specific thread, doesnt exist."; exit(); } $query2 = "INSERT INTO `threads` (`topic_group_id`,`name`,`by`,`desc`,`last_active_date`) VALUES ('$topic_id','$name','$by','$desc','$last_active_date')"; $ret2 = queryInsert($query2); if($ret2==0) echo "Thread Not Created!"; elseif($ret2==1) echo "Thread Successfully Created"; } } } function createNewTopic() { if(isset($_POST['createNewTopic'])) { if($_SESSION['rank'] < 3) { if(!isset($_POST['topicName'])) { echo "Thread Name Not Entered"; exit(); } if(!isset($_POST['topicDesc'])) { echo "Thread Desc Not Entered"; exit(); } $name = $_POST['topicName']; $name = strip_tags($name); $name = escape($name); $by = $_SESSION['name']; $desc = $_POST['topicDesc']; $desc = strip_tags($desc); $desc = escape($desc); $last_active_date = date("j F y, g:i a"); $query = "INSERT INTO `threads` (`name`,`by`,`desc`,`last_active_date`) VALUES ('$name','$by','$desc',`$last_active_date`)"; $ret = queryInsert($query); if($ret==0) echo "Topic Not Created!"; elseif($ret==1) echo "Topic Successfully Created"; } } } function outputCreateTopicBox() { echo "

Create New Topic

Description
Topic Name
"; } ?>