Location: PHPKode > projects > ProNuke. Postnuke To Oracle > postnuke/html/modules/Downloads/dl-newdownloads.php
<?php
// File: $Id: dl-newdownloads.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:
// ----------------------------------------------------------------------

function NewDownloads($newdownloadshowdays) {
    global $pntable, $ModName, $dbconn, $modurl;
    include("header.php");
    menu(1);
    echo "<br>";

    if (!authorised(0, 'Downloads::', '::', ACCESS_READ)) {
        echo _DOWNLOADSACCESSNOAUTH;
        include 'footer.php';
        return;
    }

    OpenTable();
    echo "<center><font class=\"pn-title\">"._NEWDOWNLOADS."</font></center><br>";
    $allweekdownloads = 0;
    for ($counter = 0; $counter < 7; $counter++){
        $newdownloaddayRaw = (time()-(86400 * $counter));
        $newdownloadday = date("d-M-Y", $newdownloaddayRaw);
        $newdownloadView = date("F d, Y", $newdownloaddayRaw);
        $newdownloadDB = Date("Y-m-d", $newdownloaddayRaw);
        $result = $dbconn->Execute("SELECT count(*) FROM ".$pntable['downloads_downloads'].
        " WHERE ".$pntable['downloads_downloads_column']['date']." LIKE '%".$newdownloadDB."%'");
        list($totaldownloads) = $result->fields;
        $allweekdownloads = $allweekdownloads + $totaldownloads;
    }
    for ($counter = 0; $counter < 30; $counter++){
        $newdownloaddayRaw = (time()-(86400 * $counter));
        $newdownloadDB = Date("Y-m-d", $newdownloaddayRaw);
        $result = $dbconn->Execute("SELECT count(*) FROM ".$pntable['downloads_downloads'].
        " WHERE ".$pntable['downloads_downloads_column']['date']." LIKE '%".$newdownloadDB."%'");
        list($totaldownloads) = $result->fields;
        $allmonthdownloads = $allmonthdownloads + $totaldownloads;
    }
    echo "<center><font class=\"pn-title\">"._TOTALNEWDOWNLOADS.":</font> <font class=\"pn-normal\">"._LASTWEEK." - $allweekdownloads \ "._LAST30DAYS." - $allmonthdownloads</font><br>"
    ."<font class=\"pn-title\">"._SHOW.": <a class=\"pn-normal\" href=\"$modurl&amp;req=NewDownloads&amp;newdownloadshowdays=7\">"._1WEEK."</a> - <a class=\"pn-normal\" href=\"$modurl&amp;req=NewDownloads&amp;newdownloadshowdays=14\">"._2WEEKS."</a> - <a class=\"pn-normal\" href=\"$modurl&amp;req=NewDownloads&amp;newdownloadshowdays=30\">"._30DAYS."</a>"
    ."</font></center><br>";
    /* List Last VARIABLE Days of Downloads */
    if (!isset($newdownloadshowdays)) {
        $newdownloadshowdays = 7;
    }
    echo "<br><center><font class=\"pn-title\">"._DTOTALFORLAST." $newdownloadshowdays "._DAYS.":</font><br><br>";
    $allweekdownloads = 0;
    for ($counter = 0; $counter < $newdownloadshowdays; $counter++) {
        $newdownloaddayRaw = (time()-(86400 * $counter));
        $newdownloadday = date("d-M-Y", $newdownloaddayRaw);
        $newdownloadView = date("F d, Y", $newdownloaddayRaw);
        $newdownloadDB = Date("Y-m-d", $newdownloaddayRaw);
        $result = $dbconn->Execute("select count(*) FROM ".$pntable['downloads_downloads'].
        " WHERE ".$pntable['downloads_downloads_column']['date']." LIKE '%".$newdownloadDB."%'");
        list($totaldownloads) = $result->fields;
        $allweekdownloads = $allweekdownloads + $totaldownloads;
        echo "<strong><big>&middot;</big></strong> <a class=\"pn-normal\" href=\"$modurl&amp;req=NewDownloadsDate&amp;selectdate=$newdownloaddayRaw\">$newdownloadView</a>&nbsp<font class=\"pn-normal\">($totaldownloads)</font><br>";
    }
    $counter = 0;
    $allmonthdownloads = 0;
    echo "</center>";
    CloseTable();
    include("footer.php");
}

function NewDownloadsDate($selectdate) {
    global $pntable, $admin, $ModName, $dbconn, $modurl;
    $dateDB = (date("d-M-Y", $selectdate));
    $dateView = (date("F d, Y", $selectdate));
    include("header.php");
    menu(1);
    echo "<br>";

    if (!authorised(0, 'Downloads::', '::', ACCESS_READ)) {
        echo _DOWNLOADSACCESSNOAUTH;
        include 'footer.php';
        return;
    }

    OpenTable();
    $newdownloadDB = Date("Y-m-d", $selectdate);
    $result = $dbconn->Execute("SELECT count(*) FROM $pntable[downloads_downloads] WHERE {$pntable[downloads_downloads_column][date]} LIKE '%$newdownloadDB%'");
    list($totaldownloads) = $result->fields;
    echo "<font class=\"pn-title\">$dateView - $totaldownloads "._NEWDOWNLOADS."</font>"
    ."<table width=\"100%\" cellspacing=\"0\" cellpadding=\"10\" border=\"0\"><tr><td><font class=\"pn-normal\">";
    $column = &$pntable['downloads_downloads_column'];
    $result=$dbconn->Execute("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]
                            WHERE $column[date] LIKE '%$newdownloadDB%'
                            ORDER BY $column[title] ASC");
// FTO Check EOF and databse 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();

        $cattitle = downloads_CatNameFromCID($cid);
        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&amp;lid=$lid\"><img src=\"modules/$ModName/images/lwin.gif\" border=\"0\" alt=\""._EDIT."\"></a>&nbsp;&nbsp;";
            } else {
                echo "<img src=\"modules/$ModName/images/lwin.gif\" border=\"0\" alt=\"\">&nbsp;&nbsp;";
            }
            echo "<a class=\"pn-normal\" href=\"$modurl&amp;req=getit&amp;lid=$lid\">$title</a>";
            newdownloadgraphic($datetime, $time);
            popgraphic($hits);
            detecteditorial($lid, $transfertitle, 1);
            echo "<br><font class=\"pn-normal\">"._DESCRIPTION.": $description</font><br>";
            setlocale ("LC_TIME", "$locale");
            /* INSERT code for *editor review* here */
            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&amp;req=ratedownload&amp;lid=$lid&amp;ttitle=$transfertitle\">"._RATERESOURCE."</a>";
                echo " | ";
            }
            echo "<a class=\"pn-normal\" href=\"$modurl&amp;req=brokendownload&amp;lid=$lid\">"._REPORTBROKEN."</a>";
            echo " | <a class=\"pn-normal\" href=\"$modurl&amp;req=viewdownloaddetails&amp;lid=$lid&amp;ttitle=$transfertitle\">"._DETAILS."</a>";
            if (authorised(0, 'Downloads::Item', "$title:$cattitle:$lid", ACCESS_READM)) {
                if ($totalcomments != 0) {
                    echo " | <a class=\"pn-normal\" href=\"$modurl&amp;req=viewdownloadcomments&amp;lid=$lid&amp;ttitle=$transfertitle\">"._COMMENTS." ($totalcomments)</a>";
                }
            }
            $result2=$dbconn->Execute("SELECT {$pntable[downloads_categories_column][title]} FROM $pntable[downloads_categories] WHERE {$pntable[downloads_categories_column][cid]}=$cid");
            detecteditorial($lid, $transfertitle, 0);
            echo "<br>";
            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>";
        }
    }
    echo "</font></td></tr></table>";
    CloseTable();
    include("footer.php");
}
?>
Return current item: ProNuke. Postnuke To Oracle