%@ LANGUAGE = VBScript %>
![]() Search Web Folders | ||||||||||||
<%
if Session("DoSearch") = TRUE then
' Formulate SQL Query
CiColumns = "DocTitle,vpath,FileName,Size,Write"
SearchString = Request.Form("SearchString")
if SearchString <> "" then CiRestriction = "FREETEXT ('""" & SearchString & """') > 0"
if UserScope = "" then UserScope = "/"
' reverse slashes
if (StrComp(left(UserScope,1),"\") = 0) then
UserScope = "/" & Right(UserScope,Len(UserScope)-1)
end if
Do While (Instr(UserScope,"\") <> 0)
strpos = Instr(UserScope,"\")
leftstr = Left(UserScope,strpos-1)
rightstr = Right(UserScope,(len(UserScope)-strpos))
UserScope = leftstr & "/" & rightstr
Loop
' check if absolute URL, parse out directories
strpos = Instr(UserScope,ServerName)
if (strpos <> 0) then
strpos = strpos + len(ServerName)
if (strpos-1) <> len(Userscope) then
strpos = Instr(strpos,Userscope,"/")
UserScope = Right(UserScope,(len(UserScope)-strpos))
else
UserScope = "/"
end if
end if
'prepend / if it's not there
if StrComp(left(UserScope,1),"/") <> 0 then
UserScope = "/" & UserScope
end if
if (StrComp(UserScope,"/") = 0) then
CiScope = "SCOPE()"
else
CiScope = "SCOPE(' DEEP TRAVERSAL OF """ & UserScope & """ ')"
end if
if Request.Form("DateSrchOn") = "yes" then
Select Case CInt(Request.Form("DateProp"))
case DATEPROP_MODIFIED
DateProp = "Write"
case DATEPROP_CREATED
DateProp = "Create"
case DATEPROP_LASTACCESSED
DateProp = "Access"
End Select
' check if any props are already in CiColumns
if DateProp <> "Write" AND DateProp <> Prop1 AND DateProp <> Prop2 AND DateProp <> Prop3 then
CiColumns = CiColumns & ", " & DateProp
end if
if Request.Form("DateSrchType") = "today" then
DateAddStr = "DATEADD(day, -1, GETGMTDATE())"
if CiRestriction <> "" then
CiRestriction = CiRestriction & " AND " & DateProp & " >= " & DateAddStr
else
CiRestriction = DateProp & " >= " & DateAddStr
end if
elseif Request.Form("DateSrchType") = "during" then
Select Case CInt(Request.Form("DateType"))
case DATETYPE_DAY
DateAddStr = "DATEADD(day, -" & Request.Form("LastField") & ", GETGMTDATE())"
case DATETYPE_WEEK
DateAddStr = "DATEADD(week, -" & Request.Form("LastField") & ", GETGMTDATE())"
case DATETYPE_MONTH
DateAddStr = "DATEADD(month, -" & Request.Form("LastField") & ", GETGMTDATE())"
case DATETYPE_YEAR
DateAddStr = "DATEADD(year, -" & Request.Form("LastField") & ", GETGMTDATE())"
End Select
if CiRestriction <> "" then
CiRestriction = CiRestriction & " AND " & DateProp & " >= " & DateAddStr
else
CiRestriction = DateProp & " >= " & DateAddStr
end if
end if
end if
if Prop1 <> "" then
if Prop1 <> "Write" AND Prop1 <> "Size" AND Prop1 <> "FileName" AND Prop1 <> "DocTitle" then
CiColumns = CiColumns & "," & Prop1
end if
if Request.Form("Prop1Value") <> "*" then CiRestriction = CiRestriction & AddPropToRestriction(Prop1,Request.Form("Operation1"),Request.Form("Prop1Value"))
end if
if Prop2 <> "" then
if Prop2 <> "Write" AND Prop2 <> "Size" AND Prop2 <> "FileName" AND Prop2 <> "DocTitle" then
CiColumns = CiColumns & "," & Prop2
end if
if Request.Form("Prop2Value") <> "*" then CiRestriction = CiRestriction & AddPropToRestriction(Prop2,Request.Form("Operation2"),Request.Form("Prop2Value"))
end if
if Prop3 <> "" then
if Prop3 <> "Write" AND Prop3 <> "Size" AND Prop3 <> "FileName" AND Prop3 <> "DocTitle" then
CiColumns = CiColumns & "," & Prop3
end if
if Request.Form("Prop3Value") <> "*" then CiRestriction = CiRestriction & AddPropToRestriction(Prop3,Request.Form("Operation3"),Request.Form("Prop3Value"))
end if
AdoCommand.CommandText = AdoCommand.CommandText & " SELECT " & CiColumns & " FROM " & CiScope & " WHERE " & CiRestriction
' debug output
' response.write "CiColumns: " & CiColumns & " " ' response.write "CiScope: " & CiScope & " " ' response.write "CiRestriction: " & CiRestriction & " " ' response.write AdoCommand.CommandText & " " Set RS = Server.CreateObject("ADODB.RecordSet") AdoCommand.Properties("Bookmarkable") = True RS.CursorType = adOpenKeySet RS.MaxRecords = 500 RS.Open AdoCommand if Err then if Err.Number = "-2147215867" then %> <% else %> <% end if Err.Clear else if RS.EOF then %> <% else %> | ||||||||||||
Your search query returned <%=RS.RecordCount%> result(s)<%if UserScope <> "/" then%> in the Web Folder <%=UserScope%><%end if%> on <%=ServerName%>.
<% if RS.RecordCount = 500 then response.write L_Warn500Str_TEXT%>
|