<%@language="vbscript" codepage="936"%>
<html>
<head>
<title>untitled document</title>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
</head>
<body>
<%
dim finishgetip,showip,allip
'/////////////////////////////////////////////////////////
'程序还不是很精简,以后再修改
'本程序所用的数据库为-- “冯志宏”-- 所写的--“追捕”--软件中所带ip数据库和
' “国华软件 guohua soft”的作者 --“冯国华”—所写的“全球ip地址分配表.chm”合二为一得到的
'感谢“冯志宏”和“冯国华”提供的数据
'数据库中还有不少的重复ip地址,希望有心人能将其删除,减小数据库
'我的程序写的还很笨拙,希望大家能多提意见,多多交流,谢谢!
'///////////////////////////////////////////////////////////
'解决思路: tech.acnow.net
'取得的客户端ip一般是202.11.25.1这种,而数据库中的ip格式为202.011.025.001,这就需要将取得的
'客户端ip转换为与数据库中ip一样的格式
'因为目前我们所用的ip是分为4段,每段3位,中间以“.”分隔
'所以我的思路是将客户端ip以“.”符号分割为4段,即202/11/25/1
'然后再分别核对每一段,如果是3位,则不变;如不足3位,为2位,该段前补1个0,为1,同理,则补2个0
'得到格式化后的ip后,去掉ip的最后一段,即取包括“.”的前11位,与数据库中的startip字段的前11位相比较,查找相同的值
'因为从数据库中可以看到,startip和endip的前三段都是一样的,而最后一段不过是内部子网地址,可以去掉
'所以只要取startip或endip的任意一个字段的前11位与客户端ip的前11位相比较就可以查到正确的所在地
'///////////////////////////////////////////////////////////////
function checkip_trueip()
'取客户端真实ip
getclientip = request.servervariables("http_x_forwarded_for") '如果客户端用了代理服务器,则用request.servervariables("remote_addr")方法只能得到空值,则应该用servervariables("http_x_forwarded_for")方法
if getclientip = "" then
getclientip = request.servervariables("remote_addr")'如果客户端没用代理,则request.servervariables("http_x_forwarded_for")得到是空值,应该用request.servervariables("remote_addr")方法
end if
checkip_trueip = getclientip
end function
'/////////////////////////////////////////////////////////
function getaccessrecordset(db,sql,mark,read)'取得recordset对象
set conn=getaccessconn(db)'输入参数为db-数据库的相对路径,sql-sql语句,mark,read为数据库读取方式,1,1为只读,1,3为读写
'constr="provider=microsoft.jet.oledb.4.0;"&"data source="&server.mappath(db)
' conn.open constr
set getaccessrecordset=server.createobject("adodb.recordset")
getaccessrecordset.open sql,conn,mark,read
end function
'////////////////////////////////////////////////////////////
function getaccessconn(db)'取得connection对象
set getaccessconn=server.createobject("adodb.connection")
'constr="driver={microsoft access driver (*.mdb)};dbq="&server.mappath("allcon/#bbsall.mdb")
constr="provider=microsoft.jet.oledb.4.0;"&"data source="&server.mappath(db)
getaccessconn.open constr
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器