function std_view() { global $READPOST_EXPIRY, $CURUSER, $forum_pic_url; $forums_res = mysql_query("SELECT * FROM forums ORDER BY sort, name") or sqlerr(__FILE__, __LINE__); stdhead("Forums"); $htmlout = "<h1>Forums</h1>\n"; $htmlout .= "<div style='width:80%'><p align=right><span class='btn'><a href='forums.php?action=search'>Search</a></span> <span class='btn'><a href='forums.php?action=viewunread'>View unread</a></span> <span class='btn'><a href='forums.php?action=catchup'>Catch up</a></span></p></div>"; $htmlout .= "<table border=1 cellspacing=0 cellpadding=5 width='80%'>\n"; $htmlout .= "<tr><td class=colhead align=left>Forum</td><td class=colhead align=right>Topics</td>" . "<td class=colhead align=right>Posts</td>" . "<td class=colhead align=left>Last post</td></tr>\n"; while ($forums_arr = mysql_fetch_assoc($forums_res)) { if (get_user_class() < $forums_arr["minclassread"]) { continue; } $forumid = $forums_arr["id"]; $forumname = htmlspecialchars($forums_arr["name"]); $forumdescription = htmlspecialchars($forums_arr["description"]); $topiccount = number_format($forums_arr["topiccount"]); $postcount = number_format($forums_arr["postcount"]); $lastpostid = get_forum_last_post($forumid); // Get last post info $post_res = mysql_query("SELECT p.added, p.topicid, p.userid, u.username, t.subject\r\n\t\t\t\t\t\t\tFROM posts p\r\n\t\t\t\t\t\t\tLEFT JOIN users u ON p.userid = u.id\r\n\t\t\t\t\t\t\tLEFT JOIN topics t ON p.topicid = t.id\r\n\t\t\t\t\t\t\tWHERE p.id = {$lastpostid}") or sqlerr(__FILE__, __LINE__); if (mysql_num_rows($post_res) == 1) { $post_arr = mysql_fetch_assoc($post_res) or die("Bad forum last_post"); $lastposterid = $post_arr["userid"]; $lastpostdate = get_date($post_arr["added"], ''); $lasttopicid = $post_arr["topicid"]; //$user_res = mysql_query("SELECT username FROM users WHERE id=$lastposterid") or sqlerr(__FILE__, __LINE__); //$user_arr = mysql_fetch_assoc($user_res); $lastposter = htmlspecialchars($post_arr['username']); //$topic_res = mysql_query("SELECT subject FROM topics WHERE id=$lasttopicid") or sqlerr(__FILE__, __LINE__); //$topic_arr = mysql_fetch_assoc($topic_res); $lasttopic = htmlspecialchars($post_arr['subject']); $lastpost = "<nobr>{$lastpostdate}<br>" . "by <a href=userdetails.php?id={$lastposterid}><b>{$lastposter}</b></a><br>" . "in <a href=?action=viewtopic&topicid={$lasttopicid}&page=p{$lastpostid}#{$lastpostid}><b>{$lasttopic}</b></a></nobr>"; $r = mysql_query("SELECT lastpostread FROM readposts WHERE userid={$CURUSER['id']} AND topicid={$lasttopicid}") or sqlerr(__FILE__, __LINE__); $a = mysql_fetch_row($r); //..rp.. $npostcheck = $post_arr['added'] > time() - $READPOST_EXPIRY ? !$a or $lastpostid > $a[0] : 0; /* if ($a && $a[0] >= $lastpostid) $img = "unlocked"; else $img = "unlockednew"; */ if ($npostcheck) { $img = "unlockednew"; } else { $img = "unlocked"; } // ..rp.. } else { $lastpost = "N/A"; $img = "unlocked"; } $htmlout .= "<tr><td align=left><table border=0 cellspacing=0 cellpadding=0><tr><td class=embedded style='padding-right: 5px'>" . "<img src=\"{$forum_pic_url}{$img}.gif\"></td>" . "<td class=embedded><a href=?action=viewforum&forumid={$forumid}><b>{$forumname}</b></a><br>\n" . "{$forumdescription}</td></tr></table></td><td align=right>{$topiccount}</td>" . "</td><td align=right>{$postcount}</td>" . "<td align=left>{$lastpost}</td></tr>\n"; } $htmlout .= "</table>\n<br />\n"; $htmlout .= "<div style='width:80%'><p align=right><span class='btn'><a href='forums.php?action=search'>Search</a></span> <span class='btn'><a href='forums.php?action=viewunread'>View unread</a></span> <span class='btn'><a href='forums.php?action=catchup'>Catch up</a></span></p></div>"; echo $htmlout; stdfoot(); exit; }
while ($forums_arr = mysql_fetch_assoc($forums_res)) { if (get_user_class() < $forums_arr["minclassread"] && $forums_arr["guest_read"] == "no") { continue; } if ($forums_arr['fcid'] != $fcid) { // add forum cat headers print "<tr class='f-cat'><td colspan='5' align='center'>" . htmlspecialchars($forums_arr['fcname']) . "</td></tr>\n"; $fcid = $forums_arr['fcid']; } $forumid = 0 + $forums_arr["id"]; $forumname = htmlspecialchars($forums_arr["name"]); $forumdescription = htmlspecialchars($forums_arr["description"]); $postcount = number_format(get_row_count("forum_posts", "WHERE topicid IN (SELECT id FROM forum_topics WHERE forumid={$forumid})")); $topiccount = number_format(get_row_count("forum_topics", "WHERE forumid = {$forumid}")); // Find last post ID $lastpostid = get_forum_last_post($forumid); // Get last post info $post_res = SQL_Query_exec("SELECT added,topicid,userid FROM forum_posts WHERE id={$lastpostid}"); if (mysql_num_rows($post_res) == 1) { $post_arr = mysql_fetch_assoc($post_res) or showerror(T_("ERROR"), "Bad forum last_post"); $lastposterid = $post_arr["userid"]; $lastpostdate = utc_to_tz($post_arr["added"]); $lasttopicid = $post_arr["topicid"]; $user_res = SQL_Query_exec("SELECT username FROM users WHERE id={$lastposterid}"); $user_arr = mysql_fetch_assoc($user_res); $lastposter = htmlspecialchars($user_arr['username']); $topic_res = SQL_Query_exec("SELECT subject FROM forum_topics WHERE id={$lasttopicid}"); $topic_arr = mysql_fetch_assoc($topic_res); $lasttopic = stripslashes(htmlspecialchars($topic_arr['subject'])); //cut last topic $latestleng = 10;
function std_view() { global $TBDEV, $CURUSER, $lang, $forum_pic_url; //$lang = array_merge( $lang, load_language('forums') ); $forums_res = mysql_query("SELECT * FROM forums ORDER BY sort, name") or sqlerr(__FILE__, __LINE__); $htmlout = "<h1>{$lang['forums_title']}</h1>\n"; $htmlout .= "<div style='width:80%'><p style='text-align:right;'><span class='btn'><a href='forums.php?action=search'>{$lang['forums_search']}</a></span> <span class='btn'><a href='forums.php?action=viewunread'>{$lang['forums_view_unread']}</a></span> <span class='btn'><a href='forums.php?action=catchup'>{$lang['forums_catchup']}</a></span></p></div>"; $htmlout .= "<table border='1' cellspacing='0' cellpadding='5' width='80%'>\n"; $htmlout .= "<tr><td class='colhead' style='text-align:left;'>{$lang['forums_forum_heading']}</td><td class='colhead' style='text-align:right;'>{$lang['forums_topic_heading']}</td>" . "<td class='colhead' style='text-align:right;'>{$lang['forums_posts_heading']}</td>" . "<td class='colhead' style='text-align:left;'>{$lang['forums_lastpost_heading']}</td></tr>\n"; while ($forums_arr = mysql_fetch_assoc($forums_res)) { if (get_user_class() < $forums_arr["minclassread"]) { continue; } $forumid = $forums_arr["id"]; $forumname = htmlspecialchars($forums_arr["name"]); $forumdescription = htmlspecialchars($forums_arr["description"]); $topiccount = number_format($forums_arr["topiccount"]); $postcount = number_format($forums_arr["postcount"]); $lastpostid = get_forum_last_post($forumid); // Get last post info $post_res = mysql_query("SELECT p.added, p.topicid, p.userid, u.username, t.subject\r\n\t\t\t\t\t\t\tFROM posts p\r\n\t\t\t\t\t\t\tLEFT JOIN users u ON p.userid = u.id\r\n\t\t\t\t\t\t\tLEFT JOIN topics t ON p.topicid = t.id\r\n\t\t\t\t\t\t\tWHERE p.id = {$lastpostid}") or sqlerr(__FILE__, __LINE__); if (mysql_num_rows($post_res) == 1) { $post_arr = mysql_fetch_assoc($post_res) or die("{$lang['forums_bad_post']}"); $lastposterid = $post_arr["userid"]; $lastpostdate = get_date($post_arr["added"], ''); $lasttopicid = $post_arr["topicid"]; //$user_res = mysql_query("SELECT username FROM users WHERE id=$lastposterid") or sqlerr(__FILE__, __LINE__); //$user_arr = mysql_fetch_assoc($user_res); $lastposter = htmlspecialchars($post_arr['username']); //$topic_res = mysql_query("SELECT subject FROM topics WHERE id=$lasttopicid") or sqlerr(__FILE__, __LINE__); //$topic_arr = mysql_fetch_assoc($topic_res); $lasttopic = htmlspecialchars($post_arr['subject']); $lastpost = "<span style='white-space: nowrap;'>{$lastpostdate}</span><br />" . "by <a href='userdetails.php?id={$lastposterid}'><b>{$lastposter}</b></a><br />" . "in <a href='forums.php?action=viewtopic&topicid={$lasttopicid}&page=p{$lastpostid}#{$lastpostid}'><b>{$lasttopic}</b></a>"; $r = mysql_query("SELECT lastpostread FROM readposts WHERE userid={$CURUSER['id']} AND topicid={$lasttopicid}") or sqlerr(__FILE__, __LINE__); $a = mysql_fetch_row($r); //..rp.. $npostcheck = $post_arr['added'] > time() - $TBDEV['readpost_expiry'] ? !$a or $lastpostid > $a[0] : 0; /* if ($a && $a[0] >= $lastpostid) $img = "unlocked"; else $img = "unlockednew"; */ if ($npostcheck) { $img = "unlockednew"; } else { $img = "unlocked"; } // ..rp.. } else { $lastpost = "N/A"; $img = "unlocked"; } $htmlout .= "<tr><td style='text-align:left;'>" . "<img src=\"{$forum_pic_url}{$img}.gif\" alt='' title='' />" . "<a href='forums.php?action=viewforum&forumid={$forumid}'><b>{$forumname}</b></a><br />\n" . "{$forumdescription}</td>" . "<td style='text-align:right;'>{$topiccount}</td>" . "<td style='text-align:right;'>{$postcount}</td>" . "<td style='text-align:left;'>{$lastpost}</td></tr>\n"; } $htmlout .= "</table>\n<br />\n"; $htmlout .= "<div style='width:80%'><p style='text-align:right;'><span class='btn'><a href='forums.php?action=search'>{$lang['forums_search']}</a></span> <span class='btn'><a href='forums.php?action=viewunread'>{$lang['forums_view_unread']}</a></span> <span class='btn'><a href='forums.php?action=catchup'>{$lang['forums_catchup']}</a></span></p></div>"; print stdhead("{$lang['forums_title']}") . $htmlout . stdfoot(); exit; }