<?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($approve))
	{
	// gather info
	$rs=mysql_fetch_row(mysql_query("select ogcreate, resolved_time, ur_date, whm_id, whm_username, reason_for_cancel, cancel_date, whm_id from hosting_order where oid='".addslashes(trim($oid))."' limit 0, 1"));
	$whm_username=$rs[4];
	$reason_for_cancel=$rs[5];
	$cancel_date=$rs[6];
	$whm_id=$rs[7];

	$rs0=mysql_fetch_row(mysql_query("select server_ip from server_config where whm_id='".addslashes(trim($rs[3]))."'"));
	$server_ip=$rs0[0];
	
	// update order
	mysql_query("update hosting_order set status='5', ogcreate='".addslashes(trim($rs[0]))."', resolved_time='".addslashes(trim($rs[1]))."', ur_date='".addslashes(trim($rs[2]))."', reason_for_cancel='".addslashes(trim($reason_for_cancel))."', cancel_date='".addslashes(trim($cancel_date))."' where oid='".addslashes(trim($oid))."'");

	// suspend the account
	// read in logins
	$temp=@read_log($whm_id, $below_public);
	list($xwhm_username, $xwhm_password)=split("[|]", $temp);
	suspend_account($server_ip, $xwhm_username, $xwhm_password, $whm_username);

	// send notification
	cancel_processed($oid, $email_admin, $reason_for_cancel);
	}
else if (isset($cancel))
	{
	// gather info
	$rs=mysql_fetch_row(mysql_query("select ogcreate, resolved_time, ur_date, cancel_date from hosting_order where oid='".addslashes(trim($oid))."' limit 0, 1"));
	
	// update order
	mysql_query("update hosting_order set status='1', ogcreate='".addslashes(trim($rs[0]))."', resolved_time='".addslashes(trim($rs[1]))."', ur_date='".addslashes(trim($rs[2]))."', reason_for_revoke='".addslashes(trim($reason_for_revoke))."', cancel_date='".addslashes(trim($rs[3]))."' where oid='".addslashes(trim($oid))."'");

	// send email notify for the admin
	$reason_for_revoke="Processed by the site Administrator.";
	request_cancel_revoked($oid, $email_admin, $reason_for_revoke);
	}

include $server_admin_inc."/header.php";


echo("
<form action='".$PHP_SELF."' method='POST'>
<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'>&nbsp;&nbsp;<b>Process Request</b></td>
			<td align='center' valign='top' bgcolor='#E5E7E9'>&nbsp;&nbsp;<b>Deny Request</b></td>
			<td align='left' valign='top' bgcolor='#E5E7E9'>&nbsp;&nbsp;<b>Client</b></td>
			<td align='left' valign='top' bgcolor='#E5E7E9'>&nbsp;&nbsp;<b>Domain</b></td>
			<td align='center' valign='top' bgcolor='#E5E7E9'>&nbsp;&nbsp;<b>Request Submitted</b></td>
		</tr>
	");

$x=1;
$y=1;
# $row=mysql_query("select user.first_name, user.last_name, user.email, user.uid, UNIX_TIMESTAMP(hosting_order.cancel_date), hosting_order.oid, hosting_order.domain_name, hosting_order.reason_for_cancel from user, hosting_order where hosting_order.uid=user.uid and hosting_order.status='4' order by hosting_order.oid asc");
$row=mysql_query("select user.first_name, user.last_name, user.email, user.uid, hosting_order.cancel_date, hosting_order.oid, hosting_order.domain_name, hosting_order.reason_for_cancel from user, hosting_order where hosting_order.uid=user.uid and hosting_order.status='4' order by hosting_order.oid asc");
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."'>&nbsp;&nbsp;[<a href='".$http_admin."/client_cancel_account.php?approve=5&sid=".trim($sid)."&oid=".$rs[5]."'>click</a>]</td>
			<td align='center' valign='middle' bgcolor='".$bgcolor."'>&nbsp;&nbsp;[<a href='".$http_admin."/client_cancel_account.php?cancel=5&sid=".trim($sid)."&oid=".$rs[5]."'>click</a>]</td>
			<td align='left' valign='top' bgcolor='".$bgcolor."'>&nbsp;&nbsp;<a href='mailto:".$rs[2]."'>".$rs[0]." ".$rs[1]."</a></td>
			<td align='left' valign='top' bgcolor='".$bgcolor."'>&nbsp;&nbsp;<a href='http://".$rs[6]."' target='_blank'>http://".$rs[6]."</a></td>
			<td align='center' valign='top' bgcolor='".$bgcolor."'>&nbsp;&nbsp;".date("m/d/Y h:i:s a", $rs[4])."</td>
		</tr>
		<tr>
			<td colspan='2' align='center' valign='middle'></td>
			<td colspan='3' align='left' valign='middle' bgcolor='".$bgcolor."'><img src='".$http_images."/drop_arrow.gif'>".stripslashes($rs[7])."</td>
		</tr>
		<tr>
			<td colspan='5' align='center' valign='middle'><img src='".$http_images."/space.gif' width='1' height='10'></td>
		</tr>
		");
	$x++;
	}
if ($x==1)
	{
	echo("
		<tr>
			<td colspan='5'><br><img src='".$http_images."/error_arrow.gif'>No cancel requests found in the database.</td>
		</tr>
		");
	}
echo("
</table>
</form>
<!--- End Main --->
	");
// End Main Process
mysql_close($dblink);
include $server_admin_inc."/footer.php";
?>