<%
'《酷站领地搜索引擎BOT蜘蛛爬行日志访问记录插件》v2.3全功能免费版
'官方网站：酷站领地www.kz6d.com
dim startime
startime=timer()
dim botDBPath,oConnStr,oConn
	botDBPath="/botdb.mdb"
	oConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(botDBPath)  
	Set oConn = Server.CreateObject("ADODB.Connection") 
	oConn.open oConnStr 
dim botSQLstr,rsbot,needlogin,login_clear,login_search,login_del,pagesizenum,viewlistframe,urlrewrite,clearday

	botSQLstr="Select needlogin,login_clear,login_search,login_del,pagesizenum,viewlistframe,urlrewrite,clearday,viewallrecord,viewrecordnum from config"
	Set rsbot=oconn.Execute(botSQLstr,0,1) 
	if not rsbot.eof then
	needlogin=rsbot(0)
	login_clear=rsbot(1)
	login_search=rsbot(2)
	login_del=rsbot(3)
	pagesizenum=rsbot(4)
	viewlistframe=rsbot(5)
	urlrewrite=rsbot(6)
	clearday=rsbot(7)
	viewallrecord=rsbot(8)
	viewrecordnum=rsbot(9)
	end if
	rsbot.close
	set rsbot=nothing

function spiderbot()


	Dim FromUrl,GetLocationURL
	Dim ServerPort,ServerName,ScriptName,QueryString,serverip
	ServerName = Request.ServerVariables("SERVER_NAME")       '获取服务器IP
	ServerPort = Request.ServerVariables("SERVER_PORT")       '服务器处理请求的端口
		if urlrewrite=1 then
			ScriptName = Request.ServerVariables("SCRIPT_NAME")       '记录网址URL
			
		else
			ScriptName = Request.ServerVariables("HTTP_X_REWRITE_URL")       '记录网址URL，伪静态方式执行脚本的名称，会浏览html的路径形式
		end if
	QueryString = Request.ServerVariables("QUERY_STRING")      '查询字符串内容
	serverip = Request.ServerVariables("REMOTE_ADDR")           '获取访问IP
	FromUrl="http://"&ServerName 
	'If ServerPort <> "80" Then FromUrl = FromUrl & ":" & ServerPort     '判断端口是否为80，如果不是就填上端口号
	FromUrl=FromUrl&ScriptName 
		if urlrewrite=1 then
			If QueryString <>"" Then FromUrl=FromUrl&"?"& QueryString           '判断所访问的地址是否带有参数
		else
		end if
	GetLocationURL=FromUrl 
	dim agent: agent = lcase(request.servervariables("http_user_agent"))   '获取来路蜘蛛信息
	botname = ""
	botinfo = agent
'设定所有未知蜘蛛
if instr(agent,"bot") > 0 or instr(agent,"spider") > 0 or instr(agent,"slurp") > 0 then botname = "其它蜘蛛"

'从返回值中判断是什么蜘蛛
dim rs_id,rs_name,rs_info,rs_color,botid,botname,botinfo
botsqlstr="Select id,botname,botinfo,botcolor from bottype"
Set Rsbot=oconn.Execute(botsqlstr,0,1)

do while not rsbot.eof
rs_id=rsbot(0)
rs_name=rsbot(1)
rs_info=lcase(rsbot(2))
rs_color=rsbot(3)
	if instr(agent,rs_info) > 0 then
		botid=rs_id
		botname=rs_name
		botinfo=rs_info
		if rs_color<>"" then botname="<font color="&rs_color&">"&botname&"</font>"
	end if
rsbot.movenext
loop
rsbot.close
set rsbot=nothing


'BOT入库
'spiderbot变量，用于开发者站点的ASP浏览页更新点击数，如果是蜘蛛则不更新点击数。如：if spiderbot=0 then 更新点击数字段
if botname<>"" then
if botid="" then botid=0
oconn.execute ("insert into bot(bid,bot,agent,serverip,shijian,url) values('"&botid&"','"&botname&"','"&botinfo&"','"&serverip&"','"&now()&"','"&GetLocationURL&"')")
spiderbot=1
else
spiderbot=0
end if

end function
%>
<%call spiderbot()%>