" ."" ." " ."
".$site_long_name." Forums (Prototype)
\n" ."\n" ."

Welcome to the Forums, where you can take part in public online discussions.

\n"; // if action is not set, show the front page if ($_GET["action"]==""){ $html .= "
\n"; // list the forums themselves $con = db_connect(); $sql = "SELECT f.nSort,f.nForumId,f.cTitle,f.cSummary,f.nPosts,f.nTopics,f.nOwnerId,uo.cUsername AS cOwner,f.nLastPostBy,ul.cUsername AS cLastPoster,f.dLastPost,f.nLastPostId" ." FROM nexus_forums f" ." INNER JOIN nexus_users uo ON f.nOwnerId=uo.nUserId" ." LEFT OUTER JOIN nexus_users ul ON f.nLastPostBy=ul.nUserId" ." ORDER BY nSort DESC,cTitle"; // start the common border $html .= "\n" ."\n" ."\n" ."
Forum List
\n"; $result = mysql_query($sql,$con); if ($result!=false){ if (mysql_num_rows($result)>0){ $html .= "\n"; while ($row =@ mysql_fetch_array($result)){ $html .= "\n"; } $html .= "
\n" ."\n" ."\n" ."
".$row["nTopics"]." topics, ".$row["nPosts"]." posts, last post by ".stripslashes($row["cLastPoster"])." on ".$row["dLastPost"]." »
\n" ."
".stripslashes($row["cSummary"])."
\n" ."
Click here to visit the forum.
\n" ."
\n"; } else { // no forums to list } } else { $html .= "
problem with SQL [".$sql."]
\n"; } // finish the common border $html .= "
\n"; $html .= "
\n"; } // if action is 'view_forum' show the topics in a forum if ($_GET["action"]=="view_forum"){ $con = db_connect(); // get the user membertype if ($_SESSION["nexus_userid"]!=""){ $sql = "SELECT cType FROM nexus_forummembers WHERE nUserId=".$_SESSION["nexus_userid"]." AND nForumId=".$_GET["forumid"]; $result = mysql_query($sql,$con); if ($result!=false){ if (mysql_num_rows($result)>0){ $row = mysql_fetch_array($result); $member_type = $row["cType"]; } else { // no records $member_type=""; } } else { // problem with SQL $html .= "
Problem with SQL [".$sql."]
\n"; } } // start putting the page together $html .= "\n" ."\n" ."\n" ."
Forum Description
\n"; // show the forum name $sql = "SELECT f.nForumId,f.cType,f.cStatus,f.cTitle,f.cSummary,f.nPosts,f.nTopics,f.nOwnerId,uo.cUsername AS cOwner,f.nLastPostBy,ul.cUsername AS cLastPoster,f.dLastPost,f.nLastPostId" ." FROM nexus_forums f" ." INNER JOIN nexus_users uo ON f.nOwnerId=uo.nUserId" ." LEFT OUTER JOIN nexus_users ul ON f.nLastPostBy=ul.nUserId" ." WHERE nForumId=".$_GET["forumid"]; $result = mysql_query($sql,$con); if ($result!=false){ if (mysql_num_rows($result)>0){ $row = mysql_fetch_array($result); switch($member_type){ case "owner": $html_newtopic = ""; break; case "moderator": $html_newtopic = ""; break; case "member": $html_newtopic = ""; break; case "pending": $html_newtopic = "
You Cannot Post
Your membership of this forum is pending approval of its owner.
"; break; case "banned": $html_newtopic = "
You Cannot Post
You have been banned from posting to this forum.
"; break; default: switch($row["cType"]){ case "open": // user is joined immediately on join request $html_newtopic = "
Join
This is an open forum
just click 'Join' to join.
"; break; case "managed": // user is added as pending on join request $html_newtopic = "
Join
This is a managed forum
click 'Join' to request membership.
"; break; } break; } // figure out if the forum is open or not if ($row["cStatus"]=="live"){ $html .= "
"; $html .= "
".stripslashes($row["cTitle"])." Forum
\n" ."\n" ."
 
\n" ."
".$row["nTopics"]." topics, ".$row["nPosts"]." posts, last post by ".stripslashes($row["cLastPoster"])." on ".$row["dLastPost"]." »
\n" ."
 
\n" ."
".stripslashes($row["cSummary"])."
\n"; $html .= "
"; if ($_SESSION["nexus_userid"]!=""){ $html .= $html_newtopic; } else { $html .= "
Login Required
You need to login before you can post to the forums.
\n"; } $html .= "
\n"; } if ($row["cStatus"]=="pending"){ $html .= "
".stripslashes($row["cTitle"])." Forum
\n" ."
This forum has been requested for creation, but has not been enabled yet. Please contact the administrator if you have any questions, or would just like to lean on him a bit :)
\n"; } if ($row["cStatus"]=="closed"){ $html .= "
".stripslashes($row["cTitle"])." Forum
\n" ."
This forum has been closed. Please contact the administrator if you have any questions.
\n"; } } else { // no forums to list } } else { $html .= "
problem with SQL [".$sql."]
\n"; } $html .= "
\n"; if ($row["cStatus"]=="live"){ // get the posts $sql = "SELECT t.nTopicId,t.cTitle AS cTopicTitle,t.nForumId,f.cTitle AS cForumTitle,t.nFirstPostId,t.nLastPostId,uf.cUsername AS cFirstPostBy,ul.cUsername AS cLastPostBy,t.nFirstPostBy,t.nLastPostBy,t.dFirstPost,t.dLastPost,t.nPosts,t.nViews" ." FROM nexus_topics t" ." INNER JOIN nexus_forums f ON t.nForumId=f.nForumId" ." INNER JOIN nexus_users uf ON t.nFirstPostBy=uf.nUserId" ." INNER JOIN nexus_users ul ON t.nLastPostBy=ul.nUserId" ." WHERE t.nForumId=".$_GET["forumid"] ." ORDER BY t.dLastPost DESC;"; $result = mysql_query($sql,$con); if ($result!=false){ $html .= "" ."" ."" ."" ."" ."" ."" ."" ."" ."\n"; if (mysql_num_rows($result)>0){ while ($row =@ mysql_fetch_array($result)){ $html .= "" ."\n" ."\n" ."\n" ."\n" ."\n" ."\n" ."\n"; } } else { $html .= "\n"; } $html .= "
Topics
 Topic TitleViewsPostsFirst PostLast Post
 ".$row["cTopicTitle"]."".$row["nViews"]."".$row["nPosts"]."".stripslashes($row["cFirstPostBy"])."
".$row["dFirstPost"]." »
".stripslashes($row["cLastPostBy"])."
".$row["dLastPost"]." »
No Topics in this forum yet.
".$html_newtopic."
\n"; } else { // no forum to show $html .= "

Problem with the SQL [".$sql."]

\n"; } } else { // forum is not live $html .= "
The forum contents cannot be shown while it's status is not 'live'.
"; } $html .= "
\n"; } // if action is 'view_topic' show a single topic in a forum if ($_GET["action"]=="view_topic"){ $con = db_connect(); // see if we were given a postid (i.e. we will need to find out the topic from it $postid = $_GET["postid"]; if($postid!=""){ $sql = "SELECT nTopicId FROM nexus_posts WHERE nPostId=".$postid; $result = mysql_query($sql,$con); if ($result!=false) { if (mysql_num_rows($result)>0){ $row = mysql_fetch_array($result); $topicid = $row["nTopicId"]; } else { // no such post } } else { // problem with SQL } } else { $topicid = $_GET["topicid"]; } // update the view stats for the topic $sql = "UPDATE nexus_topics SET nViews=nViews+1 WHERE nTopicId=".$topicid; $result = mysql_query($sql,$con); // get the topic name, forumid and forumtype (use forum type to influence buttons available) $sql = "SELECT t.cTitle,t.nForumId,f.cType AS cForumType" ." FROM nexus_topics t" ." INNER JOIN nexus_forums f ON t.nForumId=f.nForumId" ." WHERE t.nTopicId=".$topicid; $result = mysql_query($sql,$con); if ($result!=false){ if (mysql_num_rows($result)>0){ $row = mysql_fetch_array($result); // store the title of the topic away for use at the top of the thread of messages $forumid = $row["nForumId"]; $topic_title = stripslashes($row["cTitle"]); $forum_type = $row["cForumType"]; // get the user membertype for the forum if ($_SESSION["nexus_userid"]!=""){ $sql = "SELECT cType FROM nexus_forummembers WHERE nUserId=".$_SESSION["nexus_userid"]." AND nForumId=".$row["nForumId"]; $result = mysql_query($sql,$con); if ($result!=false){ if (mysql_num_rows($result)>0){ $row = mysql_fetch_array($result); $member_type = $row["cType"]; } else { // no records $member_type=""; } } else { // problem with SQL } } // now figure out what to show for addtopic and reply links // (make them context sensitive to the type of forum and the membership status of the user) switch($member_type){ case "owner": $html_newtopic = "
Post New Topic
"; $html_reply = "Reply"; break; case "moderator": $html_newtopic = "
Post New Topic
"; $html_reply = "Reply"; break; case "member": $html_newtopic = "
Post New Topic
"; $html_reply = "Reply"; break; case "pending": $html_newtopic = "
You Cannot Post
Your membership of this forum is pending approval of its owner.
"; $html_reply = "Membership Pending - Cannot Reply"; break; case "banned": $html_newtopic = "
You Cannot Post
You have been banned from posting to this forum.
"; $html_reply = "You Cannot Post
You have been banned from posting to this forum.
"; break; case "": switch($forum_type){ case "open": // user is joined immediately on join request $html_newtopic = "
Join
This is an open forum
just click 'Join' to join.
"; $html_reply = "Join to Reply"; break; case "managed": // user is added as pending on join request $html_newtopic = "
Join
This is a managed forum
click 'Join' to request membership.
"; $html_reply = "Managed Forum - Join to Reply"; break; } break; } //$html .= "
NEW [".$html_newtopic."]
\n"; // start putting the page together $html .= "\n" ."\n" ."
Forum Description
\n"; // show the forum name $sql = "SELECT f.nForumId,f.cTitle,f.cSummary,f.nPosts,f.nTopics,f.nOwnerId,uo.cUsername AS cOwner,f.nLastPostBy,ul.cUsername AS cLastPoster,f.dLastPost,f.nLastPostId" ." FROM nexus_forums f" ." INNER JOIN nexus_users uo ON f.nOwnerId=uo.nUserId" ." INNER JOIN nexus_users ul ON f.nLastPostBy=ul.nUserId" ." WHERE nForumId=".$forumid; $result = mysql_query($sql,$con); if ($result!=false){ if (mysql_num_rows($result)>0){ $row = mysql_fetch_array($result); $html .= "
"; $html .= "\n" ."\n" ."
 
\n" ."
".$row["nTopics"]." topics, ".$row["nPosts"]." posts, last post by ".stripslashes($row["cLastPoster"])." on ".$row["dLastPost"]." »
\n" ."
 
\n" ."
".stripslashes($row["cSummary"])."
\n"; $html .= "
"; if ($_SESSION["nexus_userid"]!=""){ $html .= $html_newtopic; } else { $html .= "
Login Required
You need to login before you can post to the forums.
\n"; } $html .= "
\n"; } else { // no forums to list } } else { $html .= "
problem with SQL [".$sql."]
\n"; } $html .= "
\n"; $html .= "
Topic : ".$topic_title."
\n"; // get the posts in the topic $sql = "SELECT p.nPostId,p.nForumId,p.nTopicId,p.nUserId,u.cUsername,p.cTitle,p.cBody,p.dAdded,p.dEdited,u.nPosts,u.cGender,u.cChatYahoo,u.cChatMSN,u.cChatAIM,u.cChatICQ" ." FROM nexus_posts p" ." INNER JOIN nexus_users u ON p.nUserId=u.nUserId" ." WHERE nTopicId=".$topicid." ORDER BY nPostId"; $result = mysql_query($sql,$con); if ($result!=false){ $html .= ""; while ($row =@ mysql_fetch_array($result)){ if ($row["cTitle"]!="") { $title = stripslashes($row["cTitle"]); } else { $title = "... (untitled)"; } $body = stripslashes($row["cBody"]); $username = stripslashes($row["cUsername"]); $userid = stripslashes($row["nUserId"]); $dateadded = stripslashes($row["dEdited"]); $posts = stripslashes($row["nPosts"]); // sort out a thumbnail if (file_exists("pictures/".$row["nUserId"]."t.jpg")){ $picture = "pictures/".$row["nUserId"]."t.jpg"; } else { switch ($row["cGender"]){ case "": $picture = "pictures/no_thumb.jpg"; break; case "m": $picture = "pictures/no_thumb_male.jpg"; break; case "f": $picture = "pictures/no_thumb_female.jpg"; break; } } // prepare the chat icons if ($_SESSION["nexus_userid"]!=""){ if ($row["cChatYahoo"]!="") { $chat_yahoo = ""; } if ($row["cChatMSN"]!="") { $chat_msn = ""; } if ($row["cChatAIM"]!="") { $chat_aim = ""; } if ($row["cChatICQ"]!="") { $chat_icq = ""; } $chat = $chat_yahoo.$chat_msn.$chat_aim.$chat_icq; } else { $chat = "login for more info"; } // prepare the reply html if ($_SESSION["nexus_userid"]!=""){ $html_reply = str_replace("[topicid]",$row["nTopicId"],$html_reply); $html_reply = str_replace("[forumid]",$row["nForumId"],$html_reply); $html_reply = str_replace("[postid]",$row["nPostId"],$html_reply); } else { $html_reply = "Login to Reply"; } $html .= "\n"; } $html .= "
" ."
\n" ."\n" ."" ."\n" ."\n" ."
" ."
\n" ."
\n" ."\n" ."
".$chat."
\n" ."
".$posts." posts
\n" ."
\n" ."
" ."
".prepare($title)."
" ."
".prepare($body)."
" ."
Posted by ".$username." on ".$dateadded.".  ".$html_reply."
\n" ."
\n" ."
\n" ."
\n"; } else { $html .= "

Problem with the SQL [".$sql."]

\n"; } $html .= "
\n"; } else { // no such topic } } else { // problem with SQL } } // if action is 'new_topic' show the entry form if ($_GET["action"]=="new_topic"){ if ($_SESSION["nexus_userid"]!="" && $_SESSION["nexus_enabled"]!=""){ // show the form for a new topic $html .= "
\n" ."\n" ."\n" ."\n" ."\n" ."\n" ."\n" ."
Post New Topic
Title
Body
\n" ."
\n"; } else { $html .= "

Login Required

\n" ."

You are trying to access a section of the site that requires a login. Use the form on the left to login - you will then be taken to the page you were trying to access.

\n" ."

If you get stuck, email ".$admin_email." for assistance.

\n"; } } // if action is 'reply' show the reply form if ($_GET["action"]=="reply"){ if ($_SESSION["nexus_userid"]!="" && $_SESSION["nexus_enabled"]!=""){ $forumid = $_GET["forumid"]; $topicid = $_GET["topicid"]; $postid = $_GET["postid"]; // get data of the message we are replying to $con = db_connect(); $sql = "SELECT p.cTitle,p.cBody,p.dAdded,p.dEdited,u.cUsername,p.nUserId" ." FROM nexus_posts p" ." INNER JOIN nexus_users u ON p.nUserId=u.nUserId" ." WHERE p.nPostId=".$postid; $result = mysql_query($sql,$con); if ($result!=false){ if (mysql_num_rows($result)>0){ $row = mysql_fetch_array($result); // show the message they are replying to $html .= "\n" ."\n" ."\n" ."
Reply to this message by ".stripslashes($row["cUsername"]).", written on ".$row["dAdded"]."
".stripslashes($row["cTitle"])."

".prepare(stripslashes($row["cBody"]))."
\n"; $html .= "
\n"; // prepare a title $title = stripslashes($row["cTitle"]); if ($title==""){ $title = "untitled"; } $title = str_replace("re: ","",$title); $title = "re: ".$title; // show the form for a reply to a topic $html .= "
\n" ."\n" ."\n" ."\n" ."\n" ."\n" ."\n" ."\n" ."\n" ."
Post Reply
Title
Body
\n" ."
\n"; } else { $html .= "
No Post exists with that ID
\n"; } } else { $html .= "

Problem with the SQL [".$sql."]

\n"; } } else { // enabled account required $html .= "

Login Required

\n" ."

You are trying to access a section of the site that requires a login. Use the form on the left to login - you will then be taken to the page you were trying to access.

\n" ."

If you get stuck, email ".$admin_email." for assistance.

\n"; } } $html .= html_page_end(); print $html; ?>