function show_forums($forid, $subforums = false, $sfa = "", $mods_array = "", $show_mods = false) { global $CURUSER, $INSTALLER09, $Multi_forum; $mods_array = forummods(); $htmlout = ''; $forums_res = sql_query("SELECT f.id, f.name, f.description, f.post_count, f.topic_count, f.min_class_read, p.added, p.topic_id, p.anonymous, p.user_id, p.id AS pid, u.id AS uid, u.username, u.class, u.donor, u.enabled, u.warned, u.chatpost, u.leechwarn, u.pirate, u.king, t.topic_name, t.last_post, r.last_post_read " . "FROM forums AS f " . "LEFT JOIN posts AS p ON p.id = (SELECT MAX(last_post) FROM topics WHERE forum_id = f.id) " . "LEFT JOIN users AS u ON u.id = p.user_id " . "LEFT JOIN topics AS t ON t.id = p.topic_id " . "LEFT JOIN read_posts AS r ON r.user_id = " . sqlesc($CURUSER['id']) . " AND r.topic_id = p.topic_id " . "WHERE " . ($subforums == false ? "f.forum_id = " . sqlesc($forid) . " AND f.place =-1 ORDER BY f.forum_id ASC" : "f.place=" . sqlesc($forid) . " ORDER BY f.id ASC") . "") or sqlerr(__FILE__, __LINE__); $htmlout .= begin_f_main_table(); while ($forums_arr = mysqli_fetch_assoc($forums_res)) { if ($CURUSER['class'] < $forums_arr["min_class_read"]) { continue; } $forumid = (int) $forums_arr["id"]; $lastpostid = (int) $forums_arr['last_post']; $user_stuff = $forums_arr; $user_stuff['id'] = (int) $forums_arr['uid']; if ($subforums == false && !empty($sfa[$forumid])) { if ($sfa[$forumid]['last_post']['postid'] > $forums_arr['pid']) { if ($sfa[$forumid]['last_post']["anonymous"] == "yes") { if ($CURUSER['class'] < UC_STAFF && $sfa[$forumid]['last_post']['user_id'] != $CURUSER['id']) { $lastpost1 = "Anonymous<br />"; } else { $lastpost1 = "Anonymous[<a href='{$INSTALLER09['baseurl']}/userdetails.php?id=" . (int) $sfa[$forumid]['last_--post']['userid'] . "'><b>" . htmlsafechars($sfa[$forumid]['last_post']['user']) . "</b></a>]<br />"; } } elseif ($sfa[$forumid]['last_post']["anonymous"] == "no") { $lastpost1 = "<a href='{$INSTALLER09['baseurl']}/userdetails.php?id=" . (int) $sfa[$forumid]['last_post']['userid'] . "'><b>" . htmlsafechars($sfa[$forumid]['last_post']['user']) . "</b></a><br />"; } $lastpost = "" . get_date($sfa[$forumid]['last_post']['added'], 'LONG', 1, 0) . "<br />" . "by {$lastpost1}" . "in <a href='{$INSTALLER09['baseurl']}/forums.php?action=viewtopic&topicid=" . (int) $sfa[$forumid]['last_post']['topic'] . "&page=p" . (int) $sfa[$forumid]['last_post']['post_id'] . "#p" . (int) $sfa[$forumid]['last_post']['post_id'] . "'><b>" . htmlsafechars($sfa[$forumid]['last_post']['tname']) . "</b></a>"; } elseif ($sfa[$forumid]['last_post']['postid'] < $forums_arr['pid']) { if ($forums_arr["anonymous"] == "yes") { if ($CURUSER['class'] < UC_STAFF && $forums_arr["user_id"] != $CURUSER["id"]) { $lastpost2 = "Anonymous<br />"; } else { $lastpost2 = "Anonymous[<a href='{$INSTALLER09['baseurl']}/userdetails.php?id=" . (int) $forums_arr["user_id"] . "'><b>" . format_username($user_stuff, true) . "</b></a>]<br />"; } } elseif ($forums_arr["anonymous"] == "no") { $lastpost2 = "<a href='{$INSTALLER09['baseurl']}/userdetails.php?id=" . (int) $forums_arr["user_id"] . "'><b>" . format_username($user_stuff, true) . "</b></a><br />"; } $lastpost = "" . get_date($forums_arr["added"], 'LONG', 1, 0) . "<br />" . "by {$lastpost2}" . "in <a href='{$INSTALLER09['baseurl']}/forums.php?action=viewtopic&topicid=" . (int) $forums_arr["topic_id"] . "&page=p{$lastpostid}#p{$lastpostid}'><b>" . htmlsafechars($forums_arr['topic_name']) . "</b></a>"; } else { $lastpost = "N/A"; } } else { if (is_valid_id($forums_arr['pid'])) { if ($forums_arr["anonymous"] == "yes") { if ($CURUSER['class'] < UC_STAFF && $forums_arr["user_id"] != $CURUSER["id"]) { $lastpost = "" . get_date($forums_arr["added"], 'LONG', 1, 0) . "<br />" . "by <i>Anonymous</i><br />" . "in <a href='" . $INSTALLER09['baseurl'] . "/forums.php?action=viewtopic&topicid=" . (int) $forums_arr["topic_id"] . "&page=p{$lastpostid}#p{$lastpostid}'><b>" . htmlsafechars($forums_arr['topic_name']) . "</b></a>"; } else { $lastpost = "" . get_date($forums_arr["added"], 'LONG', 1, 0) . "<br />" . "by <i>Anonymous[</i><a href='{$INSTALLER09['baseurl']}/userdetails.php?id=" . (int) $forums_arr["user_id"] . "'><b>" . format_username($user_stuff, true) . "</b></a>]<br />" . "in <a href='{$INSTALLER09['baseurl']}/forums.php??action=viewtopic&topicid=" . (int) $forums_arr["topic_id"] . "&page=p{$lastpostid}#p{$lastpostid}'><b>" . htmlsafechars($forums_arr['topic_name']) . "</b></a>"; } } else { $lastpost = "<span class='smalltext'><a href='{$INSTALLER09['baseurl']}/forums.php?action=viewtopic&topicid=" . (int) $forums_arr["topic_id"] . "&page=p{$lastpostid}#p{$lastpostid}'>" . htmlsafechars($forums_arr['topic_name']) . "</a><br />" . "" . get_date($forums_arr["added"], 'LONG', 1, 0) . "<br />" . "by <a href='{$INSTALLER09['baseurl']}/userdetails.php?id=" . (int) $forums_arr["user_id"] . "'>" . format_username($user_stuff, true) . "</a> "; } } else { $lastpost = "N/A"; } } $image_to_use = $forums_arr['added'] > TIME_NOW - $INSTALLER09['readpost_expiry'] ? (int) $forums_arr['pid'] > $forums_arr['last_post_read'] : 0; if (is_valid_id($forums_arr['pid'])) { $img = $image_to_use ? '<span class="forum_status forum_on ajax_mark_read" title="Forum Contains New Posts" ></span>' : '<span class="forum_status forum_off ajax_mark_read" title="Forum Contains No New Posts" ></span>'; } else { $img = "<span class='forum_status forum_offlock ajax_mark_read' title='Forum Contains No Posts' ></span>"; } if ($subforums == false && !empty($sfa[$forumid])) { list($subposts, $subtopics) = get_count($sfa[$forumid]["count"]); $topics = $forums_arr["topic_count"] + $subtopics; $posts = $forums_arr["post_count"] + $subposts; } else { $topics = (int) $forums_arr["topic_count"]; $posts = (int) $forums_arr["post_count"]; } $htmlout .= "\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td class=row align='center' valign='middle' width='1%'>" . $img . "</td>\n\t\t\t\t\t\t<td class=row valign='middle' width='50%'>\n\t\t\t\t\t\t<strong><a href='{$INSTALLER09['baseurl']}/forums.php?action=viewforum&forumid=" . $forumid . "'><b>" . htmlsafechars($forums_arr["name"]) . "</b></a></strong>\n"; if ($CURUSER['class'] >= UC_ADMINISTRATOR || isMod($forumid, "forum")) { $htmlout .= " <font class='small'><a class='altlink' href='{$INSTALLER09['baseurl']}/forums.php?action=editforum&forumid=" . $forumid . "'><span class='btn btn-default btn-xs'><i class='fa fa-pencil-square-o'></i>\n\t\t Edit</span></a>  <a class='altlink' href='{$INSTALLER09['baseurl']}/forums.php?action=deleteforum&forumid=" . $forumid . "'><span class='btn btn-default btn-xs'><i class='fa fa-eraser'></i>\n\t\t Delete</span></a></font>"; } if (!empty($forums_arr["description"])) { $htmlout .= "<br />" . htmlsafechars($forums_arr["description"]) . ""; } if ($subforums == false && !empty($sfa[$forumid])) { $htmlout .= "<br/>" . subforums($sfa[$forumid]["topics"]); } if ($show_mods == true && isset($mods_array[$forumid])) { $htmlout .= "<br/>" . showMods($mods_array[$forumid]); } $htmlout .= "</td>\n<td class=row valign='top' style='white-space: nowrap' width= '8%'>\n<span class='badge'>" . number_format($posts) . "</span> Posts</br>\n<span class='badge'>" . number_format($topics) . "</span> Topics\n</td>\n\t\t\t<td class=row valign='top' align='right' style='white-space: nowrap'>" . $lastpost . "</td>\n\t\t</tr>\n\t\t"; } $htmlout .= "</table><br />"; $htmlout .= end_f_body_div(); $htmlout .= end_f_main_div(); return $htmlout; }
function show_forums($forid, $subforums = false, $sfa = "", $show_mods = false) { global $CURUSER, $pic_base_url, $READPOST_EXPIRY, $DEFAULTBASEURL, $ss_uri, $forummods; $forums_res = sql_query("SELECT f.id, f.name, f.description, f.postcount, f.topiccount, f.minclassread, p.added, p.topicid, p.userid, p.id AS pid, u.username, t.subject, t.lastpost, r.lastpostread " . "FROM forums AS f " . "LEFT JOIN posts AS p ON p.id = (SELECT MAX(lastpost) FROM topics WHERE forumid = f.id) " . "LEFT JOIN users AS u ON u.id = p.userid " . "LEFT JOIN topics AS t ON t.id = p.topicid " . "LEFT JOIN readposts AS r ON r.userid = " . sqlesc($CURUSER['id']) . " AND r.topicid = p.topicid " . "WHERE " . ($subforums == false ? "f.forid = {$forid} AND f.place =-1 ORDER BY f.forid ASC" : "f.place={$forid} ORDER BY f.id ASC") . "") or sqlerr(__FILE__, __LINE__); while ($forums_arr = mysql_fetch_assoc($forums_res)) { if ($CURUSER['class'] < $forums_arr["minclassread"]) { continue; } $forumid = (int) $forums_arr["id"]; $lastpostid = (int) $forums_arr['lastpost']; if ($subforums == false && !empty($sfa[$forumid])) { if ($sfa[$forumid]['lastpost']['postid'] > $forums_arr['pid']) { $lastpost = "" . $sfa[$forumid]['lastpost']['added'] . "<br />" . "by <a href='{$DEFAULTBASEURL}/userdetails.php?id=" . (int) $sfa[$forumid]['lastpost']['userid'] . "'><b>" . safeChar($sfa[$forumid]['lastpost']['user']) . "</b></a><br />" . "in <a href='" . $_SERVER['PHP_SELF'] . "?action=viewtopic&topicid=" . (int) $sfa[$forumid]['lastpost']['topic'] . "&page=p" . $sfa[$forumid]['lastpost']['postid'] . "#p" . $sfa[$forumid]['lastpost']['postid'] . "'><b>" . safeChar($sfa[$forumid]['lastpost']['tname']) . "</b></a>"; } elseif ($sfa[$forumid]['lastpost']['postid'] < $forums_arr['pid']) { $lastpost = "" . $forums_arr["added"] . "<br />" . "by <a href='{$DEFAULTBASEURL}/userdetails.php?id=" . (int) $forums_arr["userid"] . "'><b>" . safeChar($forums_arr['username']) . "</b></a><br />" . "in <a href='" . $_SERVER['PHP_SELF'] . "?action=viewtopic&topicid=" . (int) $forums_arr["topicid"] . "&page=p{$lastpostid}#p{$lastpostid}'><b>" . safeChar($forums_arr['subject']) . "</b></a>"; } else { $lastpost = "N/A"; } } else { if (is_valid_id($forums_arr['pid'])) { $lastpost = "" . $forums_arr["added"] . "<br />" . "by <a href='{$DEFAULTBASEURL}/userdetails.php?id=" . (int) $forums_arr["userid"] . "'><b>" . safeChar($forums_arr['username']) . "</b></a><br />" . "in <a href='" . $_SERVER['PHP_SELF'] . "?action=viewtopic&topicid=" . (int) $forums_arr["topicid"] . "&page=p{$lastpostid}#p{$lastpostid}'><b>" . safeChar($forums_arr['subject']) . "</b></a>"; } else { $lastpost = "N/A"; } } if (is_valid_id($forums_arr['pid'])) { $img = 'unlocked' . ($forums_arr['added'] > get_date_time(gmtime() - $READPOST_EXPIRY) ? (int) $forums_arr['pid'] > $forums_arr['lastpostread'] : 0 ? 'new' : ''); } else { $img = "unlocked"; } if ($subforums == false && !empty($sfa[$forumid])) { list($subposts, $subtopics) = get_count($sfa[$forumid]["count"]); $topics = $forums_arr["topiccount"] + $subtopics; $posts = $forums_arr["postcount"] + $subposts; } else { $topics = $forums_arr["topiccount"]; $posts = $forums_arr["postcount"]; } ?> <tr> <td align='left' style="border:none;"> <table border=0 cellspacing=0 cellpadding=0 style="border:none;"> <tr> <td class=embedded style='padding-right: 5px'><img src="themes/<?php echo $ss_uri . "/forum/" . $img; ?> .png" /></td> <td class=embedded> <a href='<?php echo $_SERVER['PHP_SELF']; ?> ?action=viewforum&forumid=<?php echo $forumid; ?> '><b><?php echo safeChar($forums_arr["name"]); ?> </b></a><?php if ($CURUSER['class'] >= UC_ADMINISTRATOR || isMod($forumid)) { ?> <font class='small'>[<a class='altlink' href='<?php echo $_SERVER['PHP_SELF']; ?> ?action=editforum&forumid=<?php echo $forumid; ?> '>Edit</a>][<a class='altlink' href='<?php echo $_SERVER['PHP_SELF']; ?> ?action=deleteforum&forumid=<?php echo $forumid; ?> '>Delete</a>]</font><?php } if (!empty($forums_arr["description"])) { ?> <br /><?php echo safeChar($forums_arr["description"]); } if ($subforums == false && !empty($sfa[$forumid])) { echo "<br/>" . subforums($sfa[$forumid]["topics"]); } if ($show_mods == true && isset($forummods[$forumid])) { print "<br/>" . showMods($forummods[$forumid]); } ?> </td> </tr> </table> </td> <td align='center'><?php echo number_format($topics); ?> </td> <td align='center'><?php echo number_format($posts); ?> </td> <td align='left' nowrap="nowrap"><?php echo $lastpost; ?> </td> </tr><?php } }
function show_forums($forid, $subforums = false, $sfa = "", $mods_array = "", $show_mods = false) { global $CURUSER, $TBDEV; $htmlout = ''; $forums_res = mysql_query("SELECT f.id, f.name, f.description, f.postcount, f.topiccount, f.minclassread, p.added, p.topicid, p.anonymous, p.userid, p.id AS pid, u.username, t.subject, t.lastpost, r.lastpostread " . "FROM forums AS f " . "LEFT JOIN posts AS p ON p.id = (SELECT MAX(lastpost) FROM topics WHERE forumid = f.id) " . "LEFT JOIN users AS u ON u.id = p.userid " . "LEFT JOIN topics AS t ON t.id = p.topicid " . "LEFT JOIN readposts AS r ON r.userid = " . sqlesc($CURUSER['id']) . " AND r.topicid = p.topicid " . "WHERE " . ($subforums == false ? "f.forid = {$forid} AND f.place =-1 ORDER BY f.forid ASC" : "f.place={$forid} ORDER BY f.id ASC") . "") or sqlerr(__FILE__, __LINE__); while ($forums_arr = mysql_fetch_assoc($forums_res)) { if ($CURUSER['class'] < $forums_arr["minclassread"]) { continue; } $forumid = (int) $forums_arr["id"]; $lastpostid = (int) $forums_arr['lastpost']; if ($subforums == false && !empty($sfa[$forumid])) { if ($sfa[$forumid]['lastpost']['postid'] > $forums_arr['pid']) { if ($sfa[$forumid]['lastpost']["anonymous"] == "yes") { if ($CURUSER['class'] < UC_MODERATOR && $sfa[$forumid]['lastpost']['userid'] != $CURUSER['id']) { $lastpost1 = "Anonymous<br />"; } else { $lastpost1 = "Anonymous(<a href='{$TBDEV['baseurl']}/userdetails.php?id=" . (int) $sfa[$forumid]['lastpost']['userid'] . "'><b>" . htmlspecialchars($sfa[$forumid]['lastpost']['user']) . "</b></a>)<br />"; } } elseif ($sfa[$forumid]['lastpost']["anonymous"] == "no") { $lastpost1 = "<a href='{$TBDEV['baseurl']}/userdetails.php?id=" . (int) $sfa[$forumid]['lastpost']['userid'] . "'><b>" . htmlspecialchars($sfa[$forumid]['lastpost']['user']) . "</b></a><br />"; } $lastpost = "" . get_date($sfa[$forumid]['lastpost']['added'], 'LONG', 1, 0) . "<br />" . "by {$lastpost1}" . "in <a href='" . $_SERVER['PHP_SELF'] . "?action=viewtopic&topicid=" . (int) $sfa[$forumid]['lastpost']['topic'] . "&page=p" . $sfa[$forumid]['lastpost']['postid'] . "#p" . $sfa[$forumid]['lastpost']['postid'] . "'><b>" . htmlspecialchars($sfa[$forumid]['lastpost']['tname']) . "</b></a>"; } elseif ($sfa[$forumid]['lastpost']['postid'] < $forums_arr['pid']) { if ($forums_arr["anonymous"] == "yes") { if ($CURUSER['class'] < UC_MODERATOR && $forums_arr["userid"] != $CURUSER["id"]) { $lastpost2 = "Anonymous<br />"; } else { $lastpost2 = "Anonymous(<a href='{$TBDEV['baseurl']}/userdetails.php?id=" . (int) $forums_arr["userid"] . "'><b>" . htmlspecialchars($forums_arr['username']) . "</b></a>)<br />"; } } elseif ($forums_arr["anonymous"] == "no") { $lastpost2 = "<a href='{$TBDEV['baseurl']}/userdetails.php?id=" . (int) $forums_arr["userid"] . "'><b>" . htmlspecialchars($forums_arr['username']) . "</b></a><br />"; } $lastpost = "" . get_date($forums_arr["added"], 'LONG', 1, 0) . "<br />" . "by {$lastpost2}" . "in <a href='" . $_SERVER['PHP_SELF'] . "?action=viewtopic&topicid=" . (int) $forums_arr["topicid"] . "&page=p{$lastpostid}#p{$lastpostid}'><b>" . htmlspecialchars($forums_arr['subject']) . "</b></a>"; } else { $lastpost = "N/A"; } } else { if (is_valid_id($forums_arr['pid'])) { if ($forums_arr["anonymous"] == "yes") { if ($CURUSER['class'] < UC_MODERATOR && $forums_arr["userid"] != $CURUSER["id"]) { $lastpost = "" . get_date($forums_arr["added"], 'LONG', 1, 0) . "<br />" . "by <i>Anonymous</i><br />" . "in <a href='" . $_SERVER['PHP_SELF'] . "?action=viewtopic&topicid=" . (int) $forums_arr["topicid"] . "&page=p{$lastpostid}#p{$lastpostid}'><b>" . htmlspecialchars($forums_arr['subject']) . "</b></a>"; } else { $lastpost = "" . get_date($forums_arr["added"], 'LONG', 1, 0) . "<br />" . "by <i>Anonymous</i>(<a href='{$TBDEV['baseurl']}/userdetails.php?id=" . (int) $forums_arr["userid"] . "'><b>" . htmlspecialchars($forums_arr['username']) . "</b></a>)<br />" . "in <a href='" . $_SERVER['PHP_SELF'] . "?action=viewtopic&topicid=" . (int) $forums_arr["topicid"] . "&page=p{$lastpostid}#p{$lastpostid}'><b>" . htmlspecialchars($forums_arr['subject']) . "</b></a>"; } } else { $lastpost = "" . get_date($forums_arr["added"], 'LONG', 1, 0) . "<br />" . "by <a href='{$TBDEV['baseurl']}/userdetails.php?id=" . (int) $forums_arr["userid"] . "'><b>" . htmlspecialchars($forums_arr['username']) . "</b></a><br />" . "in <a href='" . $_SERVER['PHP_SELF'] . "?action=viewtopic&topicid=" . (int) $forums_arr["topicid"] . "&page=p{$lastpostid}#p{$lastpostid}'><b>" . htmlspecialchars($forums_arr['subject']) . "</b></a>"; } } else { $lastpost = "N/A"; } } if (is_valid_id($forums_arr['pid'])) { $img = 'unlocked' . ($forums_arr['added'] > time() - $TBDEV['readpost_expiry'] ? (int) $forums_arr['pid'] > $forums_arr['lastpostread'] : 0 ? 'new' : ''); } else { $img = "unlocked"; } if ($subforums == false && !empty($sfa[$forumid])) { list($subposts, $subtopics) = get_count($sfa[$forumid]["count"]); $topics = $forums_arr["topiccount"] + $subtopics; $posts = $forums_arr["postcount"] + $subposts; } else { $topics = $forums_arr["topiccount"]; $posts = $forums_arr["postcount"]; } $htmlout .= "<tr>\r\n\t\t\t<td align='left'>\r\n\t\t\t\t<table border='0' cellspacing='0' cellpadding='0' style='border:none;'>\r\n\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t<td class='embedded' style='padding-right: 5px'><img src='" . $TBDEV['pic_base_url'] . $img . ".gif' alt='' /></td>\r\n\t\t\t\t\t\t<td class='embedded'>\r\n\t\t\t\t\t\t\t<a href='" . $_SERVER['PHP_SELF'] . "?action=viewforum&forumid=" . $forumid . "'><b>" . htmlspecialchars($forums_arr["name"]) . "</b></a>"; if ($CURUSER['class'] >= UC_ADMINISTRATOR || isMod($forumid)) { $htmlout .= " <font class='small'>[<a class='altlink' href='" . $_SERVER['PHP_SELF'] . "?action=editforum&forumid=" . $forumid . "'>Edit</a>][<a class='altlink' href='" . $_SERVER['PHP_SELF'] . "?action=deleteforum&forumid=" . $forumid . "'>Delete</a>]</font>"; } if (!empty($forums_arr["description"])) { $htmlout .= "<br />" . htmlspecialchars($forums_arr["description"]); } if ($subforums == false && !empty($sfa[$forumid])) { $htmlout .= "<br/>" . subforums($sfa[$forumid]["topics"]); } if ($show_mods == true && isset($mods_array[$forumid])) { $htmlout .= "<br/>" . showMods($mods_array[$forumid]); } $htmlout .= "</td>\r\n\t\t\t\t\t</tr>\r\n\t\t\t\t</table>\r\n\t\t\t</td>\r\n\t\t\t<td align='center'>" . number_format($topics) . "</td>\r\n\t\t\t<td align='center'>" . number_format($posts) . "</td>\r\n\t\t\t<td align='left' nowrap='nowrap'>" . $lastpost . "</td>\r\n\t\t</tr>"; } return $htmlout; }