<!--#include file="../lib/base.asp"-->
<!--#include file="../theme.asp"-->
<%
''' EYCMS 搜索
''' ==================================================================
	eycms.stophack
	dim sql_where:sql_where=""
	dim classid:classid=eycms.getint(eycms.fget("classid",0),0)
	dim key:key=eycms.enhtml(eycms.fget("key",0))
	dim keylen:keylen=eycms.strlen(key)
	dim modeid:modeid=eycms.getint(eycms.fget("modeid",0),0)
	if keylen<=0  then
		dim errormsg:errormsg="&#20851;&#38190;&#23383;&#19981;&#33021;&#20026;&#31354;"
	end if
	if keylen<2 then
		errormsg="&#20851;&#38190;&#23383;&#19981;&#33021;&#23567;&#20110;&#50;&#20010;&#23383;&#31526;"
	end if
	if keylen>20  then
		errormsg="&#20851;&#38190;&#23383;&#19981;&#33021;&#22823;&#20110;&#50;&#48;&#20010;&#23383;&#31526;"
	end if
	
	if errormsg<>"" then
		eycms.show eycms.getsys("theme_404"),""
		eycms.die
	end if
	
	if datatype then
		sql_where=sql_where&" and (instr(1,lcase(title),lcase('"&key&"'),0)<>0)"
	else
		sql_where=sql_where&" and (title like '%"&key&"%')"
	end if

	dim classname,catepic
	dim sonid,parentid,rootid,pagenum
	pagenum=20
	if classid<>0 then
		dim data:data=eycms.getclassdb(classid)
		if isarray(data) then
			sonid=data(5)
			parentid=data(6)
			rootid=split(parentid,"]")(0)
			rootid=replace(rootid,"[","")
			rootid=CInt(rootid)
			classname=data(1)
			catepic=data(15)
			If catepic="" Then catepic=eycms.get_catepic(rootid)
			pagenum=data(19)
		end if
		sql_where=sql_where&" and classid in("&sonid&")"
	end if
	if modeid<>0 then
		sql_where=sql_where&" and modeid=" & modeid
	end if
	eycms.show eycms.getsys("theme_search"),""
	if html_page_total<>0 and page=1 then
		addsearchkey key
	end if
	eycms.db.dbclose
	
	sub addsearchkey(byval t0)
		if eycms.loadcookie("search_keyword_"&t0)="" then
			dim rs
			set rs=server.createobject("adodb.recordset")
			rs.open "select title,hits,islock from ey_expand_keyword where title='"&t0&"'",eycms.db.conn,1,3
			if rs.eof then
				rs.addnew
				rs(0)=t0
				rs(1)=1
				rs(2)=1
			else
				rs.update
				rs(1)=rs(1)+1
			end if
			rs.update
			rs.close
			set rs=nothing
			eycms.setcookie "search_keyword_"&t0,t0
		end if
	end sub
%>
