<?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 supporters rn MAXIMUS directly...');

if (defined('ADMIN_ALLOW')) {
	$block_retention   = CACHE_BL_SUPPORTERSRN;
	$block_name_cache = "SupportersRNAdmin";
	$extension        = "php";
} else {
	$block_retention   = CACHE_BL_SUPPORTERSRN;
	$block_name_cache = "SupportersRN";
	$extension        = "html";
}

if ( $content = opencacheb ( "".$block_name_cache."", "".$extension."" , "".$block_retention."", '2' ) ) {
} else {


get_lang("Supporters");
$supporterrn = $GLOBALS['db']->sql_fetchrow($GLOBALS['db']->sql_query("SELECT * from `".TABLE_NSNSP_CONFIG."`"));
$content = "<center>"._SUPPORTEDBY."<br /><br />";
    $j = 1;
    while ($j <= 5) {
        $sresult = $GLOBALS['db']->sql_query("SELECT `site_id` FROM `".TABLE_NSNSP_SITES."` WHERE `site_status`='1'");
        $numrows = $GLOBALS['db']->sql_numrows($sresult);
        if ($numrows==1) {
            list ($siteid) = $GLOBALS['db']->sql_fetchrow($sresult);
        } else if ($numrows > 1) {
            $i = 1;
            while (list ($stid) = $GLOBALS['db']->sql_fetchrow($sresult)) {
                $abid[$i] = $stid;
                $i++;
            }
            $siteid = $abid[rand(1, $numrows)];
        } else {
            $siteid = 0;
        }
        if($j == 1) {
            $sitelist = "WHERE `site_id`='$siteid'";
        } else {
            $sitelist = $sitelist." OR `site_id`='$siteid'";
        }
        $j++;
    }

    $result = $GLOBALS['db']->sql_query("SELECT `site_id`, `site_name`, `site_image` FROM `".TABLE_NSNSP_SITES."` $sitelist");
    while ($raw = $GLOBALS['db']->sql_fetchrow($result)) {
$site_id    = $GLOBALS['db']->XMFnum($raw['site_id']);
$site_name  = stripslashes($raw['site_name']);
$site_image = stripslashes($raw['site_image']);
        echo "<a href=\"modules.php?name=Supporters&amp;op=go&amp;site_id=$site_id\" target=\"_blank\"><img src=\"$site_image\" height=\"31\" width=\"88\" title=\"$site_name\" alt='$site_name' border=\"0\" /></a><br /><br />\n";
    }
$content .="</center>\n";
if ($supporterrn['require_user'] == 0 || defined('USER_ALLOW')) { $content .= "[ <a href='modules.php?name=Supporters&amp;file=submit'>"._BESUPPORTER."</a> ]<br />\n"; }
if (defined('ADMIN_ALLOW')) { $content .= "[ <a href='modules.php?name=Supporters&amp;file=admin'>"._GOTOADMIN."</a> ]<br />\n"; }
$content .= "[ <a href='modules.php?name=Supporters'>"._SUPPORTERS."</a> ]</center>\n";

closecacheb ( "".$content."", "".$block_name_cache."", "".$extension."" , "".$block_retention."", '2' );
}