Location: PHPKode > scripts > LX - Reciprocal Link Exchange > lx-reciprocal-link-exchange/lx.php
<?php

include 'lxconfig.php';

if($newlink)
{
echo "
<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">
<html>
<head>
<title>Add A Link</title>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">
<meta name=\"description\" content=\"funny pictures, postcards, screensavers, sounds, movies, flash and text files.\">
<meta name=\"keywords\" content=\"funny,stuff,pictures,cartoon,cartoons,comic,flash,forwards,forward,free,humor,humour,movies,screensavers,sounds,pics,postcards,programs,text,april,fools\">
</head>

<body>
<table width=\"100%\" border=\"1\" cellpadding=\"0\" cellspacing=\"0\" bordercolor=\"#000000\">
  <tr> 
    <td><div align=\"center\"> 
        <h1><font color=\"#000000\">Add A Link</font></h1>
        <p>&nbsp;</p>
        <form name=\"form1\" method=\"post\" action=\"lx.php?addlink=1\">
          <p> 
            <input name=\"sitetitle\" type=\"text\" id=\"sitetitle\" value=\"Site Title\" size=\"100\" maxlength=\"25\">
            <br>
            <input name=\"email\" type=\"text\" id=\"email\" value=\"Your Email\" size=\"100\" maxlength=\"40\">
            <br>
            <input name=\"sitelink\" type=\"text\" id=\"sitelink\" value=\"Link\" size=\"100\" maxlength=\"100\">
            <br>
            <input name=\"recip\" type=\"text\" id=\"recip\" value=\"Reciprocal Link Location (where our link is on your site)\" size=\"100\" maxlength=\"100\">
            <br>
            <input name=\"desc\" type=\"text\" id=\"desc\" value=\"Description\" size=\"100\" maxlength=\"100\">
            <br>
          </p>
          <p> 
            <input name=\"submit\" type=\"submit\" id=\"submit\" value=\"Submit\">
            <br>
          </p>
        </form>
        <p>&nbsp;</p>
        <p>&nbsp;</p>
      </div></td>
  </tr>
</table>
</body>
</html>
";
exit;
}

if($addlink)
{

if(!($handle = @fopen ("$recip", "r")))
{
printf("Error: $recip could not be opened, the location probably does not exist<br>\n");
exit;
}

while (!feof ($handle)) {
    $buffer = fgets($handle, 4096);
if (eregi($yoururl, $buffer)) {
printf("Your link was found at $recip\n<br>\n");

printf("<a href=\"$sitelink\">$sitetitle</a> - $desc<BR>");
printf("Reciprocal link location: $recip<BR>");

MYSQL_CONNECT($dbserver,$dbuser,$dbpass) OR DIE("Unable to connect to database, have you run lxsetup.php?");
@mysql_select_db($dbname) or die("Unable to select database");
$query="SELECT * FROM $dbtable WHERE link = '$sitelink'";
$result=mysql_query($query);

// $alreadyin=mysql_result($result,0,"link");
MYSQL_CLOSE();
if ($alreadyin=@mysql_result($result,0,"link"))
{
printf("Your link is in our database already.\n<br>\nIf you cannot see your link in our listings, it is either pending our review, or your site has been banned.");
exit;
}


if ($reviewsubmissions == "no")
{
printf("Link added\n<br>\n");
$linkflag = "1";
}
if ($reviewsubmissions == "yes")
{
printf("The Webmaster will review your link exchange request soon.\n<br>\n");
$linkflag = "0";
}

printf("<BR>");
printf("<a href=\"$linkpageurl\">Link Page</a><br>");
printf("<a href=\"lx.php?newlink=1\">Add more links</a><br>");

MYSQL_CONNECT($dbserver,$dbuser,$dbpass) OR DIE("Unable to connect to database");
@mysql_select_db($dbname) or die("Unable to select database");

mysql_query("INSERT INTO $dbtable VALUES('','$sitetitle','$sitelink', '$recip', '$desc', '$email', '$linkflag')");
MYSQL_CLOSE();

exit;

}
}
fclose ($handle);
printf("Your link ($yoururl) was NOT found at $recip\n<br>\n");

exit;
}

MYSQL_CONNECT($dbserver,$dbuser,$dbpass) OR DIE("Unable to connect to database");
@mysql_select_db($dbname) or die("Unable to select database");

$query="SELECT * FROM $dbtable order by id";
$result=mysql_query($query);
     if(mysql_num_rows($result)) {
       while($row = mysql_fetch_row($result))
       {
printf("<a href=\"$row[2]\">$row[1]</a> - $row[4]<br>");
       }
     } else {
       printf("No links created yet");
     }

echo "<a href=\"http://www.kaitaia.com/funny\">Funny Stuff</a><br>";

exit;
?>
Return current item: LX - Reciprocal Link Exchange