<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostEmail.asp"-->
<!--#include virtual="/inc-freehost-function/FreeHostFunction.asp"-->
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<%
server.ScriptTimeout =240
If session("admau")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。"
ElseIf Request.Form ("username")="" Then
	ef=True
	ec="请输入用户名！"
ElseIf RegExpTest("[^A-Za-z0-9]",Request.Form ("username")) Then
	ef=True
	ec="用户名中有非法字符！"
ElseIf RegExpTest("[^A-Za-z0-9]",Replace(Request ("productid"),"_","")) Then
	ef=True
	ec="用户名中有非法字符！"
ElseIf Request.Form ("year")="" Then
	ef=True
	ec="请选择时间！"
ElseIf Request.Form ("domain")="" Then
	ef=True
	ec="请输入域名！"
ElseIf Request.Form ("os")="" Then
	ef=True
	ec="请选择操作系统！"
ElseIf Not IsDate(Request("deaddate")) And Request("deaddate")<>"" Then
	ef=True
	ec="录入的到期时间不对。"
ElseIf RegExpTest("[^A-Za-z0-9]",Request.Form ("hostadminid")) Then
	ef=True
	ec="FTP名中有非法字符！"
'ElseIf Not IsNumeric(Request.Form ("Hosttype")) then
'	ef=True
'	ec="产品类型有非法字符！"
elseIf session("canadmhostadd")="" Then
	ef=True
	ec="您没有此操作的权限。"
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='"&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
'	Set dsph = Server.CreateObject("ADODB.Recordset")	
'	Sql="Select * from FreeHost.FreeHost_Product_NetCN where Ftpname='"&trim(Request.Form ("Ftpname"))&"'"
'	dsph.Open Sql,conn,1,1
'if not dsph.Eof then
'	ef=True
'	ec="您输入的FTP用户名已存在，请另外输入一个！"
'end if
'dsph.close
end if


if not ef then
	Set dsNetCNpdlist = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_NetCNProductlist where productid='"&Request ("productid")&"'"
	if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
	dsNetCNpdlist.Open Sql,conn,1,1
if dsNetCNpdlist.Eof then
	ef=True
	ec="产品不存在！"
Else
productid=dsNetCNpdlist("productid")
end if
end If

if not ef Then
If productid="host_xiangyun_1" And Request.Form ("os")<>"host_xiangyun" Then
	ef=True
	ec="此类型产品只能选云类型操作系统！"
End If
If productid="host_xiangyun_2" And Request.Form ("os")<>"host_xiangyun" Then
	ef=True
	ec="此类型产品只能选云类型操作系统！"
End If
If productid="host_xiangyun_3" And Request.Form ("os")<>"host_xiangyun" Then
	ef=True
	ec="此类型产品只能选云类型操作系统！"
End If
If productid="host_xiangyun_4" And Request.Form ("os")<>"host_xiangyun" Then
	ef=True
	ec="此类型产品只能选云类型操作系统！"
End If
If productid="host_xiangyun_6" And Request.Form ("os")<>"host_xiangyun" Then
	ef=True
	ec="此类型产品只能选云类型操作系统！"
End If
If productid="host_xiangyun_7" And Request.Form ("os")<>"host_xiangyun" Then
	ef=True
	ec="此类型产品只能选云类型操作系统！"
End If
If productid="host_xiangyun_12" And Request.Form ("os")<>"host_xiangyun" Then
	ef=True
	ec="此类型产品只能选云类型操作系统！"
End If
end if

if not ef then
Set dsph = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_NetCN where username='"&ds ("username")&"'"
	dsph.Open Sql,conn,1,3
end if



if not ef Then


os=request("os")
If productid="host_xiangyun_1" Then OS=productid
If productid="host_xiangyun_2" Then OS=productid
If productid="host_xiangyun_3" Then OS=productid
If productid="host_xiangyun_4" Then OS=productid
If productid="host_xiangyun_6" Then OS=productid
If productid="host_xiangyun_7" Then OS=productid
If productid="host_xiangyun_12" Then OS=productid

dim Subject,body'send mail

starttime=NOW

'结束时间
y=Request.Form ("year")
temptime=dateadd("yyyy",y,now)




dsph.AddNew
dsph("username")=ds ("username")
dsph("Ftpname")="未设置"
'dsph("Ftppasswordword")=Ftppasswordword
'dsph("volume")=request("volume")
'dsph("ipaddress")=request("ipaddress")
'dsph("dbname")=request("dbname")
'dsph("dbpassword")=request("dbpassword")
dsph("starttime")=starttime
dsph("endtime")=temptime
dsph("Domain")=Trim(request("Domain"))
dsph("category")="host"
dsph("productid")=productid
dsph("os")=OS
dsph("idc")=request("idc")
dsph("vyear")=request("year")
'dsph("amount")=request("amount")
dsph("status")="正常"
dsph("corewhat")=Request.Form ("corewhat")
if ds("agent1")<>"n" then
dsph("agent1")=ds("agent1")
else
dsph("agent1")="n"
end If
dsph("agent2")="n"



			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		=request("productid")
			action			="activate"
			
			vsendStr		="userid="&userid&"&userstr="&userstr&"&vtime="&vtime
			
			vsendStr		=vsendStr&"&category="&category
			vsendStr		=vsendStr&"&productid="&productid
			vsendStr		=vsendStr&"&action="&action
			
			vsendStr		=vsendStr&"&domain="&server.URLEncode(Trim(request("Domain")))
If dsph("vyear")=0.1 Then vsendStr		=vsendStr&"&vmonth="&(10*dsph("vyear"))
If dsph("vyear")=0.2 Then vsendStr		=vsendStr&"&vmonth="&(10*dsph("vyear"))
If dsph("vyear")=0.3 Then vsendStr		=vsendStr&"&vmonth="&(10*dsph("vyear"))
If dsph("vyear")=0.4 Then vsendStr		=vsendStr&"&vmonth="&(10*dsph("vyear"))
If dsph("vyear")=0.5 Then vsendStr		=vsendStr&"&vmonth="&(10*dsph("vyear"))
If dsph("vyear")=0.6 Then vsendStr		=vsendStr&"&vmonth="&(10*dsph("vyear"))
If dsph("vyear")>0.9 Then vsendStr		=vsendStr&"&vyear="&dsph("vyear")
			vsendStr		=vsendStr&"&os="&server.URLEncode(OS)
			vsendStr		=vsendStr&"&idc="&server.URLEncode(request("idc"))
			'vsendStr=LIT_URLEncoding(vsendStr)

				'		Response.Write vsendStr
				'		Response.End
If Request.Form ("onlyadd")="" then
			retdns=LIT_RetrunStr("http://api.hichina.com/wwwnetcn.aspx",vsendStr)
'			retdns=LIT_RetrunStr("http://api.hichina.com:8081/wwwnetcn.aspx",vsendStr)

If retdns="" then
	ef=True
	ec="操作失败，可能的原因是您服务器连接万网的网络不正常"
	retdns=ec
	FreeHost_oplog session("username"),"失败","开通万网主机时由于网络不正常等原因操作失败:"&dsph("Domain")
	dsph.cancel
end If

End if

end if

If Not ef Then

If Request.Form ("onlyadd")="" then
dsph("retdns")=retdns

			dim returncodevalue,failreason,sucdate,deaddate,hostadminid,hostpassword,volume,ipaddress,dbname,dbpassword
			xmlvalue(retdns)
			If Instr(retdns,"200")<=0 Then
				retdns= "返回状态码:"&returncodevalue&" 原因:"&failreason
				ef=True
				ec=retdns
				FreeHost_oplog session("username"),"失败","万网主机:"&dsph("id")&"<br>"&retdns
				dsph.cancel
			Else
				FreeHost_oplog session("username"),"信息","万网主机："&retdns&":"&dsph("id")
			End If		
Else
hostadminid=Request.Form ("hostadminid")
Ftppassword=Request.Form ("Ftppassword")
volume=Request.Form ("volume")
ipaddress=Request.Form ("ipaddress")
deaddate=Request.Form ("deaddate")
dsph("retdns")="管理员只录入数据，不向万网提交"&"ID:"&dsph("id")&" ftp名："&hostadminid
FreeHost_oplog session("username"),"信息","万网主机："&dsph("retdns")&":"&dsph("id")
End if
end if

If Not ef Then


dsph("ftpname")=hostadminid
dsph("Ftppassword")=hostpassword
dsph("volume")=volume
dsph("ipaddress")=ipaddress
'dsph("dbname")=dbname
'dsph("dbpassword")=dbpassword
dsph("endtime")=deaddate
dsph.Update

olduser_money=ds("usermoney")
ds("usermoney")=ds("usermoney")-Request.Form ("usermoney")
moneych=-Request.Form ("usermoney")
ds.update
newuser_money=ds("usermoney")

	Set dsph = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_NetCN where username='"&ds ("username")&"' and Ftpname='"&hostadminid&"' order by id desc"
	dsph.Open Sql,conn,1,3



pdtype=dsNetCNpdlist("Hosttype")

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"),"管理员新万网建虚拟主机(FTP名"&dsph("ftpname")&")","管理员新建万网虚拟主机(FTP名"&dsph("ftpname")&")","虚拟主机",dsph("id"),pingzheng,type1,bank,haveget,havecheck




%>
<!--#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 align="left"><table height="59"  border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td width="7" background="img/midtop.gif">&nbsp;</td>
          <td width="90" align="center" valign="middle" background="img/r3.jpg" id="tableTop1" style="Cursor:hand"><a href="netcnhost1.asp"><font color="#FFFFFF"><strong>万网主机管理</strong></font></a></td>
          <td width="5" background="img/midtop2.gif">&nbsp;</td>
        </tr>
      </table></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">
<table width="65%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>
	<br>
<DIV class="tableborder"><br>
<br>
万网API返回信息：
<%
'调用开通function

'	dsph("status")="正常"


response.write returncodevalue
'FreeHost_oplog session("admusername"),"信息","管理员开通虚拟主机: "&temp



If Application("smshostopen")=True And (ds("agent1")="n" Or Application("agncangetsms")=True) Then
Dim username
username=ds("username")
mobi=Trim(ds("mobi"))
smsContent=Application("smshostopencon")
'恭喜！您的虚拟主机已开通了！用户名 ：#用户名# FTP地址：#FTP地址#服务器IP ：#IP#FTP用户名 ：#FTP#FTP密码 ：#FTP密码#到期时间是 ：#到期时间#您的帐户余款是 ：#金额# 元
smsContent=Replace(smsContent,"#用户名#",ds("username"))
smsContent=Replace(smsContent,"#FTP地址#",dsph("domain"))
smsContent=Replace(smsContent,"#IP#",dsph("ipaddress"))
smsContent=Replace(smsContent,"#FTP#",dsph("ftpname"))
'smsContent=Replace(smsContent,"#FTP密码#",dsph("Ftppassword"))
smsContent=Replace(smsContent,"#到期时间#",formatdatetime(dsph("endtime"),1))
smsContent=Replace(smsContent,"#金额#",newuser_money)
ret=SendSms(mobi,smsContent,0,Now,"")
End if

'dsph.close

'dim Subject,body
'EmailUserHOSTOpen
'ret=Send2Mail(conn,ds("username"),Subject,body)


%>
<br>
<br>

</div>
	
	</td>
  </tr>
</table>

<br>
<table width="65%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>
	
	
	<br><DIV class="tableborder">
<table width="100%"  border="0" align="center" cellpadding="2" cellspacing="1">
  <tr align="center" bordercolor="#000000" bgcolor="#999999">
    <td height="24" colspan="4" background="img/tablebg.gif"><font color="#990000"><font color="#FFFFFF">虚拟主机开通成功，以下是相关的资料</font></font></td>
  </tr>
  <tr bordercolor="#000000" bgcolor="#E4EAF2">
    <td width="53%" height="30"><font color="#000000"> 　　　 用户的原金额：</font></td>
    <td width="47%" colspan="3"><font color="#000000"><%=olduser_money%>元</font></td>
  </tr>
  <tr bordercolor="#000000" bgcolor="#E4EAF2">
    <td height="41"><font color="#000000">　　　 用户的金额变化：</font></td>
    <td colspan="3"><font color=red><%=moneych%></font><font color=#FF0000> 元</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">　　　 FTP登陆用户名是：</font></td>
    <td colspan="3"><%=dsph("ftpname")%></td>
  </tr>
  <tr bordercolor="#000000" bgcolor="#E4EAF2">
    <td height="37"><font color="#000000"> 　　　 FTP密码是：</font></td>
    <td colspan="3"><%=dsph("Ftppassword")%></td>
  </tr>
  <tr bordercolor="#000000" bgcolor="#E4EAF2">
    <td height="42" colspan="4"><font color="#000000">　　　 </font><font color="#000000">用户的网址为：</font><font color="#000000"><a href="http://<%=dsph("Domain")%>" target=_blank><font color="#000000">http://<%=dsph("Domain")%></font></a></font></td>
  </tr>
  <tr bordercolor="#000000" bgcolor="#E4EAF2">
    <td height="40" colspan="4"><font color="#000000"> 　　　 用户的FTP地址是：<font color=red><%=dsph("ipaddress")%></font></font></td>
  </tr>
  <tr bordercolor="#000000" bgcolor="#E4EAF2">
    <td height="37"><font color="#000000"> 　　　 现在的到期时间是:</font></td>
    <td colspan="3"><%=temptime%></td>
  </tr>
    
  <tr bordercolor="#000000" bgcolor="#E4EAF2">
    <td height="37" colspan="4" align="right" bgcolor="#E4EAF2"><font color="#000000"> 　　　</font><a href="#top"><font color="#6B9EDE" face="Arial, Helvetica, sans-serif">Top↑</font></a>	</td>
    </tr>
<!--<%if request.Form("openmustre")="1" then%>
  <tr bordercolor="#000000">
    <td height="37" bgcolor="#eeeeee"><font color="#000000"> 　　　 网站暂停中:</font></td>
    <td colspan="3" bgcolor="#eeeeee">此网站未备案您设置了暂停。</td>
  </tr>
<%end if%>-->

</table>
	</div>

	</td>
  </tr>
</table>

</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%>
