mysql_query("SELECT `id`, `read_perms` FROM {$ipb_table_prefix}forums");
while($r = mysql_fetch_row())
{
$perms = explode(",", $r['read_perms']);
if(in_array($member['group_id'], $perms)
{
$forums[$r['id']] = "t.forum_id = {$r['id']}";
}
}
$forum_string = implode(" OR ", $forums);
mysql_query("SELECT DISTINCT t.tid, t.title, t.last_poster_name, t.last_poster_id, t.starter_id, t.starter_name, t.forum_id, f.read_perms FROM ".$ipb_table_prefix."topics t INNER JOIN ".$ipb_table_prefix."forums f ON t.forum_id = f.id where {$forum_string} ORDER BY t.last_post DESC LIMIT ".$ipb_limit, $ipb_db_connection);