<?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");

$pagetitle = "- "._NEWDOWNLOADS;
incoh();
menu('1');
br('1');
title(_NEWDOWNLOADS);
Max_OpenTable();
$counter = 0;
$allweekdownloads = 0;
while ($counter <= 7-1){
  $newdownloaddayRaw = (time()-(86400 * $counter));
  $newdownloadDB = Date("Y-m-d", $newdownloaddayRaw);
  $totaldownloads = $GLOBALS['db']->sql_numrows($GLOBALS['db']->sql_query("SELECT * FROM `".TABLE_NSNGD_DOWNLOADS."` WHERE `date` LIKE '%$newdownloadDB%' AND `active`>'0'"));
  $counter++;
  $allweekdownloads = $allweekdownloads + $totaldownloads;
}
$counter = 0;
$allmonthdownloads = 0;
while ($counter <=30-1){
  $newdownloaddayRaw = (time()-(86400 * $counter));
  $newdownloadDB = Date("Y-m-d", $newdownloaddayRaw);
  $totaldownloads = $GLOBALS['db']->sql_numrows($GLOBALS['db']->sql_query("SELECT * FROM `".TABLE_NSNGD_DOWNLOADS."` WHERE `date` LIKE '%$newdownloadDB%' AND `active`>'0'"));
  $allmonthdownloads = $allmonthdownloads + $totaldownloads;
  $counter++;
}
echo "<center><b>"._TOTALNEWDOWNLOADS.":</b> "._LASTWEEK." - $allweekdownloads \ "._LAST30DAYS." - $allmonthdownloads<br />\n";
echo ""._SHOW.": <a href='modules.php?name=$module_name&amp;op=NewDownloads&amp;newdownloadshowdays=7'>"._1WEEK."</a> - <a href='modules.php?name=$module_name&amp;op=NewDownloads&amp;newdownloadshowdays=14'>"._2WEEKS."</a> - <a href='modules.php?name=$module_name&amp;op=NewDownloads&amp;newdownloadshowdays=30'>"._30DAYS."</a>\n";
echo "</center><br />\n";
if (!isset($newdownloadshowdays)) { $newdownloadshowdays = 7; }
echo "<br /><center><b>"._DTOTALFORLAST." $newdownloadshowdays "._DAYS.":</b><br /><br />\n";
$counter = 0;
$allweekdownloads = 0;
while ($counter <= $newdownloadshowdays-1) {
  $newdownloaddayRaw = (time()-(86400 * $counter));
  $newdownloadDB = Date("Y-m-d", $newdownloaddayRaw);
  $totaldownloads = $GLOBALS['db']->sql_numrows($GLOBALS['db']->sql_query("SELECT * FROM ".TABLE_NSNGD_DOWNLOADS." WHERE date LIKE '%$newdownloadDB%' AND active>'0'"));
  $counter++;
  $allweekdownloads = $allweekdownloads + $totaldownloads;
  echo "<strong><big>&middot;</big></strong> <a href='modules.php?name=$module_name&amp;op=NewDownloadsDate&amp;selectdate=$newdownloaddayRaw'>$newdownloadDB</a>&nbsp($totaldownloads)<br />\n";
}
$counter = 0;
$allmonthdownloads = 0;
echo "</center>\n";
Max_CloseTable();
incof();