<% dim k k=trim(request("keyword")) k=replace(k,"'","'’") if k = "" then response.write "请输入关键字!" response.end end if %> <%=k%>的搜索结果 - <%=Web_Name%> <%=Rw(Skin_HeadB)%>
  • 歌曲名称
  • 歌手名称
  • 试听
  • 点歌
  • 收藏
  • 铃声
  • 歌词
<% Dim CurPage,Url_Add If Request.QueryString("Page")<>"" Then Curpage=Request.QueryString("Page") If IsInteger(Curpage)=False OR Curpage<0 Then Curpage=1 Else Curpage=1 End If Url_Add="?keyword="&k&"&" set rs=qqp3_conn(AutoKey(CheckStr(k)),1) if rs.eof and rs.bof then Response.Write(" 抱歉,没有找到您要的歌曲!") Else Dim MusicNums,MultiPages,j rs.PageSize=Admin_Page rs.AbsolutePage=CurPage MusicNums=rs.RecordCount MultiPages=""&SearchPage(MusicNums,Admin_Page,CurPage,Url_Add)&"" %> <% i=0 Do Until Rs.EOF OR j=rs.PageSize i=i+1 MusicName=HighlightKeyword(rs(1),k&NameKey(CheckStr(k))) MusicSinger=HighlightKeyword(rs(2),k&NameKey(CheckStr(k))) MusicPlayUrl=PlayUrl(rs(0),rs(3),rs(4)) MusicSingerUrl=SingerUrl(rs(3),rs(2)) %> <% j=j+1 rs.movenext loop end if rs.close set rs=nothing %>
你搜索的:[ <%=k%> ] 合计<%=MusicNums%>个  <%=MultiPages%>
<%=Rw(Skin_FootB)%> <% Function AutoKey(keyword) CONST lngSubKey=2 Dim lngLenKey, key1, key2, i, strSubKey keyword=replace(keyword," ","") if abs(asc(keyword))>127 then '判断是否为汉字,是则开始执行拆词搜索! lngLenKey=Len(keyword) select Case lngLenKey Case 1 '若长度为1,则不设任何值 key1="" key2="" Case Else '若长度大于1,则从字符串首字符开始,循环取长度为2的子字符串作为查询条件 For i=1 To lngLenKey-(lngSubKey-1) strSubKey=Mid(keyword,i,lngSubKey) key1=key1 & " or MusicName like '%" & strSubKey & "%'" key2=key2 & " or MusicSinger like '%" & strSubKey & "%'" Next End Select else '不是中文则不执行拆词搜索 key1="" key2="" end If If key1<>"" Then key1 = mid(key1, 5) End If 'like If InStr(k, " ")>0 Then Dim regEx, Match, Matches, ct1, ct2 ' 建立变量。 Set regEx = New RegExp ' 建立正则表达式。 regEx.Pattern = "([ ]{1,})" ' 设置模式。 regEx.IgnoreCase = True ' 设置是否区分大小写。 regEx.Global = True ' 设置全局替换。 Set Matches = regEx.Execute(k) ' 执行搜索。 ct1 = "" ct2 = "" For Each Match in Matches ' 遍历 Matches 集合。 k = Replace(k, Match.Value, " ") Next Dim Arr Arr = Split(k, " ") ct1 = ct1 & " or (MusicName like '%" & Arr(0) & "%' and MusicSinger like '%" & Arr(1) & "%')" ct1 = ct1 & " or (MusicName like '%" & Arr(1) & "%' and MusicSinger like '%" & Arr(0) & "%')" ct2 = ct2 & " or not (MusicName like '%" & Arr(0) & "%' and MusicSinger like '%" & Arr(1) & "%')" ct2 = ct2 & " or not (MusicName like '%" & Arr(1) & "%' and MusicSinger like '%" & Arr(0) & "%')" End If AutoKey="Select MusicId,MusicName,MusicSinger,MusicSingerId,ClassId,MusicUrl from MusicList where (MusicName like '%" & k & "%' or MusicSinger like '%" & k & "%')" & ct1 & " union all Select MusicId,MusicName,MusicSinger,MusicSingerId,ClassId,MusicUrl from MusicList where (MusicName not like '%" & k & "%' and MusicSinger not like '%" & k & "%')" & ct2 & "" If key1<>"" Then AutoKey = AutoKey & " and ("&key1&key2&")" End If End Function Function NameKey(keyword) CONST lngSubKey=2 Dim lngLenKey, key1, key2, i, strSubKey keyword=replace(keyword," ","") if abs(asc(keyword))>127 then '判断是否为汉字,是则开始执行拆词搜索! lngLenKey=Len(keyword) select Case lngLenKey Case 1 '若长度为1,则不设任何值 key1="" key2="" Case Else '若长度大于1,则从字符串首字符开始,循环取长度为2的子字符串作为查询条件 For i=1 To lngLenKey-(lngSubKey-1) strSubKey=Mid(keyword,i,lngSubKey) key1=key1 & "|" & strSubKey key2=key2 & "|" & strSubKey Next End Select else '不是中文则不执行拆词搜索 key1="" key2="" end If If key1<>"" Then key1 = mid(key1, 5) End If 'like If InStr(k, " ")>0 Then Dim regEx, Match, Matches, ct1, ct2 ' 建立变量。 Set regEx = New RegExp ' 建立正则表达式。 regEx.Pattern = "([ ]{1,})" ' 设置模式。 regEx.IgnoreCase = True ' 设置是否区分大小写。 regEx.Global = True ' 设置全局替换。 Set Matches = regEx.Execute(k) ' 执行搜索。 ct1 = "" ct2 = "" For Each Match in Matches ' 遍历 Matches 集合。 k = Replace(k, Match.Value, " ") Next Dim Arr Arr = Split(k, " ") NameKey=NameKey& Arr(0)&"|"& Arr(1)&"|" End If If key1<>"" Then NameKey = NameKey &key1&key2 End If End Function Function HighlightKeyword(strContent,keyword) keyword=Replace(keyword," ", "") Dim RegEx Set RegEx=new RegExp RegEx.IgnoreCase =True '不区分大小写 RegEx.Global=True Dim ArrayKeyword,i ArrayKeyword = Split(keyword,"|")'用|隔开的多关键字 For i=0 To Ubound(ArrayKeyword) RegEx.Pattern="("&ArrayKeyword(i)&")" strContent=RegEx.Replace(strContent,"$1" ) Next Set RegEx=Nothing HighlightKeyword=strContent End Function %>