<?php
/********************************************************/
/* NSN Groupes Sections                                 */
/* By: NukeScripts Network (webmaster@nukescripts.fr)   */
/* http://www.nukescripts.fr                            */
/* Copyright ¿ 2000-2005 by NukeScripts Network         */
/* ==================================================== */
/* Based from:                                          */
/* PHP-NUKE: Web Portal System                          */
/********************************************************/
defined('MAXIMUS') or Header("Location: index.php");

    $sections_config = sections_get_configs();
    $blockr = $sections_config['blockr'];
    $index  = $blockr; 
    
if (defined('ADMIN_ALLOW')) {
	$news_retention = CACHE_ASECTIONS;
	$name_homenews  = "SectionsAdmin";
	$news_extension = "php";
} elseif ( defined('USER_ALLOW') ) {
	$news_retention = CACHE_USECTIONS;
	$name_homenews  = "SectionsUser";
	$news_extension = "html";
} else {
	$news_retention = VSECTIONS;
	$name_homenews  = "Sections";
	$news_extension = "html";
}
incoh( "".$name_homenews."", "".$news_extension."", "".$news_retention."" );
    global $sitename;
    menu();
    
    $sql = "SELECT `secid`, `secname`, `image`, `view`, `groups`, `actif` from `".TABLE_NSNSECTIONS_RUBRIQUES."` where `actif`='1' order by `secid` ";
    if ( !($result = $GLOBALS['db']->sql_query($sql)) )
{ query_die(CORE_ERROR, 'Could not obtain _nsnsections_rubriques', '', __LINE__, __FILE__, $sql);}
    Max_OpenTable();
    echo "<table border=\"0\" width='100%' align=\"center\"><tr>";
	while($row = $db->sql_fetchrow($result)) {
	    $secid   = $db->XMFnum($row['secid']);
	    $secname = stripslashes($row['secname']);
	    $image   = stripslashes($row['image']);
	    $view    = $db->XMFnum($row['view']);
	    $groups  = $db->XMFnum($row['groups']);


$nbartcles = $db->sql_query("SELECT `secid` from `".TABLE_NSNSECTIONS_ARTICLES."` where `secid`='$secid'");
$nbartcles = $db->sql_numrows($nbartcles);

$count  = 0;
$nbvues = $db->sql_query("SELECT `counter` from `".TABLE_NSNSECTIONS_ARTICLES."` where `secid`='$secid'");
 while($vues = $db->sql_fetchrow($nbvues)) {
$counter = $db->XMFnum($vues['counter']);
$count   = $count + $counter;
}

    if ($view == 0) {
        $view2 = ""._SC_VISITEURS."";
    } elseif ($view == 1) {
        $view2 = ""._SC_USERSI."";
    } elseif ($view == 2) {
        $view2 = ""._SC_ADMINI."";
    } elseif ($view > 3) {
        $view2 = ""._SC_GROUPS."";
    }

if ($a == 0) { echo "<tr>"; }
echo "<td width='50%' valign='top'>";

if ($view == 0) {
viewsections ($secid, $image, $secname, $nbartcles, $count, $view2);
}

if ($view == 1 AND defined('USER_ALLOW') || defined('ADMIN_ALLOW')) {
viewsections ($secid, $image, $secname, $nbartcles, $count, $view2);
}

if ($view == 2 AND defined('ADMIN_ALLOW')) {
viewsections ($secid, $image, $secname, $nbartcles, $count, $view2);
}

if ($view > 3 AND in_groups($groups) || defined('ADMIN_ALLOW')) {
viewsections ($secid, $image, $secname, $nbartcles, $count, $view2);
}

else  {

if ($view > 3 AND !in_groups($groups)) {
Max_OpenTable();
echo "<table border='0' width='100%' align='center' valign='top'><tr><td>";
echo "<center><img src='modules/Sections/images/group.gif' alt='' />&nbsp;&nbsp;&nbsp;"._SC_ACCES." <b>"._SC_GROUPS."</b> "._SC_ONLY."</center>";
echo "</td></tr></table>";
Max_CloseTable();
}

if ($view == 2 AND !defined('ADMIN_ALLOW')) {Max_OpenTable();
echo "<table border='0' width='100%' align='center' valign='top'><tr><td>";
echo "<center><img src='modules/Sections/images/admin.gif' alt='' />&nbsp;&nbsp;&nbsp;"._SC_ACCES." <b>"._SC_ADMINI."</b> "._SC_ONLY."</center>";
echo "</td></tr></table>";
Max_CloseTable();
}
if ($view == 1 AND !defined('USER_ALLOW')) {Max_OpenTable();
echo "<table border='0' width='100%' align='center' valign='top'><tr><td>";
echo "<center><img src='modules/Sections/images/registered.gif' alt='' />&nbsp;&nbsp;&nbsp;"._SC_ACCES." <b>"._SC_USERSI."</b> "._SC_ONLY."</center>";
echo "</td></tr></table>";
Max_CloseTable();
}
}

echo "</td>";
$a++;
if ($a == 2) { echo "</tr>"; $a = 0; }
}
if ($a ==1) { echo "<td width='50%'>&nbsp;</td></tr></table>"; } else { echo "</tr></table>"; }


    Max_CloseTable();
    incof("".$name_homenews."", "".$news_extension."", "".$news_retention."");