home *** CD-ROM | disk | FTP | other *** search
/ PC World 2005 April / PCWorld_2005-04_cd.bin / akce / web / unitednuke / unitednuke.exe / html / modules / Downloads / index.php < prev    next >
PHP Script  |  2004-05-06  |  119KB  |  2,451 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. /* Based on Journey Links Hack                                          */
  11. /* Copyright (c) 2000 by James Knickelbein                              */
  12. /* Journey Milwaukee (http://www.journeymilwaukee.com)                  */
  13. /*                                                                      */
  14. /* This program is free software. You can redistribute it and/or modify */
  15. /* it under the terms of the GNU General Public License as published by */
  16. /* the Free Software Foundation; either version 2 of the License.       */
  17. /************************************************************************/
  18.  
  19. if (!eregi("modules.php", $_SERVER['PHP_SELF'])) {
  20.     die ("You can't access this file directly...");
  21. }
  22.  
  23. require_once("mainfile.php");
  24. $module_name = basename(dirname(__FILE__));
  25. get_lang($module_name);
  26. $pagetitle = "- "._UDOWNLOADS."";
  27. require_once("modules/$module_name/d_config.php");
  28. $index = 1;
  29.  
  30. // ALTERED BY PALADIN - 170102 - Start
  31. function getparent($parentid,$title) {
  32.     global $prefix, $db;
  33.     $parentid = intval($parentid);
  34.     $row = $db->sql_fetchrow($db->sql_query("SELECT cid, title, parentid FROM ".$prefix."_downloads_categories WHERE cid='$parentid'"));
  35.     $cid = intval($row['cid']);
  36.     $ptitle = $row['title'];
  37.     $pparentid = $row['parentid'];
  38.     if ($ptitle!="") $title=$ptitle."/".$title;
  39.     if ($pparentid!=0) {
  40.     $title=getparent($pparentid,$ptitle);
  41.     }
  42.     return $title;
  43. }
  44.  
  45. function getparentlink($parentid,$title) {
  46.     global $prefix, $db, $module_name;
  47.     $parentid = intval($parentid);
  48.     $row = $db->sql_fetchrow($db->sql_query("SELECT cid, title, parentid FROM ".$prefix."_downloads_categories WHERE cid='$parentid'"));
  49.     $cid = intval($row['cid']);
  50.     $ptitle = $row['title'];
  51.     $pparentid = $row['parentid'];
  52.     if ($ptitle!="") $title="<a href=modules.php?name=$module_name&d_op=viewdownload&cid=$cid>$ptitle</a>/".$title;
  53.     if ($pparentid!=0) {
  54.         $title=getparentlink($pparentid,$ptitle);
  55.     }
  56.     return $title;
  57. }
  58. // ALTERED BY PALADIN - 170102 - End
  59.  
  60. function menu($maindownload) {
  61.     global $prefix, $user_adddownload, $module_name;
  62.     OpenTable();
  63.     $ThemeSel = get_theme();
  64.     if (file_exists("themes/$ThemeSel/images/down-logo.gif")) {
  65.     echo "<br><center><a href=\"modules.php?name=$module_name\"><img src=\"themes/$ThemeSel/images/down-logo.gif\" border=\"0\" alt=\"\"></a><br><br>";
  66.     } else {
  67.     echo "<br><center><a href=\"modules.php?name=$module_name\"><img src=\"modules/$module_name/images/down-logo.gif\" border=\"0\" alt=\"\"></a><br><br>";
  68.     }
  69.     echo "<form action=\"modules.php?name=$module_name&d_op=search&query=$query\" method=\"post\">"
  70.     ."<font class=\"content\"><input type=\"text\" size=\"25\" name=\"query\"> <input type=\"submit\" value=\""._SEARCHF."\"></font>"
  71.     ."</form>";
  72.     echo "<font class=\"content\">[ ";
  73.     if ($maindownload>0) {
  74.     echo "<a href=\"modules.php?name=$module_name\">"._DOWNLOADSMAIN."</a> | ";
  75.     }
  76.     if ($user_adddownload == 1) {
  77.     echo "<a href=\"modules.php?name=$module_name&d_op=AddDownload\">"._ADDDOWNLOAD."</a>"
  78.         ." | ";
  79.     }
  80.     echo "<a href=\"modules.php?name=$module_name&d_op=NewDownloads\">"._NEW."</a>"
  81.     ." | <a href=\"modules.php?name=$module_name&d_op=MostPopular\">"._POPULAR."</a>"
  82.     ." | <a href=\"modules.php?name=$module_name&d_op=TopRated\">"._TOPRATED."</a> ]"
  83.     ."</font></center>";
  84.     CloseTable();
  85. }
  86.  
  87. function SearchForm() {
  88.     global $module_name;
  89.     echo "<form action=\"modules.php?name=$module_name\" method=\"post\">"
  90.     ."<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">"
  91.     ."<tr><td><font class=\"content\"><imput type=\"hidden\" name=\"d_op\" value=\"search\"><input type=\"text\" size=\"25\" name=\"query\"> <input type=\"submit\" value=\""._SEARCHF."\"></td></tr>"
  92.     ."</table>"
  93.     ."</form>";
  94. }
  95.  
  96. function downloadinfomenu($lid, $ttitle) {
  97.     global $module_name, $user;
  98.     echo "<br><font class=\"content\">[ "
  99.     ."<a href=\"modules.php?name=$module_name&d_op=viewdownloadcomments&lid=$lid&ttitle=$ttitle\">"._DOWNLOADCOMMENTS."</a>"
  100.     ." | <a href=\"modules.php?name=$module_name&d_op=viewdownloaddetails&lid=$lid&ttitle=$ttitle\">"._ADDITIONALDET."</a>"
  101.     ." | <a href=\"modules.php?name=$module_name&d_op=viewdownloadeditorial&lid=$lid&ttitle=$ttitle\">"._EDITORREVIEW."</a>"
  102.     ." | <a href=\"modules.php?name=$module_name&d_op=modifydownloadrequest&lid=$lid\">"._MODIFY."</a>";
  103.     if (is_user($user)) {
  104.     echo " | <a href=\"modules.php?name=$module_name&d_op=brokendownload&lid=$lid\">"._REPORTBROKEN."</a>";
  105.     }
  106.     echo " ]</font>";
  107. }
  108.  
  109. function index() {
  110.     global $prefix, $db, $show_links_num, $module_name;
  111.     include("header.php");
  112.     $maindownload = 0;
  113.     menu($maindownload);
  114.     echo "<br>";
  115.     OpenTable();
  116.     echo "<center><font class=\"title\"><b>"._DOWNLOADSMAINCAT."</b></font></center><br>";
  117.     echo "<table border=\"0\" cellspacing=\"10\" cellpadding=\"0\" align=\"center\"><tr>";
  118.     $result = $db->sql_query("SELECT cid, title, cdescription FROM ".$prefix."_downloads_categories WHERE parentid='0' ORDER BY title");
  119.     $count = 0;
  120.     while ($row = $db->sql_fetchrow($result)) {
  121.     $cid = intval($row['cid']);
  122.     $title = $row['title'];
  123.     $cdescription = stripslashes($row['cdescription']);
  124.     if ($show_links_num == 1) {
  125.         $cnumrows = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_downloads_downloads WHERE cid='$cid'"));
  126.         $cnumm = "($cnumrows)";
  127.     } else {
  128.         $cnumm = "";
  129.     }
  130.     echo "<td><font class=\"option\"><strong><big>·</big></strong> <a href=\"modules.php?name=$module_name&d_op=viewdownload&cid=$cid\"><b>$title</b></a>$cnumm</font>";
  131.     categorynewdownloadgraphic($cid);
  132.     if ($cdescription) {
  133.         echo "<br><font class=\"content\">$cdescription</font><br>";
  134.     } else {
  135.         echo "<br>";
  136.     }
  137.     $result2 = $db->sql_query("SELECT cid, title FROM ".$prefix."_downloads_categories WHERE parentid='$cid' ORDER BY title LIMIT 0,3");
  138.     $space = 0;
  139.     while ($row2 = $db->sql_fetchrow($result2)) {
  140.         $cid = $row2['cid'];
  141.         $stitle = $row2['title'];
  142.             if ($space>0) {
  143.         echo ", ";
  144.         }
  145.             if ($show_links_num == 1) {
  146.             $cnumrows2 = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_downloads_downloads WHERE cid='$cid'"));
  147.         $cnum = " ($cnumrows2)";
  148.         } else {
  149.         $cnumrows2 = "";
  150.         }
  151.         echo "<font class=\"content\"><a href=\"modules.php?name=$module_name&d_op=viewdownload&cid=$cid\">$stitle</a>$cnum</font>";
  152.         $space++;
  153.     }
  154.     if ($count<1) {
  155.         echo "</td><td>    </td>";
  156.         $dum = 1;
  157.     }
  158.     $count++;
  159.     if ($count==2) {
  160.         echo "</td></tr><tr>";
  161.         $count = 0;
  162.         $dum = 0;
  163.     }
  164.     }
  165.     if ($dum == 1) {
  166.     echo "</tr></table>";
  167.     } elseif ($dum == 0) {
  168.     echo "<td></td></tr></table>";
  169.     }
  170.     $numrows = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_downloads_downloads"));
  171.     $catnum = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_downloads_categories"));
  172.     echo "<center><font class=\"content\">"._THEREARE." <b>$numrows</b> "._DOWNLOADS." "._AND." <b>$catnum</b> "._CATEGORIES." "._INDB."</font></center>";
  173.     CloseTable();
  174.     include("footer.php");
  175. }
  176.  
  177. function AddDownload() {
  178.     global $prefix, $db, $cookie, $user, $downloads_anonadddownloadlock, $module_name;
  179.     include("header.php");
  180.     $maindownload = 1;
  181.     menu(1);
  182.     echo "<br>";
  183.     OpenTable();
  184.     echo "<center><font class=\"title\"><b>"._ADDADOWNLOAD."</b></font></center><br><br>";
  185.     if (is_user($user) || $downloads_anonadddownloadlock != 1) {
  186.         echo "<b>"._INSTRUCTIONS.":</b><br>"
  187.         ."<strong><big>·</big></strong> "._DSUBMITONCE."<br>"
  188.         ."<strong><big>·</big></strong> "._DPOSTPENDING."<br>"
  189.         ."<strong><big>·</big></strong> "._USERANDIP."<br>";
  190.         echo "<form method=\"post\" action=\"modules.php?name=$module_name&d_op=Add\">"
  191.             .""._DOWNLOADNAME.": <input type=\"text\" name=\"title\" size=\"40\" maxlength=\"100\"><br>"
  192.             .""._FILEURL.": <input type=\"text\" name=\"url\" size=\"50\" maxlength=\"100\" value=\"http://\"><br>";
  193.         echo ""._CATEGORY.": <select name=\"cat\">";
  194.         $result = $db->sql_query("SELECT cid, title, parentid FROM ".$prefix."_downloads_categories ORDER BY parentid,title");
  195.         while ($row = $db->sql_fetchrow($result)) {
  196.         $cid2 = intval($row['cid']);
  197.         $ctitle2 = $row['title'];
  198.         $parentid2 = $row['parentid'];
  199.             if ($parentid2!=0) $ctitle2=getparent($parentid2,$ctitle2);
  200.             echo "<option value=\"$cid2\">$ctitle2</option>";
  201.         }
  202.         echo "</select><br><br>"
  203.             .""._LDESCRIPTION."<br><textarea name=\"description\" cols=\"60\" rows=\"8\"></textarea><br><br>"
  204.             .""._AUTHORNAME.": <input type=\"text\" name=\"auth_name\" size=\"30\" maxlength=\"60\"><br>"
  205.             .""._AUTHOREMAIL.": <input type=\"text\" name=\"email\" size=\"30\" maxlength=\"60\"><br>"
  206.         .""._FILESIZE.": <input type=\"text\" name=\"filesize\" size=\"12\" maxlength=\"11\"> ("._INBYTES.")<br>"
  207.         .""._VERSION.": <input type=\"text\" name=\"version\" size=\"11\" maxlength=\"10\"><br>"
  208.             .""._HOMEPAGE.": <input type=\"text\" name=\"homepage\" size=\"50\" maxlength=\"200\" value=\"http://\"><br><br>"
  209.         ."<input type=\"hidden\" name=\"d_op\" value=\"Add\">"
  210.             ."<input type=\"submit\" value=\""._ADDTHISFILE."\"> "._GOBACK."<br><br>"
  211.             ."</form>";
  212.     } else {
  213.         echo "<center>"._DOWNLOADSNOTUSER1."<br>"
  214.         .""._DOWNLOADSNOTUSER2."<br><br>"
  215.             .""._DOWNLOADSNOTUSER3."<br>"
  216.             .""._DOWNLOADSNOTUSER4."<br>"
  217.             .""._DOWNLOADSNOTUSER5."<br>"
  218.             .""._DOWNLOADSNOTUSER6."<br>"
  219.             .""._DOWNLOADSNOTUSER7."<br><br>"
  220.             .""._DOWNLOADSNOTUSER8."";
  221.     }
  222.     CloseTable();
  223.     include("footer.php");
  224. }
  225.  
  226. function Add($title, $url, $auth_name, $cat, $description, $email, $filesize, $version, $homepage) {
  227.     global $prefix, $db, $user;
  228.     $result = $db->sql_query("SELECT url FROM ".$prefix."_downloads_downloads WHERE url='$url'");
  229.     $numrows = $db->sql_numrows($result);
  230.     if ($numrows>0) {
  231.     include("header.php");
  232.     menu(1);
  233.     echo "<br>";
  234.     OpenTable();
  235.     echo "<center><b>"._DOWNLOADALREADYEXT."</b><br><br>"
  236.         .""._GOBACK."";
  237.     CloseTable();
  238.     include("footer.php");
  239.     } else {
  240.     if(is_user($user)) {
  241.         $user2 = base64_decode($user);
  242.         $cookie = explode(":", $user2);
  243.         cookiedecode($user);
  244.         $submitter = $cookie[1];
  245.     }
  246. // Check if Title exist
  247.     if ($title=="") {
  248.     include("header.php");
  249.     menu(1);
  250.     echo "<br>";
  251.     OpenTable();
  252.     echo "<center><b>"._DOWNLOADNOTITLE."</b><br><br>"
  253.         .""._GOBACK."";
  254.     CloseTable();
  255.     include("footer.php");
  256.     }
  257. // Check if URL exist
  258.     if ($url=="") {
  259.     include("header.php");
  260.     menu(1);
  261.     echo "<br>";
  262.     OpenTable();
  263.     echo "<center><b>"._DOWNLOADNOURL."</b><br><br>"
  264.         .""._GOBACK."";
  265.     CloseTable();
  266.     include("footer.php");
  267.     }
  268. // Check if Description exist
  269.     if ($description=="") {
  270.     include("header.php");
  271.     menu(1);
  272.     echo "<br>";
  273.     OpenTable();
  274.     echo "<center><b>"._DOWNLOADNODESC."</b><br><br>"
  275.         .""._GOBACK."";
  276.     CloseTable();
  277.     include("footer.php");
  278.     }
  279.     $cat = explode("-", $cat);
  280.     if ($cat[1]=="") {
  281.     $cat[1] = 0;
  282.     }
  283.     $title = stripslashes($title);
  284.     $url = stripslashes($url);
  285.     $description = stripslashes($description);
  286.     $auth_name = stripslashes($auth_name);
  287.     $email = stripslashes($email);
  288.     $filesize = ereg_replace("\.","",$filesize);
  289.     $filesize = ereg_replace("\,","",$filesize);
  290.     $cat[0] = intval($cat[0]);
  291.     $cat[1] = intval($cat[1]);
  292.     $db->sql_query("INSERT INTO ".$prefix."_downloads_newdownload VALUES (NULL, '$cat[0]', '$cat[1]', '$title', '$url', '$description', '$auth_name', '$email', '$submitter', '$filesize', '$version', '$homepage')");
  293.     include("header.php");
  294.     menu(1);
  295.     echo "<br>";
  296.     OpenTable();
  297.     echo "<center><b>"._DOWNLOADRECEIVED."</b><br>";
  298.     if ($email == "") {
  299.     echo _CHECKFORIT;
  300.     }
  301.     CloseTable();
  302.     include("footer.php");
  303.     }
  304. }
  305.  
  306. function NewDownloads($newdownloadshowdays) {
  307.     global $prefix, $db, $module_name, $locale;
  308.     include("header.php");
  309.     menu(1);
  310.     echo "<br>";
  311.     OpenTable();
  312.     echo "<center><font class=\"option\"><b>"._NEWDOWNLOADS."</b></font></center><br>";
  313.     $counter = 0;
  314.     $allweekdownloads = 0;
  315.     while ($counter <= 7-1){
  316.     $newdownloaddayRaw = (time()-(86400 * $counter));
  317.     $newdownloadday = date("d-M-Y", $newdownloaddayRaw);
  318.     $newdownloadView = date("F d, Y", $newdownloaddayRaw);
  319.     $newdownloadDB = Date("Y-m-d", $newdownloaddayRaw);
  320.     $totaldownloads = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_downloads_downloads WHERE date LIKE '%$newdownloadDB%'"));
  321.     $counter++;
  322.     $allweekdownloads = $allweekdownloads + $totaldownloads;
  323.     }
  324.     $counter = 0;
  325.     while ($counter <=30-1){
  326.         $newdownloaddayRaw = (time()-(86400 * $counter));
  327.         $newdownloadDB = Date("Y-m-d", $newdownloaddayRaw);
  328.         $totaldownloads = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_downloads_downloads WHERE date LIKE '%$newdownloadDB%'"));
  329.         $allmonthdownloads = $allmonthdownloads + $totaldownloads;
  330.         $counter++;
  331.     }
  332.     echo "<center><b>"._TOTALNEWDOWNLOADS.":</b> "._LASTWEEK." - $allweekdownloads \ "._LAST30DAYS." - $allmonthdownloads<br>"
  333.     .""._SHOW.": <a href=\"modules.php?name=$module_name&d_op=NewDownloads&newdownloadshowdays=7\">"._1WEEK."</a> - <a href=\"modules.php?name=$module_name&d_op=NewDownloads&newdownloadshowdays=14\">"._2WEEKS."</a> - <a href=\"modules.php?name=$module_name&d_op=NewDownloads&newdownloadshowdays=30\">"._30DAYS."</a>"
  334.     ."</center><br>";
  335.     /* List Last VARIABLE Days of Downloads */
  336.     if (!isset($newdownloadshowdays)) {
  337.     $newdownloadshowdays = 7;
  338.     }
  339.     echo "<br><center><b>"._DTOTALFORLAST." $newdownloadshowdays "._DAYS.":</b><br><br>";
  340.     $counter = 0;
  341.     $allweekdownloads = 0;
  342.     setlocale(LC_TIME, $locale); //nastavime locale
  343.     while ($counter <= $newdownloadshowdays-1) {
  344.     $newdownloaddayRaw = (time()-(86400 * $counter));
  345.     $newdownloadday = date("d-M-Y", $newdownloaddayRaw);
  346.     $newdownloadView = date("F d, Y", $newdownloaddayRaw);
  347.     $newdownloadDB = Date("Y-m-d", $newdownloaddayRaw);
  348.     $totaldownloads = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_downloads_downloads WHERE date LIKE '%$newdownloadDB%'"));
  349.     $counter++;
  350.     $allweekdownloads = $allweekdownloads + $totaldownloads;
  351.  
  352.     $new_date_by_locale = strtotime($newdownloadView); //nacteme do timestamp mesic slovne
  353.     $new_date_by_locale = strftime(translate(downloads), $new_date_by_locale); //timestamp prevedeme zpet do stejneho tvaru jako ma originalni user_reg
  354.     $newdownloadView = $new_date_by_locale;
  355.  
  356.     echo "<strong><big>·</big></strong> <a href=\"modules.php?name=$module_name&d_op=NewDownloadsDate&selectdate=$newdownloaddayRaw\">$newdownloadView</a> ($totaldownloads)<br>";
  357.     }
  358.     setlocale(LC_TIME, ''); //nastavime zpet locale na vychozi systemovou hodnotu
  359.     $counter = 0;
  360.     $allmonthdownloads = 0;
  361.     echo "</center>";
  362.     CloseTable();
  363.     include("footer.php");
  364. }
  365.  
  366. function NewDownloadsDate($selectdate) {
  367.     global $prefix, $db, $module_name, $admin, $user, $locale;
  368.     $dateDB = (date("d-M-Y", $selectdate));
  369.     $dateView = (date("F d, Y", $selectdate));
  370.  
  371.     setlocale(LC_TIME, $locale); //nastavime locale
  372.     $new_date_by_locale = strtotime($dateView); //nacteme do timestamp mesic slovne
  373.     $new_date_by_locale = strftime(translate(downloads), $new_date_by_locale); //timestamp prevedeme zpet do stejneho tvaru jako ma originalni user_reg
  374.     $dateView = $new_date_by_locale;
  375.     setlocale(LC_TIME, ''); //nastavime zpet locale na vychozi systemovou hodnotu
  376.  
  377.     include("header.php");
  378.     menu(1);
  379.     echo "<br>";
  380.     OpenTable();
  381.     $newdownloadDB = Date("Y-m-d", $selectdate);
  382.     $totaldownloads = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_downloads_downloads WHERE date LIKE '%$newdownloadDB%'"));
  383.     echo "<font class=\"option\"><b>$dateView - $totaldownloads "._NEWDOWNLOADS2."</b></font>"
  384.     ."<table width=\"100%\" cellspacing=\"0\" cellpadding=\"10\" border=\"0\"><tr><td><font class=\"content\">";
  385.     $result = $db->sql_query("SELECT lid, cid, title, description, date, hits, downloadratingsummary, totalvotes, totalcomments, filesize, version, homepage FROM ".$prefix."_downloads_downloads WHERE date LIKE '%$newdownloadDB%' ORDER BY title ASC");
  386.     while ($row = $db->sql_fetchrow($result)) {
  387.     $lid = intval($row['lid']);
  388.     $cid = intval($row['cid']);
  389.     $title = stripslashes($row['title']);
  390.     $description = stripslashes($row['description']);
  391.     $time = $row['date'];
  392.     $hits = intval($row['hits']);
  393.     $downloadratingsummary = $row['downloadratingsummary'];
  394.     $totalvotes = intval($row['totalvotes']);
  395.     $totalcomments = $row['totalcomments'];
  396.     $filesize = $row['filesize'];
  397.     $version = $row['version'];
  398.     $homepage = $row['homepage'];
  399.     $downloadratingsummary = number_format($downloadratingsummary, $mainvotedecimal);
  400.     if (is_admin($admin)) {
  401.         echo "<a href=\"admin.php?op=DownloadsModDownload&lid=$lid\"><img src=\"modules/$module_name/images/lwin.gif\" border=\"0\" alt=\""._EDIT."\"></a>  ";
  402.     } else {
  403.         echo "<img src=\"modules/$module_name/images/lwin.gif\" border=\"0\" alt=\"\">  ";
  404.     }
  405.     echo "<a href=\"modules.php?name=$module_name&d_op=getit&lid=$lid\">$title</a>";
  406.     newdownloadgraphic($datetime, $time);
  407.     popgraphic($hits);
  408.     detecteditorial($lid, $transfertitle, 1);
  409.     echo "<br><b>"._DESCRIPTION.":</b> $description<br>";
  410.     setlocale (LC_TIME, $locale);
  411.     /* INSERT code for *editor review* here */
  412.     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);
  413.     $datetime = strftime(""._LINKSDATESTRING."", mktime($datetime[4],$datetime[5],$datetime[6],$datetime[2],$datetime[3],$datetime[1]));
  414.     $datetime = ucfirst($datetime);
  415.     echo "<b>"._VERSION.":</b> $version <b>"._FILESIZE.":</b> ".CoolSize($filesize)."<br>";
  416.     echo "<b>"._ADDEDON.":</b> <b>$datetime</b> <b>"._UDOWNLOADSH.":</b> $hits";
  417.         $transfertitle = str_replace (" ", "_", $title);
  418.         /* voting & comments stats */
  419.         if ($totalvotes == 1) {
  420.         $votestring = _VOTE;
  421.         } else {
  422.         $votestring = _VOTES;
  423.     }
  424.         if ($downloadratingsummary!="0" || $downloadratingsummary!="0.0") {
  425.         echo " <b>"._RATING.":</b> $downloadratingsummary ($totalvotes $votestring)";
  426.     }
  427.         if ($homepage == "") {
  428.         echo "<br>";
  429.     } else {
  430.         echo "<br><a href=\"$homepage\" target=\"new\">"._HOMEPAGE."</a> | ";
  431.     }
  432.     echo "<a href=\"modules.php?name=$module_name&d_op=ratedownload&lid=$lid&ttitle=$transfertitle\">"._RATERESOURCE."</a>";
  433.         if (is_user($user)) {
  434.         echo " | <a href=\"modules.php?name=$module_name&d_op=brokendownload&lid=$lid\">"._REPORTBROKEN."</a>";
  435.     }
  436.     echo " | <a href=\"modules.php?name=$module_name&d_op=viewdownloaddetails&lid=$lid&ttitle=$transfertitle\">"._DETAILS."</a>";
  437.         if ($totalcomments != 0) {
  438.         echo " | <a href=\"modules.php?name=$module_name&d_op=viewdownloadcomments&lid=$lid&ttitle=$transfertitle\">"._SCOMMENTS." ($totalcomments)</a>";
  439.     }
  440.     detecteditorial($lid, $transfertitle, 0);
  441.     echo "<br>";
  442.     $row2 = $db->sql_fetchrow($db->sql_query("SELECT title FROM ".$prefix."_downloads_categories WHERE cid='$cid'"));
  443.     $ctitle = $row2['title'];
  444.     $ctitle = getparent($cid,$ctitle);
  445.     echo ""._CATEGORY.": $ctitle";
  446.     echo "<br><br>";
  447.     }
  448.     echo "</font></td></tr></table>";
  449.     CloseTable();
  450.     include("footer.php");
  451. }
  452.  
  453. function TopRated($ratenum, $ratetype) {
  454.     global $prefix, $db, $admin, $module_name, $user, $locale;
  455.     $ratenum = intval($ratenum);
  456.     include("header.php");
  457.     include("modules/$module_name/d_config.php");
  458.     menu(1);
  459.     echo "<br>";
  460.     OpenTable();
  461.     echo "<table border=\"0\" width=\"100%\"><tr><td align=\"center\">";
  462.     if ($ratenum != "" && $ratetype != "") {
  463.         $topdownloads = $ratenum;
  464.         if ($ratetype == "percent") {
  465.         $topdownloadspercentrigger = 1;
  466.     }
  467.     }
  468.     if ($topdownloadspercentrigger == 1) {
  469.         $topdownloadspercent = $topdownloads;
  470.         $totalrateddownloads = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_downloads_downloads WHERE downloadratingsummary != 0"));
  471.         $topdownloads = $topdownloads / 100;
  472.         $topdownloads = $totalrateddownloads * $topdownloads;
  473.         $topdownloads = round($topdownloads);
  474.     }
  475.     if ($topdownloadspercentrigger == 1) { 
  476.     echo "<center><font class=\"option\"><b>"._DBESTRATED." $topdownloadspercent% ("._OF." $totalrateddownloads "._TRATEDDOWNLOADS.")</b></font></center><br>";
  477.     } else {
  478.     echo "<center><font class=\"option\"><b>"._DBESTRATED." $topdownloads </b></font></center><br>";
  479.     }
  480.     echo "</td></tr>"
  481.     ."<tr><td><center>"._NOTE." $downloadvotemin "._TVOTESREQ."<br>"
  482.     .""._SHOWTOP.":  [ <a href=\"modules.php?name=$module_name&d_op=TopRated&ratenum=10&ratetype=num\">10</a> - "
  483.     ."<a href=\"modules.php?name=$module_name&d_op=TopRated&ratenum=25&ratetype=num\">25</a> - "
  484.         ."<a href=\"modules.php?name=$module_name&d_op=TopRated&ratenum=50&ratetype=num\">50</a> | "
  485.         ."<a href=\"modules.php?name=$module_name&d_op=TopRated&ratenum=1&ratetype=percent\">1%</a> - "
  486.         ."<a href=\"modules.php?name=$module_name&d_op=TopRated&ratenum=5&ratetype=percent\">5%</a> - "
  487.         ."<a href=\"modules.php?name=$module_name&d_op=TopRated&ratenum=10&ratetype=percent\">10%</a> ]</center><br><br></td></tr>";
  488.     $result = $db->sql_query("SELECT lid, cid, title, description, date, hits, downloadratingsummary, totalvotes, totalcomments, filesize, version, homepage FROM ".$prefix."_downloads_downloads WHERE downloadratingsummary != 0 AND totalvotes >= $downloadvotemin ORDER BY downloadratingsummary DESC LIMIT 0,$topdownloads");
  489.     echo "<tr><td>";
  490.     while ($row = $db->sql_fetchrow($result)) {
  491.     $lid = intval($row['lid']);
  492.     $cid = intval($row['cid']);
  493.     $title = stripslashes($row['title']);
  494.     $description = stripslashes($row['description']);
  495.     $time = $row['date'];
  496.     $hits = intval($row['hits']);
  497.     $downloadratingsummary = $row['downloadratingsummary'];
  498.     $totalvotes = intval($row['totalvotes']);
  499.     $totalcomments = $row['totalcomments'];
  500.     $filesize = $row['filesize'];
  501.     $version = $row['version'];
  502.     $homepage = $row['homepage'];
  503.     $downloadratingsummary = number_format($downloadratingsummary, $mainvotedecimal);
  504.     if (is_admin($admin)) {
  505.         echo "<a href=\"admin.php?op=DownloadsModDownload&lid=$lid\"><img src=\"modules/$module_name/images/lwin.gif\" border=\"0\" alt=\""._EDIT."\"></a>  ";
  506.     } else {
  507.         echo "<img src=\"modules/$module_name/images/lwin.gif\" border=\"0\" alt=\"\">  ";
  508.     }
  509.         echo "<a href=\"modules.php?name=$module_name&d_op=getit&lid=$lid\">$title</a>";
  510.     newdownloadgraphic($datetime, $time);
  511.     popgraphic($hits);
  512.     detecteditorial($lid, $transfertitle, 1);
  513.     echo "<br>";
  514.     echo "<b>"._DESCRIPTION.":</b> $description<br>";
  515.     setlocale (LC_TIME, $locale);
  516.     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);
  517.     $datetime = strftime(""._LINKSDATESTRING."", mktime($datetime[4],$datetime[5],$datetime[6],$datetime[2],$datetime[3],$datetime[1]));
  518.     $datetime = ucfirst($datetime);
  519.     echo "<b>"._VERSION.":</b> $version <b>"._FILESIZE.":</b> ".CoolSize($filesize)."<br>";
  520.     echo "<b>"._ADDEDON.":</b> $datetime <b>"._UDOWNLOADSH.":</b> $hits";
  521.     $transfertitle = str_replace (" ", "_", $title);
  522.     /* voting & comments stats */
  523.         if ($totalvotes == 1) {
  524.         $votestring = _VOTE;
  525.         } else {
  526.         $votestring = _VOTES;
  527.     }
  528.     if ($downloadratingsummary!="0" || $downloadratingsummary!="0.0") {
  529.         echo " <b>"._RATING.":</b> <b>$downloadratingsummary</b> ($totalvotes $votestring)";
  530.     }
  531.         if ($homepage == "") {
  532.         echo "<br>";
  533.     } else {
  534.         echo "<br><a href=\"$homepage\" target=\"new\">"._HOMEPAGE."</a> | ";
  535.     }
  536.     echo "<a href=\"modules.php?name=$module_name&d_op=ratedownload&lid=$lid&ttitle=$transfertitle\">"._RATERESOURCE."</a>";
  537.     if (is_user($user)) {
  538.         echo " | <a href=\"modules.php?name=$module_name&d_op=brokendownload&lid=$lid\">"._REPORTBROKEN."</a>";
  539.     }
  540.     echo " | <a href=\"modules.php?name=$module_name&d_op=viewdownloaddetails&lid=$lid&ttitle=$transfertitle\">"._DETAILS."</a>";
  541.     if ($totalcomments != 0) {
  542.         echo " | <a href=\"modules.php?name=$module_name&d_op=viewdownloadcomments&lid=$lid&ttitle=$transfertitle\">"._SCOMMENTS." ($totalcomments)</a>";
  543.     }
  544.     detecteditorial($lid, $transfertitle, 0);
  545.     echo "<br>";
  546.     $row2 = $db->sql_fetchrow($db->sql_query("SELECT title FROM ".$prefix."_downloads_categories WHERE cid='$cid'"));
  547.     $ctitle = $row2['title'];
  548.     $ctitle = getparent($cid,$ctitle);
  549.     echo ""._CATEGORY.": $ctitle";
  550.     echo "<br><br>";
  551.     }
  552.     echo "</font></td></tr></table>";
  553.     CloseTable();
  554.     include("footer.php");
  555. }
  556.  
  557. function MostPopular($ratenum, $ratetype) {
  558.     global $prefix, $db, $admin, $module_name, $user;
  559.     $ratenum = intval($ratenum);
  560.     include("header.php");
  561.     include("modules/$module_name/d_config.php");
  562.     menu(1);
  563.     echo "<br>";
  564.     OpenTable();
  565.     echo "<table border=\"0\" width=\"100%\"><tr><td align=\"center\">";
  566.     if ($ratenum != "" && $ratetype != "") {
  567.         $mostpopdownloads = $ratenum;
  568.         if ($ratetype == "percent") $mostpopdownloadspercentrigger = 1;
  569.     }
  570.     if ($mostpopdownloadspercentrigger == 1) {
  571.         $topdownloadspercent = $mostpopdownloads;
  572.         $result = $db->sql_query("SELECT * FROM ".$prefix."_downloads_downloads");
  573.         $totalmostpopdownloads = $db->sql_numrows($result);
  574.         $mostpopdownloads = $mostpopdownloads / 100;
  575.         $mostpopdownloads = $totalmostpopdownloads * $mostpopdownloads;
  576.         $mostpopdownloads = round($mostpopdownloads);
  577.     }    
  578.     if ($mostpopdownloadspercentrigger == 1) {
  579.     echo "<center><font class=\"option\"><b>"._MOSTPOPULAR." $topdownloadspercent% ("._OFALL." $totalmostpopdownloads "._DOWNLOADS.")</b></font></center>";
  580.     } else {
  581.     echo "<center><font class=\"option\"><b>"._MOSTPOPULAR." $mostpopdownloads</b></font></center>";
  582.     }
  583.     echo "<tr><td><center>"._SHOWTOP.": [ <a href=\"modules.php?name=$module_name&d_op=MostPopular&ratenum=10&ratetype=num\">10</a> - "
  584.     ."<a href=\"modules.php?name=$module_name&d_op=MostPopular&ratenum=25&ratetype=num\">25</a> - "
  585.         ."<a href=\"modules.php?name=$module_name&d_op=MostPopular&ratenum=50&ratetype=num\">50</a> | "
  586.         ."<a href=\"modules.php?name=$module_name&d_op=MostPopular&ratenum=1&ratetype=percent\">1%</a> - "
  587.         ."<a href=\"modules.php?name=$module_name&d_op=MostPopular&ratenum=5&ratetype=percent\">5%</a> - "
  588.         ."<a href=\"modules.php?name=$module_name&d_op=MostPopular&ratenum=10&ratetype=percent\">10%</a> ]</center><br><br></td></tr>";
  589.     $result2 = $db->sql_query("SELECT lid, cid, title, description, date, hits, downloadratingsummary, totalvotes, totalcomments, filesize, version, homepage FROM ".$prefix."_downloads_downloads order by hits DESC limit 0,$mostpopdownloads");
  590.     echo "<tr><td>";
  591.     while($row2 = $db->sql_fetchrow($result2)) {
  592.         $lid = intval($row2['lid']);
  593.         $cid = intval($row2['cid']);
  594.         $title = stripslashes($row2['title']);
  595.         $url = $row2['url'];
  596.         $description = stripslashes($row2['description']);
  597.         $time = $row2['date'];
  598.         $hits = intval($row2['hits']);
  599.         $downloadratingsummary = $row2['downloadratingsummary'];
  600.         $totalvotes = intval($row2['totalvotes']);
  601.         $totalcomments = $row2['totalcomments'];
  602.         $filesize = $row2['filesize'];
  603.         $version = $row2['version'];
  604.         $homepage = $row2['homepage'];
  605.     if (is_admin($admin)) {
  606.         echo "<a href=\"admin.php?op=DownloadsModDownload&lid=$lid\"><img src=\"modules/$module_name/images/lwin.gif\" border=\"0\" alt=\""._EDIT."\"></a>  ";
  607.     } else {
  608.         echo "<img src=\"modules/$module_name/images/lwin.gif\" border=\"0\" alt=\"\">  ";
  609.     }
  610.         echo "<font class=\"content\"><a href=\"modules.php?name=$module_name&d_op=getit&lid=$lid\">$title</a>";
  611.     newdownloadgraphic($datetime, $time);
  612.     popgraphic($hits);
  613.     detecteditorial($lid, $transfertitle, 1);
  614.     echo "<br>";
  615.     echo "<b>"._DESCRIPTION.":</b> $description<br>";
  616.     setlocale (LC_TIME, $locale);
  617.     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);
  618.     $datetime = strftime(""._LINKSDATESTRING."", mktime($datetime[4],$datetime[5],$datetime[6],$datetime[2],$datetime[3],$datetime[1]));
  619.     $datetime = ucfirst($datetime);
  620.     echo "<b>"._VERSION.":</b> $version <b>"._FILESIZE.":</b> ".CoolSize($filesize)."<br>";
  621.     echo "<b>"._ADDEDON.":</b> $datetime <b>"._UDOWNLOADSH.":</b> <b>$hits</b>";
  622.     $transfertitle = str_replace (" ", "_", $title);
  623.     /* voting & comments stats */
  624.         if ($totalvotes == 1) {
  625.         $votestring = _VOTE;
  626.         } else {
  627.         $votestring = _VOTES;
  628.     }
  629.     if ($downloadratingsummary!="0" || $downloadratingsummary!="0.0") {
  630.         echo " <b>"._RATING.":</b> $downloadratingsummary ($totalvotes $votestring)";
  631.     }
  632.         if ($homepage == "") {
  633.         echo "<br>";
  634.     } else {
  635.         echo "<br><a href=\"$homepage\" target=\"new\">"._HOMEPAGE."</a> | ";
  636.     }
  637.     echo "<a href=\"modules.php?name=$module_name&d_op=ratedownload&lid=$lid&ttitle=$transfertitle\">"._RATERESOURCE."</a>";
  638.     if (is_user($user)) {
  639.         echo " | <a href=\"modules.php?name=$module_name&d_op=brokendownload&lid=$lid\">"._REPORTBROKEN."</a>";
  640.     }
  641.     echo " | <a href=\"modules.php?name=$module_name&d_op=viewdownloaddetails&lid=$lid&ttitle=$transfertitle\">"._DETAILS."</a>";
  642.     if ($totalcomments != 0) {
  643.         echo " | <a href=\"modules.php?name=$module_name&d_op=viewdownloadcomments&lid=$lid&ttitle=$transfertitle\">"._SCOMMENTS." ($totalcomments)</a>";
  644.     }
  645.     detecteditorial($lid, $transfertitle, 0);
  646.     echo "<br>";
  647.     $row3 = $db->sql_fetchrow($db->sql_query("SELECT title FROM ".$prefix."_downloads_categories WHERE cid='$cid'"));
  648.     $ctitle = $row3['title'];
  649.     $ctitle = getparent($cid,$ctitle);
  650.     echo ""._CATEGORY.": $ctitle";
  651.     echo "<br><br>";
  652.     }
  653.     echo "</font></td></tr></table>";
  654.     CloseTable();
  655.     include("footer.php");
  656. }
  657.  
  658. function viewdownload($cid, $min, $orderby, $show) {
  659.     global $prefix, $db, $admin, $perpage, $module_name, $user;
  660.     include("header.php");
  661.     if (!isset($min)) $min=0;
  662.     if (!isset($max)) $max=$min+$perpage;
  663.     if(isset($orderby)) {
  664.     $orderby = convertorderbyin($orderby);
  665.     } else {
  666.     $orderby = "title ASC";
  667.     }
  668.     if ($show!="") {
  669.     $perpage = $show;
  670.     } else {
  671.     $show=$perpage;
  672.     }
  673.     menu(1);
  674.     echo "<br>";
  675.     OpenTable();
  676.     $cid = intval($cid);
  677.     $row = $db->sql_fetchrow($db->sql_query("SELECT title,parentid FROM ".$prefix."_downloads_categories WHERE cid='$cid'"));
  678.     $title = $row['title'];
  679.     $parentid = intval($row['parentid']);
  680.     $title=getparentlink($parentid,$title);
  681.     $title="<a href=\"modules.php?name=$module_name\">"._MAIN."</a>/$title";
  682.     echo "<center><font class=\"option\"><b>"._CATEGORY.": $title</b></font></center><br>";
  683.     echo "<table border=\"0\" cellspacing=\"10\" cellpadding=\"0\" align=\"center\"><tr>";
  684.     $cid = intval($cid);
  685.     $result2 = $db->sql_query("SELECT cid, title, cdescription FROM ".$prefix."_downloads_categories WHERE parentid='$cid' order by title");
  686.     $count = 0;
  687.     while($row2 = $db->sql_fetchrow($result2)) {
  688.         $cid2 = intval($row2['cid']);
  689.         $title2 = stripslashes($row2['title']);
  690.         $cdescription2 = stripslashes($row2['cdescription']);
  691.         $cresult = $db->sql_query("SELECT * FROM ".$prefix."_downloads_downloads WHERE cid='$cid2'");
  692.         $cnumrows = $db->sql_numrows($cresult);
  693.     echo "<td><font class=\"option\"><strong><big>·</big></strong> <a href=\"modules.php?name=$module_name&d_op=viewdownload&cid=$cid2\"><b>$title2</b></a></font> ($cnumrows)";
  694.     categorynewdownloadgraphic($cid2);
  695.     if ($cdescription2) {
  696.         echo "<font class=\"content\">$cdescription2</font><br>";
  697.     } else {
  698.         echo "<br>";
  699.     }
  700.     $result3 = $db->sql_query("SELECT cid, title FROM ".$prefix."_downloads_categories WHERE parentid='$cid2' order by title limit 0,3");
  701.     $space = 0;
  702.     while($row3 = $db->sql_fetchrow($result3)) {
  703.         $cid3 = intval($row3['cid']);
  704.         $title3 = stripslashes($row3['title']);
  705.             if ($space>0) {
  706.         echo ", ";
  707.         }
  708.             $cresult2 = $db->sql_query("SELECT * FROM ".$prefix."_downloads_downloads WHERE cid='$cid3'");
  709.             $cnumrows2 = $db->sql_numrows($cresult2);
  710.         echo "<font class=\"content\"><a href=\"modules.php?name=$module_name&d_op=viewdownload&cid=$cid3\">$title3</a> ($cnumrows2)</font>";
  711.         $space++;
  712.     }
  713.     if ($count<1) {
  714.         echo "</td><td>    </td>";
  715.         $dum = 1;
  716.     }
  717.     $count++;
  718.     if ($count==2) {
  719.         echo "</td></tr><tr>";
  720.         $count = 0;
  721.         $dum = 0;
  722.     }
  723.     }
  724.     if ($dum == 1) {
  725.     echo "</tr></table>";
  726.     } elseif ($dum == 0) {
  727.     echo "<td></td></tr></table>";
  728.     }
  729.  
  730.     echo "<hr noshade size=\"1\">";
  731.     $orderbyTrans = convertorderbytrans($orderby);
  732.     echo "<center><font class=\"content\">"._SORTDOWNLOADSBY.": "
  733.         .""._TITLE." (<a href=\"modules.php?name=$module_name&d_op=viewdownload&cid=$cid&orderby=titleA\">A</a>\<a href=\"modules.php?name=$module_name&d_op=viewdownload&cid=$cid&orderby=titleD\">D</a>) "
  734.         .""._DATE." (<a href=\"modules.php?name=$module_name&d_op=viewdownload&cid=$cid&orderby=dateA\">A</a>\<a href=\"modules.php?name=$module_name&d_op=viewdownload&cid=$cid&orderby=dateD\">D</a>) "
  735.         .""._RATING." (<a href=\"modules.php?name=$module_name&d_op=viewdownload&cid=$cid&orderby=ratingA\">A</a>\<a href=\"modules.php?name=$module_name&d_op=viewdownload&cid=$cid&orderby=ratingD\">D</a>) "
  736.         .""._POPULARITY." (<a href=\"modules.php?name=$module_name&d_op=viewdownload&cid=$cid&orderby=hitsA\">A</a>\<a href=\"modules.php?name=$module_name&d_op=viewdownload&cid=$cid&orderby=hitsD\">D</a>)"
  737.     ."<br><b>"._RESSORTED.": $orderbyTrans</b></font></center><br><br>";
  738.     $orderby = trim($orderby);
  739.     $result4 = $db->sql_query("SELECT lid, title, description, date, hits, downloadratingsummary, totalvotes, totalcomments, filesize, version, homepage FROM ".$prefix."_downloads_downloads WHERE cid='$cid' order by $orderby limit $min,$perpage");
  740.     $fullcountresult = $db->sql_query("SELECT lid, title, description, date, hits, downloadratingsummary, totalvotes, totalcomments FROM ".$prefix."_downloads_downloads WHERE cid='$cid'");
  741.     $totalselecteddownloads = $db->sql_numrows($fullcountresult);
  742.     echo "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"10\" border=\"0\"><tr><td><font class=\"content\">";
  743.     $x=0;
  744.     while($row4 = $db->sql_fetchrow($result4)) {
  745.         $lid = intval($row4['lid']);
  746.         $title = stripslashes($row4['title']);
  747.         $description = stripslashes($row4['description']);
  748.         $time = $row4['date'];
  749.         $hits = intval($row4['hits']);
  750.         $downloadratingsummary = $row4['downloadratingsummary'];
  751.         $totalvotes = intval($row4['totalvotes']);
  752.         $totalcomments = intval($row4['totalcomments']);
  753.         $filesize = $row4['filesize'];
  754.         $version = $row4['version'];
  755.         $homepage = $row4['homepage'];
  756.     if (is_admin($admin)) {
  757.         echo "<a href=\"admin.php?op=DownloadsModDownload&lid=$lid\"><img src=\"modules/$module_name/images/lwin.gif\" border=\"0\" alt=\""._EDIT."\"></a>  ";
  758.     } else {
  759.         echo "<img src=\"modules/$module_name/images/lwin.gif\" border=\"0\" alt=\"\">  ";
  760.     }
  761.         echo "<a href=\"modules.php?name=$module_name&d_op=getit&lid=$lid\">$title</a>";
  762.     newdownloadgraphic($datetime, $time);
  763.     popgraphic($hits);
  764.     /* INSERT code for *editor review* here */
  765.     detecteditorial($lid, $transfertitle, 1);
  766.     echo "<br>";
  767.     echo "<b>"._DESCRIPTION.":</b> $description<br>";
  768.     setlocale (LC_TIME, $locale);
  769.     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);
  770.     $datetime = strftime(""._LINKSDATESTRING."", mktime($datetime[4],$datetime[5],$datetime[6],$datetime[2],$datetime[3],$datetime[1]));
  771.     $datetime = ucfirst($datetime);
  772.     echo "<b>"._VERSION.":</b> $version <b>"._FILESIZE.":</b> ".CoolSize($filesize)."<br>";
  773.     echo "<b>"._ADDEDON.":</b> $datetime <b>"._UDOWNLOADSH.":</b> $hits";
  774.         $transfertitle = str_replace (" ", "_", $title);
  775.         /* voting & comments stats */
  776.         if ($totalvotes == 1) {
  777.         $votestring = _VOTE;
  778.         } else {
  779.         $votestring = _VOTES;
  780.     }
  781.         if ($downloadratingsummary!="0" || $downloadratingsummary!="0.0") {
  782.         echo " <b>"._RATING.":</b> $downloadratingsummary ($totalvotes $votestring)";
  783.     }
  784.         if ($homepage == "") {
  785.         echo "<br>";
  786.     } else {
  787.         echo "<br><a href=\"$homepage\" target=\"new\">"._HOMEPAGE."</a> | ";
  788.     }
  789.     echo "<a href=\"modules.php?name=$module_name&d_op=ratedownload&lid=$lid&ttitle=$transfertitle\">"._RATERESOURCE."</a>";
  790.         if (is_user($user)) {
  791.         echo " | <a href=\"modules.php?name=$module_name&d_op=brokendownload&lid=$lid\">"._REPORTBROKEN."</a>";
  792.     }
  793.     echo " | <a href=\"modules.php?name=$module_name&d_op=viewdownloaddetails&lid=$lid&ttitle=$transfertitle\">"._DETAILS."</a>";
  794.         if ($totalcomments != 0) {
  795.         echo " | <a href=\"modules.php?name=$module_name&d_op=viewdownloadcomments&lid=$lid&ttitle=$transfertitle\">"._SCOMMENTS." ($totalcomments)</a>";
  796.     }
  797.         detecteditorial($lid, $transfertitle, 0);
  798.     echo "<br><br>";    
  799.     $x++;
  800.     }
  801.     echo "</font>";
  802.     $orderby = convertorderbyout($orderby);
  803.     /* Calculates how many pages exist. Which page one should be on, etc... */
  804.     $downloadpagesint = ($totalselecteddownloads / $perpage);            
  805.     $downloadpageremainder = ($totalselecteddownloads % $perpage);        
  806.     if ($downloadpageremainder != 0) {                     
  807.         $downloadpages = ceil($downloadpagesint);                
  808.         if ($totalselecteddownloads < $perpage) {
  809.             $downloadpageremainder = 0;
  810.         }
  811.     } else {
  812.         $downloadpages = $downloadpagesint;
  813.     }
  814.     /* Page Numbering */
  815.     if ($downloadpages!=1 && $downloadpages!=0) {
  816.         echo "<br><br>";
  817.           echo ""._SELECTPAGE.": ";
  818.          $prev=$min-$perpage;
  819.          if ($prev>=0) {
  820.             echo "  <b>[ <a href=\"modules.php?name=$module_name&d_op=viewdownload&cid=$cid&min=$prev&orderby=$orderby&show=$show\">";
  821.             echo " << "._PREVIOUS."</a> ]</b> ";
  822.           }
  823.         $counter = 1;
  824.      $currentpage = ($max / $perpage);
  825.            while ($counter<=$downloadpages ) {
  826.               $cpage = $counter;
  827.               $mintemp = ($perpage * $counter) - $perpage;
  828.               if ($counter == $currentpage) {
  829.         echo "<b>$counter</b> ";
  830.         } else {
  831.         echo "<a href=\"modules.php?name=$module_name&d_op=viewdownload&cid=$cid&min=$mintemp&orderby=$orderby&show=$show\">$counter</a> ";
  832.         }
  833.                $counter++;
  834.                }
  835.          $next=$min+$perpage;
  836.          if ($x>=$perpage) {
  837.             echo "  <b>[ <a href=\"modules.php?name=$module_name&d_op=viewdownload&cid=$cid&min=$max&orderby=$orderby&show=$show\">";
  838.             echo " "._NEXT." >></a> ]</b> ";
  839.          }
  840.     }
  841.     echo "</td></tr></table>";
  842.     CloseTable();
  843.     include("footer.php");
  844. }
  845.  
  846. function viewsdownload($sid, $min, $orderby, $show) {
  847.     global $prefix, $db, $admin, $module_name, $user;
  848.     include("modules/$module_name/d_config.php");
  849.     include("header.php");
  850.     menu(1);
  851.     if (!isset($min)) $min=0;
  852.     if (!isset($max)) $max=$min+$perpage;
  853.     if(isset($orderby)) {
  854.     $orderby = convertorderbyin($orderby);
  855.     } else {
  856.     $orderby = "title ASC";
  857.     }
  858.     if ($show!="") {
  859.     $perpage = $show;
  860.     } else {
  861.     $show=$perpage;
  862.     }
  863.     echo "<br>";
  864.     OpenTable();
  865.     $cid = intval(trim($cid));
  866.     $row = $db->sql_fetchrow($db->sql_query("SELECT title,parentid FROM ".$prefix."_downloads_categories WHERE cid='$cid'"));
  867.     $title = $row['title'];
  868.     $parentid = intval($row['parentid']);
  869.     $title=getparentlink($parentid,$title);
  870.     $title="<a href=modules.php?name=$module_name>"._MAIN."</a>/$title";
  871.     echo "<center><font class=\"option\"><b>"._CATEGORY.": $title</b></font></center><br>";
  872.     echo "<table border=\"0\" cellspacing=\"10\" cellpadding=\"0\" align=\"center\"><tr>";
  873.     $result2 = $db->sql_query("SELECT cid, title, cdescription FROM ".$prefix."_downloads_categories WHERE parentid='$cid' order by title");
  874.     $count = 0;
  875.     while($row2 = $db->sql_fetchrow($result2)) {
  876.         $cid2 = intval($row2['cid']);
  877.         $title2 = stripslashes($row2['title']);
  878.         $cdescription2 = stripslashes($row2['cdescription']);
  879.     echo "<td><font class=\"option\"><strong><big>·</big></strong> <a href=\"modules.php?name=$module_name&d_op=viewdownload&cid=$cid2\"><b>$title2</b></a></font>";
  880.     categorynewdownloadgraphic($cid2);
  881.     if ($cdescription2) {
  882.         echo "<font class=\"content\">$cdescription2</font><br>";
  883.     } else {
  884.         echo "<br>";
  885.     }
  886.     $result3 = $db->sql_query("SELECT cid, title FROM ".$prefix."_downloads_categories WHERE parentid='$cid2' order by title limit 0,3");
  887.     $space = 0;
  888.     while($row3 = $db->sql_fetchrow($result3)) {
  889.             $cid3 = intval($row3['cid']);
  890.             $title3 = stripslashes($row3['title']);
  891.             if ($space>0) {
  892.         echo ", ";
  893.         }
  894.         echo "<font class=\"content\"><a href=\"modules.php?name=$module_name&d_op=viewdownload&cid=$cid3\">$title3</a></font>";
  895.         $space++;
  896.     }
  897.     if ($count<1) {
  898.         echo "</td><td>    </td>";
  899.         $dum = 1;
  900.     }
  901.     $count++;
  902.     if ($count==2) {
  903.         echo "</td></tr><tr>";
  904.         $count = 0;
  905.         $dum = 0;
  906.     }
  907.     }
  908.     if ($dum == 1) {
  909.     echo "</tr></table>";
  910.     } elseif ($dum == 0) {
  911.     echo "<td></td></tr></table>";
  912.     }
  913.  
  914.     echo "<hr noshade size=\"1\">";
  915.     $orderbyTrans = convertorderbytrans($orderby);
  916.     echo "<br><center><font class=\"content\">"._SORTDOWNLOADSBY.": "
  917.     .""._TITLE." (<a href=\"modules.php?name=$module_name&d_op=viewdownload&sid=$sid&orderby=titleA\">A</a>\<a href=\"modules.php?name=$module_name&d_op=viewdownload&sid=$sid&orderby=titleD\">D</a>)"
  918.     ." "._DATE." (<a href=\"modules.php?name=$module_name&d_op=viewdownload&sid=$sid&orderby=dateA\">A</a>\<a href=\"modules.php?name=$module_name&d_op=viewdownload&sid=$sid&orderby=dateD\">D</a>)"
  919.     ." "._RATING." (<a href=\"modules.php?name=$module_name&d_op=viewdownload&sid=$sid&orderby=ratingA\">A</a>\<a href=\"modules.php?name=$module_name&d_op=viewdownload&sid=$sid&orderby=ratingD\">D</a>)"
  920.         ." "._POPULARITY." (<a href=\"modules.php?name=$module_name&d_op=viewdownload&sid=$sid&orderby=hitsA\">A</a>\<a href=\"modules.php?name=$module_name&d_op=viewdownload&sid=$sid&orderby=hitsD\">D</a>)"
  921.     ."<br><b>"._RESSORTED.": $orderbyTrans</b></font></center><br><br>";
  922.     $sid = intval($sid);
  923.     $orderby = trim($orderby);
  924.     $result4 = $db->sql_query("SELECT lid, url, title, description, date, hits, downloadratingsummary, totalvotes, totalcomments, filesize, version, homepage FROM ".$prefix."_downloads_downloads WHERE sid='$sid' order by $orderby limit $min,$perpage");
  925.     $fullcountresult = $db->sql_query("SELECT lid, title, description, date, hits, downloadratingsummary, totalvotes, totalcomments FROM ".$prefix."_downloads_downloads WHERE sid='$sid'");
  926.     $totalselecteddownloads = $db->sql_numrows($fullcountresult);
  927.     echo "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"10\" border=\"0\"><tr><td><font class=\"content\">";
  928.     $x=0;
  929.     while($row4 = $db->sql_fetchrow($result4)) {
  930.         $lid = intval($row4['lid']);
  931.         $url = $row4['url'];
  932.         $title = stripslashes($row4['title']);
  933.         $description = stripslashes($row4['description']);
  934.         $time = $row4['date'];
  935.         $hits = intval($row4['hits']);
  936.         $downloadratingsummary = $row4['downloadratingsummary'];
  937.         $totalvotes = intval($row4['totalvotes']);
  938.         $totalcomments = intval($row4['totalcomments']);
  939.         $filesize = $row4['filesize'];
  940.         $version = $row4['version'];
  941.         $homepage = $row4['homepage'];
  942.     $downloadratingsummary = number_format($downloadratingsummary, $mainvotedecimal);
  943.     if (is_admin($admin)) {
  944.         echo "<a href=\"admin.php?op=DownloadsModDownload&lid=$lid\"><img src=\"modules/$module_name/images/lwin.gif\" border=\"0\" alt=\""._EDIT."\"></a>  ";
  945.     } else {
  946.         echo "<img src=\"modules/$module_name/images/lwin.gif\" border=\"0\" alt=\"\">  ";
  947.     }
  948.         echo "<a href=\"modules.php?name=$module_name&d_op=getit&lid=$lid\">$title</a>";
  949.     newdownloadgraphic($datetime, $time);
  950.     popgraphic($hits);
  951.         /* code for *editor review* insert here    */
  952.     detecteditorial($lid, $transfertitle, 1);
  953.     echo "<br><b>"._DESCRIPTION.":</b> $description<br>";
  954.     setlocale (LC_TIME, $locale);
  955.     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);
  956.     $datetime = strftime(""._LINKSDATESTRING."", mktime($datetime[4],$datetime[5],$datetime[6],$datetime[2],$datetime[3],$datetime[1]));
  957.     $datetime = ucfirst($datetime);
  958.     echo "<b>"._VERSION.":</b> $version <b>"._FILESIZE.":</b> ".CoolSize($filesize)."<br>";
  959.     echo "<b>"._ADDEDON.":</b> $datetime <b>"._UDOWNLOADSH.":</b> $hits";
  960.         $transfertitle = str_replace (" ", "_", $title);
  961.         /* voting & comments stats */
  962.         if ($totalvotes == 1) {
  963.         $votestring = _VOTE;
  964.     } else {
  965.         $votestring = _VOTES;
  966.     }
  967.         if ($downloadratingsummary!="0" || $downloadratingsummary!="0.0") {
  968.         echo " <b>"._RATING.":</b> $downloadratingsummary ($totalvotes $votestring)";
  969.         }
  970.         if ($homepage == "") {
  971.         echo "<br>";
  972.     } else {
  973.         echo "<br><a href=\"$homepage\" target=\"new\">"._HOMEPAGE."</a> | ";
  974.     }
  975.     echo "<a href=\"modules.php?name=$module_name&d_op=ratedownload&lid=$lid&ttitle=$transfertitle\">"._RATERESOURCE."</a>";
  976.     if (is_user($user)) {
  977.         echo " | <a href=\"modules.php?name=$module_name&d_op=brokendownload&lid=$lid\">"._REPORTBROKEN."</a>";
  978.     }
  979.     echo " | <a href=\"modules.php?name=$module_name&d_op=viewdownloaddetails&lid=$lid&ttitle=$transfertitle\">"._DETAILS."</a>";
  980.         if ($totalcomments != 0) {
  981.         echo " | <a href=\"modules.php?name=$module_name&d_op=viewdownloadcomments&lid=$lid&ttitle=$transfertitle\">"._SCOMMENTS." ($totalcomments)</a>";
  982.     }
  983.     detecteditorial($lid, $transfertitle, 0);
  984.     echo "<br><br>";
  985.     $x++;
  986.     }
  987.     echo "</font>";
  988.     $orderby = convertorderbyout($orderby);
  989.     /* Calculates how many pages exist.  Which page one should be on, etc... */
  990.     $downloadpagesint = ($totalselecteddownloads / $perpage);            
  991.     $downloadpageremainder = ($totalselecteddownloads % $perpage);        
  992.     if ($downloadpageremainder != 0) {                     
  993.     $downloadpages = ceil($downloadpagesint);                
  994.         if ($totalselecteddownloads < $perpage) {
  995.             $downloadpageremainder = 0;
  996.         }
  997.     } else {
  998.         $downloadpages = $downloadpagesint;
  999.     }        
  1000.     /* Page Numbering */
  1001.     if ($downloadpages!=1 && $downloadpages!=0) {
  1002.     echo "<br><br>"
  1003.             .""._SELECTPAGE.": ";
  1004.         $prev=$min-$perpage;
  1005.         if ($prev>=0) {
  1006.             echo "  <b>[ <a href=\"modules.php?name=$module_name&d_op=viewdownload&sid=$sid&min=$prev&orderby=$orderby&show=$show\">"
  1007.             ." << "._PREVIOUS."</a> ]</b> ";
  1008.               }
  1009.         $counter = 1;
  1010.         $currentpage = ($max / $perpage);
  1011.         while ($counter<=$downloadpages ) {
  1012.             $cpage = $counter;
  1013.             $mintemp = ($perpage * $counter) - $perpage;
  1014.             if ($counter == $currentpage) {
  1015.         echo "<b>$counter</b> ";
  1016.         } else {
  1017.         echo "<a href=\"modules.php?name=$module_name&d_op=viewdownload&sid=$sid&min=$mintemp&orderby=$orderby&show=$show\">$counter</a> ";
  1018.         }
  1019.             $counter++;     
  1020.         }        
  1021.         $next=$min+$perpage;
  1022.         if ($x>=$perpage) {
  1023.             echo "  <b>[ <a href=\"modules.php?name=$module_name&d_op=viewdownload&sid=$sid&min=$max&orderby=$orderby&show=$show\">"
  1024.             ." "._NEXT." >></a> ]</b> ";
  1025.         }
  1026.     }
  1027.     echo "</td></tr></table>";
  1028.     CloseTable();
  1029.     include("footer.php");
  1030. }
  1031.  
  1032. function newdownloadgraphic($datetime, $time) {
  1033.     global $module_name;
  1034.     echo " ";
  1035.     setlocale (LC_TIME, $locale);
  1036.     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);  
  1037.     $datetime = strftime(""._LINKSDATESTRING."", mktime($datetime[4],$datetime[5],$datetime[6],$datetime[2],$datetime[3],$datetime[1]));
  1038.     $datetime = ucfirst($datetime);           
  1039.     $startdate = time();
  1040.     $count = 0;
  1041.     while ($count <= 7) {
  1042.     $daysold = date("d-M-Y", $startdate);
  1043.         if ("$daysold" == "$datetime") {
  1044.             if ($count<=1) {
  1045.         echo "<img src=\"modules/$module_name/images/new_1.gif\" alt=\""._NEWTODAY."\">";
  1046.         }
  1047.             if ($count<=3 && $count>1) {
  1048.         echo "<img src=\"modules/$module_name/images/new_3.gif\" alt=\""._NEWLAST3DAYS."\">";
  1049.         }
  1050.             if ($count<=7 && $count>3) {
  1051.         echo "<img src=\"modules/$module_name/images/new_7.gif\" alt=\""._NEWTHISWEEK."\">";
  1052.         }
  1053.     }
  1054.         $count++;
  1055.         $startdate = (time()-(86400 * $count));
  1056.     }
  1057. }
  1058.  
  1059. function categorynewdownloadgraphic($cat) {
  1060.     global $prefix, $db, $module_name;
  1061.     $cat = intval(trim($cat));
  1062.     $row = $db->sql_fetchrow($db->sql_query("SELECT date FROM ".$prefix."_downloads_downloads WHERE cid='$cat' order by date desc limit 1"));
  1063.     $time = $row['date'];
  1064.     echo " ";
  1065.     setlocale (LC_TIME, $locale);
  1066.     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);  
  1067.     $datetime = strftime(""._LINKSDATESTRING."", mktime($datetime[4],$datetime[5],$datetime[6],$datetime[2],$datetime[3],$datetime[1]));
  1068.     $datetime = ucfirst($datetime);           
  1069.     $startdate = time();
  1070.     $count = 0;
  1071.     while ($count <= 7) {
  1072.     $daysold = date("d-M-Y", $startdate);
  1073.         if ("$daysold" == "$datetime") {
  1074.             if ($count<=1) {
  1075.         echo "<img src=\"modules/$module_name/images/new_1.gif\" alt=\""._DCATNEWTODAY."\">";
  1076.         }
  1077.             if ($count<=3 && $count>1) {
  1078.         echo "<img src=\"modules/$module_name/images/new_3.gif\" alt=\""._DCATLAST3DAYS."\">";
  1079.         }
  1080.             if ($count<=7 && $count>3) {
  1081.         echo "<img src=\"modules/$module_name/images/new_7.gif\" alt=\""._DCATTHISWEEK."\">";
  1082.         }
  1083.     }
  1084.         $count++;
  1085.         $startdate = (time()-(86400 * $count));
  1086.     }
  1087. }
  1088.  
  1089. function popgraphic($hits) {
  1090.     global $module_name;
  1091.     include("modules/$module_name/d_config.php");
  1092.     if ($hits>=$popular) {
  1093.     echo " <img src=\"modules/$module_name/images/popular.gif\" alt=\""._POPULAR."\">";
  1094.     }
  1095. }
  1096.  
  1097. function convertorderbyin($orderby) {
  1098.     if ($orderby == "titleA")    $orderby = "title ASC";
  1099.     if ($orderby == "dateA")    $orderby = "date ASC";
  1100.     if ($orderby == "hitsA")    $orderby = "hits ASC";
  1101.     if ($orderby == "ratingA")    $orderby = "downloadratingsummary ASC";
  1102.     if ($orderby == "titleD")    $orderby = "title DESC"; 
  1103.     if ($orderby == "dateD")    $orderby = "date DESC";
  1104.     if ($orderby == "hitsD")    $orderby = "hits DESC";
  1105.     if ($orderby == "ratingD")    $orderby = "downloadratingsummary DESC";
  1106.     return $orderby;
  1107. }
  1108.  
  1109. function convertorderbytrans($orderby) {
  1110.     if ($orderby == "hits ASC")            $orderbyTrans = ""._POPULARITY1."";
  1111.     if ($orderby == "hits DESC")        $orderbyTrans = ""._POPULARITY2."";
  1112.     if ($orderby == "title ASC")        $orderbyTrans = ""._TITLEAZ."";
  1113.     if ($orderby == "title DESC")        $orderbyTrans = ""._TITLEZA."";
  1114.     if ($orderby == "date ASC")            $orderbyTrans = ""._DDATE1."";
  1115.     if ($orderby == "date DESC")        $orderbyTrans = ""._DDATE2."";
  1116.     if ($orderby == "downloadratingsummary ASC")    $orderbyTrans = ""._RATING1."";
  1117.     if ($orderby == "downloadratingsummary DESC")    $orderbyTrans = ""._RATING2."";
  1118.     return $orderbyTrans;
  1119. }
  1120.  
  1121. function convertorderbyout($orderby) {
  1122.     if ($orderby == "title ASC")        $orderby = "titleA";
  1123.     if ($orderby == "date ASC")            $orderby = "dateA";
  1124.     if ($orderby == "hits ASC")            $orderby = "hitsA";
  1125.     if ($orderby == "downloadratingsummary ASC")    $orderby = "ratingA";
  1126.     if ($orderby == "title DESC")        $orderby = "titleD";
  1127.     if ($orderby == "date DESC")        $orderby = "dateD";
  1128.     if ($orderby == "hits DESC")        $orderby = "hitsD";
  1129.     if ($orderby == "downloadratingsummary DESC")    $orderby = "ratingD";
  1130.     return $orderby;
  1131. }
  1132.  
  1133. function getit($lid) {
  1134.     global $prefix, $db;
  1135.     $lid = intval($lid);
  1136.     $db->sql_query("update ".$prefix."_downloads_downloads set hits=hits+1 WHERE lid='$lid'");
  1137.     $row = $db->sql_fetchrow($db->sql_query("SELECT url FROM ".$prefix."_downloads_downloads WHERE lid='$lid'"));
  1138.     $url = $row['url'];
  1139.     Header("Location: $url");
  1140. }
  1141.  
  1142. function search($query, $min, $orderby, $show) {
  1143.     global $prefix, $db, $admin, $bgcolor2, $module_name;
  1144.     include("modules/$module_name/d_config.php");
  1145.     include("header.php");
  1146.     if (!isset($min)) $min=0;
  1147.     if (!isset($max)) $max=$min+$downloadsresults;
  1148.     if(isset($orderby)) {
  1149.     $orderby = convertorderbyin($orderby);
  1150.     } else {
  1151.     $orderby = "title ASC";
  1152.     }
  1153.     if ($show!="") {
  1154.     $downloadsresults = $show;
  1155.     } else {
  1156.     $show=$downloadsresults;     
  1157.     }
  1158.     $query = check_html($query, nohtml);
  1159.     $query = addslashes($query);
  1160.     $orderby = trim($orderby);
  1161.     $result = $db->sql_query("SELECT lid, cid, title, url, description, date, hits, downloadratingsummary, totalvotes, totalcomments, filesize, version, homepage FROM ".$prefix."_downloads_downloads WHERE title LIKE '%$query%' OR description LIKE '%$query%' ORDER BY $orderby LIMIT $min,$downloadsresults");
  1162.     $fullcountresult = $db->sql_query("SELECT lid, title, description, date, hits, downloadratingsummary, totalvotes, totalcomments FROM ".$prefix."_downloads_downloads WHERE title LIKE '%$query%' OR description LIKE '%$query%'");
  1163.     $totalselecteddownloads = $db->sql_numrows($fullcountresult);
  1164.     $nrows = $db->sql_numrows($result);
  1165.     $x=0;
  1166.     $the_query = stripslashes($query);
  1167.     $the_query = str_replace("\'", "'", $the_query);
  1168.     menu(1);
  1169.     echo "<br>";
  1170.     OpenTable();
  1171.     if ($query != "") {
  1172.         if ($nrows>0) {
  1173.         echo "<font class=\"option\">"._SEARCHRESULTS4.": <b>$the_query</b></font><br><br>"
  1174.             ."<table width=\"100%\" bgcolor=\"$bgcolor2\"><tr><td><font class=\"option\"><b>"._USUBCATEGORIES."</b></font></td></tr></table>";
  1175.             $result2 = $db->sql_query("SELECT cid, title FROM ".$prefix."_downloads_categories WHERE title LIKE '%$query%' ORDER BY title DESC");
  1176.             while ($row2 = $db->sql_fetchrow($result2)) {
  1177.             $cid = intval($row2['cid']);
  1178.             $stitle = $row2['title'];
  1179.             $res = $db->sql_query("SELECT * FROM ".$prefix."_downloads_downloads WHERE cid='$cid'");
  1180.             $numrows = $db->sql_numrows($res);
  1181.                 $row3 = $db->sql_fetchrow($db->sql_query("SELECT cid,title,parentid FROM ".$prefix."_downloads_categories WHERE cid='$cid'"));
  1182.                 $cid3 = intval($row3['cid']);
  1183.                 $title3 = $row3['title'];
  1184.                 $parentid3 = intval($row3['parentid']);
  1185.                 if ($parentid3>0) $title3 = getparent($parentid3,$title3);
  1186.                 $title3 = ereg_replace($query, "<b>$query</b>", $title3);
  1187.                 echo "<strong><big>·</big></strong> <a href=\"modules.php?name=$module_name&d_op=viewdownload&cid=$cid\">$title3</a> ($numrows)<br>";
  1188.         }
  1189.         echo "<br><table width=\"100%\" bgcolor=\"$bgcolor2\"><tr><td><font class=\"option\"><b>"._UDOWNLOADS."</b></font></td></tr></table>";
  1190.             $orderbyTrans = convertorderbytrans($orderby);
  1191.             echo "<center><font class=\"content\">"._SORTDOWNLOADSBY.": "
  1192.             .""._TITLE." (<a href=\"modules.php?name=$module_name&d_op=search&query=$the_query&orderby=titleA\">A</a>\<a href=\"modules.php?name=$module_name&d_op=search&query=$the_query&orderby=titleD\">D</a>) "
  1193.             .""._DATE." (<a href=\"modules.php?name=$module_name&d_op=search&query=$the_query&orderby=dateA\">A</a>\<a href=\"modules.php?name=$module_name&d_op=search&query=$the_query&orderby=dateD\">D</a>) "
  1194.             .""._RATING." (<a href=\"modules.php?name=$module_name&d_op=search&query=$the_query&orderby=ratingA\">A</a>\<a href=\"modules.php?name=$module_name&d_op=search&query=$the_query&orderby=ratingD\">D</a>) "
  1195.             .""._POPULARITY." (<a href=\"modules.php?name=$module_name&d_op=search&query=$the_query&orderby=hitsA\">A</a>\<a href=\"modules.php?name=$module_name&d_op=search&query=$the_query&orderby=hitsD\">D</a>)"
  1196.             ."<br>"._RESSORTED.": $orderbyTrans</center><br><br><br>";
  1197.         while($row = $db->sql_fetchrow($result)) {
  1198.                 $lid = intval($row['lid']);
  1199.                 $cid = intval($row['cid']);
  1200.                 $title = stripslashes($row['title']);
  1201.                 $url = $row['url'];
  1202.                 $description = stripslashes($row['description']);
  1203.                 $time = $row['date'];
  1204.                 $hits = intval($row['hits']);
  1205.                 $downloadratingsummary = $row['downloadratingsummary'];
  1206.                 $totalvotes = intval($row['totalvotes']);
  1207.                 $totalcomments = $row['totalcomments'];
  1208.                 $filesize = $row['filesize'];
  1209.                 $version = $row['version'];
  1210.                 $homepage = $row['homepage'];
  1211.         $downloadratingsummary = number_format($downloadratingsummary, $mainvotedecimal);
  1212.         $transfertitle = str_replace (" ", "_", $title);
  1213.         $title = ereg_replace($query, "<b>$query</b>", $title);
  1214.         if (is_admin($admin)) {
  1215.             echo "<a href=\"admin.php?op=DownloadsModDownload&lid=$lid\"><img src=\"modules/$module_name/images/lwin.gif\" border=\"0\" alt=\""._EDIT."\"></a>  ";
  1216.         } else {
  1217.             echo "<img src=\"modules/$module_name/images/lwin.gif\" border=\"0\" alt=\"\">  ";
  1218.         }
  1219.         echo "<a href=\"modules.php?name=$module_name&d_op=getit&lid=$lid\">$title</a>";
  1220.         newdownloadgraphic($datetime, $time);      
  1221.             popgraphic($hits);
  1222.         detecteditorial($lid, $transfertitle, 1);
  1223.         echo "<br>";        
  1224.         $description = ereg_replace($query, "<b>$query</b>", $description);
  1225.         echo "<b>"._DESCRIPTION.":</b> $description<br>";
  1226.         setlocale (LC_TIME, $locale);
  1227.         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);
  1228.         $datetime = strftime(""._LINKSDATESTRING."", mktime($datetime[4],$datetime[5],$datetime[6],$datetime[2],$datetime[3],$datetime[1]));
  1229.         $datetime = ucfirst($datetime);
  1230.         echo "<b>"._VERSION.":</b> $version <b>"._FILESIZE.":</b> ".CoolSize($filesize)."<br>";
  1231.         echo "<b>"._ADDEDON.":</b> $datetime <b>"._UDOWNLOADSH.":</b> $hits";
  1232.             /* voting & comments stats */
  1233.             if ($totalvotes == 1) {
  1234.             $votestring = _VOTE;
  1235.         } else {
  1236.             $votestring = _VOTES;
  1237.         }
  1238.             if ($downloadratingsummary!="0" || $downloadratingsummary!="0.0") {
  1239.             echo " <b>"._RATING.":</b> $downloadratingsummary ($totalvotes $votestring)";
  1240.         }
  1241.             if ($homepage == "") {
  1242.             echo "<br>";
  1243.         } else {
  1244.             echo "<br><a href=\"$homepage\" target=\"new\">"._HOMEPAGE."</a> | ";
  1245.         }
  1246.             echo "<a href=\"modules.php?name=$module_name&d_op=ratedownload&lid=$lid&ttitle=$transfertitle\">"._RATERESOURCE."</a>";
  1247.         echo " | <a href=\"modules.php?name=$module_name&d_op=viewdownloaddetails&lid=$lid&ttitle=$transfertitle\">"._DETAILS."</a>";
  1248.             if ($totalcomments != 0) {
  1249.                 echo " | <a href=\"modules.php?name=$module_name&d_op=viewdownloadcomments&lid=$lid&ttitle=$transfertitle>"._SCOMMENTS." ($totalcomments)</a>";
  1250.         }
  1251.         detecteditorial($lid, $transfertitle, 0);
  1252.         echo "<br>";
  1253.         $row4 = $db->sql_fetchrow($db->sql_query("SELECT cid,title,parentid FROM ".$prefix."_downloads_categories WHERE cid='$cid'"));
  1254.         $cid3 = intval($row4['cid']);
  1255.         $title3 = $row4['title'];
  1256.         $parentid3 = intval($row4['parentid']);
  1257.         if ($parentid3>0) $title3 = getparent($parentid3,$title3);
  1258.         echo ""._CATEGORY.": $title3<br><br>";
  1259.         $x++;
  1260.         }
  1261.         echo "</font>";
  1262.             $orderby = convertorderbyout($orderby);
  1263.     } else {
  1264.         echo "<br><br><center><font class=\"option\"><b>"._NOMATCHES."</b></font><br><br>"._GOBACK."<br></center>";
  1265.     }
  1266.     /* Calculates how many pages exist.  Which page one should be on, etc... */
  1267.     $downloadpagesint = ($totalselecteddownloads / $downloadsresults);            
  1268.     $downloadpageremainder = ($totalselecteddownloads % $downloadsresults);        
  1269.     if ($downloadpageremainder != 0) {                     
  1270.         $downloadpages = ceil($downloadpagesint);                
  1271.         if ($totalselecteddownloads < $downloadsresults) {
  1272.             $downloadpageremainder = 0;
  1273.     }
  1274.     } else {
  1275.         $downloadpages = $downloadpagesint;
  1276.     }        
  1277.     /* Page Numbering */
  1278.     if ($downloadpages!=1 && $downloadpages!=0) {
  1279.     echo "<br><br>"
  1280.         .""._SELECTPAGE.": ";
  1281.     $prev=$min-$downloadsresults;
  1282.     if ($prev>=0) {
  1283.             echo "  <b>[ <a href=\"modules.php?name=$module_name&d_op=search&query=$the_query&min=$prev&orderby=$orderby&show=$show\">"
  1284.             ." << "._PREVIOUS."</a> ]</b> ";
  1285.           }
  1286.     $counter = 1;
  1287.         $currentpage = ($max / $downloadsresults);
  1288.         while ($counter<=$downloadpages ) {
  1289.             $cpage = $counter;
  1290.             $mintemp = ($perpage * $counter) - $downloadsresults;
  1291.             if ($counter == $currentpage) {
  1292.         echo "<b>$counter</b> ";
  1293.         } else {
  1294.         echo "<a href=\"modules.php?name=$module_name&d_op=search&query=$the_query&min=$mintemp&orderby=$orderby&show=$show\">$counter</a> ";
  1295.         }
  1296.             $counter++;     
  1297.         }        
  1298.         $next=$min+$downloadsresults;
  1299.         if ($x>=$perpage) {
  1300.             echo "  <b>[ <a href=\"modules.php?name=$module_name&d_op=search&query=$the_query&min=$max&orderby=$orderby&show=$show\">"
  1301.             ." "._NEXT." >></a> ]</b>";
  1302.         }
  1303.     }
  1304.     echo "<br><br><center><font class=\"content\">"
  1305.     .""._TRY2SEARCH." \"$the_query\" "._INOTHERSENGINES."<br>"
  1306.     ."<a target=\"_blank\" href=\"http://www.altavista.com/cgi-bin/query?pg=q&sc=on&hl=on&act=2006&par=0&q=$the_query&kl=XX&stype=stext\">Alta Vista</a> - "
  1307.     ."<a target=\"_blank\" href=\"http://www.hotbot.com/?MT=$the_query&DU=days&SW=web\">HotBot</a> - "
  1308.     ."<a target=\"_blank\" href=\"http://www.infoseek.com/Titles?qt=$the_query\">Infoseek</a> - "
  1309.     ."<a target=\"_blank\" href=\"http://www.dejanews.com/dnquery.xp?QRY=$the_query\">Deja News</a> - "
  1310.     ."<a target=\"_blank\" href=\"http://www.lycos.com/cgi-bin/pursuit?query=$the_query&maxhits=20\">Lycos</a> - "
  1311.     ."<a target=\"_blank\" href=\"http://search.yahoo.com/bin/search?p=$the_query\">Yahoo</a>"
  1312.     ."<br>"
  1313.     ."<a target=\"_blank\" href=\"http://es.linuxstart.com/cgi-bin/sqlsearch.cgi?pos=1&query=$the_query&language=&advanced=&urlonly=&withid=\">LinuxStart</a> - "
  1314.     ."<a target=\"_blank\" href=\"http://search.1stlinuxsearch.com/compass?scope=$the_query&ui=sr\">1stLinuxSearch</a> - "
  1315.     ."<a target=\"_blank\" href=\"http://www.google.com/search?q=$the_query\">Google</a> - "
  1316.     ."<a target=\"_blank\" href=\"http://www.linuxdownloads.com/cgi-bin/search.cgi?query=$the_query&engine=Downloads\">LinuxDownloads</a> - "
  1317.     ."<a target=\"_blank\" href=\"http://www.freshmeat.net/search/?q=$the_query&section=projects\">Freshmeat</a> - "
  1318.     ."<a target=\"_blank\" href=\"http://www.justlinux.com/bin/search.pl?key=$the_query\">JustLinux</a>"
  1319.     ."</font>";
  1320.     } else {
  1321.     echo "<center><font class=\"option\"><b>"._NOMATCHES."</b></font></center><br><br>";
  1322.     }
  1323.     CloseTable();
  1324.     include("footer.php");
  1325. }
  1326.  
  1327. function viewdownloadeditorial($lid, $ttitle) {
  1328.     global $prefix, $db, $admin, $module_name;
  1329.     include("header.php");
  1330.     include("modules/$module_name/d_config.php");
  1331.     menu(1);
  1332.     $lid = intval(trim($lid));
  1333.     $result = $db->sql_query("SELECT adminid, editorialtimestamp, editorialtext, editorialtitle FROM ".$prefix."_downloads_editorials WHERE downloadid = '$lid'");
  1334.     $recordexist = $db->sql_numrows($result);
  1335.     $transfertitle = ereg_replace ("_", " ", $ttitle);
  1336.     $displaytitle = $transfertitle;
  1337.     echo "<br>";
  1338.     OpenTable();
  1339.     echo "<center><font class=\"option\"><b>"._DOWNLOADPROFILE.": $displaytitle</b></font><br>";
  1340.     downloadinfomenu($lid, $ttitle); 
  1341.     if ($recordexist != 0) {
  1342.     while($row = $db->sql_fetchrow($result)) {
  1343.         $adminid = intval($row['adminid']);
  1344.         $editorialtimestamp = $row['editorialtimestamp'];
  1345.         $editorialtext = stripslashes($row['editorialtext']);
  1346.         $editorialtitle = stripslashes($row['editorialtitle']);
  1347.             ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $editorialtimestamp, $editorialtime);
  1348.         $editorialtime = strftime("%F",mktime($editorialtime[4],$editorialtime[5],$editorialtime[6],$editorialtime[2],$editorialtime[3],$editorialtime[1]));
  1349.         $date_array = explode("-", $editorialtime); 
  1350.         $timestamp = mktime(0, 0, 0, $date_array["1"], $date_array["2"], $date_array["0"]); 
  1351.                $formatted_date = date("F j, Y", $timestamp);
  1352.         echo "<br><br>";
  1353.            OpenTable2();
  1354.         echo "<center><font class=\"option\"><b>'$editorialtitle'</b></font></center>"
  1355.         ."<center><font class=\"tiny\">"._EDITORIALBY." $adminid - $formatted_date</font></center><br><br>"
  1356.         ."$editorialtext";
  1357.         CloseTable2();
  1358.         }
  1359.     } else {
  1360.         echo "<br><br><center><font class=\"option\"><b>"._NOEDITORIAL."</b></font></center>";
  1361.     }
  1362.     echo "<br><br><center>";
  1363.     downloadfooter($lid,$ttitle);
  1364.     echo "</center>";
  1365.     CloseTable();
  1366.     include("footer.php");
  1367. }
  1368.  
  1369. function detecteditorial($lid, $ttitle, $img) {
  1370.     global $prefix, $db, $module_name;
  1371.     $lid = intval($lid);
  1372.     $resulted2 = $db->sql_query("SELECT adminid FROM ".$prefix."_downloads_editorials WHERE downloadid='$lid'");
  1373.     $recordexist = $db->sql_numrows($resulted2);
  1374.     if ($recordexist != 0) {
  1375.     if ($img == 1) {
  1376.         echo "  <a href=\"modules.php?name=$module_name&d_op=viewdownloadeditorial&lid=$lid&ttitle=$ttitle\"><img src=\"modules/$module_name/images/cool.gif\" alt=\""._EDITORIAL."\" border=\"0\"></a>";
  1377.     } else {
  1378.         echo " | <a href=\"modules.php?name=$module_name&d_op=viewdownloadeditorial&lid=$lid&ttitle=$ttitle\">"._EDITORIAL."</a>";
  1379.     }
  1380.     }
  1381. }
  1382.  
  1383. function viewdownloadcomments($lid, $ttitle) {
  1384.     global $prefix, $db, $admin, $bgcolor2, $module_name;
  1385.     include("header.php");
  1386.     include("modules/$module_name/d_config.php");
  1387.     menu(1);
  1388.     echo "<br>";
  1389.     $lid = intval(trim($lid));
  1390.     $result = $db->sql_query("SELECT ratinguser, rating, ratingcomments, ratingtimestamp FROM ".$prefix."_downloads_votedata WHERE ratinglid = '$lid' AND ratingcomments != '' ORDER BY ratingtimestamp DESC");
  1391.     $totalcomments = $db->sql_numrows($result);
  1392.     $transfertitle = ereg_replace ("_", " ", $ttitle);
  1393.     $displaytitle = $transfertitle;
  1394.     OpenTable();
  1395.     echo "<center><font class=\"option\"><b>"._DOWNLOADPROFILE.": $displaytitle</b></font><br><br>";
  1396.     downloadinfomenu($lid, $ttitle); 
  1397.     echo "<br><br><br>"._TOTALOF." $totalcomments "._COMMENTS."</font></center><br>"
  1398.     ."<table align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\" width=\"450\">";
  1399.     $x=0;
  1400.     while($row = $db->sql_fetchrow($result)) {
  1401.         $ratinguser = $row['ratinguser'];
  1402.         $rating = intval($row['rating']);
  1403.         $ratingcomments = $row['ratingcomments'];
  1404.         $ratingtimestamp = $row['ratingtimestamp'];
  1405.         ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $ratingtimestamp, $ratingtime);
  1406.     $ratingtime = strftime("%F",mktime($ratingtime[4],$ratingtime[5],$ratingtime[6],$ratingtime[2],$ratingtime[3],$ratingtime[1]));
  1407.     $date_array = explode("-", $ratingtime); 
  1408.     $timestamp = mktime(0, 0, 0, $date_array["1"], $date_array["2"], $date_array["0"]); 
  1409.         $formatted_date = date("F j, Y", $timestamp); 
  1410.     /* Individual user information */
  1411.     $result2 = $db->sql_query("SELECT rating FROM ".$prefix."_downloads_votedata WHERE ratinguser = '$ratinguser'");
  1412.         $usertotalcomments = $db->sql_numrows($result2);
  1413.         $useravgrating = 0;
  1414.     while($row2 = $db->sql_fetchrow($result2)) {
  1415.         $rating2 = intval($row2['rating']);
  1416.     $useravgrating = $useravgrating + $rating2;
  1417.         $useravgrating = $useravgrating / $usertotalcomments;
  1418.         $useravgrating = number_format($useravgrating, 1);
  1419.         echo "<tr><td bgcolor=\"$bgcolor2\">"
  1420.             ."<font class=\"content\"><b> "._USER.": </b><a href=\"$nukeurl/modules.php?name=Your_Account&op=userinfo&username=$ratinguser\">$ratinguser</a></font>"
  1421.         ."</td>"
  1422.         ."<td bgcolor=\"$bgcolor2\">"
  1423.         ."<font class=\"content\"><b>"._RATING.": </b>$rating</font>"
  1424.         ."</td>"
  1425.         ."<td bgcolor=\"$bgcolor2\" align=\"right\">"
  1426.             ."<font class=\"content\">$formatted_date</font>"
  1427.         ."</td>"
  1428.         ."</tr>"
  1429.         ."<tr>"
  1430.         ."<td valign=\"top\">"
  1431.         ."<font class=\"tiny\">"._USERAVGRATING.": $useravgrating</font>"
  1432.         ."</td>"
  1433.         ."<td valign=\"top\" colspan=\"2\">"
  1434.         ."<font class=\"tiny\">"._NUMRATINGS.": $usertotalcomments</font>"
  1435.         ."</td>"
  1436.         ."</tr>"
  1437.             ."<tr>"
  1438.         ."<td colspan=\"3\">"
  1439.         ."<font class=\"content\">";
  1440.         if (is_admin($admin)) {
  1441.         echo "<a href=\"admin.php?op=DownloadsModDownload&lid=$lid\"><img src=\"modules/$module_name/images/editicon.gif\" border=\"0\" alt=\""._EDITTHISDOWNLOAD."\"></a>";
  1442.         }    
  1443.     echo " $ratingcomments</font>"
  1444.         ."<br><br><br></td></tr>";        
  1445.     $x++;
  1446.         }
  1447.     }
  1448.     echo "</table><br><br><center>";
  1449.     downloadfooter($lid,$ttitle);
  1450.     echo "</center>";
  1451.     CloseTable();
  1452.     include("footer.php");
  1453. }
  1454.  
  1455. function viewdownloaddetails($lid, $ttitle) {
  1456.     global $prefix, $db, $admin, $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4, $module_name;
  1457.     include("header.php");
  1458.     include("modules/$module_name/d_config.php");
  1459.     menu(1);
  1460.     $lid = intval($lid);
  1461.     $voteresult = $db->sql_query("SELECT rating, ratinguser, ratingcomments FROM ".$prefix."_downloads_votedata WHERE ratinglid = '$lid'");
  1462.     $totalvotesDB = $db->sql_numrows($voteresult);
  1463.     $anonvotes = 0;
  1464.     $anonvoteval = 0;
  1465.     $outsidevotes = 0;
  1466.     $outsidevoteeval = 0;
  1467.     $regvoteval = 0;
  1468.     $topanon = 0;
  1469.     $bottomanon = 11;
  1470.     $topreg = 0;
  1471.     $bottomreg = 11;
  1472.     $topoutside = 0;
  1473.     $bottomoutside = 11;
  1474.     $avv = array(0,0,0,0,0,0,0,0,0,0,0);
  1475.     $rvv = array(0,0,0,0,0,0,0,0,0,0,0);
  1476.     $ovv = array(0,0,0,0,0,0,0,0,0,0,0);
  1477.     $truecomments = $totalvotesDB;
  1478.     while($row = $db->sql_fetchrow($voteresult)) {
  1479.      $ratingDB = intval($row['rating']);
  1480.      $ratinguserDB = $row['ratinguser'];
  1481.      $ratingcommentsDB = $row['ratingcomments'];
  1482.      if ($ratingcommentsDB=="") $truecomments--;
  1483.         if ($ratinguserDB==$anonymous) {
  1484.         $anonvotes++;
  1485.         $anonvoteval += $ratingDB;
  1486.     }
  1487.     if ($useoutsidevoting == 1) {
  1488.         if ($ratinguserDB=='outside') {
  1489.         $outsidevotes++;
  1490.             $outsidevoteval += $ratingDB;
  1491.         }
  1492.     } else {
  1493.         $outsidevotes = 0;
  1494.     }
  1495.     if ($ratinguserDB!=$anonymous && $ratinguserDB!="outside") {
  1496.         $regvoteval += $ratingDB;
  1497.     }
  1498.     if ($ratinguserDB!=$anonymous && $ratinguserDB!="outside") {
  1499.         if ($ratingDB > $topreg) $topreg = $ratingDB;
  1500.         if ($ratingDB < $bottomreg) $bottomreg = $ratingDB;
  1501.         for ($rcounter=1; $rcounter<11; $rcounter++) if ($ratingDB==$rcounter) $rvv[$rcounter]++;
  1502.     }
  1503.     if ($ratinguserDB==$anonymous) {
  1504.         if ($ratingDB > $topanon) $topanon = $ratingDB;
  1505.         if ($ratingDB < $bottomanon) $bottomanon = $ratingDB;
  1506.         for ($rcounter=1; $rcounter<11; $rcounter++) if ($ratingDB==$rcounter) $avv[$rcounter]++;
  1507.     }
  1508.     if ($ratinguserDB=="outside") {
  1509.         if ($ratingDB > $topoutside) $topoutside = $ratingDB;
  1510.         if ($ratingDB < $bottomoutside) $bottomoutside = $ratingDB;
  1511.         for ($rcounter=1; $rcounter<11; $rcounter++) if ($ratingDB==$rcounter) $ovv[$rcounter]++;
  1512.     }
  1513.     }
  1514.     $regvotes = $totalvotesDB - $anonvotes - $outsidevotes;
  1515.     if ($totalvotesDB == 0) {
  1516.     $finalrating = 0;
  1517.     } else if ($anonvotes == 0 && $regvotes == 0) {
  1518.     /* Figure Outside Only Vote */
  1519.     $finalrating = $outsidevoteval / $outsidevotes;
  1520.     $finalrating = number_format($finalrating, $detailvotedecimal);
  1521.     $avgOU = $outsidevoteval / $totalvotesDB;
  1522.     $avgOU = number_format($avgOU, $detailvotedecimal);
  1523.     } else if ($outsidevotes == 0 && $regvotes == 0) {
  1524.      /* Figure Anon Only Vote */
  1525.     $finalrating = $anonvoteval / $anonvotes;
  1526.     $finalrating = number_format($finalrating, $detailvotedecimal);
  1527.     $avgAU = $anonvoteval / $totalvotesDB;
  1528.     $avgAU = number_format($avgAU, $detailvotedecimal);
  1529.     } else if ($outsidevotes == 0 && $anonvotes == 0) {
  1530.     /* Figure Reg Only Vote */
  1531.     $finalrating = $regvoteval / $regvotes;
  1532.     $finalrating = number_format($finalrating, $detailvotedecimal);
  1533.     $avgRU = $regvoteval / $totalvotesDB;
  1534.     $avgRU = number_format($avgRU, $detailvotedecimal);
  1535.     } else if ($regvotes == 0 && $useoutsidevoting == 1 && $outsidevotes != 0 && $anonvotes != 0 ) {
  1536.      /* Figure Reg and Anon Mix */
  1537.      $avgAU = $anonvoteval / $anonvotes;
  1538.     $avgOU = $outsidevoteval / $outsidevotes;
  1539.     if ($anonweight > $outsideweight ) {
  1540.         /* Anon is 'standard weight' */
  1541.         $newimpact = $anonweight / $outsideweight;
  1542.         $impactAU = $anonvotes;
  1543.         $impactOU = $outsidevotes / $newimpact;
  1544.         $finalrating = ((($avgOU * $impactOU) + ($avgAU * $impactAU)) / ($impactAU + $impactOU));
  1545.         $finalrating = number_format($finalrating, $detailvotedecimal);
  1546.     } else {
  1547.         /* Outside is 'standard weight' */
  1548.         $newimpact = $outsideweight / $anonweight;
  1549.         $impactOU = $outsidevotes;
  1550.         $impactAU = $anonvotes / $newimpact;
  1551.         $finalrating = ((($avgOU * $impactOU) + ($avgAU * $impactAU)) / ($impactAU + $impactOU));
  1552.         $finalrating = number_format($finalrating, $detailvotedecimal);
  1553.     }
  1554.     } else {
  1555.          /* REG User vs. Anonymous vs. Outside User Weight Calutions */
  1556.          $impact = $anonweight;
  1557.          $outsideimpact = $outsideweight;
  1558.          if ($regvotes == 0) {
  1559.         $avgRU = 0;
  1560.     } else {
  1561.         $avgRU = $regvoteval / $regvotes;
  1562.     }
  1563.     if ($anonvotes == 0) {
  1564.         $avgAU = 0;
  1565.     } else {
  1566.         $avgAU = $anonvoteval / $anonvotes;
  1567.     }
  1568.     if ($outsidevotes == 0 ) {
  1569.         $avgOU = 0;
  1570.     } else {
  1571.         $avgOU = $outsidevoteval / $outsidevotes;
  1572.     }
  1573.     $impactRU = $regvotes;
  1574.     $impactAU = $anonvotes / $impact;
  1575.     $impactOU = $outsidevotes / $outsideimpact;
  1576.     $finalrating = (($avgRU * $impactRU) + ($avgAU * $impactAU) + ($avgOU * $impactOU)) / ($impactRU + $impactAU + $impactOU);
  1577.     $finalrating = number_format($finalrating, $detailvotedecimal);
  1578.     }
  1579.     if ($avgOU == 0 || $avgOU == "") {
  1580.     $avgOU = "";
  1581.     } else {
  1582.     $avgOU = number_format($avgOU, $detailvotedecimal);
  1583.     }
  1584.     if ($avgRU == 0 || $avgRU == "") {
  1585.     $avgRU = "";
  1586.     } else {
  1587.     $avgRU = number_format($avgRU, $detailvotedecimal);
  1588.     }
  1589.     if ($avgAU == 0 || $avgAU == "") {
  1590.     $avgAU = "";
  1591.     } else {
  1592.     $avgAU = number_format($avgAU, $detailvotedecimal);
  1593.     }
  1594.     if ($topanon == 0) $topanon = "";
  1595.     if ($bottomanon == 11) $bottomanon = "";
  1596.     if ($topreg == 0) $topreg = "";
  1597.     if ($bottomreg == 11) $bottomreg = "";
  1598.     if ($topoutside == 0) $topoutside = "";
  1599.     if ($bottomoutside == 11) $bottomoutside = "";
  1600.     $totalchartheight = 70;
  1601.     $chartunits = $totalchartheight / 10;
  1602.     $avvper        = array(0,0,0,0,0,0,0,0,0,0,0);
  1603.     $rvvper         = array(0,0,0,0,0,0,0,0,0,0,0);
  1604.     $ovvper         = array(0,0,0,0,0,0,0,0,0,0,0);
  1605.     $avvpercent     = array(0,0,0,0,0,0,0,0,0,0,0);
  1606.     $rvvpercent     = array(0,0,0,0,0,0,0,0,0,0,0);
  1607.     $ovvpercent     = array(0,0,0,0,0,0,0,0,0,0,0);
  1608.     $avvchartheight    = array(0,0,0,0,0,0,0,0,0,0,0);
  1609.     $rvvchartheight    = array(0,0,0,0,0,0,0,0,0,0,0);
  1610.     $ovvchartheight    = array(0,0,0,0,0,0,0,0,0,0,0);
  1611.     $avvmultiplier = 0;
  1612.     $rvvmultiplier = 0;
  1613.     $ovvmultiplier = 0;
  1614.     for ($rcounter=1; $rcounter<11; $rcounter++) {
  1615.         if ($anonvotes != 0) $avvper[$rcounter] = $avv[$rcounter] / $anonvotes;
  1616.         if ($regvotes != 0) $rvvper[$rcounter] = $rvv[$rcounter] / $regvotes;
  1617.         if ($outsidevotes != 0) $ovvper[$rcounter] = $ovv[$rcounter] / $outsidevotes;
  1618.         $avvpercent[$rcounter] = number_format($avvper[$rcounter] * 100, 1);
  1619.         $rvvpercent[$rcounter] = number_format($rvvper[$rcounter] * 100, 1);
  1620.         $ovvpercent[$rcounter] = number_format($ovvper[$rcounter] * 100, 1);
  1621.         if ($avv[$rcounter] > $avvmultiplier) $avvmultiplier = $avv[$rcounter];
  1622.         if ($rvv[$rcounter] > $rvvmultiplier) $rvvmultiplier = $rvv[$rcounter];
  1623.         if ($ovv[$rcounter] > $ovvmultiplier) $ovvmultiplier = $ovv[$rcounter];
  1624.     }
  1625.     if ($avvmultiplier != 0) $avvmultiplier = 10 / $avvmultiplier;
  1626.     if ($rvvmultiplier != 0) $rvvmultiplier = 10 / $rvvmultiplier;
  1627.     if ($ovvmultiplier != 0) $ovvmultiplier = 10 / $ovvmultiplier;
  1628.     for ($rcounter=1; $rcounter<11; $rcounter++) {
  1629.         $avvchartheight[$rcounter] = ($avv[$rcounter] * $avvmultiplier) * $chartunits;
  1630.         $rvvchartheight[$rcounter] = ($rvv[$rcounter] * $rvvmultiplier) * $chartunits;
  1631.         $ovvchartheight[$rcounter] = ($ovv[$rcounter] * $ovvmultiplier) * $chartunits;
  1632.         if ($avvchartheight[$rcounter]==0) $avvchartheight[$rcounter]=1;
  1633.         if ($rvvchartheight[$rcounter]==0) $rvvchartheight[$rcounter]=1;
  1634.         if ($ovvchartheight[$rcounter]==0) $ovvchartheight[$rcounter]=1;
  1635.     }
  1636.     $transfertitle = ereg_replace ("_", " ", $ttitle);
  1637.     $displaytitle = $transfertitle;
  1638.     $row_res = $db->sql_fetchrow($db->sql_query("SELECT name, email, description, filesize, version, homepage FROM ".$prefix."_downloads_downloads WHERE lid='$lid'"));
  1639.     $auth_name = $row_res['name'];
  1640.     $email = $row_res['email'];
  1641.     $description = stripslashes($row_res['description']);
  1642.     $filesize = $row_res['filesize'];
  1643.     $version = $row_res['version'];
  1644.     $homepage = $row_res['homepage'];
  1645.     echo "<br>";
  1646.     OpenTable();
  1647.     echo "<center><font class=\"option\"><b>"._DOWNLOADPROFILE.": $displaytitle</b></font><br><br>";
  1648.     downloadinfomenu($lid, $ttitle); 
  1649.     echo "<br><br>"._DOWNLOADRATINGDET."<br>"
  1650.         .""._TOTALVOTES." $totalvotesDB<br>"
  1651.         .""._OVERALLRATING.": $finalrating<br><br>"
  1652.     ."<font class=\"content\">$description<br>";
  1653.     if ($auth_name == "") {
  1654.     $auth_name = "<i>"._UNKNOWN."</i>";
  1655.     } else {
  1656.     if ($email == "") {
  1657.         $auth_name = "$auth_name";
  1658.     } else {
  1659.         $email = ereg_replace("@"," <i>"._DLAT."</i> ",$email);
  1660.         $email = ereg_replace("\."," <i>"._DLDOT."</i> ",$email);
  1661.         $auth_name = "$auth_name ($email)";
  1662.     }
  1663.     }
  1664.     echo "<br><b>"._AUTHOR.":</b> $auth_name<br>"
  1665.     ."<b>"._VERSION.":</b> $version <b>"._FILESIZE.":</b> ".CoolSize($filesize)."</font><br><br>"
  1666.     ."[ <b><a href=\"modules.php?name=$module_name&d_op=getit&lid=$lid\">"._DOWNLOADNOW."</a></b> ";
  1667.     if (($homepage == "") OR ($homepage == "http://")) {
  1668.     echo "]<br><br>";
  1669.     } else {
  1670.     echo "| <a href=\"$homepage\" target=\"new\">"._HOMEPAGE."</a> ]<br><br>";
  1671.     }
  1672.     echo "<table align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\" width=\"455\">"
  1673.     ."<tr><td colspan=\"2\" bgcolor=\"$bgcolor2\">"
  1674.     ."<font class=\"content\"><b>"._REGISTEREDUSERS."</b></font>"
  1675.     ."</td></tr>"
  1676.     ."<tr>"
  1677.     ."<td bgcolor=\"$bgcolor1\">"
  1678.         ."<font class=\"content\">"._NUMBEROFRATINGS.": $regvotes</font>"
  1679.     ."</td>"
  1680.     ."<td rowspan=\"5\" width=\"200\">";
  1681.     if ($regvotes==0) {
  1682.     echo "<center><font class=\"content\">"._NOREGUSERSVOTES."</font></center>";
  1683.     } else {
  1684.            echo "<table border=\"1\" width=\"200\">"
  1685.             ."<tr>"
  1686.         ."<td valign=\"top\" align=\"center\" colspan=\"10\" bgcolor=\"$bgcolor2\"><font class=\"content\">"._BREAKDOWNBYVAL."</font></td>"
  1687.         ."</tr>"
  1688.         ."<tr>"
  1689.         ."<td bgcolor=\"$bgcolor1\" valign=\"bottom\"><img border=\"0\" alt=\"$rvv[1] "._LVOTES." ($rvvpercent[1]% "._LTOTALVOTES.")\" src=\"images/blackpixel.gif\" width=\"15\" height=\"$rvvchartheight[1]\"></td>"
  1690.         ."<td bgcolor=\"$bgcolor1\" valign=\"bottom\"><img border=\"0\" alt=\"$rvv[2] "._LVOTES." ($rvvpercent[2]% "._LTOTALVOTES.")\" src=\"images/blackpixel.gif\" width=\"15\" height=\"$rvvchartheight[2]\"></td>"
  1691.         ."<td bgcolor=\"$bgcolor1\" valign=\"bottom\"><img border=\"0\" alt=\"$rvv[3] "._LVOTES." ($rvvpercent[3]% "._LTOTALVOTES.")\" src=\"images/blackpixel.gif\" width=\"15\" height=\"$rvvchartheight[3]\"></td>"
  1692.         ."<td bgcolor=\"$bgcolor1\" valign=\"bottom\"><img border=\"0\" alt=\"$rvv[4] "._LVOTES." ($rvvpercent[4]% "._LTOTALVOTES.")\" src=\"images/blackpixel.gif\" width=\"15\" height=\"$rvvchartheight[4]\"></td>"
  1693.         ."<td bgcolor=\"$bgcolor1\" valign=\"bottom\"><img border=\"0\" alt=\"$rvv[5] "._LVOTES." ($rvvpercent[5]% "._LTOTALVOTES.")\" src=\"images/blackpixel.gif\" width=\"15\" height=\"$rvvchartheight[5]\"></td>"
  1694.         ."<td bgcolor=\"$bgcolor1\" valign=\"bottom\"><img border=\"0\" alt=\"$rvv[6] "._LVOTES." ($rvvpercent[6]% "._LTOTALVOTES.")\" src=\"images/blackpixel.gif\" width=\"15\" height=\"$rvvchartheight[6]\"></td>"
  1695.         ."<td bgcolor=\"$bgcolor1\" valign=\"bottom\"><img border=\"0\" alt=\"$rvv[7] "._LVOTES." ($rvvpercent[7]% "._LTOTALVOTES.")\" src=\"images/blackpixel.gif\" width=\"15\" height=\"$rvvchartheight[7]\"></td>"
  1696.         ."<td bgcolor=\"$bgcolor1\" valign=\"bottom\"><img border=\"0\" alt=\"$rvv[8] "._LVOTES." ($rvvpercent[8]% "._LTOTALVOTES.")\" src=\"images/blackpixel.gif\" width=\"15\" height=\"$rvvchartheight[8]\"></td>"
  1697.         ."<td bgcolor=\"$bgcolor1\" valign=\"bottom\"><img border=\"0\" alt=\"$rvv[9] "._LVOTES." ($rvvpercent[9]% "._LTOTALVOTES.")\" src=\"images/blackpixel.gif\" width=\"15\" height=\"$rvvchartheight[9]\"></td>"
  1698.         ."<td bgcolor=\"$bgcolor1\" valign=\"bottom\"><img border=\"0\" alt=\"$rvv[10] "._LVOTES." ($rvvpercent[10]% "._LTOTALVOTES.")\" src=\"images/blackpixel.gif\" width=\"15\" height=\"$rvvchartheight[10]\"></td>"
  1699.         ."</tr>"
  1700.         ."<tr><td colspan=\"10\" bgcolor=\"$bgcolor2\">"
  1701.         ."<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"200\"><tr>"
  1702.         ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">1</font></td>"
  1703.         ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">2</font></td>"
  1704.         ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">3</font></td>"
  1705.         ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">4</font></td>"
  1706.         ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">5</font></td>"
  1707.         ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">6</font></td>"
  1708.         ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">7</font></td>"
  1709.         ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">8</font></td>"
  1710.         ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">9</font></td>"
  1711.         ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">10</font></td>"
  1712.         ."</tr></table>"
  1713.         ."</td></tr></table>";
  1714.     }
  1715.     echo "</td>"
  1716.     ."</tr>"
  1717.     ."<tr><td bgcolor=\"$bgcolor2\"><font class=\"content\">"._DOWNLOADRATING.": $avgRU</font></td></tr>"
  1718.     ."<tr><td bgcolor=\"$bgcolor1\"><font class=\"content\">"._HIGHRATING.": $topreg</font></td></tr>"
  1719.     ."<tr><td bgcolor=\"$bgcolor2\"><font class=\"content\">"._LOWRATING.": $bottomreg</font></td></tr>"
  1720.     ."<tr><td bgcolor=\"$bgcolor1\"><font class=\"content\">"._NUMOFCOMMENTS.": $truecomments</font></td></tr>"
  1721.     ."<tr><td></td></tr>"
  1722.     ."<tr><td valign=\"top\" colspan=\"2\"><font class=\"tiny\"><br><br>"._WEIGHNOTE." $anonweight "._TO." 1.</font></td></tr>"
  1723.         ."<tr><td colspan=\"2\" bgcolor=\"$bgcolor2\"><font class=\"content\"><b>"._UNREGISTEREDUSERS."</b></font></td></tr>"
  1724.     ."<tr><td bgcolor=\"$bgcolor1\"><font class=\"content\">"._NUMBEROFRATINGS.": $anonvotes</font></td>"
  1725.     ."<td rowspan=\"5\" width=\"200\">";
  1726.     if ($anonvotes==0) {
  1727.     echo "<center><font class=\"content\">"._NOUNREGUSERSVOTES."</font></center>";
  1728.     } else {
  1729.         echo "<table border=\"1\" width=\"200\">"
  1730.             ."<tr>"
  1731.         ."<td valign=\"top\" align=\"center\" colspan=\"10\" bgcolor=\"$bgcolor2\"><font class=\"content\">"._BREAKDOWNBYVAL."</font></td>"
  1732.         ."</tr>"
  1733.         ."<tr>"
  1734.         ."<td bgcolor=\"$bgcolor1\" valign=\"bottom\"><img border=\"0\" alt=\"$avv[1] "._LVOTES." ($avvpercent[1]% "._LTOTALVOTES.")\" src=\"images/blackpixel.gif\" width=\"15\" height=\"$avvchartheight[1]\"></td>"
  1735.         ."<td bgcolor=\"$bgcolor1\" valign=\"bottom\"><img border=\"0\" alt=\"$avv[2] "._LVOTES." ($avvpercent[2]% "._LTOTALVOTES.")\" src=\"images/blackpixel.gif\" width=\"15\" height=\"$avvchartheight[2]\"></td>"
  1736.         ."<td bgcolor=\"$bgcolor1\" valign=\"bottom\"><img border=\"0\" alt=\"$avv[3] "._LVOTES." ($avvpercent[3]% "._LTOTALVOTES.")\" src=\"images/blackpixel.gif\" width=\"15\" height=\"$avvchartheight[3]\"></td>"
  1737.         ."<td bgcolor=\"$bgcolor1\" valign=\"bottom\"><img border=\"0\" alt=\"$avv[4] "._LVOTES." ($avvpercent[4]% "._LTOTALVOTES.")\" src=\"images/blackpixel.gif\" width=\"15\" height=\"$avvchartheight[4]\"></td>"
  1738.         ."<td bgcolor=\"$bgcolor1\" valign=\"bottom\"><img border=\"0\" alt=\"$avv[5] "._LVOTES." ($avvpercent[5]% "._LTOTALVOTES.")\" src=\"images/blackpixel.gif\" width=\"15\" height=\"$avvchartheight[5]\"></td>"
  1739.         ."<td bgcolor=\"$bgcolor1\" valign=\"bottom\"><img border=\"0\" alt=\"$avv[6] "._LVOTES." ($avvpercent[6]% "._LTOTALVOTES.")\" src=\"images/blackpixel.gif\" width=\"15\" height=\"$avvchartheight[6]\"></td>"
  1740.         ."<td bgcolor=\"$bgcolor1\" valign=\"bottom\"><img border=\"0\" alt=\"$avv[7] "._LVOTES." ($avvpercent[7]% "._LTOTALVOTES.")\" src=\"images/blackpixel.gif\" width=\"15\" height=\"$avvchartheight[7]\"></td>"
  1741.         ."<td bgcolor=\"$bgcolor1\" valign=\"bottom\"><img border=\"0\" alt=\"$avv[8] "._LVOTES." ($avvpercent[8]% "._LTOTALVOTES.")\" src=\"images/blackpixel.gif\" width=\"15\" height=\"$avvchartheight[8]\"></td>"
  1742.         ."<td bgcolor=\"$bgcolor1\" valign=\"bottom\"><img border=\"0\" alt=\"$avv[9] "._LVOTES." ($avvpercent[9]% "._LTOTALVOTES.")\" src=\"images/blackpixel.gif\" width=\"15\" height=\"$avvchartheight[9]\"></td>"
  1743.         ."<td bgcolor=\"$bgcolor1\" valign=\"bottom\"><img border=\"0\" alt=\"$avv[10] "._LVOTES." ($avvpercent[10]% "._LTOTALVOTES.")\" src=\"images/blackpixel.gif\" width=\"15\" height=\"$avvchartheight[10]\"></td>"
  1744.         ."</tr>"
  1745.         ."<tr><td colspan=\"10\" bgcolor=\"$bgcolor2\">"
  1746.         ."<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"200\"><tr>"
  1747.         ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">1</font></td>"
  1748.         ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">2</font></td>"
  1749.         ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">3</font></td>"
  1750.         ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">4</font></td>"
  1751.         ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">5</font></td>"
  1752.         ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">6</font></td>"
  1753.         ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">7</font></td>"
  1754.         ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">8</font></td>"
  1755.         ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">9</font></td>"
  1756.         ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">10</font></td>"
  1757.         ."</tr></table>"
  1758.         ."</td></tr></table>";
  1759.     }
  1760.     echo "</td>"
  1761.     ."</tr>"
  1762.     ."<tr><td bgcolor=\"$bgcolor2\"><font class=\"content\">"._DOWNLOADRATING.": $avgAU</font></td></tr>"
  1763.     ."<tr><td bgcolor=\"$bgcolor1\"><font class=\"content\">"._HIGHRATING.": $topanon</font></td></tr>"
  1764.     ."<tr><td bgcolor=\"$bgcolor2\"><font class=\"content\">"._LOWRATING.": $bottomanon</font></td></tr>"
  1765.     ."<tr><td bgcolor=\"$bgcolor1\"><font class=\"content\"> </font></td></tr>";
  1766.     if ($useoutsidevoting == 1) {
  1767.     echo "<tr><td valign=top colspan=\"2\"><font class=\"tiny\"><br><br>"._WEIGHOUTNOTE." $outsideweight "._TO." 1.</font></td></tr>"
  1768.         ."<tr><td colspan=\"2\" bgcolor=\"$bgcolor2\"><font class=\"content\"><b>"._OUTSIDEVOTERS."</b></font></td></tr>"
  1769.         ."<tr><td bgcolor=\"$bgcolor1\"><font class=\"content\">"._NUMBEROFRATINGS.": $outsidevotes</font></td>"
  1770.         ."<td rowspan=\"5\" width=\"200\">";
  1771.         if ($outsidevotes==0) {
  1772.         echo "<center><font class=\"content\">"._NOOUTSIDEVOTES."</font></center>";
  1773.     } else {
  1774.         echo "<table border=\"1\" width=\"200\">"
  1775.             ."<tr>"
  1776.           ."<td valign=\"top\" align=\"center\" colspan=\"10\" bgcolor=\"$bgcolor2\"><font class=\"content\">"._BREAKDOWNBYVAL."</font></td>"
  1777.           ."</tr>"
  1778.           ."<tr>"
  1779.           ."<td bgcolor=\"$bgcolor1\" valign=\"bottom\"><img border=\"0\" alt=\"$ovv[1] "._LVOTES." ($ovvpercent[1]% "._LTOTALVOTES.")\" src=\"images/blackpixel.gif\" width=\"15\" height=\"$ovvchartheight[1]\"></td>"
  1780.           ."<td bgcolor=\"$bgcolor1\" valign=\"bottom\"><img border=\"0\" alt=\"$ovv[2] "._LVOTES." ($ovvpercent[2]% "._LTOTALVOTES.")\" src=\"images/blackpixel.gif\" width=\"15\" height=\"$ovvchartheight[2]\"></td>"
  1781.           ."<td bgcolor=\"$bgcolor1\" valign=\"bottom\"><img border=\"0\" alt=\"$ovv[3] "._LVOTES." ($ovvpercent[3]% "._LTOTALVOTES.")\" src=\"images/blackpixel.gif\" width=\"15\" height=\"$ovvchartheight[3]\"></td>"
  1782.           ."<td bgcolor=\"$bgcolor1\" valign=\"bottom\"><img border=\"0\" alt=\"$ovv[4] "._LVOTES." ($ovvpercent[4]% "._LTOTALVOTES.")\" src=\"images/blackpixel.gif\" width=\"15\" height=\"$ovvchartheight[4]\"></td>"
  1783.           ."<td bgcolor=\"$bgcolor1\" valign=\"bottom\"><img border=\"0\" alt=\"$ovv[5] "._LVOTES." ($ovvpercent[5]% "._LTOTALVOTES.")\" src=\"images/blackpixel.gif\" width=\"15\" height=\"$ovvchartheight[5]\"></td>"
  1784.           ."<td bgcolor=\"$bgcolor1\" valign=\"bottom\"><img border=\"0\" alt=\"$ovv[6] "._LVOTES." ($ovvpercent[6]% "._LTOTALVOTES.")\" src=\"images/blackpixel.gif\" width=\"15\" height=\"$ovvchartheight[6]\"></td>"
  1785.           ."<td bgcolor=\"$bgcolor1\" valign=\"bottom\"><img border=\"0\" alt=\"$ovv[7] "._LVOTES." ($ovvpercent[7]% "._LTOTALVOTES.")\" src=\"images/blackpixel.gif\" width=\"15\" height=\"$ovvchartheight[7]\"></td>"
  1786.           ."<td bgcolor=\"$bgcolor1\" valign=\"bottom\"><img border=\"0\" alt=\"$ovv[8] "._LVOTES." ($ovvpercent[8]% "._LTOTALVOTES.")\" src=\"images/blackpixel.gif\" width=\"15\" height=\"$ovvchartheight[8]\"></td>"
  1787.           ."<td bgcolor=\"$bgcolor1\" valign=\"bottom\"><img border=\"0\" alt=\"$ovv[9] "._LVOTES." ($ovvpercent[9]% "._LTOTALVOTES.")\" src=\"images/blackpixel.gif\" width=\"15\" height=\"$ovvchartheight[9]\"></td>"
  1788.           ."<td bgcolor=\"$bgcolor1\" valign=\"bottom\"><img border=\"0\" alt=\"$ovv[10] "._LVOTES." ($ovvpercent[10]% "._LTOTALVOTES.")\" src=\"images/blackpixel.gif\" width=\"15\" height=\"$ovvchartheight[10]\"></td>"
  1789.           ."</tr>"
  1790.           ."<tr><td colspan=\"10\" bgcolor=\"$bgcolor2\">"
  1791.           ."<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"200\"><tr>"
  1792.           ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">1</font></td>"
  1793.           ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">2</font></td>"
  1794.           ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">3</font></td>"
  1795.           ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">4</font></td>"
  1796.           ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">5</font></td>"
  1797.           ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">6</font></td>"
  1798.           ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">7</font></td>"
  1799.           ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">8</font></td>"
  1800.           ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">9</font></td>"
  1801.           ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">10</font></td>"
  1802.           ."</tr></table>"
  1803.           ."</td></tr></table>";
  1804.       }
  1805.     echo "</td>"
  1806.         ."</tr>"
  1807.         ."<tr><td bgcolor=\"$bgcolor2\"><font class=\"content\">"._DOWNLOADRATING.": $avgOU</font></td></tr>"
  1808.         ."<tr><td bgcolor=\"$bgcolor1\"><font class=\"content\">"._HIGHRATING.": $topoutside</font></td></tr>"
  1809.         ."<tr><td bgcolor=\"$bgcolor2\"><font class=\"content\">"._LOWRATING.": $bottomoutside</font></td></tr>"
  1810.         ."<tr><td bgcolor=\"$bgcolor1\"><font class=\"content\"> </font></td></tr>";
  1811.     }
  1812.     echo "</table><br><br><center>";
  1813.     downloadfooter($lid,$ttitle);
  1814.     echo "</center>";
  1815.     CloseTable();
  1816.     include("footer.php");
  1817. }
  1818.  
  1819. function downloadfooter($lid,$ttitle) {
  1820.     global $module_name;
  1821.     echo "<font class=\"content\">[ <a href=\"modules.php?name=$module_name&d_op=getit&lid=$lid\">"._DOWNLOADNOW."</a> | <a href=\"modules.php?name=$module_name&d_op=ratedownload&lid=$lid&ttitle=$ttitle\">"._RATETHISSITE."</a> ]</font><br><br>";
  1822.     downloadfooterchild($lid);
  1823. }
  1824.  
  1825. function downloadfooterchild($lid) {
  1826.     global $module_name;
  1827.     include("modules/$module_name/d_config.php");
  1828.     if ($useoutsidevoting = 1) { 
  1829.     echo "<br><font class=\"content\">"._ISTHISYOURSITE." <a href=\"modules.php?name=$module_name&d_op=outsidedownloadsetup&lid=$lid\">"._ALLOWTORATE."</a></font>";
  1830.     }
  1831. }
  1832.  
  1833. function outsidedownloadsetup($lid) {
  1834.     global $module_name, $sitename, $nukeurl;
  1835.     include("header.php");
  1836.     include("modules/$module_name/d_config.php");
  1837.     menu(1);
  1838.     echo "<br>";
  1839.     OpenTable();
  1840.     echo "<center><font class=\"option\"><b>"._PROMOTEYOURSITE."</b></font></center><br><br>
  1841.  
  1842.     "._PROMOTE01."<br><br>
  1843.  
  1844.     <b>1) "._TEXTLINK."</b><br><br>
  1845.  
  1846.     "._PROMOTE02."<br><br>
  1847.     <center><a href=\"$nukeurl/modules.php?name=$module_name&d_op=ratedownload&lid=$lid\">"._RATETHISSITE." @ $sitename</a></center><br><br>
  1848.     <center>"._HTMLCODE1."</center><br>
  1849.     <center><i><a href=\"$nukeurl/modules.php?name=$module_name&d_op=ratedownload&lid=$lid\">"._RATETHISSITE."</a></i></center>
  1850.     <br><br>
  1851.     "._THENUMBER." \"$lid\" "._IDREFER."<br><br>
  1852.  
  1853.     <b>2) "._BUTTONLINK."</b><br><br>
  1854.  
  1855.     "._PROMOTE03."<br><br>
  1856.  
  1857.     <center>
  1858.     <form action=\"modules.php?name=$module_name\" method=\"post\">\n
  1859.     <input type=\"hidden\" name=\"lid\" value=\"$lid\">\n
  1860.     <input type=\"hidden\" name=\"d_op\" value=\"ratedownload\">\n
  1861.     <input type=\"submit\" value=\""._RATEIT."\">\n
  1862.     </form>\n
  1863.     </center>
  1864.  
  1865.     <center>"._HTMLCODE2."</center><br><br>
  1866.  
  1867.     <table border=\"0\" align=\"center\"><tr><td align=\"left\"><i>
  1868.     <form action=\"$nukeurl/modules.php?name=$module_name\" method=\"post\"><br>\n
  1869.       <input type=\"hidden\" name=\"lid\" value=\"$lid\"><br>\n
  1870.       <input type=\"hidden\" name=\"d_op\" value=\"ratedownload\"><br>\n
  1871.       <input type=\"submit\" value=\""._RATEIT."\"><br>\n
  1872.     </form>\n
  1873.     </i></td></tr></table>
  1874.  
  1875.     <br><br>
  1876.  
  1877.     <b>3) "._REMOTEFORM."</b><br><br>
  1878.  
  1879.     "._PROMOTE04."
  1880.  
  1881.     <center>
  1882.     <form method=\"post\" action=\"$nukeurl/modules.php?name=$module_name\">
  1883.     <table align=\"center\" border=\"0\" width=\"175\" cellspacing=\"0\" cellpadding=\"0\">
  1884.     <tr><td align=\"center\"><b>"._VOTE4THISSITE."</b></a></td></tr>
  1885.     <tr><td>
  1886.     <table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">
  1887.     <tr><td valign=\"top\">
  1888.         <select name=\"rating\">
  1889.         <option selected>--</option>
  1890.     <option>10</option>
  1891.     <option>9</option>
  1892.     <option>8</option>
  1893.     <option>7</option>
  1894.     <option>6</option>
  1895.     <option>5</option>
  1896.     <option>4</option>
  1897.     <option>3</option>
  1898.     <option>2</option>
  1899.     <option>1</option>
  1900.     </select>
  1901.     </td><td valign=\"top\">
  1902.     <input type=\"hidden\" name=\"ratinglid\" value=\"$lid\">
  1903.         <input type=\"hidden\" name=\"ratinguser\" value=\"outside\">
  1904.         <input type=\"hidden\" name=\"op value=\"addrating\">
  1905.     <input type=\"submit\" value=\""._DOWNLOADVOTE."\">
  1906.     </td></tr></table>
  1907.     </td></tr></table></form>
  1908.  
  1909.     <br>"._HTMLCODE3."<br><br></center>
  1910.  
  1911.     <blockquote><i>
  1912.     <form method=\"post\" action=\"$nukeurl/modules.php?name=$module_name\"><br>
  1913.     <table align=\"center\" border=\"0\" width=\"175\" cellspacing=\"0\" cellpadding=\"0\"><br>
  1914.         <tr><td align=\"center\"><b>"._VOTE4THISSITE."</b></a></td></tr><br>
  1915.         <tr><td><br>
  1916.         <table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\"><br>
  1917.         <tr><td valign=\"top\"><br>
  1918.             <select name=\"rating\"><br>
  1919.             <option selected>--</option><br>
  1920.         <option>10</option><br>
  1921.         <option>9</option><br>
  1922.         <option>8</option><br>
  1923.         <option>7</option><br>
  1924.         <option>6</option><br>
  1925.         <option>5</option><br>
  1926.         <option>4</option><br>
  1927.         <option>3</option><br>
  1928.         <option>2</option><br>
  1929.         <option>1</option><br>
  1930.         </select><br>
  1931.         </td><td valign=\"top\"><br>
  1932.         <input type=\"hidden\" name=\"ratinglid\" value=\"$lid\"><br>
  1933.             <input type=\"hidden\" name=\"ratinguser\" value=\"outside\"><br>
  1934.             <input type=\"hidden\" name=\"d_op\" value=\"addrating\"><br>
  1935.         <input type=\"submit\" value=\""._DOWNLOADVOTE."\"><br>
  1936.         </td></tr></table><br>
  1937.     </td></tr></table><br>
  1938.     </form><br>
  1939.     </i></blockquote>
  1940.     <br><br><center>
  1941.     "._PROMOTE05."<br><br>
  1942.     - $sitename "._STAFF."
  1943.     <br><br></center>";
  1944.     CloseTable();
  1945.     include("footer.php");
  1946. }
  1947.  
  1948. function brokendownload($lid) {
  1949.     global $prefix, $db, $user, $cookie, $module_name;
  1950.     if (is_user($user)) {
  1951.     include("header.php");
  1952.     include("modules/$module_name/d_config.php");
  1953.         $user2 = base64_decode($user);
  1954.        $cookie = explode(":", $user2);
  1955.     cookiedecode($user);
  1956.     $ratinguser = $cookie[1];
  1957.     menu(1);
  1958.         $lid = intval($lid);
  1959.     echo "<br>";
  1960.     $row = $db->sql_fetchrow($db->sql_query("SELECT cid, title, url, description from ".$prefix."_downloads_downloads where lid='$lid'"));
  1961.     $cid = intval($row['cid']);
  1962.     $title = stripslashes($row['title']);
  1963.     $url = $row['url'];
  1964.     $description = stripslashes($row['description']);
  1965.     OpenTable();
  1966.     echo "<center><font class=\"option\"><b>"._REPORTBROKEN."</b></font><br><br><br><font class=\"content\">";
  1967.     echo "<form action=\"modules.php?name=$module_name\" method=\"post\">";
  1968.     echo "<input type=\"hidden\" name=\"lid\" value=\"$lid\">";
  1969.     echo "<input type=\"hidden\" name=\"modifysubmitter\" value=\"$ratinguser\">";
  1970.     echo ""._THANKSBROKEN."<br>"._SECURITYBROKEN."<br><br>"; 
  1971.     echo "<input type=\"hidden\" name=\"d_op\" value=\"brokendownloadS\"><input type=\"submit\" value=\""._REPORTBROKEN."\"></center></form>";
  1972.     CloseTable();
  1973.     include("footer.php");
  1974.     } else {
  1975.     Header("Location: modules.php?name=$module_name");
  1976.     }
  1977. }
  1978.  
  1979. function brokendownloadS($lid, $modifysubmitter) {
  1980.     global $prefix, $db, $user, $anonymous, $cookie, $module_name, $user;
  1981.     if (is_user($user)) {
  1982.     include("modules/$module_name/d_config.php");
  1983.     $user2 = base64_decode($user);
  1984.        $cookie = explode(":", $user2);
  1985.     cookiedecode($user);
  1986.     $ratinguser = $cookie[1];
  1987.         $lid = intval($lid);
  1988.     $db->sql_query("insert into ".$prefix."_downloads_modrequest values (NULL, '$lid', '0', '0', '', '', '', '$ratinguser', '1', '$auth_name', '$email', '$filesize', '$version', '$homepage')");
  1989.     include("header.php");
  1990.     menu(1);
  1991.     echo "<br>";
  1992.     OpenTable();
  1993.     echo "<br><center>"._THANKSFORINFO."<br><br>"._LOOKTOREQUEST."</center><br>";
  1994.     CloseTable();
  1995.     include("footer.php");
  1996.     } else {
  1997.     Header("Location: modules.php?name=$module_name");
  1998.     }
  1999. }
  2000.  
  2001. function modifydownloadrequest($lid) {
  2002.     global $prefix, $db, $user, $module_name;
  2003.     include("header.php");
  2004.     if(is_user($user)) {
  2005.         $user2 = base64_decode($user);
  2006.        $cookie = explode(":", $user2);
  2007.     cookiedecode($user);
  2008.     $ratinguser = $cookie[1];
  2009.     } else {
  2010.     $ratinguser = "$anonymous";
  2011.     }
  2012.     menu(1);
  2013.     echo "<br>";
  2014.     OpenTable();
  2015.     $blocknow = 0;
  2016.     $lid = intval(trim($lid));
  2017.     if ($blockunregmodify == 1 && $ratinguser=="$anonymous") {
  2018.     echo "<br><br><center>"._DONLYREGUSERSMODIFY."</center>";
  2019.     $blocknow = 1;
  2020.     }
  2021.     if ($blocknow != 1) {
  2022.         $result = $db->sql_query("SELECT cid, title, url, description, name, email, filesize, version, homepage FROM ".$prefix."_downloads_downloads WHERE lid='$lid'");
  2023.         echo "<center><font class=\"option\"><b>"._REQUESTDOWNLOADMOD."</b></font><br><font class=\"content\">";
  2024.         while($row = $db->sql_fetchrow($result)) {
  2025.             $cid = intval($row['cid']);
  2026.             $title = stripslashes($row['title']);
  2027.             $url = $row['url'];
  2028.             $description = stripslashes($row['description']);
  2029.             $auth_name = $row['name'];
  2030.             $email = $row['email'];
  2031.             $filesize = $row['filesize'];
  2032.             $version = $row['version'];
  2033.             $homepage = $row['homepage'];
  2034.             echo "<form action=\"modules.php?name=$module_name\" method=\"post\">"
  2035.             .""._DOWNLOADID.": <b>$lid</b></center><br><br><br>"
  2036.             .""._DOWNLOADNAME.":<br><input type=\"text\" name=\"title\" value=\"$title\" size=\"50\" maxlength=\"100\"><br><br>"
  2037.             .""._URL.":<br><input type=\"text\" name=\"url\" value=\"$url\" size=\"50\" maxlength=\"100\"><br><br>"
  2038.             .""._DESCRIPTION.": <br><textarea name=\"description\" cols=\"60\" rows=\"10\">$description</textarea><br><br>";
  2039.         // $result2 = $db->sql_query("SELECT cid, title FROM ".$prefix."_downloads_categories order by title");
  2040.         echo "<input type=\"hidden\" name=\"lid\" value=\"$lid\">"
  2041.         ."<input type=\"hidden\" name=\"modifysubmitter\" value=\"$ratinguser\">"
  2042.         .""._CATEGORY.": <select name=\"cat\">";
  2043.     $result2 = $db->sql_query("SELECT cid, title, parentid FROM ".$prefix."_downloads_categories order by title");
  2044.     while($row2 = $db->sql_fetchrow($result2)) {
  2045.         $cid2 = intval($row2['cid']);
  2046.         $ctitle2 = $row2['title'];
  2047.         $parentid2 = intval($row2['parentid']);
  2048.         if ($cid2==$cid) {
  2049.             $sel = "selected";
  2050.         } else {
  2051.             $sel = "";
  2052.         }
  2053.         if ($parentid2!=0) $ctitle2=getparent($parentid2,$ctitle2);
  2054.         echo "<option value=\"$cid2\" $sel>$ctitle2</option>";
  2055.     }
  2056.         echo "</select><br><br>"
  2057.         .""._AUTHORNAME.":<br><input type=\"text\" name=\"auth_name\" value=\"$auth_name\" size=\"30\" maxlength=\"80\"><br><br>"
  2058.         .""._AUTHOREMAIL.":<br><input type=\"text\" name=\"email\" value=\"$email\" size=\"30\" maxlength=\"80\"><br><br>"
  2059.         .""._FILESIZE.": ("._INBYTES.")<br><input type=\"text\" name=\"filesize\" value=\"$filesize\" size=\"12\" maxlength=\"11\"><br><br>"
  2060.         .""._VERSION.":<br><input type=\"text\" name=\"version\" value=\"$version\" size=\"11\" maxlength=\"10\"><br><br>"
  2061.         .""._HOMEPAGE.":<br><input type=\"text\" name=\"homepage\" value=\"$homepage\" size=\"50\" maxlength=\"200\"><br><br>"
  2062.         ."<input type=\"hidden\" name=\"d_op\" value=\"modifydownloadrequestS\">"
  2063.         ."<input type=\"submit\" value=\""._SENDREQUEST."\"></form>";
  2064.         }
  2065.     }
  2066.     CloseTable();
  2067.     include("footer.php");
  2068. }
  2069.  
  2070. function modifydownloadrequestS($lid, $cat, $title, $url, $description, $modifysubmitter, $auth_name, $email, $filesize, $version, $homepage) {
  2071.     global $prefix, $db, $user, $module_name;
  2072.     include("modules/$module_name/d_config.php");
  2073.     if(is_user($user)) {
  2074.     $user2 = base64_decode($user);
  2075.     $cookie = explode(":", $user2);
  2076.     cookiedecode($user);
  2077.     $ratinguser = $cookie[1];
  2078.     } else {
  2079.     $ratinguser = "$anonymous";
  2080.     }
  2081.     $blocknow = 0;
  2082.     if ($blockunregmodify == 1 && $ratinguser=="$anonymous") {
  2083.     include("header.php");
  2084.     menu(1);
  2085.     echo "<br>";
  2086.     OpenTable();
  2087.     echo "<center><font class=\"content\">"._DONLYREGUSERSMODIFY."</font></center>";
  2088.     $blocknow = 1;
  2089.     CloseTable();
  2090.     include("footer.php");
  2091.     }
  2092.     if ($blocknow != 1) {
  2093.         $cat = explode("-", $cat);
  2094.         if ($cat[1]=="") {
  2095.             $cat[1] = 0;
  2096.         }
  2097.         $title = stripslashes($title);
  2098.         $url = stripslashes($url);
  2099.         $description = stripslashes($description);
  2100.         $lid = intval($lid);
  2101.         $cat[0] = intval($cat[0]);
  2102.         $cat[1] = intval($cat[1]);
  2103.         $db->sql_query("insert into ".$prefix."_downloads_modrequest values (NULL, '$lid', '$cat[0]', '$cat[1]', '$title', '$url', '$description', '$ratinguser', '0', '$auth_name', '$email', '$filesize', '$version', '$homepage')");
  2104.         include("header.php");
  2105.     menu(1);
  2106.     echo "<br>";
  2107.     OpenTable();
  2108.         echo "<center><font class=\"content\">"._THANKSFORINFO." "._LOOKTOREQUEST."</font></center>";
  2109.         CloseTable();
  2110.     include("footer.php");
  2111.     }
  2112. }
  2113.  
  2114. function rateinfo($lid) {
  2115.     global $prefix, $db;
  2116.     $lid = intval($lid);                            
  2117.     $db->sql_query("update ".$prefix."_downloads_downloads set hits=hits+1 WHERE lid='$lid'");
  2118.     $row = $db->sql_fetchrow($db->sql_query("SELECT url FROM ".$prefix."_downloads_downloads WHERE lid='$lid'"));
  2119.     $url = $row['url'];
  2120.     Header("Location: $url");
  2121. }
  2122.  
  2123. function addrating($ratinglid, $ratinguser, $rating, $ratinghost_name, $ratingcomments) {
  2124.     global $prefix, $db, $cookie, $user, $module_name;
  2125.     $passtest = "yes";
  2126.     include("header.php");
  2127.     include("modules/$module_name/d_config.php");
  2128.     $ratinglid = intval($ratinglid);
  2129.     completevoteheader();
  2130.     if(is_user($user)) {
  2131.     $user2 = base64_decode($user);
  2132.        $cookie = explode(":", $user2);
  2133.     cookiedecode($user);
  2134.     $ratinguser = $cookie[1];
  2135.     } else if ($ratinguser=="outside") {
  2136.     $ratinguser = "outside";
  2137.     } else {
  2138.     $ratinguser = "$anonymous";
  2139.     }
  2140.     $result = $db->sql_query("SELECT title FROM ".$prefix."_downloads_downloads WHERE lid='$ratinglid'");
  2141.     while ($row = $db->sql_fetchrow($result)) {
  2142.     $title = $row['title'];
  2143.     /* Make sure only 1 anonymous from an IP in a single day. */
  2144.     $ip = $_SERVER["REMOTE_HOST"];
  2145.     if (empty($ip)) {
  2146.        $ip = $_SERVER["REMOTE_ADDR"];
  2147.     }
  2148.     /* Check if Rating is Null */
  2149.     if ($rating=="--") {
  2150.     $error = "nullerror";
  2151.         completevote($error);
  2152.     $passtest = "no";
  2153.     }
  2154.     /* Check if Download POSTER is voting (UNLESS Anonymous users allowed to post) */
  2155.     if ($ratinguser != $anonymous && $ratinguser != "outside") {
  2156.     $result2 = $db->sql_query("SELECT submitter FROM ".$prefix."_downloads_downloads WHERE lid='$ratinglid'");
  2157.     while ($row2 = $db->sql_fetchrow($result2)) {
  2158.     $ratinguserDB = $row2['submitter'];
  2159.             if ($ratinguserDB==$ratinguser) {
  2160.             $error = "postervote";
  2161.                 completevote($error);
  2162.         $passtest = "no";
  2163.             }
  2164.        }
  2165.     }
  2166.     /* Check if REG user is trying to vote twice. */
  2167.     if ($ratinguser!=$anonymous && $ratinguser != "outside") {
  2168.     $result3 = $db->sql_query("SELECT ratinguser FROM ".$prefix."_downloads_votedata WHERE ratinglid='$ratinglid'");
  2169.     while ($row3 = $db->sql_fetchrow($result3)) {
  2170.     $ratinguserDB = $row3['ratinguser'];
  2171.             if ($ratinguserDB==$ratinguser) {
  2172.                 $error = "regflood";
  2173.                 completevote($error);
  2174.         $passtest = "no";
  2175.         }
  2176.         }
  2177.     }
  2178.     /* Check if ANONYMOUS user is trying to vote more than once per day. */
  2179.     if ($ratinguser==$anonymous){
  2180.         $yesterdaytimestamp = (time()-(86400 * $anonwaitdays));
  2181.         $ytsDB = Date("Y-m-d H:i:s", $yesterdaytimestamp);
  2182.         $result4 = $db->sql_query("SELECT * FROM ".$prefix."_downloads_votedata WHERE ratinglid='$ratinglid' AND ratinguser='$anonymous' AND ratinghostname = '$ip' AND TO_DAYS(NOW()) - TO_DAYS(ratingtimestamp) < '$anonwaitdays'");
  2183.         $anonvotecount = $db->sql_numrows($result4);
  2184.         if ($anonvotecount >= 1) {
  2185.             $error = "anonflood";
  2186.             completevote($error);
  2187.             $passtest = "no";
  2188.         }
  2189.     }
  2190.     /* Check if OUTSIDE user is trying to vote more than once per day. */
  2191.     if ($ratinguser=="outside"){
  2192.         $yesterdaytimestamp = (time()-(86400 * $outsidewaitdays));
  2193.         $ytsDB = Date("Y-m-d H:i:s", $yesterdaytimestamp);
  2194.         $result5 = $db->sql_query("SELECT * FROM ".$prefix."_downloads_votedata WHERE ratinglid='$ratinglid' AND ratinguser='outside' AND ratinghostname = '$ip' AND TO_DAYS(NOW()) - TO_DAYS(ratingtimestamp) < '$outsidewaitdays'");
  2195.         $outsidevotecount = $db->sql_numrows($result5);
  2196.         if ($outsidevotecount >= 1) {
  2197.             $error = "outsideflood";
  2198.             completevote($error);
  2199.             $passtest = "no";
  2200.         }
  2201.     }
  2202.     /* Passed Tests */
  2203.     if ($passtest == "yes") {
  2204.         $comment = stripslashes($comment);
  2205.         /* All is well.  Add to Line Item Rate to DB. */
  2206.         $ratinglid = intval($ratinglid);
  2207.         $rating = intval($rating);
  2208.      $db->sql_query("INSERT into ".$prefix."_downloads_votedata values (NULL,'$ratinglid', '$ratinguser', '$rating', '$ip', '$ratingcomments', now())");    
  2209.     /* All is well.  Calculate Score & Add to Summary (for quick retrieval & sorting) to DB. */
  2210.     /* NOTE: If weight is modified, ALL downloads need to be refreshed with new weight. */
  2211.     /*     Running a SQL statement with your modded calc for ALL downloads will accomplish this. */
  2212.         $voteresult = $db->sql_query("SELECT rating, ratinguser, ratingcomments FROM ".$prefix."_downloads_votedata WHERE ratinglid = '$ratinglid'");
  2213.     $totalvotesDB = $db->sql_numrows($voteresult);
  2214.     include ("modules/$module_name/voteinclude.php");
  2215.         $finalrating = intval($finalrating);
  2216.         $totalvotesDB = intval($totalvotesDB);
  2217.         $truecomments = intval($truecomments);
  2218.         $ratinglid = intval($ratinglid);
  2219.         $db->sql_query("UPDATE ".$prefix."_downloads_downloads SET downloadratingsummary='$finalrating',totalvotes='$totalvotesDB',totalcomments='$truecomments' WHERE lid = '$ratinglid'");
  2220.         $error = "none";
  2221.         completevote($error);
  2222.         }
  2223.     }
  2224.     completevotefooter($ratinglid, $ttitle, $ratinguser);
  2225.     include("footer.php");
  2226. }
  2227.  
  2228. function completevoteheader(){
  2229.     menu(1);
  2230.     echo "<br>";
  2231.     OpenTable();
  2232. }
  2233.  
  2234. function completevotefooter($lid, $ttitle, $ratinguser) {
  2235.     global $prefix, $db, $module_name, $sitename;
  2236.     include("modules/$module_name/d_config.php");
  2237.     $lid = intval($lid);
  2238.     $row = $db->sql_fetchrow($db->sql_query("SELECT url FROM ".$prefix."_downloads_downloads WHERE lid='$lid'"));
  2239.     $url = $row['url'];
  2240.     echo "<font class=\"content\">"._THANKSTOTAKETIME." $sitename. "._DLETSDECIDE."</font><br><br><br>";
  2241.     if ($ratinguser=="outside") {
  2242.     echo "<center><font class=\"content\">".WEAPPREACIATE." $sitename!<br><a href=\"$url\">"._RETURNTO." $ttitle</a></font><center><br><br>";
  2243.     $row2 = $db->sql_fetchrow($db->sql_query("SELECT title FROM ".$prefix."_downloads_downloads WHERE lid='$lid'"));
  2244.     $title = $row2['title'];
  2245.         $ttitle = ereg_replace (" ", "_", $title);
  2246.     }
  2247.     echo "<center>";
  2248.     downloadinfomenu($lid,$ttitle);
  2249.     echo "</center>";
  2250.     CloseTable();
  2251. }
  2252.  
  2253. function completevote($error) {
  2254.     global $module_name;
  2255.     include("modules/$module_name/d_config.php");
  2256.     if ($error == "none") echo "<center><font class=\"content\"><b>"._COMPLETEVOTE1."</b></font></center>";
  2257.     if ($error == "anonflood") echo "<center><font class=\"option\"><b>"._COMPLETEVOTE2."</b></font></center><br>";
  2258.     if ($error == "regflood") echo "<center><font class=\"option\"><b>"._COMPLETEVOTE3."</b></font></center><br>";
  2259.     if ($error == "postervote") echo "<center><font class=\"option\"><b>"._COMPLETEVOTE4."</b></font></center><br>";
  2260.     if ($error == "nullerror") echo "<center><font class=\"option\"><b>"._COMPLETEVOTE5."</b></font></center><br>";
  2261.     if ($error == "outsideflood") echo "<center><font class=\"option\"><b>"._COMPLETEVOTE6."</b></font></center><br>";
  2262. }
  2263.  
  2264. function ratedownload($lid, $user, $ttitle) {
  2265.     global $prefix, $cookie, $datetime, $module_name;
  2266.     include("header.php");
  2267.     menu(1);
  2268.     echo "<br>";
  2269.     OpenTable();
  2270.     $transfertitle = ereg_replace ("_", " ", $ttitle);
  2271.     $displaytitle = $transfertitle;
  2272.     $ip = $_SERVER["REMOTE_HOST"];
  2273.     if (empty($ip)) {
  2274.        $ip = $_SERVER["REMOTE_ADDR"];
  2275.     }
  2276.     echo "<b>$displaytitle</b>"
  2277.     ."<ul><font class=\"content\">"
  2278.     ."<li>"._RATENOTE1.""
  2279.     ."<li>"._RATENOTE2.""
  2280.     ."<li>"._RATENOTE3.""
  2281.     ."<li>"._DRATENOTE4.""
  2282.     ."<li>"._RATENOTE5."";
  2283.     if(is_user($user)) {
  2284.         $user2 = base64_decode($user);
  2285.        $cookie = explode(":", $user2);
  2286.     echo "<li>"._YOUAREREGGED.""
  2287.         ."<li>"._FEELFREE2ADD."";
  2288.     cookiedecode($user);
  2289.     $auth_name = $cookie[1];
  2290.     } else {
  2291.     echo "<li>"._YOUARENOTREGGED.""
  2292.         ."<li>"._IFYOUWEREREG."";
  2293.     $auth_name = "$anonymous";
  2294.     }
  2295.     echo "</ul>"
  2296.         ."<form method=\"post\" action=\"modules.php?name=$module_name\">"
  2297.         ."<table border=\"0\" cellpadding=\"1\" cellspacing=\"0\" width=\"100%\">"
  2298.         ."<tr><td width=\"25\" nowrap></td>"
  2299.         ."<tr><td width=\"25\" nowrap></td><td width=\"550\">"
  2300.         ."<input type=\"hidden\" name=\"ratinglid\" value=\"$lid\">"
  2301.         ."<input type=\"hidden\" name=\"ratinguser\" value=\"$auth_name\">"
  2302.         ."<input type=\"hidden\" name=\"ratinghost_name\" value=\"$ip\">"
  2303.         ."<font class=content>"._RATETHISSITE.""
  2304.         ."<select name=\"rating\">"
  2305.         ."<option>--</option>"
  2306.         ."<option>10</option>"
  2307.         ."<option>9</option>"
  2308.     ."<option>8</option>"
  2309.         ."<option>7</option>"
  2310.         ."<option>6</option>"
  2311.         ."<option>5</option>"
  2312.         ."<option>4</option>"
  2313.         ."<option>3</option>"
  2314.         ."<option>2</option>"
  2315.         ."<option>1</option>"
  2316.         ."</select></font>"
  2317.     ."<font class=\"content\"><input type=\"submit\" value=\""._RATETHISSITE."\"></font>"
  2318.         ."<br><br>";
  2319.     if(is_user($user)) {
  2320.     echo "<b>"._SCOMMENTS.":</b><br><textarea wrap=\"virtual\" cols=\"50\" rows=\"10\" name=\"ratingcomments\"></textarea>"
  2321.          ."<br><br><br>"
  2322.              ."</font></td>";
  2323.     } else {
  2324.     echo"<input type=\"hidden\" name=\"ratingcomments\" value=\"\">";
  2325.     }
  2326.     echo "</tr></table></form>";
  2327.     echo "<center>";
  2328.     downloadfooterchild($lid);
  2329.     echo "</center>";
  2330.     CloseTable();
  2331.     include("footer.php");
  2332. }
  2333.  
  2334. function CoolSize($size) {
  2335.     $mb = 1024*1024;
  2336.     if ( $size > $mb ) {
  2337.         $mysize = sprintf ("%01.2f",$size/$mb) . " MB";
  2338.     } elseif ( $size >= 1024 ) {
  2339.         $mysize = sprintf ("%01.2f",$size/1024) . " Kb";
  2340.     } else {
  2341.         $mysize = $size . " "._UDOWNLOADSSIZE."";
  2342.     }
  2343.     return $mysize;
  2344. }
  2345.  
  2346. if (isset($ratinglid) && isset ($ratinguser) && isset ($rating)) {
  2347.     $ret = addrating($ratinglid, $ratinguser, $rating, $ratinghost_name, $ratingcomments);
  2348. }
  2349.  
  2350. switch($d_op) {
  2351.  
  2352.     case "menu":
  2353.     menu($maindownload);
  2354.     break;
  2355.  
  2356.     case "AddDownload":
  2357.     AddDownload();
  2358.     break;
  2359.  
  2360.     case "NewDownloads":
  2361.     NewDownloads($newdownloadshowdays);
  2362.     break;
  2363.  
  2364.     case "NewDownloadsDate":
  2365.     NewDownloadsDate($selectdate);
  2366.     break;
  2367.  
  2368.     case "CoolSize":
  2369.     CoolSize($size);
  2370.     break;
  2371.  
  2372.     case "TopRated":
  2373.     TopRated($ratenum, $ratetype);
  2374.     break;
  2375.  
  2376.     case "MostPopular":
  2377.     MostPopular($ratenum, $ratetype);
  2378.     break;
  2379.  
  2380.     case "viewdownload":
  2381.     viewdownload($cid, $min, $orderby, $show);
  2382.     break;
  2383.  
  2384.     case "viewsdownload":
  2385.     viewsdownload($sid, $min, $orderby, $show);
  2386.     break;
  2387.  
  2388.     case "brokendownload":
  2389.     brokendownload($lid);
  2390.     break;
  2391.     
  2392.     case "modifydownloadrequest":    
  2393.     modifydownloadrequest($lid);
  2394.     break;
  2395.     
  2396.     case "modifydownloadrequestS":    
  2397.     modifydownloadrequestS($lid, $cat, $title, $url, $description, $modifysubmitter, $auth_name, $email, $filesize, $version, $homepage);
  2398.     break;
  2399.    
  2400.     case "brokendownloadS":
  2401.     brokendownloadS($lid, $modifysubmitter);
  2402.     break;
  2403.     
  2404.     case "getit":
  2405.     getit($lid);
  2406.     break;
  2407.  
  2408.     case "Add":
  2409.     Add($title, $url, $auth_name, $cat, $description, $email, $filesize, $version, $homepage);
  2410.     break;
  2411.  
  2412.     case "search":
  2413.     search($query, $min, $orderby, $show);
  2414.     break;
  2415.  
  2416.     case "rateinfo":
  2417.     rateinfo($lid, $user, $title);
  2418.     break;
  2419.  
  2420.     case "ratedownload":
  2421.     ratedownload($lid, $user, $ttitle);
  2422.     break;    
  2423.     
  2424.     case "addrating":
  2425.     addrating($ratinglid, $ratinguser, $rating, $ratinghost_name, $ratingcomments, $user);
  2426.     break;
  2427.  
  2428.     case "viewdownloadcomments":
  2429.     viewdownloadcomments($lid, $ttitle);
  2430.     break;
  2431.     
  2432.     case "outsidedownloadsetup":
  2433.     outsidedownloadsetup($lid);
  2434.     break;
  2435.     
  2436.     case "viewdownloadeditorial":
  2437.     viewdownloadeditorial($lid, $ttitle);
  2438.     break;
  2439.  
  2440.     case "viewdownloaddetails":                                
  2441.     viewdownloaddetails($lid, $ttitle);                        
  2442.     break;    
  2443.     
  2444.     default:
  2445.     index();
  2446.     break;
  2447.  
  2448. }
  2449.  
  2450. ?>
  2451.