<%
Function RegExpTest(patrn, strng)
  Dim regEx
  Set regEx = New RegExp
  regEx.Pattern = patrn
  regEx.IgnoreCase = False
  RegExpTest = regEx.Test(strng)
End Function 

Function ONLY_GET(tar)
Dim returnstr
ref=""
Set xml = Server.CreateObject("Msxml2.ServerXMLHTTP.3.0")
xml.setTimeouts FreeHost_t1, FreeHost_t2, FreeHost_t3, FreeHost_t4
xml.Open "GET", tar, False
xml.setRequestHeader "UserAgent","Mozilla/2.0 (compatible; MSIE 5.0B; Windows NT)"
xml.send
returnstr = bytes2BSTR(xml.responsebody)
ONLY_GET = returnstr
End Function

Function bytes2BSTR(vIn)
    strReturn = ""
    For i = 1 To LenB(vIn)
        ThisCharCode = AscB(MidB(vIn,i,1))
        If ThisCharCode < &H80 Then
            strReturn = strReturn & Chr(ThisCharCode)
        Else
            NextCharCode = AscB(MidB(vIn,i+1,1))
            strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + Clng(NextCharCode))
            i = i + 1
        End If
    Next
    bytes2BSTR = strReturn
End Function

'If session("username")="" Then
'ef=TRUE
'response.write "errorA"
'response.end
'end If

If Trim(LCase(Request("ftpname")))="" or RegExpTest("[^A-Za-z0-9]",Request("ftpname")) Then
ef=TRUE
response.write "errorB"
response.end
End if


'验证会员资格
If not ef then
Set conn=Server.CreateObject("ADODB.Connection")
	conn.Open Application("FreeHostDBlink")
If Request("isagentpd")="" then
  Set dsreg = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Product_Host where ftpname='"&Trim(LCase(Request("ftpname")))&"'"
'Response.Write sql
		if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
		dsreg.Open Sql,conn,1,1
If dsreg.Eof Then
response.write "ok"
Else
response.write "errorC"
end If
dsreg.close
else
'查询上级URL
if IsNumeric(Request("pdid"))  Then
	Set dshost = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_HostProductlist where id='"&Request("pdid")&"'"
'	Response.write sql
	dshost.Open Sql,conn,1,1
if Not dshost.Eof Then
'response.write "http://"&dshost("VPSApiName")&"/api/checkvpsname.asp?vpsname="&Request("vpsname")
'http://127.0.0.1/api/checkvpsname.asp?isagentpd=yes&pdid=2&vpsname=kjkljkl
'调用xml查上级
If ONLY_GET("http://"&dshost("HostApiName")&"/api/checkftpname.asp?ftpname="&Request("ftpname"))="ok" Then
response.write "ok"
Else
response.write "errorE"
End if

else
response.write "errorD"'不存在ID
End If

dshost.close
Else
response.write "errorC"'不是合法ID
End If

End if
conn.Close
set conn=nothing
end if

%>