<?php
// File: $Id: dl-mostpopular.php,v 1.3 2001/12/09 15:44:49 gregorrothfuss Exp $ $Name: $
// ----------------------------------------------------------------------
// POST-NUKE Content Management System
// Copyright (C) 2001 by the Post-Nuke Development Team.
// http://www.postnuke.com/
// ----------------------------------------------------------------------
// Based on:
// PHP-NUKE Web Portal System - http://phpnuke.org/
// Thatware - http://thatware.org/
// ----------------------------------------------------------------------
// LICENSE
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// To read the license please visit http://www.gnu.org/copyleft/gpl.html
// ----------------------------------------------------------------------
// Original Author of file: Francisco Burzi
// Purpose of file:
// ----------------------------------------------------------------------
/**
* MostPopular
*/
function MostPopular($ratenum, $ratetype) {
global $admin, $ModName, $pntable, $mostpopdownloads, $topdownloadspercent;
global $totalmostpopdownloads, $datetime, $transferfile, $dbconn, $modurl, $locale;
include("header.php");
include(WHERE_IS_PERSO."config.php");
menu(1);
echo "<br>";
OpenTable();
echo "<table border=\"0\" width=\"100%\"><tr><td align=\"center\">";
if ($ratenum != "" && $ratetype != "") {
$mostpopdownloads = $ratenum;
if ($ratetype == "percent") $mostpopdownloadspercentrigger = 1;
}
if ($mostpopdownloadspercentrigger == 1) {
$topdownloadspercent = $mostpopdownloads;
$result=$dbconn->Execute("SELECT count(*) FROM $pntable[downloads_downloads]");
list($totalmostpopdownloads) = $result->fields;
$mostpopdownloads = $mostpopdownloads / 100;
$mostpopdownloads = $totalmostpopdownloads * $mostpopdownloads;
$mostpopdownloads = round($mostpopdownloads);
}
if ($mostpopdownloadspercentrigger == 1) {
echo "<center><font class=\"pn-title\">"._MOSTPOPULAR." $topdownloadspercent% ("._OFALL." $totalmostpopdownloads "._DOWNLOADS.")</font></center>";
} else {
echo "<center><font class=\"pn-title\">"._MOSTPOPULAR." $mostpopdownloads</font></center>";
}
echo "<tr><td><center><font class=\"pn-title\">"._SHOWTOP.":</font> [ <a class=\"pn-normal\" href=\"$modurl&req=MostPopular&ratenum=10&ratetype=num\">10</a> - "
."<a class=\"pn-normal\" href=\"$modurl&req=MostPopular&ratenum=25&ratetype=num\">25</a> - "
."<a class=\"pn-normal\" href=\"$modurl&req=MostPopular&ratenum=50&ratetype=num\">50</a> | "
."<a class=\"pn-normal\" href=\"$modurl&req=MostPopular&ratenum=1&ratetype=percent\">1%</a> - "
."<a class=\"pn-normal\" href=\"$modurl&req=MostPopular&ratenum=5&ratetype=percent\">5%</a> - "
."<a class=\"pn-normal\" href=\"$modurl&req=MostPopular&ratenum=10&ratetype=percent\">10%</a> ]</center><br><br></td></tr>";
$column = &$pntable['downloads_downloads_column'];
$sql = "SELECT $column[lid], $column[cid], $column[sid],
$column[title], $column[description], $column[date],
$column[hits], $column[downloadratingsummary],
$column[totalvotes], $column[totalcomments],
$column[filesize], $column[version], $column[homepage]
FROM $pntable[downloads_downloads]
ORDER BY $column[hits] DESC";
$result=$dbconn->SelectLimit($sql,$mostpopdownloads);
echo "<tr><td>";
//FTO : Test EOF and database error
if (!$result) {
PN_DBMsgError($dbconn, __FILE__, __LINE__, "An error ocurred");
die();
}
while(!$result->EOF) {
list($lid, $cid, $sid, $title, $description, $time, $hits, $downloadratingsummary, $totalvotes, $totalcomments, $filesize, $version, $homepage)=$result->fields;
$result->MoveNext();
$itemname = downloads_ItemNameFromIID($lid);
$catname = downloads_CatNameFromIID($lid);
if (authorised(0, 'Downloads::Item', "$itemname:$catname:$lid", ACCESS_READ)) {
$downloadratingsummary = number_format($downloadratingsummary, $mainvotedecimal);
$title = stripslashes($title);
$description = stripslashes($description);
if (authorised(0, 'Downloads::Item', "$itemname:$catname:$lid", ACCESS_EDIT)) {
echo "<a class=\"pn-normal\" href=\"admin.php?op=DownloadsModDownload&lid=$lid\"><img src=\"modules/$ModName/images/lwin.gif\" border=\"0\" alt=\""._EDIT."\"></a> ";
} else {
echo "<img src=\"modules/$ModName/images/lwin.gif\" border=\"0\" alt=\"\"> ";
}
echo "<font class=\"pn-normal\"><a class=\"pn-normal\" href=\"$modurl&req=getit&lid=$lid\">$title</a>";
newdownloadgraphic($datetime, $time);
popgraphic($hits);
detecteditorial($lid, $transfertitle, 1);
echo "<br>";
echo "<font class=\"pn-normal\">"._DESCRIPTION.": $description</font><br>";
setlocale (LC_TIME, $locale);
ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $time, $datetime);
$datetime = ml_ftime(""._LINKSDATESTRING."", mktime($datetime[4],$datetime[5],$datetime[6],$datetime[2],$datetime[3],$datetime[1]));
$datetime = ucfirst($datetime);
echo "<font class=\"pn-normal\">"._VERSION.": $version "._FILESIZE.": ".CoolSize($filesize)."</font><br>";
echo "<font class=\"pn-normal\">"._ADDEDON.": $datetime "._UDOWNLOADS.": $hits</font>";
$transfertitle = str_replace (" ", "_", $title);
/* voting & comments stats */
if ($totalvotes == 1) {
$votestring = _VOTE;
} else {
$votestring = _VOTES;
}
if ($downloadratingsummary!="0" || $downloadratingsummary!="0.0") {
echo " <font class=\"pn-normal\">"._RATING.": $downloadratingsummary ($totalvotes $votestring)</font>";
}
if ($homepage == "") {
echo "<br>";
} else {
echo "<br><a class=\"pn-normal\" href=\"$homepage\" target=\"new\">"._HOMEPAGE."</a> | ";
}
if (authorised(0, 'Downloads::Item', "$itemname:$catname:$lid", ACCESS_COMMENT)) {
echo "<a class=\"pn-normal\" href=\"$modurl&req=ratedownload&lid=$lid&ttitle=$transfertitle\">"._RATERESOURCE."</a>";
echo " | ";
}
echo "<a class=\"pn-normal\" href=\"$modurl&req=brokendownload&lid=$lid\">"._REPORTBROKEN."</a>";
echo " | <a class=\"pn-normal\" href=\"$modurl&req=viewdownloaddetails&lid=$lid&ttitle=$transfertitle\">"._DETAILS."</a>";
if ($totalcomments != 0) {
echo " | <a class=\"pn-normal\" href=\"$modurl&req=viewdownloadcomments&lid=$lid&ttitle=$transfertitle\">"._COMMENTS." ($totalcomments)</a>";
}
detecteditorial($lid, $transfertitle, 0);
echo "<br>";
$result2=$dbconn->Execute("SELECT ".$pntable['downloads_categories_column']['title'].
" FROM ".$pntable['downloads_categories'].
" WHERE ".$pntable['downloads_categories_column']['cid']."=".$cid);
list($ctitle) = $result2->fields;
echo "<font class=\"pn-normal\">"._CATEGORY.": $ctitle</font>";
$result3=$dbconn->Execute("SELECT ".$pntable['downloads_subcategories_column']['title'].
" FROM ".$pntable['downloads_subcategories'].
" WHERE ".$pntable['downloads_subcategories_column']['sid']."=".$sid);
// FTO Check EOF and databse error
if (!$result3) {
PN_DBMsgError($dbconn, __FILE__, __LINE__, "An error ocurred");
die();
}
while(!$result3->EOF) {
list($stitle) = $result3->fields;
$result3->MoveNext();
echo " / $stitle";
}
echo "<br><br></font>";
}
}
// and ending here -------------------------- function called 'showdownload()'
echo "</td></tr></table>";
CloseTable();
include("footer.php");
}
?>