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.

498 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. ActiveQuery = TRUE
  180. elseif UseSavedQuery then
  181. if IsObject( Session("Query") ) And IsObject( Session("RecordSet") ) then
  182. set Q = Session("Query")
  183. set RS = Session("RecordSet")
  184. ActiveQuery = TRUE
  185. else
  186. Response.Write "ERROR - No saved query"
  187. end if
  188. end if
  189. if ActiveQuery then
  190. if RS.RecordCount <> -1 and NextPageNumber <> -1 then
  191. RS.AbsolutePage = NextPageNumber
  192. NextRecordNumber = RS.AbsolutePosition
  193. end if
  194. if not RS.EOF then
  195. %>
  196. <p>
  197. <HR WIDTH=80% ALIGN=center SIZE=3>
  198. <p>
  199. <%
  200. LastRecordOnPage = NextRecordNumber + RS.PageSize - 1
  201. CurrentPage = RS.AbsolutePage
  202. if RS.RecordCount <> -1 AND RS.RecordCount < LastRecordOnPage then
  203. LastRecordOnPage = RS.RecordCount
  204. end if
  205. Response.Write "Documents " & NextRecordNumber & " to " & LastRecordOnPage
  206. if RS.RecordCount <> -1 then
  207. Response.Write " of " & RS.RecordCount
  208. end if
  209. Response.Write " matching the query " & chr(34) & "<I>"
  210. Response.Write SearchString & "</I>" & chr(34) & ".<P>"
  211. %>
  212. <% if Not RS.EOF and NextRecordNumber <= LastRecordOnPage then%>
  213. <table border=0>
  214. <colgroup width=105>
  215. <% end if %>
  216. <% Do While Not RS.EOF and NextRecordNumber <= LastRecordOnPage
  217. ' This is the detail portion for Title, Abstract, URL, Size, and
  218. ' Modification Date.
  219. ' If there is a title, display it, otherwise display the filename.
  220. %>
  221. <p>
  222. <%
  223. ' Graphically indicate rank of document with list of stars (*'s).
  224. if NextRecordNumber = 1 then
  225. RankBase=RS("rank")
  226. end if
  227. if RankBase>1000 then
  228. RankBase=1000
  229. elseif RankBase<1 then
  230. RankBase=1
  231. end if
  232. NormRank = RS("rank")/RankBase
  233. if NormRank > 0.80 then
  234. stars = "rankbtn5.gif"
  235. elseif NormRank > 0.60 then
  236. stars = "rankbtn4.gif"
  237. elseif NormRank > 0.40 then
  238. stars = "rankbtn3.gif"
  239. elseif NormRank >.20 then
  240. stars = "rankbtn2.gif"
  241. else
  242. stars = "rankbtn1.gif"
  243. end if
  244. %>
  245. <tr class="RecordTitle">
  246. <td align="right" valign=top class="RecordTitle">
  247. <%= NextRecordNumber%>.
  248. </td>
  249. <td><b class="RecordTitle">
  250. <%if VarType(RS("DocTitle")) = 1 or RS("DocTitle") = "" then%>
  251. <a href="javascript:NAF('http://<%=Request.ServerVariables("SERVER_NAME")%><%=RS("vpath")%>','<%=SearchString%>')" class="RecordTitle"><%= Server.HTMLEncode( RS("filename") )%></a>
  252. <%else%>
  253. <a href="javascript:NAF('http://<%=Request.ServerVariables("SERVER_NAME")%><%=RS("vpath")%>','<%=SearchString%>')" class="RecordTitle"><%= Server.HTMLEncode(RS("DocTitle"))%></a>
  254. <%end if%>
  255. </b></td>
  256. </tr>
  257. <tr>
  258. <td valign=top align=left>
  259. <IMG SRC="<%=stars%>">
  260. <br>
  261. <%
  262. ' Construct the URL for hit highlighting
  263. WebHitsQuery = "CiWebHitsFile=" & Server.URLEncode( RS("vpath") )
  264. WebHitsQuery = WebHitsQuery & "&CiRestriction=" & Server.URLEncode( Q.Query )
  265. WebHitsQuery = WebHitsQuery & "&CiBeginHilite=" & Server.URLEncode( "<strong class=Hit>" )
  266. WebHitsQuery = WebHitsQuery & "&CiEndHilite=" & Server.URLEncode( "</strong>" )
  267. WebHitsQuery = WebHitsQuery & "&CiUserParam3=" & QueryForm
  268. ' WebHitsQuery = WebHitsQuery & "&CiLocale=" & Q.LocaleID
  269. %>
  270. <a href="qsumrhit.htw?<%= WebHitsQuery %>">
  271. <IMG src="hilight.gif" align=left alt="Highlight matching terms in document using Summary mode."> Summary</a>
  272. <br>
  273. <a href="qfullhit.htw?<%= WebHitsQuery %>&CiHiliteType=Full">
  274. <IMG src="hilight.gif" align=left alt="Highlight matching terms in document."> Full</a>
  275. </td>
  276. <td valign=top>
  277. <%if VarType(RS("characterization")) = 8 and RS("characterization") <> "" then%>
  278. <b><i>Abstract: </i></b>
  279. <%= Server.HTMLEncode(RS("characterization"))%>
  280. <%end if%>
  281. <p>
  282. <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>
  283. <br><%if RS("size") = "" then%>(size and time unknown)<%else%>size <%=RS("size")%> bytes - <%=RS("write")%> GMT<%end if%></i>
  284. </td>
  285. </tr>
  286. <tr>
  287. </tr>
  288. <%
  289. RS.MoveNext
  290. NextRecordNumber = NextRecordNumber+1
  291. Loop
  292. %>
  293. </table>
  294. <P><BR>
  295. <%
  296. else ' NOT RS.EOF
  297. if NextRecordNumber = 1 then
  298. Response.Write "No documents matched the query<P>"
  299. else
  300. Response.Write "No more documents in the query<P>"
  301. end if
  302. end if ' NOT RS.EOF
  303. if NOT Q.OutOfDate then
  304. ' If the index is current, display the fact %>
  305. <P>
  306. <I><B>The index is up to date.</B></I><BR>
  307. <%end if
  308. if Q.QueryIncomplete then
  309. ' If the query was not executed because it needed to enumerate to
  310. ' resolve the query instead of using the index, but AllowEnumeration
  311. ' was FALSE, let the user know
  312. %>
  313. <P>
  314. <I><B>The query is too expensive to complete.</B></I><BR>
  315. <%end if
  316. if Q.QueryTimedOut then
  317. ' If the query took too long to execute (for example, if too much work
  318. ' was required to resolve the query), let the user know %>
  319. <P>
  320. <I><B>The query took too long to complete.</B></I><BR>
  321. <%end if%>
  322. <TABLE>
  323. <%
  324. ' This is the "previous" button.
  325. ' This retrieves the previous page of documents for the query.
  326. SaveQuery = FALSE
  327. if CurrentPage > 1 and RS.RecordCount <> -1 then %>
  328. <td align=left>
  329. <form action="<%=QueryForm%>" method="get">
  330. <INPUT TYPE="HIDDEN" NAME="qu" VALUE="<%=SearchString%>">
  331. <INPUT TYPE="HIDDEN" NAME="Advanced" VALUE="<%=Advanced%>">
  332. <INPUT TYPE="HIDDEN" NAME="sc" VALUE="<%=FormScope%>">
  333. <INPUT TYPE="HIDDEN" NAME="pg" VALUE="<%=CurrentPage-1%>" >
  334. <INPUT TYPE="HIDDEN" NAME="RankBase" VALUE="<%=RankBase%>">
  335. <input type="submit" value="Previous <%=RS.PageSize%> documents">
  336. </form>
  337. </td>
  338. <%SaveQuery = UseSessions%>
  339. <%end if%>
  340. <%
  341. ' This is the "next" button for unsorted queries.
  342. ' This retrieves the next page of documents for the query.
  343. if Not RS.EOF then%>
  344. <td align=right>
  345. <form action="<%=QueryForm%>" method="get">
  346. <INPUT TYPE="HIDDEN" NAME="qu" VALUE="<%=SearchString%>">
  347. <INPUT TYPE="HIDDEN" NAME="Advanced" VALUE="<%=Advanced%>">
  348. <INPUT TYPE="HIDDEN" NAME="sc" VALUE="<%=FormScope%>">
  349. <INPUT TYPE="HIDDEN" NAME="pg" VALUE="<%=CurrentPage+1%>">
  350. <INPUT TYPE="HIDDEN" NAME="RankBase" VALUE="<%=RankBase%>">
  351. <%
  352. NextString = "Next "
  353. if RS.RecordCount <> -1 then
  354. NextSet = (RS.RecordCount - NextRecordNumber) + 1
  355. if NextSet > RS.PageSize then
  356. NextSet = RS.PageSize
  357. end if
  358. NextString = NextString & NextSet & " documents"
  359. else
  360. NextString = NextString & " page of documents"
  361. end if
  362. %>
  363. <input type="submit" value="<%=NextString%>">
  364. </form>
  365. </td>
  366. <%SaveQuery = UseSessions%>
  367. <%end if%>
  368. </TABLE>
  369. <% ' Display the page number
  370. if RS.PageCount <> 0 then
  371. Response.Write "Page " & CurrentPage
  372. if RS.PageCount <> -1 then
  373. Response.Write " of " & RS.PageCount
  374. end if
  375. end if
  376. %>
  377. <%
  378. ' If either of the previous or back buttons were displayed, save the query
  379. ' and the recordset in session variables.
  380. if SaveQuery then
  381. set Session("Query") = Q
  382. set Session("RecordSet") = RS
  383. else
  384. RS.close
  385. Set RS = Nothing
  386. Set Q = Nothing
  387. if UseSessions then
  388. set Session("Query") = Nothing
  389. set Session("RecordSet") = Nothing
  390. end if
  391. end if
  392. %>
  393. <% end if %>
  394. <BR>
  395. <!--#include file ="is2foot.inc"-->
  396. </BODY>
  397. <SCRIPT LANGUAGE=JSCRIPT>
  398. function Init()
  399. {
  400. QueryForm.SearchString.focus();
  401. }
  402. function msieversion()
  403. {
  404. var ua = window.navigator.userAgent;
  405. var msie = ua.indexOf("MSIE");
  406. if (msie>0)
  407. return parseInt(ua.substring(msie+5, ua.indexOf(".", msie)));
  408. else
  409. return 0;
  410. }
  411. function NAF(szUrl, szQuery)
  412. {
  413. if (msieversion() >= 5)
  414. window.external.NavigateAndFind(szUrl, szQuery, "_main");
  415. else
  416. window.navigate(szUrl, target="_main");
  417. }
  418. </SCRIPT>
  419. </HTML>