<!--#include file="../../lib/base.asp"-->
<!--#include file="../../theme/admin_leo/config.asp"-->
<!--#include file="../../lib/cmd.asp"-->
<%
''' EYCMS 蜘蛛来访插件
''' ==================================================================

	'注释：插件是否安装
	is_plug_install "eycms.plug.spider"
	
	'注释：下面是接收处理程序
	dim spider_name:spider_name=getspider
	if eycms.strlen(spider_name)<=0 then eycms.die
	
	'注释：检查缓存
	if not(eycms.checkcache("spider_"&spider_name,0)) then
		spiderdb(spider_name)
		eycms.setcache "spider_"&spider_name,spider_name,0
	end if
	
	function getspider()
		dim agent:agent=request.servervariables("http_user_agent")
		if agent="" then
			getspider=""
			exit function
		end if
		dim str01,str02
		str01=split("Baidu|Google|archiver|ASPSeek|Yahoo|sohu|MSNBOT|360","|")
		str02=split("Baidu|Google|Alexa|ASPSeek|Yahoo|SOHU|MSN|360","|")
		dim i
		for i=0 to ubound(str01)
			if instr(lcase(agent),lcase(str01(i)))>0 then
				getspider=str02(i)
				exit function
			end if
		next
		getspider=""
	end function
	
	sub spiderdb(byval t0)
		dim rs
		set rs=server.createobject("adodb.recordset")
		rs.open "select spider,hits,lastupdate from ey_plug_spider where spider='"&t0&"'",eycms.db.conn,1,3
		if rs.eof then
			rs.addnew
			rs(0)=t0
			rs(1)=1
			rs(2)=now()
		else
			rs.update
			rs(1)=rs(1)+1
			rs(2)=now()
		end if
		rs.update
		rs.close
		set rs=nothing
	end sub
%>
