<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostEmail.asp"-->
<!--#include virtual="/inc-freehost-function/FreeHostFunction.asp"-->
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMoney.asp"-->
<%
If session("username")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。"
ElseIf Request ("id")="" Then
	ef=True
	ec="请输入产品ID！"
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")



username=session("username")
agentname=session("agentname")
AgnRunasUser=session("AgnRunasUser")
If session("agentusername")<>"" Then
agentname=session("agentusername")
username=session("agentusername")
AgnRunasUser=True
End If

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

	Set dsph = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_NetCN where id='"&Request("id")&"' and username='"&username&"'"
			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
If dsph("status")<>"正常" Then
	ef=True
	ec="处于正常状态的产品才能延期！"
end if
End If

If not ef then
	Set dsNetCNpdlist = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_NetCNProductlist where productid='"&dsph ("productid")&"'"
	dsNetCNpdlist.Open Sql,conn,1,1
if dsNetCNpdlist.Eof then
	ef=True
	ec="产品不存在！"
Else
'读取月付
PAY_Month=dsNetCNpdlist("PAY_Month")
PAY_Season=dsNetCNpdlist("PAY_Season")
PAY_halfyear=dsNetCNpdlist("PAY_halfyear")
PAY_Nextyear=dsNetCNpdlist("PAY_Nextyear")
PAY_2year=dsNetCNpdlist("PAY_2year")
PAY_3year=dsNetCNpdlist("PAY_3year")
PAY_4year=dsNetCNpdlist("PAY_4year")
PAY_5year=dsNetCNpdlist("PAY_5year")
End If
End If

if not ef then
If 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

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,isRepaymoney,Repaymoney
set RsDlist=dsNetCNpdlist
Userpaymoney=dsNetCNpdlist("usermoney")
forpayyear=Request.Form ("year")
set RsUserds=ds
Useragentname=ds("agent1")
forpaytype="万网主机产品"
forpayid=dsNetCNpdlist("id")
logfor="用户区延期"
pubisagnSer=isAgnIDCSer
AgnRunasUser=session("AgnRunasUser")

If session("agentusername")<>"" Then AgnRunasUser=true

if not isnull(dsph("repaymoney")) and not isAgnHostSer then'管理员单独设置续费价格
logfor="用户区延期(单独价格)"
Repaymoney=dsph("repaymoney")
isRepaymoney=true
else
isRepaymoney=false
end if
DoPayMoneyIDC
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("emailstatus")=Null
dsph("smsstatus")=null
'end if
dsph.update

End if

if not ef then
			userid=Application("Domain_Agent_username_5")			'万网数字ID
			password		=Application("Domain_Agent_password_5")		'万网数字ID密码
			email			=Application("Domain_Agent_username_5_emamil")	'万网注册email
			vtime			= FormatDate(now())
			userstr			=md5(userid&password&email&vtime)

			category		="host"
			productid		=dsph("productid")
			action			="renew"
			
			vsendStr		="userid="&userid&"&userstr="&userstr&"&vtime="&vtime
			
			vsendStr		=vsendStr&"&category="&category
			vsendStr		=vsendStr&"&productid="&productid
			vsendStr		=vsendStr&"&action="&action
			
			vsendStr		=vsendStr&"&hostadminid="&dsph("ftpname")
			vsendStr		=vsendStr&"&vyear="&forpayyear

			retdns=LIT_RetrunStr("http://api.hichina.com/wwwnetcn.aspx",vsendStr)
dsph("retdns")=retdns
dsph.update

End if

if not ef then
			dim returncodevalue,failreason,sucdate,deaddate,hostadminid,hostpassword,volume,ipaddress,dbname,dbpassword,relatedname,os,icpstatus,porflag,idc
			xmlvalue(retdns)
			If Instr(retdns,"200")<=0 Then
				'retdns= "返回状态码:"&returncodevalue&" 原因:"&failreason
				ef=True
				ec="返回状态码:"&returncodevalue&" 原因:"&failreason
				FreeHost_oplog session("username"),"失败","万网主机:"&dsph("id")&"<br>"&retdns
			Else
				FreeHost_oplog session("username"),"信息","万网主机："&retdns&":"&dsph("id")
			End If	
End if

if not ef Then
'dsph("Ftppassword")=hostpassword
dsph("endtime")=deaddate
'dsph("volume")=volume
'dsph("ipaddress")=ipaddress
'dsph("dbname")=dbname
'dsph("dbpassword")=dbpassword
dsph.Update

if session("agentusername")<>"" Then%>
<!--#include virtual="/inc-freehost-function/htmlwrite.asp"--><%=htmlwrite("html5")%>
<%else%>
<!--#include virtual="/inc-freehost-function/htmlwrite.asp"--><%=htmlwrite("html2")%>
<%End if%>
　 万网主机类延期
<%if session("agentusername")<>"" Then%>
<%=htmlwrite("html6")%>
<%else%>
<%=htmlwrite("html3")%>
<%End if%>
<br><br><br>
操作完成：<br>
万网中的开通时间：<%=sucdate%><br>
万网中的到期时间：<%=deaddate%><br>
<br><br><br>
<%If Instr(retdns,"200")>0 Then%>操作成功<%End if%>
<br><br><br>
<%if session("agentusername")<>"" Then%>
<%=htmlwrite("html7")%>
<%else%>
<%=htmlwrite("html4")%>
<%End if%>
<%end if
if ef then
Response.Redirect "e.asp?e="&ec
end if%>
