<?PHP
include "../inc/var.php";
include "../inc/connect.php";
include $server_inc."/whm_functions.php";
include $server_inc."/client_functions.php";
include $server_inc."/login_functions.php";

if (isset($accept))
	{
	mysql_query("update affiliate_user set status='0' where afuid='".addslashes(trim($afuid))."'");

	affiliate_approved($uid, $http_web, $email_admin);
	}
else if (isset($reject))
	{
	mysql_query("update affiliate_user set status='3' where afuid='".addslashes(trim($afuid))."'");

	affiliate_denied($uid, $http_web, $email_admin);
	}

include $server_admin_inc."/header.php";


echo("
<form action='".$PHP_SELF."' method='POST'>
".((isset($pid))?"<input type='hidden' name='pid' value='".trim($pid)."'>":"")."
<input type='hidden' name='sid' value='".trim($sid)."'>

<!--- Start Main --->
<table width='725' border='0' cellspacing='1' cellpadding='2'>
		<tr>
			<td align='center' valign='top' bgcolor='#E5E7E9'><b>Approve</b></td>
			<td align='center' valign='top' bgcolor='#E5E7E9'><b>Reject</b></td>
			<td align='left' valign='top' bgcolor='#E5E7E9'>
			<table width='100%' cellpadding='0' cellspacing='0' border='0'>
				<tr>
					<td width='55%' align='left' valign='top'>&nbsp;&nbsp;&nbsp;<b>Client</b></td>
					<td width='45%' align='left' valign='top'><b>Domain(s) on account</b>&nbsp;&nbsp;&nbsp;</td>
				</tr>
			</table>
			</td>
			<td align='left' valign='top' bgcolor='#E5E7E9'><b>Request Submitted</b></td>
		</tr>
	");

$x=1;
$y=1;
$query="select ";
$query.="user.first_name, ";			// 0
$query.="user.last_name, ";				// 1
$query.="user.email, ";					// 2
# $query.="UNIX_TIMESTAMP(affiliate_user.ogcreate), ";	// 3
$query.="affiliate_user.ogcreate, ";	// 3
$query.="user.uid, ";					// 4
$query.="affiliate_user.afuid ";		// 5
$query.="from ";
$query.="user, affiliate_user ";
$query.="where ";
$query.="user.uid=affiliate_user.uid ";
$query.="and ";
$query.="affiliate_user.status='2' ";
$query.="order by ";
$query.="affiliate_user.uid asc";

$row=mysql_query($query);
while ($rs=mysql_fetch_row($row))
	{
	if ($y==1) {$bgcolor="#F2F4F6"; $y=0;} else {$bgcolor="#ECEEF0"; $y=1;}
	echo("
		<tr>
			<td align='center' valign='middle' bgcolor='".$bgcolor."'>[<a href='".$http_admin."/affiliate_approve.php?accept=5&sid=".trim($sid)."&afuid=".$rs[5]."&uid=".$rs[4]."'>click</a>]</td>
			<td align='center' valign='middle' bgcolor='".$bgcolor."'>[<a href='".$http_admin."/affiliate_approve.php?reject=5&sid=".trim($sid)."&afuid=".$rs[5]."&uid=".$rs[4]."'>click</a>]</td>
			<td align='left' valign='top' bgcolor='".$bgcolor."'>
			<table width='100%' cellpadding='0' cellspacing='0' border='0'>
				<tr>
					<td width='55%' align='left' valign='top'>&nbsp;&nbsp;&nbsp;".$rs[0]." ".$rs[1]."</td>
					<td width='45%' align='left' valign='top'><select ".$input_style.">
		");
	$sd=0;
	$row1=mysql_query("select domain_name from hosting_order where uid='".addslashes(trim($rs[4]))."'");
	while ($rs1=mysql_fetch_row($row1))
		{
		echo"<option>http://".$rs1[0]."</option>\n";
		$sd++;
		}
	if ($sd==0) { echo"<option>Affiliate Only - No Hosted Domains</option>\n"; }
	echo("
			</select>&nbsp;&nbsp;&nbsp;</td>
				</tr>
			</table></td>
			<td align='left' valign='top' bgcolor='".$bgcolor."'>".date("m/d/Y h:i:s a", $rs[3])."</td>
		</tr>
		");
	$x++;
	}
if ($x==1)
	{
	echo("
		<tr>
			<td colspan='5'><br><img src='".$http_images."/error_arrow.gif'>No affiliate requests found in the database.</td>
		</tr>
		");
	}
echo("
</table>
</form>
<!--- End Main --->
	");
// End Main Process
mysql_close($dblink);
include $server_admin_inc."/footer.php";
?>