<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunction.asp"-->
<%server.ScriptTimeout =5
	Response.Expires = -9999 
	Response.AddHeader "Pragma","no-cache"
	Response.AddHeader "cache-ctrol","no-cache"
If session("HOSTAUID")="" And session("username")="" And session("admau")="" And session("agentusername")="" Then
response.write "请先登陆"
response.end
End if
FreeHost_t1=20000
FreeHost_t2=20000
FreeHost_t3=30000
FreeHost_t4=240000

siteurl=Application("siteurl")

nametocheck=request("domain")

If request("domain")<>"" Then
nametocheck=GetDomainMain(nametocheck)
'response.write nametocheck
'response.end
 
hostname=trim(replace(nametocheck,"http://",""))
if hostname<>"" then hostname=ComX.idntoac_7i24_com(cstr(hostname))
hostnamecheck=replace(hostname,".","")
hostnamecheck=replace(hostnamecheck,"xn--","")
If RegExpTest("[^A-Za-z0-9--]",hostnamecheck) Then
response.contenttype="text/html;charset=GB2312"
response.write "请输入合法的域名！"
response.end
end if

response.contenttype="text/html;charset=GB2312"
'response.write 
'backuinfo=ICPCHECK_A(nametocheck,session("ICPCHECK_cookieA"))'2013-9-25取消
session("ICPCHECK_Domain")=nametocheck
session(session("ICPCHECK_Domain")&"_status")=false
End If'end domein enter

If request("getcode")<>"" then
response.contenttype="image/jpeg"
Response.BinaryWrite ICPCHECK_B(siteurl&"/getVerifyCode?"&Second(Now),siteurl&"/icp/publish/query/icpMemoInfo_showPage.action",session("ICPCHECK_cookieA"))
'ICPCHECK_B siteurl&"/getVerifyCode?"&Second(Now),siteurl&"/icp/publish/query/icpMemoInfo_showPage.action",session("ICPCHECK_cookieA")
End if'end getcode

If request("validateValue")<>"" then
returnstr=ICPCHECK_D(request("validateValue"),session("ICPCHECK_cookieA"))
response.write server.htmlencode(returnstr)
End if'end validateValue

If request("code")<>"" Then'realcheck
response.contenttype="text/html;charset=GB2312"
response.write "检查中，如果长时间没有结果请刷新重试："

returnstr=ICPCHECK_D(request("code"),session("ICPCHECK_cookieA"))
If InStr(returnstr,"true")>1 Then
response.write "验证码正确："
Else
response.write "<font color=blue>验证码不正确！请重新输入！</font>"
Response.end
End if
'response.write "验证码："&server.htmlencode(returnstr)

If session(session("ICPCHECK_Domain")&"_status")=TRUE Then
Response.write "备案成功!"



else
returnstr=ICPCHECK_C(request("code"),session("ICPCHECK_cookieA"))
If InStr(returnstr,"审核时间")<1 Then
response.write "验证码不对，或工信系统忙，请您刷新重试:->"'&server.htmlencode(returnstr)
'Response.write session("ICPCHECK_cookieA")
'session("ICPCHECK_cookieA")=""
End If

'response.write server.htmlencode(returnstr)

'response.write request("code")&session("ICPCHECK_cookieA")&replace(Replace(returnstr,"""",""),"'","")

if instr (returnstr,"已通过")>1 Or instr (returnstr,"已备案")>1 or instr (returnstr,"ICP备")>1 or instr (returnstr,"ICP证")>1 or instr (returnstr,"B2-20")>1 Or (Application("beianupsaok")=True And ((instr (returnstr,"审核中")>1 Or instr (returnstr,"审核阶段")>1 ))) then
session(session("ICPCHECK_Domain")&"_status")=true
Response.write "备案成功"
If (Application("beianupsaok")=True And ((instr (returnstr,"审核中")>1 Or instr (returnstr,"审核阶段")>1 ))) or instr (returnstr,"ICP备")>1 or instr (returnstr,"ICP证")>1 Or instr (returnstr,"B2-20")>1 Then
'Response.write "(系统设置了将审核中的域名作备案成功处理)"
'Else
'取得ICP_SN
If InStr(returnstr,"ICP证")Or InStr(returnstr,"B2-20") Then
Response.write "(经营性ICP证)"

If InStr(returnstr,"ICP证") Then
strary=Split(returnstr,"ICP证")
If UBound(strary)>0 Then
ICP_SN=Replace(Right(strary(0),1)&"ICP证"&left(strary(1),6),"号","")&"号"
strarywho=Split(strary(0),"</")
strarywho2=Split(strarywho(UBound(strarywho)-2),">")
ICP_Who=Trim(strarywho2(UBound(strarywho2)))
End If
End If

If InStr(returnstr,"B2-20") Then
strary=Split(returnstr,"B2-2")
If UBound(strary)>0 Then
ICP_SN=Right(strary(0),1)&"B2-2"&left(strary(1),20)
ICP_SN_ary=Split(ICP_SN,"<")
ICP_SN=ICP_SN_ary(0)
strarywho=Split(strary(0),"</")
strarywho2=Split(strarywho(UBound(strarywho)-2),">")
ICP_Who=Trim(strarywho2(UBound(strarywho2)))
End If
End If

Else
Response.write "(非经营性ICP备案)"
strary=Split(returnstr,"ICP备")
If UBound(strary)>0 Then
ICP_SN=Replace(Right(strary(0),1)&"ICP备"&left(strary(1),9),"号","")&"号"
strarywho=Split(strary(0),"</")
strarywho2=Split(strarywho(UBound(strarywho)-2),">")
ICP_Who=Trim(strarywho2(UBound(strarywho2)))
End if
End If
ICP_Who=Replace(ICP_Who,"&nbsp;","")
Response.write " ICP证号："&ICP_SN&" "&ICP_Who&" "


End if
'加入icpdb

 
hostname=trim(replace(session("ICPCHECK_Domain"),"http://",""))
if hostname<>"" then hostname=ComX.idntoac_7i24_com(cstr(hostname))
hostnamecheck=replace(hostname,".","")
hostnamecheck=replace(hostnamecheck,"xn--","")
If RegExpTest("[^A-Za-z0-9--]",hostnamecheck) Then
response.contenttype="text/html;charset=GB2312"
response.write "请输入合法的域名！也可能是本次操作已超时,请刷新IE重试."
response.End
Else
Set conn=Server.CreateObject("ADODB.Connection")
	conn.Open Application("FreeHostDBlink")
	Set dsICPDB = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_ICPDB where domain='"&session("ICPCHECK_Domain")&"'"
	dsICPDB.Open Sql,conn,1,3
if dsICPDB.Eof Then dsICPDB.addnew
'dsICPDB("username")=ds("username")
'dsICPDB("ftpname")=dsph("ftpname")
dsICPDB("domain")=session("ICPCHECK_Domain")
dsICPDB("status")="备案成功"
dsICPDB("firstaddtime")=Now
dsICPDB("checktime")=Now
If ICP_SN<>"" Then dsICPDB("ICP_SN")=ICP_SN
If ICP_Who<>"" Then dsICPDB("ICP_Who")=ICP_Who
response.write "域名信息已成功录入本地数据库"&session("ICPCHECK_Domain")
'dsph("alldomainok")=0
dsICPDB.update
'end If
dsICPDB.close
end If
Set dsICPDB=nothing
conn.close
Set conn=nothing

Response.end
End If
  if instr (returnstr,"未向系统报备")>1 Or instr (returnstr,"在备案库中不存在")>1 Or instr (returnstr,"未备案")>1 Or instr (returnstr,"没有符合条件的记录")>1 Then'没有符合条件的记录
  Response.write "未提交备案"
  Response.end
  End if
  if (instr (returnstr,"审核中")>1 Or instr (returnstr,"审核阶段")>1 ) Then
  Response.write "已提交备案，尚未备案成功"
  Response.end
  End if
  if instr (returnstr,"拒绝")>1 Then
  Response.write "备案被拒绝"
  Response.end
  End if

if instr (returnstr,"验证码输入错误")>1 then
Response.write "验证码输入错误!请刷新IE重试!"
Response.end
End If
if instr (returnstr,"not allowed")>1 then
Response.write "超时请刷新IE重试!"
Response.end
End if
'验证码输入错误
End If


End if'end realcheck


Function ICPCHECK_A(nametocheck,cookieIN)
body="wzmc=&cxfs=1&cxNr="&server.URLEncode(nametocheck)&"&syurl=&baxh=&ip=&dwmc=&xxdz="
ref=siteurl&"/chaxun/ggcx.jsp"
tar=siteurl&"/icp/publish/query/icpMemoInfo_showPage.action"
Set xml = Server.CreateObject("WinHttp.WinHttpRequest.5.1")
xml.Option(6)=0
xml.setTimeouts FreeHost_t1, FreeHost_t2, FreeHost_t3, FreeHost_t4
xml.Open "GET", tar, False
'xml.setRequestHeader "REFERER",ref
'xml.setRequestHeader "Content-Length",Len(body)
'xml.setRequestHeader "CONTENT-TYPE","application/x-www-form-urlencoded"
xml.setRequestHeader "Accept","text/html, application/xhtml+xml, */*"
xml.setRequestHeader "Accept-Language","en-US,en;q=0.8,zh-Hans-CN;q=0.5,zh-Hans;q=0.3"
xml.setRequestHeader "User-Agent","Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)"
'xml.setRequestHeader "Accept-Encoding","gzip, deflate"
xml.setRequestHeader "Accept-Encoding","none"
'xml.setRequestHeader "Cookie",cookieIN'新加4-11
xml.send' body
'Set-Cookie: JSESSIONID=15A669848C36ACB11BEE9577E3EFBA53; Path=/
session("ICPCHECK_cookieA") = xml.getResponseHeader("Set-Cookie")
session("ICPCHECK_cookieA") =left(session("ICPCHECK_cookieA"),instr(1,session("ICPCHECK_cookieA"),";")-1)
ICPCHECK_A = bytes2BSTR(xml.responsebody)
'Response.write bytes2BSTR(xml.responsebody)
Set xml = Nothing
End Function

Function ICPCHECK_B(tar,ref,cookieIN)
Set xml = Server.CreateObject("WinHttp.WinHttpRequest.5.1")
xml.Option(6)=0
xml.setTimeouts FreeHost_t1, FreeHost_t2, FreeHost_t3, FreeHost_t4
'xml.Open "GET", tar&"?"&session("ICPCHECK_cckey"), False
'Response.write tar
xml.Open "GET", tar, False
xml.setRequestHeader "Accept","text/html, application/xhtml+xml, */*"
xml.setRequestHeader "Accept-Language","en-US,en;q=0.8,zh-Hans-CN;q=0.5,zh-Hans;q=0.3"
xml.setRequestHeader "User-Agent","Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)"
'xml.setRequestHeader "Accept-Encoding","gzip, deflate"
'xml.setRequestHeader "User-Agent","Mozilla/2.0 (compatible; MSIE 5.0B; Windows NT)"
xml.setRequestHeader "Accept-Encoding","none"
xml.setRequestHeader "REFERER",ref
'xml.setRequestHeader "Cookie",cookieIN
xml.send
'Response.write xml.GetAllResponseHeaders
session("ICPCHECK_cookieA") = xml.getResponseHeader("Set-Cookie")
'cookiearytemp=Split(xml.GetAllResponseHeaders,"__jsluid=")
'cookiearytemp2=Split(cookiearytemp(1),"X-Cache")
'session("ICPCHECK_cookieA") =Replace(Replace(Replace("__jsluid="&cookiearytemp2(0),vbcrlf,""),"Set-Cookie: ",""),"path=/","")
'Response.write Replace(Replace(Replace("__jsluid="&cookiearytemp2(0),vbcrlf,""),"Set-Cookie: ",""),"path=/","")
'Response.end
'session("ICPCHECK_cookieA") = xml.getResponseHeader("Set-Cookie")
'session("ICPCHECK_cookieA") =left(session("ICPCHECK_cookieA"),instr(1,session("ICPCHECK_cookieA"),";")-1)
ICPCHECK_B = xml.responsebody
'Response.write bytes2BSTR(xml.responsebody)
'Response.end
Set xml = Nothing
End Function

Function ICPCHECK_C(vertifycodeg,cookieIN)
'siteName=&condition=1&siteDomain=sina.com.cn&siteUrl=&mainLicense=&siteIp=&unitName=&mainUnitNature=-1&certType=-1&mainUnitCertNo=&verifyCode=R8Y5J9
body="siteName=&condition=1&siteDomain="&session("ICPCHECK_Domain")&"&siteUrl=&mainLicense=&siteIp=&unitName=&mainUnitNature=-1&certType=-1&mainUnitCertNo=&verifyCode="&server.URLEncode(vertifycodeg)
'Response.write body
    'siteName=&condition=1&siteDomain=sina.com.cn&siteUrl=&mainLicense=&siteIp=&unitName=&mainUnitNature=-1&certType=-1&mainUnitCertNo=&verifyCode=f818
ref=siteurl&"/icp/publish/query/icpMemoInfo_searchExecute.action"
tar=siteurl&"/icp/publish/query/icpMemoInfo_searchExecute.action"
Set xml = Server.CreateObject("WinHttp.WinHttpRequest.5.1")
xml.Option(6)=0
xml.setTimeouts FreeHost_t1, FreeHost_t2, FreeHost_t3, FreeHost_t4
xml.Open "POST", tar, False
xml.setRequestHeader "Accept","text/html, application/xhtml+xml, */*"
xml.setRequestHeader "REFERER",ref
xml.setRequestHeader "Accept-Language","en-US,en;q=0.8,zh-Hans-CN;q=0.5,zh-Hans;q=0.3"
xml.setRequestHeader "User-Agent","Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)"
xml.setRequestHeader "Content-Type","application/x-www-form-urlencoded"
xml.setRequestHeader "Accept-Encoding","none"
xml.setRequestHeader "Content-Length",Len(body)
xml.setRequestHeader "Cache-Control","no-cache"
xml.setRequestHeader "Cookie",cookieIN
'xml.setRequestHeader "Accept-Encoding","gzip, deflate"
'Response.write cookieIN
xml.send body
'Response.write bytes2BSTR(xml.responsebody)
ICPCHECK_C = bytes2BSTR(xml.responsebody)
Set xml = Nothing
End Function

Function ICPCHECK_D(validateValue,cookieIN)
'validateValue=K73RV
body="validateValue="&server.URLEncode(validateValue)
'Response.write body
ref=siteurl&"/icp/publish/query/icpMemoInfo_showPage.action"
tar=siteurl&"/common/validate/validCode.action"
Set xml = Server.CreateObject("WinHttp.WinHttpRequest.5.1")
xml.Option(6)=0
xml.setTimeouts FreeHost_t1, FreeHost_t2, FreeHost_t3, FreeHost_t4
xml.Open "POST", tar, False
xml.setRequestHeader "Accept","text/html, application/xhtml+xml, */*"
xml.setRequestHeader "REFERER",ref
xml.setRequestHeader "X-Requested-With","XMLHttpRequest"
xml.setRequestHeader "Accept-Language","en-US,en;q=0.8,zh-Hans-CN;q=0.5,zh-Hans;q=0.3"
xml.setRequestHeader "User-Agent","Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)"
xml.setRequestHeader "Content-Type","application/x-www-form-urlencoded"
xml.setRequestHeader "Accept-Encoding","none"
xml.setRequestHeader "Content-Length",Len(body)
xml.setRequestHeader "Cache-Control","no-cache"
xml.setRequestHeader "Cookie",cookieIN
'xml.setRequestHeader "Accept-Encoding","gzip, deflate"
'Response.write cookieIN
xml.send body
'Response.write xml.GetAllResponseHeaders
ICPCHECK_D = bytes2BSTR(xml.responsebody)
Set xml = Nothing
End Function


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

%>
