<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunction.asp"-->
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<%
If session("username")="" Then
	ef=True
	ec="请您先登陆用户区，再续费，在主机面板中不能续费。也有可能是超时造成了出错。"
ElseIf Request.Form ("id")="" Then
	ef=True
	ec="请选择产品！"
ElseIf Instr(1, Request.Form ("id"), "'", 1)>0 then
	ef=True
	ec="非法产品ID！"
ElseIf not IsNumeric(Request.Form ("id"))  Then
	ef=True
	ec="产品ID应该是数字！"
end if
if not ef then
Set conn=Server.CreateObject("ADODB.Connection")
	conn.Open Application("FreeHostDBlink")
	Set ds = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_USER where username='"&session("username")&"'"
		ds.Open Sql,conn,1,3
if ds.eof then
	ef=True
	ec="用户不存在!"
end if
end if

if not ef then
if ds("password")<>session("password") then
	ef=True
	ec="密码不正确!"
end if
end if

if not ef then
	Set dsph = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_Email where id='"&Request.Form ("id")&"'"
			if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
	dsph.Open Sql,conn,1,3
if dsph.Eof then
	ef=True
	ec="邮箱不存在！"
end if
end if

if not ef then
	Set dshost = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_EmailProductlist where Emailtype='"&dsph ("Emailtype")&"'"
		if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
	dshost.Open Sql,conn,1,1
if dshost.Eof then
	ef=True
	ec="产品类型不存在！"
Else
'读取月付
PAY_Month=dshost("PAY_Month")
PAY_Season=dshost("PAY_Season")
PAY_halfyear=dshost("PAY_halfyear")
PAY_Nextyear=dshost("PAY_Nextyear")
if dsph("istest")="y" then PAY_Nextyear="1"
PAY_2year=dshost("PAY_2year")
PAY_3year=dshost("PAY_3year")
PAY_4year=dshost("PAY_4year")
PAY_5year=dshost("PAY_5year")
end if
end If

if not ef then
If Request.Form ("year")<>PAY_Month and Request.Form ("year")<>PAY_Season  and Request.Form ("year")<>PAY_halfyear and Request.Form ("year")<>PAY_Nextyear and Request.Form ("year")<>PAY_2year and Request.Form ("year")<>PAY_3year and Request.Form ("year")<>PAY_4year and Request.Form ("year")<>PAY_5year Then
	ef=True'不包含一年,不包含试用,只有续费
	ec="请选择时间！"
end If
end if

if not ef then
if dshost("isbyhost")="y" then
	ef=True
	ec="赠送的类型不能延期，只能由主产品延期。"
end if
end if

if not ef then
if Request.Form ("year")=PAY_Month and dshost("canmonth")="n" then
	ef=True
	ec="很抱歉,本产品不可以月付！"
end if
end if

if not ef then
if Request.Form ("year")=PAY_Season and dshost("canseason")="n" then
	ef=True
	ec="很抱歉,本产品不可以季付！"
end if
end if
if not ef then
if Request.Form ("year")=PAY_halfyear and dshost("canhalfyear")="n" then
	ef=True
	ec="很抱歉,本产品不可以半年付！"
end if
end if

if not ef then
	Set dsserver = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_ServerEmaillist where id='"&dsph ("ServerlistID")&"'"
	dsserver.Open Sql,conn,1,1
if dsserver.Eof then
	ef=True
	ec="服务器不存在！"
else
if dsserver("agent1")="n" then
isAgnEmailSer=false
else
isAgnEmailSer=true
end if
end if
end if

if not ef then
'结束时间
dim starttime,temptime,pdtype,isAgnHostSer
isAgnHostSer=isAgnEmailSer
starttime=dsph("endtime")
pdtype=dsph ("Emailtype")
oldtime=dsph("endtime")
if dsph("istest")="y" then  oldtime=now
y=Request.Form ("year")

if y=PAY_Nextyear then temptime=dateadd("yyyy",1,oldtime)
if y=PAY_2year then temptime=dateadd("yyyy",2,oldtime)
if y=PAY_3year then temptime=dateadd("yyyy",3,oldtime)
if y=PAY_4year then temptime=dateadd("yyyy",4,oldtime)
if y=PAY_5year then temptime=dateadd("yyyy",5,oldtime)
if y=PAY_Month then temptime=dateadd("y",31,oldtime)
if y=PAY_Season then temptime=dateadd("y",92,oldtime)
if y=PAY_halfyear then temptime=dateadd("y",182,oldtime)


end if

if not ef then
dim ef,ec,Userpaymoney,forpaytype,olduser_money,moneych,newuser_money,oldagn_money,mymoneych,newagn_money,Useragentname,agent_UP,agent_thisgree_cost,agent_this_name,logfor,pubisagnSer,AgnRunasUser,isRepaymoney,Repaymoney
Userpaymoney=dsHost("usermoney")
forpayyear=Request.Form ("year")
set RsUserds=ds
Useragentname=ds("agent1")
forpaytype="邮箱产品"
forpayid=dshost("id")
logfor="用户区延期"
pubisagnSer=isAgnEmailSer
AgnRunasUser=session("AgnRunasUser")
if not isnull(dsph("repaymoney")) and not isAgnHostSer then'管理员单独设置续费价格
logfor="用户区延期(单独价格)(邮箱产品ID:"&dsph("id")&")"
Repaymoney=dsph("repaymoney")
isRepaymoney=true
else
isRepaymoney=false
end if
DoPayMoney
Sql="UPDATE [FreeHost].[FreeHost_Moneylog] set pdid='"&dsph("id")&"' where pdid='"&session("moneylog_pdid")&"'"
    conn.Execute Sql
end if


if not ef then



'更新产品类别
'dsph ("Hosttype")=dshost("Hosttype")
'if dsph("istest")="y" then
dsph ("endtime")=temptime
dsph("status")="正常"
dsph("istest")="n"
dsph("emailstatus")=Null
dsph("smsstatus")=null
'end if
dsph.update


%>
<!--#include virtual="/inc-freehost-function/template-emailadm-top.asp"-->
 　邮箱延期
 
<br>
<br>
<br>
<table width="65%"  border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#FF0000">
  <tr align="center" bordercolor="#000000" bgcolor="#999999">
    <td height="39" colspan="4"><font color="#000000">　　　</font><font color="#990000"><font color="#FF0000">恭喜您的邮箱延期成功，以下是您的资料：</font></font></td>
  </tr>
  <tr bordercolor="#000000" bgcolor="#EEEEEE">
    <td width="44%" height="30"><font color="#000000"> 　　　 您的原金额：</font></td>
    <td width="56%" colspan="3"><%=olduser_money%> 元</td>
  </tr>
  <tr bordercolor="#000000" bgcolor="#EEEEEE">
    <td height="41"><font color="#000000">　　　 您的金额变化：</font></td>
    <td colspan="3"><font color=red><%=moneych%> 元</font></td>
  </tr>
  <tr bordercolor="#000000" bgcolor="#EEEEEE">
    <td height="39"><font color="#000000">　　　 您的新金额：</font></td>
    <td colspan="3"><font color="#000000"><%=newuser_money%> 元</font></td>
  </tr>
  <tr bordercolor="#000000">
    <td height="37" bgcolor="#eeeeee"><font color="#000000">　　　 原来的到期时间是:</font></td>
    <td colspan="3" bgcolor="#eeeeee"><%=oldtime%></td>
  </tr>
  <tr bordercolor="#000000">
    <td height="37" bgcolor="#eeeeee"><font color="#000000"> 　　　 现在的到期时间是:</font></td>
    <td colspan="3" bgcolor="#eeeeee"><%=temptime%></td>
  </tr>
  <tr bordercolor="#000000" bgcolor="#eeeeee">
    <td colspan="4"><font color="#000000">　　　</font><font color="#000000">　　　</font><font color="#000000">　</font><font color="#000000">　　　</font><font color="#000000">　　　</font><font color="#000000"> 　　　</font> 　</td>
  </tr>
  <tr align="center" bordercolor="#000000">
    <td height="34" colspan="4" bgcolor="#999999"><font color="#990000">　我　们　为　您　提　供　优　质　的　服　务！</font></td>
  </tr>
</table>
<br>
<br>
<!--#include virtual="/inc-freehost-function/template-emailadm-end.asp"-->
<%end if
if ef then
Response.Redirect "e.asp?e="&ec
end if%>