<?PHP
include "inc/var.php";
include "inc/connect.php";
include $server_inc."/pagefind.php";
include $server_inc."/languages/".$local_lang.".php";
include $server_inc."/languages/".$local_lang."/".file_name().".php";
include $server_inc."/select.php";
include $server_inc."/whm_functions.php";
if (isset($one_time)) { include $server_tools."/credit_card_code[2].php"; }
else  { include $server_tools."/credit_card_code[1].php"; }
include $server_inc."/header.php";

echo("
	<script language='javascript'>
	function lock(whichform) 
		{
		ua=new String(navigator.userAgent);
		if (ua.match(/IE/g)) 
			{
			for (i=1; i<whichform.elements.length; i++) 
				{
				if (whichform.elements[i].type=='submit') { whichform.elements[i].disabled=true; }
				}
			}

		whichform.submit();
		}
	</script>
	");

if (isset($e69))
	{
	echo("
			<table width='85%' cellpadding='2' cellspacing='0' border='0' align='center'>
				<tr>
					<td><font color='#C60C08'><b>ERROR!</b></font> ".$e69."</td>
				</tr>
			</table>
			");
	}


if (isset($e0))
	{
	echo("
			<table width='85%' cellpadding='2' cellspacing='0' border='0' align='center'>
				<tr>
					<td>".$error_nofirstname."</td>
				</tr>
			</table>
			");
	}

if (isset($e1))
	{
	echo("
			<table width='85%' cellpadding='2' cellspacing='0' border='0' align='center'>
				<tr>
					<td>".$error_nolastname."</td>
				</tr>
			</table>
			");
	}

if (isset($e2))
	{
	echo("
		<table width='85%' cellpadding='2' cellspacing='0' border='0' align='center'>
			<tr>
				<td>".$error_noaddress."</td>
			</tr>
		</table>
		");
	}

if (isset($e3))
	{
	echo("
		<table width='85%' cellpadding='2' cellspacing='0' border='0' align='center'>
			<tr>
				<td>".$error_nocity."</td>
			</tr>
		</table>
		");
	}

if (isset($e4))
	{
	echo("
		<table width='85%' cellpadding='2' cellspacing='0' border='0' align='center'>
			<tr>
				<td>".$error_nozip."</td>
			</tr>
		</table>
		");
	}

if (isset($e5))
	{
	echo("
		<table width='85%' cellpadding='2' cellspacing='0' border='0' align='center'>
			<tr>
				<td>".$error_nophone."</td>
			</tr>
		</table>
		");
	}

if (isset($e6))
	{
	echo("
		<table width='85%' cellpadding='2' cellspacing='0' border='0' align='center'>
			<tr>
				<td>".$error_nocard."</td>
			</tr>
		</table>
		");
	}

if (isset($e7))
	{
	echo("
		<table width='85%' cellpadding='2' cellspacing='0' border='0' align='center'>
			<tr>
				<td>".$error_noexpiration."</td>
			</tr>
		</table>
		");
	}

if (isset($e8))
	{
	echo("
		<table width='85%' cellpadding='2' cellspacing='0' border='0' align='center'>
			<tr>
				<td>".$text_noccv."</td>
			</tr>
		</table>
		");
	}

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

$query="select ";
$query.="total_due_today, ";
$query.="total_due_reoccur, ";
$query.="oid, ";
$query.="uid ";
$query.="from ";
$query.="invoice ";
$query.="where ";
$query.="iid='".addslashes(trim($iid))."'";

$rs=mysql_fetch_row(mysql_query($query));

$total_due_today=$rs[0];
$total_due_reoccur=$rs[1];
$oid=$rs[2];
$uid=$rs[3];

if ($total_due_today!=0)
	{
	echo("
		<table width='".$standard_table_width."' cellpadding='".$standard_table_padding."' cellspacing='".$standard_table_spacing."' border='".$standard_table_border."' align='".$standard_table_align."' bgcolor='".$standard_table_bgcolor."'>
			<tr>
				<td><img src='".$http_images."/menu_arrow.gif'><font color='#C60C08'><b>Your card will be billed today in the amount of:</b> ".$currency."".sprintf("%01.2f", $rs[0])." ".$currency_type."</font></td>
			</tr>
		");
	}

if ($total_due_reoccur!=0)
	{
	$rs1=mysql_fetch_row(mysql_query("select payment_term from hosting_order where oid='".addslashes(trim($oid))."'"));

	echo("
			<tr>
				<td><img src='".$http_images."/space.gif' width='15' height='9'>Recurring charges of ".$currency."".sprintf("%01.2f", $rs[1])." ".$currency_type." will be charged ");
	$payment_term=strtolower(str_replace("-", "_", $rs1[0]));
	if ($payment_term=="monthly") { echo "Monthly"; }
	else if ($payment_term=="quarterly") { echo "Quarterly"; }
	else if ($payment_term=="semi_annual") { echo "Semi-Annually"; }
	else if ($payment_term=="annual") { echo "Annually"; }
	echo(".</font></td>
			</tr>
		</table>
		");
	}


echo("
	<table width='".$standard_table_width."' cellpadding='".$standard_table_padding."' cellspacing='".$standard_table_spacing."' border='".$standard_table_border."' align='".$standard_table_align."' bgcolor='".$standard_table_bgcolor."'>
		<tr>
			<td colspan='2' align='left' valign='top'><img src='".$http_images."/space.gif' width='1' height='10'><td>
		</tr>
	");

if ($uid==0)
	{
	$query="select ";
	$query.="uid ";
	$query.="from ";
	$query.="hosting_order ";
	$query.="where oid='".addslashes(trim($oid))."' ";

	$rs=mysql_fetch_row(mysql_query($query));
	
	$uid=$rs[0];
	}

$query="select ";
$query.="count(*) ";				// 12
$query.="from ";
$query.="authnet_master_cc ";
$query.="where uid='".addslashes(trim($uid))."' ";
$query.="and ";
$query.="master_cc='1'";

$rs=mysql_fetch_row(mysql_query($query));

$count=stripslashes(trim($rs[0]));

if ($count>=1)
	{
	echo("
		<tr>
			<td width='35%' align='left' valign='top'><img src='".$http_images."/menu_arrow.gif'><b>Use Exsiting Card:</b></td>
			<td width='65%' align='left' valign='top'><select name='ccid' ".$orderinput_style.">
			<option value='0'>No, Enter New Card Information Below</option>
		");
	$query3="select ";
	$query3.="ccid, ";
	$query3.="card_info, ";
	$query3.="master_cc ";
	$query3.="from ";
	$query3.="authnet_master_cc ";
	$query3.="where ";
	$query3.="uid='".addslashes(trim($uid))."' ";

	$row3=mysql_query($query3);
	while ($rs3=mysql_fetch_row($row3))
		{
		list($card_num, $card_exp, $card_code)=explode("|", d("576cb7f68040520768bf51c75f7f4c84", $rs3[1]));
		# ".(($rs3[2]==1)?" style='background-color: #F3F4F5;'":"")."
		echo "<option value='".$rs3[0]."'".(($rs3[2]==1)?" style='background-color: #F3F4F5;'":"").">".substr($card_num, 0, 2)."**********".substr($card_num, -4)."".(($rs3[2]==1)?" (Last Used)":"")."</option>\n";
		}

	unset($x_Card_Num);
	unset($x_Exp_Date_y);
	unset($x_Exp_Date_m);
	unset($x_Card_Code);
	echo("
				</select></td>
			</tr>
		<tr>
			<td colspan='2' align='left' valign='top'><img src='".$http_images."/space.gif' width='1' height='10'><td>
		</tr>	
		<tr>
			<td width='35%' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'></td>
			<td width='65%' align='left' valign='top'><input type='hidden' name='x_Submit' value='1'><input onclick='lock(this.form);' ".$orderbutton_style." type='submit' name='x_Submit' value='".$text_continue."'></td>
		</tr>
		<tr>
			<td width='35%' align='left' valign='top'></td>
			<td width='65%' align='left' valign='top'".$text_warning."</td>
		</tr>
		<tr>
			<td colspan='2' align='left' valign='top'><img src='".$http_images."/space.gif' width='1' height='10'><td>
		</tr>
		");
	}

echo("
		<tr>
			<td colspan='2' align='left' valign='top'><img src='".$http_images."/menu_arrow.gif'><b>".$text_ccpersonalinfo."</b><td>
		</tr>
		<tr>
			<td width='35%' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'>".$text_firstname.":</td>
			<td width='65%' align='left' valign='top'><input ".$orderinput_style." size='40' maxlength='50' type='text' name='x_First_Name' value='".((isset($x_First_Name))?"".$x_First_Name."":"")."'></td>
		</tr>
		<tr>
			<td width='35%' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'>".$text_lastname.":</td>
			<td width='65%' align='left' valign='top'><input ".$orderinput_style." size='40' maxlength='50' type='text' name='x_Last_Name' value='".((isset($x_Last_Name))?"".$x_Last_Name."":"")."'></td>
		</tr>
		<tr>
			<td width='35%' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'>".$text_address1.":</td>
			<td width='65%' align='left' valign='top'><input ".$orderinput_style." size='40' maxlength='60' type='text' name='x_Address' value='".((isset($x_Address))?"".$x_Address."":"")."'></td>
		</tr>
		<tr>
			<td width='35%' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'>".$text_city.":</td>
			<td width='65%' align='left' valign='top'><input ".$orderinput_style." size='40' maxlength='40' type='text' name='x_City' value='".((isset($x_City))?"".$x_City."":"")."'></td>
		</tr>
		<tr>
			<td width='35%' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'>".$text_state.":</td>
			<td width='65%' align='left' valign='top'><input ".$orderinput_style." size='40' maxlength='40' type='text' name='x_state' value='".((isset($x_state))?"".$x_state."":"")."'><BR>( 2 Digits State/Province Abbreviation )</td>
		</tr>
		<tr>
			<td width='35%' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'>".$text_zip.":</td>
			<td width='65%' align='left' valign='top'><input ".$orderinput_style." size='20' maxlength='20' type='text' name='x_Zip' value='".((isset($x_Zip))?"".$x_Zip."":"")."'></td>
		</tr>
		<tr>
			<td width='35%' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'>".$text_country.":</td>
			<td width='65%' align='left' valign='top'>".display_country($x_Country, $orderinput_style)."</td>
		</tr>
		<tr>
			<td width='35%' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'>".$text_phone."</td>
			<td width='65%' align='left' valign='top'><input ".$orderinput_style." size='15' maxlength='15' type='text' name='x_Phone' value='".((isset($x_Phone))?"".$x_Phone."":"")."'></td>
		</tr>
		<tr>
			<td width='35%' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'>".$text_fax."</td>
			<td width='65%' align='left' valign='top'><input ".$orderinput_style." size='15' maxlength='15' type='text' name='x_Fax' value='".((isset($x_Fax))?"".$x_Fax."":"")."'></td>
		</tr>
		<tr>
			<td width='35%' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'>".$text_email.":</td>
			<td width='65%' align='left' valign='top'><input ".$orderinput_style." size='40' maxlength='255' type='text' name='x_Email' value='".((isset($x_Email))?"".$x_Email."":"")."'></td>
		</tr>
		<tr>
			<td colspan='2' align='left' valign='top'><img src='".$http_images."/space.gif' width='1' height='10'><td>
		</tr>
		<tr>
			<td colspan='2' align='left' valign='top'><img src='".$http_images."/menu_arrow.gif'><b>".$text_ccinfo."</b><td>
		</tr>
		<tr>
			<td width='35%' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'>".$text_ccnumber.":</td>
			<td width='65%' align='left' valign='top'><input ".$orderinput_style." size='40' maxlength='22' type='text' name='x_Card_Num' value='".((isset($x_Card_Num))?"".$x_Card_Num."":"")."'></td>
		</tr>
		<tr>
			<td width='35%' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'>".$text_ccexpiration .":</td>
			<td width='65%' align='left' valign='top'><input ".$orderinput_style." size='2' maxlength='2' type='text' name='x_Exp_Date_m' value='".((isset($x_Exp_Date_m))?"".$x_Exp_Date_m."":"")."'>&nbsp;/&nbsp;<input ".$orderinput_style." size='2' maxlength='2' type='text' name='x_Exp_Date_y' value='".((isset($x_Exp_Date_y))?"".$x_Exp_Date_y."":"")."'>&nbsp;<font color='#990000'>ex. MM/YY</font></td>
		</tr>
		<tr>
			<td width='35%' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'>".$text_ccv .":</td>
			<td width='65%' align='left' valign='top'><input ".$orderinput_style." size='4' maxlength='4' type='text' name='x_Card_Code' value='".((isset($x_Card_Code))?"".$x_Card_Code."":"")."'></td>
		</tr>
		<tr>
			<td colspan='2' align='center' valign='top'><img src='".$http_images."/cvv-pic-3cards.gif'><td>
		</tr>
		<tr>
			<td colspan='2' align='left' valign='top'><img src='".$http_images."/space.gif' width='1' height='10'><td>
		</tr>	
		<tr>
			<td width='35%' align='left' valign='top'><img src='".$http_images."/space.gif' width='15' height='9'></td>
			<td width='65%' align='left' valign='top'><input type='hidden' name='x_Submit' value='1'><input onclick='lock(this.form);' ".$orderbutton_style." type='submit' name='x_Submit' value='".$text_continue."'></td>
		</tr>
		<tr>
			<td width='35%' align='left' valign='top'></td>
			<td width='65%' align='left' valign='top'>".$text_warning."</td>
		</tr>
	</table>
	");
include $server_inc."/footer.php";
mysql_close($dblink);
?>