<%
'////////////////////////////'
'//NO10 Index Server Search//'
'//Ben Lovell 2002 //'
'////////////////////////////'
Dim sQuery, oQuery, oRs, sTitle, iRecord, sSitePath
Dim iCurrPage, iNumPages, iCurrentRecord, sPage
Dim iSection, iDay, iMonth, iYear, bSection
Dim sDayQuery, sSectionQuery, sTextQuery, sFullText
Dim iPerPage, iNumResults
Dim bPDF, bMSWORD, bEXCEL
Dim sHTML
sHTML = ""
iCurrentRecord = 0
'//get all the params from the querystring//'
iCurrPage = Request("offset")
iDay = Request("day")
iMonth = Request("month")
iYear = Request("year")
sPage = Request.ServerVariables("SCRIPT_NAME")
iSection = Request("section")
sFullText = Request("searchbox")
sFullText = Replace(sFullText, "<" , "<" )
sFullText = Replace(sFullText, ">" , ">" )
sFullText = Replace(sFullText, """" , """ )
sFullText = Replace(sFullText, "'" , "'" )
sFullText = Replace(sFullText, "=" , "=" )
sFullText = Replace(sFullText, "-" , "-" )
sFullText = Replace(sFullText, "/" , "⁄" )
bSection = (Request("SearchSection") = "True")
iPerPage = cInt(Request("perpage"))
iNumResults = cInt(Request("numresults"))
If Len(iSection) Then bSection = True
'//determine the section query//'
If bSection Then
Select Case iSection
Case "PDF"
bPDF = true
Case "MSWORD"
bMSWORD = true
Case "EXCEL"
bEXCEL = true
Case Else
sSectionQuery = "AND ($docKeywords " & iSection & ") "
End Select
Else
'//were not searching sections//'
sSectionQuery = ""
End If
'//set current page if == 0//'
If Len(iCurrPage) = 0 Then iCurrPage = 1
If iPerPage = 0 Then iPerPage = 5
'//build up date section of query//'
If (Len(iMonth) > 0) And (Len(iYear) > 0) Then
'//we are definately doing a date search//'
sDayQuery = " AND ($docKeywords "
'//we are also doing a day specific search//'
If Len(iDay) Then
sDayQuery = sDayQuery & iDay & "*"
End If
'//build up the rest of the search
sDayQuery = sDayQuery & iMonth & "*" & iYear & ") "
Else
'//we must be doing a non date search//'
sDayQuery = ""
End If
'//build up free text portion of query//'
If Len(sFullText) > 0 Then
'//dump the date parts//'
sDayQuery = ""
sTextQuery = " AND (" & sFullText & ") "
End If
'//create query object...
Set oQuery = Server.CreateObject("IXSSO.Query")
'//concatenate the full query now//'
If bPDF Then
sQuery = "(#vpath *\files\pdf*) " & sDayQuery & sSectionQuery & sTextQuery
ElseIf bMSWORD Then
sQuery = "(#vpath *\files\word*) " & sDayQuery & sSectionQuery & sTextQuery
ElseIf bEXCEL Then
sQuery = "(#vpath *\files\excel*) " & sDayQuery & sSectionQuery & sTextQuery
Else
sQuery = "(#vpath *\output*) AND (NOT #vpath *\_vti*) " & sDayQuery & sSectionQuery & sTextQuery
End If
'Response.Write sQuery
On Error Resume Next
'//set up options...
With oQuery
.Columns = "doctitle, filename, size, characterization, rank"
.MaxRecords = iNumResults
.SortBy = "rank[d], doctitle"
.Catalog = Application("IndexCatalog")
.Query = sQuery
'Response.Write(.Query) : Response.end
'//create recordset
Set oRs = .CreateRecordset("nonsequential")
End With
If oRs.EOF Or Err.number > 0 Then
'//no records returned
Response.Write("Sorry, your search didn't return any pages.")
Else
If Len(iMonth) > 0 Or Len(iYear) > 0 Then
'Response.Write(iDay & " " & MonthName(iMonth) & " " & iYear & "")
End If
With oRs
.PageSize = iPerPage
.AbsolutePage = iCurrPage
iNumPages = cInt(.PageCount)
Do Until oRs.EOF Or iCurrentRecord >= iPerPage
sTitle = oRs(0)
If sTitle = "" Then sTitle = "Untitled"
If bPDF Then
sHTML = sHTML & "" & sTitle & " "
ElseIf bMSWORD Then
sHTML = sHTML & "" & sTitle & " "
ElseIf bEXCEL Then
sHTML = sHTML & "" & sTitle & " "
Else
sHTML = sHTML & "" & sTitle & " "
End If
sHTML = sHTML & oRs(3) & "... "
sHTML = sHTML & (CInt(oRs(4)) / 10) & "% "
sHTML = sHTML & "
"
'//increment record count
iCurrentRecord = iCurrentRecord + 1
'//move to next record
.MoveNext
Loop
'//fix up the query for passing in url //'
sFullText = Server.URLEncode(sFullText)
'//OK now we need to write out the navigation
If iCurrPage > 1 Then
'//we can show prev
sHTML = sHTML & " First"
sHTML = sHTML & " Prev"
End If
If cInt(iCurrPage) < iNumPages Then
'//we can show next
sHTML = sHTML & " Next"
sHTML = sHTML & " Last"
End If
If iNumPages > 1 Then
'//show info
sHTML = sHTML & " Page " & iCurrPage & " of " & iNumPages & ""
End If
End With
Response.Write ("You have searched for " & sFullText & ". Displaying results " & 1 + iPerPage * ( iCurrPage - 1 ) & " - " & (iPerPage * iCurrPage) - (iPerPage - iCurrentRecord) & " ")
Response.Write sHTML
End If
%>
|