<?php
$mysql = new mysql(DB_MAIN);
if (isset($_GET['action'])) {
$action = $_GET['action'];
}
if (isset($_GET['id'])) {
$id = $_GET['id'];
}
if(isset($action))
{
switch($action)
{
case 'delete':
$delete = $mysql->delete(PRE."affiliates", "id='$id'");
if ($delete) {
echo('Deleted successfully, please wait...');
header("Location: ".$HTTP_REFERER);
//exit();
} else {
echo('Error deleting entry: ' . mysql_error());
}
break;
case 'deleteall':
$id = $_GET['id'];
$delete = $mysql->query("TRUNCATE TABLE ".PRE."affiliates");
if ($delete) {
echo('Deleted all affiliates successfully, please wait...');
header("Location: ".$HTTP_REFERER);
//exit();
} else {
echo('Error truncating: ' . mysql_error());
}
break;
case 'accept':
$select = $mysql->select(PRE."affiliates", "id='".$id."'", "id");
$row = mysql_fetch_assoc($select);
$sitename = stripslashes($row['sitename']);
$accept = $mysql->update(PRE."affiliates", "status='yes'", "id='$id'");
if ($accept) {
echo($sitename.' accepted successfully!, please wait...');
header("Location: ".$HTTP_REFERER);
//exit();
} else {
echo('Error accepting entry: ' . mysql_error());
}
break;
case 'decline':
$select = $mysql->select(PRE."affiliates", "id='".$id."'", "id");
$row = mysql_fetch_assoc($select);
$sitename = stripslashes($row['sitename']);
$decline = $mysql->update(PRE."affiliates", "status='no'", "id='".$id."'");
if ($decline) {
echo($sitename.' declined successfully!, please wait...');
header("Location: ".$HTTP_REFERER);
//exit();
} else {
echo('Error declining entry: ' . mysql_error());
}
break;
}
}
$select = $mysql->select(PRE."affiliates", NULL, "id", "DESC");
while( $row = mysql_fetch_assoc($select))
{
$id = $row['id'];
$sitename = stripslashes($row['sitename']);
$webmaster = stripslashes($row['webmaster']);
$address = stripslashes($row['address']);
$button = stripslashes($row['button']);
$contact = stripslashes($row['contact']);
$date = $row['submitdate'];
$status = $row['status'];
echo '<table style="width: 350px; border: 1px solid #000; text-align: center; left: 50%; margin-left: 33%;">
<tr>
<td style="background: #555555; text-align: center;" colspan="2">
<b>'.$date.'</b>
</td>
</tr>
<tr>
<td style="width:35%;">
Site Name:
</td>
<td style="width:50%;">
'.$sitename.'
</td>
</tr>
<tr>
<td>
Webmaster:
</td>
<td>
'.$webmaster.'
</td>
</tr>
<tr>
<td>
Site address:
</td>
<td>
<a href="'.$address.'">'.$address.'</a>
</td>
</tr>
<tr>
<td>
Affiliate\'s button:
</td>
<td>
<img src="'.$button.'" style="width: 88px; height: 31px;" alt="" />
</td>
</tr>
<tr>
<td>
Contact email:
</td>
<td>
'.$contact.'
</td>
</tr>
<tr>
<td>
Status:
</td>
<td>';
switch($status)
{
case 'pending':
echo('<span style="color: yellow;">Pending</span>');
break;
case 'yes':
echo('<span style="color: green">Accepted</span>');
break;
case 'no':
echo('<span style="color: red">Declined</span>');
break;
}
echo "</td>
</tr>
</table>
<div style=\"text-align:center;\">
<a href=\"admin.php?sect=affs&action=delete&id='.$id.'\">Delete</a>";
switch($status)
{
case 'no':
echo ' | <a href="admin.php?sect=affs&action=accept&id='.$id.'">Accept this affiliate</a>';
break;
case 'pending':
echo ' | <a href="admin.php?sect=affs&action=accept&id='.$id.'">Accept this affiliate</a>';
break;
case 'yes':
echo ' | <a href="admin.php?sect=affs&action=decline&id='.$id.'">Decline this affiliate</a>';
break;
}
echo '</div>';
$num_rows = mysql_num_rows($select);
}
if ($num_rows > 0) {
echo '<div style="text-align:center;">
<a href="admin.php?sect=affs&action=deleteall">Delete All</a>
</div>';
} else {
echo('There are no affiliates');
}
//}
?>