<?php
# START addlink()
function addlink()
{
if(isset($_POST) && is_array($_POST) && count($_POST) > 0 && checkPostForm('instantLEadminAddLink', $_POST) === TRUE)
{
global $instantLEmaxLinks;
$name = $_POST['instantLEname'];
$email = $_POST['instantLEemail'];
$title = $_POST['instantLEtitle'];
$url = $_POST['instantLEurl'];
$recurl = $_POST['instantLErecipURL'];
$description = $_POST['instantLEdescription'];
$url = str_replace('&', '&', $url);
$recurl = str_replace('&', '&', $recurl);
$linkCountQuery = dbcom('SELECT COUNT(*) AS linkCount FROM instantle;');
$linkCountArray = mysql_fetch_assoc($linkCountQuery);
if(($linkCountArray['linkCount'] - 1 ) > $instantLEmaxLinks)
{
echo 'We are not accepting any more links at the moment. We appologize for the inconvenience!';
}
else
{
if(array_key_exists('instantLErecipURL', $_POST))
{
dbcom("INSERT INTO instantle VALUES(NULL, '{$_POST['instantLEname']}', '{$_POST['instantLEemail']}', '{$_POST['instantLEtitle']}', '$url', '{$_POST['instantLEdescription']}', 1);");
}
else
{
dbcom("INSERT INTO instantle VALUES(NULL, '{$_POST['instantLEname']}', '{$_POST['instantLEemail']}', '{$_POST['instantLEtitle']}', '$url', '{$_POST['instantLEdescription']}', 0);");
}
?>
<h2>Instant Link Exchange</h2>
<p><b>Link added</b></p>
<p>The URL <?php echo $url; ?> was successfully added to your links page.</p>
<p><a href="instantLEadmin.php">Click to continue</a></p>
<?php
}
}
else
{
echo 'Link could not be added, because an error occurred.';
}
}
# END addlink()
# START check()
function check()
{
echo '<h2>Instant Link Exchange</h2>';
echo '<p><b>Checking reciprocal links...</b></p>';
global $site_url;
$linksQuery = dbcom('SELECT * FROM instantle ORDER BY id ASC;');
while($link = mysql_fetch_assoc($linksQuery))
{
$id = $link['id'];
$name = $link['name'];
$email = $link['email'];
$title = $link['sitename'];
$url = $link['siteurl'];
$description = $link['description'];
$checkRecURL = $link['checkRecURL'];
echo "<p>Checking link N. <b>$id</b>...<br>\n";
echo '-> Link URL: <a href="' . $url . '" target="_blank">' . $url .'</a><br>' . "\n";
if($checkRecURL == 0)
{
echo '<span style="color: #008800">>No reciprocal link required!</span><br><br>' . "\n";
echo "- - - - - - - - - - - - - - - - - - - - - - - - - - - -</p>\n";
continue;
}
echo '-> Opening and reading URL ';
$html = @file_get_contents($url, 'r') or $html='NO';
if($html == 'NO')
{
echo '<br>' . "\n" . '<span style="color: #ffff00">ERROR: CAN\'T OPEN URL, PLEASE TRY LATER!</span> <a href="instantLEadmin.php?action=remove&id=' . $id . '">[Delete]</a><br><br>' . "\n\n";
}
else
{
if(stristr($html, $site_url))
{
echo '<br>' . "\n" . '<span style="color: #008800">A link to ' . $site_url . ' was found!</span><br><br>' . "\n\n";
}
else
{
echo '<br>' . "\n" . '<span style="color: #ff0000">LINK NOT FOUND!</span><br><br>' . "\n\n" . 'Removing link ...<br>';
dbcom("DELETE FROM instantle WHERE id='$id';");
}
}
echo "</p><hr />\n";
}
echo '<p> </p>';
if(mysql_num_rows($linksQuery) > 0)
{
echo '<p><b>DONE!</b></p>';
}
else
{
echo '<p>There are no links to check.</p>';
}
echo '<p><a href="instantLEadmin.php">Back to main page</a></p>';
}
# END check()
# START removelink()
function removelink($id)
{
dbcom("DELETE FROM instantle WHERE id = '$id';");
mainpage('The selected link was successfully removed!');
}
# END removelink()
# START mainpage()
function mainpage($notice)
{
global $instantLE, $pagelimit, $instantLEsort;
?>
<script type="text/javascript"><!--
function doconfirm(message) {
if (confirm(message)) {return true;}
else {return false;}
}
//-->
</script>
<h2>Instant Link Exchange</h2>
<br>
View/Delete Links
<?php
echo "<br><br>\n";
if(isset($_GET) && is_array($_GET) && count($_GET) > 0 && array_key_exists('page', $_GET) && ctype_digit($_GET['page']))
{
$page = $_GET['page'];
}
else
{
$page = 1;
}
$instantLE->page = $page;
$instantLE->page *= $pagelimit;
$instantLE->page -= $pagelimit;
$linkTotalQuery = dbcom('SELECT COUNT(*) AS linkTotal FROM instantle;');
$linkTotalArray = mysql_fetch_assoc($linkTotalQuery);
if($linkTotalArray['linkTotal'] == 0)
{
?>
<p>You don't have any links yet.</p>
<?php
}
else
{
$instantLE->total = $linkTotalArray['linkTotal'];
switch($instantLEsort)
{
case 'asc':
$sortLinks = 'sitename';
break;
case 'date':
$sortLinks = 'id';
break;
case 'random':
$sortLinks = 'RAND()';
break;
}
$linkQuery = dbcom("SELECT * FROM instantle ORDER BY $sortLinks LIMIT $instantLE->page, $pagelimit;");
while($linkArray = mysql_fetch_assoc($linkQuery))
{
echo "<a href=\"instantLEadmin.php?action=remove&id={$linkArray['id']}\" onclick=\"return doconfirm('Are you sure you want to remove this link? This cannot be undone!');\"><img src=\"images/delete.png\" border=\"0\" height=\"16\" width=\"16\" alt=\"Remove this link\" align=\"middle\"></a>
<a href=\"{$linkArray['siteurl']}\" target=\"_new\">{$linkArray['sitename']}</a> - {$linkArray['description']}<br />";
}
?>
<p>You can remove links by clicking the <img src="images/delete.png" height="16" width="16" align="middle"> button.</p>
<?php
}
$instantLE->paginate('instantLEadmin.php?action=remove&page=');
}
# END mainpage()
# START error()
function error($myproblem)
{
?>
<tr>
<td><b>Instant Link Exchange</b></td>
</tr>
<tr>
<td><p> </p>
<div>
<table> <tr>
<td>ERROR</td>
</tr>
<tr>
<td>
<form>
<p> </p>
<p><b>An error occured:</b></p>
<p><?php echo $myproblem; ?></p>
<p> </p>
<p><a href="javascript:history.go(-1)">Back to the previous page</a></p>
<p> </p>
</form>
</td>
</tr> </table>
</div>
<p> </p>
<p> </p>
<p> </p>
</td>
</tr>
<?php
}
# END error()
?>