<?PHP
/************************************************************************/
/* NPDS V : Net Portal Dynamic System !                                 */
/* ===========================                                          */
/*                                                                      */
/* Original Copyright (c) 2001 by Francisco Burzi (fburzi@ncc.org.ve)   */
/* http://phpnuke.org                                                   */
/*                                                                      */
/* This version name NPDS Copyright (c) 2001-2003 by Philippe Brunier   */
/*                                                                      */
/* New Links.php Module with SFROM extentions                           */
/*                                                                      */
/* 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.       */
/************************************************************************/
if (!eregi("modules.php", $PHP_SELF)) { die(); }

function NewLinksDate($selectdate) {
    global $ModPath, $ModStart, $links_DB;
    global $admin;
    global$pdst; $pdst="1";
    $dateDB = (date("d-M-Y", $selectdate));
    if ($language=="english") {
       $dateView = date("F d, Y", $selectdate);
    } else {
       $dateView = date("d-m-Y", $selectdate);
    }
    include("header.php");
    OpenTable();
    mainheader();
    $filen="modules/$ModPath/links.ban_01.php";
    if (file_exists($filen)) {include($filen);}
    $newlinkDB = Date("Y-m-d", $selectdate);
    $result = mysql_query("select lid FROM ".$links_DB."links_links WHERE date LIKE '%$newlinkDB%'");
    $totallinks = mysql_num_rows($result);
    $result=mysql_query("select lid, url, title, description, date, hits from ".$links_DB."links_links where date LIKE '%$newlinkDB%' order by title ASC");
    include_once("modules/$ModPath/links-view.php");
    CloseTable();
    include("footer.php");
}

function NewLinks($newlinkshowdays) {
    global $ModPath, $ModStart, $links_DB;
    global $pdst; $pdst="1";
    include("header.php");
    OpenTable();
    mainheader();
    echo "<BR><TABLE WIDTH=100% CELLSPACING=2 CELLPADDING=2 BORDER=0><TR><TD CLASS=\"HEADER\">\n";
    echo translate("New Links");
    echo "</TD></TR></TABLE>\n";
    echo "<BR>\n";
    $counter = 0;
    $allweeklinks = 0;
    while ($counter <= 7-1){
       $newlinkdayRaw = (time()-(86400 * $counter));
       $newlinkday = date("d-M-Y", $newlinkdayRaw);
       $newlinkView = date("F d, Y", $newlinkdayRaw);
       $newlinkDB = Date("Y-m-d", $newlinkdayRaw);
       $result = mysql_query("select * FROM ".$links_DB."links_links WHERE date LIKE '%$newlinkDB%'");
       $totallinks = mysql_num_rows($result);
       $counter++;
       $allweeklinks = $allweeklinks + $totallinks;
    }

    $counter = 0;
    while ($counter <=30-1){
        $newlinkdayRaw = (time()-(86400 * $counter));
        $newlinkDB = Date("Y-m-d", $newlinkdayRaw);
        $result = mysql_query("select * FROM ".$links_DB."links_links WHERE date LIKE '%$newlinkDB%'");
        $totallinks = mysql_num_rows($result);
        $allmonthlinks = $allmonthlinks + $totallinks;
        $counter++;
    }
    echo "<center>".translate("Total new links: Last week")." : <b>$allweeklinks</b> -::- ".translate("Last 30 days")." : <b>$allmonthlinks</b><BR><BR>
         ".translate("Show:")." [<a href=modules.php?ModStart=$ModStart&ModPath=$ModPath&op=NewLinks&newlinkshowdays=7 CLASS=\"NOIR\">".translate("week")."</a>, <a href=modules.php?ModStart=$ModStart&ModPath=$ModPath&op=NewLinks&newlinkshowdays=14 CLASS=\"NOIR\">2 ".translate("weeks")."</a>, <a href=modules.php?ModStart=$ModStart&ModPath=$ModPath&op=NewLinks&newlinkshowdays=30 CLASS=\"NOIR\">30 ".translate("days")."</a>]";
    if (!isset($newlinkshowdays)) {$newlinkshowdays = 7;}
    echo " -::- <b>".translate("Total new links for last")." $newlinkshowdays ".translate("days")." :</b><BR><BR>";
    $counter = 0;
    $allweeklinks = 0;
    while ($counter <= $newlinkshowdays-1) {
       $newlinkdayRaw = (time()-(86400 * $counter));
       $newlinkday = date("d-M-Y", $newlinkdayRaw);
       global $language;
       if ($language=="english") {
          $newlinkView = date("F d, Y", $newlinkdayRaw);
       } else {
          $newlinkView = date("d-m-Y", $newlinkdayRaw);
       }
       $newlinkDB = Date("Y-m-d", $newlinkdayRaw);
       $result = mysql_query("select * FROM ".$links_DB."links_links WHERE date LIKE '%$newlinkDB%'");
       $totallinks = mysql_num_rows($result);
       $counter++;
       $allweeklinks = $allweeklinks + $totallinks;
       if ($totallinks>0)
          echo "<LI><a href=modules.php?ModStart=$ModStart&ModPath=$ModPath&op=NewLinksDate&selectdate=$newlinkdayRaw CLASS=\"NOIR\">$newlinkView</a>&nbsp( $totallinks )";
    }
    $counter = 0;
    $allmonthlinks = 0;

    echo "</center>";
    CloseTable();
    include("footer.php");
}
?>