<?php
// File: $Id: dl-viewdownload.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:
// ----------------------------------------------------------------------
/**
* viewdownload
*/
function viewdownload($cid, $min, $orderby, $show) {
global $admin, $perpage, $pntable, $ModName;
global $datetime, $transferfile, $dbconn, $modurl, $locale;
include("header.php");
$cattitle = downloads_CatNameFromCID($cid);
if (!authorised(0, 'Downloads::Category', "$cattitle::$cid", ACCESS_READ)) {
echo _DOWNLOADSACCESSNOAUTH;
include 'footer.php';
return;
}
if (!isset($min)) $min=0;
if (!isset($max)) $max=$min+$perpage;
if(isset($orderby)) {
$orderby = convertorderbyin($orderby);
} else {
$orderby = $pntable['downloads_downloads_column']['title'] . ' ASC';
}
if ($show!="") {
$perpage = $show;
} else {
$show=$perpage;
}
menu(1);
echo "<br>";
OpenTable();
$result=$dbconn->Execute("SELECT ".$pntable['downloads_categories_column']['title'].
" FROM ".$pntable['downloads_categories'].
" WHERE ".$pntable['downloads_categories_column']['cid']."=".$cid);
list($title) = $result->fields;
echo "<center><font class=\"pn-title\">"._CATEGORY.": $title</font></center><br>";
$carrytitle = $title;
$column = &$pntable['downloads_subcategories_column'];
$subresult=$dbconn->Execute("SELECT $column[sid], $column[title]
FROM $pntable[downloads_subcategories]
WHERE $column[cid]=$cid");
if (!$subresult->EOF) {
$scount = 0;
echo "<center><font class=\"pn-normal\">"._DLALSOAVAILABLE." $title "._SUBCATEGORIES.":</font></center><br>"
."<table align=\"center\" border=\"0\"><tr>";
// FTO Check EOF and databse error
if (!$subresult) {
PN_DBMsgError($dbconn, __FILE__, __LINE__, "An error ocurred");
die();
}
while(!$subresult->EOF) {
list($sid, $title) = $subresult->fields;
if (authorised(0, 'Downloads::Category', "$title::$sid", ACCESS_READ)) {
$result2 = $dbconn->Execute("SELECT count(*)
FROM $pntable[downloads_downloads]
WHERE {$pntable[downloads_downloads_column][sid]}=$sid");
list($numrows) = $result2->fields;
echo "<td><a class=\"pn-normal\" href=\"$modurl&req=viewsdownload&sid=$sid\">$title</a> ($numrows) </td>";
$scount++;
if ($scount==4) {
echo "</tr><tr>";
$scount = 0;
}
$subresult->MoveNext();
}
}
if ($count != 0) {
echo "</tr></table>";
} else {
echo "<td></td></tr></table>";
}
echo "<hr noshade size=\"1\">";
}
$orderbyTrans = convertorderbytrans($orderby);
echo "<center><font class=\"pn-normal\">"._SORTDOWNLOADSBY.": "
.""._TITLE." (<a class=\"pn-normal\" href=\"$modurl&req=viewdownload&cid=$cid&orderby=titleA\">A</a>\<a class=\"pn-normal\" href=\"$modurl&req=viewdownload&cid=$cid&orderby=titleD\">D</a>) "
.""._DATE." (<a class=\"pn-normal\" href=\"$modurl&req=viewdownload&cid=$cid&orderby=dateA\">A</a>\<a class=\"pn-normal\" href=\"$modurl&req=viewdownload&cid=$cid&orderby=dateD\">D</a>) "
.""._RATING." (<a class=\"pn-normal\" href=\"$modurl&req=viewdownload&cid=$cid&orderby=ratingA\">A</a>\<a class=\"pn-normal\" href=\"$modurl&req=viewdownload&cid=$cid&orderby=ratingD\">D</a>) "
.""._POPULARITY." (<a class=\"pn-normal\" href=\"$modurl&req=viewdownload&cid=$cid&orderby=hitsA\">A</a>\<a href=\"$modurl&req=viewdownload&cid=$cid&orderby=hitsD\">D</a>)"
."<br>"._RESSORTED.":$orderbyTrans</font></center><br><br>";
$column = &$pntable['downloads_downloads_column'];
$sql = "SELECT $column[lid], $column[title],
$column[description], $column[date], $column[hits],
$column[downloadratingsummary], $column[totalvotes],
$column[totalcomments], $column[filesize],
$column[version], $column[homepage]
FROM $pntable[downloads_downloads]
WHERE $column[cid]=$cid
AND $column[sid]=0 ORDER BY $orderby";
$result=$dbconn->SelectLimit($sql,$perpage,$min);
$fullcountresult=$dbconn->Execute("SELECT $column[lid], $column[title],
$column[description], $column[date],
$column[hits], $column[downloadratingsummary],
$column[totalvotes], $column[totalcomments]
FROM $pntable[downloads_downloads]
WHERE $column[cid]=$cid AND $column[sid]=0");
$totalselecteddownloads = $fullcountresult->PO_RecordCount();
echo "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"10\" border=\"0\"><tr><td><font class=\"pn-normal\">";
$x=0;
// FTO Check EOF and databse error
if (!$result) {
PN_DBMsgError($dbconn, __FILE__, __LINE__, "An error ocurred");
die();
}
while(!$result->EOF) {
list($lid, $title, $description, $time, $hits, $downloadratingsummary, $totalvotes, $totalcomments, $filesize, $version, $homepage)=$result->fields;
$result->MoveNext();
if (authorised(0, 'Downloads::Item', "$title:$cattitle:$lid", ACCESS_READ)) {
$downloadratingsummary = number_format($downloadratingsummary, $mainvotedecimal);
$title = stripslashes($title);
$description = stripslashes($description);
if (authorised(0, 'Downloads::Item', "$title:$cattitle:$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 "<a class=\"pn-normal\" href=\"$modurl&req=getit&lid=$lid\">$title</a>";
newdownloadgraphic($datetime, $time);
popgraphic($hits);
/* INSERT code for *editor review* here */
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', "$title:$cattitle:$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><br>";
$x++;
}
}
echo "</font>";
$orderby = convertorderbyout($orderby);
/* Calculates how many pages exist. Which page one should be on, etc... */
$downloadpagesint = ($totalselecteddownloads / $perpage);
$downloadpageremainder = ($totalselecteddownloads % $perpage);
if ($downloadpageremainder != 0) {
$downloadpages = ceil($downloadpagesint);
if ($totalselecteddownloads < $perpage) {
$downloadpageremainder = 0;
}
} else {
$downloadpages = $downloadpagesint;
}
/* Page Numbering */
if ($downloadpages!=1 && $downloadpages!=0) {
echo "<br><br>";
echo "<font class=\"pn-normal\">"._SELECTPAGE.":</font> ";
$prev=$min-$perpage;
if ($prev>=0) {
echo " [ <a class=\"pn-normal\" href=\"$modurl&req=viewdownload&cid=$cid&min=$prev&orderby=$orderby&show=$show\">";
echo " << "._PREVIOUS."</a> ] ";
}
$counter = 1;
$currentpage = ($max / $perpage);
while ($counter<=$downloadpages ) {
$cpage = $counter;
$mintemp = ($perpage * $counter) - $perpage;
if ($counter == $currentpage) {
echo "<font class=\"pn-normal\">$counter</font> ";
} else {
echo "<a class=\"pn-normal\" href=\"$modurl&req=viewdownload&cid=$cid&min=$mintemp&orderby=$orderby&show=$show\">$counter</a> ";
}
$counter++;
}
$next=$min+$perpage;
if ($x>=$perpage) {
echo " [ <a class=\"pn-normal\" href=\"$modurl&req=viewdownload&cid=$cid&min=$max&orderby=$orderby&show=$show\">";
echo " "._NEXT." >></a> ] ";
}
}
echo "</td></tr></table>";
CloseTable();
include("footer.php");
}
function viewsdownload($sid, $min, $orderby, $show) {
global $admin, $ModName, $pntable, $dbconn, $modurl;
include(WHERE_IS_PERSO."config.php");
include("header.php");
menu(1);
$cattitle = downloads_CatNameFromCID($sid);
if (!authorised(0, 'Downloads::Category', "$cattitle::$sid", ACCESS_READ)) {
echo _DOWNLOADSACCESSNOAUTH;
include 'footer.php';
return;
}
if (!isset($min)) $min=0;
if (!isset($max)) $max=$min+$perpage;
if(isset($orderby)) {
$orderby = convertorderbyin($orderby);
} else {
$orderby = "title ASC";
}
if ($show != "") {
$perpage = $show;
} else {
$show = $perpage;
}
echo "<br>";
OpenTable();
$column = &$pntable['downloads_subcategories_column'];
$result = $dbconn->Execute("SELECT $column[cid], $column[title]
FROM $pntable[downloads_subcategories]
WHERE $column[sid]=$sid");
list($cid, $stitle) = $result->fields;
$column = &$pntable['downloads_categories_column'];
$result2 = $dbconn->Execute("SELECT $column[cid], $column[title]
FROM $pntable[downloads_categories]
WHERE $column[cid]=$cid");
list($cid, $title) = $result2->fields;
echo "<center><font class=\"pn-title\"><a class=\"pn-normal\" href=\"$modurl\">"._MAIN."</a> / <a class=\"pn-normal\" href=\"$modurl&req=viewdownload&cid=$cid\">$title</a> / $stitle</center></font>";
$orderbyTrans = convertorderbytrans($orderby);
echo "<br><center><font class=\"pn-normal\">"._SORTDOWNLOADSBY.": "
.""._TITLE." (<a class=\"pn-normal\" href=\"$modurl&req=viewsdownload&sid=$sid&orderby=titleA\">A</a>\<a href=\"$modurl&req=viewsdownload&sid=$sid&orderby=titleD\">D</a>)"
." "._DATE." (<a class=\"pn-normal\" href=\"$modurl&req=viewsdownload&sid=$sid&orderby=dateA\">A</a>\<a href=\"$modurl&req=viewsdownload&sid=$sid&orderby=dateD\">D</a>)"
." "._RATING." (<a class=\"pn-normal\" href=\"$modurl&req=viewsdownload&sid=$sid&orderby=ratingA\">A</a>\<a href=\"$modurl&req=viewsdownload&sid=$sid&orderby=ratingD\">D</a>)"
." "._POPULARITY." (<a class=\"pn-normal\" href=\"$modurl&req=viewsdownload&sid=$sid&orderby=hitsA\">A</a>\<a href=\"$modurl&req=viewsdownload&sid=$sid&orderby=hitsD\">D</a>)"
."<br>"._RESSORTED.": $orderbyTrans</center></font><br><br>";
$column = &$pntable['downloads_downloads_column'];
$sql = "SELECT $column[lid], $column[url], $column[title],
$column[description], $column[date], $column[hits],
$column[downloadratingsummary], $column[totalvotes],
$column[totalcomments], $column[filesize],
$column[version], $column[homepage]
FROM $pntable[downloads_downloads]
WHERE $column[sid]=$sid
ORDER BY $orderby";
$result=$dbconn->SelectLimit($sql,$perpage,$min);
//
// Temporary Fixed eugeniobaldi 01/07/11
// ORDER BY {$column[$orderby]} LIMIT $min,$perpage");
$fullcountresult=$dbconn->Execute("SELECT $column[lid], $column[title],
$column[description], $column[date],
$column[hits], $column[downloadratingsummary],
$column[totalvotes], $column[totalcomments]
FROM $pntable[downloads_downloads]
WHERE $column[sid]=$sid");
$totalselecteddownloads = $fullcountresult->PO_RecordCount();
echo "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"10\" border=\"0\"><tr><td><font class=\"pn-normal\">";
$x=0;
// FTO Check EOF and databse error
if (!$result) {
PN_DBMsgError($dbconn, __FILE__, __LINE__, "An error ocurred");
die();
}
while(!$result->EOF) {
list($lid, $url, $title, $description, $time, $hits, $downloadratingsummary, $totalvotes, $totalcomments, $filesize, $version, $homepage) = $result->fields;
//jgm
$result->MoveNext();
if (authorised(0, 'Downloads::Item', "$title:$cattitle:$lid", ACCESS_READ)) {
$downloadratingsummary = number_format($downloadratingsummary, $mainvotedecimal);
$title = stripslashes($title); $description = stripslashes($description);
if (authorised(0, 'Downloads::Item', "$title:$cattitle:$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 "<a class=\"pn-normal\" href=\"$modurl&req=getit&lid=$lid\">$title</a>";
newdownloadgraphic($datetime, $time);
popgraphic($hits);
/* code for *editor review* insert here */
detecteditorial($lid, $transfertitle, 1);
echo "<br><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', "$title:$cattitle:$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=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><br>";
$x++;
}
}
echo "</font>";
$orderby = convertorderbyout($orderby);
/* Calculates how many pages exist. Which page one should be on, etc... */
$downloadpagesint = ($totalselecteddownloads / $perpage);
$downloadpageremainder = ($totalselecteddownloads % $perpage);
if ($downloadpageremainder != 0) {
$downloadpages = ceil($downloadpagesint);
if ($totalselecteddownloads < $perpage) {
$downloadpageremainder = 0;
}
} else {
$downloadpages = $downloadpagesint;
}
/* Page Numbering */
if ($downloadpages!=1 && $downloadpages!=0) {
echo "<br><br>"
."<font class=\"pn-normal\">"._SELECTPAGE.":</font> ";
$prev=$min-$perpage;
if ($prev>=0) {
echo " [ <a class=\"pn-normal\" href=\"$modurl&req=viewsdownload&sid=$sid&min=$prev&orderby=$orderby&show=$show\">"
." << "._PREVIOUS."</a> ] ";
}
$counter = 1;
$currentpage = ($max / $perpage);
while ($counter<=$downloadpages ) {
$cpage = $counter;
$mintemp = ($perpage * $counter) - $perpage;
if ($counter == $currentpage) {
echo "<font class=\"pn-normal\">$counter</font> ";
} else {
echo "<a class=\"pn-normal\" href=\"$modurl&req=viewsdownload&sid=$sid&min=$mintemp&orderby=$orderby&show=$show\">$counter</a> ";
}
$counter++;
}
$next=$min+$perpage;
if ($x>=$perpage) {
echo " [ <a class=\"pn-normal\" href=\"$modurl&req=viewsdownload&sid=$sid&min=$max&orderby=$orderby&show=$show\">"
." "._NEXT." >></a> ] ";
}
}
echo "</td></tr></table>";
CloseTable();
include("footer.php");
}
?>