<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunction.asp"-->
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<!--#include virtual="/inc-freehost-function/FreeHostDomain.asp"-->
<!--#include virtual="/inc-freehost-function/ZPapi.asp"-->
<!--#include virtual="/inc-freehost-function/xml.cls.asp"-->
<%
If session("admau")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。"
elseIf session("candomainpay")="" Then
	ef=True
	ec="您没有此操作的权限。"
ElseIf Request("id")="" Then
	ef=True
	ec="请选择产品！"
ElseIf not IsNumeric(Request("id"))  Then
	ef=True
	ec="产品ID应该是数字！"
ElseIf not IsNumeric(Request("years"))  Then
	ef=True
	ec="年限应该是数字！"
ElseIf IsNumeric(Request("years")) and (Request("years")>5 or Request("years")<1)  Then
	ef=True
	ec="年限不能大于四年！"
end if

if not ef then
Set conn=Server.CreateObject("ADODB.Connection")
	conn.Open Application("FreeHostDBlink")
Set dsdom = Server.CreateObject("ADODB.Recordset")
sql="Select * from FreeHost.FreeHost_Product_Domain where id='"&Request("id")&"'"
if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
	dsdom.Open sql,conn,1,3
if dsdom.eof then
	ef=True
	ec="不存在的域名！"
end if
end if

if not ef then
if dsdom("status")<>"正常" And dsdom("status")<>"续费失败" then
	ef=True
	ec="只有处于正常状态的域名才能续费。"
end if
end if

if not ef Then
Dim enc
Enddomaintypeid=GetDomaintype(dsdom("Domain"))
end if

If Not ef Then
If Enddomaintypeid=2 Or Enddomaintypeid=3 Then
'If dsdom("endtime")<Now Then
'	ef=True
'	ec="这个域名已过期，请联系管理员手工帮您续费。"
'End if
End if
End if

if not ef then
	Set dsDlist = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_DomainProductlist where id='"&Enddomaintypeid&"'"
		dsDlist.Open Sql,conn,1,1
if dsDlist.eof then
	ef=True
	ec="管理员没有定义域名的价格，请联系管理员！"
else
usermoney=dsDlist("usermoneyrepay")
myrealcost=dsDlist("usermoneyagnrepay")
end if
end if

if not ef then
	Set ds = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_USER where username='"&dsdom("username")&"'"
		ds.Open Sql,conn,3,2
if ds.eof then
	ef=True
	ec="用户不存在!"
end if
end if


if not ef then
yearstr=Request("years")
end if

If Not ef Then
Dim cnrepay
cnrepay=false
if Application("cnrepay")=true then
if Enddomaintypeid=2 And Clng(yearstr)=1 Then
If dsdom("starttime")>CDate(#2007-3-7 12:00:00#) and dsdom("starttime")<CDate(#2008-12-31 23:59:59#) And dsdom("endtime")>CDate(#2008-3-7 12:00:00#) and dsdom("endtime")<CDate(#2009-12-31 23:59:59#) and now<CDate(#2010-3-1 00:00:01#) Then
cnrepay=true
End if
End if
end If
end If

if not ef then
if dsdom("Domain_API")<>1 and dsdom("Domain_API")<>2 and dsdom("Domain_API")<>3 and dsdom("Domain_API")<>4  and dsdom("Domain_API")<>5  And dsdom("Domain_API")<>6 And dsdom("Domain_API")<>7 then
	ef=True
	ec="非法API！"
end if
end if

if not ef then
if DateDiff("s", Application("domainoptime"),NOW )<Application("domainopmax") and Application("domainoplock")=true then
'	ef=True
	ec="系统繁忙，前一个操作尚未处理完，请您稍等两分钟后再试，谢谢您的支持。"
end if
end if

if not ef then
Application.lock
Application("domainoptime")=now
Application("domainoplock")=true
Application.unlock
dim starttime,temptime,pdtype
starttime=dsdom("endtime")
pdtype=dsdom("Domain")

oldtime=dsdom("endtime")
tend=dsdom("endtime")
temptime=dateadd("yyyy",yearstr,tend)

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,RsDlist,isreplay,domainRepayAPI
isreplay=true
set RsDlist=dsDlist
Userpaymoney=dsDlist("usermoneyrepay")'续费价
domainRepayAPI=dsdom("Domain_API")
If domainRepayAPI<>1 Then Userpaymoney=dsDlist("usermoneyrepay"&domainRepayAPI)'api
if havehostget=false then
forpayyear=yearstr
else
forpayyear=999
end if
set RsUserds=ds
Useragentname=ds("agent1")
forpaytype="域名产品"
forpayid=dsDlist("id")
logfor="管理区续费(域名"&dsdom("Domain")&")"
pubisagnSer=isAgnHostSer
AgnRunasUser=session("AgnRunasUser")
AgnRunasUser=false'管理区
session("moneylog_pdid")=dsdom("id")
DoPayMoneyDomain
Application.lock
Application("domainoplock")=false
Application.unlock
end if

if not ef Then
dsdom("status")="续费失败"
dsdom.update
Application.lock
Application("domainoptime")=now
Application("domainoplock")=true
Application.unlock


dim returncodevalue,failreason
RepayDomainNow()
dsdom.update
Application.lock
Application("domainoplock")=false
Application.unlock
end if


if not ef Then
dsdom("status")="正常"
dsdom("endtime")=temptime
dsdom("emailstatus")=Null
dsdom("smsstatus")=null
dsdom.update




'email
'开通邮箱
	Set dsemailpdlist = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_EmailProductlist where Domaintype='"&dsDlist("Domaintype")&"' and isbydomain='y'"
	dsemailpdlist.Open Sql,conn,1,1
if not dsemailpdlist.Eof then
Set dsphemail = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Product_Email where bydomain='"&dsdom("id")&"'"
	dsphemail.Open Sql,conn,1,3
if not dsphemail.Eof then
dsphemail("endtime")=temptime
dsphemail.update
FreeHost_oplog session("admusername"),"信息","管理员操作域名延期，域名赠送邮箱产品自动延期 ID:"&dsphemail("id")
retemail="赠送的邮箱产品已延期"
dsphemail.close
end if
end if

%>
<!--#include virtual="/inc-freehost-function/htmlwrite.asp"--><%=htmlwrite("html8")%>
<%=htmlwrite("html9")%>
<TABLE width="100%" border=0 cellPadding=0 cellSpacing=0 background="img/midtop4.gif">
  <TBODY>
    <TR>
      <TD width=53 align="left" background="img/midtop1.gif"><strong> 　 </strong><font color="#FFFFFF">─<strong>&gt;</strong></font> </TD>
      <TD width="83"><table height="59"  border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td width="7" background="img/midtop.gif">&nbsp;</td>
            <td width="60" align="center" valign="middle" background="img/r3.jpg" id="tableTop1" style="Cursor:hand"><a href="listmydomain.asp"><font color="#FFFFFF">域名管理</font></a><a href="systeminfo.asp"></a><a href="logininfo.asp"></a></td>
            <td width="5" background="img/midtop2.gif">&nbsp;</td>
          </tr>
      </table></TD>
      <TD width="83">&nbsp;</TD>
      <TD width="83">&nbsp;</TD>
      <TD width="83" align="left">&nbsp;</TD>
      <TD align="left">&nbsp;</TD>
      <TD width=23 align="right"><IMG height=59 
                  src="img/rtop4.jpg" 
                  width=19></TD>
    </TR>
  </TBODY>
</TABLE>
<TABLE width="100%" border=0 cellPadding=0 cellSpacing=0>
  <TBODY>
    <TR>
      <TD width=19 background="img/midlef.gif" id=rightid>&nbsp;</TD>
      <TD height="300" align="center" vAlign=top bgcolor="#FFFFFF"><br>
<%response.flush()%>
<br>
<DIV class="tableborder">
<table width="65%"  border="0" align="center" cellpadding="0" cellspacing="1" bordercolor="#FF0000">
  <tr align="center" bordercolor="#000000" background="img/tablebg.gif">
    <td height="24" colspan="4"><font color="#000000">　　　</font><font color="#FFFFFF">恭喜域名延期成功，以下是您的资料：</font></td>
  </tr>
  <tr bordercolor="#000000" bgcolor="#E4EAF2">
    <td width="44%" height="30"><font color="#000000"> 　　　 用户的原金额：</font></td>
    <td width="56%" colspan="3"><%=olduser_money%> 元</td>
  </tr>
  <tr bordercolor="#000000" bgcolor="#E4EAF2">
    <td height="41"><font color="#000000">　　　 用户的金额变化：</font></td>
    <td colspan="3"><font color=red><%=moneych%> 元</font></td>
  </tr>
  <tr bordercolor="#000000" bgcolor="#E4EAF2">
    <td height="39"><font color="#000000">　　　 用户的新金额：</font></td>
    <td colspan="3"><font color="#000000"><%=newuser_money%> 元</font></td>
  </tr>
  <tr bordercolor="#000000" bgcolor="#E4EAF2">
    <td height="37"><font color="#000000">　　　 原来的到期时间是:</font></td>
    <td colspan="3"><%=oldtime%></td>
  </tr>
  <tr bordercolor="#000000" bgcolor="#E4EAF2">
    <td height="37"><font color="#000000"> 　　　 现在的到期时间是:</font></td>
    <td colspan="3"><%=temptime%>　<a href="/style/info/whois.asp?domain=<%=dsdom("Domain")%>">（此到期时间尚未确认，请您48小时后访问以下网址确认）</a></td>
  </tr>
</table>
</div>

</TD>
      <TD width=18 background="img/midri.gif">&nbsp;</TD>
    </TR>
  </TBODY>
</TABLE>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY>
    <TR>
      <TD width=30><IMG height=19 
                  src="img/rb1.jpg" 
                  width=30></TD>
      <TD 
                background=img/rb2.jpg>&nbsp;</TD>
      <TD width=30><IMG height=19 
                  src="img/rb3.jpg" 
                  width=30></TD>
    </TR>
  </TBODY>
</TABLE>

<%=htmlwrite("html10")%>
<%end if
if ef then
Response.Redirect "e.asp?e="&ec
end if%>
