CSDN博客

img gengwei80

Indexing Service查询

发表于2004/10/10 15:19:00  738人阅读

<%@ Language=VBScript %>
<%
    Response.Expires = 0
    Response.Buffer = false
%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE>Indexing Service</TITLE>
<style type="text/css">
    body, p, div, th, td, br, a, input, textarea, select
    {
        font-family: "Tahoma", "宋体";
        font-size: "12px";
    }

    a:link
    {
        color: "#336699";
        text-decoration: none;
    }

    a:visited
    {
        color: "#6699CC";
        text-decoration: none;
    }

    a:hover
    {
        color: "#996633";
        text-decoration: underline;
    }
</style></HEAD>
<%
work=request("work")
if work<>"search" then

%>
<BODY scroll=no>
<TABLE cellSpacing=1 cellPadding=1 width="100%" border=1>
  <form action=200server.Asp method=get name=Index target="result">
  <INPUT type="hidden" name=work value="search">
  <TR>
    <TD bgColor=#ffff99>
      <P>Search for: <INPUT id=keyword name=keyword size=50>
      <select name="stype">
        <option value="1" selected>一般</option>
        <option value="2">精确</option>
        <option value="4">模糊</option>
      </select>
      <select name="pagesize">
        <option value="10">10</option>
        <option value="20" selected>20</option>
        <option value="30">30</option>
        <option value="50">50</option>
        <option value="100">100</option>
        <option value="200">200</option>
        <option value="500">500</option>
        <option value="all">All</option>
      </select>
      <INPUT type=submit value="Perform">&nbsp; <INPUT style="LEFT: 285px; TOP: 41px" type=reset value="Clear"></P></TD>
    </TR>
    <tr>
   <td>
    <iframe src=about:blank border=0 frameborder=0 id=result name=result height=350 width=100%></iframe>
   </td>
  
   </tr>
    </form>
    </TABLE>
<HR>
(C) 2003/12/26 <U>geng Wei</U> - <STRONG>Windows 2000 Server Indexing Service</STRONG>

<%else
    Response.Write "<BODY>"
    dim keyword
    dim stype
    dim pagesize
    oldkeyword = Request("keyword")
    keyword = replace(oldkeyword,"'","''")

    function clen(str)
        For i = 1 To Len(str)
            zh = Mid(str, i, 1)
            zhasc = Asc(zh)
            If zhasc < 0 Then
                clen=false
                exit function
            End If
        Next
        if len(str)<3 then clen=true else clen=false
    end function

    if clen(keyword) then
        Response.Write "没有任何结果 - 关键字必须 > 3(英文) or > 1(中文)。"
        Response.End
    end if

    stype = cstr(Request("stype"))
    pagesize = Request("pagesize")
    dim page
    page = clng(request("page"))
    if page<1 then page=1

    if keyword <> "" then

    dim con, rs
    set con = server.CreateObject("adodb.connection")
    set rs = server.CreateObject("adodb.recordset")

    dim strSearchSQL
    select case stype
        case "1"
            strSearchSQL = "select DocTitle, vPath, FileName, Characterization, Size, Rank from scope() where contains('" & keyword & "') order by Rank Desc"

        case "2"
            strSearchSQL = "select DocTitle, vPath, FileName, Characterization, Size, Rank from scope() where freetext('" & keyword & "') order by Rank Desc"

        case "4"
            strSearchSQL = "select DocTitle, vPath, FileName, Characterization, Size, Rank from scope() where contains('formsof(INFLECTIONAL,""" & keyword & """)') order by Rank Desc"

    end select
    'Response.Write stype & strSearchSQL

    con.Open "Provider=MSIDXS; Data Source=Web"
    rs.Open strSearchSQL, con, 3
    if pagesize="all" then pagesize = rs.RecordCount
    pagesize=clng(pagesize)
    rs.PageSize = pagesize
    if page> rs.PageCount then page=rs.PageCount
    if not rs.BOF then rs.AbsolutePage = page

    ahref = "200server.asp?work=search&keyword=" & keyword & "&stype=" & stype & "&pagesize=" & pagesize

    Response.Write "<h3>Results of search for <EM>" & server.HTMLEncode(oldkeyword) & "</EM></h3> Total records: " & rs.RecordCount

    call pageinfo

    for i=1 to rs.PageSize
        if rs.EOF then exit for
        %>
        <table border=0 width='100%' cellpadding=0 cellspacing=0>
            <tr bgColor=#ccccff>
                <td width="5%"><%=i+pagesize * (page-1)%>.</td>
                <td><STRONG><%
                    if len(rs("DocTitle")) then
                        Response.Write server.HTMLEncode(rs("DocTitle"))
                    else
                        Response.Write server.HTMLEncode(left(rs("FileName"),instrrev(rs("FileName"),".")-1))
                    end if
                %></STRONG></td>
                <td width='10%' align='right'><STRONG><%=rs("Rank")%>‰</STRONG></td>
            </tr>
            <tr>
                <td colspan=3><%=server.HTMLEncode(rs("Characterization"))%></td>
            </tr>
            <tr>
                <td colspan=3><a href='<%=rs("vPath")%>' target=_blank><%=rs("FileName")%></a> (<%=rs("Size")%> bytes)</td>
            </tr>
        </table>
        <%
        rs.MoveNext
    next

    Response.Write "<hr>"

    call pageinfo

    end if
   
sub pageinfo
    Response.Write "<p><b>"

    if page>1 then
        Response.Write "<a href='" & ahref & "&page=1'>" & server.HTMLEncode("|<") & "</a>"
        Response.Write " "
        Response.Write "<a href='" & ahref & "&page=" & page-1 & "'>" & server.HTMLEncode("<<") & "</a>"
    else
        Response.Write server.HTMLEncode("|<")
        Response.Write " "
        Response.Write server.HTMLEncode("<<")
    end if
    Response.Write " "
    if page<rs.PageCount then
        Response.Write "<a href='" & ahref & "&page=" & page+1 & "'>" & server.HTMLEncode(">>") & "</a>"
        Response.Write " "
        Response.Write "<a href='" & ahref & "&page=" & rs.PageCount & "'>" & server.HTMLEncode(">|") & "</a>"
    else
        Response.Write server.HTMLEncode(">>")
        Response.Write " "
        Response.Write server.HTMLEncode(">|")
    end if

    Response.Write " - " & pagesize & " Records/Page"
    Response.Write " - " & page & "/" & rs.PageCount & " Pages"
    Response.Write "</b><br>"

    for i=1 to rs.PageCount
        if i=page then
            Response.Write "<b>[" & i & "]</b>"
        else
            Response.Write "<a href='" & ahref & "&page=" & i & "'>[" & i & "]</a>"
        end if
    next
   
    Response.Write "</p>"
end sub

end if
%>

</BODY>
</HTML>

阅读全文
0 0

相关文章推荐

img
取 消
img