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.

579 lines
19 KiB

  1. <%@ LANGUAGE = VBScript %>
  2. <% ' Option Explicit %>
  3. <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 3.0//EN" "html.dtd">
  4. <HTML>
  5. <HEAD>
  6. <TITLE>Advanced Indexing Service Search Form</TITLE>
  7. <LINK REL=STYLESHEET HREF="is2style.css" TYPE="text/css">
  8. <META NAME="DESCRIPTION" CONTENT="Sample query form for Indexing Service">
  9. <META NAME="AUTHOR" CONTENT="Indexing Service Team">
  10. <META NAME="KEYWORDS" CONTENT="query, content, hit">
  11. <META NAME="SUBJECT" CONTENT="sample form">
  12. <META NAME="MS.CATEGORY" CONTENT="Internet">
  13. <META NAME="MS.LOCALE" CONTENT="EN-US">
  14. <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=Windows-1252">
  15. <%
  16. ' Customization variables
  17. DebugFlag = FALSE ' set TRUE for debugging
  18. UseSessions = FALSE ' set FALSE to disable use of session variables
  19. RecordsPerPage = 10 ' number of results on a page
  20. MaxResults = -1 ' total number of results returned
  21. FormLogo = "is2logo.gif" ' picture at top of page
  22. ' Hard-code some parameters that could be taken from the form
  23. ' SortBy = "rank[d]" ' sort order
  24. Scope = "/" ' query scope
  25. ' Set initial conditions
  26. NewQuery = FALSE
  27. UseSavedQuery = FALSE
  28. SearchString = ""
  29. QueryForm = Request.ServerVariables("PATH_INFO")
  30. if Request.ServerVariables("REQUEST_METHOD") = "POST" then
  31. SearchString = Request.Form("SearchString")
  32. DocAuthorRestriction = Request.Form("DocAuthorRestriction")
  33. FSRest = Request.Form("FSRest")
  34. FSRestVal = Request.Form("FSRestVal")
  35. FSRestOther = Request.Form("FSRestOther")
  36. FMMod = Request.Form("FMMod")
  37. FMModDate = Request.Form("FMModDate")
  38. SortBy = Request.Form("SortBy")
  39. ' Scope = Request.Form("Scope")
  40. RankBase = Request.Form("RankBase")
  41. ' NOTE: this will be true only if the button is actually pushed.
  42. if Request.Form("Action") = "Execute" then
  43. NewQuery = TRUE
  44. NextPageNumber = -1
  45. elseif Request.Form("pg") <> "" then
  46. NextPageNumber = Request.Form("pg")
  47. UseSavedQuery = UseSessions
  48. NewQuery = not UseSessions
  49. end if
  50. end if
  51. %>
  52. </HEAD>
  53. <BODY background="is2bkgnd.gif" OnLoad="SetAll()" LANGUAGE=JavaScript>
  54. <TABLE>
  55. <TR><TD><A HREF="http://www.microsoft.com/ntserver/search" target="_top">
  56. <IMG SRC ="<%=FormLogo%>" border=0 VALIGN=MIDDLE ALIGN="LEFT"></a></TD></TR>
  57. <TR><TD ALIGN="RIGHT"><H3>Advanced ASP Sample</H3></TD></TR>
  58. </TABLE>
  59. <SCRIPT LANGUAGE=JavaScript>
  60. <!--
  61. function SetAll()
  62. {
  63. document.QForm.SearchString.value = "<%=SearchString%>";
  64. <%select case FSRest%>
  65. <%case " > "%>
  66. document.QForm.FSRest.selectedIndex = 1;
  67. <%case else%>
  68. document.QForm.FSRest.selectedIndex = 0;
  69. <%end select%>
  70. <%select case FSRestVal%>
  71. <%case "any"%>
  72. document.QForm.FSRestVal.selectedIndex = 0;
  73. <%case "100"%>
  74. document.QForm.FSRestVal.selectedIndex = 1;
  75. <%case "1024"%>
  76. document.QForm.FSRestVal.selectedIndex = 2;
  77. <%case "10240"%>
  78. document.QForm.FSRestVal.selectedIndex = 3;
  79. <%case "102400"%>
  80. document.QForm.FSRestVal.selectedIndex = 4;
  81. <%case "1048576"%>
  82. document.QForm.FSRestVal.selectedIndex = 5;
  83. <%case "10485760"%>
  84. document.QForm.FSRestVal.selectedIndex = 6;
  85. <%case "104857600"%>
  86. document.QForm.FSRestVal.selectedIndex = 7;
  87. <%case "other"%>
  88. document.QForm.FSRestVal.selectedIndex = 8;
  89. <%case else%>
  90. document.QForm.FSRestVal.selectedIndex = 0;
  91. <%end select%>
  92. document.QForm.FSRestOther.value = "<%=FSRestOther%>";
  93. <%select case FMMod%>
  94. <%case "any"%>
  95. document.QForm.FMMod.selectedIndex = 0;
  96. <%case "-10n"%>
  97. document.QForm.FMMod.selectedIndex = 1;
  98. <%case "-1h"%>
  99. document.QForm.FMMod.selectedIndex = 2;
  100. <%case "-1d"%>
  101. document.QForm.FMMod.selectedIndex = 3;
  102. <%case "-1w"%>
  103. document.QForm.FMMod.selectedIndex = 4;
  104. <%case "-1m"%>
  105. document.QForm.FMMod.selectedIndex = 5;
  106. <%case "-1q"%>
  107. document.QForm.FMMod.selectedIndex = 6;
  108. <%case "-1y"%>
  109. document.QForm.FMMod.selectedIndex = 7;
  110. <%case "since"%>
  111. document.QForm.FMMod.selectedIndex = 8;
  112. <%case else%>
  113. document.QForm.FMMod.selectedIndex = 0;
  114. <%end select%>
  115. document.QForm.FMModDate.value = "<%=FMModDate%>";
  116. document.QForm.DocAuthorRestriction.value = "<%=DocAuthorRestriction%>";
  117. document.QForm.SearchString.focus();
  118. }
  119. function msieversion()
  120. {
  121. var ua = window.navigator.userAgent;
  122. var msie = ua.indexOf("MSIE");
  123. if (msie>0)
  124. return parseInt(ua.substring(msie+5, ua.indexOf(".", msie)));
  125. else
  126. return 0;
  127. }
  128. function NAF(szUrl, szQuery)
  129. {
  130. if ( (msieversion() >= 5) && (szQuery.length > 0) )
  131. window.external.NavigateAndFind(szUrl, szQuery, "_main");
  132. else
  133. window.navigate(szUrl, target="_main");
  134. }
  135. //-->
  136. </SCRIPT>
  137. <FORM NAME="QForm" ACTION="<%=QueryForm%>" METHOD=POST>
  138. <!-- -->
  139. <table width=500>
  140. <tr>
  141. <td>Enter your query:</td>
  142. <td><INPUT TYPE="TEXT" NAME="SearchString" SIZE="51" MAXLENGTH="100" VALUE=""></td>
  143. </tr>
  144. <tr>
  145. <td align="right" colspan=2>Document author:
  146. <INPUT TYPE="TEXT" NAME="DocAuthorRestriction" SIZE="27" MAXLENGTH="100" VALUE="">
  147. <td>
  148. </tr>
  149. <tr>
  150. <td align="right" colspan=2>Where File Size is:
  151. <SELECT NAME="FSRest">
  152. <!-- <OPTION VALUE=" &lt; " <%if FSRest = " < " then%>SELECTED <%end if%>>Less Than
  153. <OPTION VALUE=" &gt; " <%if FSRest = " > " then%>SELECTED <%end if%>>Greater Than
  154. -->
  155. <OPTION VALUE=" &lt; " SELECTED>Less Than
  156. <OPTION VALUE=" &gt; " >Greater Than
  157. </SELECT>
  158. <SELECT NAME="FSRestVal">
  159. <OPTION VALUE="any" SELECTED>any size
  160. <OPTION VALUE="100" >100 bytes
  161. <OPTION VALUE="1024" >1K bytes
  162. <OPTION VALUE="10240" >10K bytes
  163. <OPTION VALUE="102400" >100K bytes
  164. <OPTION VALUE="1048576" >1M byte
  165. <OPTION VALUE="10485760" >10M bytes
  166. <OPTION VALUE="104857600" >100M bytes
  167. <OPTION VALUE="other" >Other
  168. </SELECT>
  169. <INPUT TYPE="TEXT" NAME="FSRestOther" SIZE="12" MAXLENGTH="9" VALUE="">
  170. </td>
  171. </tr>
  172. <tr>
  173. <td align="right" colspan=2>Modified:
  174. <SELECT NAME="FMMod">
  175. <OPTION VALUE="any" SELECTED >at any time.
  176. <OPTION VALUE="-10n">in the last 10 minutes.
  177. <OPTION VALUE="-1h">in the last hour.
  178. <OPTION VALUE="-1d">in the last day.
  179. <OPTION VALUE="-1w">in the last week.
  180. <OPTION VALUE="-1m">in the last month.
  181. <OPTION VALUE="-1q">in the last quarter.
  182. <OPTION VALUE="-1y">in the last year.
  183. <OPTION VALUE="since">since GMT (yy/mm/dd) .
  184. </SELECT>
  185. <INPUT TYPE="TEXT" NAME="FMModDate" SIZE="12" MAXLENGTH="9" VALUE="">
  186. </td>
  187. </tr>
  188. <tr>
  189. <td align="right"><A HREF="ixtiphlp.htm">Tips for searching</A></td>
  190. <td align="right">
  191. <BUTTON TYPE=SUBMIT NAME="Action">Execute</BUTTON>
  192. <INPUT TYPE="RESET" NAME="Clear" VALUE="Clear">
  193. </td>
  194. </tr>
  195. </table>
  196. <INPUT TYPE="HIDDEN" NAME="SortBy" VALUE="rank[d]">
  197. <INPUT TYPE="HIDDEN" NAME="Scope" VALUE="/">
  198. <INPUT TYPE="HIDDEN" NAME="ColChoice" VALUE="1">
  199. </FORM>
  200. <BR>
  201. <%if DebugFlag then%>
  202. <PRE>
  203. SearchString = <%=SearchString%>
  204. DocAuthorRestriction = <%=DocAuthorRestriction%>
  205. FSRest = <%=FSRest%>
  206. FSRestVal = <%=FSRestVal%>
  207. FSRestOther = <%=FSRestOther%>
  208. FMMod = <%=FMMod%>
  209. FMModDate = <%=FMModDate%>
  210. SortBy = <%=SortBy%>
  211. Scope = <%=Scope%>
  212. NewQuery = <%=CStr(NewQuery)%>
  213. UseSavedQuery = <%=CStr(UseSavedQuery)%>
  214. </PRE>
  215. <%end if%>
  216. <%
  217. if NewQuery then
  218. if UseSessions then
  219. set Session("Query") = nothing
  220. set Session("Recordset") = nothing
  221. end if
  222. NextRecordNumber = 1
  223. set Q = Server.CreateObject("ixsso.Query")
  224. Composer = ""
  225. TheQuery = ""
  226. if SearchString <> "" then
  227. if Left( SearchSting, 1 ) <> "@" AND Left( SearchString, 1 ) <> "#" AND Left( SearchString, 1 ) <> "$" then
  228. TheQuery = "(@Contents " + SearchString + ")"
  229. else
  230. TheQuery = "(" + SearchString + ")"
  231. end if
  232. Composer = " & "
  233. end if
  234. if FSRestVal <> "any" then
  235. if FSRestVal <> "other" then
  236. TheQuery = "(@Size " + FSRest + FSRestVal + ") " + Composer + TheQuery
  237. else
  238. TheQuery = "(@Size " + FSRest + FSRestOther + ") " + Composer + TheQuery
  239. end if
  240. Composer = " & "
  241. end if
  242. if DocAuthorRestriction <> "" then
  243. TheQuery = "(@DocAuthor " + DocAuthorRestriction + ") " + Composer + TheQuery
  244. Composer = " & "
  245. end if
  246. if FMMod <> "" AND FMMod <> "any" then
  247. if FMMod <> "since" then
  248. TheQuery = "(@Write > " + FMMod + ") " + Composer + TheQuery
  249. else
  250. TheQuery = "(@Write > " + FMModDate + ") " + Composer + TheQuery
  251. end if
  252. end if
  253. if DebugFlag then
  254. Response.Write "TheQuery = " & TheQuery & "<BR>"
  255. end if
  256. Q.Catalog = "web"
  257. Q.Query = TheQuery
  258. Q.SortBy = SortBy
  259. Q.Columns = "DocTitle, vpath, path, filename, size, write, characterization, rank"
  260. if MaxResults <> -1 then
  261. Q.MaxRecords = MaxResults
  262. end if
  263. if Scope <> "\" then
  264. set Util = Server.CreateObject("ixsso.Util")
  265. Util.AddScopeToQuery Q, Scope, "DEEP"
  266. set Util = nothing
  267. end if
  268. set RS = Q.CreateRecordSet("nonsequential")
  269. RS.PageSize = RecordsPerPage
  270. ActiveQuery = TRUE
  271. elseif UseSavedQuery then
  272. if IsObject( Session("Query") ) And IsObject( Session("RecordSet") ) then
  273. set Q = Session("Query")
  274. set RS = Session("RecordSet")
  275. ActiveQuery = TRUE
  276. else
  277. Response.Write "ERROR - No saved query"
  278. end if
  279. end if
  280. if ActiveQuery then
  281. if RS.RecordCount <> -1 and NextPageNumber <> -1 then
  282. RS.AbsolutePage = NextPageNumber
  283. NextRecordNumber = RS.AbsolutePosition
  284. end if
  285. if not RS.EOF then
  286. %>
  287. <p>
  288. <HR WIDTH=80% ALIGN=center SIZE=3>
  289. <p>
  290. <%
  291. LastRecordOnPage = NextRecordNumber + RS.PageSize - 1
  292. CurrentPage = RS.AbsolutePage
  293. if RS.RecordCount <> -1 AND RS.RecordCount < LastRecordOnPage then
  294. LastRecordOnPage = RS.RecordCount
  295. end if
  296. Response.Write "Documents " & NextRecordNumber & " to " & LastRecordOnPage
  297. if RS.RecordCount <> -1 then
  298. Response.Write " of " & RS.RecordCount
  299. end if
  300. if SearchString <> "" then
  301. Response.Write " matching the query " & chr(34) & "<I>"
  302. Response.Write SearchString & "</I>" & chr(34) & ".<P>"
  303. end if
  304. %>
  305. <% if Not RS.EOF and NextRecordNumber <= LastRecordOnPage then%>
  306. <table border=0>
  307. <colgroup width=105>
  308. <%end if%>
  309. <% Do While Not RS.EOF and NextRecordNumber <= LastRecordOnPage
  310. ' This is the detail portion for Title, Abstract, URL, Size, and
  311. ' Modification Date.
  312. ' If there is a title, display it, otherwise display the filename.
  313. %>
  314. <p>
  315. <%
  316. ' Graphically indicate rank of document with list of stars (*'s).
  317. if NextRecordNumber = 1 then
  318. RankBase=RS("rank")
  319. end if
  320. if RankBase>1000 then
  321. RankBase=1000
  322. elseif RankBase<1 then
  323. RankBase=1
  324. end if
  325. NormRank = RS("rank")/RankBase
  326. if NormRank > 0.80 then
  327. stars = "rankbtn5.gif"
  328. elseif NormRank > 0.60 then
  329. stars = "rankbtn4.gif"
  330. elseif NormRank > 0.40 then
  331. stars = "rankbtn3.gif"
  332. elseif NormRank >.20 then
  333. stars = "rankbtn2.gif"
  334. else
  335. stars = "rankbtn1.gif"
  336. end if
  337. %>
  338. <tr class="RecordTitle">
  339. <td align="right" valign=top class="RecordTitle">
  340. <%= NextRecordNumber%>.
  341. </td>
  342. <td><b class="RecordTitle">
  343. <%if VarType(RS("DocTitle")) = 1 or RS("DocTitle") = "" then%>
  344. <a href="javascript:NAF('http://<%=Request.ServerVariables("SERVER_NAME")%><%=RS("vpath")%>','<%=SearchString%>')" class="RecordTitle"><%= Server.HTMLEncode( RS("filename") )%></a>
  345. <%else%>
  346. <a href="javascript:NAF('http://<%=Request.ServerVariables("SERVER_NAME")%><%=RS("vpath")%>','<%=SearchString%>')" class="RecordTitle"><%= Server.HTMLEncode(RS("DocTitle"))%></a>
  347. <%end if%>
  348. </b></td>
  349. </tr>
  350. <tr>
  351. <td valign=top align="left">
  352. <IMG SRC="<%=stars%>">
  353. <br>
  354. <%
  355. ' Construct the URL for hit highlighting
  356. WebHitsQuery = "CiWebHitsFile=" & Server.URLEncode( RS("vpath") )
  357. WebHitsQuery = WebHitsQuery & "&CiRestriction=" & Server.URLEncode( Q.Query )
  358. WebHitsQuery = WebHitsQuery & "&CiBeginHilite=" & Server.URLEncode( "<b class=""Hit"">" )
  359. WebHitsQuery = WebHitsQuery & "&CiEndHilite=" & Server.URLEncode( "</b>" )
  360. WebHitsQuery = WebHitsQuery & "&CiUserParam3=" & QueryForm
  361. WebHitsQuery = WebHitsQuery & "&CiLocale=" & Q.LocaleID
  362. %>
  363. <a href="qsumrhit.htw?<%= WebHitsQuery %>">
  364. <IMG src="hilight.gif" align="left" alt="Highlight matching terms in document using Summary mode."> Summary</a>
  365. <br>
  366. <a href="qfullhit.htw?<%= WebHitsQuery %>&CiHiliteType=Full">
  367. <IMG src="hilight.gif" align="left" alt="Highlight matching terms in document."> Full</a>
  368. </td>
  369. <td valign=top>
  370. <%if VarType(RS("characterization")) = 8 and RS("characterization") <> "" then%>
  371. <b><i>Abstract: </i></b>
  372. <%= Server.HTMLEncode(RS("characterization"))%>
  373. <%end if%>
  374. <p>
  375. <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>
  376. <br><%if RS("size") = "" then%>(size and time unknown)<%else%>size <%=RS("size")%> bytes - <%=RS("write")%> GMT<%end if%></i>
  377. </td>
  378. </tr>
  379. <tr>
  380. </tr>
  381. <%
  382. RS.MoveNext
  383. NextRecordNumber = NextRecordNumber+1
  384. Loop
  385. %>
  386. </table>
  387. <P><BR>
  388. <%
  389. else ' NOT RS.EOF
  390. if NextRecordNumber = 1 then
  391. Response.Write "No documents matched the query<P>"
  392. else
  393. Response.Write "No more documents in the query<P>"
  394. end if
  395. end if ' NOT RS.EOF
  396. if NOT Q.OutOfDate then
  397. ' If the index is current, display the fact %>
  398. <P>
  399. <I><B>The index is up to date.</B></I><BR>
  400. <%end if
  401. if Q.QueryIncomplete then
  402. ' If the query was not executed because it needed to enumerate to
  403. ' resolve the query instead of using the index, but AllowEnumeration
  404. ' was FALSE, let the user know
  405. %>
  406. <P>
  407. <I><B>The query is too expensive to complete.</B></I><BR>
  408. <%end if
  409. if Q.QueryTimedOut then
  410. ' If the query took too long to execute (for example, if too much work
  411. ' was required to resolve the query), let the user know %>
  412. <P>
  413. <I><B>The query took too long to complete.</B></I><BR>
  414. <%end if%>
  415. <TABLE>
  416. <%
  417. ' This is the "previous" button.
  418. ' This retrieves the previous page of documents for the query.
  419. SaveQuery = FALSE
  420. if CurrentPage > 1 and RS.RecordCount <> -1 then %>
  421. <td align="left">
  422. <form action="<%=QueryForm%>" method="post">
  423. <INPUT TYPE="HIDDEN" NAME="SearchString" VALUE="<%=SearchString%>">
  424. <INPUT TYPE="HIDDEN" NAME="DocAuthorRestriction" VALUE="<%=DocAuthorRestriction%>">
  425. <INPUT TYPE="HIDDEN" NAME="FSRest" VALUE="<%=FSRest%>">
  426. <INPUT TYPE="HIDDEN" NAME="FSRestVal" VALUE="<%=FSRestVal%>">
  427. <INPUT TYPE="HIDDEN" NAME="FSRestOther" VALUE="<%=FSRestOther%>">
  428. <INPUT TYPE="HIDDEN" NAME="FMMod" VALUE="<%=FMMod%>">
  429. <INPUT TYPE="HIDDEN" NAME="FMModDate" VALUE="<%=FMModDate%>">
  430. <INPUT TYPE="HIDDEN" NAME="SortBy" VALUE="<%=SortBy%>">
  431. <INPUT TYPE="HIDDEN" NAME="Scope" VALUE="<%=Scope%>">
  432. <INPUT TYPE="HIDDEN" NAME="pg" VALUE="<%=CurrentPage-1%>" >
  433. <INPUT TYPE="HIDDEN" NAME="RankBase" VALUE="<%=RankBase%>">
  434. <input type="submit" value="Previous <%=RS.PageSize%> documents">
  435. </form>
  436. </td>
  437. <%SaveQuery = UseSessions%>
  438. <%end if%>
  439. <%if Not RS.EOF then
  440. ' This is the "next" button.
  441. ' This button retrieves the next page of documents for the query.
  442. %>
  443. <td align="right">
  444. <form action="<%=QueryForm%>" method="post">
  445. <INPUT TYPE="HIDDEN" NAME="SearchString" VALUE="<%=SearchString%>">
  446. <INPUT TYPE="HIDDEN" NAME="DocAuthorRestriction" VALUE="<%=DocAuthorRestriction%>">
  447. <INPUT TYPE="HIDDEN" NAME="FSRest" VALUE="<%=FSRest%>">
  448. <INPUT TYPE="HIDDEN" NAME="FSRestVal" VALUE="<%=FSRestVal%>">
  449. <INPUT TYPE="HIDDEN" NAME="FSRestOther" VALUE="<%=FSRestOther%>">
  450. <INPUT TYPE="HIDDEN" NAME="FMMod" VALUE="<%=FMMod%>">
  451. <INPUT TYPE="HIDDEN" NAME="FMModDate" VALUE="<%=FMModDate%>">
  452. <INPUT TYPE="HIDDEN" NAME="SortBy" VALUE="<%=SortBy%>">
  453. <INPUT TYPE="HIDDEN" NAME="Scope" VALUE="<%=Scope%>">
  454. <INPUT TYPE="HIDDEN" NAME="pg" VALUE="<%=CurrentPage+1%>" >
  455. <INPUT TYPE="HIDDEN" NAME="RankBase" VALUE="<%=RankBase%>">
  456. <%
  457. NextString = "Next "
  458. if RS.RecordCount <> -1 then
  459. NextSet = (RS.RecordCount - NextRecordNumber) + 1
  460. if NextSet > RS.PageSize then
  461. NextSet = RS.PageSize
  462. end if
  463. NextString = NextString & NextSet & " documents"
  464. else
  465. NextString = NextString & " page of documents"
  466. end if
  467. %>
  468. <input type="submit" value="<%=NextString%>">
  469. </form>
  470. </td>
  471. <%SaveQuery = UseSessions%>
  472. <%end if%>
  473. </TABLE>
  474. <% ' Display the page number
  475. if RS.PageCount <> 0 then
  476. Response.Write "Page " & CurrentPage
  477. if RS.PageCount <> -1 then
  478. Response.Write " of " & RS.PageCount
  479. end if
  480. end if
  481. ' If either of the previous or back buttons were displayed, save
  482. ' the query and the recordset in session variables.
  483. if SaveQuery then
  484. set Session("Query") = Q
  485. set Session("RecordSet") = RS
  486. else
  487. RS.close
  488. Set RS = Nothing
  489. Set Q = Nothing
  490. if UseSessions then
  491. set Session("Query") = Nothing
  492. set Session("RecordSet") = Nothing
  493. end if
  494. end if
  495. end if
  496. %>
  497. <BR>
  498. <!--#include file ="is2foot.inc"-->
  499. </BODY>
  500. </HTML>