<?php
/********************************************************/
/* NSN GR Downloads                                     */
/* By: NukeScripts Network (webmaster@nukescripts.net)  */
/* http://www.nukescripts.net                           */
/* Copyright  2000-2005 by NukeScripts Network         */
/********************************************************/
defined('MAXIMUS') or die ('Access denied block nsngd access MAXIMUS directly...');

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

$modname = "Downloads";
get_lang($modname);

$content .= "<img src=\"images/blocks/uploads.png\" alt=\""._DL_UP."\" title=\""._DL_UP."\"height=\"16\" width=\"16\" /> <b>"._DL_UP.":</b><br />\n";
$sql = "SELECT `username`, `uploads` FROM `".TABLE_NSNGD_ACCESSES."` WHERE `uploads`>'0' ORDER BY `uploads` DESC LIMIT 0,5";
if ( !($result = $GLOBALS['db']->sql_query($sql)) )
{ query_die(CORE_ERROR, 'Could not obtain _nsngd_accesses', '', __LINE__, __FILE__, $sql);}
$a = 1;
while($row = $GLOBALS['db']->sql_fetchrow($result)) {
$uloads = $GLOBALS['db']->XMFnum($row['uploads']);
$uname  = stripslashes($row['username']);
    $content .= "<strong><big>&middot;</big></strong>&nbsp;$a: <a href=\"modules.php?name=Your_Account&amp;op=userinfo&amp;username=$uname\">$uname</a> ($uloads) "._DL_FILES."<br />";
    $a++;
}
$content .= "<hr>\n";
$content .= "<img src=\"images/blocks/downloads.png\" alt=\""._DL_DN."\" title=\""._DL_DN."\"height=\"16\" width=\"16\" /> <b>"._DL_DN.":</b><br />\n";
$sql1 = "SELECT `username`, `downloads` FROM `".TABLE_NSNGD_ACCESSES."` WHERE `downloads`>'0' ORDER BY `downloads` DESC LIMIT 0,5";
if ( !($result1 = $GLOBALS['db']->sql_query($sql1)) )
{ query_die(CORE_ERROR, 'Could not obtain _nsngd_accesses', '', __LINE__, __FILE__, $sql1);}
$a = 1;
while($row1 = $GLOBALS['db']->sql_fetchrow($result1)) {
$dloads = $GLOBALS['db']->XMFnum($row1['dloads']);
$uname  = stripslashes($row1['uname']);
    $unum = $GLOBALS['db']->sql_numrows($GLOBALS['db']->sql_query("SELECT * FROM `".TABLE_USERS."` WHERE `username`='$uname'"));
    if ($unum==0) { $uname = "Anonymous"; }
    $content .= "<strong><big>&middot;</big></strong>&nbsp;$a: <a href=\"modules.php?name=Your_Account&amp;op=userinfo&amp;username=$uname\">$uname</a> ($dloads) "._DL_FILES."<br />";
    $a++;
}
$content .= "<hr>\n";
$sql2 = "select `hits` from `".TABLE_NSNGD_DOWNLOADS."` WHERE `active`='1'";
if ( !($result2= $GLOBALS['db']->sql_query($sql2)) )
{ query_die(CORE_ERROR, 'Could not obtain _nsngd_downloads', '', __LINE__, __FILE__, $sql2);}
$totdld = $GLOBALS['db']->sql_numrows($result2);
while($raw2 = $GLOBALS['db']->sql_fetchrow($result2)) {
$hits = $GLOBALS['db']->XMFnum($raw2['hits']);
$total_hits = $total_hits + $hits;
}
$content .= "<img src=\"images/blocks/totals.png\" alt=\""._DL_TDN."\" title=\""._DL_TDN."\"height=\"16\" width=\"16\" /> <b>"._DL_TDN.":</b><br />\n";
$content .= "$totdld "._DL_FILESDL." $total_hits "._DL_TIMES."<br />";

closecacheb ( "".$content."", 'NSNGDAccess', 'html' , "".CACHE_BL_NSNGDACCESS."", '1' );
}