<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunction.asp"-->
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<%'on error resume next
 
If session("admau")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。"
ElseIf RegExpTest("[^A-Za-z0-9]",Request ("password")) Then
	ef=True
	ec="FTP密码中有非法字符！"	
ElseIf not IsNumeric(Request("id"))  Then
	ef=True
	ec="产品ID应该是数字！"
ElseIf RegExpTest("[^A-Za-z0-9]",Request.Form ("username")) Then
	ef=True
	ec="用户名中有非法字符！"
ElseIf Request.Form ("newusername")<>"" and RegExpTest("[^A-Za-z0-9]",Request.Form ("newusername")) Then
	ef=True
	ec="转移用户名中有非法字符！"
Elseif Request.Form ("Submit")="马上转移" and Request.Form ("newusername")="" then
	ef=True
	ec="请输入转移用户名！"
elseIf session("canadmhostset")="" Then

if Request.Form ("Submit")="马上转移" and session("canadmhostch")="" then
	ef=True
	ec="您没有此操作的权限。"
end If

elseIf session("canadmhostset")="" and session("canadmhost")="" and session("canadmhostch")="" and session("canadmhostmidsub")="" and session("canadmhostmiddomain")="" and session("canadmhostmidcpu")="" and session("canadmhostmidrepay")="" and session("canadmhostdel")=""  and session("canadmhostoth")="" Then
	ef=True
	ec="您没有此操作的权限。"
end if



if not ef then
Set conn=Server.CreateObject("ADODB.Connection")
	conn.Open Application("FreeHostDBlink")
	Set dsph = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_NetCn where id='"&Request("id")&"'"
	dsph.Open Sql,conn,1,3
if dsph.Eof then
	ef=True
	ec="不存在的万网虚拟主机！"
end if
end If


if not ef then
	Set ds = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_USER where username='"&Request.Form ("username")&"'"
		if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
		ds.Open Sql,conn,1,3
if ds.eof then
	ef=True
	ec="用户不存在!"
end if
end if

if not ef then
If Request.Form ("newusername")<>"" then
	Set dsNew = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_USER where username='"&Request.Form ("newusername")&"'"
		if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
		dsNew.Open Sql,conn,1,3
if dsNew.eof then
	ef=True
	ec="要转移的用户不存在!"
end if
end if
end if

if not ef Then


starttime=dsph("starttime")
endtime=dsph("endtime")
repaymoney=dsph("repaymoney")
corewhat=dsph("corewhat")


	Set dspdl = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_NetCNProductlist where productid='"&dsph ("productid")&"'"
		dspdl.Open Sql,conn,1,1
If dspdl.Eof Then
	ef=True
	ec="不存在的产品类型！"
Else
'读取月付
PAY_Month=dspdl("PAY_Month")
PAY_Season=dspdl("PAY_Season")
PAY_halfyear=dspdl("PAY_halfyear")
PAY_Nextyear=dspdl("PAY_Nextyear")
PAY_2year=dspdl("PAY_2year")
PAY_3year=dspdl("PAY_3year")
PAY_4year=dspdl("PAY_4year")
PAY_5year=dspdl("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_2year and Request.Form ("year")<>PAY_3year and Request.Form ("year")<>PAY_4year and Request.Form ("year")<>PAY_5year and Request.Form ("year")<>PAY_Nextyear Then
	ef=True
	ec="请选择时间！"
end If
end If


if Request.Form ("Submit")="马上调整" Then
Dim starttime,temptime
if not ef then
olduser_money=ds("usermoney")
if Request.Form ("usermoney")="" then
cost=dspdl("usermoney")
cost=cost*Request.Form ("year")
else
cost=Clng(Request.Form ("usermoney"))
end If
if cost>ds("usermoney") then
	ef=True
	ec="很抱歉,用户的余额不足！共需:"&cost&"元"
end if
end If
if not ef then
'结束时间
oldtime=dsph("endtime")
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)

if trim(Request.Form ("endtime"))<>"" then temptime=Request.Form ("endtime")
end if


if not ef then

'开始扣费
ds("usermoney") =ds("usermoney") -cost
ds.update
'更新产品类别
'dsph ("Hosttype")=dshost("Hosttype")
'if dsph("istest")="y" then
starttime=dsph ("endtime")

dsph ("endtime")=temptime
dsph("emailstatus")=Null
dsph("smsstatus")=null


'end if
dsph.update
newuser_money=ds("usermoney")
temptime=dsph("endtime")
moneych=-cost

pdtype=dsph("productid")
logfor="超级管理员延期万网主机产品:"&dsph("ftpname")
'if trim(Request.Form ("starttime"))<>"" then logfor="超级管理员修改开通host时间原时间:"&starttime&"新时间:"&Request.Form ("starttime")
'if trim(Request.Form ("starttime"))<>"" then dsph ("starttime")=Request.Form ("starttime")

FreeHost_moneyNewlog conn,"y","n","y","n","n",isAgnHostSer,-moneych,dsph ("username"),session("admusername"),dsph ("username"),olduser_money,newuser_money,agnusername,agnStmoney,agnEndmoney,session("admusername"),"管理员延期万网主机产品",logfor,"万网主机产品",dsph("id"),pingzheng,type1,bank,haveget,havecheck
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="&Request.Form ("year")

			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("admusername"),"失败","万网主机:"&dsph("id")&"<br>"&retdns
			Else
				FreeHost_oplog session("admusername"),"信息","万网主机："&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
End if
end if


if not ef then
%>
<!--#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" onClick="t1.style.display='';"><a href="netcnhost1.asp"><font color="#FFFFFF">主机管理</font></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">
	  
	  
<%
if Request.Form ("Submit")="马上调整" Then
response.write "操作完成<br>"
response.write "本系统中到期时间："&temptime&"<br>"
response.write "万网中的到期时间："&deaddate&"<br>已同步为万网的到期时间"
FreeHost_oplog session("admusername"),"信息","管理员改万网主机时间：本系统"&temptime&" 万网系统"&deaddate&" 产品ID:"&dsph("id")&"FTP名："&dsph("ftpname")
End If

if Request.Form ("Submit")="重设FTP密码" Then

Ftppassword=Trim(Request ("password"))
if Request ("password")="" Then
response.write "密码不能为空!"
response.End
End if
			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			="changepwd"
			
			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&"&password="&Ftppassword

			retdns=LIT_RetrunStr("http://api.hichina.com/wwwnetcn.aspx",vsendStr)
dsph("Ftppassword")=Ftppassword
response.write "设置成功新密码："&Ftppassword&"<br>万网返回:"&retdns
dsph.update
dsph.close
end if




if Request.Form ("Submit")="马上转移" Then

FreeHost_oplog session("admusername"),"信息","管理员转移"&dsph ("username")&"万网主机产品FTP名("&dsph ("Ftpname")&") 给"&Request.Form ("newusername")

dsph("username")=Request.Form ("newusername")
response.write "产品已转移到用户："&Request.Form ("newusername")&" 名下。<br>"
'if Request.Form ("changeagn")="y" then
dsph("agent1")=dsNEW("agent1")
if dsph("agent1")<>"n" then
response.write "产品已转移到代理："&dsph("agent1")&" 名下。<br>"
end If
dsph.update
dsph.close

end If


if Request.Form ("Submit")="删除" Then
FreeHost_oplog session("admusername"),"信息","管理员删除"&dsph ("username")&"万网主机产品FTP名("&dsph ("Ftpname")&")"
response.write "删除成功："&dsph ("username")&"万网主机产品FTP名("&dsph ("Ftpname")&")<br>"
dsph.delete
dsph.update
dsph.close
end If
%>	  
	  
	  </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%>
