home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 February / CHIP_2_98.iso / software / pelne / optionp / ins.cab / nntpqry.asp < prev    next >
Text File  |  1997-10-12  |  13KB  |  404 lines

  1. <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 3.0//EN" "html.dtd">
  2. <HTML>
  3. <HEAD>
  4.  
  5. <%
  6. ' ********** INSTRUCTIONS FOR QUICK CUSTOMIZATION **********
  7. '
  8. ' This form is set up for easy customization. It allows you to modify the
  9. ' page logo, the page background, the page title and simple query
  10. ' parameters by modifying a few files and form variables. The procedures
  11. ' to do this are explained below.
  12. '
  13. '
  14. ' *** Modifying the Form Logo:
  15.  
  16. ' The logo for the form is named is2logo.gif. To change the page logo, simply
  17. ' name your logo is2logo.gif and place in the same directory as this form. If
  18. ' your logo is not a GIF file, or you don't want to copy it, change the following
  19. ' line so that the logo variable contains the URL to your logo.
  20.  
  21.         FormLogo = "is2logo.gif"
  22.  
  23. '
  24. ' *** Modifying the Form's background pattern.
  25.  
  26. ' You can use either a background pattern or a background color for your
  27. ' form. If you want to use a background pattern, store the file with the name
  28. ' is2bkgnd.gif in the same directory as this file and remove the remark character
  29. ' the single quote character) from the line below. Then put the remark character on
  30. ' the second line below.
  31. '
  32. ' If you want to use a different background color than white, simply edit the
  33. ' bgcolor line below, replacing white with your color choice.
  34.  
  35. '       FormBG = "background = " & chr(34) & "is2bkgnd.gif" & chr(34)
  36.         FormBG = "bgcolor = " & chr(34) & "#FFFFFF" & chr(34)
  37.  
  38.  
  39. ' *** Modifying the Form's Title Text.
  40.  
  41. ' The Form's title text is set on the following line.
  42. %>
  43.  
  44.     <TITLE>NNTP Search Form</TITLE>
  45.  
  46. <%
  47. '
  48. ' *** Modifying the Form's Search Scope.
  49. '
  50. ' The form will search from the root of your web server's namespace and below
  51. ' (deep from "/" ). To search a subset of your server, for example, maybe just
  52. ' a PressReleases directory, modify the scope variable below to list the virtual path to
  53. ' search. The search will start at the directory you specify and include all sub-
  54. ' directories.
  55.  
  56.         FormScope = "/"
  57.  
  58. '
  59. ' *** Modifying the Number of Returned Query Results.
  60. '
  61. ' You can set the number of query results returned on a single page
  62. ' using the variable below.
  63.  
  64.         PageSize = 10
  65.  
  66. '
  67. ' *** Setting the Locale.
  68. '
  69. ' The following line sets the locale used for queries. In most cases, this
  70. ' should match the locale of the server. You can set the locale below.
  71.  
  72.         SiteLocale = "EN-US"
  73.  
  74.  
  75.  
  76. ' ********** END QUICK CUSTOMIZATION SECTIONS ***********
  77. %>
  78.  
  79.  
  80.     <META NAME="DESCRIPTION" CONTENT="Sample ASP query form for Microsoft Index Server v2.0">
  81.     <META NAME="AUTHOR"      CONTENT="Index Server Team">
  82.     <META NAME="KEYWORDS"    CONTENT="query, content, hit">
  83.     <META NAME="SUBJECT"     CONTENT="sample form">
  84.     <META NAME="MS.CATEGORY" CONTENT="Internet">
  85.     <META NAME="MS.LOCALE"   CONTENT="EN-US">
  86.     <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=Windows-1252">
  87.  
  88. <%
  89. ' Set Initial Conditions
  90.     NewQuery = FALSE
  91.     UseSavedQuery = FALSE
  92.     SearchString = ""
  93.  
  94.     QueryForm = Request.ServerVariables("PATH_INFO")
  95.  
  96. ' Did the user press a SUBMIT button to execute the form? If so get the form variables.
  97.     if Request.ServerVariables("REQUEST_METHOD") = "POST" then
  98.         SearchString = Request.Form("SearchString")
  99.         FreeText = Request.Form("FreeText")
  100.         ' NOTE: this will be true only if the button is actually pushed.
  101.         if Request.Form("Action") = "Go" then
  102.             NewQuery = TRUE
  103.         end if
  104.     end if
  105.     if Request.ServerVariables("REQUEST_METHOD") = "GET" then
  106.         SearchString = Request.QueryString("qu")
  107.                 FreeText = Request.QueryString("FreeText")
  108.                 FormScope = Request.QueryString("sc")
  109.         if Request.QueryString("pg") <> "" then
  110.             NextPageNumber = Request.QueryString("pg")
  111.             NewQuery = FALSE
  112.             UseSavedQuery = TRUE
  113.         else
  114.             NewQuery = SearchString <> ""
  115.         end if
  116.     end if
  117. %>
  118.  
  119. </HEAD>
  120.  
  121. <BODY <%=FormBG%>>
  122.  
  123. <TABLE>
  124.     <TR><TD><A HREF="http://www.microsoft.com/ntserver/search" style="text-decoration: none" target="_top"><IMG SRC ="<%=FormLogo%>" VALIGN=MIDDLE ALIGN=LEFT></a></TD></TR>
  125.     <TR><TD ALIGN="RIGHT"><H3>NNTP Search Form</H3></TD></TR>
  126. </TABLE>
  127.  
  128. <p>
  129.  
  130.         <FORM ACTION="<%=QueryForm%>" METHOD=POST>
  131.                 <TABLE WIDTH=500>
  132.                         <TR>
  133.                                 <TD>Enter your NNTP search query below:</TD>
  134.                         </TR>
  135.                         <TR>
  136.                                 <TD><INPUT TYPE="TEXT" NAME="SearchString" SIZE="80" MAXLENGTH="100" VALUE="<%=SearchString%>"></TD>
  137.                                 <TD><INPUT TYPE="SUBMIT" NAME="Action" VALUE="Go"></TD>
  138.                         </TR>
  139.                                 <TR>
  140.                                 <TD ALIGN="RIGHT"><A HREF="ixqlang.htm">Tips for searching</A></TD>
  141.                         </TR>
  142.                         <TR>
  143.                         </TR>
  144.                         <TR>
  145.                                 <TD>
  146.                                         <P><INPUT NAME="FreeText" TYPE=CHECKBOX
  147.                                                                 <% if FreeText = "on" then
  148.                                                                                 Response.Write(" CHECKED")
  149.                                                                 end if %>>Search for any combination of words entered above.
  150.                                 </TD>
  151.                         </TR>
  152.                 </TABLE>
  153.         </FORM>
  154.  
  155. <BR>
  156.  
  157. <%
  158.   if NewQuery then
  159.     set Session("Query") = nothing
  160.     set Session("Recordset") = nothing
  161.     NextRecordNumber = 1
  162.  
  163. ' Remove any leading and ending quotes from SearchString
  164.  
  165.         SrchStrLen = len(SearchString)
  166.  
  167.         if left(SearchString, 1) = chr(34) then
  168.                 SrchStrLen = SrchStrLen-1
  169.                 SearchString = right(SearchString, SrchStrLen)
  170.         end if
  171.  
  172.         if right(SearchString, 1) = chr(34) then
  173.                 SrchStrLen = SrchStrLen-1
  174.                 SearchString = left(SearchString, SrchStrLen)
  175.         end if
  176.  
  177.     if FreeText = "on" then
  178.       CompSearch = "$contents " & chr(34) & SearchString & chr(34)
  179.     else
  180.       CompSearch = SearchString
  181.     end if
  182.  
  183.     set Q = Server.CreateObject("ixsso.Query")
  184.         set util = Server.CreateObject("ixsso.Util")
  185.  
  186.     Q.Query = CompSearch
  187.     Q.Columns = "newsgroup, newsarticleid, newsfrom, newssubject, newsdate"
  188.     Q.SortBy = "newsgroup, newsarticleid"
  189.  
  190.         if FormScope <> "/" then
  191.                 util.AddScopeToQuery Q, FormScope, "deep"
  192.         end if
  193.  
  194.         if SiteLocale<>"" then
  195.                 Q.LocaleID = util.ISOToLocaleID(SiteLocale)
  196.         end if
  197.  
  198.     set RS = Q.CreateRecordSet("nonsequential")
  199.  
  200.     RS.PageSize = PageSize
  201.     ActiveQuery = TRUE
  202.  
  203.   elseif UseSavedQuery then
  204.     if IsObject( Session("Query") ) And IsObject( Session("RecordSet") ) then
  205.       set Q = Session("Query")
  206.       set RS = Session("RecordSet")
  207.  
  208.       if RS.RecordCount <> -1 and NextPageNumber <> -1 then
  209.         RS.AbsolutePage = NextPageNumber
  210.         NextRecordNumber = RS.AbsolutePosition
  211.       end if
  212.  
  213.       ActiveQuery = TRUE
  214.     else
  215.       Response.Write "ERROR - No saved query"
  216.     end if
  217.   end if
  218.  
  219.   if ActiveQuery then
  220.     if not RS.EOF then
  221.  %>
  222.  
  223. <p>
  224. <HR WIDTH=80% ALIGN=center SIZE=3>
  225. <p>
  226.  
  227. <%
  228.         LastRecordOnPage = NextRecordNumber + RS.PageSize - 1
  229.         CurrentPage = RS.AbsolutePage
  230.         if RS.RecordCount <> -1 AND RS.RecordCount < LastRecordOnPage then
  231.             LastRecordOnPage = RS.RecordCount
  232.         end if
  233.  
  234.         Response.Write "Documents " & NextRecordNumber & " to " & LastRecordOnPage
  235.         if RS.RecordCount <> -1 then
  236.             Response.Write " of " & RS.RecordCount
  237.         end if
  238.         Response.Write " matching the query " & chr(34) & "<I>"
  239.         Response.Write SearchString & "</I>" & chr(34) & ".<P>"
  240.  %>
  241.  
  242. <!-- BEGIN column header -->
  243.  
  244. <!--  table heading for query form style 1  -->
  245. <table border=1 borderwidth=1>
  246. <tr>
  247. <td><i><b>group:articleid</b></i></td>
  248. <td><i><b>From</b></i></td>
  249. <td><i><b>Subject</b></i></td>
  250. <td><i><b>Date</b></i></td>
  251. </tr>
  252.  
  253. <%if DebugFlag then%>
  254.     <PRE>
  255.     RS.EOF           = <%=CStr(RS.EOF)%>
  256.     NextRecordNumber = <%=NextRecordNumber%>
  257.     LastRecordOnPage = <%=LastRecordOnPage%>
  258.     </PRE>
  259. <%end if%>
  260.  
  261. <!-- BEGIN first row of query results table -->
  262. <% Do While Not RS.EOF and NextRecordNumber <= LastRecordOnPage %>
  263.  
  264. <%
  265.     ' This is the detail portion for newsgroup, newsarticleid, newsfrom, newssubject
  266.  
  267.     ' If there is a title, display it, otherwise display the virtual path.
  268. %>
  269.     <tr>
  270.     <td><% = Server.HTMLEncode(RS("newsgroup")) %>:<% = Server.HTMLEncode(RS("newsarticleid")) %></td>
  271.     <td><% = Server.HTMLEncode(RS("newsfrom")) %></td>
  272.     <td><% = Server.HTMLEncode(RS("newssubject")) %></td>
  273.     <td><% = Server.HTMLEncode(RS("newsdate")) %></td>
  274.     </tr>
  275.  
  276. <%
  277.           RS.MoveNext
  278.           NextRecordNumber = NextRecordNumber+1
  279.       Loop
  280.  %>
  281.  
  282. <!--  table end for query form style 1 -->
  283. </table>
  284.  
  285. <P><BR>
  286.  
  287. <%
  288.   else   ' NOT RS.EOF
  289.       if NextRecordNumber = 1 then
  290.           Response.Write "No documents matched the query<P>"
  291.       else
  292.           Response.Write "No more documents in the query<P>"
  293.       end if
  294.  
  295.   end if ' NOT RS.EOF
  296.  
  297.  
  298. if NOT Q.OutOfDate then
  299. ' If the index is current, display the fact %>
  300. <P>
  301.     <I><B>The index is up to date.</B></I><BR>
  302. <%end if
  303.  
  304.  
  305.   if Q.QueryIncomplete then
  306. '    If the query was not executed because it needed to enumerate to
  307. '    resolve the query instead of using the index, but AllowEnumeration
  308. '    was FALSE, let the user know %>
  309.  
  310.     <P>
  311.     <I><B>The query is too expensive to complete.</B></I><BR>
  312. <%end if
  313.  
  314.  
  315.   if Q.QueryTimedOut then
  316. '    If the query took too long to execute (for example, if too much work
  317. '    was required to resolve the query), let the user know %>
  318.     <P>
  319.     <I><B>The query took too long to complete.</B></I><BR>
  320. <%end if%>
  321.  
  322.  
  323. <TABLE>
  324.  
  325. <%
  326. '    This is the "previous" button.
  327. '    This retrieves the previous page of documents for the query.
  328. %>
  329.  
  330. <%SaveQuery = FALSE%>
  331. <%if CurrentPage > 1 and RS.RecordCount <> -1 then %>
  332.     <td align=left>
  333.         <form action="<%=QueryForm%>" method="get">
  334.             <INPUT TYPE="HIDDEN" NAME="qu" VALUE="<%=SearchString%>">
  335.                         <INPUT TYPE="HIDDEN" NAME="FreeText" VALUE="<%=FreeText%>">
  336.             <INPUT TYPE="HIDDEN" NAME="sc" VALUE="<%=FormScope%>">
  337.             <INPUT TYPE="HIDDEN" name="pg" VALUE="<%=CurrentPage-1%>" >
  338.             <input type="submit" value="Previous <%=RS.PageSize%> documents">
  339.         </form>
  340.     </td>
  341.         <%SaveQuery = TRUE%>
  342. <%end if%>
  343.  
  344.  
  345. <%
  346. '    This is the "next" button for unsorted queries.
  347. '    This retrieves the next page of documents for the query.
  348.  
  349.   if Not RS.EOF then%>
  350.     <td align=right>
  351.         <form action="<%=QueryForm%>" method="get">
  352.             <INPUT TYPE="HIDDEN" NAME="qu" VALUE="<%=SearchString%>">
  353.                         <INPUT TYPE="HIDDEN" NAME="FreeText" VALUE="<%=FreeText%>">
  354.             <INPUT TYPE="HIDDEN" NAME="sc" VALUE="<%=FormScope%>">
  355.             <INPUT TYPE="HIDDEN" name="pg" VALUE="<%=CurrentPage+1%>" >
  356.  
  357.             <% NextString = "Next "
  358.                if RS.RecordCount <> -1 then
  359.                    NextSet = (RS.RecordCount - NextRecordNumber) + 1
  360.                    if NextSet > RS.PageSize then
  361.                        NextSet = RS.PageSize
  362.                    end if
  363.                    NextString = NextString & NextSet & " documents"
  364.                else
  365.                    NextString = NextString & " page of documents"
  366.                end if
  367.              %>
  368.             <input type="submit" value="<%=NextString%>">
  369.         </form>
  370.     </td>
  371.     <%SaveQuery = TRUE%>
  372. <%end if%>
  373.  
  374. </TABLE>
  375.  
  376. <% ' Display the page number %>
  377.  
  378. Page <%=CurrentPage%>
  379. <%if RS.PageCount <> -1 then
  380.      Response.Write " of " & RS.PageCount
  381.   end if %>
  382.  
  383. <%
  384.     ' If either of the previous or back buttons were displayed, save the query
  385.     ' and the recordset in session variables.
  386.     if SaveQuery then
  387.         set Session("Query") = Q
  388.         set Session("RecordSet") = RS
  389.     else
  390.         RS.close
  391.         Set RS = Nothing
  392.         Set Q = Nothing
  393.         set Session("Query") = Nothing
  394.         set Session("RecordSet") = Nothing
  395.     end if
  396.  %>
  397. <% end if %>
  398.  
  399. <!--#include file ="is2foot.inc"-->
  400.  
  401. </BODY>
  402. </HTML>
  403.  
  404.