<%
joekoe_cms.connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("data/ip_address.mdb")
function view_sys(vss)
  dim vs,ver,strUserAgentArr,strTempUserInfo1,strTempUserInfo2,Mozilla,Agent,BcType,Browser,sSystem,strSystem,strBrowser
  on error resume next
  vs=trim(vss)
  strUserAgentArr=Split(vs,"; ")
  strTempUserInfo1=strUserAgentArr(1)
  if Instr(strTempUserInfo1,"MSIE")>0 then strTempUserInfo1=Replace(strTempUserInfo1,"MSIE","Internet Explorer")
  strTempUserInfo2=trim(Left(strUserAgentArr(2),Len(strUserAgentArr(2))-1))
  if InStr(vs,"Mozilla/4.0 (compatible;")>0 and strTempUserInfo2="Windows NT 5.0" then strTempUserInfo2="Windows 2000"
  Mozilla=vs
  Agent=Split(Mozilla,"; ")
  BcType=0
  If Instr(Agent(1),"U") Or Instr(Agent(1),"I") Then BcType=1
  If InStr(Agent(1),"MSIE") Then BcType=2
  select Case BcType
  Case 0
    Browser="其它"
    sSystem="其它"
  Case 1
    Ver=Mid(Agent(0),InStr(Agent(0),"/")+1)
    Ver=Mid(Ver,1,InStr(Ver," ")-1)
    Browser="Netscape" & Ver
    sSystem=Mid(Agent(0),InStr(Agent(0),"(")+1)
    sSystem=Replace(sSystem,"Windows","Win")
  case 2
    Browser=Agent(1):sSystem=Replace(Agent(2),")",""):sSystem=Replace(sSystem,"Windows","Win")
  End select
  strSystem=Replace(sSystem,"Win","Windows")
  if InStr(strSystem,"98")>0 and InStr(Mozilla,"Win 9x")>0 then strSystem=Replace(strSystem,"98","Me")
  strSystem=Replace(strSystem,"NT 5.2","2003")
  strSystem=Replace(strSystem,"NT5.2","2003")
  strSystem=Replace(strSystem,"NT 5.1","XP")
  strSystem=Replace(strSystem,"NT5.1","XP")
  strSystem=Replace(strSystem,"NT 5.0","2000")
  strSystem=Replace(strSystem,"NT5.0","2000")
  strSystem=Replace(strSystem,"NT 5.1","XP")
  strSystem=Replace(strSystem,"NT5.1","XP")
  strBrowser=Replace(Browser,"MSIE","Internet Explorer")
  set Browser=Nothing:set sSystem=Nothing
  view_sys="操作系统：" & trim(strSystem) & " ，浏览器：" & trim(strBrowser)
  if err then err.clear:view_sys="未知的操作系统和浏览器"
end function

function ip_true(tips)
  dim tip,iptemp,iptemp1,iptemp2
  tip=tips
  ip_true=false
  tip=trim(tip)
  iptemp=tip
  iptemp=replace(replace(iptemp,".",""),":","")
  iptemp1=tip
  iptemp1=len(tip)-len(replace(iptemp1,".",""))
  iptemp2=tip
  iptemp2=len(tip)-len(replace(iptemp2,":",""))
  if isnumeric(iptemp) and cint(iptemp1)=3 and (cint(iptemp2)=1 or cint(iptemp2)=0) then ip_true=true
end function

function ip_ip(tips)
  dim ipn,tip
  tip=tips
  tip=trim(tip)
  if not ip_true(tip) then
    ip_ip="IP Error"
    exit function
  end if
  ipn=Instr(tip,":")
  if ipn>0 then
    ip_ip=left(tip,ipn-1)
    exit function
  end if
  ip_ip=tip
end function

function ip_types(tips,tu,tt)
  dim ipn,tip2,wip,ip_type
  tip2=tips
  tip2=trim(tip2)
  ip_types="IP Error"
  if not ip_true(tip2) then exit function
  wip=format_mid_num(10)
  if login_mode=format_power2(1,1) then wip=2
  select case wip
  case 0
    ip_types="*.*.*.*"
    if tt>0 then ip_types=tu&" 的IP是："&ip_types
    if tt=2 then ip_types="<img src='images/small/ip.gif' align=absMiddle title='"&ip_types&"' border=0>"
  case 1
    ipn=Instr(tip2,":")
    if ipn>0 then
      ip_types=left(tip2,ipn-1)
    else
      ip_types=tip2
    end if
    ip_type=split(ip_types,".")
    ip_types=ip_type(0)&"."&ip_type(1)&".*.*"
    erase ip_type
    if tt>0 then ip_types=tu&" 的IP是："&ip_types
    if tt=2 then ip_types="<img src='images/small/ip.gif' align=absMiddle title='"&ip_types&"' border=0>"
  case else
    ip_types=tip2
    if tt>0 then ip_types=tu&" 的IP是："&tip2
    if tt=2 then ip_types="<a href='"&joekoe_cms.web_path&"common/ip_address.asp?ip="&tip2&"'><img src='"&joekoe_cms.web_path&"images/small/ip.gif' align=absMiddle title='"&ip_types&"' border=0></a>"
  end select
end function

function ip_port(pips)
  dim ipnn,iptemp,pip
  pip=pips
  pip=trim(pip)
  if ip_true(pip)="no" then
    ip_port="no"
    exit function
  end if
  ipnn=Instr(pip,":")
  if ipnn>0 then
    ip_port=right(pip,len(pip)-ipnn)
    exit function
  end if
  ip_port="yes"
end function

function ip_address(sips)
  dim iconn,str1,str2,str3,str4,num,country,city,irs,sip
  sip=sips
  if not(isnumeric(left(sip,2))) then
    ip_address="未知"
    exit function
  end if
  if sip="127.0.0.1" then sip="192.168.0.1"
  str1=left(sip,instr(sip,".")-1)
  sip=mid(sip,instr(sip,".")+1)
  str2=left(sip,instr(sip,".")-1)
  sip=mid(sip,instr(sip,".")+1)
  str3=left(sip,instr(sip,".")-1)
  str4=mid(sip,instr(sip,".")+1)
  if not(isNumeric(str1)=0 or isNumeric(str2)=0 or isNumeric(str3)=0 or isNumeric(str4)=0) then
    num=cint(str1)*256*256*256+cint(str2)*256*256+cint(str3)*256+cint(str4)-1
    set iconn=server.createobject("adodb.connection")
    iconn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath(joekoe_cms.web_path&"data/ip_address.mdb")
    'set irs=server.createobject("adodb.recordset")
    set irs=iconn.execute("select Top 1 country,city from ip_address where ip1 <="&num&" and ip2 >="&num&"")
    if irs.eof then 
      country="亚洲"
      city=""
    else
      country=irs(0)
      city=irs(1)
    end if
    irs.close
    set irs=nothing
    iconn.close
    set iconn=nothing
  end if
  ip_address=country&city
end function

%>