Think I have it sussed out, can one of you kind people look over the code, see if I've made any glaring errors,
This forum block will a check to make sure the user has access to view the forums were the posts were made. If not it will not display the post. This checks both bbauth_access.auth_view = 1 and bbauth_access.auth_mod = 1 as well as checking to see if forum is public by using bbforums.auth_read.
Code:
<?php
/*************************************************/
/*************************************************/
/* Helius Theme Center Forum Block With Security */
/* Made For PHP Nuke 7.5 */
/* */
/* Made By Frisp http://www.unrealgamerz.org */
/* Based On Helius Center Forum Block v.3 */
/* Made by mikem http://www.nukemods.com */
/* */
/* 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 Free Software Foundation; either */
/* version 2 of the License. */
/*************************************************/
/*************************************************/
if (eregi("block-Forums.php", $PHP_SELF)) {
Header("Location: index.php");
die();
}
global $prefix, $dbi, $sitename, $user, $cookie, $group_id;
cookiedecode($user);
$uname = $cookie[1];
$result10 = sql_query("SELECT u.user_id FROM ".$prefix."_users u where username = '$uname'", $dbi);
list($user_id)=sql_fetch_row($result10, $dbi);
$userid = $user_id;
$count = 1;
$show = " <tr>
<td bgcolor=\"#525E6E\" height=\"25\" colspan=\"6\" align=\"center\" background=\"themes/Helius/forums/images/top_center.gif\"></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>";
$Count_Topics = 0;
$Topic_Buffer = "";
$result1 = sql_query("SELECT DISTINCT t.topic_id, t.topic_last_post_id, t.topic_title, t.topic_poster, t.topic_views, t.topic_replies, t.topic_moved_id, f.forum_name, f.forum_id, f.auth_read
FROM ".$prefix."_bbtopics t, ".$prefix."_bbforums f,".$prefix."_bbuser_group a, ".$prefix."_bbauth_access b
where t.forum_id=f.forum_id and
f.forum_id=b.forum_id and
b.group_id=a.group_id and
(( a.user_id='$userid' and (b.auth_view = 1 or b.auth_mod = 1 )) OR f.auth_read = 0)
ORDER BY t.topic_last_post_id DESC LIMIT 5", $dbi);
while(list($topic_id, $topic_last_post_id, $topic_title, $topic_poster, $topic_views, $topic_replies, $topic_moved_id, $forum_name, $forum_id, $auth_read) = sql_fetch_row($result1, $dbi))
{
$skip_display = 0;
if( $HideViewReadOnly == 1 )
{
$result2 = $db->sql_query( "SELECT auth_view, auth_read FROM ".$prefix."_bbforums where forum_id = '$forum_id'" );
list( $auth_view, $auth_read ) = $db->sql_fetchrow( $result2 );
if( ( $auth_view != 0 ) or ( $auth_read != 0 ) ) { $skip_display = 1; }
}
if( $topic_moved_id != 0 )
{
// Shadow Topic !!
$skip_display = 1;
}
if( $skip_display == 0 )
{
$Count_Topics += 1;
$result2 = sql_query("SELECT username, user_id FROM ".$prefix."_users where user_id='$topic_poster'", $dbi);
list($username, $user_id)=sql_fetch_row($result2, $dbi);
$avtor=$username;
$sifra=$user_id;
$result3 = sql_query("SELECT poster_id, FROM_UNIXTIME(post_time,'%b %d, %Y at %T') as post_time FROM ".$prefix."_bbposts where post_id='$topic_last_post_id'", $dbi);
list($poster_id, $post_time)=sql_fetch_row($result3, $dbi);
$result4 = sql_query("SELECT topic_id, poster_id, FROM_UNIXTIME(post_time,'%b %d, %Y at %T') as post_time FROM ".$prefix."_bbposts where post_id='$topic_last_post_id'", $dbi);
list($topic_id, $poster_id, $post_time)=sql_fetch_row($result4, $dbi);
$result5 = sql_query("SELECT username, user_id FROM ".$prefix."_users where user_id='$poster_id'", $dbi);
list($username, $user_id)=sql_fetch_row($result5, $dbi);
$viewlast .=" <tr>
<td height=\"34\" nowrap bgcolor=\"#EAEDF4\" class=\"row1\"><img src=\"themes/Helius/forums/images/folder_new.gif\" width=\"19\" height=\"18\" border=\"0\" /></td>
<td width=\"100%\" bgcolor=\"#EAEDF4\" class=\"row1\">$forum_name
<a href=\"modules.php?name=Forums&file=viewtopic&p=$topic_last_post_id#$topic_last_post_id\">$topic_title</a></td>
<td align=\"center\" bgcolor=\"#F8F9FA\" class=\"row2\">$topic_replies</td>
<td align=\"center\" bgcolor=\"#EAEDF4\" class=\"row3\"><a href=\"modules.php?name=Forums&file=profile&mode=viewprofile&u=$sifra\">$avtor</a></td>
<td align=\"center\" bgcolor=\"#F8F9FA\" class=\"row2\">$topic_views</td>
<td align=\"center\" nowrap bgcolor=\"#EAEDF4\" class=\"row3\"><font size=\"-2\">$post_time</font>
<a href=\"modules.php?name=Forums&file=profile&mode=viewprofile&u=$user_id\">$username</a><a href=\"modules.php?name=Forums&file=viewtopic&p=$topic_last_post_id#$topic_last_post_id\"><img src=\"themes/Helius/forums/images/icon_minipost_new.gif\" border=\"0\" alt=\"Last Post\"></a></td>
</tr>";
}
if( $Last_New_Topics == $Count_Topics ) { break 1; }
}
$content .= "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<tr>
<td bgcolor=\"#525E6E\"><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<tr>
<td><table width=\"100%\" border=\"0\" cellpadding=\"1\" cellspacing=\"1\">
<tr>
<th height=\"25\" colspan=\"2\" align=\"center\" nowrap background=\"themes/Helius/forums/images/top_center.gif\" class=\"thcornerl\"><font color=\"#364D67\">Forum/Topic</font></th>
<th width=\"50\" align=\"center\" nowrap background=\"themes/Helius/forums/images/top_center.gif\" class=\"thtop\"><font color=\"#364D67\">Replies</font></th>
<th width=\"100\" align=\"center\" nowrap background=\"themes/Helius/forums/images/top_center.gif\" class=\"thtop\"><font color=\"#364D67\">Author</font></th>
<th width=\"50\" align=\"center\" nowrap background=\"themes/Helius/forums/images/top_center.gif\" class=\"thtop\"><font color=\"#364D67\">Views</font></th>
<th align=\"center\" nowrap background=\"themes/Helius/forums/images/top_center.gif\" class=\"thcornerr\"><font color=\"#364D67\">Last Post</font></th>
</tr>";
$content .= "$viewlast";
$content .= "$show";
?>
Regards,
[_]frisp