home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2003 May / INTERNET103.ISO / pc / software / windows / building / php_nuke / html / modules / top / index.php
Encoding:
PHP Script  |  2002-09-16  |  11.6 KB  |  257 lines

  1. <?php
  2.  
  3. /************************************************************************/
  4. /* PHP-NUKE: Web Portal System                                          */
  5. /* ===========================                                          */
  6. /*                                                                      */
  7. /* Copyright (c) 2002 by Francisco Burzi                                */
  8. /* http://phpnuke.org                                                   */
  9. /*                                                                      */
  10. /* This program is free software. You can redistribute it and/or modify */
  11. /* it under the terms of the GNU General Public License as published by */
  12. /* the Free Software Foundation; either version 2 of the License.       */
  13. /************************************************************************/
  14.  
  15. if (!eregi("modules.php", $PHP_SELF)) {
  16.     die ("You can't access this file directly...");
  17. }
  18.  
  19. require_once("mainfile.php");
  20. $module_name = basename(dirname(__FILE__));
  21. get_lang($module_name);
  22.  
  23. //$pagetitle = "- "._TOP."";
  24. include("header.php");
  25.  
  26. if ($multilingual == 1) {
  27.     $queryalang = "WHERE (alanguage='$currentlang' OR alanguage='')"; /* top stories */
  28.     $querya1lang = "WHERE (alanguage='$currentlang' OR alanguage='') AND"; /* top stories */
  29.     $queryslang = "WHERE slanguage='$currentlang' "; /* top section articles */
  30.     $queryplang = "WHERE planguage='$currentlang' "; /* top polls */
  31.     $queryrlang = "WHERE rlanguage='$currentlang' "; /* top reviews */
  32. } else {
  33.     $queryalang = "";
  34.     $querya1lang = "WHERE";
  35.     $queryslang = "";
  36.     $queryplang = "";
  37.     $queryrlang = "";
  38. }
  39.  
  40. OpenTable();
  41. echo "<center><font class=\"title\"><b>"._TOPWELCOME." $sitename!</b></font></center>";
  42. CloseTable();
  43. echo "<br>\n\n";
  44. OpenTable();
  45.  
  46. /* Top 10 read stories */
  47.  
  48. $result = sql_query("select sid, title, counter from ".$prefix."_stories $queryalang order by counter DESC limit 0,$top", $dbi);
  49. if (sql_num_rows($result, $dbi)>0) {
  50.     echo "<table border=\"0\" cellpadding=\"10\" width=\"100%\"><tr><td align=\"left\">\n"
  51.         ."<font class=\"option\"><b>$top "._READSTORIES."</b></font><br><br><font class=\"content\">\n";
  52.     $lugar=1;
  53.     while(list($sid, $title, $counter) = sql_fetch_row($result, $dbi)) {
  54.         if($counter>0) {
  55.             echo "<strong><big>·</big></strong> $lugar: <a href=\"modules.php?name=News&file=article&sid=$sid\">$title</a> - ($counter "._READS.")<br>\n";
  56.         $lugar++;
  57.     }
  58.     }
  59.     echo "</font></td></tr></table><br>\n";
  60. }
  61.  
  62. /* Top 10 most voted stories */
  63.  
  64. $result = sql_query("select sid, title, ratings from ".$prefix."_stories $querya1lang score!=0 order by ratings DESC limit 0,$top", $dbi);
  65. if (sql_num_rows($result, $dbi)>0) {
  66.     echo "<table border=\"0\" cellpadding=\"10\" width=\"100%\"><tr><td align=\"left\">\n"
  67.         ."<font class=\"option\"><b>$top "._MOSTVOTEDSTORIES."</b></font><br><br><font class=\"content\">\n";
  68.     $lugar=1;
  69.     while(list($sid, $title, $ratings) = sql_fetch_row($result, $dbi)) {
  70.         if($ratings>0) {
  71.             echo "<strong><big>·</big></strong> $lugar: <a href=\"modules.php?name=News&file=article&sid=$sid\">$title</a> - ($ratings "._LVOTES.")<br>\n";
  72.         $lugar++;
  73.     }
  74.     }
  75.     echo "</font></td></tr></table><br>\n";
  76. }
  77.  
  78. /* Top 10 best rated stories */
  79.  
  80. $result = sql_query("select sid, title, score, ratings from ".$prefix."_stories $querya1lang score!=0 order by ratings+score DESC limit 0,$top", $dbi);
  81. if (sql_num_rows($result, $dbi)>0) {
  82.     echo "<table border=\"0\" cellpadding=\"10\" width=\"100%\"><tr><td align=\"left\">\n"
  83.         ."<font class=\"option\"><b>$top "._BESTRATEDSTORIES."</b></font><br><br><font class=\"content\">\n";
  84.     $lugar=1;
  85.     while(list($sid, $title, $score, $ratings) = sql_fetch_row($result, $dbi)) {
  86.         if($score>0) {
  87.         $rate = substr($score / $ratings, 0, 4);
  88.             echo "<strong><big>·</big></strong> $lugar: <a href=\"modules.php?name=News&file=article&sid=$sid\">$title</a> - ($rate "._POINTS.")<br>\n";
  89.         $lugar++;
  90.     }
  91.     }
  92.     echo "</font></td></tr></table><br>\n";
  93. }
  94.  
  95. /* Top 10 commented stories */
  96.  
  97. $result = sql_query("select sid, title, comments from ".$prefix."_stories $queryalang order by comments DESC limit 0,$top", $dbi);
  98. if (sql_num_rows($result, $dbi)>0) {
  99.     echo "<table border=\"0\" cellpadding=\"10\" width=\"100%\"><tr><td align=\"left\">\n"
  100.     ."<font class=\"option\"><b>$top "._COMMENTEDSTORIES."</b></font><br><br><font class=\"content\">\n";
  101.     $lugar=1;
  102.     while(list($sid, $title, $comments) = sql_fetch_row($result, $dbi)) {
  103.     if($comments>0) {
  104.         echo "<strong><big>·</big></strong> $lugar: <a href=\"modules.php?name=News&file=article&sid=$sid\">$title</a> - ($comments "._COMMENTS.")<br>\n";
  105.         $lugar++;
  106.     }
  107.     }
  108.     echo "</font></td></tr></table><br>\n";
  109. }
  110.  
  111. /* Top 10 categories */
  112.  
  113. $result = sql_query("select catid, title, counter from ".$prefix."_stories_cat order by counter DESC limit 0,$top", $dbi);
  114. if (sql_num_rows($result, $dbi)>0) {
  115.     echo "<table border=\"0\" cellpadding=\"10\" width=\"100%\"><tr><td align=\"left\">\n"
  116.     ."<font class=\"option\"><b>$top "._ACTIVECAT."</b></font><br><br><font class=\"content\">\n";
  117.     $lugar=1;
  118.     while(list($catid, $title, $counter) = sql_fetch_row($result, $dbi)) {
  119.     if($counter>0) {
  120.         echo "<strong><big>·</big></strong> $lugar: <a href=\"modules.php?name=News&file=categories&op=newindex&catid=$catid\">$title</a> - ($counter "._HITS.")<br>\n";
  121.         $lugar++;
  122.     }
  123.     }
  124.     echo "</font></td></tr></table><br>\n";
  125. }
  126.  
  127. /* Top 10 articles in special sections */
  128.  
  129. $result = sql_query("select artid, secid, title, content, counter from ".$prefix."_seccont $queryslang order by counter DESC limit 0,$top", $dbi);
  130. if (sql_num_rows($result, $dbi)>0) {
  131.     echo "<table border=\"0\" cellpadding=\"10\" width=\"100%\"><tr><td align=\"left\">\n"
  132.     ."<font class=\"option\"><b>$top "._READSECTION."</b></font><br><br><font class=\"content\">\n";
  133.     $lugar=1;
  134.     while(list($artid, $secid, $title, $content, $counter) = sql_fetch_row($result, $dbi)) {
  135.         echo "<strong><big>·</big></strong> $lugar: <a href=\"modules.php?name=Sections&op=viewarticle&artid=$artid\">$title</a> - ($counter "._READS.")<br>\n";
  136.     $lugar++;
  137.     }
  138.     echo "</font></td></tr></table><br>\n";
  139. }
  140.  
  141. /* Top 10 users submitters */
  142.  
  143. $result = sql_query("select uname, counter from ".$user_prefix."_users where counter > '0' order by counter DESC limit 0,$top", $dbi);
  144. if (sql_num_rows($result, $dbi)>0) {
  145.     echo "<table border=\"0\" cellpadding=\"10\" width=\"100%\"><tr><td align=\"left\">\n"
  146.     ."<font class=\"option\"><b>$top "._NEWSSUBMITTERS."</b></font><br><br><font class=\"content\">\n";
  147.     $lugar=1;
  148.     while(list($uname, $counter) = sql_fetch_row($result, $dbi)) {
  149.     if($counter>0) {
  150.         echo "<strong><big>·</big></strong> $lugar: <a href=\"modules.php?name=Your_Account&op=userinfo&uname=$uname\">$uname</a> - ($counter "._NEWSSENT.")<br>\n";
  151.         $lugar++;
  152.     }
  153.     }
  154.     echo "</font></td></tr></table><br>\n";
  155. }
  156.  
  157. /* Top 10 Polls */
  158.  
  159. $result = sql_query("select * from ".$prefix."_poll_desc $queryplang", $dbi);
  160. if (sql_num_rows($result, $dbi)>0) {
  161.     echo "<table border=\"0\" cellpadding=\"10\" width=\"100%\"><tr><td align=\"left\">\n"
  162.     ."<font class=\"option\"><b>$top "._VOTEDPOLLS."</b></font><br><br><font class=\"content\">\n";
  163.     $lugar = 1;
  164.     $result = sql_query("SELECT pollID, pollTitle, timeStamp, voters FROM ".$prefix."_poll_desc $querylang order by voters DESC limit 0,$top", $dbi);
  165.     $counter = 0;
  166.     while($object = sql_fetch_object($result, $dbi)) {
  167.     $resultArray[$counter] = array($object->pollID, $object->pollTitle, $object->timeStamp, $object->voters);
  168.     $counter++;
  169.     }
  170.     for ($count = 0; $count < count($resultArray); $count++) {
  171.     $id = $resultArray[$count][0];
  172.     $pollTitle = $resultArray[$count][1];
  173.     $voters = $resultArray[$count][3];
  174.     for($i = 0; $i < 12; $i++) {
  175.         $result = sql_query("SELECT optionCount FROM ".$prefix."_poll_data WHERE (pollID=$id) AND (voteID=$i)", $dbi);
  176.         $object = sql_fetch_object($result, $dbi);
  177.         $optionCount = $object->optionCount;
  178.         $sum = (int)$sum+$optionCount;
  179.     }
  180.     echo "<strong><big>·</big></strong> $lugar: <a href=\"modules.php?name=Surveys&pollID=$id\">$pollTitle</a> - ($sum "._LVOTES.")<br>\n";
  181.     $lugar++;
  182.     $sum = 0;
  183.     }
  184.     echo "</font></td></tr></table><br>\n";
  185. }
  186.  
  187. /* Top 10 authors */
  188.  
  189. $result = sql_query("select aid, counter from ".$prefix."_authors order by counter DESC limit 0,$top", $dbi);
  190. if (sql_num_rows($result, $dbi)>0) {
  191.     echo "<table border=\"0\" cellpadding=\"10\" width=\"100%\"><tr><td align=\"left\">\n"
  192.     ."<font class=\"option\"><b>$top "._MOSTACTIVEAUTHORS."</b></font><br><br><font class=\"content\">\n";
  193.     $lugar=1;
  194.     while(list($aid, $counter) = sql_fetch_row($result, $dbi)) {
  195.     if($counter>0) {
  196.         echo "<strong><big>·</big></strong> $lugar: <a href=\"modules.php?name=Search&query=&author=$aid\">$aid</a> - ($counter "._NEWSPUBLISHED.")<br>\n";
  197.         $lugar++;
  198.     }
  199.     }
  200.     echo "</font></td></tr></table><br>\n";
  201. }
  202.  
  203. /* Top 10 reviews */
  204.  
  205. $result = sql_query("select id, title, hits from ".$prefix."_reviews $queryrlang order by hits DESC limit 0,$top", $dbi);
  206. if (sql_num_rows($result, $dbi)>0) {
  207.     echo "<table border=\"0\" cellpadding=\"10\" width=\"100%\"><tr><td align=\"left\">\n"
  208.     ."<font class=\"option\"><b>$top "._READREVIEWS."</b></font><br><br><font class=\"content\">\n";
  209.     $lugar=1;
  210.     while(list($id, $title, $hits) = sql_fetch_row($result, $dbi)) {
  211.     if($hits>0) {
  212.         echo "<strong><big>·</big></strong> $lugar: <a href=\"modules.php?name=Reviews&op=showcontent&id=$id\">$title</a> - ($hits "._READS.")<br>\n";
  213.         $lugar++;
  214.     }
  215.     }
  216.     echo "</font></td></tr></table><br>\n";
  217. }
  218.  
  219. /* Top 10 downloads */
  220.  
  221. $result = sql_query("select lid, cid, title, hits from ".$prefix."_downloads_downloads order by hits DESC limit 0,$top", $dbi);
  222. if (sql_num_rows($result, $dbi)>0) {
  223.     echo "<table border=\"0\" cellpadding=\"10\" width=\"100%\"><tr><td align=\"left\">\n"
  224.     ."<font class=\"option\"><b>$top "._DOWNLOADEDFILES."</b></font><br><br><font class=\"content\">\n";
  225.     $lugar=1;
  226.     while(list($lid, $cid, $title, $hits) = sql_fetch_row($result, $dbi)) {
  227.     if($hits>0) {
  228.         $res = sql_query("select title from ".$prefix."_downloads_categories where cid='$cid'", $dbi);
  229.         list($ctitle) = sql_fetch_row($res, $dbi);
  230.         $utitle = ereg_replace(" ", "_", $title);
  231.         echo "<strong><big>·</big></strong> $lugar: <a href=\"modules.php?name=Downloads&d_op=viewdownloaddetails&lid=$lid&ttitle=$utitle\">$title</a> ("._CATEGORY.": $ctitle) - ($hits "._LDOWNLOADS.")<br>\n";
  232.         $lugar++;
  233.     }
  234.     }
  235.     echo "</font></td></tr></table>\n\n";
  236. }
  237.  
  238. /* Top 10 Pages in Content */
  239.  
  240. $result = sql_query("select pid, title, counter from ".$prefix."_pages where active='1' order by counter DESC limit 0,$top", $dbi);
  241. if (sql_num_rows($result, $dbi)>0) {
  242.     echo "<table border=\"0\" cellpadding=\"10\" width=\"100%\"><tr><td align=\"left\">\n"
  243.     ."<font class=\"option\"><b>$top "._MOSTREADPAGES."</b></font><br><br><font class=\"content\">\n";
  244.     $lugar=1;
  245.     while(list($pid, $title, $counter) = sql_fetch_row($result, $dbi)) {
  246.     if($counter>0) {
  247.         echo "<strong><big>·</big></strong> $lugar: <a href=\"modules.php?name=Content&pa=showpage&pid=$pid\">$title</a> ($counter "._READS.")<br>\n";
  248.         $lugar++;
  249.     }
  250.     }
  251.     echo "</font></td></tr></table>\n\n";
  252. }
  253.  
  254. CloseTable();
  255. include("footer.php");
  256.  
  257. ?>