⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 search.asp

📁 不错的ASP整站源代码。在IIS环境下运行都没有问题
💻 ASP
字号:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="ECONN.asp" -->
<%
'过滤HTML字符
function FiltrateHtml(text,shuzi)
text = Replace(text, CHR(10), "")
text = Replace(text, CHR(13), "")
text = Replace(text, CHR(32), "")
text = Replace(text, CHR(34), "")
text = Replace(text, CHR(39), "")
text = Replace(text, "&nbsp;", "")
t1=split(text,"<")
for N=0 to UBound(t1)
t2=t1(n)
if instr(t2,">")>0 then
t3=split(t2,">")
t2=t3(1)
end if
text2=text2+t2
next
FiltrateHtml = left(text2,shuzi)
end function
'重组
function SX(title)
if instr(title,"|")>0 then
ArrayTitle = split(title,"|")
SX = ArrayTitle(0)
else
SX = title
end if
end function
'重组搜索代码
function SEARCH(title)
title = replace(title,","," ")
title = replace(title,"+"," ")
title = replace(title,"'"," ")
title = replace(title,"|"," ")
title = replace(Trim(title)," ",",")
While Instr(title,",,") > 0
title = replace(title,",,",",")
wend
keyword = split(title,",")
for i = 0 to UBound(keyword)
sqlword = sqlword + "INTETITLE&INTEDESC1&INTEDESC2 LIKE '%" + keyword(i) + "%' or "
next
if sqlword <> "" then
SEARCH = " WHERE (" + left(sqlword,(len(sqlword) - 4)) + ")"
else
SEARCH = ""
end if
end function

qSearch = SEARCH(Request.QueryString("search"))
if qSearch = "" then
S_TEXT = "关键字为空或有误"
else
Set rsINTE = Server.CreateObject("ADODB.Recordset")
rsINTE.ActiveConnection = MM_ECONN_STRING
rsINTE.Source = "SELECT * FROM S_Inte" + qSearch + "AND (INTETEXT1 <> '10' OR INTETEXT1 <> '00') AND (CLASSID=1 OR CLASSID=2 OR CLASSID=5) ORDER BY INTEDATE DESC"
rsINTE.CursorType = 0
rsINTE.CursorLocation = 2
rsINTE.LockType = 1
rsINTE.Open()

Repeat1__numRows = 10
Repeat1__index = 0
rsINTE_numRows = rsINTE_numRows + Repeat1__numRows

rsINTE_total = rsINTE.RecordCount

If (rsINTE_numRows < 0) Then
  rsINTE_numRows = rsINTE_total
Elseif (rsINTE_numRows = 0) Then
  rsINTE_numRows = 1
End If

rsINTE_first = 1
rsINTE_last  = rsINTE_first + rsINTE_numRows - 1

If (rsINTE_total <> -1) Then
  If (rsINTE_first > rsINTE_total) Then
    rsINTE_first = rsINTE_total
  End If
  If (rsINTE_last > rsINTE_total) Then
    rsINTE_last = rsINTE_total
  End If
  If (rsINTE_numRows > rsINTE_total) Then
    rsINTE_numRows = rsINTE_total
  End If
End If

If (rsINTE_total = -1) Then

  rsINTE_total=0
  While (Not rsINTE.EOF)
    rsINTE_total = rsINTE_total + 1
    rsINTE.MoveNext
  Wend

  If (rsINTE.CursorType > 0) Then
    rsINTE.MoveFirst
  Else
    rsINTE.Requery
  End If

  If (rsINTE_numRows < 0 Or rsINTE_numRows > rsINTE_total) Then
    rsINTE_numRows = rsINTE_total
  End If

  rsINTE_first = 1
  rsINTE_last = rsINTE_first + rsINTE_numRows - 1
  
  If (rsINTE_first > rsINTE_total) Then
    rsINTE_first = rsINTE_total
  End If
  If (rsINTE_last > rsINTE_total) Then
    rsINTE_last = rsINTE_total
  End If

End If

Dim MM_paramName 

Dim MM_rs
Dim MM_rsCount
Dim MM_size
Dim MM_uniqueCol
Dim MM_offset
Dim MM_atTotal
Dim MM_paramIsDefined

Dim MM_param
Dim MM_index

Set MM_rs    = rsINTE
MM_rsCount   = rsINTE_total
MM_size      = rsINTE_numRows
MM_uniqueCol = ""
MM_paramName = ""
MM_offset = 0
MM_atTotal = false
MM_paramIsDefined = false
If (MM_paramName <> "") Then
  MM_paramIsDefined = (Request.QueryString(MM_paramName) <> "")
End If

if (Not MM_paramIsDefined And MM_rsCount <> 0) then

  MM_param = Request.QueryString("index")
  If (MM_param = "") Then
    MM_param = Request.QueryString("offset")
  End If
  If (MM_param <> "") Then
    MM_offset = Int(MM_param)
  End If

  If (MM_rsCount <> -1) Then
    If (MM_offset >= MM_rsCount Or MM_offset = -1) Then  ' past end or move last
      If ((MM_rsCount Mod MM_size) > 0) Then         ' last page not a full repeat region
        MM_offset = MM_rsCount - (MM_rsCount Mod MM_size)
      Else
        MM_offset = MM_rsCount - MM_size
      End If
    End If
  End If

  MM_index = 0
  While ((Not MM_rs.EOF) And (MM_index < MM_offset Or MM_offset = -1))
    MM_rs.MoveNext
    MM_index = MM_index + 1
  Wend
  If (MM_rs.EOF) Then 
    MM_offset = MM_index  ' set MM_offset to the last possible record
  End If

End If

If (MM_rsCount = -1) Then

  MM_index = MM_offset
  While (Not MM_rs.EOF And (MM_size < 0 Or MM_index < MM_offset + MM_size))
    MM_rs.MoveNext
    MM_index = MM_index + 1
  Wend

  If (MM_rs.EOF) Then
    MM_rsCount = MM_index
    If (MM_size < 0 Or MM_size > MM_rsCount) Then
      MM_size = MM_rsCount
    End If
  End If

  If (MM_rs.EOF And Not MM_paramIsDefined) Then
    If (MM_offset > MM_rsCount - MM_size Or MM_offset = -1) Then
      If ((MM_rsCount Mod MM_size) > 0) Then
        MM_offset = MM_rsCount - (MM_rsCount Mod MM_size)
      Else
        MM_offset = MM_rsCount - MM_size
      End If
    End If
  End If

  If (MM_rs.CursorType > 0) Then
    MM_rs.MoveFirst
  Else
    MM_rs.Requery
  End If

  MM_index = 0
  While (Not MM_rs.EOF And MM_index < MM_offset)
    MM_rs.MoveNext
    MM_index = MM_index + 1
  Wend
End If

rsINTE_first = MM_offset + 1
rsINTE_last  = MM_offset + MM_size

If (MM_rsCount <> -1) Then
  If (rsINTE_first > MM_rsCount) Then
    rsINTE_first = MM_rsCount
  End If
  If (rsINTE_last > MM_rsCount) Then
    rsINTE_last = MM_rsCount
  End If
End If

MM_atTotal = (MM_rsCount <> -1 And MM_offset + MM_size >= MM_rsCount)

Dim MM_keepNone
Dim MM_keepURL
Dim MM_keepForm
Dim MM_keepBoth

Dim MM_removeList
Dim MM_item
Dim MM_nextItem

MM_removeList = "&index="
If (MM_paramName <> "") Then
  MM_removeList = MM_removeList & "&" & MM_paramName & "="
End If

MM_keepURL=""
MM_keepForm=""
MM_keepBoth=""
MM_keepNone=""

For Each MM_item In Request.QueryString
  MM_nextItem = "&" & MM_item & "="
  If (InStr(1,MM_removeList,MM_nextItem,1) = 0) Then
    MM_keepURL = MM_keepURL & MM_nextItem & Server.URLencode(Request.QueryString(MM_item))
  End If
Next

For Each MM_item In Request.Form
  MM_nextItem = "&" & MM_item & "="
  If (InStr(1,MM_removeList,MM_nextItem,1) = 0) Then
    MM_keepForm = MM_keepForm & MM_nextItem & Server.URLencode(Request.Form(MM_item))
  End If
Next

MM_keepBoth = MM_keepURL & MM_keepForm
If (MM_keepBoth <> "") Then 
  MM_keepBoth = Right(MM_keepBoth, Len(MM_keepBoth) - 1)
End If
If (MM_keepURL <> "")  Then
  MM_keepURL  = Right(MM_keepURL, Len(MM_keepURL) - 1)
End If
If (MM_keepForm <> "") Then
  MM_keepForm = Right(MM_keepForm, Len(MM_keepForm) - 1)
End If

Function MM_joinChar(firstItem)
  If (firstItem <> "") Then
    MM_joinChar = "&"
  Else
    MM_joinChar = ""
  End If
End Function

Dim MM_keepMove
Dim MM_moveParam
Dim MM_moveFirst
Dim MM_moveLast
Dim MM_moveNext
Dim MM_movePrev

Dim MM_urlStr
Dim MM_paramList
Dim MM_paramIndex
Dim MM_nextParam

MM_keepMove = MM_keepBoth
MM_moveParam = "index"

If (MM_size > 1) Then
  MM_moveParam = "offset"
  If (MM_keepMove <> "") Then
    MM_paramList = Split(MM_keepMove, "&")
    MM_keepMove = ""
    For MM_paramIndex = 0 To UBound(MM_paramList)
      MM_nextParam = Left(MM_paramList(MM_paramIndex), InStr(MM_paramList(MM_paramIndex),"=") - 1)
      If (StrComp(MM_nextParam,MM_moveParam,1) <> 0) Then
        MM_keepMove = MM_keepMove & "&" & MM_paramList(MM_paramIndex)
      End If
    Next
    If (MM_keepMove <> "") Then
      MM_keepMove = Right(MM_keepMove, Len(MM_keepMove) - 1)
    End If
  End If
End If

If (MM_keepMove <> "") Then 
  MM_keepMove = Server.HTMLEncode(MM_keepMove) & "&"
End If

MM_urlStr = Request.ServerVariables("URL") & "?" & MM_keepMove & MM_moveParam & "="

MM_moveFirst = MM_urlStr & "0"
MM_moveLast  = MM_urlStr & "-1"
MM_moveNext  = MM_urlStr & CStr(MM_offset + MM_size)
If (MM_offset - MM_size < 0) Then
  MM_movePrev = MM_urlStr & "0"
Else
  MM_movePrev = MM_urlStr & CStr(MM_offset - MM_size)
End If

Dim rsINTE_TFMcurrentPage
Dim rsINTE_TFMtotalPages
If MM_size > 0 Then
rsINTE_TFMcurrentPage = Round(rsINTE_last/MM_size + .4999)
rsINTE_TFMtotalPages = Round(rsINTE_total/MM_size + .4999)
End If

While ((Repeat1__numRows <> 0) AND (NOT rsINTE.EOF)) '############

S_TEXT = S_TEXT & "<a target=_blank href="&(rsINTE.Fields.Item("INTEPATH").Value)&"><b style='font-size:14'><u>"& _ 
	SX(rsINTE.Fields.Item("INTETITLE").Value)&"</u></b></a><br><a target=_blank href="& _
	(rsINTE.Fields.Item("INTEPATH").Value)&">"& _
	FiltrateHtml(rsINTE.Fields.Item("INTEDESC2").Value,150)&"…</a><br><br>"
	
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1 
  rsINTE.MoveNext()'############
Wend '############

If Not rsINTE.EOF Or Not rsINTE.BOF Then
TFM_MiddlePages = 10
TFM_startLink = MM_offset/MM_size - int(TFM_middlePages/2)
TFM_endLink = MM_offset/MM_size + int(TFM_middlePages/2) 
If TFM_MiddlePages/2 <> int(TFM_MiddlePages/2) Then TFM_endLink = TFM_endLink + 1
If TFM_startLink < 0 then 
   TFM_startLink = 0
   TFM_endLink = TFM_middlePages 
End If
TFM_LimitCounter = 0
For i = 1 to rsINTE_total Step MM_size
TFM_LimitCounter = TFM_LimitCounter + 1
TFM_LimitPageEndCount = i + MM_size - 1
if TFM_LimitPageEndCount > rsINTE_total Then TFM_LimitPageEndCount = rsINTE_total
If TFM_LimitCounter > TFM_startLink AND TFM_LimitCounter <= TFM_endLink Then
if i <> MM_offset + 1 then
S_PAGE = S_PAGE&("<a href=""" & Request.ServerVariables("URL") & "?" & MM_keepMove & "offset=" & i-1 & """>")
S_PAGE = S_PAGE&(TFM_LimitCounter & "</a>")
else
S_PAGE = S_PAGE&("<b><font color=#CCCCCC>" & TFM_LimitCounter & "</font></b>")
End if
if(TFM_LimitPageEndCount <> rsINTE_total AND TFM_endLink <> TFM_LimitCounter) then
S_PAGE = S_PAGE&("︱")
end if
end if
next
else
S_TEXT = "没有查到符合要求的内容"
end if
rsINTE.Close()
Set rsINTE = Nothing
end if
%>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -