home *** CD-ROM | disk | FTP | other *** search
/ PC World 2001 March / PCWorld_2001-03_cd.bin / KOMUNIK / progweb / progweb.exe / phpnuke / html / links.php < prev    next >
PHP Script  |  2000-12-05  |  109KB  |  2,285 lines

  1. <?php
  2.  
  3. ######################################################################
  4. # PHP-NUKE: Web Portal System
  5. # ===========================
  6. #
  7. # Copyright (c) 2000 by Francisco Burzi (fburzi@ncc.org.ve)
  8. # http://phpnuke.org
  9. #
  10. # This modules is to have a Yahoo! like search engine with web
  11. # resources under categories and subcategories
  12. #
  13. # This program is free software. You can redistribute it and/or modify
  14. # it under the terms of the GNU General Public License as published by
  15. # the Free Software Foundation; either version 2 of the License.
  16. ######################################################################
  17.  
  18. if (!isset($mainfile)) { include("mainfile.php"); }
  19.  
  20. function OpenTable() {
  21.     echo "<TABLE align=center WIDTH=100% CELLSPACING=1 CELLPADDING=0 BORDER=0 BGCOLOR=000000><TR><TD>";
  22.     echo "<TABLE align=center WIDTH=100% CELLSPACING=1 CELLPADDING=8 BORDER=0 BGCOLOR=FFFFFF><TR><TD>";
  23. }
  24.  
  25. function CloseTable() {
  26.     echo "</TD></TR></TABLE></TD></TR></TABLE>";
  27. }
  28.  
  29. function logo() {
  30.     echo "<center><a href=links.php><img src=images/links/web.gif border=0></a></center><br>";
  31. }
  32.  
  33. function menu($mainlink) {
  34. echo "
  35. <BR><CENTER>
  36. <TABLE align=center CELLSPACING=0 CELLPADDING=2 BORDER=0 BGCOLOR=000000>
  37. <TR><TD COLSPAN=2>
  38.  
  39. <TABLE align=center CELLSPACING=0 CELLPADDING=3 BORDER=0 BGCOLOR=FFFFFF>
  40. <TR><TD><FONT SIZE=2>";
  41.  if ($mainlink>0) {
  42.     echo "<a href=links.php>".translate("Links Main")."</a>  |  </TD><TD><FONT SIZE=2>";
  43.  }
  44.  echo "
  45.  <a href=links.php?op=AddLink>".translate("Add Link")."</a></TD><TD><FONT SIZE=2>
  46.   |  <a href=links.php?op=NewLinks>".translate("New")."</a></TD><TD><FONT SIZE=2>
  47.   |  <a href=links.php?op=MostPopular>".translate("Popular")."</a></TD><TD><FONT SIZE=2>
  48.   |  <a href=links.php?op=TopRated>".translate("Top Rated")."</a></TD><TD><FONT SIZE=2>
  49.   |  <a href=links.php?op=RandomLink>".translate("Random")."</a>
  50. </FONT></TD></TR></TABLE></tr></td></TABLE>
  51. ";
  52. }
  53.  
  54. function SearchForm() {
  55. echo "
  56.     <center>
  57.     <form action=links.php?op=search&query=$query method=POST>
  58.     <div>
  59.     <table border=0 cellspacing=0 cellpadding=0>
  60.     <tr><td><FONT SIZE=2><input type=text size=30 name=query> <input type=submit value=".translate("Search")."></td></tr>
  61.     </table>
  62.     </div>
  63.     </form>
  64.     </center>
  65. ";
  66. }
  67.  
  68. function mainheader() {
  69.     $mainlink = 1;
  70.     echo "<BR><CENTER>
  71.     <TABLE align=center CELLSPACING=0 CELLPADDING=2 BORDER=0 BGCOLOR=000000>
  72.     <TR><TD COLSPAN=2>
  73.     
  74.     <TABLE align=center CELLSPACING=0 CELLPADDING=3 BORDER=0 BGCOLOR=FFFFFF>
  75.     <TR><TD><FONT SIZE=2>";
  76.      if ($mainlink>0) {
  77.         echo "<a href=links.php>".translate("Links Main")."</a> |</TD><TD><FONT SIZE=2>";
  78.      }
  79.      echo "
  80.      <a href=links.php?op=AddLink>".translate("Add Link")."</a></TD><TD><FONT SIZE=2>
  81.      | <a href=links.php?op=NewLinks>".translate("New")."</a></TD><TD><FONT SIZE=2>
  82.      | <a href=links.php?op=MostPopular>".translate("Popular")."</a></TD><TD><FONT SIZE=2>
  83.      | <a href=links.php?op=TopRated>".translate("Top Rated")."</a></TD><TD><FONT SIZE=2>
  84.      | <a href=links.php?op=RandomLink>".translate("Random")."</a>
  85.         </FONT></TD></TR></table></td></tr></TABLE>";
  86.     echo "
  87.     <table width=100%>
  88.     <tr><td>
  89.     <tr>
  90.       <td width=50%>";
  91.         logo();
  92.         echo "<br>";
  93.         SearchForm();
  94.         echo "</td width=50%></tr></table>";
  95. //    </TD></TR></TABLE>";
  96.     
  97. }
  98.  
  99. function linkinfomenu($lid,$ttitle) {
  100.    $ttitle = ereg_replace(" ", "_", $ttitle);
  101.    echo"
  102.    <br><font size=2>
  103.    <a href=links.php?op=viewlinkcomments&lid=$lid&ttitle=$ttitle>".translate("Link Comments")."</a>
  104.    | <a href=links.php?op=viewlinkdetails&lid=$lid&ttitle=$ttitle>".translate("Additional Details")."</a> 
  105.    | <a href=links.php?op=viewlinkeditorial&lid=$lid&ttitle=$ttitle>".translate("Editor Review")."</a>
  106.    | <a href=links.php?op=modifylinkrequest&lid=$lid>".translate("Modify")."</a>
  107.    | <a href=links.php?op=brokenlink&lid=$lid>".translate("Report Broken Link")."</a></font><br>";   
  108.    
  109. }
  110.  
  111. function index() {
  112.     include("header.php");
  113.     OpenTable();
  114.     $mainlink = 0;
  115.     menu($mainlink); 
  116.     logo();
  117.     SearchForm();
  118.  
  119. echo "
  120. <table border=0 cellspacing=10 cellpadding=0><tr>";
  121.  
  122. $result=mysql_query("select cid, title, cdescription from links_categories order by title");
  123. $count = 0;
  124. while(list($cid, $title, $cdescription) = mysql_fetch_row($result)) {
  125.  
  126.     $cresult = mysql_query("select * from links_links where cid=$cid");
  127.     $cnumrows = mysql_num_rows($cresult);
  128.     echo "<td><font size=3><li><a href=links.php?op=viewlink&cid=$cid><b>$title</b></a> ($cnumrows)</font>";
  129.     categorynewlinkgraphic($cid);
  130.     if ($description) {
  131.     echo "<font size=2>$cdescription<br></font>";
  132.     } else {
  133.     echo "<br>";
  134.     }
  135.     $result2 = mysql_query("select sid, title from links_subcategories where cid=$cid order by title limit 0,3");
  136.     $space = 0;
  137.     while(list($sid, $stitle) = mysql_fetch_row($result2)) {
  138.         if ($space>0) {
  139.         echo ", ";
  140.     }
  141.     echo "<font size=2><a href=links.php?op=viewslink&sid=$sid>$stitle</a></font>";
  142.     $space++;
  143.     }
  144.     if ($count<1) {
  145.     echo "</td><td>    </td>";
  146.     }
  147.     $count++;
  148.     if ($count==2) {
  149.     echo "</td></tr><tr>";
  150.     $count = 0;
  151.     }
  152. }
  153.     echo "</td></tr></table>";
  154.     $result=mysql_query("select * from links_links");
  155.     $numrows = mysql_num_rows($result);
  156.     echo "<br><br><center><font size=2>".translate("There are")." <b>$numrows</b> ".translate("Links in our Database")." </center>";
  157.     echo "</font></basefont>";
  158.     CloseTable();
  159.     include("footer.php");
  160. }
  161.  
  162.  
  163. function AddLink() {
  164.     include("header.php");
  165.     OpenTable();
  166.     $mainlink = 1;
  167.     global $user;
  168.     mainheader();
  169.     echo "<TABLE WIDTH=100% CELLSPACING=0 CELLPADDING=1 BORDER=0><TR><TD COLSPAN=2>
  170.     <TABLE WIDTH=100% CELLSPACING=0 CELLPADDING=8 BORDER=0><TR><TD>
  171.     <br><br>";
  172.     
  173.     if (isset($user) || $links_anonaddlinklock != 1) {
  174.         echo "
  175.     <LI>".translate("Submit a unique link only once.")."
  176.     <LI>".translate("All links are posted pending verification.")."
  177.     <LI>".translate("Username and IP are recorded, so please don't abuse the system.")."
  178.     
  179.         <form method=post action=links.php?op=Add>
  180.         <font size=3>
  181.         ".translate("Page Title: ")." <input type=text name=title size=50 maxlength=100><br>
  182.         ".translate("Page URL: ")."<input type=text name=url size=50 maxlength=100 value=\"http://\"><br>";
  183.         $result=mysql_query("select cid, title from links_categories order by title");
  184.         echo "".translate("Category: ")."<select name=cat>";
  185.         while(list($cid, $title) = mysql_fetch_row($result)) {
  186.         echo "<option value=$cid>$title</option>";
  187.         $result2=mysql_query("select sid, title from links_subcategories where cid=$cid order by title");
  188.         while(list($sid, $stitle) = mysql_fetch_row($result2)) {
  189.                 echo "<option value=$cid-$sid>$title / $stitle</option>";
  190.         }
  191.         }
  192.         echo "</select><br><br><br>
  193.         ".translate("Description: (255 characters max)")."<br><textarea name=description cols=60 rows=5></textarea><br><br><br>
  194.         ".translate("Your Name: ")."<input type=text name=name size=30 maxlength=60><br>
  195.         ".translate("Your Email: ")."<input type=text name=email size=30 maxlength=60><br><br>
  196.         <input type=hidden name=op value=Add>
  197.         <center><input type=submit value=".translate("Add URL")."><br><br>
  198.         </form>";
  199.         ;
  200.     }else {
  201.         echo "<center>".translate("You are not a registered user or you have not logged in.")."<br>
  202.               ".translate("If you were registered you could add links on this website.")."<br><br>
  203.                       <a href=user.php>".translate("Register for an Account")."</a>";
  204.     }
  205.     echo "</TD></TR></TABLE></TD></TR></TABLE>";
  206.     CloseTable();
  207.     include("footer.php");
  208. }
  209.  
  210. function Add($title, $url, $name, $cat, $description, $name, $email) {
  211.     global $user;
  212.     $result = mysql_query("select url from links_links where url='$url'");
  213.     $numrows = mysql_num_rows($result);
  214.     if ($numrows>0) {
  215.     include("header.php");
  216.     echo "<TABLE WIDTH=100% CELLSPACING=0 CELLPADDING=1 BORDER=0><TR><TD COLSPAN=2>
  217.     <TABLE WIDTH=100% CELLSPACING=0 CELLPADDING=8 BORDER=ff0><TR><TD><center><br>";
  218.     SearchForm();
  219.     echo "<font size=3 color=Red>";
  220.     echo "<b>".translate("ERROR: This URL is already listed in the Database!")."</b><br><br>";
  221.     echo "</TD></TR></TABLE></TD></TR></TABLE>";
  222.     include("footer.php");
  223.     } else {
  224.     if(isset($user)) {
  225.         $user2 = base64_decode($user);
  226.         $cookie = explode(":", $user2);
  227.         cookiedecode($user);
  228.         $submitter = $cookie[1];    
  229.     }
  230. // Check if Title exist
  231.     if ($title=="") {
  232.     include("header.php");
  233.     echo "<TABLE WIDTH=100% CELLSPACING=0 CELLPADDING=1 BORDER=0><TR><TD COLSPAN=2>
  234.     <TABLE WIDTH=100% CELLSPACING=0 CELLPADDING=8 BORDER=0><TR><TD><center><br>";
  235.     SearchForm();
  236.     echo "<font size=3 color=Red>";
  237.     echo "<b>".translate("ERROR: You need to type a TITLE for your URL!")."</b><br><br>";
  238.     echo "</TD></TR></TABLE></TD></TR></TABLE>";
  239.     include("footer.php");
  240.     }
  241. // Check if URL exist
  242.     if ($url=="") {
  243.     include("header.php");
  244.     echo "<TABLE WIDTH=100% CELLSPACING=0 CELLPADDING=1 BORDER=0><TR><TD COLSPAN=2>
  245.     <TABLE WIDTH=100% CELLSPACING=0 CELLPADDING=8 BORDER=0><TR><TD><center><br>";
  246.     SearchForm();
  247.     echo "<font size=3 color=Red>";
  248.     echo "<b>".translate("ERROR: You need to type a URL for your URL!")."</b><br><br>";
  249.     echo "</TD></TR></TABLE></TD></TR></TABLE>";
  250.     include("footer.php");
  251.     }
  252. // Check if Description exist
  253.     if ($description=="") {
  254.     include("header.php");
  255.     echo "<TABLE WIDTH=100% CELLSPACING=0 CELLPADDING=1 BORDER=0><TR><TD COLSPAN=2>
  256.     <TABLE WIDTH=100% CELLSPACING=0 CELLPADDING=8 BORDER=0><TR><TD><center><br>";
  257.     SearchForm();
  258.     echo "<font size=3 color=Red>";
  259.     echo "<b>".translate("ERROR: You need to type a DESCRIPTION for your URL!")."</b><br><br>";
  260.     echo "</TD></TR></TABLE></TD></TR></TABLE>";
  261.     include("footer.php");
  262.     }
  263.     $cat = explode("-", $cat);
  264.     if ($cat[1]=="") {
  265.     $cat[1] = 0;
  266.     }
  267.     $title = stripslashes(FixQuotes($title));
  268.     $url = stripslashes(FixQuotes($url));
  269.     $description = stripslashes(FixQuotes($description));
  270.     $name = stripslashes(FixQuotes($name));
  271.     $email = stripslashes(FixQuotes($email));
  272.     mysql_query("insert into links_newlink values (NULL, '$cat[0]', '$cat[1]', '$title', '$url', '$description', '$name', '$email', '$submitter')");
  273.     include("header.php");
  274.     $mainlink = 1;
  275.     menu($mainlink);
  276.     echo "<TABLE WIDTH=100% CELLSPACING=0 CELLPADDING=1 BORDER=0 ><TR><TD COLSPAN=2>
  277.     <TABLE WIDTH=100% CELLSPACING=0 CELLPADDING=8 BORDER=0><TR><TD><center><br>";
  278.     SearchForm();
  279.     echo "<font size=3>";
  280.     echo "".translate("We received your Link submission. Thanks!")."<br>";
  281.     echo "".translate("You'll receive and E-mail when it's approved.")."<br><br>";
  282.     echo "</TD></TR></TABLE></TD></TR></TABLE>";
  283.     include("footer.php");
  284.     }
  285. }
  286.  
  287.  
  288. function NewLinks($newlinkshowdays) {
  289.     global $admin;
  290.     include("header.php");
  291.     OpenTable();
  292.     mainheader();
  293.     echo "
  294.     <TABLE WIDTH=100% CELLSPACING=0 CELLPADDING=8 BORDER=0><TR><TD>";
  295.     
  296.     echo "<TABLE WIDTH=100% CELLSPACING=2 CELLPADDING=2 BORDER=0 BGCOLOR=CCCCCC><TR><TD>";    
  297.     echo "<center><font size=3><b>".translate("New Links")."</b></font></center>";
  298.     echo "</tr></td></table><br>";
  299.  
  300.     $counter = 0;
  301.     $allweeklinks = 0;
  302.     while ($counter <= 7-1){
  303.     $newlinkdayRaw = (time()-(86400 * $counter));
  304.     $newlinkday = date("d-M-Y", $newlinkdayRaw);
  305.     $newlinkView = date("F d, Y", $newlinkdayRaw);
  306.     $newlinkDB = Date("Y-m-d", $newlinkdayRaw);
  307.     $result = mysql_query("select * FROM links_links WHERE date LIKE '%$newlinkDB%'");
  308.     $totallinks = mysql_num_rows($result); 
  309.     $counter++;
  310.     $allweeklinks = $allweeklinks + $totallinks;
  311.     }
  312.  
  313.     $counter = 0;
  314.     while ($counter <=30-1){
  315.         $newlinkdayRaw = (time()-(86400 * $counter));
  316.         # $newlinkday = date("d-M-Y", $newlinkdayRaw);
  317.         # $newlinkView = date("F d, Y", $newlinkdayRaw);
  318.         $newlinkDB = Date("Y-m-d", $newlinkdayRaw);
  319.         $result = mysql_query("select * FROM links_links WHERE date LIKE '%$newlinkDB%'");
  320.         $totallinks = mysql_num_rows($result);
  321.         $allmonthlinks = $allmonthlinks + $totallinks;
  322.         $counter++;
  323.     }    
  324.     echo "<font color = AAAAAA><center>
  325.           ".translate("Total new links: Last week")." - $allweeklinks \ ".translate("Last 30 days")." - $allmonthlinks
  326.                   </font><br>
  327.       ".translate("Show:")." (<a href=links.php?op=NewLinks&newlinkshowdays=7>".translate("week")."</a>, <a href=links.php?op=NewLinks&newlinkshowdays=14>2 ".translate("weeks")."</a>, <a href=links.php?op=NewLinks&newlinkshowdays=30>30 ".translate("days")."</a>)
  328.                   
  329.                   </center><br>";
  330.  
  331.     //List Last VARIABLE Days of Links   
  332.     if (!isset($newlinkshowdays)) {$newlinkshowdays = 7;}
  333.     echo "<center><br><b>".translate("Total new links for last")." $newlinkshowdays ".translate("days").":</b><br><br>";
  334.     $counter = 0;
  335.     $allweeklinks = 0;
  336.     while ($counter <= $newlinkshowdays-1){
  337.     $newlinkdayRaw = (time()-(86400 * $counter));
  338.     $newlinkday = date("d-M-Y", $newlinkdayRaw);
  339.     $newlinkView = date("F d, Y", $newlinkdayRaw);
  340.     $newlinkDB = Date("Y-m-d", $newlinkdayRaw);
  341.     $result = mysql_query("select * FROM links_links WHERE date LIKE '%$newlinkDB%'");
  342.     $totallinks = mysql_num_rows($result); 
  343.     $counter++;
  344.     $allweeklinks = $allweeklinks + $totallinks;
  345.     echo "<LI><a href=links.php?op=NewLinksDate&selectdate=$newlinkdayRaw>$newlinkView</a> ( $totallinks )";
  346.     }
  347.     $counter = 0;
  348.     $allmonthlinks = 0;
  349.     
  350.     echo "</center></TD></TR></TABLE>";
  351.     CloseTable();
  352.     include("footer.php");
  353. }
  354.  
  355. function NewLinksDate($selectdate) {
  356.     global $admin;
  357.     $dateDB = (date("d-M-Y", $selectdate));
  358.     $dateView = (date("F d, Y", $selectdate));
  359.     include("header.php");
  360.     OpenTable();
  361.     mainheader();
  362.     $newlinkDB = Date("Y-m-d", $selectdate);
  363.     $result = mysql_query("select * FROM links_links WHERE date LIKE '%$newlinkDB%'");
  364.     $totallinks = mysql_num_rows($result); 
  365.     
  366.     echo "<TABLE WIDTH=100% CELLSPACING=0 CELLPADDING=8 BORDER=0><TR><TD><center>";
  367.     echo "<TABLE WIDTH=100% CELLSPACING=2 CELLPADDING=2 BORDER=0 BGCOLOR=CCCCCC><TR><TD>";
  368.     echo "<FONT SIZE=3><b>$dateView - $totallinks ".translate("New Links")."</b>";
  369.     echo "</TD></TR></TABLE></center><font size=2>";    
  370.     
  371.     $result=mysql_query("select lid, cid, sid, title, description, date, hits, linkratingsummary, totalvotes, totalcomments from links_links where date LIKE '%$newlinkDB%' order by title ASC");
  372.     echo "<table width=100% cellspacing=0 cellpadding=10 border=0><tr><td><font size=2>";
  373.     while(list($lid, $cid, $sid, $title, $description, $time, $hits, $linkratingsummary, $totalvotes, $totalcomments)=mysql_fetch_row($result)) {
  374.     $linkratingsummary = number_format($linkratingsummary, $mainvotedecimal);
  375.     $title = stripslashes($title); $description = stripslashes($description);
  376.         echo "<a href=links.php?op=visit&lid=$lid target=new>$title</a>";
  377.     newlinkgraphic($datetime, $time);
  378.     popgraphic($hits);
  379.     echo "<br>";
  380.  
  381.     echo "<font color=777777>".translate("Description: ")."<font color=000000>$description<br>";
  382.     
  383.     setlocale ("LC_TIME", "$locale");
  384.     // INSERT code for *editor review* here
  385.     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);
  386.     $datetime = strftime("".translate("linksdatestring")."", mktime($datetime[4],$datetime[5],$datetime[6],$datetime[2],$datetime[3],$datetime[1]));
  387.     $datetime = ucfirst($datetime);
  388.     echo "<font color=777777>".translate("Added on: ")."<font color=000000><b>$datetime</b><font color=777777> ".translate("Hits: ")."<font color=000000>$hits";
  389.         $transfertitle = str_replace (" ", "_", $title);
  390.         //voting & comments stats
  391.         if ($totalvotes == 1) $votestring = "".translate("vote")."";
  392.             else $votestring = "".translate("votes")."";
  393.         if ($linkratingsummary!="0" || $linkratingsummary!="0.0") echo "<font color=777777> ".translate("Rating").":<font color=000000> $linkratingsummary ($totalvotes $votestring)";
  394.         echo "<br><a href=links.php?op=ratelink&lid=$lid&ttitle=$transfertitle>".translate("Rate this Site")."</a>";
  395.         if ($totalvotes != 0) echo " | <a href=\"links.php?op=viewlinkdetails&lid=$lid&ttitle=$transfertitle\">".translate("Details")."</a>";
  396.         if ($totalcomments != 0) echo " | <a href=\"links.php?op=viewlinkcomments&lid=$lid&ttitle=$transfertitle\">".translate("Comments")." ($totalcomments)</a>";    
  397.     $result2=mysql_query("select title from links_categories where cid=$cid");
  398.     detecteditorial($lid, $transfertitle);
  399.     echo "<br>";
  400.     list($ctitle) = mysql_fetch_row($result2);
  401.     echo "<font color=777777>".translate("Category: ")."<font color=000000>$ctitle";
  402.     $result3=mysql_query("select title from links_subcategories where sid=$sid");
  403.     while(list($stitle) = mysql_fetch_row($result3)) {
  404.         echo " / <font color=000000>$stitle";
  405.     }
  406.     echo "<br><br>";
  407.     }
  408.     echo "</TD></TR></TABLE></TD></TR></TABLE>";
  409.     CloseTable();
  410.     include("footer.php");
  411. }
  412.  
  413. function TopRated($ratenum, $ratetype) {            
  414.     global $admin, $toplinks;
  415.     include("header.php");
  416.     OpenTable();
  417.     mainheader();
  418.     if ($ratenum != "" && $ratetype != "") {
  419.         $toplinks = $ratenum;
  420.         if ($ratetype == "percent") $toplinkspercentrigger = 1;
  421.     }
  422.     if ($ratenum == "") {
  423.     $toplinks = 10;
  424.     }
  425.     if ($toplinkspercentrigger == 1) {
  426.         $toplinkspercent = $toplinks;
  427.         $result=mysql_query("select * from links_links where linkratingsummary != 0");
  428.         $totalratedlinks = mysql_num_rows($result);
  429.         $toplinks = $toplinks / 100;
  430.         $toplinks = $totalratedlinks * $toplinks;
  431.         $toplinks = round($toplinks);
  432.     }
  433.     echo "<TABLE WIDTH=100% CELLSPACING=0 CELLPADDING=8 BORDER=0><TR><TD>";    
  434.     echo "<TABLE WIDTH=100% CELLSPACING=2 CELLPADDING=2 BORDER=0 BGCOLOR=CCCCCC><TR><TD>";
  435.     if ($toplinkspercentrigger == 1) { echo "<FONT SIZE=3><b><center>".translate("Best Rated Links - Top")." $toplinkspercent% (".translate("of")." $totalratedlinks ".translate("total rated links").")</center></b></font>";}
  436.         else {echo "<FONT SIZE=3><b><center>".translate("Best Rated Links - Top")." $toplinks </center></b></font>";}
  437.     echo "</TR></TD></table>";
  438.     
  439.     echo "<tr><td><FONT COLOR=BBBBBB><center>".translate("Note").": $linkvotemin ".translate("total votes requirement")."<br>".translate("Show Top").": (<a href=links.php?op=TopRated&ratenum=10&ratetype=num>10</a>, 
  440.             <a href=links.php?op=TopRated&ratenum=25&ratetype=num>25</a>, 
  441.             <a href=links.php?op=TopRated&ratenum=50&ratetype=num>50</a> | 
  442.             <a href=links.php?op=TopRated&ratenum=1&ratetype=percent>1%</a>, 
  443.             <a href=links.php?op=TopRated&ratenum=5&ratetype=percent>5%</a>, 
  444.             <a href=links.php?op=TopRated&ratenum=10&ratetype=percent>10%</a>)</center></font><br><br></td></tr>";
  445.         
  446.     $result=mysql_query("select lid, cid, sid, title, description, date, hits, linkratingsummary, totalvotes, totalcomments from links_links where linkratingsummary != 0 and totalvotes >= '$linkvotemin' order by linkratingsummary DESC limit 0,$toplinks");
  447.     echo "<tr><td>";
  448.     while(list($lid, $cid, $sid, $title, $description, $time, $hits, $linkratingsummary, $totalvotes, $totalcomments)=mysql_fetch_row($result)) {
  449.     $linkratingsummary = number_format($linkratingsummary, $mainvotedecimal);
  450.     $title = stripslashes($title); $description = stripslashes($description);
  451.         echo "<a href=links.php?op=visit&lid=$lid target=new>$title</a>";
  452.     newlinkgraphic($datetime, $time);
  453.     popgraphic($hits);
  454.     echo "<br>";
  455.     echo "<font color=777777>".translate("Description: ")."<font color=000000>$description<br>";
  456.     setlocale ("LC_TIME", "$locale");
  457.     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);
  458.     $datetime = strftime("".translate("linksdatestring")."", mktime($datetime[4],$datetime[5],$datetime[6],$datetime[2],$datetime[3],$datetime[1]));
  459.     $datetime = ucfirst($datetime);
  460.     echo "<font color=777777>".translate("Added on: ")."<font color=000000>$datetime<font color=777777> ".translate("Hits: ")."<font color=000000>$hits";
  461.     
  462.     $transfertitle = str_replace (" ", "_", $title);
  463.     //voting & comments stats
  464.         if ($totalvotes == 1) $votestring = "".translate("vote")."";
  465.             else $votestring = "".translate("votes")."";
  466.     if ($linkratingsummary!="0" || $linkratingsummary!="0.0") echo "<font color=777777> ".translate("Rating").":<font color=000000><b> $linkratingsummary </b>($totalvotes $votestring)";            
  467.     echo "<br><a href=links.php?op=ratelink&lid=$lid&ttitle=$transfertitle>".translate("Rate this Site")."</a>";
  468.     if ($totalvotes != 0) echo " | <a href=\"links.php?op=viewlinkdetails&lid=$lid&ttitle=$transfertitle\">".translate("Details")."</a>";
  469.             if ($totalcomments != 0) echo " | <a href=\"links.php?op=viewlinkcomments&lid=$lid&ttitle=$transfertitle\">".translate("Comments")." ($totalcomments)</a>";
  470.     detecteditorial($lid, $transfertitle);            
  471.     echo "<br>";    
  472.     $result2=mysql_query("select title from links_categories where cid=$cid");
  473.     list($ctitle) = mysql_fetch_row($result2);
  474.     echo "<font color=777777>".translate("Category: ")."<font color=000000>$ctitle";
  475.     $result3=mysql_query("select title from links_subcategories where sid=$sid");
  476.     while(list($stitle) = mysql_fetch_row($result3)) {
  477.         echo " / <font color=000000>$stitle";
  478.     }
  479.     echo "<br><br>";
  480.  
  481.     
  482.     }
  483.     echo "</tr></td>";    
  484.     echo "</TD></TR></TABLE>";   
  485.     CloseTable();
  486.     include("footer.php");
  487. }
  488.  
  489. function MostPopular($ratenum, $ratetype) {
  490.     global $admin, $toplinks;
  491.     include("header.php");
  492.     OpenTable();
  493.     mainheader();
  494.     if ($ratenum != "" && $ratetype != "") {
  495.         $mostpoplinks = $ratenum;
  496.     if ($ratetype == "percent") $mostpoplinkspercentrigger = 1;
  497.     }
  498.     if ($ratenum == "") {
  499.     $mostpoplinks = $toplinks;
  500.     }
  501.     if ($mostpoplinkspercentrigger == 1) {
  502.         $toplinkspercent = $mostpoplinks;
  503.         $result=mysql_query("select * from links_links");
  504.         $totalmostpoplinks = mysql_num_rows($result);
  505.         $mostpoplinks = $mostpoplinks / 100;
  506.         $mostpoplinks = $totalmostpoplinks * $mostpoplinks;
  507.         $mostpoplinks = round($mostpoplinks);
  508.     }
  509.     echo "<TABLE WIDTH=100% CELLSPACING=0 CELLPADDING=8 BORDER=0><TR><TD>";    
  510.     echo "<TABLE WIDTH=100% CELLSPACING=2 CELLPADDING=2 BORDER=0 BGCOLOR=CCCCCC><TR><TD>";
  511.     if ($mostpoplinkspercentrigger == 1) {echo "<FONT SIZE=3><b><center>".translate("Most Popular - Top")." $toplinkspercent% (".translate("of all")." $totalmostpoplinks ".translate("links").")</center></b>";}
  512.         else {echo "<FONT SIZE=3><b><center>".translate("Most Popular - Top")." $mostpoplinks </center></b>";}
  513.     echo "</TD></TR></TABLE></center><FONT SIZE=2>";
  514.     echo "<tr><td><FONT COLOR=BBBBBB><center>".translate("Show Top").": (<a href=links.php?op=MostPopular&ratenum=10&ratetype=num>10</a>, 
  515.             <a href=links.php?op=MostPopular&ratenum=25&ratetype=num>25</a>, 
  516.             <a href=links.php?op=MostPopular&ratenum=50&ratetype=num>50</a> | 
  517.             <a href=links.php?op=MostPopular&ratenum=1&ratetype=percent>1%</a>, 
  518.             <a href=links.php?op=MostPopular&ratenum=5&ratetype=percent>5%</a>, 
  519.             <a href=links.php?op=MostPopular&ratenum=10&ratetype=percent>10%</a>)</font></center><br><br></td></tr>";
  520.     
  521.     $result=mysql_query("select lid, cid, sid, title, description, date, hits, linkratingsummary, totalvotes, totalcomments from links_links order by hits DESC limit 0,$mostpoplinks");
  522.     echo "<tr><td>";
  523.     while(list($lid, $cid, $sid, $title, $description, $time, $hits, $linkratingsummary, $totalvotes, $totalcomments)=mysql_fetch_row($result)) {
  524.     $linkratingsummary = number_format($linkratingsummary, $mainvotedecimal);
  525.     $title = stripslashes($title); $description = stripslashes($description);
  526.         echo "<a href=links.php?op=visit&lid=$lid target=new>$title</a>";
  527.     newlinkgraphic($datetime, $time);
  528.     popgraphic($hits);
  529.     
  530.     echo "<br>";
  531.     echo "<font color=777777>".translate("Description: ")."<font color=000000>$description<br>";
  532.     setlocale ("LC_TIME", "$locale");
  533.     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);
  534.     $datetime = strftime("".translate("linksdatestring")."", mktime($datetime[4],$datetime[5],$datetime[6],$datetime[2],$datetime[3],$datetime[1]));
  535.     $datetime = ucfirst($datetime);
  536.     echo "<font color=777777>".translate("Added on: ")."<font color=000000>$datetime<font color=777777> ".translate("Hits: ")."<font color=000000><b>$hits</b>";
  537.     
  538.     $transfertitle = str_replace (" ", "_", $title);
  539.     //voting & comments stats
  540.         if ($totalvotes == 1) $votestring = "".translate("vote")."";
  541.             else $votestring = "".translate("votes")."";
  542.     if ($linkratingsummary!="0" || $linkratingsummary!="0.0") echo "<font color=777777> ".translate("Rating").":<font color=000000> $linkratingsummary ($totalvotes $votestring)";            
  543.     echo "<br><a href=links.php?op=ratelink&lid=$lid&ttitle=$transfertitle>".translate("Rate this Site")."</a>";
  544.     if ($totalvotes != 0) echo " | <a href=\"links.php?op=viewlinkdetails&lid=$lid&ttitle=$transfertitle\">".translate("Details")."</a>";
  545.             if ($totalcomments != 0) echo " | <a href=\"links.php?op=viewlinkcomments&lid=$lid&ttitle=$transfertitle\">".translate("Comments")." ($totalcomments)</a>";
  546.     detecteditorial($lid, $transfertitle);
  547.     echo "<br>";    
  548.     $result2=mysql_query("select title from links_categories where cid=$cid");
  549.     list($ctitle) = mysql_fetch_row($result2);
  550.     echo "<font color=777777>".translate("Category: ")."<font color=000000>$ctitle";
  551.     $result3=mysql_query("select title from links_subcategories where sid=$sid");
  552.     while(list($stitle) = mysql_fetch_row($result3)) {
  553.         echo " / <font color=000000>$stitle";
  554.     }
  555.     echo "<br><br>";
  556.     }
  557.     echo "</tr></td>";    
  558.     echo "</TD></TR></TABLE>";
  559.     CloseTable();
  560.     include("footer.php");
  561. }
  562.  
  563. function RandomLink() {
  564.     $result = mysql_query("select * from links_links");
  565.     $numrows = mysql_num_rows($result);
  566.     srand((double)microtime()*1000000);
  567.     $random = rand(1,$numrows);
  568.     $result2 = mysql_query("select url from links_links where lid='$random'");
  569.     list($url) = mysql_fetch_row($result2);
  570.     mysql_query("update links_links set hits=hits+1 where lid=$random");
  571.     Header("Location: $url");
  572. }
  573.  
  574. function viewlink($cid, $min, $orderby, $show) {
  575.     global $admin, $perpage, $show;
  576.     include("header.php");
  577.     OpenTable();
  578.     if (!isset($min)) $min=0;
  579.     if (!isset($max)) $max=$min+$perpage;
  580.     if(isset($orderby)) $orderby = convertorderbyin($orderby);
  581.     else $orderby = "title ASC";
  582.     if ($show!="") $perpage = $show;
  583.         else $show=$perpage;  
  584.     mainheader();
  585.     echo "<TABLE WIDTH=100% CELLSPACING=0 CELLPADDING=3 BORDER=0><TR><TD>";
  586.     echo "<CENTER>";
  587.     echo "<TABLE WIDTH=100% CELLSPACING=2 CELLPADDING=2 BORDER=0 BGCOLOR=CCCCCC><TR><TD>";
  588.     $result=mysql_query("select title from links_categories where cid=$cid");
  589.     list($title) = mysql_fetch_row($result);
  590.     echo "<font size=3><b><center>".translate("Category: ")."$title</center></b></font>";
  591.     $carrytitle = $title;
  592.     echo "</TD></TR></TABLE>";
  593.     $subresult=mysql_query("select sid, title from links_subcategories where cid=$cid");
  594.     $numrows = mysql_num_rows($subresult);
  595.     if ($numrows != 0) {
  596.        $scount = 0;
  597.         echo "<center><font size=2>".translate("Links also available in")." $title ".translate("SubCategories").":</font><br>
  598.         <table align=center>
  599.           <tr>";
  600.             
  601.             while(list($sid, $title) = mysql_fetch_row($subresult)) {
  602.             $result2 = mysql_query("select * from links_links where sid=$sid");
  603.             $numrows = Mysql_num_rows($result2);
  604.                 echo "<td><a href=links.php?op=viewslink&sid=$sid>$title</a> ($numrows)  </td>";
  605.                 $scount++;
  606.                 if ($scount==6) { 
  607.                     echo "</tr><tr>";
  608.                     $scount = 0;
  609.                 }
  610.             }
  611.           echo "
  612.           </tr>
  613.           <tr>
  614.             <td colspan=5></td>
  615.           </tr>
  616.         </table>
  617.         <table width=100% height=1><tr><td><img src=$nuke_url/images/blackpixel.gif height=1 width=100%></tr></td>
  618.         </table>
  619.         </center>";
  620.         
  621.     }
  622.     $orderbyTrans = convertorderbytrans($orderby);
  623.     echo "<center><br><font size=2>".translate("Sort links by").":  
  624.           ".translate("Title")." (<a href=links.php?op=viewlink&cid=$cid&orderby=titleA>A</a>\<a href=links.php?op=viewlink&cid=$cid&orderby=titleD>D</a>)
  625.           ".translate("Date")." (<a href=links.php?op=viewlink&cid=$cid&orderby=dateA>A</a>\<a href=links.php?op=viewlink&cid=$cid&orderby=dateD>D</a>)
  626.           ".translate("Rating")." (<a href=links.php?op=viewlink&cid=$cid&orderby=ratingA>A</a>\<a href=links.php?op=viewlink&cid=$cid&orderby=ratingD>D</a>)
  627.           ".translate("Popularity")." (<a href=links.php?op=viewlink&cid=$cid&orderby=hitsA>A</a>\<a href=links.php?op=viewlink&cid=$cid&orderby=hitsD>D</a>)          
  628.           </font>";
  629.     echo "<b><br><font color=BBBBBB size=2>".translate("Sites currently sorted by").": $orderbyTrans</font></b></center><br><br>";    
  630.  
  631.     $result=mysql_query("select lid, title, description, date, hits, linkratingsummary, totalvotes, totalcomments from links_links where cid=$cid AND sid=0 order by $orderby limit $min,$perpage ");
  632.     $fullcountresult=mysql_query("select lid, title, description, date, hits, linkratingsummary, totalvotes, totalcomments from links_links where cid=$cid AND sid=0");
  633.     $totalselectedlinks = Mysql_num_rows($fullcountresult);
  634.     
  635.     echo "<table width=100% cellspacing=0 cellpadding=10 border=0><tr><td><font size=2>";
  636.     $x=0;
  637.     while(list($lid, $title, $description, $time, $hits, $linkratingsummary, $totalvotes, $totalcomments)=mysql_fetch_row($result)) {
  638.     $linkratingsummary = number_format($linkratingsummary, $mainvotedecimal);
  639.     $title = stripslashes($title); $description = stripslashes($description);
  640.         echo "<a href=links.php?op=visit&lid=$lid target=new>$title</a>";    
  641.     newlinkgraphic($datetime, $time);
  642.     popgraphic($hits);
  643.     // INSERT code for *editor review* here
  644.     echo "<br>";
  645.     echo "<font color=777777>".translate("Description: ")."<font color=000000>$description<br>";
  646.     setlocale ("LC_TIME", "$locale");
  647.     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);
  648.     $datetime = strftime("".translate("linksdatestring")."", mktime($datetime[4],$datetime[5],$datetime[6],$datetime[2],$datetime[3],$datetime[1]));
  649.     $datetime = ucfirst($datetime);
  650.     echo "<font color=777777>".translate("Added on: ")."<font color=000000>$datetime<font color=777777> ".translate("Hits: ")."<font color=000000>$hits";
  651.     
  652.         $transfertitle = str_replace (" ", "_", $title);
  653.         //voting & comments stats
  654.         if ($totalvotes == 1) $votestring = "".translate("vote")."";
  655.             else $votestring = "".translate("votes")."";
  656.         if ($linkratingsummary!="0" || $linkratingsummary!="0.0") echo "<font color=777777> ".translate("Rating").":<font color=000000> $linkratingsummary ($totalvotes $votestring)";
  657.         echo "<br><a href=links.php?op=ratelink&lid=$lid&ttitle=$transfertitle>".translate("Rate this Site")."</a>";
  658.         if ($totalvotes != 0) echo " | <a href=\"links.php?op=viewlinkdetails&lid=$lid&ttitle=$transfertitle\">".translate("Details")."</a>";
  659.         if ($totalcomments != 0) echo " | <a href=\"links.php?op=viewlinkcomments&lid=$lid&ttitle=$transfertitle\">".translate("Comments")." ($totalcomments)</a>";
  660.         detecteditorial($lid, $transfertitle);
  661.     echo "<br><br>";    
  662.     
  663.     $x++;
  664.     }
  665.     
  666.     $orderby = convertorderbyout($orderby);
  667.     
  668.     //Calculates how many pages exist.  Which page one should be on, etc...  
  669.       
  670.     # echo "Count Result:  $totalselectedlinks<br>";            # testing lines
  671.     $linkpagesint = ($totalselectedlinks / $perpage);            
  672.     $linkpageremainder = ($totalselectedlinks % $perpage);        
  673.     
  674.     if ($linkpageremainder != 0) {                     
  675.         $linkpages = ceil($linkpagesint);                
  676.         if ($totalselectedlinks < $perpage) {
  677.             $linkpageremainder = 0;
  678.         }
  679.     }
  680.     else {
  681.         $linkpages = $linkpagesint;
  682.     }
  683.     //Page Numbering
  684.     if ($linkpages!=1 && $linkpages!=0) {
  685.         echo "<br><br>";
  686.           echo "".translate("Select page").":  ";
  687.          $prev=$min-$perpage;
  688.          if ($prev>=0) {
  689.             echo " <a href=links.php?op=viewlink&cid=$cid&min=$prev&orderby=$orderby&show=$show>";
  690.             echo "<b>[<< ".translate("Previous")." ]</b></a> ";
  691.       }             
  692.         $counter = 1;
  693.      $currentpage = ($max / $perpage);
  694.            while ($counter<=$linkpages ) {
  695.               $cpage = $counter;
  696.               $mintemp = ($perpage * $counter) - $perpage;
  697.               if ($counter == $currentpage) echo "<b>$counter</b> ";
  698.               else echo "<a href=links.php?op=viewlink&cid=$cid&min=$mintemp&orderby=$orderby&show=$show>$counter</a> ";
  699.                    $counter++;
  700.                    
  701.         }          
  702.          $next=$min+$perpage;
  703.          if ($x>=$perpage) {
  704.             echo " <a href=links.php?op=viewlink&cid=$cid&min=$max&orderby=$orderby&show=$show>";
  705.             echo "<b>[ ".translate("Next")." >>]</b></a>";
  706.          }         
  707.     }
  708.     /*
  709.     echo "<font color=BBBBBB size=2><br><br>
  710.     ".translate("Total links in category")." - $carrytitle (".translate("not including subcategories")."): $totalselectedlinks<br>
  711.     ".translate("Set links per page (current:")." $perpage): 
  712.     <a href=links.php?op=viewlink&cid=$cid&orderby=$orderby&show=5>5</a> 
  713.     <a href=links.php?op=viewlink&cid=$cid&orderby=$orderby&show=10>10</a> 
  714.     <a href=links.php?op=viewlink&cid=$cid&orderby=$orderby&show=15>15</a> 
  715.     <a href=links.php?op=viewlink&cid=$cid&orderby=$orderby&show=25>25</a> 
  716.     <a href=links.php?op=viewlink&cid=$cid&orderby=$orderby&show=50>50</a> 
  717.     <a href=links.php?op=viewlink&cid=$cid&orderby=$orderby&show=75>75</a> 
  718.     <a href=links.php?op=viewlink&cid=$cid&orderby=$orderby&show=10000>".translate("Show All")."</a></font>";
  719.     */
  720.  
  721.     
  722.     echo "</TD></TR></TABLE></TD></TR></TABLE>";
  723.     CloseTable();
  724.     include("footer.php");
  725. }
  726.  
  727.  
  728. function viewslink($sid, $min, $orderby, $show) {
  729.     global $admin, $perpage;
  730.     include("header.php");
  731.     OpenTable();
  732.     mainheader();
  733.     if (!isset($min)) $min=0;
  734.     if (!isset($max)) $max=$min+$perpage;
  735.     if(isset($orderby)) $orderby = convertorderbyin($orderby);
  736.     else $orderby = "title ASC";
  737.     if ($show!="") $perpage = $show;
  738.         else $show=$perpage;    
  739.  
  740.     echo "<TABLE WIDTH=100% CELLSPACING=0 CELLPADDING=3 BORDER=0><TR><TD>";
  741.     echo "<CENTER>";
  742.     echo "<TABLE WIDTH=100% CELLSPACING=2 CELLPADDING=2 BORDER=0 BGCOLOR=CCCCCC><TR><TD>";
  743.     
  744.     $result = mysql_query("select cid, title from links_subcategories where sid=$sid");
  745.     list($cid, $stitle) = mysql_fetch_row($result);
  746.     
  747.     $result2 = mysql_query("select cid, title from links_categories where cid=$cid");
  748.     list($cid, $title) = mysql_fetch_row($result2);
  749.     
  750.     echo "<font size=3><b><a href=links.php><center>".translate("Main")."</a> / <a href=links.php?op=viewlink&cid=$cid>$title</a> / $stitle</center></b>";
  751.     echo "</TD></TR></TABLE>";
  752.     
  753.     $orderbyTrans = convertorderbytrans($orderby);
  754.         echo "</center><br><font size=2><center>".translate("Sort links by").":  
  755.               ".translate("Title")." (<a href=links.php?op=viewslink&sid=$sid&orderby=titleA>A</a>\<a href=links.php?op=viewslink&sid=$sid&orderby=titleD>D</a>)
  756.               ".translate("Date")." (<a href=links.php?op=viewslink&sid=$sid&orderby=dateA>A</a>\<a href=links.php?op=viewslink&sid=$sid&orderby=dateD>D</a>)
  757.               ".translate("Rating")." (<a href=links.php?op=viewslink&sid=$sid&orderby=ratingA>A</a>\<a href=links.php?op=viewslink&sid=$sid&orderby=ratingD>D</a>)
  758.               ".translate("Popularity")." (<a href=links.php?op=viewslink&sid=$sid&orderby=hitsA>A</a>\<a href=links.php?op=viewslink&sid=$sid&orderby=hitsD>D</a>)          
  759.               </font>";
  760.     echo "<b><br><font color=BBBBBB size=2>".translate("Sites currently sorted by").": $orderbyTrans</font></b></center><br><br>";
  761.     
  762.     $result=mysql_query("select lid, url, title, description, date, hits, linkratingsummary, totalvotes, totalcomments from links_links where sid=$sid order by $orderby limit $min,$perpage");
  763.     $fullcountresult=mysql_query("select lid, title, description, date, hits, linkratingsummary, totalvotes, totalcomments from links_links where sid=$sid");
  764.     $totalselectedlinks = Mysql_num_rows($fullcountresult);
  765.     
  766.     echo "<table width=100% cellspacing=0 cellpadding=10 border=0><tr><td><font size=2>";
  767.     $x=0;
  768.     while(list($lid, $url, $title, $description, $time, $hits, $linkratingsummary, $totalvotes, $totalcomments)=mysql_fetch_row($result)) {
  769.     $linkratingsummary = number_format($linkratingsummary, $mainvotedecimal);
  770.     $title = stripslashes($title); $description = stripslashes($description);
  771.         echo "<a href=links.php?op=visit&lid=$lid target=new>$title</a>";    
  772.     newlinkgraphic($datetime, $time);
  773.     popgraphic($hits);
  774.         // code for *editor review* insert here    
  775.     echo "<br>";
  776.     echo "<font color=777777>".translate("Description: ")."<font color=000000>$description<br>";
  777.     setlocale ("LC_TIME", "$locale");
  778.     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);
  779.     $datetime = strftime("".translate("linksdatestring")."", mktime($datetime[4],$datetime[5],$datetime[6],$datetime[2],$datetime[3],$datetime[1]));
  780.     $datetime = ucfirst($datetime);
  781.     echo "<font color=777777>".translate("Added on: ")."<font color=000000>$datetime<font color=777777> ".translate("Hits: ")."<font color=000000>$hits";
  782.     
  783.         $transfertitle = str_replace (" ", "_", $title);
  784.         //voting & comments stats
  785.         if ($totalvotes == 1) $votestring = "".translate("vote")."";
  786.             else $votestring = "".translate("votes")."";
  787.         if ($linkratingsummary!="0" || $linkratingsummary!="0.0") echo "<font color=777777> ".translate("Rating").":<font color=000000> $linkratingsummary ($totalvotes $votestring)";
  788.         echo "<br><a href=links.php?op=ratelink&lid=$lid&ttitle=$transfertitle>".translate("Rate this Site")."</a>";
  789.         if ($totalvotes != 0) echo " | <a href=\"links.php?op=viewlinkdetails&lid=$lid&ttitle=$transfertitle\">".translate("Details")."</a>";
  790.         if ($totalcomments != 0) echo " | <a href=\"links.php?op=viewlinkcomments&lid=$lid&ttitle=$transfertitle\">".translate("Comments")." ($totalcomments)</a>";
  791.     detecteditorial($lid, $transfertitle);
  792.     echo "<br><br>";    
  793.     
  794.     $x++;
  795.     }
  796.     
  797.      $orderby = convertorderbyout($orderby);
  798.      
  799.     //Calculates how many pages exist.  Which page one should be on, etc...  
  800.           
  801.         # echo "Count Result:  $totalselectedlinks<br>";            # testing lines
  802.         $linkpagesint = ($totalselectedlinks / $perpage);            
  803.         $linkpageremainder = ($totalselectedlinks % $perpage);        
  804.         
  805.         if ($linkpageremainder != 0) {                     
  806.             $linkpages = ceil($linkpagesint);                
  807.             if ($totalselectedlinks < $perpage) {
  808.                 $linkpageremainder = 0;
  809.             }
  810.         }
  811.         else {
  812.             $linkpages = $linkpagesint;
  813.         }        
  814.         //Page Numbering
  815.         if ($linkpages!=1 && $linkpages!=0) {
  816.             echo "<br><br>";
  817.               echo "".translate("Select page").":  ";
  818.              $prev=$min-$perpage;
  819.              if ($prev>=0) {
  820.                 echo " <a href=links.php?op=viewslink&sid=$sid&min=$prev&orderby=$orderby&show=$show>";
  821.                 echo "<b>[<< ".translate("Previous")." ]</b></a> ";
  822.           }     
  823.             
  824.             $counter = 1;
  825.             $currentpage = ($max / $perpage);
  826.                while ($counter<=$linkpages ) {
  827.                   $cpage = $counter;
  828.                   $mintemp = ($perpage * $counter) - $perpage;
  829.                   if ($counter == $currentpage) echo "<b>$counter</b> ";
  830.                   else echo "<a href=links.php?op=viewslink&sid=$sid&min=$mintemp&orderby=$orderby&show=$show>$counter</a> ";
  831.                        $counter++;     
  832.             }        
  833.              $next=$min+$perpage;
  834.              if ($x>=$perpage) {
  835.                 echo " <a href=links.php?op=viewslink&sid=$sid&min=$max&orderby=$orderby&show=$show>";
  836.                 echo "<b>[ ".translate("Next")." >>]</b></a>";
  837.              }
  838.         }
  839.         
  840.     /*
  841.     echo "<font color=BBBBBB size=2><br><br>
  842.     ".translate("Total links in subcategory")." - $stitle: $totalselectedlinks<br>
  843.     ".translate("Set links per page (current:")." $perpage): 
  844.     <a href=links.php?op=viewslink&sid=$sid&orderby=$orderby&show=5>5</a> 
  845.     <a href=links.php?op=viewslink&sid=$sid&orderby=$orderby&show=10>10</a> 
  846.     <a href=links.php?op=viewslink&sid=$sid&orderby=$orderby&show=15>15</a> 
  847.     <a href=links.php?op=viewslink&sid=$sid&orderby=$orderby&show=25>25</a> 
  848.     <a href=links.php?op=viewslink&sid=$sid&orderby=$orderby&show=50>50</a> 
  849.     <a href=links.php?op=viewslink&sid=$sid&orderby=$orderby&show=75>75</a> 
  850.     <a href=links.php?op=viewslink&sid=$sid&orderby=$orderby&show=10000>".translate("Show All")."</a></font>";
  851.     */
  852.  
  853.     echo "</TD></TR></TABLE></TD></TR></TABLE>";
  854.     CloseTable();
  855.     include("footer.php");
  856. }
  857.  
  858. function newlinkgraphic($datetime, $time) {
  859.     echo " ";
  860.     setlocale ("LC_TIME", "$locale");
  861.     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);  
  862.     $datetime = strftime("".translate("linksdatestring")."", mktime($datetime[4],$datetime[5],$datetime[6],$datetime[2],$datetime[3],$datetime[1]));
  863.     $datetime = ucfirst($datetime);           
  864.     $startdate = time();
  865.     $count = 0;
  866.         while ($count <= 7) {
  867.                 $daysold = date("d-M-Y", $startdate);
  868.                if ("$daysold" == "$datetime") {
  869.                    if ($count<=1) echo "<img src = images/links/newred.gif alt=\"".translate("New Today")."\">";
  870.                    if ($count<=3 && $count>1) echo "<img src = images/links/newgreen.gif alt=\"".translate("New last 3 days")."\">";
  871.                    if ($count<=7 && $count>3) echo "<img src = images/links/newblue.gif alt=\"".translate("New this week")."\">";
  872.                }
  873.                $count++;
  874.                $startdate = (time()-(86400 * $count));
  875.     }
  876. }
  877.  
  878. function categorynewlinkgraphic($cat) {
  879.     
  880.     $newresult = mysql_query("select date from links_links where cid=$cat order by date desc limit 1");
  881.     list($time)=mysql_fetch_row($newresult);
  882.     echo " ";
  883.     setlocale ("LC_TIME", "$locale");
  884.     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);  
  885.     $datetime = strftime("".translate("linksdatestring")."", mktime($datetime[4],$datetime[5],$datetime[6],$datetime[2],$datetime[3],$datetime[1]));
  886.     $datetime = ucfirst($datetime);           
  887.     $startdate = time();
  888.     $count = 0;
  889.         while ($count <= 7) {
  890.                 $daysold = date("d-M-Y", $startdate);
  891.                if ("$daysold" == "$datetime") {
  892.                    if ($count<=1) echo "<img src = images/links/newred.gif alt=\"".translate("New Links in this Category Added Today")."\">";
  893.                    if ($count<=3 && $count>1) echo "<img src = images/links/newgreen.gif alt=\"".translate("New Links in this Category Added in the last 3 days")."\">";
  894.                    if ($count<=7 && $count>3) echo "<img src = images/links/newblue.gif alt=\"".translate("New Links in this Category Added this week")."\">";
  895.                }
  896.                $count++;
  897.                $startdate = (time()-(86400 * $count));
  898.     }
  899. }
  900.  
  901. function popgraphic($hits) {
  902.     global $popular;
  903.     if ($hits>=$popular) {
  904.     echo " <img src = images/links/pop.gif alt=\"".translate("Popular")."\">";
  905.     }
  906. }
  907.  
  908. //Reusable Link Sorting Functions
  909. function convertorderbyin($orderby) {
  910.         if ($orderby == "titleA")            $orderby = "title ASC"; 
  911.         if ($orderby == "dateA")            $orderby = "date ASC";
  912.         if ($orderby == "hitsA")            $orderby = "hits ASC";
  913.         if ($orderby == "ratingA")            $orderby = "linkratingsummary ASC";
  914.         if ($orderby == "titleD")            $orderby = "title DESC"; 
  915.         if ($orderby == "dateD")            $orderby = "date DESC";
  916.         if ($orderby == "hitsD")            $orderby = "hits DESC";
  917.         if ($orderby == "ratingD")            $orderby = "linkratingsummary DESC";
  918.         return $orderby;
  919. }
  920.  
  921. function convertorderbytrans($orderby) {
  922.     if ($orderby == "hits ASC")            $orderbyTrans = "".translate("Popularity (Least to Most Hits)")."";
  923.     if ($orderby == "hits DESC")            $orderbyTrans = "".translate("Popularity (Most to Least Hits)")."";
  924.     if ($orderby == "title ASC")            $orderbyTrans = "".translate("Title (A to Z)")."";
  925.     if ($orderby == "title DESC")            $orderbyTrans = "".translate("Title (Z to A)")."";
  926.     if ($orderby == "date ASC")            $orderbyTrans = "".translate("Date (Old Links Listed First)")."";
  927.     if ($orderby == "date DESC")            $orderbyTrans = "".translate("Date (New Links Listed First)")."";
  928.     if ($orderby == "linkratingsummary ASC")    $orderbyTrans = "".translate("Rating (Lowest Scores to Highest Scores)")."";
  929.         if ($orderby == "linkratingsummary DESC")    $orderbyTrans = "".translate("Rating (Highest Scores to Lowest Scores)")."";
  930.         return $orderbyTrans;
  931. }
  932.  
  933. function convertorderbyout($orderby) {
  934.            if ($orderby == "title ASC")            $orderby = "titleA";
  935.            if ($orderby == "date ASC")            $orderby = "dateA";
  936.            if ($orderby == "hits ASC")            $orderby = "hitsA";
  937.            if ($orderby == "linkratingsummary ASC")    $orderby = "ratingA";
  938.            if ($orderby == "title DESC")            $orderby = "titleD";
  939.          if ($orderby == "date DESC")            $orderby = "dateD";
  940.          if ($orderby == "hits DESC")            $orderby = "hitsD";
  941.            if ($orderby == "linkratingsummary DESC")    $orderby = "ratingD";
  942.         return $orderby;
  943. }
  944.  
  945. function visit($lid) {
  946.     mysql_query("update links_links set hits=hits+1 where lid=$lid");
  947.     $result = mysql_query("select url from links_links where lid=$lid");
  948.     list($url) = mysql_fetch_row($result);
  949.     Header("Location: $url");
  950. }
  951.  
  952. function search($query, $min, $orderby, $show) {   
  953.     global $admin, $perpage, $show, $linksresults;
  954.     if (!isset($min)) $min=0;
  955.     if (!isset($max)) $max=$min+$linksresults;
  956.     if(isset($orderby)) $orderby = convertorderbyin($orderby);
  957.     else $orderby = "title ASC";
  958.     if ($show!="") $linksresults = $show;
  959.         else $show=$linksresults;     
  960.     $query = stripslashes($query);
  961.     $result = mysql_query("select lid, cid, sid, title, url, description, date, hits, linkratingsummary, totalvotes, totalcomments from links_links where title LIKE '%$query%' OR description LIKE '%$query%' ORDER BY $orderby LIMIT $min,$linksresults");
  962.     $fullcountresult=mysql_query("select lid, title, description, date, hits, linkratingsummary, totalvotes, totalcomments from links_links where title LIKE '%$query%' OR description LIKE '%$query%' ");
  963.     $totalselectedlinks = Mysql_num_rows($fullcountresult);    
  964.     $nrows  = mysql_num_rows($result);
  965.     $resultx = mysql_query("select * from links_subcategories where title LIKE '%$query%' ORDER BY title DESC");
  966.     $nrowsx  = mysql_num_rows($resultx);
  967.  
  968.     $x=0;
  969.  
  970.     include("header.php");
  971.     OpenTable();
  972.     mainheader();
  973.     echo "
  974.     <TABLE WIDTH=100% CELLSPACING=0 CELLPADDING=8 BORDER=0><TR><TD><font size=2>
  975.     <CENTER>";
  976.     if ($query != "") {
  977.         if ($nrows>0 OR $nrowsx>0) {
  978.         
  979.         $result2 = mysql_query("select cid, sid, title from links_subcategories where title LIKE '%$query%' ORDER BY title DESC");
  980.         echo "<font size=3>".translate("Search Results for: ")."<font color=Red>$query<font color=Black size=2><br><br>";
  981.         echo "</center><table width=100% bgcolor=CCCCCC><tr><td><font size=3><b>".translate("SubCategories")."</b></td></tr></table>";
  982.         while(list($cid, $sid, $stitle) = mysql_fetch_row($result2)) {
  983.             $cate = mysql_query("select title from links_categories where cid=$cid");
  984.             list($ctitle) = mysql_fetch_row($cate);
  985.             $res = mysql_query("select * from links_links where sid=$sid");
  986.             $numrows = mysql_num_rows($res);
  987.             $ctitle = ereg_replace($query, "<b>$query</b>", $ctitle);
  988.             $stitle = ereg_replace($query, "<b>$query</b>", $stitle);
  989.             echo "<li><a href=links.php?op=viewslink&sid=$sid>$ctitle / $stitle</a> ($numrows)<br>";
  990.         }
  991.         
  992.         echo "<br><table width=100% bgcolor=CCCCCC><tr><td><font size=3><b>".translate("Links")."</b></td></tr></table>";
  993.         $orderbyTrans = convertorderbytrans($orderby);
  994.             echo "</center><br><font size=2>".translate("Sort links by").":  
  995.                   ".translate("Title")." (<a href=links.php?op=search&query=$query&orderby=titleA>A</a>\<a href=links.php?op=search&query=$query&orderby=titleD>D</a>)
  996.                   ".translate("Date")." (<a href=links.php?op=search&query=$query&orderby=dateA>A</a>\<a href=links.php?op=search&query=$query&orderby=dateD>D</a>)
  997.                   ".translate("Rating")." (<a href=links.php?op=search&query=$query&orderby=ratingA>A</a>\<a href=links.php?op=search&query=$query&orderby=ratingD>D</a>)
  998.                   ".translate("Popularity")." (<a href=links.php?op=search&query=$query&orderby=hitsA>A</a>\<a href=links.php?op=search&query=$query&orderby=hitsD>D</a>)          
  999.                   </font>";
  1000.         echo "<b><br><font color=BBBBBB size=2>".translate("Sites currently sorted by").": $orderbyTrans</font></b><br><br>";
  1001.             while(list($lid, $cid, $sid, $title, $url, $description, $time, $hits, $linkratingsummary, $totalvotes, $totalcomments) = mysql_fetch_row($result)) {
  1002.             $linkratingsummary = number_format($linkratingsummary, $mainvotedecimal);
  1003.             $title = stripslashes($title); $description = stripslashes($description);        
  1004.             $transfertitle = str_replace (" ", "_", $title);
  1005.             $title = ereg_replace($query, "<b>$query</b>", $title);
  1006.     
  1007.             echo "<a href=links.php?op=visit&lid=$lid target=new>$title</a>";    
  1008.             newlinkgraphic($datetime, $time);      
  1009.                 popgraphic($hits);    
  1010.             echo "<br>";        
  1011.             $description = ereg_replace($query, "<b>$query</b>", $description);
  1012.             echo "<font color=777777>".translate("Description: ")."<font color=000000>$description<br>";
  1013.             setlocale ("LC_TIME", "$locale");
  1014.             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);
  1015.             $datetime = strftime("".translate("linksdatestring")."", mktime($datetime[4],$datetime[5],$datetime[6],$datetime[2],$datetime[3],$datetime[1]));
  1016.             $datetime = ucfirst($datetime);
  1017.             echo "<font color=777777>".translate("Added on: ")."<font color=000000>$datetime<font color=777777> ".translate("Hits: ")."<font color=000000>$hits";
  1018.             
  1019.             //voting & comments stats
  1020.             if ($totalvotes == 1) $votestring = "".translate("vote")."";
  1021.                 else $votestring = "".translate("votes")."";
  1022.             if ($linkratingsummary!="0" || $linkratingsummary!="0.0") echo "<font color=777777> ".translate("Rating").":<font color=000000> $linkratingsummary ($totalvotes $votestring)";
  1023.             echo "<br><a href=links.php?op=ratelink&lid=$lid&ttitle=$transfertitle>".translate("Rate this Site")."</a>";
  1024.             if ($totalvotes != 0) echo " | <a href=links.php?op=viewlinkdetails&lid=$lid&ttitle=$transfertitle>".translate("Details")."</a>";
  1025.             if ($totalcomments != 0) echo " | <a href=links.php?op=viewlinkcomments&lid=$lid&ttitle=$transfertitle>".translate("Comments")." ($totalcomments)</a>";
  1026.         detecteditorial($lid, $transfertitle);
  1027.         echo "<br>";            
  1028.             $result3 = mysql_query("select title from links_categories where cid=$cid");
  1029.             $result4 = mysql_query("select title from links_subcategories where sid=$sid");
  1030.             list($ctitle) = mysql_fetch_row($result3);
  1031.             list($stitle) = mysql_fetch_row($result4);
  1032.             if ($stitle=="") {
  1033.             $slash = "";
  1034.             } else {
  1035.             $slash = "/";
  1036.             }
  1037.             echo "<font color=777777>".translate("Category: ")."<font color=000000>$ctitle $slash $stitle<br><br>";
  1038.             $x++;
  1039.             
  1040.             }
  1041.             $orderby = convertorderbyout($orderby);
  1042.                     
  1043.         } else {
  1044.             echo "<center><font color=Red size=3>".translate("No matches found to your query")."</font></center><br><br>";
  1045.         }
  1046.  
  1047.     
  1048.     //Calculates how many pages exist.  Which page one should be on, etc...  
  1049.           
  1050.         # echo "Count Result:  $totalselectedlinks<br>";            # testing lines
  1051.         $linkpagesint = ($totalselectedlinks / $linksresults);            
  1052.         $linkpageremainder = ($totalselectedlinks % $linksresults);        
  1053.         
  1054.         if ($linkpageremainder != 0) {                     
  1055.             $linkpages = ceil($linkpagesint);                
  1056.             if ($totalselectedlinks < $linksresults) {
  1057.                 $linkpageremainder = 0;
  1058.             }
  1059.         }
  1060.         else {
  1061.             $linkpages = $linkpagesint;
  1062.         }        
  1063.         //Page Numbering
  1064.         if ($linkpages!=1 && $linkpages!=0) {
  1065.             echo "<br><br>";
  1066.               echo "Select page:  ";
  1067.              $prev=$min-$linksresults;
  1068.              if ($prev>=0) {
  1069.                 echo " <a href=links.php?op=search&query=$query&min=$prev&orderby=$orderby&show=$show>";
  1070.                 echo "<b>[<< ".translate("Previous")." ]</b></a> ";
  1071.           }     
  1072.             
  1073.             $counter = 1;
  1074.             $currentpage = ($max / $linksresults);
  1075.                while ($counter<=$linkpages ) {
  1076.                   $cpage = $counter;
  1077.                   $mintemp = ($perpage * $counter) - $linksresults;
  1078.                   if ($counter == $currentpage) echo "<b>$counter</b> ";
  1079.                   else echo "<a href=links.php?op=search&query=$query&min=$mintemp&orderby=$orderby&show=$show>$counter</a> ";
  1080.                        $counter++;     
  1081.             }        
  1082.              $next=$min+$linksresults;
  1083.              if ($x>=$perpage) {
  1084.                 echo " <a href=links.php?op=search&query=$query&min=$max&orderby=$orderby&show=$show>";
  1085.                 echo "<b>[ ".translate("Next")." >>]</b></a>";
  1086.              }
  1087.         }
  1088.  
  1089.     echo "<br><br><center><font size=2>
  1090.     ".translate("Try to search")." \"$query\" ".translate("in others Search Engines")."<br>
  1091.     <a target=\"_blank\" href=\"http://www.altavista.com/cgi-bin/query?pg=q&sc=on&hl=on&act=2006&par=0&q=$query&kl=XX&stype=stext\">Alta Vista</a> - 
  1092.     <a target=\"_blank\" href=\"http://www.hotbot.com/?MT=$query&DU=days&SW=web\">HotBot</a> -
  1093.     <a target=\"_blank\" href=\"http://www.infoseek.com/Titles?qt=$query\">Infoseek</a> - 
  1094.     <a target=\"_blank\" href=\"http://www.dejanews.com/dnquery.xp?QRY=$query\">Deja News</a> -
  1095.     <a target=\"_blank\" href=\"http://www.lycos.com/cgi-bin/pursuit?query=$query&maxhits=20\">Lycos</a> - 
  1096.     <a target=\"_blank\" href=\"http://search.yahoo.com/bin/search?p=$query\">Yahoo</a>
  1097.     <br>
  1098.     <a target=\"_blank\" href=\"http://es.linuxstart.com/cgi-bin/sqlsearch.cgi?pos=1&query=$query&language=&advanced=&urlonly=&withid=\">LinuxStart</a> - 
  1099.     <a target=\"_blank\" href=\"http://search.1stlinuxsearch.com/compass?scope=$query&ui=sr\">1stLinuxSearch</a> -
  1100.     <a target=\"_blank\" href=\"http://www.google.com/search?q=$query\">Google</a> -
  1101.     <a target=\"_blank\" href=\"http://www.linuxlinks.com/cgi-bin/search.cgi?query=$query&engine=Links\">LinuxLinks</a> -
  1102.     <a target=\"_blank\" href=\"http://www.freshmeat.net/search.php?query=$query\">Freshmeat</a> -
  1103.     <a target=\"_blank\" href=\"http://www.justlinux.com/bin/search.pl?key=$query\">JustLinux</a>
  1104.     </font>";
  1105.     
  1106.     
  1107.     } else {
  1108.      echo "<center><font color=Red size=3>".translate("No matches found to your query")."</font></center><br><br>";
  1109.     }
  1110.     
  1111.     echo "</td></tr></table>\n";
  1112.     CloseTable();
  1113.     include("footer.php");
  1114.  
  1115. }
  1116.  
  1117. //POSSIBLY split file here (rating stuff in new file?)
  1118.  
  1119. function viewlinkeditorial($lid, $ttitle) {
  1120.  
  1121.     global $admin;
  1122.     include("header.php");
  1123.     OpenTable();
  1124.     mainheader();
  1125.     
  1126.     $result=mysql_query("SELECT adminid, editorialtimestamp, editorialtext, editorialtitle FROM links_editorials WHERE linkid = $lid");
  1127.     $recordexist = Mysql_num_rows($result);
  1128.     
  1129.     echo "<table align=center border=0 cellspacing=0 cellpadding=2 width=98%>";
  1130.     $transfertitle = ereg_replace ("_", " ", $ttitle);
  1131.     $displaytitle = $transfertitle;
  1132.     echo "
  1133.          
  1134.           <tr><td>
  1135.             <TABLE WIDTH=100% CELLSPACING=2 CELLPADDING=2 BORDER=0 BGCOLOR=CCCCCC><TR><TD>
  1136.                <center><FONT SIZE=3><b>".translate("Link Profile").":  $displaytitle</b></font></center>
  1137.             </tr></td></table>
  1138.           </td></tr>
  1139.           <tr><td>";
  1140.     echo "<center>";
  1141.     linkinfomenu($lid, $ttitle); 
  1142.     echo "</center><br>
  1143.           </td><tr>
  1144.           <tr><td>";
  1145.             
  1146.     if ($recordexist != 0) {     
  1147.         while(list($adminid, $editorialtimestamp, $editorialtext, $editorialtitle)=mysql_fetch_row($result)) {         
  1148.             $editorialtitle = stripslashes($editorialtitle); $editorialtext = stripslashes($editorialtext);
  1149.             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);
  1150.         $editorialtime = strftime("%F",mktime($editorialtime[4],$editorialtime[5],$editorialtime[6],$editorialtime[2],$editorialtime[3],$editorialtime[1]));
  1151.         $date_array = explode("-", $editorialtime); 
  1152.         $timestamp = mktime(0, 0, 0, $date_array["1"], $date_array["2"], $date_array["0"]); 
  1153.                $formatted_date = date("F j, Y", $timestamp);      
  1154.             echo "<tr><td>
  1155.                   <table align=center border=1 bordercolor=AAAAAA cellpadding=7 cellspacing=0 width=400>
  1156.                   <tr><td>
  1157.                   <center><font size=3><b>'$editorialtitle'</b></font></center>
  1158.                   <center><font size=1>".translate("Editorial by")." $adminid - $formatted_date</font></center><br><br>          
  1159.                   $editorialtext          
  1160.                   <br><br>
  1161.                   </td></tr></table>
  1162.               </td></tr>";
  1163.         }    
  1164.     }
  1165.     else {
  1166.         echo "<br><br><center>".translate("No editorial is currently available for this website.")."</center><br>";
  1167.     }
  1168.     echo "</table><br><br>";
  1169.     linkfooter($lid,$ttitle);
  1170.     CloseTable();
  1171.     include("footer.php");
  1172.  
  1173. }
  1174.  
  1175. function detecteditorial($lid, $ttitle) {
  1176.     $resulted2 = mysql_query("select adminid from links_editorials where linkid=$lid");
  1177.     $recordexist = Mysql_num_rows($resulted2);
  1178.     // if returns 'bad query' status 0 (add editorial)
  1179.     if ($recordexist != 0) echo " | <a href=links.php?op=viewlinkeditorial&lid=$lid&ttitle=$ttitle>Editorial</a>";
  1180.     
  1181. }
  1182.  
  1183. function viewlinkcomments($lid, $ttitle) {
  1184.     global $admin;
  1185.     include("header.php");
  1186.     OpenTable();
  1187.     mainheader();
  1188.     
  1189.     $result=mysql_query("SELECT ratinguser, rating, ratingcomments, ratingtimestamp FROM links_votedata WHERE ratinglid = $lid AND ratingcomments != '' ORDER BY ratingtimestamp DESC");
  1190.     $totalcomments = Mysql_num_rows($result);  
  1191.     
  1192.     echo "<table align=center border=0 cellspacing=0 cellpadding=2 width=98%>";
  1193.     
  1194.     $transfertitle = ereg_replace ("_", " ", $ttitle);
  1195.     $displaytitle = $transfertitle;
  1196.     echo "
  1197.          
  1198.           <tr><td>
  1199.             <TABLE WIDTH=100% CELLSPACING=2 CELLPADDING=2 BORDER=0 BGCOLOR=CCCCCC><TR><TD>
  1200.                <center><FONT SIZE=3><b>".translate("Link Profile").":  $displaytitle</b></font></center>
  1201.             </tr></td></table>
  1202.           </td></tr>
  1203.           <tr><td>";
  1204.     echo "<center>";
  1205.     linkinfomenu($lid, $ttitle); 
  1206.     echo "</center><br>
  1207.           </td><tr>
  1208.           <tr><td>";
  1209.     echo "<br><center>".translate("Total of")." $totalcomments ".translate("comments")."</center></font><br>";
  1210.     echo "<table align=center border=0 cellspacing=0 cellpadding=2 width=450>";
  1211.     
  1212.     $x=0;
  1213.     while(list($ratinguser, $rating, $ratingcomments, $ratingtimestamp)=mysql_fetch_row($result)) {
  1214.         $ratingcomments = stripslashes($ratingcomments);
  1215.         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);
  1216.     $ratingtime = strftime("%F",mktime($ratingtime[4],$ratingtime[5],$ratingtime[6],$ratingtime[2],$ratingtime[3],$ratingtime[1]));
  1217.     $date_array = explode("-", $ratingtime); 
  1218.     $timestamp = mktime(0, 0, 0, $date_array["1"], $date_array["2"], $date_array["0"]); 
  1219.         $formatted_date = date("F j, Y", $timestamp); 
  1220.     
  1221.     //Individual user information
  1222.     $result2=mysql_query("SELECT rating FROM links_votedata WHERE ratinguser = '$ratinguser'");
  1223.         $usertotalcomments = Mysql_num_rows($result2);
  1224.         $useravgrating = 0;
  1225.         while(list($rating2)=mysql_fetch_row($result2))    $useravgrating = $useravgrating + $rating2;
  1226.         $useravgrating = $useravgrating / $usertotalcomments;
  1227.         $useravgrating = number_format($useravgrating, 1);
  1228.         
  1229.         
  1230.         echo "<tr>
  1231.                 <td bgcolor=#CCCCCC>
  1232.                    <font size=2><B> ".translate("User").":  </b><a href=$nuke_url/user.php?op=userinfo&uname=$ratinguser>$ratinguser</a></font>
  1233.             </td>
  1234.             <td bgcolor=#CCCCCC>
  1235.             <font size=2><B>".translate("Rating").":  </b>$rating</font>
  1236.             </td>
  1237.             <td bgcolor=#CCCCCC align=right>
  1238.                    <font size=2>$formatted_date</font>
  1239.             </td>
  1240.           </tr>
  1241.           <tr height=1>
  1242.             <td valign=top>
  1243.                <font size=1 color=AAAAAA>".translate("User's Average Rating").": $useravgrating</font>
  1244.             </td>
  1245.             <td valign=top height=1 colspan=2>
  1246.             <font size=1 color=AAAAAA>".translate("# of Ratings").": $usertotalcomments</font>
  1247.             </td>
  1248.           </tr>
  1249.  
  1250.           <tr>
  1251.             <td colspan=3>
  1252.             <font size=2>";    if ($admin) echo "<a href=admin.php?op=LinksModLink&lid=$lid><img src=images/links/editicon.gif border=0 Alt=\"".translate("Edit This Link")."\"></a>"; echo" $ratingcomments</font>";
  1253.           
  1254.     echo "  <br><br><br>
  1255.             </td>
  1256.           </tr>";        
  1257.     $x++;
  1258.     }    
  1259.     
  1260.     echo "</table></table><br><br>";
  1261.     linkfooter($lid,$ttitle);
  1262.     CloseTable();
  1263.     include("footer.php");
  1264.  
  1265. }
  1266.  
  1267. function viewlinkdetails($lid, $ttitle) {
  1268.     global $admin;
  1269.     include("header.php");
  1270.     OpenTable();
  1271.     mainheader();
  1272.     
  1273.     $voteresult = mysql_query("select rating, ratinguser, ratingcomments FROM links_votedata WHERE ratinglid = $lid");
  1274.     $totalvotesDB = mysql_num_rows($voteresult);    
  1275.     $anonvotes = 0;
  1276.     $anonvoteval = 0;
  1277.     $outsidevotes = 0;
  1278.     $outsidevoteeval = 0;
  1279.     $regvoteval = 0;    
  1280.     $topanon = 0;
  1281.     $bottomanon = 11;
  1282.     $topreg = 0;
  1283.     $bottomreg = 11;
  1284.     $topoutside = 0;
  1285.     $bottomoutside = 11;    
  1286.     $avv = array(0,0,0,0,0,0,0,0,0,0,0);
  1287.     $rvv = array(0,0,0,0,0,0,0,0,0,0,0);
  1288.     $ovv = array(0,0,0,0,0,0,0,0,0,0,0);
  1289.  
  1290.     $truecomments = $totalvotesDB;
  1291.     while(list($ratingDB, $ratinguserDB, $ratingcommentsDB)=mysql_fetch_row($voteresult)) {
  1292.          if ($ratingcommentsDB=="") $truecomments--;
  1293.             if ($ratinguserDB==$anonymous) {
  1294.                    $anonvotes++;
  1295.                 $anonvoteval += $ratingDB;
  1296.             }
  1297.             if ($useoutsidevoting == 1) {
  1298.                 if ($ratinguserDB=='outside') {
  1299.                     $outsidevotes++;
  1300.                     $outsidevoteval += $ratingDB;
  1301.                 }
  1302.             }
  1303.             else { $outsidevotes = 0; }
  1304.             
  1305.              if ($ratinguserDB!=$anonymous && $ratinguserDB!="outside") { $regvoteval += $ratingDB; }
  1306.              
  1307.              if ($ratinguserDB!=$anonymous && $ratinguserDB!="outside") {
  1308.                  if ($ratingDB > $topreg) $topreg = $ratingDB;
  1309.                  if ($ratingDB < $bottomreg) $bottomreg = $ratingDB;
  1310.                  for ($rcounter=1; $rcounter<11; $rcounter++) if ($ratingDB==$rcounter) $rvv[$rcounter]++;    
  1311.              }
  1312.              if ($ratinguserDB==$anonymous) {
  1313.                  if ($ratingDB > $topanon) $topanon = $ratingDB;
  1314.                  if ($ratingDB < $bottomanon) $bottomanon = $ratingDB;
  1315.                  for ($rcounter=1; $rcounter<11; $rcounter++) if ($ratingDB==$rcounter) $avv[$rcounter]++;    
  1316.              }
  1317.              if ($ratinguserDB=="outside") {
  1318.                  if ($ratingDB > $topoutside) $topoutside = $ratingDB;
  1319.                  if ($ratingDB < $bottomoutside) $bottomoutside = $ratingDB;
  1320.                  for ($rcounter=1; $rcounter<11; $rcounter++) if ($ratingDB==$rcounter) $ovv[$rcounter]++;    
  1321.              }             
  1322.      }
  1323.      $regvotes = $totalvotesDB - $anonvotes - $outsidevotes;     
  1324.          if ($totalvotesDB == 0) $finalrating = 0;
  1325.               else if ($anonvotes == 0 && $regvotes == 0) {
  1326.                   // Figure Outside Only Vote
  1327.                   $finalrating = $outsidevoteval / $outsidevotes;
  1328.                   $finalrating = number_format($finalrating, $detailvotedecimal); 
  1329.               $avgOU = $outsidevoteval / $totalvotesDB;
  1330.               $avgOU = number_format($avgOU, $detailvotedecimal);                  
  1331.               }
  1332.               else if ($outsidevotes == 0 && $regvotes == 0) {
  1333.                   // Figure Anon Only Vote
  1334.                   $finalrating = $anonvoteval / $anonvotes;                  
  1335.                   $finalrating = number_format($finalrating, $detailvotedecimal); 
  1336.               $avgAU = $anonvoteval / $totalvotesDB;
  1337.               $avgAU = number_format($avgAU, $detailvotedecimal);                  
  1338.               }
  1339.               else if ($outsidevotes == 0 && $anonvotes == 0) {
  1340.                   // Figure Reg Only Vote
  1341.                   $finalrating = $regvoteval / $regvotes;                  
  1342.                   $finalrating = number_format($finalrating, $detailvotedecimal); 
  1343.               $avgRU = $regvoteval / $totalvotesDB;
  1344.               $avgRU = number_format($avgRU, $detailvotedecimal);                  
  1345.               }                  
  1346.           else if ($regvotes == 0 && $useoutsidevoting == 1 && $outsidevotes != 0 && $anonvotes != 0 ) {
  1347.           // Figure Reg and Anon Mix
  1348.               
  1349.               $avgAU = $anonvoteval / $anonvotes;
  1350.               $avgOU = $outsidevoteval / $outsidevotes;              
  1351.               
  1352.                  if ($anonweight > $outsideweight ) {
  1353.                      // Anon is 'standard weight'
  1354.                 $newimpact = $anonweight / $outsideweight;
  1355.                 $impactAU = $anonvotes;
  1356.                 $impactOU = $outsidevotes / $newimpact;
  1357.  
  1358.                      $finalrating = ((($avgOU * $impactOU) + ($avgAU * $impactAU)) / ($impactAU + $impactOU));
  1359.                      $finalrating = number_format($finalrating, $detailvotedecimal); 
  1360.                  }
  1361.                  else {
  1362.                      // Outside is 'standard weight'
  1363.                         $newimpact = $outsideweight / $anonweight;
  1364.                      $impactOU = $outsidevotes;
  1365.                      $impactAU = $anonvotes / $newimpact;
  1366.                      
  1367.                      $finalrating = ((($avgOU * $impactOU) + ($avgAU * $impactAU)) / ($impactAU + $impactOU));
  1368.                      $finalrating = number_format($finalrating, $detailvotedecimal); 
  1369.                  
  1370.                  }                            
  1371.           }
  1372.           else {
  1373.                  //REG User vs. Anonymous vs. Outside User Weight Calutions
  1374.                  
  1375.                  $impact = $anonweight;                  // REG users are weighted by the impact.
  1376.                  $outsideimpact = $outsideweight;
  1377.                  if ($regvotes == 0) { $avgRU = 0; }
  1378.                      else { $avgRU = $regvoteval / $regvotes; }
  1379.                  if ($anonvotes == 0) { $avgAU = 0; }
  1380.                      else { $avgAU = $anonvoteval / $anonvotes; }
  1381.                  if ($outsidevotes == 0 ) { $avgOU = 0; }
  1382.                      else { $avgOU = $outsidevoteval / $outsidevotes; }
  1383.                  $impactRU = $regvotes;
  1384.  
  1385. // Division by zero?                 
  1386.             if ($anonvote>=1 && $impact>=1) {
  1387.                 $impactAU = $anonvotes / $impact;
  1388.             }
  1389.             if ($outsidevotes>=1 && $outsideimpact>=1) {
  1390.                      $impactOU = $outsidevotes / $outsideimpact;
  1391.                  }
  1392.  
  1393.  
  1394.             $finalrating = (($avgRU * $impactRU) + ($avgAU * $impactAU) + ($avgOU * $impactOU)) / ($impactRU + $impactAU + $impactOU);
  1395.                  $finalrating = number_format($finalrating, $detailvotedecimal); 
  1396.               }
  1397.  
  1398.     if ($avgOU == 0 || $avgOU == "") { $avgOU = ""; }
  1399.         else { $avgOU = number_format($avgOU, $detailvotedecimal); }
  1400.     if ($avgRU == 0 || $avgRU == "") { $avgRU = ""; }
  1401.         else { $avgRU = number_format($avgRU, $detailvotedecimal); }
  1402.     if ($avgAU == 0 || $avgAU == "") { $avgAU = ""; }
  1403.         else { $avgAU = number_format($avgAU, $detailvotedecimal); }        
  1404.     
  1405.     
  1406.     if ($topanon == 0) $topanon = "";
  1407.     if ($bottomanon == 11) $bottomanon = "";
  1408.     if ($topreg == 0) $topreg = "";
  1409.     if ($bottomreg == 11) $bottomreg = "";
  1410.     if ($topoutside == 0) $topoutside = "";
  1411.     if ($bottomoutside == 11) $bottomoutside = "";    
  1412.     $totalchartheight = 70;
  1413.     $chartunits = $totalchartheight / 10;
  1414.     
  1415.     $avvper        = array(0,0,0,0,0,0,0,0,0,0,0);
  1416.     $rvvper         = array(0,0,0,0,0,0,0,0,0,0,0);
  1417.     $ovvper         = array(0,0,0,0,0,0,0,0,0,0,0);
  1418.     $avvpercent     = array(0,0,0,0,0,0,0,0,0,0,0);
  1419.     $rvvpercent     = array(0,0,0,0,0,0,0,0,0,0,0);
  1420.     $ovvpercent     = array(0,0,0,0,0,0,0,0,0,0,0);
  1421.     $avvchartheight     = array(0,0,0,0,0,0,0,0,0,0,0);
  1422.     $rvvchartheight     = array(0,0,0,0,0,0,0,0,0,0,0);
  1423.     $ovvchartheight     = array(0,0,0,0,0,0,0,0,0,0,0);
  1424.     $avvmultiplier = 0;
  1425.     $rvvmultiplier = 0;
  1426.     $ovvmultiplier = 0;
  1427.     
  1428.     for ($rcounter=1; $rcounter<11; $rcounter++) {
  1429.         if ($anonvotes != 0) $avvper[$rcounter] = $avv[$rcounter] / $anonvotes;
  1430.         if ($regvotes != 0) $rvvper[$rcounter] = $rvv[$rcounter] / $regvotes;
  1431.         if ($outsidevotes != 0) $ovvper[$rcounter] = $ovv[$rcounter] / $outsidevotes;
  1432.         $avvpercent[$rcounter] = number_format($avvper[$rcounter] * 100, 1);
  1433.         $rvvpercent[$rcounter] = number_format($rvvper[$rcounter] * 100, 1);
  1434.         $ovvpercent[$rcounter] = number_format($ovvper[$rcounter] * 100, 1);
  1435.         if ($avv[$rcounter] > $avvmultiplier) $avvmultiplier = $avv[$rcounter];
  1436.         if ($rvv[$rcounter] > $rvvmultiplier) $rvvmultiplier = $rvv[$rcounter];
  1437.         if ($ovv[$rcounter] > $ovvmultiplier) $ovvmultiplier = $ovv[$rcounter];
  1438.     }
  1439.     if ($avvmultiplier != 0) $avvmultiplier = 10 / $avvmultiplier;
  1440.     if ($rvvmultiplier != 0) $rvvmultiplier = 10 / $rvvmultiplier;
  1441.     if ($ovvmultiplier != 0) $ovvmultiplier = 10 / $ovvmultiplier;
  1442.     
  1443.     for ($rcounter=1; $rcounter<11; $rcounter++) {
  1444.         
  1445.         $avvchartheight[$rcounter] = ($avv[$rcounter] * $avvmultiplier) * $chartunits;
  1446.         $rvvchartheight[$rcounter] = ($rvv[$rcounter] * $rvvmultiplier) * $chartunits;
  1447.         $ovvchartheight[$rcounter] = ($ovv[$rcounter] * $ovvmultiplier) * $chartunits;        
  1448.         if ($avvchartheight[$rcounter]==0) $avvchartheight[$rcounter]=1;
  1449.         if ($rvvchartheight[$rcounter]==0) $rvvchartheight[$rcounter]=1;
  1450.         if ($ovvchartheight[$rcounter]==0) $ovvchartheight[$rcounter]=1;        
  1451.     }
  1452.         
  1453.     echo "<table align=center border=0 cellspacing=0 cellpadding=2 width=98%>";
  1454.     $transfertitle = ereg_replace ("_", " ", $ttitle);
  1455.     $displaytitle = $transfertitle;
  1456.  
  1457.     echo "<tr><td>
  1458.             <TABLE WIDTH=100% CELLSPACING=2 CELLPADDING=2 BORDER=0 BGCOLOR=CCCCCC><TR><TD>
  1459.                <center><FONT SIZE=3><b>".translate("Link Profile").":  $displaytitle</b></font></center>
  1460.             </tr></td></table>
  1461.           </td></tr>
  1462.           <tr><td>";
  1463.     echo "<center>";
  1464.     linkinfomenu($lid, $ttitle); 
  1465.     echo "</center><br>
  1466.           </td><tr>
  1467.           <tr><td>";
  1468.     echo "<center>
  1469.     ".translate("Link Rating Details")."<br>
  1470.           $totalvotesDB ".translate("total votes")."<br>
  1471.           ".translate("Overall Rating").":  $finalrating</font></center><br><br>";
  1472.     echo "<table align=center border=0 cellspacing=0 cellpadding=2 width=455>";         
  1473.     echo "<tr>
  1474.             <td colspan=2 bgcolor=#BBBBBB>
  1475.             <font size=2><B>".translate("Registered Users")."</b></font>
  1476.         </td>
  1477.       <tr>
  1478.       <tr height=1 bac>
  1479.         <td bgcolor=#DDDDDD>
  1480.             <font size=2>".translate("Number of Ratings").":  $regvotes</font>
  1481.         </td>
  1482.         <td rowspan=5 width=200>";
  1483.            if ($regvotes==0) echo "<center><font size=-2>".translate("No Registered User Votes")."</font></center>";
  1484.                else { 
  1485.                echo "
  1486.            <table border=1 width=200 height=100%>      
  1487.              <tr>
  1488.                <td valign=top align=center colspan=10 bgcolor=BBBBBB><font size=-2>".translate("Breakdown of Ratings by Value")."</font></td>
  1489.              </tr>
  1490.              <tr>
  1491.            <td bgcolor=FFFFFF valign=bottom><img border=0 alt=\"$rvv[1] ".translate("votes")." ($rvvpercent[1]% ".translate("total votes").")\" src=images/blackpixel.gif width=15 height=$rvvchartheight[1]></td>
  1492.            <td bgcolor=FFFFFF valign=bottom><img border=0 alt=\"$rvv[2] ".translate("votes")." ($rvvpercent[2]% ".translate("total votes").")\" src=images/blackpixel.gif width=15 height=$rvvchartheight[2]></td>
  1493.            <td bgcolor=FFFFFF valign=bottom><img border=0 alt=\"$rvv[3] ".translate("votes")." ($rvvpercent[3]% ".translate("total votes").")\" src=images/blackpixel.gif width=15 height=$rvvchartheight[3]></td>
  1494.            <td bgcolor=FFFFFF valign=bottom><img border=0 alt=\"$rvv[4] ".translate("votes")." ($rvvpercent[4]% ".translate("total votes").")\" src=images/blackpixel.gif width=15 height=$rvvchartheight[4]></td>
  1495.            <td bgcolor=FFFFFF valign=bottom><img border=0 alt=\"$rvv[5] ".translate("votes")." ($rvvpercent[5]% ".translate("total votes").")\" src=images/blackpixel.gif width=15 height=$rvvchartheight[5]></td>
  1496.            <td bgcolor=FFFFFF valign=bottom><img border=0 alt=\"$rvv[6] ".translate("votes")." ($rvvpercent[6]% ".translate("total votes").")\" src=images/blackpixel.gif width=15 height=$rvvchartheight[6]></td>
  1497.            <td bgcolor=FFFFFF valign=bottom><img border=0 alt=\"$rvv[7] ".translate("votes")." ($rvvpercent[7]% ".translate("total votes").")\" src=images/blackpixel.gif width=15 height=$rvvchartheight[7]></td>
  1498.            <td bgcolor=FFFFFF valign=bottom><img border=0 alt=\"$rvv[8] ".translate("votes")." ($rvvpercent[8]% ".translate("total votes").")\" src=images/blackpixel.gif width=15 height=$rvvchartheight[8]></td>
  1499.            <td bgcolor=FFFFFF valign=bottom><img border=0 alt=\"$rvv[9] ".translate("votes")." ($rvvpercent[9]% ".translate("total votes").")\" src=images/blackpixel.gif width=15 height=$rvvchartheight[9]></td>
  1500.            <td bgcolor=FFFFFF valign=bottom><img border=0 alt=\"$rvv[10] ".translate("votes")." ($rvvpercent[10]% ".translate("total votes").")\" src=images/blackpixel.gif width=15 height=$rvvchartheight[10]></td>
  1501.              </tr>
  1502.              <tr><td colspan=10>
  1503.                 <table cellspacing=0 cellspacing=0 border=0 height=5 width=200><tr></td>
  1504.             <td bgcolor=FFFFFF width=10% valign=bottom align=center><font size=-2>1</font></td>
  1505.             <td bgcolor=FFFFFF width=10% valign=bottom align=center><font size=-2>2</font></td>
  1506.             <td bgcolor=FFFFFF width=10% valign=bottom align=center><font size=-2>3</font></td>
  1507.             <td bgcolor=FFFFFF width=10% valign=bottom align=center><font size=-2>4</font></td>
  1508.             <td bgcolor=FFFFFF width=10% valign=bottom align=center><font size=-2>5</font></td>
  1509.             <td bgcolor=FFFFFF width=10% valign=bottom align=center><font size=-2>6</font></td>
  1510.             <td bgcolor=FFFFFF width=10% valign=bottom align=center><font size=-2>7</font></td>
  1511.             <td bgcolor=FFFFFF width=10% valign=bottom align=center><font size=-2>8</font></td>
  1512.             <td bgcolor=FFFFFF width=10% valign=bottom align=center><font size=-2>9</font></td>
  1513.             <td bgcolor=FFFFFF width=10% valign=bottom align=center><font size=-2>10</font></td>
  1514.                 </td><tr></table>
  1515.              </td></tr> 
  1516.            </table>
  1517.            ";
  1518.            }
  1519.            echo "
  1520.         </td>
  1521.       </tr>
  1522.       <tr><td bgcolor=#CCCCCC><font size=2>".translate("Link Rating").": $avgRU</font></td></tr>
  1523.       <tr><td bgcolor=#DDDDDD><font size=2>".translate("High Rating").": $topreg</font></td></tr>
  1524.       <tr><td bgcolor=#CCCCCC><font size=2>".translate("Low Rating").": $bottomreg</font></td></tr>
  1525.       <tr><td bgcolor=#DDDDDD><font size=2>".translate("Number of Comments").": $truecomments</font></td></tr>
  1526.       <tr><td></td></tr>
  1527.       <tr><td valign=top colspan=2><font size=1><br><br>* ".translate("Note: This website weighs Registered vs. Unregistered user's ratings")." $anonweight ".translate("to")." 1.</font></td></tr>
  1528.           <tr><td colspan=2 bgcolor=#BBBBBB><font size=2><B>".translate("Unregistered Users")."</b></font></td></tr>
  1529.       <tr height=1><td bgcolor=#DDDDDD><font size=2>".translate("Number of Ratings").": $anonvotes</font></td>
  1530.         <td rowspan=5 width=200>
  1531.             ";
  1532.             if ($anonvotes==0) echo "<center><font size=-2>".translate("No Unregistered User Votes")."</font></center>";
  1533.                else { 
  1534.                echo "        
  1535.            <table border=1 width=200 height=100%>
  1536.              <tr>
  1537.                <td valign=top align=center colspan=10 bgcolor=BBBBBB><font size=-2>".translate("Breakdown of Ratings by Value")."</font></td>
  1538.              </tr>
  1539.              <tr>
  1540.            <td bgcolor=FFFFFF valign=bottom><img border=0 alt=\"$avv[1] ".translate("votes")." ($avvpercent[1]% ".translate("total votes").")\" src=images/blackpixel.gif width=15 height=$avvchartheight[1]></td>
  1541.            <td bgcolor=FFFFFF valign=bottom><img border=0 alt=\"$avv[2] ".translate("votes")." ($avvpercent[2]% ".translate("total votes").")\" src=images/blackpixel.gif width=15 height=$avvchartheight[2]></td>
  1542.            <td bgcolor=FFFFFF valign=bottom><img border=0 alt=\"$avv[3] ".translate("votes")." ($avvpercent[3]% ".translate("total votes").")\" src=images/blackpixel.gif width=15 height=$avvchartheight[3]></td>
  1543.            <td bgcolor=FFFFFF valign=bottom><img border=0 alt=\"$avv[4] ".translate("votes")." ($avvpercent[4]% ".translate("total votes").")\" src=images/blackpixel.gif width=15 height=$avvchartheight[4]></td>
  1544.            <td bgcolor=FFFFFF valign=bottom><img border=0 alt=\"$avv[5] ".translate("votes")." ($avvpercent[5]% ".translate("total votes").")\" src=images/blackpixel.gif width=15 height=$avvchartheight[5]></td>
  1545.            <td bgcolor=FFFFFF valign=bottom><img border=0 alt=\"$avv[6] ".translate("votes")." ($avvpercent[6]% ".translate("total votes").")\" src=images/blackpixel.gif width=15 height=$avvchartheight[6]></td>
  1546.            <td bgcolor=FFFFFF valign=bottom><img border=0 alt=\"$avv[7] ".translate("votes")." ($avvpercent[7]% ".translate("total votes").")\" src=images/blackpixel.gif width=15 height=$avvchartheight[7]></td>
  1547.            <td bgcolor=FFFFFF valign=bottom><img border=0 alt=\"$avv[8] ".translate("votes")." ($avvpercent[8]% ".translate("total votes").")\" src=images/blackpixel.gif width=15 height=$avvchartheight[8]></td>
  1548.            <td bgcolor=FFFFFF valign=bottom><img border=0 alt=\"$avv[9] ".translate("votes")." ($avvpercent[9]% ".translate("total votes").")\" src=images/blackpixel.gif width=15 height=$avvchartheight[9]></td>
  1549.            <td bgcolor=FFFFFF valign=bottom><img border=0 alt=\"$avv[10] ".translate("votes")." ($avvpercent[10]% ".translate("total votes").")\" src=images/blackpixel.gif width=15 height=$avvchartheight[10]></td>
  1550.              </tr>
  1551.              <tr><td colspan=10>
  1552.                 <table cellspacing=0 cellpadding=0 border=0 height=5 width=200><tr></td>
  1553.             <td bgcolor=FFFFFF width=10% valign=bottom align=center><font size=-2>1</font></td>
  1554.             <td bgcolor=FFFFFF width=10% valign=bottom align=center><font size=-2>2</font></td>
  1555.             <td bgcolor=FFFFFF width=10% valign=bottom align=center><font size=-2>3</font></td>
  1556.             <td bgcolor=FFFFFF width=10% valign=bottom align=center><font size=-2>4</font></td>
  1557.             <td bgcolor=FFFFFF width=10% valign=bottom align=center><font size=-2>5</font></td>
  1558.             <td bgcolor=FFFFFF width=10% valign=bottom align=center><font size=-2>6</font></td>
  1559.             <td bgcolor=FFFFFF width=10% valign=bottom align=center><font size=-2>7</font></td>
  1560.             <td bgcolor=FFFFFF width=10% valign=bottom align=center><font size=-2>8</font></td>
  1561.             <td bgcolor=FFFFFF width=10% valign=bottom align=center><font size=-2>9</font></td>
  1562.             <td bgcolor=FFFFFF width=10% valign=bottom align=center><font size=-2>10</font></td>
  1563.                 </td><tr></table>
  1564.              </td></tr>
  1565.            </table>
  1566.            ";
  1567.             }
  1568.            echo "
  1569.         </td>
  1570.       </tr>
  1571.       <tr><td bgcolor=#CCCCCC><font size=2>".translate("Link Rating").": $avgAU</font></td></tr>
  1572.       <tr><td bgcolor=#DDDDDD><font size=2>".translate("High Rating").": $topanon</font></td></tr>
  1573.       <tr><td bgcolor=#CCCCCC><font size=2>".translate("Low Rating").": $bottomanon</font></td></tr>
  1574.       <tr><td bgcolor=#DDDDDD><font size=2> </font></td></tr>";   
  1575.             
  1576.       if ($useoutsidevoting == 1) {
  1577.           echo "
  1578.           <tr><td valign=top colspan=2><font size=\"1\"><br><br>* ".translate("Note: This website weighs Registered vs. Outside voter's ratings")." $outsideweight ".translate("to")." 1.</font></td></tr>
  1579.                 <tr><td colspan=2 bgcolor=#BBBBBB><font size=2><B>".translate("Outside Voters")."</b></font></td></tr>
  1580.             <tr height=1><td bgcolor=#DDDDDD><font size=2>".translate("Number of Ratings").": $outsidevotes</font></td>
  1581.               <td rowspan=5 width=200>
  1582.                   ";
  1583.                   if ($outsidevotes==0) echo "<center><font size=-2>".translate("No Outside Votes")."</font></center>";
  1584.                      else { 
  1585.                      echo "        
  1586.                  <table border=1 width=200 height=100%>
  1587.                    <tr>
  1588.                      <td valign=top align=center colspan=10 bgcolor=BBBBBB><font size=-2>".translate("Breakdown of Ratings by Value")."</font></td>
  1589.                    </tr>
  1590.                    <tr>
  1591.                  <td bgcolor=FFFFFF valign=bottom><img border=0 alt=\"$ovv[1] ".translate("votes")." ($ovvpercent[1]% ".translate("total votes").")\" src=images/blackpixel.gif width=15 height=$ovvchartheight[1]></td>
  1592.                  <td bgcolor=FFFFFF valign=bottom><img border=0 alt=\"$ovv[2] ".translate("votes")." ($ovvpercent[2]% ".translate("total votes").")\" src=images/blackpixel.gif width=15 height=$ovvchartheight[2]></td>
  1593.                  <td bgcolor=FFFFFF valign=bottom><img border=0 alt=\"$ovv[3] ".translate("votes")." ($ovvpercent[3]% ".translate("total votes").")\" src=images/blackpixel.gif width=15 height=$ovvchartheight[3]></td>
  1594.                  <td bgcolor=FFFFFF valign=bottom><img border=0 alt=\"$ovv[4] ".translate("votes")." ($ovvpercent[4]% ".translate("total votes").")\" src=images/blackpixel.gif width=15 height=$ovvchartheight[4]></td>
  1595.                  <td bgcolor=FFFFFF valign=bottom><img border=0 alt=\"$ovv[5] ".translate("votes")." ($ovvpercent[5]% ".translate("total votes").")\" src=images/blackpixel.gif width=15 height=$ovvchartheight[5]></td>
  1596.                  <td bgcolor=FFFFFF valign=bottom><img border=0 alt=\"$ovv[6] ".translate("votes")." ($ovvpercent[6]% ".translate("total votes").")\" src=images/blackpixel.gif width=15 height=$ovvchartheight[6]></td>
  1597.                  <td bgcolor=FFFFFF valign=bottom><img border=0 alt=\"$ovv[7] ".translate("votes")." ($ovvpercent[7]% ".translate("total votes").")\" src=images/blackpixel.gif width=15 height=$ovvchartheight[7]></td>
  1598.                  <td bgcolor=FFFFFF valign=bottom><img border=0 alt=\"$ovv[8] ".translate("votes")." ($ovvpercent[8]% ".translate("total votes").")\" src=images/blackpixel.gif width=15 height=$ovvchartheight[8]></td>
  1599.                  <td bgcolor=FFFFFF valign=bottom><img border=0 alt=\"$ovv[9] ".translate("votes")." ($ovvpercent[9]% ".translate("total votes").")\" src=images/blackpixel.gif width=15 height=$ovvchartheight[9]></td>
  1600.                  <td bgcolor=FFFFFF valign=bottom><img border=0 alt=\"$ovv[10] ".translate("votes")." ($ovvpercent[10]% ".translate("total votes").")\" src=images/blackpixel.gif width=15 height=$ovvchartheight[10]></td>
  1601.                    </tr>
  1602.                    <tr><td colspan=10>
  1603.                       <table cellspacing=0 cellpadding=0 border=0 height=5 width=200><tr></td>
  1604.                   <td bgcolor=FFFFFF width=10% valign=bottom align=center><font size=-2>1</font></td>
  1605.                   <td bgcolor=FFFFFF width=10% valign=bottom align=center><font size=-2>2</font></td>
  1606.                   <td bgcolor=FFFFFF width=10% valign=bottom align=center><font size=-2>3</font></td>
  1607.                   <td bgcolor=FFFFFF width=10% valign=bottom align=center><font size=-2>4</font></td>
  1608.                   <td bgcolor=FFFFFF width=10% valign=bottom align=center><font size=-2>5</font></td>
  1609.                   <td bgcolor=FFFFFF width=10% valign=bottom align=center><font size=-2>6</font></td>
  1610.                   <td bgcolor=FFFFFF width=10% valign=bottom align=center><font size=-2>7</font></td>
  1611.                   <td bgcolor=FFFFFF width=10% valign=bottom align=center><font size=-2>8</font></td>
  1612.                   <td bgcolor=FFFFFF width=10% valign=bottom align=center><font size=-2>9</font></td>
  1613.                   <td bgcolor=FFFFFF width=10% valign=bottom align=center><font size=-2>10</font></td>
  1614.                       </td><tr></table>
  1615.                    </td></tr>
  1616.                  </table>
  1617.                  ";
  1618.                   }
  1619.                  echo "
  1620.               </td>
  1621.             </tr>
  1622.             <tr><td bgcolor=#CCCCCC><font size=2>".translate("Link Rating").": $avgOU</font></td></tr>
  1623.             <tr><td bgcolor=#DDDDDD><font size=2>".translate("High Rating").": $topoutside</font></td></tr>
  1624.             <tr><td bgcolor=#CCCCCC><font size=2>".translate("Low Rating").": $bottomoutside</font></td></tr>
  1625.             <tr><td bgcolor=#DDDDDD><font size=2> </font></td></tr>";      
  1626.       }
  1627.       
  1628.     echo "</table></table><br><br>";
  1629.     linkfooter($lid,$ttitle);
  1630.     CloseTable();
  1631.     include("footer.php");
  1632.  
  1633. }
  1634.  
  1635. function linkfooter($lid,$ttitle) {
  1636.     $ttitle = ereg_replace(" ", "_", $ttitle);
  1637.     echo "
  1638.     <a href=links.php?op=visit&lid=$lid target=_blank>".translate("Visit this Website")."</a>  |  <a href=links.php?op=ratelink&lid=$lid&ttitle=$ttitle>".translate("Rate this Website")."</a><br><br>";
  1639.     linkfooterchild($lid);
  1640. }
  1641.  
  1642. function linkfooterchild($lid) {
  1643.     if ($useoutsidevoting = 1) { echo "<br><center><hr size=1 noshade><font size=-1>".translate("Is this your resource?")." <a href=links.php?op=outsidelinksetup&lid=$lid>".translate("Allow users to rate your script from your web site!")."</center></a></font>"; }
  1644.     
  1645. }
  1646.  
  1647. function outsidelinksetup($lid) {
  1648.     include("header.php");
  1649.     OpenTable();
  1650.     mainheader();
  1651.     echo "<center><font size=3><br><b>".translate("Promote Your Website")."</b></font></center><br><br>";
  1652.     echo "
  1653.     <table width=90%>
  1654.     
  1655.     If the resource you were rating at the time you clicked on the 'remote rate'
  1656.     link was your own, you may be interested in several of the remote 'Rate a 
  1657.     Website' options we have available. These allow you to place an image (or 
  1658.     even a rating form) on your script's web site in order to increase the number
  1659.     of votes your website receive. Please choose from one of the options listed
  1660.     below if this is something you are interested in:<br><br>
  1661.     
  1662.     <b>Please, no cheating...</b><br>
  1663.     
  1664.     We have had several cases where a website has been removed from the directory due 
  1665.     to cheating involved with our rating system. We usually find these, even when they are 
  1666.     very obscure, either from user reportings or routine checks by staff. By being
  1667.     removed from the directory, you'll lose more accesses than you ever would by falsely
  1668.     bolstering your rating value.<br><br>
  1669.     
  1670.     <b>1. Text Links</b><br><br>
  1671.     
  1672.     One way to link to the rating form is through a simple text link, such as:<br><br>
  1673.     
  1674.     
  1675.     <center><a href=$nuke_url/links.php?op=ratelink&lid=$lid>Rate this Website @ $sitename</a></center><br><br>
  1676.     <center>The HTML code you should use in this case, is the following:</center><br>
  1677.     <center><textarea rows=4 name=S1 cols=50><a href=\"$nuke_url/links.php?op=ratelink&lid=$lid\">Rate this Website @ $sitename</a></textarea></center>
  1678.     <br><br>
  1679.     The number '$lid' in the HTML source references the resource id number in $sitename link directory database. You should make sure you link to the correct website.<br><br>
  1680.     
  1681.     <b>2. Small Image Links</b><br><br>
  1682.     
  1683.     If you're looking for a little more than a basic text link, you may wish for one of our smaller image links to the rating form:<br><br>
  1684.     
  1685.     <center><a href=$nuke_url/links.php?op=ratelink&lid=$lid><img src=$nuke_url/images/rate.gif></a></center><br>
  1686.     <center>Right click on image and 'Save Image'.  <b>Do NOT link this image from our site!</b>  Copy the image to your website and change the links as appropriate</center><br><br>
  1687.     <center><textarea rows=4 name=S1 cols=50><a href=\"$nuke_url/links.php?op=ratelink&lid=$lid\"><img src=\"$nuke_url/images/rate.gif\"></a></textarea></center>
  1688.     <br><br>
  1689.     
  1690.     <b>3. Remote Rating Forms</b><br><br>
  1691.      
  1692.     Our policies on the use of a remote rating form on your web site are very strict. If we find a web site in violation of the acceptable terms, we have the right to block all incoming votes from the offending web site or remove your listing from $sitename entirely. The only voting mechanisms required on a remote site are the form types shown below, unless you get permission to use a different rating form scheme. Basically, we want the default vote set to '--' and the user must be able to freely choose from 1 - 10. Any site that we find that is attempting to submit all 10's or something similar when a user simply hits submit will be in violation of the remote rating rules.<br><br>
  1693.     
  1694.     Having said that, here is what the current remote rating form looks like. If we get significant user feedback, we will create others. If you wish to have something custom made on your site, feel free, but make sure you get it approved by us and that it follows the basic guidelines set forth above.<br><br>
  1695.     
  1696.   <table align=center border=0 width=175 cellspacing=0 cellpadding=0 bordercolor=#FFFFFF bgcolor=#FFFFFF>
  1697.     <tr>
  1698.       <td width=100%><a href=$nuke_url><img border=0 src=$nuke_url/images/ratesitetop.gif width=175 height=34></a></td>
  1699.     </tr>
  1700.     <tr>
  1701.       <td width=100%>
  1702.         <table border=0 width=100% cellspacing=0 cellpadding=0 height=23>
  1703.           <tr>
  1704.             <td width=100% height=23>
  1705.               <form method=POST action=$nuke_url/links.php>
  1706.                 <input type=hidden name=ratinglid value=\"$lid\">
  1707.                 <input type=hidden name=ratinguser value=\"outside\">
  1708.                 <table border=0 width=100% background=$nuke_url/images/ratesitebottom.gif cellspacing=0 cellpadding=0>
  1709.                   <tr>
  1710.                     <td width=53% valign=top>
  1711.                       <p align=right> 
  1712.                      <select name=rating>         
  1713.                      <option selected>--
  1714.                        <option>10
  1715.                       <option>9
  1716.                        <option>8
  1717.                         <option>7
  1718.                         <option>6
  1719.                         <option>5
  1720.                         <option>4    
  1721.                         <option>3
  1722.                         <option>2
  1723.                         <option>1
  1724.                       </select>   </td>
  1725.  
  1726.                     <td width=47% valign=top>
  1727.                       <p align=right><input type=image src=$nuke_url/images/ratebutton.gif name=op value=addrating width=63 height=17 alt=\"Rate Link at $sitename\"></td>
  1728.                   </tr>
  1729.                 </table>
  1730.               </form>
  1731.             </td>
  1732.           </tr>
  1733.         </table>
  1734.         </td></tr></table></center>
  1735.    <table width=90% align=center>
  1736.    <br><br>
  1737.    Using this form will allow users to rate your website directly from your site and the rating will be recorded. The above form is disabled, but the following source code will work if you simply cut and paste it into your web page, copy the images (top, bottom, and button), and change image paths to your site. The source code is shown below:<br><br>
  1738.     <center><textarea rows=30 name=S1 cols=50>  <table align=center border=0 width=175 cellspacing=0 cellpadding=0 bordercolor=#FFFFFF bgcolor=#FFFFFF>
  1739.     <tr>
  1740.       <td width=\"100%\"><a href=\"$nuke_url\"><img border=\"0\" src=\"$nuke_url/images/ratesitetop.gif\" width=\"175\" height=\"34\"></a></td>
  1741.     </tr>
  1742.     <tr>
  1743.       <td width=\"100%\">
  1744.         <table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" height=\"23\">
  1745.           <tr>
  1746.             <td width=\"100%\" height=\"23\">
  1747.               <form method=POST action=\"$nuke_url/links.php\">
  1748.                 <input type=hidden name=ratinglid value=\"$lid\">
  1749.                 <input type=hidden name=ratinguser value=\"outside\">
  1750.                 <table border=\"0\" width=\"100%\" background=\"$nuke_url/images/ratesitebottom.gif\" cellspacing=\"0\" cellpadding=\"0\">
  1751.                   <tr>
  1752.                     <td width=\"53%\" valign=top>
  1753.                       <p align=right> 
  1754.                      <select name=rating>         
  1755.                      <option selected>--
  1756.              <option>10
  1757.                  <option>9
  1758.                      <option>8
  1759.                     <option>7
  1760.              <option>6
  1761.              <option>5
  1762.              <option>4    
  1763.              <option>3
  1764.              <option>2
  1765.              <option>1
  1766.              </select>   </td>
  1767.  
  1768.                     <td width=\"47%\" valign=\"top\">
  1769.                       <p align=right><input type=image src=\"$nuke_url/images/ratebutton.gif\" name=op value=addrating width=\"63\" height=\"17\" alt=\"Rate Link at $sitename\"></td>
  1770.                   </tr>
  1771.                 </table>
  1772.               </form>
  1773.             </td>
  1774.           </tr>
  1775.         </table>
  1776.         </td></tr></table></textarea>
  1777.     </center><br><br>
  1778.     Thanks!  Let us know if you have any questions or concerns.<br><br>
  1779.     - $sitename Staff
  1780.     <br><br>
  1781.     </table>";
  1782.     CloseTable();
  1783.     include("footer.php");
  1784. }
  1785.  
  1786. function brokenlink($lid) {
  1787.     include("header.php");
  1788.     OpenTable();
  1789.     global $user;
  1790.     if(isset($user)) {
  1791.             $user2 = base64_decode($user);
  1792.            $cookie = explode(":", $user2);
  1793.         cookiedecode($user);
  1794.         $ratinguser = $cookie[1];
  1795.     } 
  1796.     else { $ratinguser = "$anonymous";} 
  1797.     mainheader();
  1798.     
  1799.     echo "<center><font size=3><b><center>".translate("Report Broken Link")."</center></b><br><br><br><font size=2>";    
  1800.     echo "<form action=links.php method=post>";
  1801.     echo "<input type=hidden name=lid value=$lid>";
  1802.     echo "<input type=hidden name=modifysubmitter value=$ratinguser>";
  1803.     echo "<center>
  1804.       ".translate("Thank you for helping to maintain this directory's integrity.")."
  1805.           <br>
  1806.       ".translate("For security reasons your user name and IP address will also be temporarily recorded.")."
  1807.       </center><br><br>"; 
  1808.     
  1809.     echo "</select><center><input type=hidden name=op value=brokenlinkS><input type=submit value=\"".translate("Report Broken Link")."\"></center></form><br>";
  1810.     CloseTable();
  1811.     include("footer.php");    
  1812. }
  1813.  
  1814. function brokenlinkS($lid, $modifysubmitter) {
  1815.     global $user;
  1816.     if(isset($user)) {
  1817.             $user2 = base64_decode($user);
  1818.            $cookie = explode(":", $user2);
  1819.         cookiedecode($user);
  1820.         $ratinguser = $cookie[1];
  1821.     } 
  1822.     else { $ratinguser = "$anonymous";} 
  1823.  
  1824.     mysql_query("insert into links_modrequest values (NULL, $lid, 0, 0, '', '', '', '$ratinguser', 1)");
  1825.     include("header.php");
  1826.     echo "<br><br><center>".translate("Thanks for the information. We'll look into your request shortly.")."</center>";
  1827.     include("footer.php");
  1828.         
  1829. }
  1830.  
  1831. function modifylinkrequest($lid) {
  1832.     include("header.php");
  1833.     OpenTable();
  1834.     global $user;
  1835.     if(isset($user)) {
  1836.             $user2 = base64_decode($user);
  1837.            $cookie = explode(":", $user2);
  1838.         cookiedecode($user);
  1839.         $ratinguser = $cookie[1];
  1840.     } 
  1841.     else { $ratinguser = "$anonymous";}   
  1842.     mainheader();
  1843.     echo "<table width=450 align=center>";
  1844.     $blocknow = 0;
  1845.     if ($blockunregmodify == 1 && $ratinguser=="$anonymous") { 
  1846.     echo "<br><br><center>".translate("Only registered users can suggest link modifications. Please register or login.")."</center>";
  1847.     $blocknow = 1;
  1848.     }
  1849.     
  1850.     if ($blocknow != 1) {
  1851.         $result = mysql_query("select cid, sid, title, url, description from links_links where lid=$lid");
  1852.         echo "
  1853.         </center><font size=3><b>Request Link Modification</b><br><br><font size=2>";
  1854.         while(list($cid, $sid, $title, $url, $description) = mysql_fetch_row($result)) {
  1855.             $title = stripslashes($title); $description = stripslashes($description);
  1856.             echo "<form action=links.php method=post>";
  1857.         echo "<font color=Blue>".translate("Link ID: ")."<font color=Black><b>$lid</b><br>";
  1858.         echo "".translate("Page Title: ")."<input class=textbox type=text name=title value=\"$title\" size=50 maxlength=100><br>";
  1859.         echo "".translate("Page URL: ")."<input class=textbox type=text name=url value=$url size=50 maxlength=100> <br>";
  1860.         echo "".translate("Description: ")."<br><textarea name=description cols=60 rows=10>$description</textarea><br>";
  1861.         $result2=mysql_query("select cid, title from links_categories order by title");
  1862.         echo "<input type=hidden name=lid value=$lid>";
  1863.         echo "<input type=hidden name=modifysubmitter value=$ratinguser>";    
  1864.         echo "".translate("Category: ")."<select name=cat>";
  1865.         while(list($ccid, $ctitle) = mysql_fetch_row($result2)) {
  1866.             $sel = "";
  1867.             if ($cid==$ccid AND $sid==0) {
  1868.             $sel = "selected";
  1869.             }
  1870.             echo "<option value=$ccid $sel>$ctitle</option>";
  1871.             $result3=mysql_query("select sid, title from links_subcategories where cid=$ccid order by title");
  1872.             while(list($ssid, $stitle) = mysql_fetch_row($result3)) {
  1873.                     $sel = "";
  1874.             if ($sid==$ssid) {
  1875.                 $sel = "selected";
  1876.             }
  1877.             echo "<option value=$ccid-$ssid $sel>$ctitle / $stitle</option>";
  1878.             }
  1879.         }
  1880.         
  1881.         echo "</select><input type=hidden name=op value=modifylinkrequestS><input type=submit value=\"".translate("Send Request")."\"></form><br>";
  1882.         }
  1883.     
  1884.     }
  1885.     echo "</table>";
  1886.     CloseTable();
  1887.     include("footer.php");
  1888. }
  1889.  
  1890. function modifylinkrequestS($lid, $cat, $title, $url, $description, $modifysubmitter) {
  1891.     global $user;
  1892.     if(isset($user)) {
  1893.             $user2 = base64_decode($user);
  1894.            $cookie = explode(":", $user2);
  1895.         cookiedecode($user);
  1896.         $ratinguser = $cookie[1];
  1897.     } 
  1898.     else { $ratinguser = "$anonymous";}       
  1899.     $blocknow = 0;
  1900.     if ($blockunregmodify == 1 && $ratinguser=="$anonymous") { 
  1901.     include("header.php");
  1902.     echo "<br><br><center>".translate("Only registered users can suggest link modifications. Please register or login.")."</center>";
  1903.     $blocknow = 1;
  1904.     include("footer.php");
  1905.     }
  1906.     
  1907.     if ($blocknow != 1) {
  1908.         $cat = explode("-", $cat);
  1909.         if ($cat[1]=="") {
  1910.             $cat[1] = 0;
  1911.         }
  1912.         $title = stripslashes(FixQuotes($title));
  1913.         $url = stripslashes(FixQuotes($url));
  1914.         $description = stripslashes(FixQuotes($description));
  1915.         mysql_query("insert into links_modrequest values (NULL, $lid, $cat[0], $cat[1], '$title', '$url', '$description', '$ratinguser', 0)");
  1916.         include("header.php");
  1917.         echo "<br><br><center>".translate("Thanks for the information. We'll look into your request shortly.")."</center>";
  1918.         include("footer.php");
  1919.     }
  1920. }
  1921.  
  1922. function rateinfo($lid) {                            
  1923.     mysql_query("update links_links set hits=hits+1 where lid=$lid");        
  1924.     $result = mysql_query("select url from links_links where lid=$lid");    
  1925.     list($url) = mysql_fetch_row($result);                    
  1926.     Header("Location: $url");                            
  1927. }
  1928.  
  1929.  
  1930. function addrating($ratinglid, $ratinguser, $rating, $ratinghost_name, $ratingcomments) {
  1931.     global $user,$cookie, $anonymous;
  1932.     $passtest = "yes";
  1933.     include("header.php");
  1934.     OpenTable();
  1935.     
  1936.     completevoteheader();
  1937.     
  1938.     # !!if ($ratinguser != "outside") then...  determine anon or reg and write reg.  DON'T pass it in.  Bad idea.
  1939.     if(isset($user)) {
  1940.             $user2 = base64_decode($user);
  1941.            $cookie = explode(":", $user2);
  1942.         cookiedecode($user);
  1943.         $ratinguser = $cookie[1];
  1944.     } 
  1945.     else if ($ratinguser=="outside") { $ratinguser = "outside";}   
  1946.     else { $ratinguser = "$anonymous";}   
  1947.     
  1948.     $results3 = mysql_query("SELECT title FROM links_links WHERE lid=$ratinglid");       
  1949.     while(list($title)=mysql_fetch_row($results3)) $ttitle = $title;
  1950.     
  1951.     //Make sure only 1 anonymous from an IP in a single day.
  1952.     $anonwaitdays = 1;
  1953.     $ip = getenv("REMOTE_ADDR");
  1954. //    if (empty($ip)) {
  1955. //       $ip = getenv("REMOTE_ADDR");
  1956. //    }
  1957.  
  1958.     // Check if Rating is Null
  1959.         if ($rating=="--") {
  1960.             $error = "nullerror";
  1961.             completevote($error);
  1962.         $passtest = "no";
  1963.         }
  1964.  
  1965.     // Check if Link POSTER is voting (UNLESS Anonymous users allowed to post)       
  1966.     if ($ratinguser != $anonymous && $ratinguser != "outside") {
  1967.         $result=mysql_query("select submitter from links_links where lid=$ratinglid");
  1968.         while(list($ratinguserDB)=mysql_fetch_row($result)) {
  1969.             if ($ratinguserDB==$ratinguser) {
  1970.                 $error = "postervote";
  1971.                 completevote($error);
  1972.             $passtest = "no";
  1973.             }
  1974.        }
  1975.     }
  1976.  
  1977.     // Check if REG user is trying to vote twice.      
  1978.     if ($ratinguser!=$anonymous && $ratinguser != "outside") {
  1979.         $result=mysql_query("select ratinguser from links_votedata where ratinglid=$ratinglid");
  1980.         while(list($ratinguserDB)=mysql_fetch_row($result)) {
  1981.             if ($ratinguserDB==$ratinguser) {
  1982.                     $error = "regflood";
  1983.                     completevote($error);
  1984.             $passtest = "no";
  1985.         }
  1986.     
  1987.         }
  1988.     }
  1989.     
  1990.      // Check if ANONYMOUS user is trying to vote more than once per day.
  1991.     if ($ratinguser==$anonymous){
  1992.         $yesterdaytimestamp = (time()-(86400 * $anonwaitdays));
  1993.         $ytsDB = Date("Y-m-d H:i:s", $yesterdaytimestamp);
  1994.         $result=mysql_query("select * FROM links_votedata WHERE ratinglid=$ratinglid AND ratinguser='$anonymous' AND ratinghostname = '$ip' AND TO_DAYS(NOW()) - TO_DAYS(ratingtimestamp) < $anonwaitdays");
  1995.         $anonvotecount = mysql_num_rows($result); 
  1996.         if ($anonvotecount >= 1) {
  1997.                 $error = "anonflood";
  1998.                 completevote($error);
  1999.             $passtest = "no";
  2000.         }             
  2001.     }    
  2002.     
  2003.      // Check if OUTSIDE user is trying to vote more than once per day.
  2004.     if ($ratinguser=="outside"){
  2005.         $yesterdaytimestamp = (time()-(86400 * $outsidewaitdays));
  2006.         $ytsDB = Date("Y-m-d H:i:s", $yesterdaytimestamp);
  2007.         $result=mysql_query("select * FROM links_votedata WHERE ratinglid=$ratinglid AND ratinguser='outside' AND ratinghostname = '$ip' AND TO_DAYS(NOW()) - TO_DAYS(ratingtimestamp) < $outsidewaitdays");
  2008.         $outsidevotecount = mysql_num_rows($result); 
  2009.         if ($outsidevotecount >= 1) {
  2010.                 $error = "outsideflood";
  2011.                 completevote($error);
  2012.             $passtest = "no";
  2013.         }             
  2014.     }        
  2015.      
  2016.      
  2017.     // Passed Tests
  2018.     if ($passtest == "yes") {
  2019.         $comment = stripslashes(FixQuotes($comment));
  2020.         
  2021.         //All is well.  Add to Line Item Rate to DB.
  2022.      mysql_query("INSERT into links_votedata values (NULL, '$ratinglid', '$ratinguser', '$rating', '$ip', '$ratingcomments', now())");
  2023.     
  2024.     //All is well.  Calculate Score & Add to Summary (for quick retrieval & sorting) to DB.
  2025.     //NOTE:  If weight is modified, ALL links need to be refreshed with new weight.
  2026.     //     Running a SQL statement with your modded calc for ALL links will accomplish this.
  2027.  
  2028.         $voteresult = mysql_query("select rating, ratinguser, ratingcomments FROM links_votedata WHERE ratinglid = $ratinglid");
  2029.     $totalvotesDB = mysql_num_rows($voteresult);    
  2030.     include ("voteinclude.php");     
  2031.         mysql_query("UPDATE links_links SET linkratingsummary=$finalrating,totalvotes=$totalvotesDB,totalcomments=$truecomments WHERE lid = $ratinglid");
  2032.         $error = "none";
  2033.         completevote($error);
  2034.     }
  2035.     completevotefooter($ratinglid, $ttitle, $ratinguser);
  2036.     CloseTable();
  2037.     include("footer.php");
  2038. }
  2039.  
  2040.  
  2041.  
  2042.  
  2043. function completevoteheader(){
  2044.     mainheader();
  2045.     echo "<br>
  2046.     <table border=0 width=450>
  2047.       <tr>
  2048.         <td>";
  2049. }
  2050.  
  2051. function completevotefooter($lid, $ttitle, $ratinguser) {
  2052.     $result=mysql_query("select url FROM links_links WHERE lid=$lid");
  2053.     list($url)=mysql_fetch_row($result);
  2054.     echo "
  2055.         </td>
  2056.       </tr>
  2057.       <tr>
  2058.         <td>
  2059.           <font size=2>".translate("Thank you for taking the time to rate a site here at $sitename. Input from users such as yourself will help other visitors better decide which links to click on.")."</font><br><br><br>
  2060.         </td>         
  2061.       </tr>";
  2062.      if ($ratinguser=="outside") {
  2063.      echo "
  2064.       <tr>
  2065.         <td>
  2066.           <font size=2><center>".translate("We appreciate your visit to $sitename!")."</center><br><center><a href=$url>".translate("Return to")." $ttitle</a></font><center><br><br>
  2067.         </td>         
  2068.       </tr>";
  2069.      $result=mysql_query("select title FROM links_links where lid=$lid");
  2070.      list($title)=mysql_fetch_row($result);
  2071.      $ttitle = ereg_replace (" ", "_", $title);
  2072.      }
  2073.     
  2074.      
  2075.      echo "
  2076.      </table>
  2077.      <br><br>";
  2078.      linkinfomenu($lid,$ttitle);  
  2079. }
  2080.  
  2081. function completevote($error) {
  2082.     $anonwaitdays = 1;
  2083.           if ($error == "none") echo "<center><b><font size=2>".translate("Your vote is appreciated.")."</font></b></center>";
  2084.           if ($error == "anonflood") echo "<font size=3 color=Red><b><center>".translate("You have already voted for this link in the past $anonwaitdays day(s).")."</center></b><br>";
  2085.           if ($error == "regflood") echo "<font size=3 color=Red><b><center>".translate("Vote for a link only once.<br>All votes are logged and reviewed.")."</center></b><br>";
  2086.           if ($error == "postervote") echo "<font size=3 color=Red><b><center>".translate("You cannot vote on a link you submitted.<br>All votes are logged and reviewed.")."</center></b><br>";
  2087.           if ($error == "nullerror") echo "<font size=3 color=Red><b><center>".translate("No rating selected - no vote tallied")."</center></b><br>";
  2088.           if ($error == "outsideflood") echo "<font size=3 color=Red><b><center>".translate("Only one vote per IP address allowed every")." $outsidewaitdays ".translate("day(s).")."</center></b><br>";
  2089. }
  2090.  
  2091. function ratelink($lid, $user, $ttitle) {    
  2092.     
  2093.     include("header.php");
  2094.     OpenTable();
  2095.     mainheader();
  2096.     echo "</center>";
  2097.     $transfertitle = ereg_replace ("_", " ", $ttitle);
  2098.     $displaytitle = $transfertitle;
  2099.     // global $user, $cookie, $title, $datetime;
  2100.     global $cookie, $title, $datetime, $anonymous;
  2101.     $ip = getenv("REMOTE_HOST");
  2102.     if (empty($ip)) {
  2103.        $ip = getenv("REMOTE_ADDR");
  2104.     }
  2105.  
  2106.     echo "
  2107.     <hr size=1 noshade>
  2108.     <font face=\"Verdana,Arial,Helvetica\"><b>$displaytitle</b>
  2109.     <UL><FONT SIZE=-1>
  2110.      <LI>".translate("Please do not vote for the same resource more than once.")."
  2111.      <LI>".translate("The scale is 1 - 10, with 1 being poor and 10 being excellent.")."
  2112.      <LI>".translate("Please be objective, if everyone receives a 1 or a 10, the ratings aren't very useful.")."
  2113.      <LI>".translate("You can view a list of the <a href=links.php?op=TopRated>Top Rated Resources</a>.")."
  2114.      <LI>".translate("Do not vote for your own resource.")."";
  2115.     if(isset($user)) {
  2116.             $user2 = base64_decode($user);
  2117.            $cookie = explode(":", $user2);
  2118.         echo "<LI>".translate("You are a registered user and are logged in.")."
  2119.               <LI>".translate("Feel free to add a comment about this site.")."";
  2120.         cookiedecode($user);
  2121.         $name = $cookie[1];
  2122.     } else {
  2123.         echo "<LI>".translate("You are not a registered user or you have not logged in.")."
  2124.               <LI>".translate("If you were registered you could make comments on this website.")."";
  2125.         $name = "$anonymous";
  2126.     }
  2127.  
  2128.     echo "
  2129.      </font></FONT></UL>
  2130.      
  2131.      
  2132.      <table border=0 cellpadding=1 cellspacing=0 width=100%>
  2133.      <tr><td width=25 nowrap></td>  
  2134.      <tr><td width=25 nowrap></td><td width=550>
  2135.      <form method=POST action=\"links.php\">
  2136.      <input type=hidden name=\"ratinglid\" value=\"$lid\">
  2137.      <input type=hidden name=\"ratinguser\" value=\"$name\">
  2138.      <input type=hidden name=\"ratinghost_name\" value=\"$ip\">
  2139.      <font face=\"Verdana,Arial,Helvetica\"><font size=+1>".translate("Rate this Website").": </font>
  2140.      <select name=\"rating\">
  2141.      <option>--
  2142.      <option>10
  2143.      <option>9
  2144.      <option>8
  2145.      <option>7
  2146.      <option>6
  2147.      <option>5
  2148.      <option>4
  2149.      <option>3
  2150.      <option>2
  2151.      <option>1
  2152.      </select> <font size=-1><input type=hidden name=op value\"Rate this Website\"><input type=submit value=\"".translate("Rate this Website")."\"></font></font>
  2153.      <br><br>";
  2154.      
  2155.     if(isset($user)) {
  2156.     echo "     
  2157.              <b>Comments:</b> <br><TEXTAREA wrap=virtual cols=50 rows=10 name=\"ratingcomments\"></TEXTAREA>
  2158.              <br><br><br>
  2159.              </font></td>
  2160.          ";
  2161.     }
  2162.     else {
  2163.         echo"<input type=hidden name=\"ratingcomments\" value=\"\">";
  2164.         
  2165.     }
  2166.     
  2167.  
  2168.     echo "
  2169.      </tr></form></table>";
  2170.     linkfooterchild($lid);
  2171.     CloseTable();
  2172.     include("footer.php");
  2173.  
  2174.  
  2175.  
  2176. }
  2177.  
  2178. if (isset($ratinglid) && isset ($ratinguser) && isset ($rating)) {
  2179.     $ret = addrating($ratinglid, $ratinguser, $rating, $ratinghost_name, $ratingcomments);
  2180. }
  2181.  
  2182.  
  2183. switch($op) {
  2184.  
  2185.     case "menu":
  2186.     menu($mainlink);
  2187.     break;
  2188.  
  2189.     case "AddLink":
  2190.     AddLink();
  2191.     break;
  2192.  
  2193.     case "NewLinks":
  2194.     NewLinks($newlinkshowdays);
  2195.     break;
  2196.     
  2197.     case "NewLinksDate":
  2198.     NewLinksDate($selectdate);
  2199.     break;
  2200.  
  2201.     case "TopRated":
  2202.     TopRated($ratenum, $ratetype);
  2203.     break;
  2204.     
  2205.     case "MostPopular":
  2206.         MostPopular($ratenum, $ratetype);
  2207.     break;
  2208.  
  2209.     case "RandomLink":
  2210.     RandomLink();
  2211.     break;
  2212.  
  2213.     case "viewlink":
  2214.     viewlink($cid, $min, $orderby, $show);
  2215.     break;
  2216.  
  2217.     case "viewslink":
  2218.     viewslink($sid, $min, $orderby, $show);
  2219.     break;
  2220.  
  2221.     case "brokenlink":
  2222.     brokenlink($lid);
  2223.     break;
  2224.     
  2225.     case "modifylinkrequest":    
  2226.     modifylinkrequest($lid);
  2227.     break;
  2228.     
  2229.     case "modifylinkrequestS":    
  2230.     modifylinkrequestS($lid, $cat, $title, $url, $description, $modifysubmitter);
  2231.     break;
  2232.    
  2233.     case "brokenlinkS":
  2234.         brokenlinkS($lid, $modifysubmitter);
  2235.         break;
  2236.     
  2237.     case "visit":
  2238.     visit($lid);
  2239.     break;
  2240.  
  2241.     case "Add":
  2242.     Add($title, $url, $name, $cat, $description, $name, $email);
  2243.     break;
  2244.  
  2245.     case "search":
  2246.     search($query, $min, $orderby, $show);
  2247.     break;
  2248.  
  2249.     case "rateinfo":                                
  2250.     rateinfo($lid, $user, $title);                        
  2251.     break;                                    
  2252.  
  2253.     case "ratelink":                                
  2254.     ratelink($lid, $user, $ttitle);                        
  2255.     break;    
  2256.     
  2257.     case "addrating":
  2258.         addrating($ratinglid, $ratinguser, $rating, $ratinghost_name, $ratingcomments);
  2259.     break;
  2260.  
  2261.     case "viewlinkcomments":                                
  2262.         viewlinkcomments($lid, $ttitle);                        
  2263.     break;
  2264.     
  2265.     case "outsidelinksetup":
  2266.         outsidelinksetup($lid);
  2267.         break;
  2268.     
  2269.     case "viewlinkeditorial":                                
  2270.         viewlinkeditorial($lid, $ttitle);                        
  2271.     break;        
  2272.  
  2273.     case "viewlinkdetails":                                
  2274.         viewlinkdetails($lid, $ttitle);                        
  2275.     break;    
  2276.     
  2277.     default:
  2278.     index();
  2279.     break;
  2280.     
  2281. }
  2282.  
  2283.  
  2284.  
  2285. ?>