Contributions by Keith Gable This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. In addition to being restricted by the GNU General Public License, Essence Engine may not be sold, rented, sublicensed, or leased; you are not permitted to generate revenue with the Essence Engine source code. You may, however, use Essence Engine to run a website that generates revenue via other means. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA $Id$ */ // View Topic // Views a topic on the forum. include("mainheader.php"); if ($_GET["topicid"]) { $topicid = mysql_escape_string($_GET["topicid"]); $perpage = 20; // TODO: Make configurable if ($_GET["page"]) $pagenum = mysql_escape_string($_GET["page"]); else $pagenum = 1; $result = mysql_query("SELECT * FROM forum_posts WHERE post_id='$topicid'", $db); if ($topic = mysql_fetch_array($result)) $accessok = checkprivs($topic,$userinfo,"view"); if ($accessok) { $pagetitle = "Topic: " . $topic["post_head"]; $postok = checkprivs($topic,$userinfo,"post"); $forumresult = mysql_query("SELECT * FROM forum_forums WHERE forum_id=" . $topic["forum_id"], $db); $forum = mysql_fetch_array($forumresult); } else { sysmsg("You do not have permission to view that topic."); sendlocation("forums.php?forumid=" . $topic["forum_id"]); } } else sendlocation("forums.php"); include("themeheader.php"); echo '

You are here: Forums /'; echo ' ' . safetext($forum["forum_name"]) . " /"; echo ' ' . safetext($topic["post_head"]) . ""; echo "

\n"; if ($postok) echo "
Post a new reply
\n"; if ($userinfo["usertype"] >= 3) { echo '
Thread Options: '; if ($topic["opt_lock"]) echo "Unlock"; else echo "Lock"; if ($topic["opt_sticky"]) echo " - Unsticky"; else echo " - Sticky"; if ($topic["opt_hide"]) echo " - Unhide"; else echo " - Hide"; echo "
\n"; } if (!$userinfo["showhidden"]) $hide = "and opt_hide=0"; $result = mysql_query("SELECT * FROM forum_posts WHERE (post_id='$topicid' OR topic_id='$topicid') $hide ORDER BY post_time ASC LIMIT " . $perpage . " OFFSET " . (($pagenum - 1) * $perpage), $db); if (mysql_affected_rows() > 0) { while ($postdata = mysql_fetch_array($result)) { if (!isset($users[$postdata["post_username"]])) { $userquery = mysql_query("SELECT * FROM users WHERE username='" . $postdata["post_username"] . "'", $db); $userquery = mysql_fetch_array($userquery); $users[$postdata["post_username"]] = $userquery; } $postuser = $users[$postdata["post_username"]]; if ($postuser["dispname"]) echo "
\n
\n
\n \n"; else echo "
\n
\n
\n
" . $postdata["post_username"] . "
\n"; if ($postuser["tagline"]) echo '
' . safetext($postuser["tagline"]) . "
\n"; elseif (!$postuser["tagline"] && !$postuser["dispname"]) echo "
A deleted user
\n"; $postcount = mysql_query("SELECT count(*) FROM forum_posts WHERE post_username='" . $postdata["post_username"] . "'", $db); $postcount = mysql_fetch_array($postcount); echo "
Posts: " . $postcount["count(*)"] . "
\n"; echo "
\n
\n"; echo '
'; if ($postdata["opt_hide"]) echo '*HIDDEN* '; echo 'Posted: ' . safetext(date("F j, Y \@ g:i A",$postdata["post_time"])); // TODO: Update to use checkprivs() if (checkprivs($postdata,$userinfo,"edit")) echo ' - Edit - Delete'; echo "
\n

"; echo process_post($postdata,$postuser["dispname"]); echo "

\n
\n
\n"; } } else { sysmsg("There are no posts for id $topicid."); sendlocation("forums.php"); } $totalposts = mysql_fetch_array(mysql_query("SELECT count(*) FROM forum_posts WHERE post_id='$topicid' OR topic_id='$topicid'", $db)); $totalposts = $totalposts["count(*)"]; $totalpages = ceil($totalposts / $perpage); if ($totalpages > 1) { echo "
\n
Go to page: \n"; for ($curpage = 1; $curpage <= $totalpages; ++$curpage) { if ($curpage == $pagenum) echo $curpage . "\n"; else echo '' . $curpage . "\n"; if ($curpage != $totalpages) echo " - "; } echo "
\n"; } if ($postok) { if (($userinfo["usertype"] >= 2) && ((!$news["commlock"]) || ($userinfo["usertype"] >= 3))) { echo '
\n
\n"; if ($_POST) $postinfo = $_POST; if ($userinfo["usertype"] >= 5) echo ' ' . "\n" . '
\n"; if ($topicid == 0) echo ' ' . "\n" . '
\n"; ?>
/>
/>
= 3) { echo '
\n"; echo '
\n"; echo '
\n"; /* TODO: Commented pending removal echo '
\n"; echo '
\n"; */ } ?>