<?php
/************************************************************************/
/* Maximus CMS: Web Portal System                                       */
/* ==============================                                       */
/*                                                                      */
/* Copyright (c) 2002 - 2006                                            */
/* http://www.php-maximus.fr                                            */
/* dev@php-maximus.org                                                  */
/*                                                                      */
/* 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 */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/
/* Based on PHP-NUKE: Web Portal System                                 */
/************************************************************************/
defined('MAXIMUS') or die ('Access denied block forums MAXIMUS directly...');

if ( $content = opencacheb ( 'Forums', 'html' , "".CACHE_BL_FORUM."", '1' ) ) {
} else {

global $prefix, $sitename;

$sql = "SELECT `forum_id`, `topic_id`, `topic_title` FROM `".$prefix."_bbtopics` ORDER BY `topic_time` DESC LIMIT 10";
if ( !($result = $GLOBALS['db']->sql_query($sql)) )
{ query_die(BLOCK_ERROR, 'Could not obtain _bbtopics', '', __LINE__, __FILE__, $sql);}
$content = "<br />";
while ($row = $GLOBALS['db']->sql_fetchrow($result)) {
    $forum_id    = $GLOBALS['db']->XMFnum($row['forum_id']);
    $topic_id    = $GLOBALS['db']->XMFnum($row['topic_id']);
    $topic_title = stripslashes($row['topic_title']);
    $sql2 = "SELECT `auth_view`, `auth_read` FROM `".$prefix."_bbforums` WHERE `forum_id`='$forum_id'";
    if ( !($result2 = $GLOBALS['db']->sql_query($sql2)) )
{ query_die(BLOCK_ERROR, 'Could not obtain _bbforums', '', __LINE__, __FILE__, $sql2);}
    $row2      = $GLOBALS['db']->sql_fetchrow($result2);
    $auth_view = $GLOBALS['db']->XMFnum($row2['auth_view']);
    $auth_read = $GLOBALS['db']->XMFnum($row2['auth_read']);
    if (($auth_view < 2) OR ($auth_read < 2)) {
        $content .= "<img src=\"images/arrow.gif\" border=\"0\" alt=\"\" title=\"\" width=\"9\" height=\"9\">&nbsp;<a href=\"modules.php?name=Forums&amp;file=viewtopic&amp;t=$topic_id\">$topic_title</a><br />";
    }
}
$GLOBALS['db']->sql_freeresult($result);
$GLOBALS['db']->sql_freeresult($result2);
$content .= "<br /><center><a href=\"modules.php?name=Forums\"><b>$sitename Forums</b></a><br /><br /></center>";

closecacheb ( "".$content."", 'Forums', 'html' , "".CACHE_BL_FORUM."", '1' );
}