Пример #1
0
function showTopic($topicid, $showfull = TRUE)
{
    global $conn;
    global $userid;
    global $limit;
    echo breadcrumb($topicid, "P");
    if (isset($_GET['page'])) {
        $page = $_GET['page'];
    } else {
        $page = 1;
    }
    if ($limit == "") {
        $limit = 25;
    }
    $start = ($page - 1) * $limit;
    if (isset($_SESSION['user_id'])) {
        echo topicReplyBar($topicid, getForumID($topicid), "right");
    }
    $sql = "SELECT SQL_CALC_FOUND_ROWS " . "p.id, p.subject, p.body, p.date_posted, " . "p.date_updated, u.username as author, u.id as author_id, " . "c.post_count as postcount, " . "p.forum_id as forum_id, f.forum_moderator as mod, " . "p.update_id, u2.username as updated_by " . "FROM forum f " . "JOIN posts p " . "ON f.id = p.forum_id " . "JOIN login u " . "ON u.id = p.author_id " . "LEFT JOIN login u2 " . "ON u2.id = p.update_id " . "LEFT JOIN info c " . "ON u.id = c.user_id " . "WHERE (p.topic_id = {$topicid} OR p.id = {$topicid}) " . "ORDER BY p.topic_id, p.date_posted " . "LIMIT {$start}, {$limit}";
    $result = mysql_query($sql, $db) or die(mysql_error() . "<br />" . $sql);
    $pagelinks = paginate($limit);
    if (mysql_num_rows($result) == 0) {
        $msg = "There are currently no posts.Would you like to be the first person to create a thread?";
        $title = "No Posts...";
        $dest = "./frm_compose.php?forumid=" . $forumid;
        $sev = "Info";
        $message = msgBox($msg, $title, $dest, $sev);
        echo $message;
    } else {
        echo "<table class='forumtable' cellspacing='0' ";
        echo "cellpadding='2'><tr>";
        echo "<th class='author'>Author</th>";
        echo "<th class='post'>Post</th>";
        echo "</tr>";
        while ($row = mysql_fetch_array($result)) {
            $lastupdate = "";
            $editlink = "";
            $dellink = "";
            $replylink = "&nbsp;";
            $pcount = "";
            $pdate = "";
            $sig = "";
            if ($showfull) {
                $body = $row['body'];
                if (isset($_SESSION['user_id'])) {
                    $replylink = "<a href='frm_compose.php?forumid=" . $row['forum_id'] . "&topicid={$topicid}&reid=" . $row['id'] . "' class='buttonlink'>REPLY</a>&nbsp;";
                } else {
                    $replylink = "";
                }
                if ($row['update_id'] > 0) {
                    $lastupdate = "<p class='smallNote'>Last updated: " . $row['date_updated'] . " by " . $row['updated_by'] . "</p>";
                }
                if ($userid == $row['author_id'] or $userid == $row['mod'] or $_SESSION['access_lvl'] > 1) {
                    $editlink = "<a href='frm_compose.php?a=edit&post=" . $row['id'] . "' class='buttonlink'>EDIT</a>&nbsp;";
                    $dellink = "<a href='frm_transact_affirm.php?action=deletepost&id=" . $row['id'] . "' class='buttonlink'>DELETE</a>&nbsp;";
                }
                $pcount = "<br /><span class='textsmall'>Posts: " . ($row['postcount'] == "" ? "0" : $row['postcount']) . "</span>";
                $pdate = $row['date_posted'];
                $sig = ($row['sig'] != "" ? "<p class='sig'>" . nl2br($row['sig']) : "") . "</p>";
            } else {
                $body = trimBody($body);
            }
            $rowclass = $rowclass == "row1" ? "row2" : "row1";
            echo "<tr class='{$rowclass}'>";
            echo "<td class='author'>" . $row['author'];
            echo $pcount;
            echo "</td><td class='post'><p>";
            if (isset($_SESSION['user_id']) and $_SESSION['last_login'] < $row['date_posted']) {
                echo NEWPOST . " ";
            }
            if (isset($_GET['page'])) {
                $pagelink = "&page=" . $_GET['page'];
            }
            echo "<a name='post" . $row['id'] . "' href='frm_view_topic.php?t=" . $topicid . $pagelink . "#post" . $row['id'] . "'>" . POSTLINK . "</a>";
            if (isset($row['subject'])) {
                echo " <strong>" . $row['subject'] . "</strong>";
            }
            echo "</p><p>" . nl2br(htmlspecialchars($body)) . "</p>";
            echo $sig;
            echo $lastupdate;
            echo "</td></tr>";
            echo "<tr class='{$rowclass}'><td class='authorfooter'>";
            echo $pdate . "</td><td class='threadfooter'>";
            echo $replylink;
            echo $editlink;
            echo $dellink;
            echo "</td></tr>\n";
        }
        echo "</table>";
        echo $pagelinks;
        echo "<p>" . NEWPOST . " = New Post&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
        echo POSTLINK . " = Post link (use to bookmark)</p>";
    }
}
Пример #2
0
$sql = "UNLOCK TABLES";
mysql_query($sql) or die(mysql_error() . "<br />" . $sql);
// die('stop');
$sql = "SELECT SQL_CALC_FOUND_ROWS " . "t.id as topic_id, t.subject as t_subject, " . "u.name as t_author, count(p.id) as numreplies, " . "t.date_posted as t_posted, tmp.postdate as re_posted " . "FROM forum_users u " . "JOIN forum_posts t " . "ON t.author_id = u.id " . "LEFT JOIN tmp " . "ON t.id = tmp.topic_id " . "LEFT JOIN forum_posts p " . "ON p.topic_id = t.id " . "WHERE t.forum_id = {$forumid} " . "AND t.topic_id = 0 " . "GROUP BY t.id " . "ORDER BY re_posted DESC " . "LIMIT {$start}, {$limit}";
$result = mysql_query($sql) or die(mysql_error() . "<br />" . $sql);
$numrows = mysql_num_rows($result);
if ($numrows == 0) {
    $msg = "There are currently no posts.Would you like to be the first person to create a thread?";
    $title = "Welcome to " . $forum['name'];
    $dest = "compose.php?forumid=" . $forumid;
    $sev = "Info";
    $message = msgBox($msg, $title, $dest, $sev);
    echo $message;
} else {
    if (isset($_SESSION['user_id'])) {
        echo topicReplyBar(0, $_GET['f'], "right");
    }
    echo "<table class='forumtable' cellspacing='0' cellpadding='2'><tr>";
    echo "<th class='thread'>Thread</th>";
    echo "<th class='author'>Author</th>";
    echo "<th class='replies'>Replies</th>";
    echo "<th class='lastpost'>Last Post</th>";
    echo "</tr>";
    while ($row = mysql_fetch_array($result)) {
        $rowclass = $rowclass == "row1" ? "row2" : "row1";
        if ($row['re_posted'] == "") {
            $lastpost = $row['t_posted'];
        } else {
            $lastpost = $row['re_posted'];
        }
        if (isset($_SESSION['user_id']) and $_SESSION['last_login'] < $lastpost) {