<?php
/**
 * $Source: /home/cvs/nukescripts/kernel/cblocks1.php,v $
 * $Revision: 1.1.0a $
 * $Author: cyril $
 * $Date: 2006/06/19 21:03:12 $
 *
 */
/************************************************************************/
/* 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                                 */
/************************************************************************/
/********************************************************/
/* NSN Center Blocks                                    */
/* By: NukeScripts Network (webmaster@nukescripts.net)  */
/* http://www.nukescripts.net                           */
/* Copyright © 2000-2005 by NukeScripts Network         */
/********************************************************/
/* Original by: Richard Benfield                        */
/* http://www.benfield.ws                               */
/********************************************************/
defined('MAXIMUS') or die ('Access denied cblocks1 MAXIMUS directly...');

global $bgcolor1, $bgcolor2;
$sql = "SELECT `enabled`, `height`, `count` FROM `".TABLE_NSNCB_CONFIG."` WHERE `cgid`='1'";
if ( !($result = $GLOBALS['db']->sql_query($sql)) )
{ query_die(GENERAL_ERROR, 'Could not obtain config center block1', '', __LINE__, __FILE__, $sql);}
$row     = $GLOBALS['db']->sql_fetchrow($result);
$enabled = $GLOBALS['db']->XMFbin($row['enabled']);
$height  = $GLOBALS['db']->XMFnum($row['height']);
$count   = $GLOBALS['db']->XMFnum($row['count']);
if($enabled == '1') {
    if($height <> "") { $cheight = "height='$height' "; } else { $cheight = ""; }
    echo "<table width='100%' ".$cheight."border='0' cellspacing='1' cellpadding='0' bgcolor='$bgcolor2'><tr><td valign='top'>\n"
        ."<table width='100%' ".$cheight."border='0' cellspacing='1' cellpadding='4' bgcolor='$bgcolor1'><tr>";
    $sql1 = "SELECT `rid`, `cbid`, `wtype`, `width` FROM `".TABLE_NSNCB_BLOCKS."` WHERE `cgid`='1' ORDER BY `cbid`";
    if ( !($result1 = $GLOBALS['db']->sql_query($sql1)) )
    { query_die(GENERAL_ERROR, 'Could not obtain center block1', '', __LINE__, __FILE__, $sql);}
    while($row1 = $GLOBALS['db']->sql_fetchrow($result1)) {
    $cbid  = $GLOBALS['db']->XMFnum($row1['cbid']);
    $wtype = $GLOBALS['db']->XMFnum($row1['wtype']);
    $width = $GLOBALS['db']->XMFnum($row1['width']);
    $rid   = $GLOBALS['db']->XMFnum($row1['rid']);
        if($cbid <= $count) {
            if($wtype == '0') {
                echo "<td width='$width' valign='top' align='center'>\n";
            } else {
                echo "<td width='$width%' valign='top' align='center'>\n";
            }
            cb_blocks($rid);
            echo "</td>\n";
        }
    }
    echo "</tr></table>\n"
        ."</td></tr></table>\n";
    br('1');
    $GLOBALS['db']->sql_freeresult($result1);
}
$GLOBALS['db']->sql_freeresult($result);