📄 search.asp
字号:
<%Option Explicit%>
<%
'*************************************************************************************
' write by Lanmang Studio 龙家深
' 2005.8 release it
' Homepage: http://www.com2008.com
'*************************************************************************************
%>
<%
dim objRS,sql
dim keyword '查询关键字
dim op '逻辑操作——与?或?
dim si '查找网站?类目?
dim lang '网站语言
dim sortid '在ID号为sortid的类下查询
dim wanwei '查询范围——网址、网站标题、网站说明、提交人
dim i,getpidsql,objRS_getpid,pidlist,tmp
dim keywordlist,likelist
dim pagecount,currpage,Spage,Epage,recordcount,Query_String
keyword = Request.QueryString("keyword")
op = Request.QueryString("op")
si = Request.QueryString("si")
lang = UCase(Request.QueryString("lang"))
sortid = Request.QueryString("sortid")
wanwei = Request.QueryString("wanwei")
keyword = replace(keyword,"'","") '过滤关键字
keyword = replace(keyword,"[","")
keyword = trim(keyword)
if Trim(keyword) = "" then
Response.Write("<center><font color=red>请输入关键字!</font><br><a href=http://gz.com2008.com>广州城市信息网</a></center>")
Response.End
end if
if Trim(wanwei) = "" and Trim(si) = "STA" then
Response.Write("<center><font color=red>请定义查询范围!</font><br>欢迎使用中国龙★惠惠龙搜索引擎。</center>")
Response.End
end if
currpage = request.querystring("page")
if currpage = "" or IsNull(currpage) then currpage = 1
if not IsNumeric(currpage) then currpage = 1
currpage = Cint(currpage)
Query_String = request.ServerVariables("QUERY_STRING")
%>
<!--#include file="2008admin/CONFIG.ASP"-->
<!--#include file="con-the-hhlong.asp"-->
<%
keywordlist = split(keyword,chr(32)) '按空格分割关键字
if UCase(op) = "OR" then
op = "OR"
else
op = "AND"
end if
if UCase(si) = "SORT" then
likelist = mklikelist("sortname",keywordlist,op)
sql = "select * from sort where " & likelist
else
if trim(wanwei) = "" then wanwei = "stationurl,stationname,sitename,description,siteabout,whopost,sitearea"
wanwei = split(wanwei,chr(44))
likelist = ""
for i = 0 to UBound(keywordlist)
likelist = likelist & " " & op & " " & mklikelist2(wanwei,keywordlist(i),"or")
next
likelist = right(likelist,len(likelist) - len(" " & op & " "))
sql = "select * from stationinfo where " & likelist
if trim(lang) <> "" and lang <> "ALL" then
sql = sql & " and stationlang = '" & lang & "'"
end if
if trim(sortid) <> "" and IsNumeric(sortid) and sortid <> -1 and sortid <> "-1" then
getpidsql = "select * from pathform where (thispath = '" & sortid & "') or (thispath like '%" & chr(44) & sortid & chr(44) & "%') or (thispath like '%" & chr(44) & sortid & "') or (thispath like '" & sortid & chr(44) & "%')"
'Response.Write("getpidsql: " & getpidsql & "<br>")
Set objRS_getpid = objConn.Execute(getpidsql)
pidlist = ""
do while not objRS_getpid.EOF
tmp = objRS_getpid("thispath")
pidlist = pidlist & chr(44) & getEndID(tmp)
objRS_getpid.MoveNext()
loop
'Response.Write("pidlist: " & pidlist & "<br>")
if pidlist <> "" then
pidlist = "(" & right(pidlist,len(pidlist) - 1) & ")"
sql = sql & " and parentid in " & pidlist
end if
end if
sql = sql & " and ispass = TRUE order by parentid"
end if
'Response.Write("sql: " & sql & "<br>")
Set objRS = Server.CreateObject("ADODB.RecordSet")
objRS.Open sql, objConn, 3, 1
recordcount = objRS.RecordCount
objRS.PageSize = PAGESIZE
pagecount = objRS.PageCount
if currpage < 1 then
currpage = 1
elseif currpage > pagecount then
currpage = pagecount
end if
%>
<%
'//////////////////////////////////////////////// 输出查询结果 //////////////////////////////////////
dim objRS_path,pid,ischg,j
Response.Write("<HTML>" & VbCrlf)
Response.Write("<HEAD>" & VbCrlf)
Response.Write("<meta HTTP-EQUIV=""Content-Type"" CONTENT=""text/html; charset=gb2312"">" & VbCrlf)
Response.Write("<title>分类信息搜索</title>" & VbCrlf)
%>
<link href="com2008.css" rel="stylesheet" type="text/css">
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0">
<!--#include file="include-top.htm"-->
<table width="950" border="0" align="center" cellpadding="20" cellspacing="0">
<tr>
<td valign="top"> <ul>
<li>您搜索的关键字为: <font color=red><%=keyword%></font> </li>
</ul>
<%
'========================================实现翻页=============================
if pagecount > 1 then
if UCase(si) <> "SORT" then
response.write("共找到" & recordcount & "条信息 分为" & pagecount & "页 每页" & PAGESIZE & "条信息<br>" & VbCrlf)
else
response.write("共找到" & recordcount & "个类目 分为" & pagecount & "页 每页" & PAGESIZE & "个类目<br>" & VbCrlf)
end if
Response.Write("<font color=red>" & currpage & "</font>/" & pagecount & VbCrlf)
Spage = currpage mod PARTSIZE
if currpage > PARTSIZE then
if Spage = 0 then Spage = PARTSIZE
Spage = currpage - Spage + 1
else
Spage = 1
end if
Epage = Spage + PARTSIZE - 1
if Epage > pagecount then Epage = pagecount
if currpage > PARTSIZE then
response.write("<a href=""search.asp?" & GoToPage(Query_String,Spage - 1) & """>前" & PARTSIZE & "页</a>" & VbCrlf)
end if
for i = Spage to Epage
if i = currpage then
response.write("[<font style={color:red}><b>" & i & "</b></font>]" & VbCrlf)
else
response.write("[<a href=""search.asp?" & GoToPage(Query_String,i) & """>" & i & "</a>]" & VbCrlf)
end if
next
if Epage < pagecount then
response.write("<a href=""search.asp?" & GoToPage(Query_String,Epage + 1) & """>后" & PARTSIZE & "页</a>" & VbCrlf)
end if
if Spage <> 1 then response.write("[<a href=""search.asp?" & GoToPage(Query_String,1) & """>第一页</a>]")
if Epage <> pagecount then response.write("[<a href=""search.asp?" & GoToPage(Query_String,pagecount) & """>最末页</a>]" & VbCrlf)
response.write("<br>")
elseif recordcount > 0 then
if UCase(si) <> "SORT" then
Response.Write("共找到 " & recordcount & " 条相关信息<br>")
else
Response.Write("共找到 " & recordcount & " 个相关类目<br>")
end if
else
Response.Write("<br>")
if UCase(si) <> "SORT" then
Response.Write("与关键字<font color=red>"&keyword&"</font>相关的网页有:")
Response.Write("<p>")
Response.Write("<a href=http://www.baidu.com/baidu?tn=qy5com&word="&keyword&" target=_blank><font size=5>"&keyword&"</font></a>中文搜索<p>")
Response.Write("<a href=http://www.google.com/search?hl=zh-CN&inlang=zh-CN&ie=GB2312&oe=GB2312&q="&keyword&" target=_blank><font size=5>"&keyword&"</font></a>全球搜索</p></p>")
else
Response.Write("无匹配类目")
end if
Response.Write(" <center><font color=red><a href=""JavaScript: history.go(-1)"">返回</a></font></center><br>")
end if
'=============================================完成翻页==============================================
%> <%
if not objRS.EOF then objRS.AbsolutePage = currpage
if UCase(si) = "SORT" then
Response.Write("<ul>" & VbCrlf)
for i = 1 to PAGESIZE
if objRS.EOF then exit for
pid = objRS("ID")
sql = "select * from pathform where thispath = '" & pid & "' or thispath like '%" & chr(44) & pid & "'"
Set objRS_path = objConn.Execute(sql)
if objRS_path.EOF then
'Response.Write("有错误发生<br>")
else
Response.Write("<a href=""shop.asp?sortid=" & pid & """>首页∷" & replace(objRS_path("pathname"),chr(255),"∷") & "</a><p>" & VbCrlf)
end if
objRS.MoveNext()
next
else
j = ""
for i = 1 to PAGESIZE
if objRS.EOF then exit for
ischg = FALSE
pid = objRS("parentid")
if j <> pid then
if j <> "" then Response.Write("<p>" & VbCrlf)
j = pid
ischg = TRUE
sql = "select * from pathform where thispath = '" & pid & "' or thispath like '%" & chr(44) & pid & "'"
Set objRS_path = objConn.Execute(sql)
if objRS_path.EOF then
'Response.Write("有错误发生<br>")
else
Response.Write("<br>")
end if
end if
Response.Write("<table width=100% border=0 cellspacing=0 cellpadding=3><tr><td width=21% align=""right"" valign=""top"">")
Response.Write(" 【<font color=red>" & objRS("stationlang") & "</font>】<br>")
Response.Write("<a href=information.asp?ID="& objRS("id") &" target=_blank>查看详细信息</a>")
Response.Write("</td><td width=79% valign=top>")
Response.Write("<P class=s1><b>信息:</b>" & objRS("stationname") & VbCrlf)
Response.Write("<br> <b>内容:</b>"& objRS("description") & "")
Response.Write("<br>联系人:"& objRS("infoname") & " 电话:" & objRS("sitearea") & " 邮箱:" & objRS("email") &VbCrlf)
Response.Write("</td></tr></table><br>")
objRS.MoveNext()
next
end if
if pagecount > 1 then
Response.Write("<font color=red>" & currpage & "</font>/" & pagecount & VbCrlf)
if currpage > PARTSIZE then
response.write("<a href=""search.asp?" & GoToPage(Query_String,Spage - 1) & """>前" & PARTSIZE & "页</a>" & VbCrlf)
end if
for i = Spage to Epage
if i = currpage then
response.write("[<font style={color:red}><b>" & i & "</b></font>]" & VbCrlf)
else
response.write("[<a href=""search.asp?" & GoToPage(Query_String,i) & """>" & i & "</a>]" & VbCrlf)
end if
next
if Epage < pagecount then
response.write("<a href=""search.asp?" & GoToPage(Query_String,Epage + 1) & """>后" & PARTSIZE & "页</a>" & VbCrlf)
end if
if Spage <> 1 then response.write("[<a href=""search.asp?" & GoToPage(Query_String,1) & """>第一页</a>]")
if Epage <> pagecount then response.write("[<a href=""search.asp?" & GoToPage(Query_String,pagecount) & """>最末页</a>]" & VbCrlf)
response.write("<br>")
end if
Response.Write("<br>" & VbCrlf)
Response.Write("<center>" & VbCrlf)
%> </td>
</tr>
</table>
<!--#include file="buttom.asp"-->
<%
Response.Write("</body>" & VbCrlf)
Response.Write("</html>" & VbCrlf)
%>
<%
objConn.Close()
Set objRS = nothing
Set objRS_path = nothing
Set objConn = nothing
%>
<%
function mklikelist(recname,arr,op)
dim i,tmparr
tmparr = arr
for i = 0 to UBound(tmparr)
tmparr(i) = "(" & recname & " like '%" & tmparr(i) & "%')"
next
mklikelist = "(" & join(tmparr," " & op & " ") & ")"
end function
function mklikelist2(recnamearr,keyword,op)
dim i,tmparr
tmparr = recnamearr
for i = 0 to UBound(tmparr)
tmparr(i) = "(" & tmparr(i) & " like '%" & keyword & "%')"
next
mklikelist2 = "(" & join(tmparr," " & op & " ") & ")"
end function
function getEndID(idlist)
dim pos
for pos = len(idlist) to 1 step -1
if mid(idlist,pos,1) = chr(44) then exit for
next
if pos < 1 then
getEndID = idlist
else
getEndID = right(idlist,len(idlist) - pos)
end if
end function
'***********************************************************
'GoToPage(Query_String,page)
'返回在参数Query_String中替换或加入“page=”page字符串
'***********************************************************
function GoToPage(Query_String,page)
dim lens,s1,s2,pos,i
lens = len(Query_String)
pos = instr(Query_String,"page=")
if pos = 0 or IsNull(pos) then pos = instr(Query_String,"PAGE=")
if pos = 0 or IsNull(pos) then
GoToPage = Query_String & "&page=" & page
exit function
end if
s1 = left(Query_String,pos - 1 + len("page="))
i = pos + len("page=")
do while (i <= lens) and (mid(Query_String,i,1) <> "&")
i = i + 1
loop
if i > lens then
GoToPage = s1 & page
else
s2 = right(Query_String,lens - i)
GoToPage = s1 & page & "&" & s2
end if
end function
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -