home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2003 May / INTERNET103.ISO / pc / software / windows / building / php_nuke / html / modules / web_links / index.php next >
Encoding:
PHP Script  |  2002-09-16  |  95.0 KB  |  2,039 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", $PHP_SELF)) {
  20.     die ("You can't access this file directly...");
  21. }
  22. $index = 1;
  23. require_once("mainfile.php");
  24. $module_name = basename(dirname(__FILE__));
  25. get_lang($module_name);
  26. $pagetitle = "- "._WEBLINKS."";
  27. require_once("modules/Web_Links/l_config.php");
  28.  
  29. function getparent($parentid,$title) {
  30.     global $prefix, $dbi;
  31.     $result = sql_query("select cid, title, parentid from ".$prefix."_links_categories where cid=$parentid", $dbi);
  32.     list($cid, $ptitle, $pparentid) = sql_fetch_row($result, $dbi);
  33.     if ($ptitle!="") $title=$ptitle."/".$title;
  34.     if ($pparentid!=0) {
  35.     $title=getparent($pparentid,$title);
  36.     }
  37.     return $title;
  38. }
  39.  
  40. function getparentlink($parentid,$title) {
  41.     global $prefix, $dbi;
  42.     $result=sql_query("select cid, title, parentid from ".$prefix."_links_categories where cid=$parentid", $dbi);
  43.     list($cid, $ptitle, $pparentid) = sql_fetch_row($result, $dbi);
  44.     if ($ptitle!="") $title="<a href=modules.php?name=Web_Links&l_op=viewlink&cid=$cid>$ptitle</a>/".$title;
  45.     if ($pparentid!=0) {
  46.         $title=getparentlink($pparentid,$title);
  47.     }
  48.     return $title;
  49. }
  50.  
  51. function menu($mainlink) {
  52.     global $module_name;
  53.     OpenTable();
  54.     echo "<br><center><a href=\"modules.php?name=Web_Links\"><img src=\"modules/$module_name/images/web.gif\" border=\"0\" alt=\"\"></a><br><br>";
  55.     echo "<form action=\"modules.php?name=Web_Links&l_op=search&query=$query\" method=\"post\">"
  56.     ."<font class=\"content\"><input type=\"text\" size=\"25\" name=\"query\"> <input type=\"submit\" value=\""._SEARCH."\"></font>"
  57.     ."</form>";
  58.     echo "<font class=\"content\">[ ";
  59.     if ($mainlink>0) {
  60.     echo "<a href=\"modules.php?name=Web_Links\">"._LINKSMAIN."</a> | ";
  61.     }
  62.     echo "<a href=\"modules.php?name=Web_Links&l_op=AddLink\">"._ADDLINK."</a>"
  63.     ." | <a href=\"modules.php?name=Web_Links&l_op=NewLinks\">"._NEW."</a>"
  64.     ." | <a href=\"modules.php?name=Web_Links&l_op=MostPopular\">"._POPULAR."</a>"
  65.     ." | <a href=\"modules.php?name=Web_Links&l_op=TopRated\">"._TOPRATED."</a>"
  66.     ." | <a href=\"modules.php?name=Web_Links&l_op=RandomLink\">"._RANDOM."</a> ]"
  67.     ."</font></center>";
  68.     CloseTable();
  69. }
  70.  
  71. function SearchForm() {
  72.     echo "<form action=\"modules.php?name=Web_Links&l_op=search&query=$query\" method=\"post\">"
  73.     ."<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">"
  74.     ."<tr><td><font class=\"content\"><input type=\"text\" size=\"25\" name=\"query\"> <input type=\"submit\" value=\""._SEARCH."\"></td></tr>"
  75.     ."</table>"
  76.     ."</form>";
  77. }
  78.  
  79. function linkinfomenu($lid, $ttitle) {
  80.     echo "<br><font class=\"content\">[ "
  81.     ."<a href=\"modules.php?name=Web_Links&l_op=viewlinkcomments&lid=$lid&ttitle=$ttitle\">"._LINKCOMMENTS."</a>"
  82.     ." | <a href=\"modules.php?name=Web_Links&l_op=viewlinkdetails&lid=$lid&ttitle=$ttitle\">"._ADDITIONALDET."</a>"
  83.     ." | <a href=\"modules.php?name=Web_Links&l_op=viewlinkeditorial&lid=$lid&ttitle=$ttitle\">"._EDITORREVIEW."</a>"
  84.     ." | <a href=\"modules.php?name=Web_Links&l_op=modifylinkrequest&lid=$lid\">"._MODIFY."</a>"
  85.     ." | <a href=\"modules.php?name=Web_Links&l_op=brokenlink&lid=$lid\">"._REPORTBROKEN."</a> ]</font>";
  86. }
  87.  
  88. function index() {
  89.     global $prefix, $dbi;
  90.     include("header.php");
  91.     $mainlink = 0;
  92.     menu($mainlink);
  93.     echo "<br>";
  94.     OpenTable();
  95.     echo "<center><font class=\"title\"><b>"._LINKSMAINCAT."</b></font></center><br>";
  96.     echo "<table border=\"0\" cellspacing=\"10\" cellpadding=\"0\" align=\"center\"><tr>";
  97.     $result = sql_query("select cid, title, cdescription from ".$prefix."_links_categories where parentid=0 order by title", $dbi);
  98.     $count = 0;
  99.     while(list($cid, $title, $cdescription) = sql_fetch_row($result, $dbi)) {
  100.     echo "<td><font class=\"option\"><strong><big>·</big></strong> <a href=\"modules.php?name=Web_Links&l_op=viewlink&cid=$cid\"><b>$title</b></a></font>";
  101.     categorynewlinkgraphic($cid);
  102.     if ($cdescription) {
  103.         echo "<br><font class=\"content\">$cdescription</font><br>";
  104.     } else {
  105.         echo "<br>";
  106.     }
  107.     $result2 = sql_query("select cid, title from ".$prefix."_links_categories where parentid=$cid order by title limit 0,3", $dbi);
  108.     $space = 0;
  109.     while(list($cid, $stitle) = sql_fetch_row($result2, $dbi)) {
  110.             if ($space>0) {
  111.         echo ", ";
  112.         }
  113.         echo "<font class=\"content\"><a href=\"modules.php?name=Web_Links&l_op=viewlink&cid=$cid\">$stitle</a></font>";
  114.         $space++;
  115.     }
  116.     if ($count<1) {
  117.         echo "</td><td>    </td>";
  118.         $dum = 1;
  119.     }
  120.     $count++;
  121.     if ($count==2) {
  122.         echo "</td></tr><tr>";
  123.         $count = 0;
  124.         $dum = 0;
  125.     }
  126.     }
  127.     if ($dum == 1) {
  128.     echo "</tr></table>";
  129.     } elseif ($dum == 0) {
  130.     echo "<td></td></tr></table>";
  131.     }
  132.     $result=sql_query("select * from ".$prefix."_links_links", $dbi);
  133.     $numrows = sql_num_rows($result, $dbi);
  134.     $result=sql_query("select * from ".$prefix."_links_categories", $dbi);
  135.     $catnum = sql_num_rows($result, $dbi);
  136.     echo "<br><br><center><font class=\"content\">"._THEREARE." <b>$numrows</b> "._LINKS." "._AND." <b>$catnum</b> "._CATEGORIES." "._INDB."</font></center>";
  137.     CloseTable();
  138.     include("footer.php");
  139. }
  140.  
  141. function AddLink() {
  142.     global $prefix, $dbi, $user, $links_anonaddlinklock;
  143.     include("header.php");
  144.     $mainlink = 1;
  145.     menu(1);
  146.     echo "<br>";
  147.     OpenTable();
  148.     echo "<center><font class=\"title\"><b>"._ADDALINK."</b></font></center><br><br>";
  149.     if (is_user($user) || $links_anonaddlinklock == 1) {  /* 06-24-01 Bug fix : changed $links_anonaddlinklock != 1 to $links_anonaddlinklock == 1 */
  150.         echo "<b>"._INSTRUCTIONS.":</b><br>"
  151.         ."<strong><big>·</big></strong> "._SUBMITONCE."<br>"
  152.         ."<strong><big>·</big></strong> "._POSTPENDING."<br>"
  153.         ."<strong><big>·</big></strong> "._USERANDIP."<br>"
  154.             ."<form method=\"post\" action=\"modules.php?name=Web_Links&l_op=Add\">"
  155.             .""._PAGETITLE.": <input type=\"text\" name=\"title\" size=\"50\" maxlength=\"100\"><br>"
  156.             .""._PAGEURL.": <input type=\"text\" name=\"url\" size=\"50\" maxlength=\"100\" value=\"http://\"><br>";
  157.         echo ""._CATEGORY.": <select name=\"cat\">";
  158.         $result2=sql_query("select cid, title, parentid from ".$prefix."_links_categories order by parentid,title", $dbi);
  159.         while(list($cid2, $ctitle2, $parentid2) = sql_fetch_row($result2, $dbi)) {
  160.             if ($parentid2!=0) $ctitle2=getparent($parentid2,$ctitle2);
  161.             echo "<option value=\"$cid2\">$ctitle2</option>";
  162.         }
  163.         echo "</select><br><br>"
  164.             .""._LDESCRIPTION."<br><textarea name=\"description\" cols=\"60\" rows=\"5\"></textarea><br><br><br>"
  165.             .""._YOURNAME.": <input type=\"text\" name=\"auth_name\" size=\"30\" maxlength=\"60\"><br>"
  166.             .""._YOUREMAIL.": <input type=\"text\" name=\"email\" size=\"30\" maxlength=\"60\"><br><br>"
  167.             ."<input type=\"hidden\" name=\"l_op\" value=\"Add\">"
  168.             ."<input type=\"submit\" value=\""._ADDURL."\"> "._GOBACK."<br><br>"
  169.             ."</form>";
  170.     }else {
  171.         echo "<center>"._LINKSNOTUSER1."<br>"
  172.         .""._LINKSNOTUSER2."<br><br>"
  173.             .""._LINKSNOTUSER3."<br>"
  174.             .""._LINKSNOTUSER4."<br>"
  175.             .""._LINKSNOTUSER5."<br>"
  176.             .""._LINKSNOTUSER6."<br>"
  177.             .""._LINKSNOTUSER7."<br><br>"
  178.             .""._LINKSNOTUSER8."";
  179.     }
  180.     CloseTable();
  181.     include("footer.php");
  182. }
  183.  
  184. function Add($title, $url, $auth_name, $cat, $description, $email) {
  185.     global $prefix, $dbi, $user;
  186.     $result = sql_query("select url from ".$prefix."_links_links where url='$url'", $dbi);
  187.     $numrows = sql_num_rows($result, $dbi);
  188.     if ($numrows>0) {
  189.     include("header.php");
  190.     menu(1);
  191.     echo "<br>";
  192.     OpenTable();
  193.     echo "<center><b>"._LINKALREADYEXT."</b><br><br>"
  194.         .""._GOBACK."";
  195.     CloseTable();
  196.     include("footer.php");
  197.     } else {
  198.     if(is_user($user)) {
  199.         $user2 = base64_decode($user);
  200.         $cookie = explode(":", $user2);
  201.         cookiedecode($user);
  202.         $submitter = $cookie[1];
  203.     }
  204. // Check if Title exist
  205.     if ($title=="") {
  206.     include("header.php");
  207.     menu(1);
  208.     echo "<br>";
  209.     OpenTable();
  210.     echo "<center><b>"._LINKNOTITLE."</b><br><br>"
  211.         .""._GOBACK."";
  212.     CloseTable();
  213.     include("footer.php");
  214.     }
  215. // Check if URL exist
  216.     if ($url=="") {
  217.     include("header.php");
  218.     menu(1);
  219.     echo "<br>";
  220.     OpenTable();
  221.     echo "<center><b>"._LINKNOURL."</b><br><br>"
  222.         .""._GOBACK."";
  223.     CloseTable();
  224.     include("footer.php");
  225.     }
  226. // Check if Description exist
  227.     if ($description=="") {
  228.     include("header.php");
  229.     menu(1);
  230.     echo "<br>";
  231.     OpenTable();
  232.     echo "<center><b>"._LINKNODESC."</b><br><br>"
  233.         .""._GOBACK."";
  234.     CloseTable();
  235.     include("footer.php");
  236.     }
  237.     $cat = explode("-", $cat);
  238.     if ($cat[1]=="") {
  239.     $cat[1] = 0;
  240.     }
  241.     $title = stripslashes(FixQuotes($title));
  242.     $url = stripslashes(FixQuotes($url));
  243.     $description = stripslashes(FixQuotes($description));
  244.     $auth_name = stripslashes(FixQuotes($auth_name));
  245.     $email = stripslashes(FixQuotes($email));
  246.     sql_query("insert into ".$prefix."_links_newlink values (NULL, '$cat[0]', '$cat[1]', '$title', '$url', '$description', '$auth_name', '$email', '$submitter')", $dbi);
  247.     include("header.php");
  248.     menu(1);
  249.     echo "<br>";
  250.     OpenTable();
  251.     echo "<center><b>"._LINKRECEIVED."</b><br>";
  252.     if ($email != "") {
  253.     echo _EMAILWHENADD;
  254.     } else {
  255.     echo _CHECKFORIT;
  256.     }
  257.     CloseTable();
  258.     include("footer.php");
  259.     }
  260. }
  261.  
  262. function NewLinks($newlinkshowdays) {
  263.     global $prefix, $dbi;
  264.     include("header.php");
  265.     menu(1);
  266.     echo "<br>";
  267.     OpenTable();
  268.     echo "<center><font class=\"option\"><b>"._NEWLINKS."</b></font></center><br>";
  269.     $counter = 0;
  270.     $allweeklinks = 0;
  271.     while ($counter <= 7-1){
  272.     $newlinkdayRaw = (time()-(86400 * $counter));
  273.     $newlinkday = date("d-M-Y", $newlinkdayRaw);
  274.     $newlinkView = date("F d, Y", $newlinkdayRaw);
  275.     $newlinkDB = Date("Y-m-d", $newlinkdayRaw);
  276.     $result = sql_query("select * FROM ".$prefix."_links_links WHERE date LIKE '%$newlinkDB%'", $dbi);
  277.     $totallinks = sql_num_rows($result, $dbi);
  278.     $counter++;
  279.     $allweeklinks = $allweeklinks + $totallinks;
  280.     }
  281.     $counter = 0;
  282.     while ($counter <=30-1){
  283.         $newlinkdayRaw = (time()-(86400 * $counter));
  284.         $newlinkDB = Date("Y-m-d", $newlinkdayRaw);
  285.         $result = sql_query("select * FROM ".$prefix."_links_links WHERE date LIKE '%$newlinkDB%'", $dbi);
  286.         $totallinks = sql_num_rows($result, $dbi);
  287.         $allmonthlinks = $allmonthlinks + $totallinks;
  288.         $counter++;
  289.     }
  290.     echo "<center><b>"._TOTALNEWLINKS.":</b> "._LASTWEEK." - $allweeklinks \ "._LAST30DAYS." - $allmonthlinks<br>"
  291.     .""._SHOW.": <a href=\"modules.php?name=Web_Links&l_op=NewLinks&newlinkshowdays=7\">"._1WEEK."</a> - <a href=\"modules.php?name=Web_Links&l_op=NewLinks&newlinkshowdays=14\">"._2WEEKS."</a> - <a href=\"modules.php?name=Web_Links&l_op=NewLinks&newlinkshowdays=30\">"._30DAYS."</a>"
  292.     ."</center><br>";
  293.     /* List Last VARIABLE Days of Links */
  294.     if (!isset($newlinkshowdays)) {
  295.     $newlinkshowdays = 7;
  296.     }
  297.     echo "<br><center><b>"._TOTALFORLAST." $newlinkshowdays "._DAYS.":</b><br><br>";
  298.     $counter = 0;
  299.     $allweeklinks = 0;
  300.     while ($counter <= $newlinkshowdays-1) {
  301.     $newlinkdayRaw = (time()-(86400 * $counter));
  302.     $newlinkday = date("d-M-Y", $newlinkdayRaw);
  303.     $newlinkView = date("F d, Y", $newlinkdayRaw);
  304.     $newlinkDB = Date("Y-m-d", $newlinkdayRaw);
  305.     $result = sql_query("select * FROM ".$prefix."_links_links WHERE date LIKE '%$newlinkDB%'", $dbi);
  306.     $totallinks = sql_num_rows($result, $dbi);
  307.     $counter++;
  308.     $allweeklinks = $allweeklinks + $totallinks;
  309.     echo "<strong><big>·</big></strong> <a href=\"modules.php?name=Web_Links&l_op=NewLinksDate&selectdate=$newlinkdayRaw\">$newlinkView</a> ($totallinks)<br>";
  310.     }
  311.     $counter = 0;
  312.     $allmonthlinks = 0;
  313.     echo "</center>";
  314.     CloseTable();
  315.     include("footer.php");
  316. }
  317.  
  318. function NewLinksDate($selectdate) {
  319.     global $prefix, $dbi,$admin;
  320.     $admin = base64_decode($admin);
  321.     $admin = explode(":", $admin);
  322.     $aid = "$admin[0]";
  323.     $result3 = sql_query("select radminlink,radminsuper from ".$prefix."_authors where aid='$aid'", $dbi);
  324.     list($radminlink,$radminsuper) = sql_fetch_array($result3, $dbi);
  325.     $dateDB = (date("d-M-Y", $selectdate));
  326.     $dateView = (date("F d, Y", $selectdate));
  327.     include("header.php");
  328.     menu(1);
  329.     echo "<br>";
  330.     OpenTable();
  331.     $newlinkDB = Date("Y-m-d", $selectdate);
  332.     $result = sql_query("select * FROM ".$prefix."_links_links WHERE date LIKE '%$newlinkDB%'", $dbi);
  333.     $totallinks = sql_num_rows($result, $dbi);
  334.     echo "<font class=\"option\"><b>$dateView - $totallinks "._NEWLINKS."</b></font>"
  335.     ."<table width=\"100%\" cellspacing=\"0\" cellpadding=\"10\" border=\"0\"><tr><td><font class=\"content\">";
  336.     $result=sql_query("select lid, cid, sid, title, description, date, hits, linkratingsummary, totalvotes, totalcomments from ".$prefix."_links_links where date LIKE '%$newlinkDB%' order by title ASC", $dbi);
  337.     while(list($lid, $cid, $sid, $title, $description, $time, $hits, $linkratingsummary, $totalvotes, $totalcomments)=sql_fetch_row($result, $dbi)) {
  338.     $linkratingsummary = number_format($linkratingsummary, $mainvotedecimal);
  339.     $title = stripslashes($title); $description = stripslashes($description);
  340.         echo "<a href=\"modules.php?name=Web_Links&l_op=visit&lid=$lid\" target=\"new\">$title</a>";
  341.     newlinkgraphic($datetime, $time);
  342.     popgraphic($hits);
  343.     echo "<br>"._DESCRIPTION.": $description<br>";
  344.     setlocale ("LC_TIME", "$locale");
  345.     /* INSERT code for *editor review* here */
  346.     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);
  347.     $datetime = strftime(""._LINKSDATESTRING."", mktime($datetime[4],$datetime[5],$datetime[6],$datetime[2],$datetime[3],$datetime[1]));
  348.     $datetime = ucfirst($datetime);
  349.     echo ""._ADDEDON.": <b>$datetime</b> "._HITS.": $hits";
  350.         $transfertitle = str_replace (" ", "_", $title);
  351.         /* voting & comments stats */
  352.         if ($totalvotes == 1) {
  353.         $votestring = _VOTE;
  354.         } else {
  355.         $votestring = _VOTES;
  356.     }
  357.         if ($linkratingsummary!="0" || $linkratingsummary!="0.0") {
  358.         echo " "._RATING.": $linkratingsummary ($totalvotes $votestring)";
  359.     }
  360.     echo "<br>";
  361.     if ($radminsuper==1 || $radminlink==1) {
  362.         echo "<a href=\"admin.php?op=LinksModLink&lid=$lid\">"._EDIT."</a> | ";
  363.     }
  364.         echo "<a href=\"modules.php?name=Web_Links&l_op=ratelink&lid=$lid&ttitle=$transfertitle\">"._RATESITE."</a>";
  365.         echo " | <a href=\"modules.php?name=Web_Links&l_op=brokenlink&lid=$lid\">"._REPORTBROKEN."</a>";
  366.     if ($totalvotes != 0) {
  367.         echo " | <a href=\"modules.php?name=Web_Links&l_op=viewlinkdetails&lid=$lid&ttitle=$transfertitle\">"._DETAILS."</a>";
  368.     }
  369.         if ($totalcomments != 0) {
  370.         echo " | <a href=\"modules.php?name=Web_Links&l_op=viewlinkcomments&lid=$lid&ttitle=$transfertitle\">"._SCOMMENTS." ($totalcomments)</a>";
  371.     }
  372.     detecteditorial($lid, $transfertitle);
  373.     echo "<br>";
  374.     $result2=sql_query("select title from ".$prefix."_links_categories where cid=$cid", $dbi);
  375.     list($ctitle) = sql_fetch_row($result2, $dbi);
  376.     $ctitle=getparent($cid,$ctitle);
  377.     echo ""._CATEGORY.": $ctitle";
  378.     echo "<br><br>";
  379.     }
  380.     echo "</font></td></tr></table>";
  381.     CloseTable();
  382.     include("footer.php");
  383. }
  384.  
  385. function TopRated($ratenum, $ratetype) {
  386.     include("header.php");
  387.     include("modules/Web_Links/l_config.php");
  388.     global $prefix, $dbi, $admin;
  389.     menu(1);
  390.     echo "<br>";
  391.     OpenTable();
  392.     echo "<table border=\"0\" width=\"100%\"><tr><td align=\"center\">";
  393.     if ($ratenum != "" && $ratetype != "") {
  394.         $toplinks = $ratenum;
  395.         if ($ratetype == "percent") {
  396.         $toplinkspercentrigger = 1;
  397.     }
  398.     }
  399.     if ($toplinkspercentrigger == 1) {
  400.         $toplinkspercent = $toplinks;
  401.         $result=sql_query("select * from ".$prefix."_links_links where linkratingsummary != 0", $dbi);
  402.         $totalratedlinks = sql_num_rows($result, $dbi);
  403.         $toplinks = $toplinks / 100;
  404.         $toplinks = $totalratedlinks * $toplinks;
  405.         $toplinks = round($toplinks);
  406.     }
  407.     if ($toplinkspercentrigger == 1) {
  408.     echo "<center><font class=\"option\"><b>"._BESTRATED." $toplinkspercent% ("._OF." $totalratedlinks "._TRATEDLINKS.")</b></font></center><br>";
  409.     } else {
  410.     echo "<center><font class=\"option\"><b>"._BESTRATED." $toplinks </b></font></center><br>";
  411.     }
  412.     echo "</td></tr>"
  413.     ."<tr><td><center>"._NOTE." $linkvotemin "._TVOTESREQ."<br>"
  414.     .""._SHOWTOP.":  [ <a href=\"modules.php?name=Web_Links&l_op=TopRated&ratenum=10&ratetype=num\">10</a> - "
  415.     ."<a href=\"modules.php?name=Web_Links&l_op=TopRated&ratenum=25&ratetype=num\">25</a> - "
  416.         ."<a href=\"modules.php?name=Web_Links&l_op=TopRated&ratenum=50&ratetype=num\">50</a> | "
  417.         ."<a href=\"modules.php?name=Web_Links&l_op=TopRated&ratenum=1&ratetype=percent\">1%</a> - "
  418.         ."<a href=\"modules.php?name=Web_Links&l_op=TopRated&ratenum=5&ratetype=percent\">5%</a> - "
  419.         ."<a href=\"modules.php?name=Web_Links&l_op=TopRated&ratenum=10&ratetype=percent\">10%</a> ]</center><br><br></td></tr>";
  420.     $result=sql_query("select lid, cid, sid, title, description, date, hits, linkratingsummary, totalvotes, totalcomments from ".$prefix."_links_links where linkratingsummary != 0 and totalvotes >= $linkvotemin order by linkratingsummary DESC limit 0,$toplinks", $dbi);
  421.     echo "<tr><td>";
  422.     while(list($lid, $cid, $sid, $title, $description, $time, $hits, $linkratingsummary, $totalvotes, $totalcomments)=sql_fetch_row($result, $dbi)) {
  423.     $linkratingsummary = number_format($linkratingsummary, $mainvotedecimal);
  424.     $title = stripslashes($title);
  425.     $description = stripslashes($description);
  426.         echo "<a href=\"modules.php?name=Web_Links&l_op=visit&lid=$lid\" target=\"new\">$title</a>";
  427.     newlinkgraphic($datetime, $time);
  428.     popgraphic($hits);
  429.     echo "<br>";
  430.     echo ""._DESCRIPTION.": $description<br>";
  431.     setlocale ("LC_TIME", "$locale");
  432.     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);
  433.     $datetime = strftime(""._LINKSDATESTRING."", mktime($datetime[4],$datetime[5],$datetime[6],$datetime[2],$datetime[3],$datetime[1]));
  434.     $datetime = ucfirst($datetime);
  435.     echo ""._ADDEDON.": $datetime "._HITS.": $hits";
  436.     $transfertitle = str_replace (" ", "_", $title);
  437.     /* voting & comments stats */
  438.         if ($totalvotes == 1) {
  439.         $votestring = _VOTE;
  440.         } else {
  441.         $votestring = _VOTES;
  442.     }
  443.     if ($linkratingsummary!="0" || $linkratingsummary!="0.0") {
  444.         echo " "._RATING.": <b> $linkratingsummary </b> ($totalvotes $votestring)";
  445.     }
  446.     echo "<br><a href=\"modules.php?name=Web_Links&l_op=ratelink&lid=$lid&ttitle=$transfertitle\">"._RATESITE."</a>";
  447.     echo " | <a href=\"modules.php?name=Web_Links&l_op=brokenlink&lid=$lid\">"._REPORTBROKEN."</a>";
  448.     if ($totalvotes != 0) {
  449.         echo " | <a href=\"modules.php?name=Web_Links&l_op=viewlinkdetails&lid=$lid&ttitle=$transfertitle\">"._DETAILS."</a>";
  450.     }
  451.     if ($totalcomments != 0) {
  452.         echo " | <a href=\"modules.php?name=Web_Links&l_op=viewlinkcomments&lid=$lid&ttitle=$transfertitle\">"._SCOMMENTS." ($totalcomments)</a>";
  453.     }
  454.     detecteditorial($lid, $transfertitle);
  455.     echo "<br>";
  456.     $result2=sql_query("select title from ".$prefix."_links_categories where cid=$cid", $dbi);
  457.     list($ctitle) = sql_fetch_row($result2, $dbi);
  458.     $ctitle=getparent($cid,$ctitle);
  459.     echo ""._CATEGORY.": $ctitle";
  460.     echo "<br><br>";
  461.  
  462.     echo "<br><br>";
  463.     }
  464.     echo "</font></td></tr></table>";
  465.     CloseTable();
  466.     include("footer.php");
  467. }
  468.  
  469. function MostPopular($ratenum, $ratetype) {
  470. global $prefix,$admin,$dbi;
  471.     $admin = base64_decode($admin);
  472.     $admin = explode(":", $admin);
  473.     $aid = "$admin[0]";
  474.     $result3 = sql_query("select radminlink,radminsuper from ".$prefix."_authors where aid='$aid'", $dbi);
  475.     list($radminlink,$radminsuper) = sql_fetch_array($result3, $dbi);
  476.     include("header.php");
  477.     include("modules/Web_Links/l_config.php");
  478.     global $prefix, $dbi, $admin;
  479.     menu(1);
  480.     echo "<br>";
  481.     OpenTable();
  482.     echo "<table border=\"0\" width=\"100%\"><tr><td align=\"center\">";
  483.     if ($ratenum != "" && $ratetype != "") {
  484.         $mostpoplinks = $ratenum;
  485.         if ($ratetype == "percent") $mostpoplinkspercentrigger = 1;
  486.     }
  487.     if ($mostpoplinkspercentrigger == 1) {
  488.         $toplinkspercent = $mostpoplinks;
  489.         $result=sql_query("select * from ".$prefix."_links_links", $dbi);
  490.         $totalmostpoplinks = sql_num_rows($result, $dbi);
  491.         $mostpoplinks = $mostpoplinks / 100;
  492.         $mostpoplinks = $totalmostpoplinks * $mostpoplinks;
  493.         $mostpoplinks = round($mostpoplinks);
  494.     }
  495.     if ($mostpoplinkspercentrigger == 1) {
  496.     echo "<center><font class=\"option\"><b>"._MOSTPOPULAR." $toplinkspercent% ("._OFALL." $totalmostpoplinks "._LINKS.")</b></font></center>";
  497.     } else {
  498.     echo "<center><font class=\"option\"><b>"._MOSTPOPULAR." $mostpoplinks</b></font></center>";
  499.     }
  500.     echo "<tr><td><center>"._SHOWTOP.": [ <a href=\"modules.php?name=Web_Links&l_op=MostPopular&ratenum=10&ratetype=num\">10</a> - "
  501.     ."<a href=\"modules.php?name=Web_Links&l_op=MostPopular&ratenum=25&ratetype=num\">25</a> - "
  502.         ."<a href=\"modules.php?name=Web_Links&l_op=MostPopular&ratenum=50&ratetype=num\">50</a> | "
  503.         ."<a href=\"modules.php?name=Web_Links&l_op=MostPopular&ratenum=1&ratetype=percent\">1%</a> - "
  504.         ."<a href=\"modules.php?name=Web_Links&l_op=MostPopular&ratenum=5&ratetype=percent\">5%</a> - "
  505.         ."<a href=\"modules.php?name=Web_Links&l_op=MostPopular&ratenum=10&ratetype=percent\">10%</a> ]</center><br><br></td></tr>";
  506.     $result=sql_query("select lid, cid, sid, title, description, date, hits, linkratingsummary, totalvotes, totalcomments from ".$prefix."_links_links order by hits DESC limit 0,$mostpoplinks", $dbi);
  507.     echo "<tr><td>";
  508.     while(list($lid, $cid, $sid, $title, $description, $time, $hits, $linkratingsummary, $totalvotes, $totalcomments)=sql_fetch_row($result, $dbi)) {
  509.     $linkratingsummary = number_format($linkratingsummary, $mainvotedecimal);
  510.     $title = stripslashes($title);
  511.     $description = stripslashes($description);
  512.         echo "<font class=\"content\"><a href=\"modules.php?name=Web_Links&l_op=visit&lid=$lid\" target=\"new\">$title</a>";
  513.     newlinkgraphic($datetime, $time);
  514.     popgraphic($hits);
  515.     echo "<br>";
  516.     echo ""._DESCRIPTION.": $description<br>";
  517.     setlocale ("LC_TIME", "$locale");
  518.     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);
  519.     $datetime = strftime(""._LINKSDATESTRING."", mktime($datetime[4],$datetime[5],$datetime[6],$datetime[2],$datetime[3],$datetime[1]));
  520.     $datetime = ucfirst($datetime);
  521.     echo ""._ADDEDON.": $datetime "._HITS.": <b>$hits</b>";
  522.     $transfertitle = str_replace (" ", "_", $title);
  523.     /* voting & comments stats */
  524.         if ($totalvotes == 1) {
  525.         $votestring = _VOTE;
  526.         } else {
  527.         $votestring = _VOTES;
  528.     }
  529.     if ($linkratingsummary!="0" || $linkratingsummary!="0.0") {
  530.         echo " "._RATING.": $linkratingsummary ($totalvotes $votestring)";
  531.     }
  532.     echo "<br>";
  533.     if ($radminsuper==1 || $radminlink==1) {
  534.         echo "<a href=\"admin.php?op=LinksModLink&lid=$lid\">"._EDIT."</a> | ";
  535.     }
  536.     echo "<a href=\"modules.php?name=Web_Links&l_op=ratelink&lid=$lid&ttitle=$transfertitle\">"._RATESITE."</a>";
  537.     echo " | <a href=\"modules.php?name=Web_Links&l_op=brokenlink&lid=$lid\">"._REPORTBROKEN."</a>";
  538.     if ($totalvotes != 0) {
  539.         echo " | <a href=\"modules.php?name=Web_Links&l_op=viewlinkdetails&lid=$lid&ttitle=$transfertitle\">"._DETAILS."</a>";
  540.     }
  541.     if ($totalcomments != 0) {
  542.         echo " | <a href=\"modules.php?name=Web_Links&l_op=viewlinkcomments&lid=$lid&ttitle=$transfertitle\">"._SCOMMENTS." ($totalcomments)</a>";
  543.     }
  544.     detecteditorial($lid, $transfertitle);
  545.     echo "<br>";
  546.     $result2=sql_query("select title from ".$prefix."_links_categories where cid=$cid", $dbi);
  547.     list($ctitle) = sql_fetch_row($result2, $dbi);
  548.     $ctitle=getparent($cid,$ctitle);
  549.     echo ""._CATEGORY.": $ctitle";
  550.     echo "<br><br>";
  551.  
  552.     echo "<br><br></font>";
  553.     }
  554.     echo "</font></td></tr></table>";
  555.     CloseTable();
  556.     include("footer.php");
  557. }
  558.  
  559. function RandomLink() {
  560.     global $prefix, $dbi;
  561.     $result = sql_query("select * from ".$prefix."_links_links", $dbi);
  562.     $numrows = sql_num_rows($result, $dbi);
  563.     if ($numrows == 1) {
  564.     $random = 1;
  565.     } else {
  566.     srand((double)microtime()*1000000);
  567.     $random = rand(1,$numrows);
  568.     }
  569.     $result2 = sql_query("select url from ".$prefix."_links_links where lid='$random'", $dbi);
  570.     list($url) = sql_fetch_row($result2, $dbi);
  571.     sql_query("update ".$prefix."_links_links set hits=hits+1 where lid=$random", $dbi);
  572.     Header("Location: $url");
  573. }
  574.  
  575. function viewlink($cid, $min, $orderby, $show) {
  576.     global $prefix, $dbi, $admin, $perpage;
  577.     $admin = base64_decode($admin);
  578.     $admin = explode(":", $admin);
  579.     $aid = "$admin[0]";
  580.     $result3 = sql_query("select radminlink,radminsuper from ".$prefix."_authors where aid='$aid'", $dbi);
  581.     list($radminlink,$radminsuper) = sql_fetch_array($result3, $dbi);
  582.     include("header.php");
  583.     if (!isset($min)) $min=0;
  584.     if (!isset($max)) $max=$min+$perpage;
  585.     if(isset($orderby)) {
  586.         $orderby = convertorderbyin($orderby);
  587.     } else {
  588.         $orderby = "title ASC";
  589.     }
  590.     if ($show!="") {
  591.         $perpage = $show;
  592.     } else {
  593.         $show=$perpage;
  594.     }
  595.     
  596.     menu(1);
  597.     echo "<br>";
  598.     OpenTable();
  599.     $result = sql_query("select title,parentid from ".$prefix."_links_categories where cid=$cid", $dbi);
  600.     list($title,$parentid)=sql_fetch_row($result, $dbi);
  601.     $title=getparentlink($parentid,$title);
  602.     $title="<a href=modules.php?name=Web_Links>"._MAIN."</a>/$title";
  603.     echo "<center><font class=\"option\"><b>"._CATEGORY.": $title</b></font></center><br>";
  604.     echo "<table border=\"0\" cellspacing=\"10\" cellpadding=\"0\" align=\"center\"><tr>";
  605.     $result2 = sql_query("select cid, title, cdescription from ".$prefix."_links_categories where parentid=$cid order by title", $dbi);
  606.     $count = 0;
  607.     while(list($cid2, $title2, $cdescription2) = sql_fetch_row($result2, $dbi)) {
  608.     echo "<td><font class=\"option\"><strong><big>╖</big></strong> <a href=\"modules.php?name=Web_Links&l_op=viewlink&cid=$cid2\"><b>$title2</b></a></font>";
  609.     categorynewlinkgraphic($cid2);
  610.     if ($description) {
  611.         echo "<font class=\"content\">$cdescription2</font><br>";
  612.     } else {
  613.         echo "<br>";
  614.     }
  615.     $result3 = sql_query("select cid, title from ".$prefix."_links_categories where parentid=$cid2 order by title limit 0,3", $dbi);
  616.     $space = 0;
  617.     while(list($cid3, $title3) = sql_fetch_row($result3, $dbi)) {
  618.             if ($space>0) {
  619.         echo ", ";
  620.         }
  621.         echo "<font class=\"content\"><a href=\"modules.php?name=Web_Links&l_op=viewlink&cid=$cid3\">$title3</a></font>";
  622.         $space++;
  623.     }
  624.     if ($count<1) {
  625.         echo "</td><td>    </td>";
  626.         $dum = 1;
  627.     }
  628.     $count++;
  629.     if ($count==2) {
  630.         echo "</td></tr><tr>";
  631.         $count = 0;
  632.         $dum = 0;
  633.     }
  634.     }
  635.     if ($dum == 1) {
  636.     echo "</tr></table>";
  637.     } elseif ($dum == 0) {
  638.     echo "<td></td></tr></table>";
  639.     }
  640.  
  641.     echo "<hr noshade size=\"1\">";
  642.     $orderbyTrans = convertorderbytrans($orderby);
  643.     echo "<center><font class=\"content\">"._SORTLINKSBY.": "
  644.         .""._TITLE." (<a href=\"modules.php?name=Web_Links&l_op=viewlink&cid=$cid&orderby=titleA\">A</a>\<a href=\"modules.php?name=Web_Links&l_op=viewlink&cid=$cid&orderby=titleD\">D</a>) "
  645.         .""._DATE." (<a href=\"modules.php?name=Web_Links&l_op=viewlink&cid=$cid&orderby=dateA\">A</a>\<a href=\"modules.php?name=Web_Links&l_op=viewlink&cid=$cid&orderby=dateD\">D</a>) "
  646.         .""._RATING." (<a href=\"modules.php?name=Web_Links&l_op=viewlink&cid=$cid&orderby=ratingA\">A</a>\<a href=\"modules.php?name=Web_Links&l_op=viewlink&cid=$cid&orderby=ratingD\">D</a>) "
  647.         .""._POPULARITY." (<a href=\"modules.php?name=Web_Links&l_op=viewlink&cid=$cid&orderby=hitsA\">A</a>\<a href=\"modules.php?name=Web_Links&l_op=viewlink&cid=$cid&orderby=hitsD\">D</a>)"
  648.     ."<br><b>"._SITESSORTED.": $orderbyTrans</b></font></center><br><br>";
  649.     $result=sql_query("select lid, title, description, date, hits, linkratingsummary, totalvotes, totalcomments from ".$prefix."_links_links where cid=$cid order by $orderby limit $min,$perpage", $dbi);
  650.     $fullcountresult=sql_query("select lid, title, description, date, hits, linkratingsummary, totalvotes, totalcomments from ".$prefix."_links_links where cid=$cid", $dbi);
  651.     $totalselectedlinks = sql_num_rows($fullcountresult, $dbi);
  652.     echo "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"10\" border=\"0\"><tr><td><font class=\"content\">";
  653.     $x=0;
  654.     while(list($lid, $title, $description, $time, $hits, $linkratingsummary, $totalvotes, $totalcomments)=sql_fetch_row($result, $dbi)) {
  655.     $linkratingsummary = number_format($linkratingsummary, $mainvotedecimal);
  656.     $title = stripslashes($title);
  657.     $description = stripslashes($description);
  658.         echo "<a href=\"modules.php?name=Web_Links&l_op=visit&lid=$lid\" target=\"new\"><b>$title</b></a>";
  659.     newlinkgraphic($datetime, $time);
  660.     popgraphic($hits);
  661.     /* INSERT code for *editor review* here */
  662.     echo "<br>";
  663.     echo ""._DESCRIPTION.": $description<br>";
  664.     setlocale ("LC_TIME", "$locale");
  665.     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);
  666.     $datetime = strftime(""._LINKSDATESTRING."", mktime($datetime[4],$datetime[5],$datetime[6],$datetime[2],$datetime[3],$datetime[1]));
  667.     $datetime = ucfirst($datetime);
  668.     echo ""._ADDEDON.": $datetime "._HITS.": $hits";
  669.         $transfertitle = str_replace (" ", "_", $title);
  670.         /* voting & comments stats */
  671.         if ($totalvotes == 1) {
  672.         $votestring = _VOTE;
  673.         } else {
  674.         $votestring = _VOTES;
  675.     }
  676.         if ($linkratingsummary!="0" || $linkratingsummary!="0.0") {
  677.         echo " "._RATING.": $linkratingsummary ($totalvotes $votestring)";
  678.     }
  679.         echo "<br>";
  680.         if ($radminsuper==1 || $radminlink==1) {
  681.             echo "<a href=\"admin.php?op=LinksModLink&lid=$lid\">"._EDIT."</a> | ";
  682.         }
  683.         echo "<a href=\"modules.php?name=Web_Links&l_op=ratelink&lid=$lid&ttitle=$transfertitle\">"._RATESITE."</a>";
  684.         echo " | <a href=\"modules.php?name=Web_Links&l_op=brokenlink&lid=$lid\">"._REPORTBROKEN."</a>";
  685.     if ($totalvotes != 0) {
  686.         echo " | <a href=\"modules.php?name=Web_Links&l_op=viewlinkdetails&lid=$lid&ttitle=$transfertitle\">"._DETAILS."</a>";
  687.     }
  688.         if ($totalcomments != 0) {
  689.         echo " | <a href=\"modules.php?name=Web_Links&l_op=viewlinkcomments&lid=$lid&ttitle=$transfertitle\">"._SCOMMENTS." ($totalcomments)</a>";
  690.     }
  691.         detecteditorial($lid, $transfertitle);
  692.     echo "<br><br>";
  693.     $x++;
  694.     }
  695.     echo "</font>";
  696.     $orderby = convertorderbyout($orderby);
  697.     /* Calculates how many pages exist. Which page one should be on, etc... */
  698.     $linkpagesint = ($totalselectedlinks / $perpage);
  699.     $linkpageremainder = ($totalselectedlinks % $perpage);
  700.     if ($linkpageremainder != 0) {
  701.         $linkpages = ceil($linkpagesint);
  702.         if ($totalselectedlinks < $perpage) {
  703.             $linkpageremainder = 0;
  704.         }
  705.     } else {
  706.         $linkpages = $linkpagesint;
  707.     }
  708.     /* Page Numbering */
  709.     if ($linkpages!=1 && $linkpages!=0) {
  710.         echo "<br><br>";
  711.           echo ""._SELECTPAGE.": ";
  712.          $prev=$min-$perpage;
  713.          if ($prev>=0) {
  714.             echo "  <b>[ <a href=\"modules.php?name=Web_Links&l_op=viewlink&cid=$cid&min=$prev&orderby=$orderby&show=$show\">";
  715.             echo " << "._PREVIOUS."</a> ]</b> ";
  716.       }
  717.         $counter = 1;
  718.      $currentpage = ($max / $perpage);
  719.            while ($counter<=$linkpages ) {
  720.               $cpage = $counter;
  721.               $mintemp = ($perpage * $counter) - $perpage;
  722.               if ($counter == $currentpage) {
  723.         echo "<b>$counter</b> ";
  724.         } else {
  725.         echo "<a href=\"modules.php?name=Web_Links&l_op=viewlink&cid=$cid&min=$mintemp&orderby=$orderby&show=$show\">$counter</a> ";
  726.         }
  727.                $counter++;
  728.            }
  729.          $next=$min+$perpage;
  730.          if ($x>=$perpage) {
  731.             echo "  <b>[ <a href=\"modules.php?name=Web_Links&l_op=viewlink&cid=$cid&min=$max&orderby=$orderby&show=$show\">";
  732.             echo " "._NEXT." >></a> ]</b> ";
  733.          }
  734.     }
  735.     echo "</td></tr></table>";
  736.     CloseTable();
  737.     include("footer.php");
  738. }
  739.  
  740. function newlinkgraphic($datetime, $time) {
  741.     global $module_name;
  742.     echo " ";
  743.     setlocale ("LC_TIME", "$locale");
  744.     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);
  745.     $datetime = strftime(""._LINKSDATESTRING."", mktime($datetime[4],$datetime[5],$datetime[6],$datetime[2],$datetime[3],$datetime[1]));
  746.     $datetime = ucfirst($datetime);
  747.     $startdate = time();
  748.     $count = 0;
  749.     while ($count <= 7) {
  750.     $daysold = date("d-M-Y", $startdate);
  751.         if ("$daysold" == "$datetime") {
  752.             if ($count<=1) {
  753.         echo "<img src=\"modules/$module_name/images/newred.gif\" alt=\""._NEWTODAY."\">";
  754.         }
  755.             if ($count<=3 && $count>1) {
  756.         echo "<img src=\"modules/$module_name/images/newgreen.gif\" alt=\""._NEWLAST3DAYS."\">";
  757.         }
  758.             if ($count<=7 && $count>3) {
  759.         echo "<img src=\"modules/$module_name/images/newblue.gif\" alt=\""._NEWTHISWEEK."\">";
  760.         }
  761.     }
  762.         $count++;
  763.         $startdate = (time()-(86400 * $count));
  764.     }
  765. }
  766.  
  767. function categorynewlinkgraphic($cat) {
  768.     global $prefix, $dbi, $module_name;
  769.     $newresult = sql_query("select date from ".$prefix."_links_links where cid=$cat order by date desc limit 1", $dbi);
  770.     list($time)=sql_fetch_row($newresult, $dbi);
  771.     echo " ";
  772.     setlocale ("LC_TIME", "$locale");
  773.     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);
  774.     $datetime = strftime(""._LINKSDATESTRING."", mktime($datetime[4],$datetime[5],$datetime[6],$datetime[2],$datetime[3],$datetime[1]));
  775.     $datetime = ucfirst($datetime);
  776.     $startdate = time();
  777.     $count = 0;
  778.     while ($count <= 7) {
  779.     $daysold = date("d-M-Y", $startdate);
  780.         if ("$daysold" == "$datetime") {
  781.             if ($count<=1) {
  782.         echo "<img src=\"modules/$module_name/images/newred.gif\" alt=\""._CATNEWTODAY."\">";
  783.         }
  784.             if ($count<=3 && $count>1) {
  785.         echo "<img src=\"modules/$module_name/images/newgreen.gif\" alt=\""._CATLAST3DAYS."\">";
  786.         }
  787.             if ($count<=7 && $count>3) {
  788.         echo "<img src=\"modules/$module_name/images/newblue.gif\" alt=\""._CATTHISWEEK."\">";
  789.         }
  790.     }
  791.         $count++;
  792.         $startdate = (time()-(86400 * $count));
  793.     }
  794. }
  795.  
  796. function popgraphic($hits) {
  797.     global $module_name;
  798.     include("modules/Web_Links/l_config.php");
  799.     if ($hits>=$popular) {
  800.     echo " <img src=\"modules/$module_name/images/pop.gif\" alt=\""._POPULAR."\">";
  801.     }
  802. }
  803.  
  804. function convertorderbyin($orderby) {
  805.     if ($orderby == "titleA")    $orderby = "title ASC";
  806.     if ($orderby == "dateA")    $orderby = "date ASC";
  807.     if ($orderby == "hitsA")    $orderby = "hits ASC";
  808.     if ($orderby == "ratingA")    $orderby = "linkratingsummary ASC";
  809.     if ($orderby == "titleD")    $orderby = "title DESC";
  810.     if ($orderby == "dateD")    $orderby = "date DESC";
  811.     if ($orderby == "hitsD")    $orderby = "hits DESC";
  812.     if ($orderby == "ratingD")    $orderby = "linkratingsummary DESC";
  813.     return $orderby;
  814. }
  815.  
  816. function convertorderbytrans($orderby) {
  817.     if ($orderby == "hits ASC")            $orderbyTrans = ""._POPULARITY1."";
  818.     if ($orderby == "hits DESC")        $orderbyTrans = ""._POPULARITY2."";
  819.     if ($orderby == "title ASC")        $orderbyTrans = ""._TITLEAZ."";
  820.     if ($orderby == "title DESC")        $orderbyTrans = ""._TITLEZA."";
  821.     if ($orderby == "date ASC")            $orderbyTrans = ""._DATE1."";
  822.     if ($orderby == "date DESC")        $orderbyTrans = ""._DATE2."";
  823.     if ($orderby == "linkratingsummary ASC")    $orderbyTrans = ""._RATING1."";
  824.     if ($orderby == "linkratingsummary DESC")    $orderbyTrans = ""._RATING2."";
  825.     return $orderbyTrans;
  826. }
  827.  
  828. function convertorderbyout($orderby) {
  829.     if ($orderby == "title ASC")        $orderby = "titleA";
  830.     if ($orderby == "date ASC")            $orderby = "dateA";
  831.     if ($orderby == "hits ASC")            $orderby = "hitsA";
  832.     if ($orderby == "linkratingsummary ASC")    $orderby = "ratingA";
  833.     if ($orderby == "title DESC")        $orderby = "titleD";
  834.     if ($orderby == "date DESC")        $orderby = "dateD";
  835.     if ($orderby == "hits DESC")        $orderby = "hitsD";
  836.     if ($orderby == "linkratingsummary DESC")    $orderby = "ratingD";
  837.     return $orderby;
  838. }
  839.  
  840. function visit($lid) {
  841.     global $prefix, $dbi;
  842.     sql_query("update ".$prefix."_links_links set hits=hits+1 where lid=$lid", $dbi);
  843.     $result = sql_query("select url from ".$prefix."_links_links where lid=$lid", $dbi);
  844.     list($url) = sql_fetch_row($result, $dbi);
  845.     Header("Location: $url");
  846. }
  847.  
  848. function search($query, $min, $orderby, $show) {
  849.     include("modules/Web_Links/l_config.php");
  850.     global $prefix, $dbi, $admin, $bgcolor2;
  851.     if (!isset($min)) $min=0;
  852.     if (!isset($max)) $max=$min+$linksresults;
  853.     if(isset($orderby)) {
  854.     $orderby = convertorderbyin($orderby);
  855.     } else {
  856.     $orderby = "title ASC";
  857.     }
  858.     if ($show!="") {
  859.     $linksresults = $show;
  860.     } else {
  861.     $show=$linksresults;
  862.     }
  863.     $query = addslashes($query);
  864.     $result = sql_query("select lid, cid, sid, title, url, description, date, hits, linkratingsummary, totalvotes, totalcomments from ".$prefix."_links_links where title LIKE '%$query%' OR description LIKE '%$query%' ORDER BY $orderby LIMIT $min,$linksresults", $dbi);
  865.     $fullcountresult=sql_query("select lid, title, description, date, hits, linkratingsummary, totalvotes, totalcomments from ".$prefix."_links_links where title LIKE '%$query%' OR description LIKE '%$query%'", $dbi);
  866.     $totalselectedlinks = sql_num_rows($fullcountresult, $dbi);
  867.     $nrows  = sql_num_rows($result, $dbi);
  868.     $x=0;
  869.     include("header.php");
  870.     $the_query = stripslashes($query);
  871.     $the_query = str_replace("\'", "'", $the_query);
  872.     menu(1);
  873.     echo "<br>";
  874.     OpenTable();
  875.     if ($query != "") {
  876.         if ($nrows>0) {
  877.         echo "<font class=\"option\">"._SEARCHRESULTS4.": <b>$the_query</b></font><br><br>"
  878.             ."<table width=\"100%\" bgcolor=\"$bgcolor2\"><tr><td><font class=\"option\"><b>"._USUBCATEGORIES."</b></font></td></tr></table>";
  879.  
  880.         $result2 = sql_query("select cid, title from ".$prefix."_links_categories where title LIKE '%$query%' ORDER BY title DESC", $dbi);
  881.         while(list($cid, $stitle) = sql_fetch_row($result2, $dbi)) {
  882.             $res = sql_query("select * from ".$prefix."_links_links where cid=$cid", $dbi);
  883.             $numrows = sql_num_rows($res, $dbi);
  884.             $result3 = sql_query("select cid,title,parentid from ".$prefix."_links_categories where cid=$cid", $dbi);
  885.             list($cid3,$title3,$parentid3) = sql_fetch_row($result3, $dbi);
  886.             if ($parentid3>0) $title3 = getparent($parentid3,$title3);
  887.             $title3 = ereg_replace($query, "<b>$query</b>", $title3);
  888.             echo "<strong><big>╖</big></strong> <a href=\"modules.php?name=Web_Links&l_op=viewlink&cid=$cid\">$title3</a> ($numrows)<br>";
  889.         }
  890.  
  891.     echo "<br><table width=\"100%\" bgcolor=\"$bgcolor2\"><tr><td><font class=\"option\"><b>"._LINKS."</b></font></td></tr></table>";
  892.         $orderbyTrans = convertorderbytrans($orderby);
  893.         echo "<br><font class=\"content\">"._SORTLINKSBY.": "
  894.             .""._TITLE." (<a href=\"modules.php?name=Web_Links&l_op=search&query=$the_query&orderby=titleA\">A</a>\<a href=\"modules.php?name=Web_Links&l_op=search&query=$the_query&orderby=titleD\">D</a>)"
  895.             .""._DATE." (<a href=\"modules.php?name=Web_Links&l_op=search&query=$the_query&orderby=dateA\">A</a>\<a href=\"modules.php?name=Web_Links&l_op=search&query=$the_query&orderby=dateD\">D</a>)"
  896.             .""._RATING." (<a href=\"modules.php?name=Web_Links&l_op=search&query=$the_query&orderby=ratingA\">A</a>\<a href=\"modules.php?name=Web_Links&l_op=search&query=$the_query&orderby=ratingD\">D</a>)"
  897.             .""._POPULARITY." (<a href=\"modules.php?name=Web_Links&l_op=search&query=$the_query&orderby=hitsA\">A</a>\<a href=\"modules.php?name=Web_Links&l_op=search&query=$the_query&orderby=hitsD\">D</a>)"
  898.             ."<br>"._SITESSORTED.": $orderbyTrans<br><br>";
  899.         while(list($lid, $cid, $sid, $title, $url, $description, $time, $hits, $linkratingsummary, $totalvotes, $totalcomments) = sql_fetch_row($result, $dbi)) {
  900.         $linkratingsummary = number_format($linkratingsummary, $mainvotedecimal);
  901.         $title = stripslashes($title); $description = stripslashes($description);
  902.         $transfertitle = str_replace (" ", "_", $title);
  903.         $title = ereg_replace($query, "<b>$query</b>", $title);
  904.         echo "<a href=\"modules.php?name=Web_Links&l_op=visit&lid=$lid\" target=\"new\">$title</a>";
  905.         newlinkgraphic($datetime, $time);
  906.             popgraphic($hits);
  907.         echo "<br>";
  908.         $description = ereg_replace($query, "<b>$query</b>", $description);
  909.         echo ""._DESCRIPTION.": $description<br>";
  910.         setlocale ("LC_TIME", "$locale");
  911.         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);
  912.         $datetime = strftime(""._LINKSDATESTRING."", mktime($datetime[4],$datetime[5],$datetime[6],$datetime[2],$datetime[3],$datetime[1]));
  913.         $datetime = ucfirst($datetime);
  914.         echo ""._ADDEDON.": $datetime "._HITS.": $hits";
  915.             /* voting & comments stats */
  916.             if ($totalvotes == 1) {
  917.         $votestring = _VOTE;
  918.         } else {
  919.         $votestring = _VOTES;
  920.         }
  921.             if ($linkratingsummary!="0" || $linkratingsummary!="0.0") {
  922.         echo " "._RATING.": $linkratingsummary ($totalvotes $votestring)";
  923.         }
  924.             echo "<br><a href=\"modules.php?name=Web_Links&l_op=ratelink&lid=$lid&ttitle=$transfertitle\">"._RATESITE."</a>";
  925.             if ($totalvotes != 0) {
  926.         echo " | <a href=\"modules.php?name=Web_Links&l_op=viewlinkdetails&lid=$lid&ttitle=$transfertitle\">"._DETAILS."</a>";
  927.         }
  928.             if ($totalcomments != 0) {
  929.         echo " | <a href=\"modules.php?name=Web_Links&l_op=viewlinkcomments&lid=$lid&ttitle=$transfertitle>"._SCOMMENTS." ($totalcomments)</a>";
  930.         }
  931.         detecteditorial($lid, $transfertitle);
  932.         echo "<br>";
  933.         $result3 = sql_query("select cid,title,parentid from ".$prefix."_links_categories where cid=$cid", $dbi);
  934.         list($cid3,$title3,$parentid3) = sql_fetch_row($result3, $dbi);
  935.         if ($parentid3>0) $title3 = getparent($parentid3,$title3);
  936.         echo ""._CATEGORY.": $title3<br><br>";
  937.         $x++;
  938.     }
  939.     echo "</font>";
  940.         $orderby = convertorderbyout($orderby);
  941.     } else {
  942.     echo "<br><br><center><font class=\"option\"><b>"._NOMATCHES."</b></font><br><br>"._GOBACK."<br></center>";
  943.     }
  944.     /* Calculates how many pages exist.  Which page one should be on, etc... */
  945.     $linkpagesint = ($totalselectedlinks / $linksresults);
  946.     $linkpageremainder = ($totalselectedlinks % $linksresults);
  947.     if ($linkpageremainder != 0) {
  948.         $linkpages = ceil($linkpagesint);
  949.         if ($totalselectedlinks < $linksresults) {
  950.             $linkpageremainder = 0;
  951.     }
  952.     } else {
  953.         $linkpages = $linkpagesint;
  954.     }
  955.     /* Page Numbering */
  956.     if ($linkpages!=1 && $linkpages!=0) {
  957.     echo "<br><br>"
  958.         .""._SELECTPAGE.": ";
  959.     $prev=$min-$linksresults;
  960.     if ($prev>=0) {
  961.             echo "  <b>[ <a href=\"modules.php?name=Web_Links&l_op=search&query=$the_query&min=$prev&orderby=$orderby&show=$show\">"
  962.             ." << "._PREVIOUS."</a> ]</b> ";
  963.           }
  964.     $counter = 1;
  965.         $currentpage = ($max / $linksresults);
  966.         while ($counter<=$linkpages ) {
  967.             $cpage = $counter;
  968.             $mintemp = ($perpage * $counter) - $linksresults;
  969.             if ($counter == $currentpage) {
  970.         echo "<b>$counter</b> ";
  971.         } else {
  972.         echo "<a href=\"modules.php?name=Web_Links&l_op=search&query=$the_query&min=$mintemp&orderby=$orderby&show=$show\">$counter</a> ";
  973.         }
  974.             $counter++;
  975.         }
  976.         $next=$min+$linksresults;
  977.         if ($x>=$perpage) {
  978.             echo "  <b>[ <a href=\"modules.php?name=Web_Links&l_op=search&query=$the_query&min=$max&orderby=$orderby&show=$show\">"
  979.             ." "._NEXT." >></a> ]</b>";
  980.         }
  981.     }
  982.     echo "<br><br><center><font class=\"content\">"
  983.     .""._TRY2SEARCH." \"$the_query\" "._INOTHERSENGINES."<br>"
  984.     ."<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> - "
  985.     ."<a target=\"_blank\" href=\"http://www.hotbot.com/?MT=$the_query&DU=days&SW=web\">HotBot</a> - "
  986.     ."<a target=\"_blank\" href=\"http://www.infoseek.com/Titles?qt=$the_query\">Infoseek</a> - "
  987.     ."<a target=\"_blank\" href=\"http://www.dejanews.com/dnquery.xp?QRY=$the_query\">Deja News</a> - "
  988.     ."<a target=\"_blank\" href=\"http://www.lycos.com/cgi-bin/pursuit?query=$the_query&maxhits=20\">Lycos</a> - "
  989.     ."<a target=\"_blank\" href=\"http://search.yahoo.com/bin/search?p=$the_query\">Yahoo</a>"
  990.     ."<br>"
  991.     ."<a target=\"_blank\" href=\"http://es.linuxstart.com/cgi-bin/sqlsearch.cgi?pos=1&query=$the_query&language=&advanced=&urlonly=&withid=\">LinuxStart</a> - "
  992.     ."<a target=\"_blank\" href=\"http://search.1stlinuxsearch.com/compass?scope=$the_query&ui=sr\">1stLinuxSearch</a> - "
  993.     ."<a target=\"_blank\" href=\"http://www.google.com/search?q=$the_query\">Google</a> - "
  994.     ."<a target=\"_blank\" href=\"http://www.linuxlinks.com/cgi-bin/search.cgi?query=$the_query&engine=Links\">LinuxLinks</a> - "
  995.     ."<a target=\"_blank\" href=\"http://www.freshmeat.net/modules.php?name=Search&query=$the_query\">Freshmeat</a> - "
  996.     ."<a target=\"_blank\" href=\"http://www.justlinux.com/bin/search.pl?key=$the_query\">JustLinux</a>"
  997.     ."</font>";
  998.     } else {
  999.     echo "<center><font class=\"option\"><b>"._NOMATCHES."</b></font></center><br><br>";
  1000.     }
  1001.     CloseTable();
  1002.     include("footer.php");
  1003. }
  1004.  
  1005. function viewlinkeditorial($lid, $ttitle) {
  1006.     global $prefix, $dbi, $admin;
  1007.     include("header.php");
  1008.     include("modules/Web_Links/l_config.php");
  1009.     menu(1);
  1010.  
  1011.     $result=sql_query("SELECT adminid, editorialtimestamp, editorialtext, editorialtitle FROM ".$prefix."_links_editorials WHERE linkid = $lid", $dbi);
  1012.     $recordexist = sql_num_rows($result, $dbi);
  1013.  
  1014.     $transfertitle = ereg_replace ("_", " ", $ttitle);
  1015.     $displaytitle = $transfertitle;
  1016.     echo "<br>";
  1017.     OpenTable();
  1018.     echo "<center><font class=\"option\"><b>"._LINKPROFILE.": $displaytitle</b></font><br>";
  1019.     linkinfomenu($lid, $ttitle);
  1020.     if ($recordexist != 0) {
  1021.     while(list($adminid, $editorialtimestamp, $editorialtext, $editorialtitle)=sql_fetch_row($result, $dbi)) {
  1022.             $editorialtitle = stripslashes($editorialtitle); $editorialtext = stripslashes($editorialtext);
  1023.             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);
  1024.         $editorialtime = strftime("%F",mktime($editorialtime[4],$editorialtime[5],$editorialtime[6],$editorialtime[2],$editorialtime[3],$editorialtime[1]));
  1025.         $date_array = explode("-", $editorialtime);
  1026.         $timestamp = mktime(0, 0, 0, $date_array["1"], $date_array["2"], $date_array["0"]);
  1027.                $formatted_date = date("F j, Y", $timestamp);
  1028.         echo "<br><br>";
  1029.            OpenTable2();
  1030.         echo "<center><font class=\"option\"><b>'$editorialtitle'</b></font></center>"
  1031.         ."<center><font class=\"tiny\">"._EDITORIALBY." $adminid - $formatted_date</font></center><br><br>"
  1032.         ."$editorialtext";
  1033.         CloseTable2();
  1034.         }
  1035.     } else {
  1036.         echo "<br><br><center><font class=\"option\"><b>"._NOEDITORIAL."</b></font></center>";
  1037.     }
  1038.     echo "<br><br><center>";
  1039.     linkfooter($lid,$ttitle);
  1040.     echo "</center>";
  1041.     CloseTable();
  1042.     include("footer.php");
  1043. }
  1044.  
  1045. function detecteditorial($lid, $ttitle) {
  1046.     global $prefix, $dbi;
  1047.     $resulted2 = sql_query("select adminid from ".$prefix."_links_editorials where linkid=$lid", $dbi);
  1048.     $recordexist = sql_num_rows($resulted2, $dbi);
  1049.     if ($recordexist != 0) {
  1050.     echo " | <a href=\"modules.php?name=Web_Links&l_op=viewlinkeditorial&lid=$lid&ttitle=$ttitle\">"._EDITORIAL."</a>";
  1051.     }
  1052. }
  1053.  
  1054. function viewlinkcomments($lid, $ttitle) {
  1055.     global $prefix, $dbi, $admin, $bgcolor2, $module_name;
  1056.     include("header.php");
  1057.     include("modules/Web_Links/l_config.php");
  1058.     menu(1);
  1059.     echo "<br>";
  1060.     $result=sql_query("SELECT ratinguser, rating, ratingcomments, ratingtimestamp FROM ".$prefix."_links_votedata WHERE ratinglid = $lid AND ratingcomments != '' ORDER BY ratingtimestamp DESC", $dbi);
  1061.     $totalcomments = sql_num_rows($result, $dbi);
  1062.     $transfertitle = ereg_replace ("_", " ", $ttitle);
  1063.     $displaytitle = $transfertitle;
  1064.     OpenTable();
  1065.     echo "<center><font class=\"option\"><b>"._LINKPROFILE.": $displaytitle</b></font><br><br>";
  1066.     linkinfomenu($lid, $ttitle);
  1067.     echo "<br><br><br>"._TOTALOF." $totalcomments "._COMMENTS."</font></center><br>"
  1068.     ."<table align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\" width=\"450\">";
  1069.     $x=0;
  1070.     while(list($ratinguser, $rating, $ratingcomments, $ratingtimestamp)=sql_fetch_row($result, $dbi)) {
  1071.         $ratingcomments = stripslashes($ratingcomments);
  1072.         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);
  1073.     $ratingtime = strftime("%F",mktime($ratingtime[4],$ratingtime[5],$ratingtime[6],$ratingtime[2],$ratingtime[3],$ratingtime[1]));
  1074.     $date_array = explode("-", $ratingtime);
  1075.     $timestamp = mktime(0, 0, 0, $date_array["1"], $date_array["2"], $date_array["0"]);
  1076.         $formatted_date = date("F j, Y", $timestamp);
  1077.     /* Individual user information */
  1078.     $result2=sql_query("SELECT rating FROM ".$prefix."_links_votedata WHERE ratinguser = '$ratinguser'", $dbi);
  1079.         $usertotalcomments = sql_num_rows($result2, $dbi);
  1080.         $useravgrating = 0;
  1081.         while(list($rating2)=sql_fetch_row($result2, $dbi))
  1082.     $useravgrating = $useravgrating + $rating2;
  1083.         $useravgrating = $useravgrating / $usertotalcomments;
  1084.         $useravgrating = number_format($useravgrating, 1);
  1085.         echo "<tr><td bgcolor=\"$bgcolor2\">"
  1086.             ."<font class=\"content\"><b> "._USER.": </b><a href=\"$nukeurl/modules.php?name=Your_Account&op=userinfo&uname=$ratinguser\">$ratinguser</a></font>"
  1087.         ."</td>"
  1088.         ."<td bgcolor=\"$bgcolor2\">"
  1089.         ."<font class=\"content\"><b>"._RATING.": </b>$rating</font>"
  1090.         ."</td>"
  1091.         ."<td bgcolor=\"$bgcolor2\" align=\"right\">"
  1092.             ."<font class=\"content\">$formatted_date</font>"
  1093.         ."</td>"
  1094.         ."</tr>"
  1095.         ."<tr>"
  1096.         ."<td valign=\"top\">"
  1097.         ."<font class=\"tiny\">"._USERAVGRATING.": $useravgrating</font>"
  1098.         ."</td>"
  1099.         ."<td valign=\"top\" colspan=\"2\">"
  1100.         ."<font class=\"tiny\">"._NUMRATINGS.": $usertotalcomments</font>"
  1101.         ."</td>"
  1102.         ."</tr>"
  1103.             ."<tr>"
  1104.         ."<td colspan=\"3\">"
  1105.         ."<font class=\"content\">";
  1106.         if (is_admin($admin)) {
  1107.         echo "<a href=\"admin.php?op=LinksModLink&lid=$lid\"><img src=\"modules/$module_name/images/editicon.gif\" border=\"0\" alt=\""._EDITTHISLINK."\"></a>";
  1108.         }
  1109.     echo " $ratingcomments</font>"
  1110.         ."<br><br><br></td></tr>";
  1111.     $x++;
  1112.     }
  1113.     echo "</table><br><br><center>";
  1114.     linkfooter($lid,$ttitle);
  1115.     echo "</center>";
  1116.     CloseTable();
  1117.     include("footer.php");
  1118. }
  1119.  
  1120. function viewlinkdetails($lid, $ttitle) {
  1121.     global $prefix, $dbi, $admin, $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4;
  1122.     include("header.php");
  1123.     include("modules/Web_Links/l_config.php");
  1124.     menu(1);
  1125.     $voteresult = sql_query("select rating, ratinguser, ratingcomments FROM ".$prefix."_links_votedata WHERE ratinglid = $lid", $dbi);
  1126.     $totalvotesDB = sql_num_rows($voteresult, $dbi);
  1127.     $anonvotes = 0;
  1128.     $anonvoteval = 0;
  1129.     $outsidevotes = 0;
  1130.     $outsidevoteeval = 0;
  1131.     $regvoteval = 0;
  1132.     $topanon = 0;
  1133.     $bottomanon = 11;
  1134.     $topreg = 0;
  1135.     $bottomreg = 11;
  1136.     $topoutside = 0;
  1137.     $bottomoutside = 11;
  1138.     $avv = array(0,0,0,0,0,0,0,0,0,0,0);
  1139.     $rvv = array(0,0,0,0,0,0,0,0,0,0,0);
  1140.     $ovv = array(0,0,0,0,0,0,0,0,0,0,0);
  1141.     $truecomments = $totalvotesDB;
  1142.     while(list($ratingDB, $ratinguserDB, $ratingcommentsDB)=sql_fetch_row($voteresult, $dbi)) {
  1143.      if ($ratingcommentsDB=="") $truecomments--;
  1144.         if ($ratinguserDB==$anonymous) {
  1145.         $anonvotes++;
  1146.         $anonvoteval += $ratingDB;
  1147.     }
  1148.     if ($useoutsidevoting == 1) {
  1149.         if ($ratinguserDB=='outside') {
  1150.         $outsidevotes++;
  1151.             $outsidevoteval += $ratingDB;
  1152.         }
  1153.     } else {
  1154.         $outsidevotes = 0;
  1155.     }
  1156.     if ($ratinguserDB!=$anonymous && $ratinguserDB!="outside") {
  1157.         $regvoteval += $ratingDB;
  1158.     }
  1159.     if ($ratinguserDB!=$anonymous && $ratinguserDB!="outside") {
  1160.         if ($ratingDB > $topreg) $topreg = $ratingDB;
  1161.         if ($ratingDB < $bottomreg) $bottomreg = $ratingDB;
  1162.         for ($rcounter=1; $rcounter<11; $rcounter++) if ($ratingDB==$rcounter) $rvv[$rcounter]++;
  1163.     }
  1164.     if ($ratinguserDB==$anonymous) {
  1165.         if ($ratingDB > $topanon) $topanon = $ratingDB;
  1166.         if ($ratingDB < $bottomanon) $bottomanon = $ratingDB;
  1167.         for ($rcounter=1; $rcounter<11; $rcounter++) if ($ratingDB==$rcounter) $avv[$rcounter]++;
  1168.     }
  1169.     if ($ratinguserDB=="outside") {
  1170.         if ($ratingDB > $topoutside) $topoutside = $ratingDB;
  1171.         if ($ratingDB < $bottomoutside) $bottomoutside = $ratingDB;
  1172.         for ($rcounter=1; $rcounter<11; $rcounter++) if ($ratingDB==$rcounter) $ovv[$rcounter]++;
  1173.     }
  1174.     }
  1175.     $regvotes = $totalvotesDB - $anonvotes - $outsidevotes;
  1176.     if ($totalvotesDB == 0) {
  1177.     $finalrating = 0;
  1178.     } else if ($anonvotes == 0 && $regvotes == 0) {
  1179.     /* Figure Outside Only Vote */
  1180.     $finalrating = $outsidevoteval / $outsidevotes;
  1181.     $finalrating = number_format($finalrating, $detailvotedecimal);
  1182.     $avgOU = $outsidevoteval / $totalvotesDB;
  1183.     $avgOU = number_format($avgOU, $detailvotedecimal);
  1184.     } else if ($outsidevotes == 0 && $regvotes == 0) {
  1185.      /* Figure Anon Only Vote */
  1186.     $finalrating = $anonvoteval / $anonvotes;
  1187.     $finalrating = number_format($finalrating, $detailvotedecimal);
  1188.     $avgAU = $anonvoteval / $totalvotesDB;
  1189.     $avgAU = number_format($avgAU, $detailvotedecimal);
  1190.     } else if ($outsidevotes == 0 && $anonvotes == 0) {
  1191.     /* Figure Reg Only Vote */
  1192.     $finalrating = $regvoteval / $regvotes;
  1193.     $finalrating = number_format($finalrating, $detailvotedecimal);
  1194.     $avgRU = $regvoteval / $totalvotesDB;
  1195.     $avgRU = number_format($avgRU, $detailvotedecimal);
  1196.     } else if ($regvotes == 0 && $useoutsidevoting == 1 && $outsidevotes != 0 && $anonvotes != 0 ) {
  1197.      /* Figure Reg and Anon Mix */
  1198.      $avgAU = $anonvoteval / $anonvotes;
  1199.     $avgOU = $outsidevoteval / $outsidevotes;
  1200.     if ($anonweight > $outsideweight ) {
  1201.         /* Anon is 'standard weight' */
  1202.         $newimpact = $anonweight / $outsideweight;
  1203.         $impactAU = $anonvotes;
  1204.         $impactOU = $outsidevotes / $newimpact;
  1205.         $finalrating = ((($avgOU * $impactOU) + ($avgAU * $impactAU)) / ($impactAU + $impactOU));
  1206.         $finalrating = number_format($finalrating, $detailvotedecimal);
  1207.     } else {
  1208.         /* Outside is 'standard weight' */
  1209.         $newimpact = $outsideweight / $anonweight;
  1210.         $impactOU = $outsidevotes;
  1211.         $impactAU = $anonvotes / $newimpact;
  1212.         $finalrating = ((($avgOU * $impactOU) + ($avgAU * $impactAU)) / ($impactAU + $impactOU));
  1213.         $finalrating = number_format($finalrating, $detailvotedecimal);
  1214.     }
  1215.     } else {
  1216.          /* REG User vs. Anonymous vs. Outside User Weight Calutions */
  1217.          $impact = $anonweight;
  1218.          $outsideimpact = $outsideweight;
  1219.          if ($regvotes == 0) {
  1220.         $avgRU = 0;
  1221.     } else {
  1222.         $avgRU = $regvoteval / $regvotes;
  1223.     }
  1224.     if ($anonvotes == 0) {
  1225.         $avgAU = 0;
  1226.     } else {
  1227.         $avgAU = $anonvoteval / $anonvotes;
  1228.     }
  1229.     if ($outsidevotes == 0 ) {
  1230.         $avgOU = 0;
  1231.     } else {
  1232.         $avgOU = $outsidevoteval / $outsidevotes;
  1233.     }
  1234.     $impactRU = $regvotes;
  1235.     $impactAU = $anonvotes / $impact;
  1236.     $impactOU = $outsidevotes / $outsideimpact;
  1237.     $finalrating = (($avgRU * $impactRU) + ($avgAU * $impactAU) + ($avgOU * $impactOU)) / ($impactRU + $impactAU + $impactOU);
  1238.     $finalrating = number_format($finalrating, $detailvotedecimal);
  1239.     }
  1240.     if ($avgOU == 0 || $avgOU == "") {
  1241.     $avgOU = "";
  1242.     } else {
  1243.     $avgOU = number_format($avgOU, $detailvotedecimal);
  1244.     }
  1245.     if ($avgRU == 0 || $avgRU == "") {
  1246.     $avgRU = "";
  1247.     } else {
  1248.     $avgRU = number_format($avgRU, $detailvotedecimal);
  1249.     }
  1250.     if ($avgAU == 0 || $avgAU == "") {
  1251.     $avgAU = "";
  1252.     } else {
  1253.     $avgAU = number_format($avgAU, $detailvotedecimal);
  1254.     }
  1255.     if ($topanon == 0) $topanon = "";
  1256.     if ($bottomanon == 11) $bottomanon = "";
  1257.     if ($topreg == 0) $topreg = "";
  1258.     if ($bottomreg == 11) $bottomreg = "";
  1259.     if ($topoutside == 0) $topoutside = "";
  1260.     if ($bottomoutside == 11) $bottomoutside = "";
  1261.     $totalchartheight = 70;
  1262.     $chartunits = $totalchartheight / 10;
  1263.     $avvper        = array(0,0,0,0,0,0,0,0,0,0,0);
  1264.     $rvvper         = array(0,0,0,0,0,0,0,0,0,0,0);
  1265.     $ovvper         = array(0,0,0,0,0,0,0,0,0,0,0);
  1266.     $avvpercent     = array(0,0,0,0,0,0,0,0,0,0,0);
  1267.     $rvvpercent     = array(0,0,0,0,0,0,0,0,0,0,0);
  1268.     $ovvpercent     = array(0,0,0,0,0,0,0,0,0,0,0);
  1269.     $avvchartheight    = array(0,0,0,0,0,0,0,0,0,0,0);
  1270.     $rvvchartheight    = array(0,0,0,0,0,0,0,0,0,0,0);
  1271.     $ovvchartheight    = array(0,0,0,0,0,0,0,0,0,0,0);
  1272.     $avvmultiplier = 0;
  1273.     $rvvmultiplier = 0;
  1274.     $ovvmultiplier = 0;
  1275.     for ($rcounter=1; $rcounter<11; $rcounter++) {
  1276.         if ($anonvotes != 0) $avvper[$rcounter] = $avv[$rcounter] / $anonvotes;
  1277.         if ($regvotes != 0) $rvvper[$rcounter] = $rvv[$rcounter] / $regvotes;
  1278.         if ($outsidevotes != 0) $ovvper[$rcounter] = $ovv[$rcounter] / $outsidevotes;
  1279.         $avvpercent[$rcounter] = number_format($avvper[$rcounter] * 100, 1);
  1280.         $rvvpercent[$rcounter] = number_format($rvvper[$rcounter] * 100, 1);
  1281.         $ovvpercent[$rcounter] = number_format($ovvper[$rcounter] * 100, 1);
  1282.         if ($avv[$rcounter] > $avvmultiplier) $avvmultiplier = $avv[$rcounter];
  1283.         if ($rvv[$rcounter] > $rvvmultiplier) $rvvmultiplier = $rvv[$rcounter];
  1284.         if ($ovv[$rcounter] > $ovvmultiplier) $ovvmultiplier = $ovv[$rcounter];
  1285.     }
  1286.     if ($avvmultiplier != 0) $avvmultiplier = 10 / $avvmultiplier;
  1287.     if ($rvvmultiplier != 0) $rvvmultiplier = 10 / $rvvmultiplier;
  1288.     if ($ovvmultiplier != 0) $ovvmultiplier = 10 / $ovvmultiplier;
  1289.     for ($rcounter=1; $rcounter<11; $rcounter++) {
  1290.         $avvchartheight[$rcounter] = ($avv[$rcounter] * $avvmultiplier) * $chartunits;
  1291.         $rvvchartheight[$rcounter] = ($rvv[$rcounter] * $rvvmultiplier) * $chartunits;
  1292.         $ovvchartheight[$rcounter] = ($ovv[$rcounter] * $ovvmultiplier) * $chartunits;
  1293.         if ($avvchartheight[$rcounter]==0) $avvchartheight[$rcounter]=1;
  1294.         if ($rvvchartheight[$rcounter]==0) $rvvchartheight[$rcounter]=1;
  1295.         if ($ovvchartheight[$rcounter]==0) $ovvchartheight[$rcounter]=1;
  1296.     }
  1297.     $transfertitle = ereg_replace ("_", " ", $ttitle);
  1298.     $displaytitle = $transfertitle;
  1299.     echo "<br>";
  1300.     OpenTable();
  1301.     echo "<center><font class=\"option\"><b>"._LINKPROFILE.": $displaytitle</b></font><br><br>";
  1302.     linkinfomenu($lid, $ttitle);
  1303.     echo "<br><br>"._LINKRATINGDET."<br>"
  1304.         .""._TOTALVOTES." $totalvotesDB<br>"
  1305.         .""._OVERALLRATING.": $finalrating</center><br><br>"
  1306.     ."<table align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\" width=\"455\">"
  1307.     ."<tr><td colspan=\"2\" bgcolor=\"$bgcolor2\">"
  1308.     ."<font class=\"content\"><b>"._REGISTEREDUSERS."</b></font>"
  1309.     ."</td></tr>"
  1310.     ."<tr>"
  1311.     ."<td bgcolor=\"$bgcolor1\">"
  1312.         ."<font class=\"content\">"._NUMBEROFRATINGS.": $regvotes</font>"
  1313.     ."</td>"
  1314.     ."<td rowspan=\"5\" width=\"200\">";
  1315.     if ($regvotes==0) {
  1316.     echo "<center><font class=\"content\">"._NOREGUSERSVOTES."</font></center>";
  1317.     } else {
  1318.            echo "<table border=\"1\" width=\"200\">"
  1319.             ."<tr>"
  1320.         ."<td valign=\"top\" align=\"center\" colspan=\"10\" bgcolor=\"$bgcolor2\"><font class=\"content\">"._BREAKDOWNBYVAL."</font></td>"
  1321.         ."</tr>"
  1322.         ."<tr>"
  1323.         ."<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>"
  1324.         ."<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>"
  1325.         ."<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>"
  1326.         ."<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>"
  1327.         ."<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>"
  1328.         ."<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>"
  1329.         ."<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>"
  1330.         ."<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>"
  1331.         ."<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>"
  1332.         ."<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>"
  1333.         ."</tr>"
  1334.         ."<tr><td colspan=\"10\" bgcolor=\"$bgcolor2\">"
  1335.         ."<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"200\"><tr>"
  1336.         ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">1</font></td>"
  1337.         ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">2</font></td>"
  1338.         ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">3</font></td>"
  1339.         ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">4</font></td>"
  1340.         ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">5</font></td>"
  1341.         ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">6</font></td>"
  1342.         ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">7</font></td>"
  1343.         ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">8</font></td>"
  1344.         ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">9</font></td>"
  1345.         ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">10</font></td>"
  1346.         ."</tr></table>"
  1347.         ."</td></tr></table>";
  1348.     }
  1349.     echo "</td>"
  1350.     ."</tr>"
  1351.     ."<tr><td bgcolor=\"$bgcolor2\"><font class=\"content\">"._LINKRATING.": $avgRU</font></td></tr>"
  1352.     ."<tr><td bgcolor=\"$bgcolor1\"><font class=\"content\">"._HIGHRATING.": $topreg</font></td></tr>"
  1353.     ."<tr><td bgcolor=\"$bgcolor2\"><font class=\"content\">"._LOWRATING.": $bottomreg</font></td></tr>"
  1354.     ."<tr><td bgcolor=\"$bgcolor1\"><font class=\"content\">"._NUMOFCOMMENTS.": $truecomments</font></td></tr>"
  1355.     ."<tr><td></td></tr>"
  1356.     ."<tr><td valign=\"top\" colspan=\"2\"><font class=\"tiny\"><br><br>"._WEIGHNOTE." $anonweight "._TO." 1.</font></td></tr>"
  1357.         ."<tr><td colspan=\"2\" bgcolor=\"$bgcolor2\"><font class=\"content\"><b>"._UNREGISTEREDUSERS."</b></font></td></tr>"
  1358.     ."<tr><td bgcolor=\"$bgcolor1\"><font class=\"content\">"._NUMBEROFRATINGS.": $anonvotes</font></td>"
  1359.     ."<td rowspan=\"5\" width=\"200\">";
  1360.     if ($anonvotes==0) {
  1361.     echo "<center><font class=\"content\">"._NOUNREGUSERSVOTES."</font></center>";
  1362.     } else {
  1363.         echo "<table border=\"1\" width=\"200\">"
  1364.             ."<tr>"
  1365.         ."<td valign=\"top\" align=\"center\" colspan=\"10\" bgcolor=\"$bgcolor2\"><font class=\"content\">"._BREAKDOWNBYVAL."</font></td>"
  1366.         ."</tr>"
  1367.         ."<tr>"
  1368.         ."<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>"
  1369.         ."<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>"
  1370.         ."<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>"
  1371.         ."<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>"
  1372.         ."<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>"
  1373.         ."<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>"
  1374.         ."<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>"
  1375.         ."<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>"
  1376.         ."<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>"
  1377.         ."<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>"
  1378.         ."</tr>"
  1379.         ."<tr><td colspan=\"10\" bgcolor=\"$bgcolor2\">"
  1380.         ."<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"200\"><tr>"
  1381.         ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">1</font></td>"
  1382.         ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">2</font></td>"
  1383.         ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">3</font></td>"
  1384.         ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">4</font></td>"
  1385.         ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">5</font></td>"
  1386.         ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">6</font></td>"
  1387.         ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">7</font></td>"
  1388.         ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">8</font></td>"
  1389.         ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">9</font></td>"
  1390.         ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">10</font></td>"
  1391.         ."</tr></table>"
  1392.         ."</td></tr></table>";
  1393.     }
  1394.     echo "</td>"
  1395.     ."</tr>"
  1396.     ."<tr><td bgcolor=\"$bgcolor2\"><font class=\"content\">"._LINKRATING.": $avgAU</font></td></tr>"
  1397.     ."<tr><td bgcolor=\"$bgcolor1\"><font class=\"content\">"._HIGHRATING.": $topanon</font></td></tr>"
  1398.     ."<tr><td bgcolor=\"$bgcolor2\"><font class=\"content\">"._LOWRATING.": $bottomanon</font></td></tr>"
  1399.     ."<tr><td bgcolor=\"$bgcolor1\"><font class=\"content\"> </font></td></tr>";
  1400.     if ($useoutsidevoting == 1) {
  1401.     echo "<tr><td valign=top colspan=\"2\"><font class=\"tiny\"><br><br>"._WEIGHOUTNOTE." $outsideweight "._TO." 1.</font></td></tr>"
  1402.         ."<tr><td colspan=\"2\" bgcolor=\"$bgcolor2\"><font class=\"content\"><b>"._OUTSIDEVOTERS."</b></font></td></tr>"
  1403.         ."<tr><td bgcolor=\"$bgcolor1\"><font class=\"content\">"._NUMBEROFRATINGS.": $outsidevotes</font></td>"
  1404.         ."<td rowspan=\"5\" width=\"200\">";
  1405.         if ($outsidevotes==0) {
  1406.         echo "<center><font class=\"content\">"._NOOUTSIDEVOTES."</font></center>";
  1407.     } else {
  1408.         echo "<table border=\"1\" width=\"200\">"
  1409.             ."<tr>"
  1410.           ."<td valign=\"top\" align=\"center\" colspan=\"10\" bgcolor=\"$bgcolor2\"><font class=\"content\">"._BREAKDOWNBYVAL."</font></td>"
  1411.           ."</tr>"
  1412.           ."<tr>"
  1413.           ."<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>"
  1414.           ."<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>"
  1415.           ."<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>"
  1416.           ."<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>"
  1417.           ."<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>"
  1418.           ."<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>"
  1419.           ."<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>"
  1420.           ."<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>"
  1421.           ."<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>"
  1422.           ."<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>"
  1423.           ."</tr>"
  1424.           ."<tr><td colspan=\"10\" bgcolor=\"$bgcolor2\">"
  1425.           ."<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"200\"><tr>"
  1426.           ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">1</font></td>"
  1427.           ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">2</font></td>"
  1428.           ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">3</font></td>"
  1429.           ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">4</font></td>"
  1430.           ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">5</font></td>"
  1431.           ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">6</font></td>"
  1432.           ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">7</font></td>"
  1433.           ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">8</font></td>"
  1434.           ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">9</font></td>"
  1435.           ."<td width=\"10%\" valign=\"bottom\" align=\"center\"><font class=\"content\">10</font></td>"
  1436.           ."</tr></table>"
  1437.           ."</td></tr></table>";
  1438.       }
  1439.     echo "</td>"
  1440.         ."</tr>"
  1441.         ."<tr><td bgcolor=\"$bgcolor2\"><font class=\"content\">"._LINKRATING.": $avgOU</font></td></tr>"
  1442.         ."<tr><td bgcolor=\"$bgcolor1\"><font class=\"content\">"._HIGHRATING.": $topoutside</font></td></tr>"
  1443.         ."<tr><td bgcolor=\"$bgcolor2\"><font class=\"content\">"._LOWRATING.": $bottomoutside</font></td></tr>"
  1444.         ."<tr><td bgcolor=\"$bgcolor1\"><font class=\"content\"> </font></td></tr>";
  1445.     }
  1446.     echo "</table><br><br><center>";
  1447.     linkfooter($lid,$ttitle);
  1448.     echo "</center>";
  1449.     CloseTable();
  1450.     include("footer.php");
  1451. }
  1452.  
  1453. function linkfooter($lid,$ttitle) {
  1454.     echo "<font class=\"content\">[ <a href=\"modules.php?name=Web_Links&l_op=visit&lid=$lid\" target=\"_blank\">"._VISITTHISSITE."</a> | <a href=\"modules.php?name=Web_Links&l_op=ratelink&lid=$lid&ttitle=$ttitle\">"._RATETHISSITE."</a> ]</font><br><br>";
  1455.     linkfooterchild($lid);
  1456. }
  1457.  
  1458. function linkfooterchild($lid) {
  1459.     include("modules/Web_Links/l_config.php");
  1460.     if ($useoutsidevoting = 1) {
  1461.     echo "<br><font class=\"content\">"._ISTHISYOURSITE." <a href=\"modules.php?name=Web_Links&l_op=outsidelinksetup&lid=$lid\">"._ALLOWTORATE."</a></font>";
  1462.     }
  1463. }
  1464.  
  1465. function outsidelinksetup($lid) {
  1466.     global $module_name, $sitename, $nukeurl;
  1467.     include("header.php");
  1468.     include("modules/Web_Links/l_config.php");
  1469.     menu(1);
  1470.     echo "<br>";
  1471.     OpenTable();
  1472.     echo "<center><font class=\"option\"><b>"._PROMOTEYOURSITE."</b></font></center><br><br>
  1473.  
  1474.     "._PROMOTE01."<br><br>
  1475.  
  1476.     <b>1) "._TEXTLINK."</b><br><br>
  1477.  
  1478.     "._PROMOTE02."<br><br>
  1479.     <center><a href=\"$nukeurl/modules.php?name=Web_Links&l_op=ratelink&lid=$lid\">"._RATETHISSITE." @ $sitename</a></center><br><br>
  1480.     <center>"._HTMLCODE1."</center><br>
  1481.     <center><i><a href=\"$nukeurl/modules.php?name=Web_Links&l_op=ratelink&lid=$lid\">"._RATETHISSITE."</a></i></center>
  1482.     <br><br>
  1483.     "._THENUMBER." \"$lid\" "._IDREFER."<br><br>
  1484.  
  1485.     <b>2) "._BUTTONLINK."</b><br><br>
  1486.  
  1487.     "._PROMOTE03."<br><br>
  1488.  
  1489.     <center>
  1490.     <form action=\"modules.php?name=Web_Links\" method=\"post\">\n
  1491.     <input type=\"hidden\" name=\"lid\" value=\"$lid\">\n
  1492.     <input type=\"hidden\" name=\"l_op\" value=\"ratelink\">\n
  1493.     <input type=\"submit\" value=\""._RATEIT."\">\n
  1494.     </form>\n
  1495.     </center>
  1496.  
  1497.     <center>"._HTMLCODE2."</center><br><br>
  1498.  
  1499.     <table border=\"0\" align=\"center\"><tr><td align=\"left\"><i>
  1500.     <form action=\"$nukeurl/modules.php?name=Web_Links\" method=\"post\"><br>\n
  1501.       <input type=\"hidden\" name=\"lid\" value=\"$lid\"><br>\n
  1502.       <input type=\"hidden\" name=\"l_op\" value=\"ratelink\"><br>\n
  1503.       <input type=\"submit\" value=\""._RATEIT."\"><br>\n
  1504.     </form>\n
  1505.     </i></td></tr></table>
  1506.  
  1507.     <br><br>
  1508.  
  1509.     <b>3) "._REMOTEFORM."</b><br><br>
  1510.  
  1511.     "._PROMOTE04."
  1512.  
  1513.     <center>
  1514.     <form method=\"post\" action=\"$nukeurl/modules.php?name=Web_Links\">
  1515.     <table align=\"center\" border=\"0\" width=\"175\" cellspacing=\"0\" cellpadding=\"0\">
  1516.     <tr><td align=\"center\"><b>"._VOTE4THISSITE."</b></a></td></tr>
  1517.     <tr><td>
  1518.     <table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">
  1519.     <tr><td valign=\"top\">
  1520.         <select name=\"rating\">
  1521.         <option selected>--</option>
  1522.     <option>10</option>
  1523.     <option>9</option>
  1524.     <option>8</option>
  1525.     <option>7</option>
  1526.     <option>6</option>
  1527.     <option>5</option>
  1528.     <option>4</option>
  1529.     <option>3</option>
  1530.     <option>2</option>
  1531.     <option>1</option>
  1532.     </select>
  1533.     </td><td valign=\"top\">
  1534.     <input type=\"hidden\" name=\"ratinglid\" value=\"$lid\">
  1535.         <input type=\"hidden\" name=\"ratinguser\" value=\"outside\">
  1536.         <input type=\"hidden\" name=\"op value=\"addrating\">
  1537.     <input type=\"submit\" value=\""._LINKVOTE."\">
  1538.     </td></tr></table>
  1539.     </td></tr></table></form>
  1540.  
  1541.     <br>"._HTMLCODE3."<br><br></center>
  1542.  
  1543.     <blockquote><i>
  1544.     <form method=\"post\" action=\"$nukeurl/modules.php?name=Web_Links\"><br>
  1545.     <table align=\"center\" border=\"0\" width=\"175\" cellspacing=\"0\" cellpadding=\"0\"><br>
  1546.         <tr><td align=\"center\"><b>"._VOTE4THISSITE."</b></a></td></tr><br>
  1547.         <tr><td><br>
  1548.         <table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\"><br>
  1549.         <tr><td valign=\"top\"><br>
  1550.             <select name=\"rating\"><br>
  1551.             <option selected>--</option><br>
  1552.         <option>10</option><br>
  1553.         <option>9</option><br>
  1554.         <option>8</option><br>
  1555.         <option>7</option><br>
  1556.         <option>6</option><br>
  1557.         <option>5</option><br>
  1558.         <option>4</option><br>
  1559.         <option>3</option><br>
  1560.         <option>2</option><br>
  1561.         <option>1</option><br>
  1562.         </select><br>
  1563.         </td><td valign=\"top\"><br>
  1564.         <input type=\"hidden\" name=\"ratinglid\" value=\"$lid\"><br>
  1565.             <input type=\"hidden\" name=\"ratinguser\" value=\"outside\"><br>
  1566.             <input type=\"hidden\" name=\"l_op\" value=\"addrating\"><br>
  1567.         <input type=\"submit\" value=\""._LINKVOTE."\"><br>
  1568.         </td></tr></table><br>
  1569.     </td></tr></table><br>
  1570.     </form><br>
  1571.     </i></blockquote>
  1572.     <br><br><center>
  1573.     "._PROMOTE05."<br><br>
  1574.     - $sitename "._STAFF."
  1575.     <br><br></center>";
  1576.     CloseTable();
  1577.     include("footer.php");
  1578. }
  1579.  
  1580. function brokenlink($lid) {
  1581.     include("header.php");
  1582.     include("modules/Web_Links/l_config.php");
  1583.     global $prefix, $dbi, $user;
  1584.     if(is_user($user)) {
  1585.         $user2 = base64_decode($user);
  1586.        $cookie = explode(":", $user2);
  1587.     cookiedecode($user);
  1588.     $ratinguser = $cookie[1];
  1589.     } else {
  1590.     $ratinguser = "$anonymous";
  1591.     }
  1592.     menu(1);
  1593.     echo "<br>";
  1594.  
  1595.     $result = sql_query("select cid, title, url, description from ".$prefix."_links_links where lid=$lid", $dbi);
  1596.     list($cid, $title, $url, $description) = sql_fetch_row($result, $dbi);
  1597.  
  1598.     OpenTable();
  1599.     echo "<center><font class=\"option\"><b>"._REPORTBROKEN."</b></font><br><br><br><font class=\"content\">";
  1600.     echo "<form action=\"modules.php?name=Web_Links\" method=\"post\">";
  1601.     echo "<input type=\"hidden\" name=\"lid\" value=\"$lid\">";
  1602.     echo "<input type=\"hidden\" name=\"cid\" value=\"$cid\">";
  1603.     echo "<input type=\"hidden\" name=\"title\" value=\"$title\">";
  1604.     echo "<input type=\"hidden\" name=\"url\" value=\"$url\">";
  1605.     echo "<input type=\"hidden\" name=\"description\" value=\"$description\">";
  1606.     echo "<input type=\"hidden\" name=\"modifysubmitter\" value=\"$ratinguser\">";
  1607.     echo ""._THANKSBROKEN."<br><br>";
  1608.     echo "<input type=\"hidden\" name=\"l_op\" value=\"brokenlinkS\"><input type=\"submit\" value=\""._REPORTBROKEN."\"></center></form>";
  1609.     CloseTable();
  1610.     include("footer.php");
  1611. }
  1612.  
  1613. function brokenlinkS($lid,$cid, $title, $url, $description, $modifysubmitter) {
  1614.     include("modules/Web_Links/l_config.php");
  1615.     global $prefix, $dbi, $user;
  1616.     if(is_user($user)) {
  1617.     $user2 = base64_decode($user);
  1618.        $cookie = explode(":", $user2);
  1619.     cookiedecode($user);
  1620.     $ratinguser = $cookie[1];
  1621.     } else {
  1622.     $ratinguser = "$anonymous";
  1623.     }
  1624.     sql_query("insert into ".$prefix."_links_modrequest values (NULL, $lid, $cid, 0, '$title', '$url', '$description', '$ratinguser', 1)", $dbi);
  1625.     include("header.php");
  1626.     //echo "insert into ".$prefix."_links_modrequest values (NULL, $lid, $cid, 0, '$title', '$url', '$description', '$ratinguser', 1)";
  1627.     menu(1);
  1628.     echo "<br>";
  1629.     OpenTable();
  1630.     echo "<br><center>"._THANKSFORINFO."<br><br>"._LOOKTOREQUEST."</center><br>";
  1631.     CloseTable();
  1632.     include("footer.php");
  1633. }
  1634.  
  1635. function modifylinkrequest($lid) {
  1636.     include("header.php");
  1637.     include("modules/Web_Links/l_config.php");
  1638.     global $prefix, $dbi, $user;
  1639.     if(is_user($user)) {
  1640.         $user2 = base64_decode($user);
  1641.        $cookie = explode(":", $user2);
  1642.     cookiedecode($user);
  1643.     $ratinguser = $cookie[1];
  1644.     } else {
  1645.     $ratinguser = "$anonymous";
  1646.     }
  1647.     menu(1);
  1648.     echo "<br>";
  1649.     OpenTable();
  1650.     $blocknow = 0;
  1651.     if ($blockunregmodify == 1 && $ratinguser=="$anonymous") {
  1652.     echo "<br><br><center>"._ONLYREGUSERSMODIFY."</center>";
  1653.     $blocknow = 1;
  1654.     }
  1655.     if ($blocknow != 1) {
  1656.         $result = sql_query("select cid, sid, title, url, description from ".$prefix."_links_links where lid=$lid", $dbi);
  1657.         echo "<center><font class=\"option\"><b>"._REQUESTLINKMOD."</b></font><br><font class=\"content\">";
  1658.         while(list($cid, $sid, $title, $url, $description) = sql_fetch_row($result, $dbi)) {
  1659.             $title = stripslashes($title);
  1660.         $description = stripslashes($description);
  1661.             echo "<form action=\"modules.php?name=Web_Links\" method=\"post\">"
  1662.             .""._LINKID.": <b>$lid</b></center><br><br><br>"
  1663.             .""._LINKTITLE.":<br><input type=\"text\" name=\"title\" value=\"$title\" size=\"50\" maxlength=\"100\"><br><br>"
  1664.             .""._URL.":<br><input type=\"text\" name=\"url\" value=\"$url\" size=\"50\" maxlength=\"100\"><br><br>"
  1665.             .""._DESCRIPTION.": <br><textarea name=\"description\" cols=\"60\" rows=\"10\">$description</textarea><br><br>";
  1666.         $result2=sql_query("select cid, title from ".$prefix."_links_categories order by title", $dbi);
  1667.         echo "<input type=\"hidden\" name=\"lid\" value=\"$lid\">"
  1668.         ."<input type=\"hidden\" name=\"modifysubmitter\" value=\"$ratinguser\">"
  1669.         .""._CATEGORY.": <select name=\"cat\">";
  1670.  
  1671.     $result2=sql_query("select cid, title, parentid from ".$prefix."_links_categories order by title", $dbi);
  1672.     while(list($cid2, $ctitle2, $parentid2) = sql_fetch_row($result2, $dbi)) {
  1673.         if ($cid2==$cid) {
  1674.             $sel = "selected";
  1675.         } else {
  1676.             $sel = "";
  1677.         }
  1678.         if ($parentid2!=0) $ctitle2=getparent($parentid2,$ctitle2);
  1679.         echo "<option value=\"$cid2\" $sel>$ctitle2</option>";
  1680.     }
  1681.             echo "</select><br><br>"
  1682.         ."<input type=\"hidden\" name=\"l_op\" value=\"modifylinkrequestS\">"
  1683.         ."<input type=\"submit\" value=\""._SENDREQUEST."\"></form>";
  1684.         }
  1685.     }
  1686.     CloseTable();
  1687.     include("footer.php");
  1688. }
  1689.  
  1690. function modifylinkrequestS($lid, $cat, $title, $url, $description, $modifysubmitter) {
  1691.     include("modules/Web_Links/l_config.php");
  1692.     global $prefix, $dbi, $user;
  1693.     if(is_user($user)) {
  1694.     $user2 = base64_decode($user);
  1695.     $cookie = explode(":", $user2);
  1696.     cookiedecode($user);
  1697.     $ratinguser = $cookie[1];
  1698.     } else {
  1699.     $ratinguser = "$anonymous";
  1700.     }
  1701.     $blocknow = 0;
  1702.     if ($blockunregmodify == 1 && $ratinguser=="$anonymous") {
  1703.     include("header.php");
  1704.     menu(1);
  1705.     echo "<br>";
  1706.     OpenTable();
  1707.     echo "<center><font class=\"content\">"._ONLYREGUSERSMODIFY."</font></center>";
  1708.     $blocknow = 1;
  1709.     CloseTable();
  1710.     include("footer.php");
  1711.     }
  1712.     if ($blocknow != 1) {
  1713.         $cat = explode("-", $cat);
  1714.         if ($cat[1]=="") {
  1715.             $cat[1] = 0;
  1716.         }
  1717.         $title = stripslashes(FixQuotes($title));
  1718.         $url = stripslashes(FixQuotes($url));
  1719.         $description = stripslashes(FixQuotes($description));
  1720.         sql_query("insert into ".$prefix."_links_modrequest values (NULL, $lid, $cat[0], $cat[1], '$title', '$url', '$description', '$ratinguser', 0)", $dbi);
  1721.         include("header.php");
  1722.     menu(1);
  1723.     echo "<br>";
  1724.     OpenTable();
  1725.         echo "<center><font class=\"content\">"._THANKSFORINFO." "._LOOKTOREQUEST."</font></center>";
  1726.         CloseTable();
  1727.     include("footer.php");
  1728.     }
  1729. }
  1730.  
  1731. function rateinfo($lid) {
  1732.     global $prefix, $dbi;
  1733.     sql_query("update ".$prefix."_links_links set hits=hits+1 where lid=$lid", $dbi);
  1734.     $result = sql_query("select url from ".$prefix."_links_links where lid=$lid", $dbi);
  1735.     list($url) = sql_fetch_row($result, $dbi);
  1736.     Header("Location: $url");
  1737. }
  1738.  
  1739. function addrating($ratinglid, $ratinguser, $rating, $ratinghost_name, $ratingcomments) {
  1740.     global $prefix, $dbi, $cookie, $user;
  1741.     $passtest = "yes";
  1742.     include("header.php");
  1743.     include("modules/Web_Links/l_config.php");
  1744.     completevoteheader();
  1745.     if(is_user($user)) {
  1746.     $user2 = base64_decode($user);
  1747.        $cookie = explode(":", $user2);
  1748.     cookiedecode($user);
  1749.     $ratinguser = $cookie[1];
  1750.     } else if ($ratinguser=="outside") {
  1751.     $ratinguser = "outside";
  1752.     } else {
  1753.     $ratinguser = "$anonymous";
  1754.     }
  1755.     $results3 = sql_query("SELECT title FROM ".$prefix."_links_links WHERE lid=$ratinglid", $dbi);
  1756.     while(list($title)=sql_fetch_row($results3, $dbi))
  1757.     $ttitle = $title;
  1758.     /* Make sure only 1 anonymous from an IP in a single day. */
  1759.     $ip = getenv("REMOTE_HOST");
  1760.     if (empty($ip)) {
  1761.        $ip = getenv("REMOTE_ADDR");
  1762.     }
  1763.     /* Check if Rating is Null */
  1764.     if ($rating=="--") {
  1765.     $error = "nullerror";
  1766.         completevote($error);
  1767.     $passtest = "no";
  1768.     }
  1769.     /* Check if Link POSTER is voting (UNLESS Anonymous users allowed to post) */
  1770.     if ($ratinguser != $anonymous && $ratinguser != "outside") {
  1771.         $result=sql_query("select submitter from ".$prefix."_links_links where lid=$ratinglid", $dbi);
  1772.         while(list($ratinguserDB)=sql_fetch_row($result, $dbi)) {
  1773.             if ($ratinguserDB==$ratinguser) {
  1774.             $error = "postervote";
  1775.                 completevote($error);
  1776.         $passtest = "no";
  1777.             }
  1778.        }
  1779.     }
  1780.     /* Check if REG user is trying to vote twice. */
  1781.     if ($ratinguser!=$anonymous && $ratinguser != "outside") {
  1782.         $result=sql_query("select ratinguser from ".$prefix."_links_votedata where ratinglid=$ratinglid", $dbi);
  1783.         while(list($ratinguserDB)=sql_fetch_row($result, $dbi)) {
  1784.             if ($ratinguserDB==$ratinguser) {
  1785.                 $error = "regflood";
  1786.                 completevote($error);
  1787.         $passtest = "no";
  1788.         }
  1789.         }
  1790.     }
  1791.     /* Check if ANONYMOUS user is trying to vote more than once per day. */
  1792.     if ($ratinguser==$anonymous){
  1793.         $yesterdaytimestamp = (time()-(86400 * $anonwaitdays));
  1794.         $ytsDB = Date("Y-m-d H:i:s", $yesterdaytimestamp);
  1795.         $result=sql_query("select * FROM ".$prefix."_links_votedata WHERE ratinglid=$ratinglid AND ratinguser='$anonymous' AND ratinghostname = '$ip' AND TO_DAYS(NOW()) - TO_DAYS(ratingtimestamp) < $anonwaitdays", $dbi);
  1796.         $anonvotecount = sql_num_rows($result, $dbi);
  1797.         if ($anonvotecount >= 1) {
  1798.             $error = "anonflood";
  1799.             completevote($error);
  1800.             $passtest = "no";
  1801.         }
  1802.     }
  1803.     /* Check if OUTSIDE user is trying to vote more than once per day. */
  1804.     if ($ratinguser=="outside"){
  1805.         $yesterdaytimestamp = (time()-(86400 * $outsidewaitdays));
  1806.         $ytsDB = Date("Y-m-d H:i:s", $yesterdaytimestamp);
  1807.         $result=sql_query("select * FROM ".$prefix."_links_votedata WHERE ratinglid=$ratinglid AND ratinguser='outside' AND ratinghostname = '$ip' AND TO_DAYS(NOW()) - TO_DAYS(ratingtimestamp) < $outsidewaitdays", $dbi);
  1808.         $outsidevotecount = sql_num_rows($result, $dbi);
  1809.         if ($outsidevotecount >= 1) {
  1810.             $error = "outsideflood";
  1811.             completevote($error);
  1812.             $passtest = "no";
  1813.         }
  1814.     }
  1815.     /* Passed Tests */
  1816.     if ($passtest == "yes") {
  1817.         $comment = stripslashes(FixQuotes($comment));
  1818.         /* All is well.  Add to Line Item Rate to DB. */
  1819.      sql_query("INSERT into ".$prefix."_links_votedata values (NULL,'$ratinglid', '$ratinguser', '$rating', '$ip', '$ratingcomments', now())", $dbi);
  1820.     /* All is well.  Calculate Score & Add to Summary (for quick retrieval & sorting) to DB. */
  1821.     /* NOTE: If weight is modified, ALL links need to be refreshed with new weight. */
  1822.     /*     Running a SQL statement with your modded calc for ALL links will accomplish this. */
  1823.         $voteresult = sql_query("select rating, ratinguser, ratingcomments FROM ".$prefix."_links_votedata WHERE ratinglid = $ratinglid", $dbi);
  1824.     $totalvotesDB = sql_num_rows($voteresult, $dbi);
  1825.     include ("modules/Web_Links/voteinclude.php");
  1826.         sql_query("UPDATE ".$prefix."_links_links SET linkratingsummary=$finalrating,totalvotes=$totalvotesDB,totalcomments=$truecomments WHERE lid = $ratinglid", $dbi);
  1827.         $error = "none";
  1828.         completevote($error);
  1829.     }
  1830.     completevotefooter($ratinglid, $ttitle, $ratinguser);
  1831.     include("footer.php");
  1832. }
  1833.  
  1834. function completevoteheader(){
  1835.     menu(1);
  1836.     echo "<br>";
  1837.     OpenTable();
  1838. }
  1839.  
  1840. function completevotefooter($lid, $ttitle, $ratinguser) {
  1841.     global $prefix, $dbi;
  1842.     include("modules/Web_Links/l_config.php");
  1843.     $result=sql_query("select url FROM ".$prefix."_links_links WHERE lid=$lid", $dbi);
  1844.     list($url)=sql_fetch_row($result, $dbi);
  1845.     echo "<font class=\"content\">"._THANKSTOTAKETIME." $sitename. "._LETSDECIDE."</font><br><br><br>";
  1846.     if ($ratinguser=="outside") {
  1847.     echo "<center><font class=\"content\">".WEAPPREACIATE." $sitename!<br><a href=\"$url\">"._RETURNTO." $ttitle</a></font><center><br><br>";
  1848.         $result=sql_query("select title FROM ".$prefix."_links_links where lid=$lid", $dbi);
  1849.         list($title)=sql_fetch_row($result, $dbi);
  1850.         $ttitle = ereg_replace (" ", "_", $title);
  1851.     }
  1852.     echo "<center>";
  1853.     linkinfomenu($lid,$ttitle);
  1854.     echo "</center>";
  1855.     CloseTable();
  1856. }
  1857.  
  1858. function completevote($error) {
  1859.     include("modules/Web_Links/l_config.php");
  1860.     if ($error == "none") echo "<center><font class=\"content\"><b>"._COMPLETEVOTE1."</b></font></center>";
  1861.     if ($error == "anonflood") echo "<center><font class=\"option\"><b>"._COMPLETEVOTE2."</b></font></center><br>";
  1862.     if ($error == "regflood") echo "<center><font class=\"option\"><b>"._COMPLETEVOTE3."</b></font></center><br>";
  1863.     if ($error == "postervote") echo "<center><font class=\"option\"><b>"._COMPLETEVOTE4."</b></font></center><br>";
  1864.     if ($error == "nullerror") echo "<center><font class=\"option\"><b>"._COMPLETEVOTE5."</b></font></center><br>";
  1865.     if ($error == "outsideflood") echo "<center><font class=\"option\"><b>"._COMPLETEVOTE6."</b></font></center><br>";
  1866. }
  1867.  
  1868. function ratelink($lid, $user, $ttitle) {
  1869.     include("header.php");
  1870.     menu(1);
  1871.     echo "<br>";
  1872.     OpenTable();
  1873.     $transfertitle = ereg_replace ("_", " ", $ttitle);
  1874.     $displaytitle = $transfertitle;
  1875.     global $prefix, $dbi, $cookie, $datetime;
  1876.     $ip = getenv("REMOTE_HOST");
  1877.     if (empty($ip)) {
  1878.        $ip = getenv("REMOTE_ADDR");
  1879.     }
  1880.     echo "<b>$displaytitle</b>"
  1881.     ."<ul><font class=\"content\">"
  1882.     ."<li>"._RATENOTE1.""
  1883.     ."<li>"._RATENOTE2.""
  1884.     ."<li>"._RATENOTE3.""
  1885.     ."<li>"._RATENOTE4.""
  1886.     ."<li>"._RATENOTE5."";
  1887.     if(is_user($user)) {
  1888.         $user2 = base64_decode($user);
  1889.        $cookie = explode(":", $user2);
  1890.     echo "<li>"._YOUAREREGGED.""
  1891.         ."<li>"._FEELFREE2ADD."";
  1892.     cookiedecode($user);
  1893.     $auth_name = $cookie[1];
  1894.     } else {
  1895.     echo "<li>"._YOUARENOTREGGED.""
  1896.         ."<li>"._IFYOUWEREREG."";
  1897.     $auth_name = "$anonymous";
  1898.     }
  1899.     echo "</ul>"
  1900.         ."<form method=\"post\" action=\"modules.php?name=Web_Links\">"
  1901.         ."<table border=\"0\" cellpadding=\"1\" cellspacing=\"0\" width=\"100%\">"
  1902.         ."<tr><td width=\"25\" nowrap></td>"
  1903.         ."<tr><td width=\"25\" nowrap></td><td width=\"550\">"
  1904.         ."<input type=\"hidden\" name=\"ratinglid\" value=\"$lid\">"
  1905.         ."<input type=\"hidden\" name=\"ratinguser\" value=\"$auth_name\">"
  1906.         ."<input type=\"hidden\" name=\"ratinghost_name\" value=\"$ip\">"
  1907.         ."<font class=content>"._RATETHISSITE.""
  1908.         ."<select name=\"rating\">"
  1909.         ."<option>--</option>"
  1910.         ."<option>10</option>"
  1911.         ."<option>9</option>"
  1912.     ."<option>8</option>"
  1913.         ."<option>7</option>"
  1914.         ."<option>6</option>"
  1915.         ."<option>5</option>"
  1916.         ."<option>4</option>"
  1917.         ."<option>3</option>"
  1918.         ."<option>2</option>"
  1919.         ."<option>1</option>"
  1920.         ."</select></font>"
  1921.     ."<font class=\"content\"><input type=\"submit\" value=\""._RATETHISSITE."\"></font>"
  1922.         ."<br><br>";
  1923.     if(is_user($user)) {
  1924.     echo "<b>"._SCOMMENTS.":</b><br><textarea wrap=\"virtual\" cols=\"50\" rows=\"10\" name=\"ratingcomments\"></textarea>"
  1925.          ."<br><br><br>"
  1926.              ."</font></td>";
  1927.     } else {
  1928.     echo"<input type=\"hidden\" name=\"ratingcomments\" value=\"\">";
  1929.     }
  1930.     echo "</tr></table></form>";
  1931.     echo "<center>";
  1932.     linkfooterchild($lid);
  1933.     echo "</center>";
  1934.     CloseTable();
  1935.     include("footer.php");
  1936. }
  1937.  
  1938. if (isset($ratinglid) && isset ($ratinguser) && isset ($rating)) {
  1939.     $ret = addrating($ratinglid, $ratinguser, $rating, $ratinghost_name, $ratingcomments);
  1940. }
  1941.  
  1942. switch($l_op) {
  1943.  
  1944.     case "menu":
  1945.     menu($mainlink);
  1946.     break;
  1947.  
  1948.     case "AddLink":
  1949.     AddLink();
  1950.     break;
  1951.  
  1952.     case "NewLinks":
  1953.     NewLinks($newlinkshowdays);
  1954.     break;
  1955.  
  1956.     case "NewLinksDate":
  1957.     NewLinksDate($selectdate);
  1958.     break;
  1959.  
  1960.     case "TopRated":
  1961.     TopRated($ratenum, $ratetype);
  1962.     break;
  1963.  
  1964.     case "MostPopular":
  1965.     MostPopular($ratenum, $ratetype);
  1966.     break;
  1967.  
  1968.     case "RandomLink":
  1969.     RandomLink();
  1970.     break;
  1971.  
  1972.     case "viewlink":
  1973.     viewlink($cid, $min, $orderby, $show);
  1974.     break;
  1975.  
  1976.     case "brokenlink":
  1977.     brokenlink($lid);
  1978.     break;
  1979.  
  1980.     case "modifylinkrequest":
  1981.     modifylinkrequest($lid);
  1982.     break;
  1983.  
  1984.     case "modifylinkrequestS":
  1985.     modifylinkrequestS($lid, $cat, $title, $url, $description, $modifysubmitter);
  1986.     break;
  1987.  
  1988.     case "brokenlinkS":
  1989.     brokenlinkS($lid,$cid, $title, $url, $description, $modifysubmitter);
  1990.     break;
  1991.  
  1992.     case "visit":
  1993.     visit($lid);
  1994.     break;
  1995.  
  1996.     case "Add":
  1997.     Add($title, $url, $auth_name, $cat, $description, $email);
  1998.     break;
  1999.  
  2000.     case "search":
  2001.     search($query, $min, $orderby, $show);
  2002.     break;
  2003.  
  2004.     case "rateinfo":
  2005.     rateinfo($lid, $user, $title);
  2006.     break;
  2007.  
  2008.     case "ratelink":
  2009.     ratelink($lid, $user, $ttitle);
  2010.     break;
  2011.  
  2012.     case "addrating":
  2013.     addrating($ratinglid, $ratinguser, $rating, $ratinghost_name, $ratingcomments, $user);
  2014.     break;
  2015.  
  2016.     case "viewlinkcomments":
  2017.     viewlinkcomments($lid, $ttitle);
  2018.     break;
  2019.  
  2020.     case "outsidelinksetup":
  2021.     outsidelinksetup($lid);
  2022.     break;
  2023.  
  2024.     case "viewlinkeditorial":
  2025.     viewlinkeditorial($lid, $ttitle);
  2026.     break;
  2027.  
  2028.     case "viewlinkdetails":
  2029.     viewlinkdetails($lid, $ttitle);
  2030.     break;
  2031.  
  2032.     default:
  2033.     index();
  2034.     break;
  2035.  
  2036. }
  2037.  
  2038. ?>
  2039.