📄 query.asp
字号:
<%
Class ImplMocomWAPmoWAPQuery
Private Sub Class_Initialize()
Set MyXML = MyKernel.XMLParser
End Sub
Private Sub Class_Terminate()
End Sub
Public Sub main()
MyXML.Align = "center"
MyXML.Println MyKernel.Config("QueryTitle")
MyXML.Align = "left"
If MyKernel.Config("IsQuery") <> "1" Then
MyXML.Println "该功能已被站长关闭"
ElseIf Request.ServerVariables("REQUEST_METHOD") = "POST" Then
Call doPost
Else
Call doGet
End If
Call ExportForm
Call BackHomeX(QUERY_SEQID)
Call setLog("query", 0)
MyXML.Transform Response
End Sub
Private Sub doGet()
Dim lngStaple
Dim intCate
Dim strKey
lngStaple = atol(MyIO.QueryString("Staple"))
intCate = atoi(MyIO.QueryString("Category"))
strKey = Trim(MyIO.QueryString("Keyword"))
If Len(strKey) > 1 Then
Call doGetQuery(lngStaple, intCate, strKey)
End If
End Sub
Private Sub doPost()
End Sub
Private Sub doGetQuery(ByVal lngStaple, ByVal intCate, ByVal strKey)
Dim clsPage
Dim rs
Dim i
Dim strWhere
Set clsPage = MyKernel.Page()
clsPage.PageNum = MyIO.QueryString("Page")
clsPage.PageSize = 10
clsPage.DataType = WM_DataType
clsPage.Increment = "SeqId"
clsPage.Column = "SeqId,StapleId,StapleTitle,Title,Matter,Hit,Intime"
clsPage.Table = T_CONTENT
strWhere = "HIDDEN=0 AND EXAMINE=1"
Select Case intCate
Case 50
strWhere = "CONTENT LIKE '%$(Keyword)%'"
Case 100
strWhere = "(TITLE LIKE '%$(Keyword)%' Or CONTENT LIKE '%$(Keyword)%')"
Case Else
strWhere = "TITLE LIKE '%$(Keyword)%'"
End Select
If lngStaple > 0 Then
strWhere = strWhere & getStapleWhere(lngStaple)
ElseIf ValidCoop() Then
strWhere = strWhere & getCoopWhere()
End If
strWhere = Replace(strWhere, "$(Keyword)", SafeString(strKey))
clsPage.Where = strWhere
clsPage.Sort = "SEQID DESC"
clsPage.SortType = True
Set rs = clsPage.Execute()
MyXML.Println "搜索到" & clsPage.TotalRow & "条与[" & strKey & "]相关的内容"
If clsPage.TotalRow > 0 Then
i = 0
Do While rs.EOF = False And i < clsPage.PageSize
MyXML.Printf "["
MyXML.Printf CreateA(getStapleURL(rs("StapleId"), 1), rs("StapleTitle"), "")
MyXML.Printf "]"
MyXML.Println CreateA(getContentURL(rs("StapleId"), 1, rs("SeqId"), rs("Intime"), 1), ((clsPage.PageNum - 1) * clsPage.PageSize + i + 1) & "." & rs("Title"), "")
rs.MoveNext
i = i + 1
Loop
MyXML.Println ""
Dim arr1, arr2
arr1 = Array("Staple", "Category", "Keyword", "Page")
arr2 = Array(lngStaple, intCate, strKey, 0)
If clsPage.PageNum < clsPage.TotalPage Then
arr2(3) = clsPage.PageNum + 1
MyXML.Printf CreateA(getURL("query.asp", arr1, arr2), "下一页", "")
MyXML.Printf "|"
arr2(3) = clsPage.TotalPage
MyXML.Println CreateA(getURL("query.asp", arr1, arr2), "最末页", "")
End If
If clsPage.PageNum > 1 Then
arr2(3) = clsPage.PageNum - 1
MyXML.Printf CreateA(getURL("query.asp", arr1, arr2), "上一页", "")
MyXML.Printf "|"
arr2(3) = 1
MyXML.Println CreateA(getURL("query.asp", arr1, arr2), "第一页", "")
End If
If clsPage.TotalPage > 2 Then
MyXML.SetF "query.asp", "get", "", True
Call setQuery
MyXML.SetN "Staple", "hidden", lngStaple, "", "", False
MyXML.SetN "Category", "hidden", intCate, "", "", False
MyXML.SetN "Keyword", "hidden", strKey, "", "", False
MyXML.SetN "Page", "text", "", clsPage.PageNum & "/" & clsPage.TotalPage & "页>>跳到", "页", False, 5, 5, "*N"
MyXML.SetN "", "submit", "GO", "", "", True
End If
MyXML.Println ""
End If
If Not rs Is Nothing Then rs.Close
Set rs = Nothing
Set clsPage = Nothing
End Sub
Private Sub ExportForm()
MyXML.SetF "query.asp", "get", "", True
Call setQuery
If MyKernel.Config("QueryStaple") = "1" Then
MyXML.SetS "Staple", atol(MyIO.QueryString("Staple")), "选择栏目:", "", True
MyXML.SetO 0, "所有栏目"
If ValidCoop() Then
Call ExportCoopStaple
Else
Call ExportStaple
End If
End If
MyXML.SetN "Keyword", "text", MyIO.QueryString("Keyword"), "搜索单词:", " 最少两个字符", True
MyXML.SetS "Category", atoi(MyIO.QueryString("Category")), "搜索选项:", "", True
MyXML.SetO "0", "标题"
MyXML.SetO "50", "内容"
MyXML.SetO "100", "标题和内容"
MyXML.SetN "", "submit", "搜索", "", "", True
End Sub
Private Function getCoopWhere()
If MyCoop("Staple") = "" Then
getCoopWhere = " AND 0=1"
Exit Function
End If
Dim strSQL
Dim ret, arr, i
strSQL = "SELECT MARK FROM $(Table) WHERE SEQID IN ($(SeqId))"
strSQL = Replace(strSQL, "$(Table)", T_STAPLE)
strSQL = Replace(strSQL, "$(SeqId)", MyCoop("Staple"))
arr = MyKernel.DB.getRecords(strSQL)
If Not IsArray(arr) Then
getCoopWhere = " AND 0=1"
Exit Function
End If
ReDim ret(UBound(arr, 2))
For i = 0 To UBound(arr, 2)
If MyKernel.Env("DATA_TYPE") = adOracle Then
ret(i) = "(MARK='$(Mark)' OR SUBSTR(MARK,$(Length))='$(Mark)_')"
Else
ret(i) = "(MARK='$(Mark)' OR LEFT(MARK,$(Length))='$(Mark)_')"
End If
ret(i) = Replace(ret(i), "$(Mark)", arr(0, i))
ret(i) = Replace(ret(i), "$(Length)", Len(arr(0, i)) + 1)
Next
getCoopWhere = " AND (" & Join(ret, " OR ") & ")"
Erase ret
End Function
Private Function getStapleWhere(ByVal lngId)
Dim strMark
Dim strSQL
Dim ret
strSQL = getLimitSQL(1, "MARK", T_STAPLE, "SEQID=$(SeqId)", "", "")
strSQL = Replace(strSQL, "$(SeqId)", lngId)
strMark = MyKernel.DB.getRecord(strSQL)
If strMark = "" Then Exit Function
ret = " AND (STAPLEID=$(StapleId) Or LEFT(MARK,$(Length))='$(Mark)_')"
ret = Replace(ret, "$(StapleId)", lngId)
ret = Replace(ret, "$(Mark)", strMark)
ret = Replace(ret, "$(Length)", Len(strMark) + 1)
getStapleWhere = ret
End Function
Private Sub ExportStaple()
Dim strSQL
Dim arr
strSQL = "SELECT SEQID,TITLE,FOLLOW FROM $(Table) WHERE HIDDEN=0 AND CATEGORY=$(Category)"
strSQL = Replace(strSQL, "$(Table)", T_STAPLE)
strSQL = Replace(strSQL, "$(Category)", wmStapleNormal)
arr = MyKernel.DB.getRecords(strSQL)
If Not IsArray(arr) Then Exit Sub
ExportStapleX arr, 0, 0, atoi(MyKernel.Config("QueryDepth"))
End Sub
Private Sub ExportStapleX(arr, ByVal lngFollow, ByVal intDeep, ByVal intDepth)
Dim i
For i = 0 To UBound(arr, 2)
If arr(2, i) = lngFollow Then
MyXML.SetO arr(0, i), String(intDeep * 2, "-") & arr(1, i)
If intDepth > 0 And intDeep <> intDepth Then
ExportStapleX arr, arr(0, i), intDeep + 1, intDepth
End If
End If
Next
End Sub
Private Sub ExportCoopStaple()
If MyCoop("Staple") = "" Then Exit Sub
Dim rs, strSQL
strSQL = "SELECT SEQID,TITLE FROM $(Table) WHERE SEQID IN ($(SeqId))"
strSQL = Replace(strSQL, "$(Table)", T_STAPLE)
strSQL = Replace(strSQL, "$(SeqId)", MyCoop("Staple"))
Set rs = MyKernel.DB.Execute(strSQL)
Do While Not rs.EOF
MyXML.SetO rs("SeqId"), rs("Title")
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
End Sub
Public Function newInstance()
Set newInstance = New ImplMocomWAPmoWAPQuery
End Function
End Class
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -