|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
大家可以自己去看一看.可以说看得想呕吐.以前有次下了个动网来看.里面连基本内置函数的保护措施(函数没防御性)都没有.难怪经常补这个补那个了.可能现在.NET版会好点吧搜刮引擎上面是库中URLINDEX表:URL和Keywords字段分离增加了索引.
URL文本(索引:有(无反复))
Title文本
Description文本
Summary文本
Keywords文本(索引:有(无反复))
doquery.asp
<HTML><HEAD><TITLE>复杂搜刮引擎</TITLE></HEAD>
<BODYBGCOLOR=#ffffffMARGINWIDTH="0"MARGINHEIGHT="0"
LEFTMARGIN=0TOPMARGIN=0>
<FORMMETHOD="post"ACTION="doquery.asp?act=search">
Query:<INPUTTYPE="Text"NAME="QueryString"><BR>
<INPUTTYPE="Submit"VALUE="Submit">
</FORM>
</CENTER>
<%
dimact
act=request("act")
if(act="search")then
QueryString=Request.form("QueryString")
QueryWords=Split(QueryString)
strIndent=""
假如搜刮为空则前往
IfQueryString=""Then
Response.Redirect("default.asp")
EndIf
Session.timeout=2
IfIsObject(Session("sitesearch_conn"))Then
Setconn=Session("sitesearch_conn")
Else
Setconn=Server.CreateObject("ADODB.Connection")
conn.open"driver={MicrosoftAccessDriver(*.mdb)};dbq="&Server.MapPath("database/SiteSearch.mdb"),"",""
SetSession("sitesearch_conn")=conn
EndIf
查询语句
sql="SELECT*FROM[URLIndex]WHERE"
搜刮Description字段
sql=sql&"([Description]LIKE%"&QueryWords(0)&"%"First
Fori=LBound(QueryWords)+1toUBound(QueryWords)
IfQueryWords(i)""andUCase(QueryWords(i))"OR"andUCase(QueryWords(i))"AND"Then
IfuCase(QueryWords(i-1))="OR"Then
sql=sql&"OR[Description]LIKE%"&QueryWords(i)&"%"
Else
sql=sql&"AND[Description]LIKE%"&QueryWords(i)&"%"
EndIf
EndIf
Next
搜刮Keywords字段
sql=sql&")OR([Keywords]LIKE%"&QueryWords(0)&"%"
Fori=LBound(QueryWords)+1toUBound(QueryWords)
IfQueryWords(i)""andUCase(QueryWords(i))"OR"andUCase(QueryWords(i))"AND"Then
IfuCase(QueryWords(i-1))="OR"Then
sql=sql&"OR[Keywords]LIKE%"&QueryWords(i)&"%"
Else
sql=sql&"AND[Keywords]LIKE%"&QueryWords(i)&"%"
EndIf
EndIf
Next
搜刮Title字段
sql=sql&")OR([Title]LIKE%"&QueryWords(0)&"%"
Fori=LBound(QueryWords)+1toUBound(QueryWords)
IfQueryWords(i)""andUCase(QueryWords(i))"OR"andUCase(QueryWords(i))"AND"Then
IfuCase(QueryWords(i-1))="OR"Then
sql=sql&"OR[Title]LIKE%"&QueryWords(i)&"%"
Else
sql=sql&"AND[Title]LIKE%"&QueryWords(i)&"%"
EndIf
EndIf
Next
搜刮Summary字段
sql=sql&")OR([Summary]LIKE%"&QueryWords(0)&"%"
Fori=LBound(QueryWords)+1toUBound(QueryWords)
IfQueryWords(i)""andUCase(QueryWords(i))"OR"andUCase(QueryWords(i))"AND"Then
IfuCase(QueryWords(i-1))="OR"Then
sql=sql&"OR[Summary]LIKE%"&QueryWords(i)&"%"
Else
sql=sql&"AND[Summary]LIKE%"&QueryWords(i)&"%"
EndIf
EndIf
Next
sql=sql&")"
Setrs=Server.CreateObject("ADODB.Recordset")
rs.Opensql,conn,3,3
Response.Write"<BR><B>你搜刮的是:</B>"&QueryString
Response.Write"<BR><B>搜刮的关头字:</B>"
Fori=LBound(QueryWords)toUBound(QueryWords)
Response.Write"<BR>"&strIndent&i&":"&QueryWords(i)
Next
PrinttheSQLString
Response.Write"<BR><B>sql语句:</B>"&sql
PrinttheResults
Response.Write"<BR><B>了局:</B><UL>"
OnErrorResumeNext
rs.MoveFirst
DoWhileNotrs.eof
Response.Write"<BR>"&"<AHREF=OpenPage.asp?IndexURL="&rs.Fields("URL").Value&">"&rs.Fields("Title")&"</A>-"
Response.Writers.Fields("Description")&"<BR>"
Response.Write"<FONTSIZE=2>URL:"&rs.Fields("URL")&"</FONT>"
Response.Write"<HRSIZE=1WIDTH=200ALIGN=LEFT>"
rs.MoveNext
Loop
Response.Write"</UL>"
endif
%>
</BODY>
</HTML>
缺点:安全性不是太差了,还行,只要你充分利用系统自带的工具;唯一缺点就是执行效率慢,如何进行网站优化以后,效果会比较好。 |
|