<h2>View/Edit Partner Links</h2>
<?php
#global $list, $row, $pagelimit;
if(isset($_GET) && is_array($_GET) && count($_GET) > 0 && array_key_exists('page', $_GET) && ctype_digit($_GET['page']))
{
$page = $_GET['page'];
}
else
{
$page = 1;
}
$e->page = $page;
$e->page *= $pagelimit;
$e->page -= $pagelimit;
$g_total = dbcom('SELECT COUNT(id) AS TOTAL FROM partners;');
$e->total = mysql_result($g_total, 0);
echo '<p>These are the partner links displayed in the left pane under "Partners."</p>' . "\n";
echo '<form action="ddl.php?go=editplinks" method="post">' . "\n";
echo 'Manually add a partner link:' . "<br><br>\n";
echo '<table>' . "\n";
echo '<tr>' . "\n";
echo '<td align=right>' . "\n";
echo '<label for="txtSiteURL">Partner URL:</label>' . "\n";
echo '</td>' . "\n";
echo '<td align=right>' . "\n";
echo '<input type="text" name="surl" id="txtSiteURL" size="30" maxlength="255" />' . "\n";
echo '</td>' . "\n";
echo '</tr>' . "\n";
echo '<tr>' . "\n";
echo '<td>' . "\n";
echo '<label for="txtSiteName">Partner Site Name:</label>' . "\n";
echo '</td>' . "\n";
echo '<td>' . "\n";
echo '<input type="text" name="sname" id="txtSiteName" size="30" maxlength="100" />' . "\n";
echo '</td>' . "\n";
echo '</tr>' . "\n";
echo '<tr>' . "\n";
echo '<td colspan=2>' . "\n";
echo '<br><input type="submit" name="sub" value="Add" class="formbutton">' . "\n";
echo '</td>' . "\n";
echo '</tr>' . "\n";
echo '</table>' . "\n";
echo '</form>' . "\n";
if(isset($_POST) && is_array($_POST) && count($_POST) > 0 && array_key_exists('sub', $_POST))
{
switch($_POST['sub'])
{
case 'Remove from Partners':
if(checkPostForm('deletePartner', $_POST) === TRUE)
{
echo '<b>' . count($_POST['list']) . '</b> URL';
if(count($_POST['list']) != 1)
{
echo 's';
}
echo ' removed from Partners.<br><br>';
$idList = implode(',', $_POST['list']);
dbcom("DELETE FROM partners WHERE id IN ($idList);");
}
break;
case 'Add':
if(checkPostForm('addPartner', $_POST) === TRUE)
{
echo 'URL (<span><a href="' . $_POST['surl'] . '">' . $_POST['sname'] . '</a></span>) has been added to the partners list.';
dbcom("INSERT INTO partners VALUES (NULL, '{$_POST['surl']}', '{$_POST['sname']}');");
}
break;
case 'Sort':
if(checkPostForm('partnerSort', $_POST) === TRUE)
{
echo '<p>Partner Link settings update was successful.</p>' . "\n";
dbcom("UPDATE config SET
partnerLinksSort = '{$_POST['partnerLinksSort']}'
WHERE siteID = '{$_POST['siteID']}';");
}
break;
}
}
echo '<form action="ddl.php?go=editplinks" method="post">' . "\n";
echo '<input type="hidden" name="siteID" value="' . $siteID . '" />' . "\n";
echo '<table>' . "\n";
echo '<tr>' . "\n";
echo '<td><label for="lstPartnerLinksSort">Partner Links Sort:</label></td>' . "\n";
echo '<td><select name="partnerLinksSort" id="lstPartnerLinksSort" class="form">' . "\n";
if($partnerLinksSort == 'asc')
{
echo '<option value="asc" selected="selected"> Alphabetical </option>' . "\n";
}
else
{
echo '<option value="asc"> Alphabetical </option>' . "\n";
}
if($partnerLinksSort == 'date')
{
echo '<option value="date" selected="selected"> By Date </option>' . "\n";
}
else
{
echo '<option value="date"> By Date </option>' . "\n";
}
if($partnerLinksSort == 'random')
{
echo '<option value="random" selected="selected"> Scrambled </option>' . "\n";
}
else
{
echo '<option value="random"> Scrambled </option>' . "\n";
}
echo '</select></td>' . "\n";
echo '<td><input type="submit" name="sub" value="Sort" class="form"/></td>' . "\n";
echo '</tr>' . "\n";
echo '</table>' . "\n";
echo '</form>' . "\n";
$get = dbcom("SELECT * FROM partners ORDER BY id LIMIT $e->page, $pagelimit;");
if(mysql_num_rows($get) > 0)
{
echo '<form action="ddl.php?go=editplinks" method="post"><table border=0 cellpadding=0 cellspacing=0 width="100%"><tr>' . "\n";
while($row = mysql_fetch_array($get))
{
$column++;
echo '<td width="33%"><input type="checkbox" name="list[]" value="' . $row['id'] . '" id="list"><a href="' . $row['siteurl'] . '">' . $row['sitename'] . '</a></td>' . "\n";
if(is_int($column/3))
{
echo '</tr><tr>' . "\n";
}
}
echo '</tr></table><br>';
$e->paginate('ddl.php?go=editplinks&page=');
echo '<table>' . "\n";
echo '<tr>' . "\n";
echo '<td><br>' . "\n";
echo '<input type="button" value="Check All" class="form" onClick="this.value=check(this.form.list)">' . "\n";
echo '</td>' . "\n";
echo '</tr>' . "\n";
echo '<tr>' . "\n";
echo '<td><br>' . "\n";
echo '<input type="Submit" name="sub" value="Remove from Partners" class="formbuttonwide">' . "\n";
echo '</td>' . "\n";
echo '</tr>' . "\n";
echo '</table>' . "\n";
echo '</form>' . "\n";
}
else
{
echo '<p>You have no partner links.</p>' . "\n";
}
?>