<!--#include file="inc/conn.asp" -->
<!--#include file="inc/360_safe3.asp" -->
<%
'软件名称：MacCMS
'开发作者：MagicBlack    官方网站：http://www.maccms.com/
'--------------------------------------------------------
'适用本程序需遵循 CC BY-ND 许可协议
'这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和使用；
'不允许对程序代码以任何形式任何目的的再发布。
'--------------------------------------------------------
%>
<%
	page = be("all", "page")
    searchflag = be("all", "searchtype")
    searchkeyword = be("all", "keyword"): searchkeyword = chkSql(searchkeyword, True)
    searchkeytype = be("all", "keytype"): searchkeytype = chkSql(searchkeytype, True)
    searchids = be("all", "ids"): searchids = chkSql(searchids, True)
    searchpinyin = be("all", "pinyin"): searchpinyin = chkSql(searchpinyin, True)
    searchstarring = be("all", "starring"): searchstarring = chkSql(searchstarring, True)
    searchdirected = be("all", "directed"): searchdirected = chkSql(searchdirected, True)
    searcharea = be("all", "area"): searcharea = chkSql(searcharea, True)
    searchlanguage = be("all", "language"): searchlanguage = chkSql(searchlanguage, True)
    searchyear = be("all", "year"): searchyear = chkSql(searchyear, True)
    searchletter = be("all", "letter"): searchletter = chkSql(searchletter, True)
    searchtype = be("all", "type"): searchtype = chkSql(searchtype, True)
    order = be("all", "order"): order = chkSql(order, True)
    by = be("all", "by"): by = chkSql(by, True)
    
    Select Case searchkeytype
        Case "pinyin": searchpinyin = searchkeyword : searchkeyword=""
        Case "starring": searchstarring = searchkeyword : searchkeyword=""
        Case "directed": searchdirected = searchkeyword : searchkeyword=""
        Case "area": searcharea = searchkeyword : searchkeyword=""
        Case "language": searchlanguage = searchkeyword : searchkeyword=""
        Case "year": searchyear = searchkeyword : searchkeyword=""
        Case "letter" : searchletter = searchkeyword : searchkeyword=""
        Case "type" : searchtype = searchkeyword : searchkeyword=""
        Case else : searchkeyword = searchkeyword
    End Select
    
    If searchflag <> "artsearch" then searchflag = "vodsearch"
    If Not isNum(page) Then page = 1 Else page = CInt(page)
    If page < 1 Then page = 1
    if not isNum(searchtype) then searchtype =""
    
    If page=1 and getTimeSpan("lastSearchTime") < 5 Then
    	showMsg "每次搜索时间间隔5秒，请稍后重试", app_installdir
    end if
    
    If isN(searchkeyword) And isN(searchids) And isN(searchpinyin) And isN(searchstarring) And isN(searchdirected) And isN(searcharea) And isN(searchlanguage) And isN(searchyear) And isN(searchletter) And isN(searchtype) Then alert ("搜索参数不正确")
    
    dim typearr
    if searchflag = "artdsearch" then
    	If Not isN(searchkeyword) Then searchkey=searchkeyword : searchdes = searchdes & "&nbsp;标签为" & searchkeyword: searchwhere = searchwhere & " AND a_title LIKE '%" & searchkeyword & "%' "
	    If Not isN(searchpinyin) Then searchkey=searchpinyin : searchdes = searchdes & "&nbsp;拼音为" & searchpinyin: searchwhere = searchwhere & " AND a_entitle LIKE '%" & searchpinyin & "%' "
	    If Not isN(searchletter) Then searchkey=searchletter : searchdes = searchdes & "&nbsp;首字母为" & searchletter: searchwhere = searchwhere & " AND a_letter = '" & searchletter & "' "
	    If Not isN(searchtype) then
	    	typearr = getValueByArray(cachearttype, searchtype)
	    	if isarray(typearr) then
	   			if isN(searchkey) then searchkey= typearr(1)
	   			searchdes = searchdes & "&nbsp;分类为" & typearr(1)
	   			searchwhere = searchwhere & " AND a_type in (" & typearr(10) & ") "
	   		end if
	    end if
    else
    	If Not isN(searchkeyword) Then searchkey=searchkeyword : searchdes = searchdes & "&nbsp;名称或主演为" & searchkeyword: searchwhere = searchwhere & " AND  ( d_name LIKE '%" & searchkeyword & "%' OR d_starring LIKE '%"&searchkeyword&"%') "
	    If Not isN(searchpinyin) Then searchkey=searchpinyin : searchdes = searchdes & "&nbsp;拼音为" & searchpinyin: searchwhere = searchwhere & " AND d_enname LIKE '%" & searchpinyin & "%' "
	    If Not isN(searchletter) Then searchkey=searchletter : searchdes = searchdes & "&nbsp;首字母为" & searchletter: searchwhere = searchwhere & " AND d_letter = '" & searchletter & "' "
	    If Not isN(searchstarring) Then searchkey=searchstarring : searchdes = searchdes & "&nbsp;主演为" & searchstarring: searchwhere = searchwhere & " AND d_starring LIKE '%" & searchstarring & "%' "
	    If Not isN(searchdirected) Then searchkey=searchdirected : searchdes = searchdes & "&nbsp;导演为" & searchdirected: searchwhere = searchwhere & " AND d_directed LIKE '%" & searchdirected & "%' "
	    If Not isN(searcharea) Then searchkey=searcharea : searchdes = searchdes & "&nbsp;地区为" & searcharea: searchwhere = searchwhere & " AND d_area LIKE '%" & searcharea & "%' "
	    If Not isN(searchlanguage) Then searchkey=searchlanguage : searchdes = searchdes & "&nbsp;语言为" & searchlanguage: searchwhere = searchwhere & " AND d_language LIKE '%" & searchlanguage & "%' "
	    If Not isN(searchyear) Then searchkey=searchyear : searchdes = searchdes & "&nbsp;上映年份为" & searchyear: searchwhere = searchwhere & " AND d_year LIKE '%" & searchyear & "%' "
	    If Not isN(searchtype) then
	    	typearr = getValueByArray(cachevodtype, searchtype)
	    	
	    	if isarray(typearr) then
	   			if isN(searchkey) then searchkey= typearr(1)
	   			searchdes = searchdes & "&nbsp;分类为" & typearr(1)
	   			searchwhere = searchwhere & " AND d_type in (" & typearr(12) & ") "
	   		end if
	    end if
    end if
    
    attemptCacheFile "search", searchkeyword & "-" & searchids & "-" & searchpinyin & "-" & searcharea & "-" & searchlanguage & "-" & searchyear & "-" & searchletter & "-" &  searchtype  &  "-" & searchstarring & "-" & searchdirected & "-"  & page
    objTemplate.html = getFileByCache("template_" & searchflag, app_installdir & "template/" & app_templatedir & "/" & app_htmldir & "/" & searchflag & ".html")
    objTemplate.mark
    If searchflag = "artsearch" Then
    	objTemplate.artpagelist 
    Else
    	objTemplate.vodpagelist
    end if
    objTemplate.pageshow
    
    objTemplate.html = Replace(objTemplate.html, "{searchpage:page}", page)
    objTemplate.html = Replace(objTemplate.html, "{searchpage:des}", searchdes)
    objTemplate.html = Replace(objTemplate.html, "{searchpage:key}", searchkey)
    objTemplate.html = Replace(objTemplate.html, "{searchpage:order}", order)
    objTemplate.html = Replace(objTemplate.html, "{searchpage:by}", by)
    
    objTemplate.html = Replace(objTemplate.html, "{searchpage:name}", searchkeyword)
    objTemplate.html = Replace(objTemplate.html, "{searchpage:nameencode}", Server.UrlEncode(searchkeyword) )
    
    objTemplate.html = Replace(objTemplate.html, "{searchpage:pinyin}", searchpinyin)
    objTemplate.html = Replace(objTemplate.html, "{searchpage:letter}", searchletter)
    objTemplate.html = Replace(objTemplate.html, "{searchpage:year}", searchyear)
    objTemplate.html = Replace(objTemplate.html, "{searchpage:type}", searchtype)
    
    objTemplate.html = Replace(objTemplate.html, "{searchpage:starring}", searchstarring)
    objTemplate.html = Replace(objTemplate.html, "{searchpage:starringencode}", Server.UrlEncode(searchstarring) )
    
    objTemplate.html = Replace(objTemplate.html, "{searchpage:directed}", searchdirected)
    objTemplate.html = Replace(objTemplate.html, "{searchpage:directedencode}", Server.UrlEncode(searchdirected) )
    
    objTemplate.html = Replace(objTemplate.html, "{searchpage:area}", searcharea)
    objTemplate.html = Replace(objTemplate.html, "{searchpage:areaencode}", Server.UrlEncode(searcharea) )
    
    objTemplate.html = Replace(objTemplate.html, "{searchpage:language}", searchlanguage)
    objTemplate.html = Replace(objTemplate.html, "{searchpage:languageencode}", Server.UrlEncode(searchlanguage) )
    
    
    objTemplate.ifEx
    setCacheFile "search", searchkeyword & "-" & searchids & "-" & searchpinyin & "-" & searcharea & "-" & searchlanguage & "-" & searchyear & "-" & searchletter & "-" &  searchtype &  "-" & searchstarring & "-" & searchdirected & "-"  & page, objTemplate.html
    
    objTemplate.run
    writeA objTemplate.html
    Session("lastSearchTime") = Now
    dispseObj()
%>