<!--#include file="conn.asp"-->
<!-- #include file="inc/const.asp" -->
<!-- #include file="chkuser.asp" -->
<!--#include file=inc/theme.asp -->
<!--#include file="inc/char.asp"-->
<!--#include file="footer.asp"-->
<!--#include file="forum_css.asp"-->

<% 
	stats="IP查询"
	call nav()
	call headline(1)

dim ip        
IP=Trim(Request("IP"))
'用户来源 
Function address(sip)
if Instr(sip,"=")>0 or Instr(sip,"%")>0 or Instr(sip,chr(32))>0 or Instr(sip,"?")>0 or Instr(sip,"&")>0 or Instr(sip,";")>0 or Instr(sip,",")>0 or Instr(sip,"'")>0 or Instr(sip,",")>0 or Instr(sip,chr(34))>0 or Instr(sip,chr(9))>0 or Instr(sip,"")>0 or len(sip)>15 then response.redirect("ip.asp"): exit Function 
Dim arr_ipp
         sip = Trim(sip)
         If sip = "127.0.0.1" Then sip = "192.168.0.1"

         arr_ipp = Split(sip, ".")
         dim R
         R = False
         If UBound(arr_ipp) = 3 Then
         If IsNumeric(arr_ipp(0)) <> 0 And IsNumeric(arr_ipp(1)) <> 0 And IsNumeric(arr_ipp(2)) <> 0 And IsNumeric(arr_ipp(3)) <> 0 Then
         R = True
         End If
         End If
 
If R Then
    dim num,country,city
    num = CInt(arr_ipp(0)) * 256 * 256 * 256 + CInt(arr_ipp(1)) * 256 * 256 + CInt(arr_ipp(2)) * 256 + CInt(arr_ipp(3)) - 1
    Set rs = server.CreateObject("adodb.recordset")
    sql = "select Top 1 country,city from address where ip1 <=" & num & " and ip2 >=" & num & ""
    rs.open sql, conn, 1, 1
    
    If rs.EOF And rs.bof Then
        country = "未知"
        city = ""
    Else
        country = rs("country")
        city = rs("city")
    End If
    
    rs.Close
    Set rs = Nothing
    address = country & city
Else
    address = "不合法IP"
End If
Set arr_ipp = Nothing
'conn.Close
'Set conn = Nothing
End Function

%>

<html>
<head>
<META HTTP-EQUIV="Content-Type" content="text/html; charset=gb_2312-80">
<title>IP地址查询</title>

<form name="f1" method="post" action="ip.asp">
<table cellspacing=0 cellpadding=0 width=350 align=center border=0>
  <tbody>
  <tr> 
    <td valign=bottom align=right width=347 rowspan=2> 
      <table cellspacing=0 cellpadding=0 width="100%" border=0 style="BORDER-RIGHT: #333333 1px solid; BORDER-TOP: #333333 1px solid; BORDER-LEFT: #333333 1px solid; BORDER-BOTTOM: #333333 1px solid;">
        <tbody> 
<% if not ip<>empty then%>
        <tr align="middle" bgcolor="#F7d7b5">
          <td colspan=4 height=35 style="BORDER-BOTTOM: #F7d7b5 1px solid;"><b><font 
            color=#8c5900>欢迎使用IP地址查询</font></b></td>
        </tr>
        <tr>
          <td colspan="4" height="1"  bgcolor="#000000" ></td>
        </tr>
        <tr>
		<td colspan="4" nowrap align="center" height="30">
			<font class="s" color="#000099"><b>请输入您要搜寻的IP地址：</b>
          </td>
        </tr>
        <tr>
          <td colspan="4" nowrap align="center" height="30">
			<font class="s" color="#000099"></font><input type="text" name="IP" value="" size="30" style="font-size: 12px; border-style: solid; border-width: 1">
          </td>
       </tr>

        <tr> 
		<td colspan="4" nowrap align="right" height="50">
			<input class="Bsbttn" type=submit value=" 确定 ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		</td>
        </tr>
<%else%>
       <tr align="middle" bgcolor="#F7d7b5">
          <td colspan=4 height=35 style="BORDER-BOTTOM: #F7d7b5 1px solid;"><b><font 
            color=#8c5900>IP地址查询结果</font></b></td>
        </tr>
         <tr>
          <td colspan="4" height="1"  bgcolor="#000000" ></td>
        </tr>
        <tr>
		<td colspan="4" nowrap align="center" height="30">
			<font class="s" color="#000099"><b>您要搜寻的IP地址：</b><% if ip<>empty then response.write IP %><br><br>
          </td>
        </tr>
        <tr>
          <td colspan="4" nowrap align="center" height="30">
		<font class="s" color="#000099"><b>搜寻的IP地址来自：</b><%if ip<>empty then response.write address(ip) end if%><br>
          </td>
       </tr>
        <tr>
          <td colspan="4" nowrap align="right" height="50">
<input type="submit" name="Submit2" value="返回" onClick=history.go(-1)> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          </td>
       </tr>
<%end if%>
        </tbody>
      </table>
    </td>
    <td width=1 bgcolor=#ffffff height=5></td>
    <td width=1 bgcolor=#ffffff height=5></td>
    <td width=1 bgcolor=#ffffff height=5></td>
  </tr>
  <tr> 
    <td width=1 bgcolor=#333333 height=120></td>
    <td width=1 bgcolor=#666666 height=120></td>
    <td width=1 bgcolor=#999999 height=120></td>
  </tr>
  <tr valign=top align=right> 
    <td colspan=4> 
      <table cellspacing=0 cellpadding=0 width="345" border=0>
        <tbody> 
        <tr> 
          <td bgcolor=#333333 height=1></td>
        </tr>
        <tr> 
          <td bgcolor=#666666 height=1></td>
        </tr>
        <tr> 
          <td bgcolor=#999999 height=1></td>
        </tr>
        </tbody>
      </table>
    </td>
  </tr>
  <tr valign=center align=right> 
    <td colspan=4 height=25>&nbsp;</td>
  </tr>
  <tr valign=top align=right> 
    <td colspan=4 height=25> 
      <div align=center></div>
    </td>
  </tr>
  </tbody>
</table>
</form>
</body>
</html>

<%call endline()%>
