<% '****************************************************************************************** ' Software name: Max(马克斯) Content Management System ' Version:4.0 ' Web: //www.maxcms.net ' Author: 石头(maxcms2008@qq.com),yuet,长明,酒瓶 ' Copyright (C) 2005-2009 马克斯官方 版权所有 ' 法律申明:MaxCMS程序所有代码100%原创、未引入任何网上代码,对一切抄袭行为、坚决严肃追究法律责任 '****************************************************************************************** dim searchLimitFlag,searchtime:searchLimitFlag=0:searchtime=5'searchLimitFlag为显示搜索控制标识(0不开启,1开启),searchtime为搜索间隔秒数 dim action : action = getForm("action", "get") dim searchTemplatePath dim searchword,searchType,page:searchword=getForm("searchword","both") : searchType=getForm("searchtype","both") : page=getForm("page","both") '控制缓存前几页 Const CachePage=3 Function GetSearchPage dim i,cacheName,pSize,rsObj,whereStr,curTypeId,pCount,searchTemplateName,tempStr,searchPageStr 'if isNul(searchword) then echoMsgAndGo "请输入搜索关键字",searchtime:die "" if searchLimitFlag=1 then checkSearchTimes searchTemplateName="search.html" searchTemplatePath = "/"&sitePath&"template/"&defaultTemplate&"/"&templateFileFolder&"/"&searchTemplateName pSize = getPageSizeOnCache(searchTemplatePath,"search","") : if isNul(pSize) then pSize=12 dim x:x=EscapeSql(searchword) select case clng(searchType) case -1 : whereStr=" where m_recycle=0 AND (m_name like '%"&x&"%' OR m_actor like '%"&x&"%' OR m_director like '%"&x&"%')" case 0 : whereStr=" where m_recycle=0 AND m_name like '%"&x&"%'" case 1 : whereStr=" where m_recycle=0 AND (m_actor like '%"&x&"%' OR m_director like '%"&x&"%')" case 2 : whereStr=" where m_recycle=0 AND m_publisharea like '%"&x&"%'" case 3 : whereStr=" where m_recycle=0 AND m_publishyear like '%"&x&"%'" case 4 : whereStr=" where m_recycle=0 AND m_letter = '"&UCase(searchword)&"'" case 5 : whereStr=" where m_recycle=0 AND m_lang like '%"&x&"%'" end select if ""&searchword="" then whereStr=" where 1=2" set rsObj = conn.db("select m_id from {pre}data "&whereStr,"records1") rsObj.pagesize = pSize cacheName="parse_search_" if cacheStart=1 then if cacheObj.chkCache(cacheName) then templateObj.content = cacheObj.getCache(cacheName) else parseSearchPart cacheObj.setCache cacheName,templateObj.content end if else parseSearchPart end if tempStr = templateObj.content: pCount = rsObj.pagecount tempStr=replaceStr(tempStr,"{maxcms:searchword}",searchword):tempStr=replaceStr(tempStr,"{searchpage:page}",page): tempStr=replaceStr(tempStr,"{maxcms:searchnum}",rsObj.recordcount) with templateObj : .content=tempStr : .ParsePageList "",page,pCount,"search":.parseIf() : searchPageStr = .content : end with GetSearchPage=searchPageStr rsObj.close:set rsObj = nothing End Function Sub parseSearchPart with templateObj .load(searchTemplatePath) : .parseTopAndFoot():.parseSelf():.parseGlobal():.content=replaceCurrentTypeId(.content):.parseMenuList(""):.parseAreaList():.parseTopicList():.parseVideoList():.parseNewsList() end with End Sub Sub checkSearchTimes if not isNul(getForm("searchword", "post")) then if rCookie("maxcms2_search")="ok" then echoMsgAndGo "搜索限制为"&searchtime&"秒一次",searchtime,true:die "" wCookieInTime "maxcms2_search","ok","s",searchtime 'echo "