%
dim Mesky,Keyword ,MakeHtml
Dim FobWords,Fi
Keyword = Trim(Request.QueryString("Keyword"))
if Keyword="" then '如果关键字为空就跳回首页
Response.Redirect(WebUrl)
end if
Dim Query
Query = Request.ServerVariables("Query_String")
if IsRedirect=1 then 'conn里是否设置了跳转
TempRedirectUrl= RedirectUrl
TempRedirectUrl = replace(TempRedirectUrl,"{Query}",Query)
TempRedirectUrl = replace(TempRedirectUrl,"{Keyword}",Keyword)
Response.Redirect(TempRedirectUrl)
end if
if lenb(Keyword)>10000 then '如果超过20个关键字就跳走
Response.Redirect("http://s.59370.com/cse/search?q="& Keyword &"&s=11350483759209916373&nsid=0")
end if
Set Mesky = New cls_main
set MyFun = New cls_MyFun
Set MakeHtml = New admin_MakeHtml
Keyword = Mesky.checkStr(Keyword)
'搜索过滤字
FobWords = Array(91,92,304,305,430,431,437,438,12460,12461,12462,12463,12464,12465,12466,12467,12468,12469,12470,12471,12472,12473,12474,12475,12476,12477,12478,12479,12480,12481,12482,12483,12485,12486,12487,12488,12489,12490,12496,12497,12498,12499,12500,12501,12502,12503,12504,12505,12506,12507,12508,12509,12510,12532,12533,65339,65340)
For Fi = 1 to Ubound(FobWords,1)
' Response.Write(ChrW(FobWords(Fi) & "|")
If InStr(keyword,ChrW(FobWords(Fi))) > 0 Then
Response.Write("搜索关键字中包含非法字符!")
Set Mesky = Nothing
Response.End
Exit For
End If
Next
'Response.Write(Query)
If InStr(Query,lcase("script")) > 0 or InStr(Query,lcase("alert")) > 0 or InStr(Query,lcase("select")) > 0 or InStr(Query,lcase("insert")) > 0or InStr(Query,lcase("update")) > 0 Then
Response.Write("搜索关键字中包含非法字符!")
Set Mesky = Nothing
Response.End
End if
FobWords = Array("~","!","@","#","$","%","^","&","*","(",")","_","+","=","`","[","]","{","}",";",":","""","'",",","<",">",".","/","\","|","?","_","about","1","2","3","4","5","6","7","8","9","0","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","after","all","also","an","and","another","any","are","as","at","be","because","been","before","being","between","both","but","by","came","can","come","could","did","do","each","for","from","get","got","had","has","have","he","her","here","him","himself","his","how","if","in","into","is","it","like","make","many","me","might","more","most","much","must","my","never","now","of","on","only","or","other","our","out","over","said","same","see","should","since","some","still","such","take","than","that","the","their","them","then","there","these","they","this","those","through","to","too","under","up","very","was","way","we","well","were","what","where","which","while","who","with","would","you","your","的","一","不","在","人","有","是","为","以","于","上","他","而","后","之","来","及","了","因","下","可","到","由","这","与","也","此","但","并","个","其","已","无","小","我","们","起","最","再","今","去","好","只","又","或","很","亦","某","把","那","你","乃","它")
keyword = Left(keyword,100)
keyword = Replace(keyword,"!"," ")
keyword = Replace(keyword,"]"," ")
keyword = Replace(keyword,"["," ")
keyword = Replace(keyword,")"," ")
keyword = Replace(keyword,"("," ")
keyword = Replace(keyword," "," ")
'keyword = Replace(keyword,"-"," ")
keyword = Replace(keyword,"/"," ")
keyword = Replace(keyword,"+"," ")
keyword = Replace(keyword,"="," ")
keyword = Replace(keyword,","," ")
keyword = Replace(keyword,"'"," ")
keyword = Replace(keyword,"<","")
keyword = Replace(keyword,">","")
keyword = Replace(keyword,"script","")
For Fi = 0 To Ubound(FobWords,1)
If keyword=FobWords(Fi) Then
Response.Write("搜索关键字中包含非法字符!")
Set Mesky = Nothing
Response.End
Exit For
End IF
Next
'If Not IsObject(Conn) Then ConnectionDatabase
call Mesky.LoadSetting()
dim arrPage,arrMainPage,sRs ,currentPage,mo,key
If Trim(Request.QueryString("Page")) = "" Then
currentPage = 1
Else
currentPage = Trim(Request.QueryString("Page"))
End If
mo = Trim(Request.QueryString("mo"))
mo = Mesky.checkStr(mo)
key = Trim(Request("searchType"))
key = Mesky.checkStr(key)
dim sType,CatalogID,aKeyword,sKey,RootId, cacthName
sType= Request("sType")
CatalogID = Request("CatalogID")
RootId = Request("RootId")
sType = Mesky.checkStr(sType)
RootId = Mesky.checkStr(RootId)
CatalogID = Mesky.checkStr(CatalogID)
cacthName = "S_" & server.URLEncode( Keyword & currentPage & key & mo &sType &CatalogID &RootId)
Mesky.name = cacthName '用缓存HTML
If Mesky.ObjIsEmpty Then
tempStr= Main()
Mesky.name = cacthName '用缓存HTML
Mesky.value = tempStr
'Call Mesky.WriteMesky_Log("search",keyword)
else
tempStr = Mesky.value
End if
Response.Write(tempStr)
Set Mesky = Nothing
Function Main()
dim tempStr
if key="cms" then
arrPage = Split(Mesky.ReadStylePage("Style_Cms_Search"),"")
tempStr = CmsSearchList()
tempStr = MakeHtml.regExp_INCLUDE(tempStr) '引用文件
tempStr = Replace(tempStr,"{$page_title}",keyword)
tempStr = Replace(tempStr,"{$keyword}",keyword)
Main = tempStr
else
arrPage = Split(Mesky.ReadStylePage("Style_Down_Search"),"")
tempStr = ViewSearchList()
tempStr = MakeHtml.regExp_INCLUDE(tempStr) '引用文件
'tempStr = tempStr & arrPage(4)
tempStr = Replace(tempStr,"{$page_title}",keyword)
tempStr = Replace(tempStr,"{$keyword}",keyword)
Main = tempStr
end if
Main= MakeHtml.regExp_ALL(Main)
End Function
'=================================搜索软件====================
Function ViewSearchList()
Dim Rs,showPageRs,sql,i,sColumn,sKeyword,q,sCatalog,iPage
ViewSearchList = arrPage(0)
if not IsNumeric(currentPage) then currentPage =1
dim orderCh
select case mo
case "time"
orderCh ="UpdateTime Desc"
case "timea"
orderCh ="UpdateTime asc"
case "hpl"
orderCh ="abet Desc" '软件打分
case "hits"
orderCh ="HitsTotal Desc"
case "size"
orderCh ="ResSize Desc"
case "sizea"
orderCh ="ResSize asc"
case "comm"
orderCh ="CommendId Desc" '按评论数
case "rank"
orderCh ="ResRank Desc" '等级大到小
case else
orderCh ="ResRank Desc , HitsTotal Desc"
mo=""
end select
sColumn = Mesky.dColumn
sKeyword = " (" & Mesky.translate(keyword,"ResName+ResVer+pinyin") &")"
if len(keyword)>15 then
sKeyword = " ResName like '"&keyword&"%' "
end if
q="&keyword="&Server.URLEncode(keyword)
aKeyword = Split(keyword)
'Response.Write(ubound(aKeyword))
'Response.Flush()
if ubound(aKeyword) = -1 then
sKey = keyword
else
sKey = aKeyword(0)
end if
sCatalog = sKeyword & " and isAuditing=1 "
'===查询相关类别 Begin ====
if instr(ViewSearchList,"{$xgcate}")>0 then
strSQL="select a1.catalogName ,a1.catalogID ,count(*) from Mesky_Down_Catalog as a1 INNER JOIN Mesky_Down_Resource on a1.catalogID =Mesky_Down_Resource.catalogID and "&sCatalog&" GROUP BY a1.catalogName ,a1.catalogID "
dim xgcate
xgcate =""
Set Rs=Mesky.Execute(strSQL)
While Not rs.eof
xgcate = xgcate & "
" &Rs(0)&" (" &Rs(2)&") "
Rs.MoveNext
Wend
Rs.close
ViewSearchList = Replace(ViewSearchList,"{$xgcate}",xgcate)
end if
'===查询相关类别 End ====
'===查询相关TAGS Begin ====
if instr(ViewSearchList,"{$xgtags}")>0 then
dim xgtags
xgtags =""
strSQL = "select top 10 RegCode from Mesky_Key where RegType=1 and RegCode like '%" &sKey & "%'"
Set Rs=Mesky.Execute(strSQL)
While Not rs.eof
xgtags = xgtags & " " & Rs(0) &" "
Rs.MoveNext
Wend
Rs.close
ViewSearchList = Replace(ViewSearchList,"{$xgtags}",xgtags)
end if
'===查询相关TAGS End ====
if IsNumeric(catalogid) and catalogid<>"" then
sCatalog = sCatalog & " and CatalogID=" & CatalogID
q=q&"&CatalogID=" & CatalogID
end if
if IsNumeric(RootId) and RootId<>"" then
sCatalog = sCatalog & " and RootId=" & RootId
q=q&"&RootId=" & RootId
end if
'Response.Write(IsNumeric(catalogid))
'Response.Flush()
Set showPageRs= New cls_Mesky_showPage
dim setPageSize
setPageSize =25
If IsSqlDataBase = 1 Then
showPageRs.DbType = "MSSQL_SP"
Else
showPageRs.DbType = "AC"
End If
showPageRs.RecSql=0
showPageRs.RecTerm=1
showPageRs.CookieName="search"&keyword
showPageRs.Order=1
showPageRs.PageSize= setPageSize
showPageRs.currentPage = currentPage
showPageRs.Sql=sColumn & "$Mesky_Down_Resource$" & sCatalog &"$"&orderCh&",charindex('"&sKey&"',ResName)$id"
dim iRecCount,sqlRs,no,result_info,s
iRecCount = showPageRs.RecCount
'Rs=showPageRs.ResultSet()
If Trim(Request.QueryString("Page"))="" or Trim(Request.QueryString("Page"))="1" then
iPage = 1
Else
iPage = clng(currentPage)*setPageSize+1-setPageSize
End If
if iRecCount < setPageSize then
no = iRecCount
Elseif (iPage + setPageSize -1 )>iRecCount then
no = iRecCount
Else
no = iPage + setPageSize -1
end if
result_info = "搜索关键字:"& Keyword &" 查找到: "&iRecCount&" 条相关记录,"&iPage&"-"&no&" 显示如下。"
ViewSearchList = Replace(ViewSearchList,"{$result_info}",result_info)
ViewSearchList = Replace(ViewSearchList,"{$count}",iRecCount)
'Response.Write(arrPage(1))
If iRecCount < 1 then
ViewSearchList = ViewSearchList & arrPage(1) & arrPage(4)
Else
no = iPage
set sqlRs = showPageRs.ResultSet '返回ResultSet
i=0
mb=Mesky.ReplaceLcase("\{.*?\}" ,arrPage(2) ) '标签全部转换为小写
while not sqlRs.eof and i<25
s = mb
s = Replace(s,"{$no}",no)
s = Mesky.FullReplace(s,sqlRs)
' s= Mesky.KeywordColor(s,keyword)
ViewSearchList = ViewSearchList & s
no = int(no) +1
i=i+1
sqlRs.movenext
wend
Set sqlRs = nothing
ViewSearchList = ViewSearchList & arrPage(4)
End If
ViewSearchList =replace( ViewSearchList ,"{$q}", q)
q= q & "&mo=" & mo
ViewSearchList =replace( ViewSearchList ,"{$mo}", mo)
ViewSearchList = replace(ViewSearchList,"{$showpage}",showPageRs.ShowPage("?Page={$pages}"&q))
Rs=NULL
showPageRs=NULL
Set showPageRs=NoThing
End Function
'===============搜索文章==========================
Function CmsSearchList()
Dim Rs,showPageRs,sql,i,sColumn,sKeyword,q,sCatalog,iPage
sColumn = Mesky.cColumn
dim catalog
sKeyword = " (" & Mesky.translate(keyword,"title") & ")"
q="&searchType=cms&sType=title&keyword="&Server.URLEncode(keyword)
sCatalog =sKeyword
if IsNumeric(catalogid) and catalogid<>"" then
sCatalog = sCatalog & " and CatalogID=" & CatalogID
q=q&"&CatalogID=" & CatalogID
end if
if IsNumeric(RootId) and RootId<>"" then
sCatalog = sCatalog & " and RootId=" & RootId
q=q & "&RootId=" & RootId
end if
sCatalog = sCatalog & " and isAuditing=1 "
Set showPageRs= New cls_Mesky_showPage
'.Conn=ConnStr '得到数据库连接对象
If IsSqlDataBase = 1 Then
showPageRs.DbType = "MSSQL_SP"
Else
showPageRs.DbType = "AC"
End If
showPageRs.RecSql=0
showPageRs.RecTerm=1
showPageRs.CookieName="search"&keyword
showPageRs.Order=1
showPageRs.PageSize=30
showPageRs.currentPage = currentPage
showPageRs.Sql=sColumn&"$Mesky_Cms_Resource$"&sCatalog&"$id Desc$id"
dim iRecCount,sqlRs,no,result_info,s
iRecCount = showPageRs.RecCount
'Rs=showPageRs.ResultSet()
If Trim(Request.QueryString("Page"))="" or Trim(Request.QueryString("Page"))="1" then
iPage = 1
Else
iPage = clng(Trim(Request.QueryString("Page")))*Mesky.setting(83)+1-Mesky.setting(83)
End If
if iRecCount < 30 then
no = iRecCount
Elseif (iPage+29)>iRecCount then
no = iRecCount
Else
no = iPage+29
end if
result_info = "搜索关键字:"& Keyword & " 在文章中查找到: "& iRecCount &" 个结果 "&iPage&"-"&no&" 显示如下。"
CmsSearchList = Replace(arrPage(0),"{$result_info}",result_info)
CmsSearchList = Replace(CmsSearchList,"{$count}",iRecCount)
'Response.Write(arrPage(1))
If iRecCount < 1 then
CmsSearchList = CmsSearchList & arrPage(1)
Else
no = iPage
set Rs = showPageRs.ResultSet '返回ResultSet
i=0
while not rs.eof and i<30
s = arrPage(2)
s = Replace(s,"{$no}",no)
s = Mesky.FullReplaceCms(s,rs)
CmsSearchList = CmsSearchList & s
no = int(no) +1
i=i+1
rs.movenext
wend
Set rs = nothing
End If
CmsSearchList = CmsSearchList & arrPage(3)
CmsSearchList = Replace(CmsSearchList,"{$showpage}",showPageRs.ShowPage("?Page={$pages}"&q))
Rs=NULL
showPageRs=NULL
Set showPageRs=NoThing
End Function
'================================================================
' 上下页部分
'================================================================
Public Function ShowPage(FileName,totalRecord,Mesky_PageSize,Mesky_CurrentPage)
Const Btn_First = "9" '定义第一页按钮显示样式
Const Btn_Prev = "3" '定义前一页按钮显示样式
Const Btn_Next = "4" '定义下一页按钮显示样式
Const Btn_Last = ":" '定义最后一页按钮显示样式
Const BtnNum_Count = 6 '定义最多显示多少页分页
Const Btn_more = ".." '定义更多按钮
Dim sPageInfo, totalPage
Dim showNumBtn '数字导航
Dim showFirstPrev '首页、前一页
Dim showNextLast '下一页、末页
If (totalRecord Mod Mesky_PageSize) = 0 Then
totalPage = totalRecord \ Mesky_PageSize
Else
totalPage = totalRecord \ Mesky_PageSize + 1
End If
sPageInfo = "页次:" & Mesky_CurrentPage & "/" & totalPage & " 每页:" & Mesky_PageSize & " 共计:" & totalRecord & ""
'数字导航
Dim i, str_tmp
Dim start_p, end_p
Dim Str_start, str_end
If totalPage < BtnNum_Count Then
For i = 1 To totalPage
If i = Mesky_CurrentPage Then
str_tmp = str_tmp & "" & i & " "
Else
str_tmp = str_tmp & "[" & i & "] "
End If
Next
Else
If Mesky_CurrentPage <= BtnNum_Count Then
start_p = 1
end_p = BtnNum_Count
Str_start = ""
str_end = "" & Btn_more & " "
ElseIf Mesky_CurrentPage > (totalPage \ BtnNum_Count) * BtnNum_Count Then
start_p = (totalPage \ BtnNum_Count) * BtnNum_Count + 1
end_p = totalPage
Str_start = "" & Btn_more & " "
str_end = ""
Else
If (Mesky_CurrentPage Mod BtnNum_Count) = 0 Then
start_p = Mesky_CurrentPage - BtnNum_Count + 1
end_p = Mesky_CurrentPage
Else
start_p = (Mesky_CurrentPage \ BtnNum_Count) * BtnNum_Count + 1
end_p = (Mesky_CurrentPage \ BtnNum_Count) * BtnNum_Count + BtnNum_Count
End If
Str_start = "" & Btn_more & " "
str_end = "" & Btn_more & " "
End If
For i = start_p To end_p
If i = Mesky_CurrentPage Then
str_tmp = str_tmp & "" & i & " "
Else
str_tmp = str_tmp & "[" & i & "] "
End If
Next
str_tmp = Str_start & str_tmp & str_end
End If
showNumBtn = str_tmp
i = Empty: str_tmp = Empty
start_p = Empty: end_p = Empty
Str_start = Empty: str_end = Empty
'首页、前一页
If Mesky_CurrentPage = 1 Then
showFirstPrev = Btn_First & " " & Btn_Prev & " "
Else
showFirstPrev = "" & Btn_First & " " & Btn_Prev & " "
End If
'下一页、末页
If Mesky_CurrentPage >= totalPage Then
showNextLast = Btn_Next & " " & Btn_Last & " "
Else
showNextLast = "" & Btn_Next & " " & Btn_Last & " "
End If
ShowPage = ShowPage & "" & vbCrLf
ShowPage = ShowPage & "" & vbCrLf
ShowPage = ShowPage & "
" & vbCrLf
End Function
%>