<?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                                 */
/************************************************************************/
/********************************************************/
/* NSN GR Downloads                                     */
/* By: NukeScripts Network (webmaster@nukescripts.net)  */
/* http://www.nukescripts.net                           */
/* Copyright  2000-2005 by NukeScripts Network         */
/********************************************************/
defined('MAXIMUS') or Header("Location: index.php");

if ($dl_config['mostpopulartrig'] == 1) {
  $pagetitle = "- "._MOSTPOPULAR." ".$dl_config['mostpopular']."%";
} else {
  $pagetitle = "- "._MOSTPOPULAR." ".$dl_config['mostpopular']."";
}
incoh();
menu('1');
br('1');
Max_OpenTable();
echo "<table border='0' width='100%'><tr><td align='center'>\n";
if ($ratenum != "" && $ratetype != "") {
  $dl_config['mostpopular'] = $ratenum;
  if ($ratetype == "percent") $dl_config['mostpopulartrig'] = 1;
}
if ($dl_config['mostpopulartrig'] == 1) {
  //$mostpopularpercent = $dl_config['mostpopular'];
  $result = $GLOBALS['db']->sql_query("SELECT * FROM `".TABLE_NSNGD_DOWNLOADS."` WHERE `active`>'0'");
  $totalmostpopdownloads = $GLOBALS['db']->sql_numrows($result);
  $dl_config['mostpopular'] = $dl_config['mostpopular'] / 100;
  $dl_config['mostpopular'] = $totalmostpopdownloads * $dl_config['mostpopular'];
  $dl_config['mostpopular'] = round($dl_config['mostpopular']);
}
if ($dl_config['mostpopulartrig'] == 1) {
  echo "<center><font class='option'><b>"._MOSTPOPULAR." ".$dl_config['mostpopular']."% ("._OFALL." $totalmostpopdownloads "._DOWNLOADS.")</b></font></center>\n";
} else {
  echo "<center><font class='option'><b>"._MOSTPOPULAR." ".$dl_config['mostpopular']."</b></font></center>\n";
}
echo "<tr><td align='center'>"._SHOWTOP.": [ <a href='modules.php?name=$module_name&amp;op=MostPopular&amp;ratenum=10&amp;ratetype=num'>10</a> - ";
echo "<a href='modules.php?name=$module_name&amp;op=MostPopular&amp;ratenum=25&amp;ratetype=num'>25</a> - ";
echo "<a href='modules.php?name=$module_name&amp;op=MostPopular&amp;ratenum=50&amp;ratetype=num'>50</a> | ";
echo "<a href='modules.php?name=$module_name&amp;op=MostPopular&amp;ratenum=1&amp;ratetype=percent'>1%</a> - ";
echo "<a href='modules.php?name=$module_name&amp;op=MostPopular&amp;ratenum=5&amp;ratetype=percent'>5%</a> - ";
echo "<a href='modules.php?name=$module_name&amp;op=MostPopular&amp;ratenum=10&amp;ratetype=percent'>10%</a> ]</td></tr\n>";
echo "</table>\n";
echo "<table border='0' cellpadding='0' cellspacing='4' width='100%'>\n";
$result = $GLOBALS['db']->sql_query("SELECT `lid` FROM `".TABLE_NSNGD_DOWNLOADS."` WHERE `active`>'0' ORDER BY `hits` DESC LIMIT 0,".$dl_config['mostpopular']);
$a = 0;
while(list($lid) = $GLOBALS['db']->sql_fetchrow($result)) {
  if ($a == 0) { echo "<tr>"; }
  echo "<td valign='top' width='50%'><font class='content'>";
  showresulting($lid);
  echo "</font></td>";
  $a++;
  if ($a == 2) { echo "</tr>"; $a = 0; }
}
if ($a ==1) { echo "<td width=\"50%\">&nbsp;</td></tr>"; } else { echo "</tr>"; }
echo "</table>\n";
Max_CloseTable();
incof();