Recently, ESET add my domain name to the black-list of their database. You can’t open my site and been warned my site is not safe if your PC is running the ESS or EAV. Why Eset block my site?The answer is obvious. That is reason that you come here. I promise that my site is pure, no virus, no spyware, no Trojan, no pop ads. You can test my word through intalling Kaspersky or other Antivirus Software. If you want open my site and take latest escalation ID & Activation Code, close your ESET software(disable antivirus and antispyware protection function temporarily) or by proxy or virtual machinor. You can also feed the RSS source http://feed.loserblog.cn.
Home > Life > asp simple search engine code

asp simple search engine code

Below are the library URLINDEX Table: URL and the Keywords field were added to the index.

  URL text (Index: (without duplication))
Title text
Description text
Summary text
Keywords text (Index: (without duplication))

doquery.asp

  <HTML> <HEAD> <TITLE> Simple search engine </ TITLE> </ HEAD>
<BODY BGCOLOR = # ffffff MARGINWIDTH = "0" MARGINHEIGHT = "0"
LEFTMARGIN = 0 TOPMARGIN = 0>

<FORM METHOD="post" ACTION="doquery.asp?act=search">
  Query: <INPUT TYPE="Text" NAME="QueryString"> <BR>
  <INPUT TYPE="Submit" VALUE="Submit">
</ FORM>
</ CENTER>


<%
dim act
act = request ( "act")
if (act = "search") then
  QueryString = Request.form ( "QueryString")
  QueryWords = Split (QueryString)
  strIndent = ""

  'If the search is to return to the air
  If QueryString = "" Then
   Response.Redirect ( "default.asp")
  End If

  Session.timeout = 2
  If IsObject (Session ( "sitesearch_conn")) Then
      Set conn = Session ( "sitesearch_conn")
  Else
      Set conn = Server.CreateObject ( "ADODB.Connection")
      conn.open "driver = (Microsoft Access Driver (*. mdb)); dbq =" & Server.MapPath ( "database / SiteSearch.mdb "),"",""
      Set Session ( "sitesearch_conn") = conn
  End If

  'Query
  sql = "Select * FROM [URLIndex] Where"
  


  'Search field Description
  sql = sql & "([Description] LIKE '%" & QueryWords (0) & "%'" 'First
  For i = LBound (QueryWords) + 1 to UBound (QueryWords)
   If QueryWords (i) <> "" and UCase (QueryWords (i)) <> "OR" and UCase (QueryWords (i)) <> "AND" Then
    If uCase (QueryWords (i-1)) = "OR" Then
     sql = sql & "OR [Description] LIKE '%" & QueryWords (i) & "%'"
    Else
     sql = sql & "AND [Description] LIKE '%" & QueryWords (i) & "%'"
    End If
   End If
  Next

  'Search Keywords field
  sql = sql & ") or ([Keywords] LIKE '%" & QueryWords (0) & "%'"
  For i = LBound (QueryWords) + 1 to UBound (QueryWords)
   If QueryWords (i) <> "" and UCase (QueryWords (i)) <> "OR" and UCase (QueryWords (i)) <> "AND" Then
    If uCase (QueryWords (i-1)) = "OR" Then
     sql = sql & "OR [Keywords] LIKE '%" & QueryWords (i) & "%'"
    Else
     sql = sql & "AND [Keywords] LIKE '%" & QueryWords (i) & "%'"
    End If
   End If
  Next


  'Search field Title
  sql = sql & ") or ([Title] LIKE '%" & QueryWords (0) & "%'"
  For i = LBound (QueryWords) + 1 to UBound (QueryWords)
   If QueryWords (i) <> "" and UCase (QueryWords (i)) <> "OR" and UCase (QueryWords (i)) <> "AND" Then
    If uCase (QueryWords (i-1)) = "OR" Then
     sql = sql & "OR [Title] LIKE '%" & QueryWords (i) & "%'"
    Else
     sql = sql & "AND [Title] LIKE '%" & QueryWords (i) & "%'"
    End If
   End If
  Next


  'Search field Summary
  sql = sql & ") or ([Summary] LIKE '%" & QueryWords (0) & "%'"
  For i = LBound (QueryWords) + 1 to UBound (QueryWords)
   If QueryWords (i) <> "" and UCase (QueryWords (i)) <> "OR" and UCase (QueryWords (i)) <> "AND" Then
    If uCase (QueryWords (i-1)) = "OR" Then
     sql = sql & "OR [Summary] LIKE '%" & QueryWords (i) & "%'"
    Else
     sql = sql & "AND [Summary] LIKE '%" & QueryWords (i) & "%'"
    End If
   End If
  Next

  sql = sql & ")"


     '
     Set rs = Server.CreateObject ( "ADODB.Recordset")
     rs.Open sql, conn, 3, 3
  
     Response.Write "<BR> <B> your search is: </ B>" & QueryString
  
     Response.Write "<BR> <B> search keyword: </ B>"
  For i = LBound (QueryWords) to UBound (QueryWords)
   Response.Write "<BR>" & strIndent & i & ":" & QueryWords (i)
  Next

     'Print the SQL String
     Response.Write "<BR> <B> sql statement: </ B>" & sql

  'Print the Results
     Response.Write "<BR> <B> results: </ B> <UL>"
  On Error Resume Next
  rs.MoveFirst
  Do While Not rs.eof
   Response.Write "<BR>" & "<A HREF='OpenPage.asp?IndexURL=" & rs.Fields("URL").Value & "'>" & rs.Fields ( "Title") & "< / A> – "
   Response.Write rs.Fields ( "Description") & "<BR>"
   Response.Write "<FONT SIZE=2> URL:" & rs.Fields ( "URL") & "</ FONT>"
   Response.Write "<HR SIZE=1 WIDTH=200 ALIGN=LEFT>"
   rs.MoveNext
  Loop
  Response.Write "</ UL>"

end if
%>


</ BODY>
</ HTML>

Categories: Life Tags:
  1. No comments yet.
  1. No trackbacks yet.
  • Partner links