asp通过传入域名判断域名绑定ip的函数

函数代码:

 function cxip(URL)//给出域名查询域名绑定的ip
  K=replace(URL,chr(13),"")
  K=split(K,chr(10))
  Stime=Timer()
  Set objWShell=CreateObject("WScript.Shell")
  Set objCmd=objWShell.Exec("ping "&url)
  StrPResult=objCmd.StdOut.Readall()
  Set objCmd=nothing
  Set objWShell=nothing
  IP=strCut(StrPResult,"[","]",2)
  If Err Then
  Err.Clear
  IP="此IP未知或域名不可用!"
  conn.execute("update FreeHost_Beian_Wz_xx set fwqip='"& ip &"' where id="& rs("id") &"")
  else
  Response.Write "服务器ip:"&ip
  ipss=split(ip,".")(0)&"."&split(ip,".")(1)&"."&split(ip,".")(2)
  set rs3=server.CreateObject("adodb.recordset")
  sql3="select ip from  newip where ip='"& ipss &"' "
  rs3.open sql3,conn,1,1
  if rs3.recordcount>0 then
  response.Write(" (在本公司接入)")
  conn.execute("update FreeHost_Beian_Wz_xx set fwqip='"& ip &"' where id="& rs("id") &"")
  conn.execute("update FreeHost_Beian_Wz_xx set isjieru=1 where id="& rs("id") &"")
  else
  response.Write(" (不在本公司接入)")
  conn.execute("update FreeHost_Beian_Wz_xx set fwqip='"& ip &"' where id="& rs("id") &"")
  end if
  rs3.close
  set rs3=nothing
  End if
  
  'Response.Write("您查询的域名:"&URL&"<br><br>IP地址为:"&IP&"<br>")
  'Response.Write("<p>"&Replace(StrPResult,vbCrLf,"<br>"))'输出详细内容
  'EndTime=Timer()
  'Response.Write("<br>查询时间共用:"&FormatNumber((EndTime-STime),3,-1)&"</b> 秒")
  end function

注意:在运行的时候可能会出现拒绝访问,或者没有权限,你需要给iis用户赋予一个最大权限。如下图所示:

by 雪洁 2010-10-28 15:31:54 5355 views
我来说几句

相关文章