<?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-2004 by Philippe Brunier   */
/*                                                                      */
/* 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 (!function_exists("Mysql_Connexion")) {include ("mainfile.php");}

   include("header.php");
   OpenTable();
   echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\" border=\"0\"><tr><td class=\"HEADER\">\n";
   echo translate("Welcome to the TOP page for")." $sitename";
   echo "</td></tr></TABLE>\n";
   echo "<br />";
   settype($top,"integer");
   echo "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"2\" border=\"0\"><tr><td class=\"ONGL\">$top ".translate("most read stories")."</td><td class=\"ONGL\" align=\"right\">".translate("read:")."</td></tr>";
   $lugar=1;
   $xtab=news_aff("libre","order by counter DESC limit 0, ".$top*2,0,$top*2);
   $story_limit=0;
   while (($story_limit<$top) and ($story_limit<sizeof($xtab))) {
      $rowcolor = tablos();
      list($sid, $catid, $aid, $title, $time, $hometext, $bodytext, $comments, $counter) = $xtab[$story_limit];
      $story_limit++;
      if($counter>0) {
         echo "<tr $rowcolor><td>$lugar: <a href=\"article.php?sid=$sid\" class=\"NOIR\">".aff_langue($title)."</a></td><td align=\"right\">".wrh($counter)." ".translate("times")."<br /></td></tr>";
         $lugar++;
     }
   }
   echo "</table><br /><br />";

   // Top X commented stories
   echo "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"2\" border=\"0\"><tr><td class=\"ONGL\">$top ".translate("most commented stories")."</td><td class=\"ONGL\" align=\"right\">".translate("comments:")."</td></tr>";
   $lugar=1;
   $xtab=news_aff("libre","order by comments DESC  limit 0, ".$top*2,0,$top*2);
   $story_limit=0;
   while (($story_limit<$top) and ($story_limit<sizeof($xtab))) {
      $rowcolor = tablos();
      list($sid, $catid, $aid, $title, $time, $hometext, $bodytext, $comments) = $xtab[$story_limit];
      $story_limit++;
      if($comments>0) {
         echo "<tr $rowcolor><td>$lugar: <a href=\"article.php?sid=$sid\" class=\"NOIR\">".aff_langue($title)."</a></td><td align=\"right\">".wrh($comments)."<br /></td></tr>";
         $lugar++;
      }
   }
   echo "</table><br /><br />";

   // Top X categories
   $result = mysql_query("select catid, title, counter from stories_cat order by counter DESC limit 0,$top");
   echo "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"2\" border=\"0\"><tr><td class=\"ONGL\">$top ".translate("most active categories")."</td><td class=\"ONGL\" align=\"right\">".translate("Hits")."</td></tr>";
   $lugar=1;
   while (list($catid, $title, $counter) = mysql_fetch_row($result)) {
      $rowcolor = tablos();
      if ($counter>0) {
         echo "<tr $rowcolor><td>$lugar: <a href=\"index.php?op=newindex&amp;catid=$catid\" class=\"NOIR\">".aff_langue($title)."</a></td><td align=\"right\">".wrh($counter)."<br /></td></tr>";
         $lugar++;
      }
   }
   echo "</table><br /><br />";
   mysql_free_result($result);

   // Top X articles in special sections
   $result = mysql_query("select artid, secid, title, content, counter from seccont order by counter DESC limit 0,$top");
   echo "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"2\" border=\"0\"><tr><td class=\"ONGL\">$top ".translate("most read articles in special sections")."</td><td class=\"ONGL\" align=\"right\">".translate("read:")."</td></tr>";
   $lugar=1;
   while (list($artid, $secid, $title, $content, $counter) = mysql_fetch_row($result)) {
      $rowcolor = tablos();
      echo "<tr $rowcolor><td>$lugar: <a href=\"sections.php?op=viewarticle&amp;artid=$artid\" class=\"NOIR\">".aff_langue($title)."</a></td><td align=\"right\">".wrh($counter)." ".translate("times")."<br /></td></tr>";
      $lugar++;
   }
   echo "</table><br /><br />";
   mysql_free_result($result);

   // Top X users submitters
   $result = mysql_query("select uname, counter from users order by counter DESC limit 0,$top");
   echo "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"2\" border=\"0\"><tr><td class=\"ONGL\">$top ".translate("most active news submitters")."</td><td class=\"ONGL\" align=\"right\">".translate("sent news:")."</td></tr>";
   $lugar=1;
   while (list($uname, $counter) = mysql_fetch_row($result)) {
      $rowcolor = tablos();
      if ($counter>0) {
         echo "<tr $rowcolor><td>$lugar: <a href=\"user.php?op=userinfo&amp;uname=$uname\" class=\"NOIR\">$uname</a></td><td align=\"right\">".wrh($counter)."<br /></td></tr>";
         $lugar++;
      }
   }
   echo "</table><br /><br />";
   mysql_free_result($result);

   // Top X Polls
   $result = mysql_query("select pollID, pollTitle, voters from poll_desc order by voters DESC limit 0,$top");
   echo "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"2\" border=\"0\"><tr><td class=\"ONGL\">$top ".translate("most voted polls")."</td><td class=\"ONGL\" align=\"right\">".translate("votes:")."</td></tr>";
   $lugar=1;
   while (list($pollID, $pollTitle, $voters) = mysql_fetch_row($result)) {
      $rowcolor = tablos();
      if ($voters>0) {
         echo "<tr $rowcolor><td>$lugar: <a href=\"pollBooth.php?op=results&amp;pollID=$pollID\" class=\"NOIR\">".aff_langue($pollTitle)."</a></td><td align=\"right\">".wrh($voters)."<br /></td></tr>";
         $lugar++;
      }
   }
   echo "</table><br /><br />";
   mysql_free_result($result);

   // Top X authors
   $result = mysql_query("select aid, counter from authors order by counter DESC limit 0,$top");
   echo "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"2\" border=\"0\"><tr><td class=\"ONGL\">$top ".translate("most active authors")."</td><td class=\"ONGL\" align=\"right\">".translate("news published:")."</td></tr>";
   $lugar=1;
   while (list($aid, $counter) = mysql_fetch_row($result)) {
      $rowcolor = tablos();
      if ($counter>0) {
         echo "<tr $rowcolor><td>$lugar: <a href=\"search.php?query=&amp;author=$aid\" class=\"NOIR\">$aid</a></td><td align=\"right\">".wrh($counter)."<br /></td></tr>";
         $lugar++;
      }
   }
   echo "</table><br /><br />";
   mysql_free_result($result);

   // Top X reviews
   $result = mysql_query("select id, title, hits from reviews order by hits DESC limit 0,$top");
   echo "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"2\" border=\"0\"><tr><td class=\"ONGL\">$top ".translate("most read reviews")."</td><td class=\"ONGL\" align=\"right\">".translate("read:")."</td></tr>";
   $lugar=1;
   while (list($id, $title, $hits) = mysql_fetch_row($result)) {
      $rowcolor = tablos();
      if ($hits>0) {
         echo "<tr $rowcolor><td>$lugar: <a href=\"reviews.php?op=showcontent&amp;id=$id\" class=\"NOIR\">$title</a></td><td align=right>".wrh($hits)." ".translate("times")."<br /></td></tr>";
         $lugar++;
      }
   }
   echo "</table><br /><br />";
   mysql_free_result($result);

   // Top X downloads
   echo "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"2\" border=\"0\"><tr><td class=\"ONGL\">$top ".translate("most downloaded")."</td><td class=\"ONGL\" align=right>".translate("downloads")." :</td></tr>";
   echo topdownload_data("long","dcounter");
   echo "</table>";
   echo "<br /><br /><p align=\"center\"><a href=\"http://www.npds.org\" class=\"NOIR\">http://www.npds.org</a></p>";
   CloseTable();
   include("footer.php");
?>