📄 search.asp
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!--#include file="Includes/site-dataconn.asp" -->
<!--#include file="Includes/func-common.asp" -->
<!--#include file="Includes/site-config.asp" -->
<!--#include file="Includes/inc-common.asp" -->
<%
Response.Expires = 60
Response.Expiresabsolute = Now() - 1
Response.AddHeader "pragma","no-cache"
Response.AddHeader "cache-control","private"
Response.CacheControl = "no-cache"
%>
<html>
<head>
<title>// <%=Site_Name%> //</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<LINK REL=stylesheet TYPE="text/css" HREF="Includes/site-style.css">
</head>
<body>
<!--#include file="Includes/inc-header.asp" -->
<%
'navigation trail
response.write("<table border='0' cellspacing='0' cellpadding='2' align='center' class='plain'><tr><td valign='top'><a href='default.asp'>"& Site_Name &"</a> >> Search<br>"& Site_Description &"</td></tr></table>")
Action = request.querystring("Action")
if Action = "" then
Action = "Search"
end if
if Action = "Search" then
'Display search form
%>
<table width="100%" border="0" cellspacing="1" cellpadding="3" align="center" class="main">
<form action="search.asp?Action=Results" method="post" onSubmit="this.button.disabled = true;">
<tr align="left" class="title">
<td colspan="2"><%=site_name%> 论 坛 搜 索</td>
</tr>
<tr align="left" class="sub-title">
<td width="100%" valign="top">搜索关键字:</td>
</tr>
<tr align="left" class="body">
<td valign="top">
<input name="Keyword" type="text" style="width: 300px; border: 1px solid black" size="20">
</td>
</tr>
</table>
<table width="100%" border="0" cellspacing="1" cellpadding="3" align="center" class="main">
<tr align="left" class="title">
<td colspan="3"><%=site_name%> 搜索选项:</td>
</tr>
<tr align="left" class="sub-title">
<td width="50%" valign="top">Search Forum</td>
<td width="25%" valign="top" nowrap>For Posts Dated</td>
<td width="25%" valign="top" nowrap>Order Results By</td>
</tr>
<tr align="left" class="body">
<td valign="top">
<%
'Populate forum specific search drop down
set rsForums = server.createobject("adodb.recordset")
sqlForums = "SELECT Forum_ID, Forum_Name, Category_ID, Category_Title FROM Forum_Forums, Forum_Categories WHERE Forum_Category_ID = Category_ID AND Forum_Category_ID <> 10 ORDER BY Forum_Category_ID, Forum_ID"
rsForums.open sqlForums, adoConn, CMDText
if not (rsForums.eof or rsForums.bof) then
ForumCnt = rsForums.recordcount
ForumData = rsForums.getrows()
else
ForumCnt = 0
end if
rsForums.close
set rsForums = nothing
tempCnt = 0
tempCategory = ""
response.write("<select name='Forum' style='width: 300px'><option value='0'>All Open Forums</option>")
do until tempCnt = ForumCnt
if tempCategory <> ForumData(2, tempCnt) then
tempCategory = ForumData(2, tempCnt)
response.write("<option value='C"& ForumData(2, tempCnt) &"'>"& ForumData(3, tempCnt) &"</option>")
end if
response.write("<option value='"& ForumData(0, tempCnt) &"'>- - "& ForumData(1, tempCnt) &"</option>")
tempCnt = tempCnt + 1
loop
response.write("</select>")
%>
<table width="300" border="0" cellspacing="0" cellpadding="0">
<tr align="left" valign="middle">
<td><input type="radio" name="Topics" value="1" checked> Search 话题 Only</td>
</tr>
<tr align="left" valign="middle">
<td><input type="radio" name="Topics" value="0"> Search 全部贴子</td>
</tr>
</table>
</td>
<td valign="top">
<select name="Date" style="width: 100px; border: 1px solid black">
<option value="0">所有日期</option>
<option value="1">昨天</option>
<option value="7">上星期</option>
<option value="28">上个月</option>
<option value="294">半年前</option>
<option value="365">一年前</option>
</select>
<table width="100" border="0" cellspacing="0" cellpadding="0">
<tr align="left" valign="middle">
<td><input type="radio" name="Age" value="1" checked>And Newer</td>
</tr>
<tr align="left" valign="middle">
<td><input type="radio" name="Age" value="0">And Older</td>
</tr>
</table>
</td>
<td valign="top">
<select name="OrderType" style="width: 100px; border: 1px solid black">
<option value="FT.Topic_Time">日期</option>
<option value="FT.Topic_Forum_ID">论坛</option>
</select>
<table width="100" border="0" cellspacing="0" cellpadding="0">
<tr align="left" valign="middle">
<td><input type="radio" name="Order" value="1"> Ascending</td>
</tr>
<tr align="left" valign="middle">
<td><input type="radio" name="Order" value="0" checked> Descending</td>
</tr>
</table>
</td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center" valign="top">
<input name="reset" type="reset" value="重置" style="width: 100px">
<input name="button" type="submit" value="完成" style="width: 100px"></td>
</tr>
</form>
</table>
<%
end if
if Action = "Results" then
'define keywords
strKeywords = split(trim(request.form("Keyword")), " ")
strKeywordCnt = ubound(strKeywords) + 1
tmpCnt = 0
'create search string
do until tempCnt = strKeywordCnt
if len(strKeywords(tempCnt)) > 3 then
if request.form("Topics") = 1 then
strSearchTerms = strSearchTerms & " Post_Title LIKE "
else
strSearchTerms = strSearchTerms & " Post_Text LIKE "
end if
strSearchTerms = strSearchterms & "'%" & strKeywords(tempCnt) & "%'"
if tempCnt + 1 < strkeywordCnt then
strSearchTerms = strSearchTerms & " OR "
end if
else
strRemoved =true
end if
tempCnt = tempCnt + 1
loop
'generate any applicable error message
if len(strSearchTerms) = 0 then
strMessage = "Your search did not include any valid keywords. All search keywords must be greater in length than three characters otherwise they will be ignored. Click <a href=""search.asp?Action=Search"">here</a> if you are not redirected within 5 seconds."
strRedirectURL = "search.asp?Action=Search"
end if
if session("userid") = "" then
strMessage = "你还没有登陆, please log in and try agian. Click <a href='default.asp'>here</a> if you are not redirected within 5 seconds."
strRedirectURL = "default.asp"
end if
'Display error message if it exists
if strMessage <> "" then
response.write("<table width='100%' border='0' cellspacing='1' cellpadding='3' align='center' class='main'><tr valign='middle' class='title'><td align='center'>"& Site_Name &" // Error</td>")
response.write("</tr><tr valign='top' class='body'><td align='center'>"& strMessage &"</td></tr></table><META HTTP-EQUIV='Refresh' CONTENT='5; URL="& strRedirectURL &"'>")
else
'Start building sql statement
sqlSearch = "SELECT DISTINCT FP.Post_Topic_ID, FT.Topic_User_ID, FT.Topic_Last_User_ID, FT.Topic_Title, FT.Topic_Views, FT.Topic_Replies, FT.Topic_Type, FT.Topic_Status, FU.User_Name AS UserOne, FU2.User_Name AS UserTwo, FT.Topic_Time, FT.Topic_Forum_ID, FF.Forum_Name FROM (((Forum_Posts FP INNER JOIN Forum_Topics FT ON FP.Post_Topic_ID = FT.Topic_ID) INNER JOIN Forum_Users FU ON FT.Topic_User_ID = FU.User_ID) INNER JOIN Forum_Users FU2 ON FT.Topic_Last_User_ID = FU2.User_ID) INNER JOIN Forum_Forums FF ON FT.Topic_Forum_ID = FF.Forum_ID WHERE"
sqlsearch = sqlSearch & strSearchterms
'specify dates
if request.form("Date") <> 0 then
if request.form("Age") = 1 then
sqlSearch = sqlSearch & " AND Post_Time >= "& search_date(request.form("Date")) &") "
else
sqlSearch = sqlSearch & " AND Post_Time <= "& search_date(request.form("Date")) &") "
end if
end if
'specify forum or category
if request.form("Forum") <> "0" then
if instr(1, request.form("Forum"), "C", 1) <> 0 then
sqlSearch = sqlSearch & " AND Post_Category_ID = " & right(request.form("Forum"), 1)
else
sqlSearch = sqlSearch & " AND Post_Forum_ID = " & request.form("Forum")
end if
end if
'sepcify open and sticky posts only
sqlSearch = sqlSearch & " AND FT.Topic_Type <> 0 AND FT.Topic_Type <> 3 "
'sepcify order
if request.form("Order") = 1 then
sqlsearch = sqlSearch & " ORDER BY "& request.form("OrderType") & " ASC"
else
sqlsearch = sqlSearch & " ORDER BY "& request.form("OrderType") & " DESC"
end if
'execute search
set rsSearch = server.createobject("adodb.recordset")
rsSearch.open sqlSearch, adoConn, CMDText
if rsSearch.eof or rsSearch.bof then
rsSearch.close
set rsSearch = nothing
response.write("<table width='100%' border='0' cellspacing='1' cellpadding='3' align='center' class='main'><tr valign='middle' class='title'><td align='center'>"& Site_Name &" // Search</td>")
response.write("</tr><tr valign='top' class='body'><td align='center'>没有找到任何结果. 重新查找或者等待一下. Click <a href='search.asp'>here</a> if you are not redirected within 5 seconds.</td></tr></table><META HTTP-EQUIV='Refresh' CONTENT='5; URL=search.asp'>")
else
'Draw search table header
response.write("<table width='100%' border='0' cellspacing='1' cellpadding='3' align='center' class='main'><tr align='left' valign='middle' class='title'><td></td><td align='left'>Topic</td><td align='center' nowrap>Forum</td><td align='center' nowrap>Topic Starter</td><td align='center'>Replies</td><td align='center'>Views</td><td align='center' nowrap>Last Post</td></tr>")
'Set search page size
iPagesize = Site_View_Topic
'Set current page
if request.querystring("P") = "" then
iPageCurrent = 1
else
iPageCurrent = clng(request.querystring("P"))
end if
iPageCount = rsSearch.PageCount
if iPageCurrent > iPageCount then iPageCurrent = iPageCount
if iPageCurrent < 1 then iPageCurrent = 1
rsSearch.AbsolutePage = iPageCurrent
SearchData = rsSearch.GetRows(iPageSize)
SearchCnt = UBound(SearchData, 2) + 1
rsSearch.close
set rsSearch = nothing
'Re-Initialise temporary counter
tempCnt = 0
'Display topics from the specified forums
do until tempCnt = SearchCnt
response.write("<tr align='left' valign='middle' class='body'><td width='20' align='center'>")
'Image Select Code
strReadCookie = request.cookies(site_name)("read")
strReadTopic = "r" & SearchData(0,tempCnt) & "r"
if (int(session("laston")) >= int(SearchData(10,tempCnt))) or instr(1, strReadCookie, strReadTopic, 1) >= 1 or session("userid") = "" then
image = "old"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -