Location: PHPKode > scripts > LX - Reciprocal Link Exchange > lx-reciprocal-link-exchange/lxadmin.php
<?php
include 'lxconfig.php';

if($admin)
{
if ($admin != $password)
{
exit("Incorrect password");
}
}

if(!$admin)
{
exit("You must supply your password");
}

if($batchcheck)
{

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))
       {
//Check commands in here

	   
       }
     } else {
       printf("No links created yet");
     }

exit;

}


if($accsite)
{
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="UPDATE $dbtable SET linkstatus = '1' WHERE id='$accsite'";
$result=mysql_query($query);

MYSQL_CLOSE();

header("Location: lxadmin.php?admin=$admin");
exit;
}

if($unban)
{
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="UPDATE $dbtable SET linkstatus = '0' WHERE id='$unban'";
$result=mysql_query($query);

MYSQL_CLOSE();

header("Location: lxadmin.php?admin=$admin");
exit;
}

if($ban)
{
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="UPDATE $dbtable SET linkstatus = '3' WHERE id='$ban'";
$result=mysql_query($query);

MYSQL_CLOSE();

header("Location: lxadmin.php?admin=$admin");
exit;
}

if($checksite)
{
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 id = '$checksite'";
$result=mysql_query($query);

$checklink=mysql_result($result,0,"reciplink");
$statusoflink=mysql_result($result,0,"linkstatus");

MYSQL_CLOSE();

if(!($handle = fopen ("$checklink", "r")))
{
printf("Error: $checklink could not be opened, the location probably does not exist anymore<br>\n");
printf("<a href=\"$checklink\">Click here to view $checklink</a><br>\n");
printf("<a href=\"lxadmin.php??admin=$admin&delsite=$checksite\">Delete this link</a><br>\n");
exit;
}

while (!feof ($handle)) {
    $buffer = fgets($handle, 4096);
if (eregi($yoururl, $buffer)) {
printf("Your link was found at $checklink\n<br>\n");
if ($statusoflink == '2')
{
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="UPDATE $dbtable SET linkstatus = '1' WHERE id='$checksite'";
$result=mysql_query($query);

MYSQL_CLOSE();
printf("Reciprocal link found, moving link back to accepted link exchange section<br>");

}
printf("<a href=\"lxadmin.php?admin=$admin\">Continue</a><br>");
exit;
}
}
fclose ($handle);
printf("Your link was NOT found at $checklink\n<br>\n");

if ($statusoflink == '1')
{
printf("Link moved to missing reciprocal link section\n<br>\n<br>\n");

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="UPDATE $dbtable SET linkstatus = '2' WHERE id='$checksite'";
$result=mysql_query($query);

MYSQL_CLOSE();
}

printf("<a href=\"lxadmin.php?admin=$admin\">Return to admin menu</a><br>\n");
printf("<a href=\"lxadmin.php?admin=$admin&delsite=$checksite\">Delete this link</a><br>\n");
exit;
}

if($delsite)
{
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");

if ($emailwebmasters == yes)
{
$query="SELECT * FROM $dbtable WHERE id = '$delsite'";
$result=mysql_query($query);

$webmasteremail=mysql_result($result,0,"email");
mail("$webmasteremail", "Your Link Has Been Deleted", "Your link on $yoururl has been deleted.\nThis could be for a number of reasons, the most likely is that you have removed our link from your site, if you would like to exchange links again, please visit $yoururl and sign back up again.", "From: $youremail\n");
}

$query="DELETE FROM $dbtable WHERE id = '$delsite'";
$result=mysql_query($query);

MYSQL_CLOSE();

header("Location: lxadmin.php?admin=$admin");

exit;
}

echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">
<html>
<head>
<title>LX Admin Page</title>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">
</head>

<body>
<strong>LX Admin Page</strong>
<br>
<br>
<p><strong><a href=\"lx.php?newlink=1\">Add Link</a></strong></p>\n
<br>
";


Printf("<p><strong>Accepted Link Exchanges</strong></p>\n");

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 WHERE linkstatus = 1 order by id";
$result=mysql_query($query);
     if(mysql_num_rows($result)) {
       // we have at least one user, so show all users as options in select form
       while($row = mysql_fetch_row($result))
       {
printf("<a href=\"$row[2]\">$row[1]</a> - $row[4]\n<br>\n");
printf("<a href=\"lxadmin.php?admin=$admin&checksite=$row[0]\"><font size=\"-2\">Check For Reciprocal Link</font></a> | <a href=\"lxadmin.php?admin=$admin&delsite=$row[0]\"><font size=\"-2\">Delete</font></a> | <a href=\"mailto:$row[5]\"><font size=\"-2\">Email Webmaster</font></a>\n<br>\n<br>\n");
       }
     } else {
       printf("No links yet\n<br>\n");
     }

Printf("<p><strong>Requested Link Exchanges</strong></p>\n");

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 WHERE linkstatus = 0 order by id";
$result=mysql_query($query);
     if(mysql_num_rows($result)) {
       // we have at least one user, so show all users as options in select form
       while($row = mysql_fetch_row($result))
       {
printf("<a href=\"$row[2]\">$row[1]</a> - $row[4]\n<br>\n");
printf("<a href=\"lxadmin.php?admin=$admin&checksite=$row[0]\"><font size=\"-2\">Check For Reciprocal Link</font></a> | <a href=\"lxadmin.php?admin=$admin&ban=$row[0]\"><font size=\"-2\">Ban</font></a> | <a href=\"lxadmin.php?admin=$admin&accsite=$row[0]\"><font size=\"-2\">Accept Link</font></a> | <a href=\"lxadmin.php?admin=$admin&delsite=$row[0]\"><font size=\"-2\">Delete</font></a> | <a href=\"mailto:$row[5]\"><font size=\"-2\">Email Webmaster</font></a>\n<br>\n<br>\n");
       }
     } else {
       printf("No links yet\n<br>\n");
     }

Printf("<p><strong>Link Exchanges Missing A Reciprocal Link</strong></p>\n");

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 WHERE linkstatus = 2 order by id";
$result=mysql_query($query);
     if(mysql_num_rows($result)) {
       // we have at least one user, so show all users as options in select form
       while($row = mysql_fetch_row($result))
       {
printf("<a href=\"$row[2]\">$row[1]</a> - $row[4]\n<br>\n");
printf("<a href=\"lxadmin.php?admin=$admin&checksite=$row[0]\"><font size=\"-2\">Check For Reciprocal Link</font></a> | <a href=\"lxadmin.php?admin=$admin&ban=$row[0]\"><font size=\"-2\">Ban</font></a> | <a href=\"lxadmin.php?admin=$admin&delsite=$row[0]\"><font size=\"-2\">Delete</font></a> | <a href=\"mailto:$row[5]\"><font size=\"-2\">Email Webmaster</font></a>\n<br>\n<br>\n");
       }
     } else {
       printf("No links\n<br>\n");
     }

Printf("<p><strong>Banned Sites</strong></p>\n");

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 WHERE linkstatus = 3 order by id";
$result=mysql_query($query);
     if(mysql_num_rows($result)) {
       // we have at least one user, so show all users as options in select form
       while($row = mysql_fetch_row($result))
       {
printf("<a href=\"$row[2]\">$row[1]</a> - $row[4]\n<br>\n");
printf("<a href=\"lxadmin.php?admin=$admin&checksite=$row[0]\"><font size=\"-2\">Check For Reciprocal Link</font></a> | <a href=\"lxadmin.php?admin=$admin&unban=$row[0]\"><font size=\"-2\">Unban</font></a> | <a href=\"lxadmin.php?admin=$admin&delsite=$row[0]\"><font size=\"-2\">Delete</font></a> | <a href=\"mailto:$row[5]\"><font size=\"-2\">Email Webmaster</font></a>\n<br>\n<br>\n");
       }
     } else {
       printf("No sites\n<br>\n");
     }

echo "</body>
</html>";

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