home *** CD-ROM | disk | FTP | other *** search
/ PC World 2005 April / PCWorld_2005-04_cd.bin / akce / web / unitednuke / unitednuke.exe / html / modules / Top / index.php
PHP Script  |  2004-01-10  |  13KB  |  293 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", $_SERVER['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. include("header.php");
  24.  
  25. if ($multilingual == 1) {
  26.     $queryalang = "WHERE (alanguage='$currentlang' OR alanguage='')"; /* top stories */
  27.     $querya1lang = "WHERE (alanguage='$currentlang' OR alanguage='') AND"; /* top stories */
  28.     $queryslang = "WHERE slanguage='$currentlang' "; /* top section articles */
  29.     $queryplang = "WHERE planguage='$currentlang' "; /* top polls */
  30.     $queryrlang = "WHERE rlanguage='$currentlang' "; /* top reviews */
  31. } else {
  32.     $queryalang = "";
  33.     $querya1lang = "WHERE";
  34.     $queryslang = "";
  35.     $queryplang = "";
  36.     $queryrlang = "";
  37. }
  38.  
  39. OpenTable();
  40. echo "<center><font class=\"title\"><b>"._TOPWELCOME." $sitename!</b></font></center>";
  41. CloseTable();
  42. echo "<br>\n\n";
  43. OpenTable();
  44.  
  45. /* Top 10 read stories */
  46. global $prefix, $db, $dbi;
  47. $result = $db->sql_query("SELECT sid, title, counter FROM ".$prefix."_stories $queryalang ORDER BY counter DESC LIMIT 0,$top");
  48. if ($db->sql_numrows($result) > 0) {
  49.     echo "<table border=\"0\" cellpadding=\"10\" width=\"100%\"><tr><td align=\"left\">\n"
  50.         ."<font class=\"option\"><b>$top "._READSTORIES."</b></font><br><br><font class=\"content\">\n";
  51.     $lugar=1;
  52.     while ($row = $db->sql_fetchrow($result)) {
  53.     $sid = intval($row['sid']);
  54.     $title = $row['title'];
  55.     $counter = $row['counter'];
  56.         if($counter>0) {
  57.             echo "<strong><big>·</big></strong> $lugar: <a href=\"modules.php?name=News&file=article&sid=$sid\">$title</a> - ($counter "._READS.")<br>\n";
  58.         $lugar++;
  59.     }
  60.     }
  61.     echo "</font></td></tr></table><br>\n";
  62. }
  63.  
  64. /* Top 10 most voted stories */
  65.  
  66. $result2 = $db->sql_query("SELECT sid, title, ratings FROM ".$prefix."_stories $querya1lang score!='0' ORDER BY ratings DESC LIMIT 0,$top");
  67. if ($db->sql_numrows($result2) > 0) {
  68.     echo "<table border=\"0\" cellpadding=\"10\" width=\"100%\"><tr><td align=\"left\">\n"
  69.         ."<font class=\"option\"><b>$top "._MOSTVOTEDSTORIES."</b></font><br><br><font class=\"content\">\n";
  70.     $lugar=1;
  71.     while ($row2 = $db->sql_fetchrow($result2)) {
  72.     $sid = intval($row2['sid']);
  73.     $title = $row2['title'];
  74.     $ratings = $row2['ratings'];
  75.         if($ratings>0) {
  76.             echo "<strong><big>·</big></strong> $lugar: <a href=\"modules.php?name=News&file=article&sid=$sid\">$title</a> - ($ratings "._LVOTES.")<br>\n";
  77.         $lugar++;
  78.     }
  79.     }
  80.     echo "</font></td></tr></table><br>\n";
  81. }
  82.  
  83. /* Top 10 best rated stories */
  84.  
  85. $result3 = $db->sql_query("SELECT sid, title, score, ratings FROM ".$prefix."_stories $querya1lang score!='0' ORDER BY ratings+score DESC LIMIT 0,$top");
  86. if ($db->sql_numrows($result3) > 0) {
  87.     echo "<table border=\"0\" cellpadding=\"10\" width=\"100%\"><tr><td align=\"left\">\n"
  88.         ."<font class=\"option\"><b>$top "._BESTRATEDSTORIES."</b></font><br><br><font class=\"content\">\n";
  89.     $lugar=1;
  90.     while ($row3 = $db->sql_fetchrow($result3)) {
  91.     $sid = intval($row3['sid']);
  92.     $title = $row3['title'];
  93.     $score = intval($row3['score']);
  94.     $ratings = intval($row3['ratings']);
  95.         if($score>0) {
  96.         $rate = substr($score / $ratings, 0, 4);
  97.             echo "<strong><big>·</big></strong> $lugar: <a href=\"modules.php?name=News&file=article&sid=$sid\">$title</a> - ($rate "._POINTS.")<br>\n";
  98.         $lugar++;
  99.     }
  100.     }
  101.     echo "</font></td></tr></table><br>\n";
  102. }
  103.  
  104. /* Top 10 commented stories */
  105.  
  106. if ($articlecomm == 1) {
  107.     $result4 = $db->sql_query("SELECT sid, title, comments FROM ".$prefix."_stories $queryalang ORDER BY comments DESC LIMIT 0,$top");
  108.     if ($db->sql_numrows($result4) > 0) {
  109.     echo "<table border=\"0\" cellpadding=\"10\" width=\"100%\"><tr><td align=\"left\">\n"
  110.         ."<font class=\"option\"><b>$top "._COMMENTEDSTORIES."</b></font><br><br><font class=\"content\">\n";
  111.     $lugar=1;
  112.     while ($row4 = $db->sql_fetchrow($result4)) {
  113.         $sid = intval($row4['sid']);
  114.     $title = $row4['title'];
  115.     $comments = $row4['comments'];
  116.         if($comments>0) {
  117.         echo "<strong><big>·</big></strong> $lugar: <a href=\"modules.php?name=News&file=article&sid=$sid\">$title</a> - ($comments "._TOPCOMMENTS.")<br>\n";
  118.         $lugar++;
  119.         }
  120.     }
  121.     echo "</font></td></tr></table><br>\n";
  122.     }
  123. }
  124.  
  125. /* Top 10 categories */
  126.  
  127. $result5 = $db->sql_query("SELECT catid, title, counter FROM ".$prefix."_stories_cat ORDER BY counter DESC LIMIT 0,$top");
  128. if ($db->sql_numrows($result5) > 0) {
  129.     echo "<table border=\"0\" cellpadding=\"10\" width=\"100%\"><tr><td align=\"left\">\n"
  130.     ."<font class=\"option\"><b>$top "._ACTIVECAT."</b></font><br><br><font class=\"content\">\n";
  131.     $lugar=1;
  132.     while ($row5 = $db->sql_fetchrow($result5)) {
  133.     $catid = intval($row5['catid']);
  134.     $title = $row5['title'];
  135.     $counter = $row5['counter'];
  136.     if($counter>0) {
  137.         echo "<strong><big>·</big></strong> $lugar: <a href=\"modules.php?name=News&file=categories&op=newindex&catid=$catid\">$title</a> - ($counter "._HITS.")<br>\n";
  138.         $lugar++;
  139.     }
  140.     }
  141.     echo "</font></td></tr></table><br>\n";
  142. }
  143.  
  144. /* Top 10 articles in special sections */
  145.  
  146. $result6 = $db->sql_query("SELECT artid, secid, title, content, counter FROM ".$prefix."_seccont $queryslang ORDER BY counter DESC LIMIT 0,$top");
  147. if ($db->sql_numrows($result6) > 0) {
  148.     echo "<table border=\"0\" cellpadding=\"10\" width=\"100%\"><tr><td align=\"left\">\n"
  149.     ."<font class=\"option\"><b>$top "._READSECTION."</b></font><br><br><font class=\"content\">\n";
  150.     $lugar=1;
  151.     while ($row6 = $db->sql_fetchrow($result6)) {
  152.     $artid = intval($row6['artid']);
  153.     $secid = intval($row6['secid']);
  154.     $title = $row6['title'];
  155.     $content = $row6['content'];
  156.     $counter = $row6['counter'];
  157.         echo "<strong><big>·</big></strong> $lugar: <a href=\"modules.php?name=Sections&op=viewarticle&artid=$artid\">$title</a> - ($counter "._READS.")<br>\n";
  158.     $lugar++;
  159.     }
  160.     echo "</font></td></tr></table><br>\n";
  161. }
  162.  
  163. /* Top 10 users submitters */
  164.  
  165. $result7 = $db->sql_query("SELECT username, counter FROM ".$user_prefix."_users WHERE counter > '0' ORDER BY counter DESC LIMIT 0,$top");
  166. if ($db->sql_numrows($result7) > 0) {
  167.     echo "<table border=\"0\" cellpadding=\"10\" width=\"100%\"><tr><td align=\"left\">\n"
  168.     ."<font class=\"option\"><b>$top "._NEWSSUBMITTERS."</b></font><br><br><font class=\"content\">\n";
  169.     $lugar=1;
  170.     while ($row7 = $db->sql_fetchrow($result7)) {
  171.     $uname = $row7['username'];
  172.     $counter = $row7['counter'];
  173.     if($counter>0) {
  174.         echo "<strong><big>·</big></strong> $lugar: <a href=\"modules.php?name=Your_Account&op=userinfo&username=$uname\">$uname</a> - ($counter "._NEWSSENT.")<br>\n";
  175.         $lugar++;
  176.     }
  177.     }
  178.     echo "</font></td></tr></table><br>\n";
  179. }
  180.  
  181. /* Top 10 Polls */
  182.  
  183. $result8 = $db->sql_query("select * from ".$prefix."_poll_desc $queryplang");
  184. if ($db->sql_numrows($result8)>0) {
  185.     echo "<table border=\"0\" cellpadding=\"10\" width=\"100%\"><tr><td align=\"left\">\n"
  186.     ."<font class=\"option\"><b>$top "._VOTEDPOLLS."</b></font><br><br><font class=\"content\">\n";
  187.     $lugar = 1;
  188.     $result9 = sql_query("SELECT pollID, pollTitle, timeStamp, voters FROM ".$prefix."_poll_desc $querylang order by voters DESC limit 0,$top", $dbi);
  189.     $counter = 0;
  190.     while($object = sql_fetch_object($result9, $dbi)) {
  191.     $resultArray[$counter] = array($object->pollID, $object->pollTitle, $object->timeStamp, $object->voters);
  192.     $counter++;
  193.     }
  194.     for ($count = 0; $count < count($resultArray); $count++) {
  195.     $id = $resultArray[$count][0];
  196.     $pollTitle = $resultArray[$count][1];
  197.     $voters = $resultArray[$count][3];
  198.     for($i = 0; $i < 12; $i++) {
  199.         $result10 = sql_query("SELECT optionCount FROM ".$prefix."_poll_data WHERE (pollID='$id') AND (voteID='$i')", $dbi);
  200.         $object = sql_fetch_object($result10, $dbi);
  201.         $optionCount = $object->optionCount;
  202.         $sum = (int)$sum+$optionCount;
  203.     }
  204.     echo "<strong><big>·</big></strong> $lugar: <a href=\"modules.php?name=Surveys&pollID=$id\">$pollTitle</a> - ($sum "._LVOTES.")<br>\n";
  205.     $lugar++;
  206.     $sum = 0;
  207.     }
  208.     echo "</font></td></tr></table><br>\n";
  209. }
  210.  
  211. /* Top 10 authors */
  212.  
  213. $result11 = $db->sql_query("SELECT aid, counter FROM ".$prefix."_authors ORDER BY counter DESC LIMIT 0,$top");
  214. if ($db->sql_numrows($result11) > 0) {
  215.     echo "<table border=\"0\" cellpadding=\"10\" width=\"100%\"><tr><td align=\"left\">\n"
  216.     ."<font class=\"option\"><b>$top "._MOSTACTIVEAUTHORS."</b></font><br><br><font class=\"content\">\n";
  217.     $lugar=1;
  218.     while ($row11 = $db->sql_fetchrow($result11)) {
  219.     $aid = $row11['aid'];
  220.     $counter = $row11['counter'];
  221.     if($counter>0) {
  222.         echo "<strong><big>·</big></strong> $lugar: <a href=\"modules.php?name=Search&query=&author=$aid\">$aid</a> - ($counter "._NEWSPUBLISHED.")<br>\n";
  223.         $lugar++;
  224.     }
  225.     }
  226.     echo "</font></td></tr></table><br>\n";
  227. }
  228.  
  229. /* Top 10 reviews */
  230.  
  231. $result12 = $db->sql_query("SELECT id, title, hits FROM ".$prefix."_reviews $queryrlang ORDER BY hits DESC LIMIT 0,$top");
  232. if ($db->sql_numrows($result12) > 0) {
  233.     echo "<table border=\"0\" cellpadding=\"10\" width=\"100%\"><tr><td align=\"left\">\n"
  234.     ."<font class=\"option\"><b>$top "._READREVIEWS."</b></font><br><br><font class=\"content\">\n";
  235.     $lugar=1;
  236.     while ($row12 = $db->sql_fetchrow($result12)) {
  237.     $id = intval($row12['id']);
  238.     $title = $row12['title'];
  239.     $hits = intval($row12['hits']);
  240.     if($hits>0) {
  241.         echo "<strong><big>·</big></strong> $lugar: <a href=\"modules.php?name=Reviews&op=showcontent&id=$id\">$title</a> - ($hits "._READS.")<br>\n";
  242.         $lugar++;
  243.     }
  244.     }
  245.     echo "</font></td></tr></table><br>\n";
  246. }
  247.  
  248. /* Top 10 downloads */
  249.  
  250. $result13 = $db->sql_query("SELECT lid, cid, title, hits FROM ".$prefix."_downloads_downloads ORDER BY hits DESC LIMIT 0,$top");
  251. if ($db->sql_numrows($result13) > 0) {
  252.     echo "<table border=\"0\" cellpadding=\"10\" width=\"100%\"><tr><td align=\"left\">\n"
  253.     ."<font class=\"option\"><b>$top "._DOWNLOADEDFILES."</b></font><br><br><font class=\"content\">\n";
  254.     $lugar=1;
  255.     while ($row13 = $db->sql_fetchrow($result13)) {
  256.     $lid = intval($row13['lid']);
  257.     $cid = intval($row13['cid']);
  258.     $title = $row13['title'];
  259.     $hits = intval($row13['hits']);
  260.     if($hits>0) {
  261.         $row_res = $db->sql_fetchrow($db->sql_query("SELECT title FROM ".$prefix."_downloads_categories WHERE cid='$cid'"));
  262.         $ctitle = $row_res['title'];
  263.         $utitle = ereg_replace(" ", "_", $title);
  264.         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";
  265.         $lugar++;
  266.     }
  267.     }
  268.     echo "</font></td></tr></table>\n\n";
  269. }
  270.  
  271. /* Top 10 Pages in Content */
  272.  
  273. $result14 = $db->sql_query("SELECT pid, title, counter FROM ".$prefix."_pages WHERE active='1' ORDER BY counter DESC LIMIT 0,$top");
  274. if ($db->sql_numrows($result14) > 0) {
  275.     echo "<table border=\"0\" cellpadding=\"10\" width=\"100%\"><tr><td align=\"left\">\n"
  276.     ."<font class=\"option\"><b>$top "._MOSTREADPAGES."</b></font><br><br><font class=\"content\">\n";
  277.     $lugar=1;
  278.     while ($row14 = $db->sql_fetchrow($result14)) {
  279.     $pid = intval($row14['pid']);
  280.     $title = $row14['title'];
  281.     $counter = $row14['counter'];
  282.     if($counter>0) {
  283.         echo "<strong><big>·</big></strong> $lugar: <a href=\"modules.php?name=Content&pa=showpage&pid=$pid\">$title</a> ($counter "._READS.")<br>\n";
  284.         $lugar++;
  285.     }
  286.     }
  287.     echo "</font></td></tr></table>\n\n";
  288. }
  289.  
  290. CloseTable();
  291. include("footer.php");
  292.  
  293. ?>