<%if Session("weight")<>5 then 
Response.Redirect "error.asp?cause=4"
 end if
%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<LINK 
href="css/default.css" rel=stylesheet>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<LINK 
href="css/default.css" rel=stylesheet>
</HEAD>
<BODY><object runat=server id=conn1 progid="adodb.connection"></object>
<%application.Lock
conn1.Open Application("p_jyzx")
Application.UnLock
%>
<% if Request("flag")=1 then
	'///从账户上扣除汇款金额
	user_name=Request("user_name")
	mymoney=Request("money")
	 Set rs1 = Server.CreateObject("ADODB.Recordset")
	 sql="select * from affiliate where user_name='"&user_name&"'"
	rs1.Open sql,conn1,2,3
	rs1("left_money")=rs1("left_money")-Request("money")
	rs1.Update
    '/////////法电子邮件
	SMTPServer_username=Application("SMTPServer_username")
   SMTPServer_passwd=Application("SMTPServer_passwd")
	SMTPServer=trim(Application("SMTPServer"))
	SystemEmail=trim(Application("SystemEmail"))
	SenderName=trim(Application("SenderName"))
	email=trim(Request("to_who"))
	topic=trim(Request("topic"))
	mailbody=trim(Request("mailbody"))
	
	on error resume next
	dim msg,SendMail
	Set msg = Server.CreateObject("JMail.Message")

		msg.silent = true
		msg.Logging = true
		msg.Charset = "gb2312"
		msg.MailServerUserName = SMTPServer_username
		msg.MailServerPassword = SMTPServer_passwd
		msg.From = SystemEmail
		msg.FromName = SenderName
		msg.AddRecipient email,user_name
		msg.Subject = topic
		msg.Body = mailbody
		msg.Send (SMTPServer)
	set msg=nothing
	if err then 
	SendMail=err.description
	err.clear
	else
	SendMail="ok"
	end if
	'end sub
  
  
%>
	<%if SendMail="ok" then%>
<p align=center>邮件发送成功！
</P>
<p align=center>系统已经将你的信件发到<%=email%>处了&nbsp;&nbsp;
</P>
	<%else%>
	<p align=center>邮件发送失败！
	</P>
	<p align=center>失败原因：<%=SendMail%>&nbsp;&nbsp;
	</P>
	<%end if%>
<p align=center><font color="red">已经从用户账户扣除<%=Request("money")%>元</font></p>	
<p align=center><a href=affiliate_list.asp >返 回</a></p>
<%else%>
<%'////////////
 user_name=Request("user_name")
   Set rs = Server.CreateObject("ADODB.Recordset")
	 sql="select * from affiliate where user_name='"&user_name&"'"
	rs.Open sql,conn1,3,2
		
    email=rs("email")
    address=rs("address")
    postcode=rs("postcode")

    visit_counter=rs("visit_counter")
    join_counter=rs("join_counter")
    vip_join_counter=rs("vip_join_counter")
    left_money=rs("left_money")
 '//////////////////////
 set rs=server.CreateObject ("ADODB.recordset")
 sql="select * from my_system where system_id=1"
 rs.Open sql,conn1,3
 if rs.RecordCount<>0 then
	affiliate_visit_value=rs("affiliate_visit_value")
	affiliate_join_value=rs("affiliate_join_value")
	affiliate_join_vip=rs("affiliate_join_vip")
 end if   
    money=visit_counter*affiliate_visit_value+join_counter*affiliate_join_value+vip_join_counter*affiliate_join_vip+left_money
     money=clng(money)
%>
<SCRIPT language=JavaScript>
function is_number(str)
{
	exp=/[^0-9]/g;
	if(str.search(exp) != -1)
	{
		return false;
	}
	return true;
}
function is_email(str)
{ if((str.indexOf("@")==-1)||(str.indexOf(".")==-1)){
	
	return false;
	}
	return true;
}
function checkform(){
	 if( inputform.money.value =="") {
                alert("\请输入汇款金额!!")
                return false;
        }
	if(!is_number(document.inputform.money.value)){
		alert("汇款金额必须用数字！");
		inputform.money.focus();
		return false;
	}
	
	if( inputform.to_who.value =="") {
                alert("\请输入EMail地址!!")
                inputform.to_who.focus();
                return false;
        }
	if(!is_email(inputform.to_who.value))
	{ alert("非法的EMail地址！");
		inputform.to_who.focus();
	return false;
	}
	return true;
}
</script>
<p><BR>
<TABLE cellSpacing=1 width="100%" align=center bgColor=#fff7fd cellPadding=5>
        <TBODY bgColor=#fff7fd>
         <TR >
    <TD  align=left  colspan=2> <font size=5>系统信息 </font></TD>
   </TR>
        <TR>
		<TD align=center>汇款通知邮件</TD><TD><font size=5><A href=affiliate_list.asp>返回</A></font></TD>
		</TR>
</tbody>
</table>	
<FORM action="affiliate_post_money.asp?user_name=<%=user_name%>" method=POST id=form1 name=inputform onsubmit=return(checkform())>
<INPUT type="hidden" id=text1 name=flag value=1>
<TABLE cellSpacing=1 width="100%" align=center bgColor=#fff7fd cellPadding=5>
        <TBODY bgColor=#fff7fd>
        <TR>
		<TD>&nbsp;&nbsp;汇款金额：</TD>
		<TD><INPUT type="text" id=text1 name=money size=5 maxlength=5 value=<%=money%> >元&nbsp;&nbsp;用户账户共有<%=money%>元,请不要超出这个数字</TD>
	</TR>
        <TR>
		<TD>&nbsp;&nbsp;收信人地址：</TD>
		<TD><INPUT type="text" id=text1 name=to_who size=50 value=<%=email%> ></TD>
	</TR>
	<TR>
		<TD>&nbsp;&nbsp;主题：</TD>
		<TD ><INPUT type="text" id=text2 name=topic  size=50 value="汇款通知" ></TD>
	</TR>
	<TR>
		<TD colspan=2 align=center>主体内容：</TD>
		
	</TR>
	<TR>
		
		<TD colspan=2 align=center><TEXTAREA rows=16 cols=80 id=textarea1 name=mailbody>
		根据您的付费申请，经我们的核实后。
		现在给您汇款**元。请您注意近日的汇款单。</TEXTAREA></TD>
	</TR>
	<TR align=center>
		<TD  align=center colspan=2><INPUT type="submit" value="发 送" id=submit1 name=submit1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		<INPUT type="reset" value="取 消" id=reset1 name=reset1></TD>
	</TR>
</TABLE>

</FORM>
</FORM>
</BODY>
</HTML>
<%end if%>