Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

499 lines
15 KiB

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