<%@ 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("id")="" Then
	ef=True
	ec="请选择产品！"
ElseIf not IsNumeric(Request("id"))  Then
	ef=True
	ec="产品ID应该是数字！"
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 username='"&session("username")&"' and 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,1
if dsdom.eof then
	ef=True
	ec="不存在的域名！"
end if
end if

if not ef then
Enddomaintypeid=GetDomaintype(dsdom("Domain"))
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
domainRepayAPI=dsdom("Domain_API")
usermoney=dsDlist("usermoneyrepay")
If domainRepayAPI<>1 Then usermoney=dsDlist("usermoneyrepay"&domainRepayAPI)'api
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='"&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
if ds("agent1")<>"n" then
  Set dsagent = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_AGENT where username='"&ds("agent1")&"'"
		dsagent.Open Sql,conn,1,3
If dsagent.Eof Then
		ef=True
		ec="代理会员名不存在或密码出错了！"
end if
end if
end if

if not ef then
if ds("agent1")<>"n" then
	Set dsagnpri = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Agent_price where prtype='域名产品' and username='"&ds("agent1")&"' and id="&dsDlist("id")&""
		dsagnpri.Open Sql,conn,1,1
if dsagnpri.eof then
myrealcost=dsDlist("usermoneyagnrepay")
else
myrealcost=dsagnpri("usermoneyrepay")
end if
dsagnpri.close
	Set dsendmoney = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Agent_user_price where prtype='域名产品' and username='"&ds("agent1")&"' and id="&dsDlist("id")&""
		dsendmoney.Open Sql,conn,1,1
'		response.write sql
if dsendmoney.eof then
usermoney=dsDlist("usermoneyrepay")
If domainRepayAPI<>1 Then usermoney=dsDlist("usermoneyrepay"&domainRepayAPI)'api
else
usermoney=dsendmoney("usermoneyrepay")
If domainRepayAPI<>1 Then
If Not IsNull(dsendmoney("usermoneyrepay"&domainRepayAPI)) Then usermoney=dsendmoney("usermoneyrepay"&domainRepayAPI)'api
End if
end if
dsendmoney.close
end If'是代理名下用户的处理办法
end if

'if not ef then
'cost=usermoney*yearstr
'cost=usermoney
'if cost>ds("usermoney") and havehostget=false then
'	ef=True
'	ec="很抱歉,您的余额不足！您共需支付："&cost&" 元"
'end if
'end if

if not ef then
%>
<!--#include virtual="/inc-freehost-function/htmlwrite.asp"--><%=htmlwrite("html2")%>
　域名续费
<%=htmlwrite("html3")%>
<br><br>
域名：<%=dsdom("domain")%><br>
<br> 
金额：<%=usermoney%> 元/年
<%if session("AgnRunasUser") then%>　　<font color=red>(代理成本价格
<%

	Set dsagnpri = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Agent_price where prtype='域名产品' and username='"&ds("agent1")&"' and id="&dsDlist("id")&""
'		response.write sql
		dsagnpri.Open Sql,conn,1,1
if dsagnpri.eof Or (IsNull(dsagnpri("usermoneyrepay")) And domainRepayAPI=1) Or (IsNull(dsagnpri("usermoneyrepay2")) And domainRepayAPI=2) Or (IsNull(dsagnpri("usermoneyrepay3")) And domainRepayAPI=3) Or (IsNull(dsagnpri("usermoneyrepay4")) And domainRepayAPI=4) Or (IsNull(dsagnpri("usermoneyrepay5")) And domainRepayAPI=5) Or (IsNull(dsagnpri("usermoneyrepay6")) And domainRepayAPI=6) then
usermoney=dsDlist("usermoneyagnrepay")
If domainRepayAPI<>1 Then usermoney=dsDlist("usermoneyagnrepay"&domainRepayAPI)'api
else
usermoney=dsagnpri("usermoneyrepay")
If domainRepayAPI<>1 Then usermoney=dsagnpri("usermoneyrepay"&domainRepayAPI)'api
end If

dsagnpri.close
%><%=usermoney%>元)</font><%End if%>

<%
if Application("cnrepay")=true then
if Enddomaintypeid=2 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%>
<br>
<br>您的域名<%=dsdom("domain")%>的注册时间为：<%=dsdom("starttime")%>，到期时间为：<%=dsdom("endtime")%>，如果您现在再续费一年，就会符合CNNIC新的续费政策，只需要支付5元就可以续费一年。(续费多年没有此优惠)
<%End if
End if
end if
%>
<br>
<br>
请您选择续费的年限：
<form name="autoopen" method="post" action="domain_repay2.asp">
  <select name="years" id="years">
    <option value="1" selected>一年</option>
    <option value="2">二年</option>
    <option value="3">三年</option>
    <option value="4">四年</option>
    <option value="5">五年</option>
  </select>
  <input name="id" type="hidden" value="<%=Request("id")%>">
  <input type="submit" name="openX" value="马上续费"  onClick="document.autoopen.openX.value ='请等待不要重复刷新！....';document.autoopen.openX.disabled=true;document.autoopen.submit()">
</form>
<%=htmlwrite("html4")%>
<%end if
if ef then
Response.Redirect "e.asp?e="&ec
end if%>
