<%@ Language=VBScript %> <% Session.LCID = 1033 On Error Resume Next strOrderBy="" strOrderImage="" Call CalculateOrderBy TargetPageNumber=Request.Form("TargetPageNumber") if TargetPageNumber="" or Request.Form("action")="search" then _ TargetPageNumber=1 if Request.Form("PageSize")<>"" then Session("PageSize") = Request.Form("PageSize") end if if Session("PageSize")<>"" then PageSize = Session("PageSize") ' delete record if (Request.Form("deleteid")<>"") then if (Request.Form("NeedQuotes"&BuildFieldName(strKeyField)))="True" then strQuote="'" else strQuote="" end if if (Request.Form("NeedQuotes"&BuildFieldName(strKeyField2)))="True" then strQuote2="'" else strQuote2="" end if if (Request.Form("NeedQuotes"&BuildFieldName(strKeyField3)))="True" then strQuote3="'" else strQuote3="" end if strSQL="delete from " & strTableName & _ " where " & AddWrappers(strKeyField) & "=" & strQuote & Replace(Request.Form("deleteid"),"'","''") & strQuote if strKeyField2<>"" then _ strSQL=strSQL & " and " & AddWrappers(strKeyField2) & "=" & strQuote2 & Replace(Request.Form("deleteid2"),"'","''") & strQuote2 if strKeyField3<>"" then _ strSQL=strSQL & " and " & AddWrappers(strKeyField3) & "=" & strQuote3 & Replace(Request.Form("deleteid3"),"'","''") & strQuote3 set dbConnection = server.CreateObject ("ADODB.Connection") dbConnection.ConnectionString = strConnection dbConnection.Open Call ReportError LogInfo(strSQL) dbConnection.Execute strSQL Call ReportError dbConnection.close set dbConnection = nothing end if if Request.Form("action")<>"Search" and Request.Form("SQL")<>"" then strSQL=Request.Form("SQL") if strOrderBy<>"" then if InStr(1, strSQL, "order by")>0 then strSQL = Left(strSQL,InStr(1, strSQL, "order by")-1) & strOrderBy else strSQL = strSQL & strOrderBy end if end if else if gstrSQL="" then strSQL="select * from " & strTableName else strSQL = gstrSQL if LCase(Left(strSQL,7)) = "select " then if InStr(1, LCase(gstrSQL), LCase(strKeyField) & ",")<1 then strSQL = "select " & AddWrappers(strKeyField) & ", " & Mid(strSQL, 8) if InStr(1, LCase(gstrSQL), LCase(strKeyField2) & ",")<1 then strSQL = "select " & AddWrappers(strKeyField2) & ", " & Mid(strSQL, 8) if InStr(1, LCase(gstrSQL), LCase(strKeyField3) & ",")<1 then strSQL = "select " & AddWrappers(strKeyField3) & ", " & Mid(strSQL, 8) if InStr(1, LCase(gstrSQL), LCase(","))<1 then strSQL = "select " & AddWrappers("") & ", " & Mid(strSQL, 8) end if end if ' see if we have some search parameters ' regular search if Request.Form("action")="Search" and Request.Form("SearchFor")<>"" then strSearchFor=Trim(Request.Form("SearchFor")) strSearchOption=Trim(Request.Form("SearchOption")) if Request.Form("SearchField")<>"AnyField" then strSQL = strSQL & " where " & AddWrappers(Request.Form("SearchField")) & StrWhere(Request.Form("SearchField"), strSearchFor, strSearchOption) else strSQL = strSQL & " where 1=0" strSQL = strSQL & " or " & AddWrappers("YEAR") & StrWhere("YEAR", strSearchFor, strSearchOption) strSQL = strSQL & " or " & AddWrappers("MONTH") & StrWhere("MONTH", strSearchFor, strSearchOption) strSQL = strSQL & " or " & AddWrappers("DAY") & StrWhere("DAY", strSearchFor, strSearchOption) strSQL = strSQL & " or " & AddWrappers("PLACE") & StrWhere("PLACE", strSearchFor, strSearchOption) strSQL = strSQL & " or " & AddWrappers("Province") & StrWhere("Province", strSearchFor, strSearchOption) strSQL = strSQL & " or " & AddWrappers("KIND") & StrWhere("KIND", strSearchFor, strSearchOption) strSQL = strSQL & " or " & AddWrappers("SOURCE") & StrWhere("SOURCE", strSearchFor, strSearchOption) strSQL = strSQL & " or " & AddWrappers("Number") & StrWhere("Number", strSearchFor, strSearchOption) strSQL = strSQL & " or " & AddWrappers("UFO") & StrWhere("UFO", strSearchFor, strSearchOption) strSQL = strSQL & " or " & AddWrappers("COMMENT") & StrWhere("COMMENT", strSearchFor, strSearchOption) strSQL = strSQL & " or " & AddWrappers("SOURCE2") & StrWhere("SOURCE2", strSearchFor, strSearchOption) end if end if ' advanced search if Request.Form("action")="AdvancedSearch" then sWhere="" For i = 1 To Request.Form("SearchFor").Count strSearchFor=Trim(Request.Form("SearchFor")(i)) if strSearchFor<>"" then if sWhere="" then sWhere=" where 1=1" strSearchOption=Trim(Request.Form("SearchOption")(i)) sWhere = sWhere & " and " & AddWrappers(Request.Form("FieldName")(i)) & StrWhere(Request.Form("FieldName")(i), strSearchFor, strSearchOption) end if next strSQL = strSQL & sWhere end if strSQL = strSQL & " " & Trim(strOrderBy) end if Response.Write("") Response.Write("") Response.Write("" & strTableName & "") Response.Write("") Response.Write(""" then Response.Write(" onLoad=""if (document.frmAdmin.SearchFor != null) document.frmAdmin.SearchFor.focus();""") Response.Write(">") %>
>
>
<% ' Pagination: Control Variables dim iNumberOfRows dim maxRecords dim maxpages dim mypage iNumberOfRows =0 maxRecords = 0 maxpages = 0 mypage = TargetPageNumber if mypage = "" then mypage =1 if CDBL(mypage)<=0 then mypage =1 %> <%' Control Functions %>
"> <% If Session("UserID")<>"" Then %> <% End If %>
 Logged as <%=Session("UserID")%>   Log out   Advanced search  
<%' Pagination: Write Search result Header%> <% set rsDetails = setupRs(strConnection,strSQL,PageSize) Call ReportError %>
Search for:     Details found: <%=maxRecords%>
Page <%=mypage%> of <%=maxpages%>
Records Per Page:
<% ' quotes for search and edit fields for i=0 to rsDetails.Fields.Count-1 strNeedQuotes=IfNeedQuotes(rsDetails.Fields(i).Type) Response.Write "" & vbCRLF Response.Write "" & vbCRLF if rsDetails.Fields(i).Name=strKeyField or rsDetails.Fields(i).Name=strKeyField2 or rsDetails.Fields(i).Name=strKeyField3 then %> <% end if next %>
<% for i=0 to rsDetails.Fields.Count-1 strNeedQuotes=IfNeedQuotes(rsDetails.Fields(i).Type) Response.Write "" & vbCrLF Response.Write "" & vbCRLF next %>
<% call WriteTableHeader call loopRs(rsDetails, CLng(PageSize)) %> <% rsDetails.Close Set rsDetails = Nothing %>
<%' Pagination: Write Control%> <% Response.Write("") Response.Write("") function setupRs(strConnection,strSQL,nPageSize) Err.Clear Set setupRs = server.CreateObject ("ADODB.Recordset") set dbConnection = server.CreateObject ("ADODB.Connection") dbConnection.ConnectionString = strConnection dbConnection.Open Call ReportError LogInfo(strSQL) setupRs.open strSQL,dbConnection Call ReportError ' Pagination: if NOT setupRs.EOF then setupRs.PageSize =nPageSize maxRecords = cdbl(setupRs.RecordCount) maxpages=cdbl(setupRs.PageCount) if cdbl(mypage) > cdbl(maxpages) then mypage = maxpages End IF setupRs.AbsolutePage = mypage maxrecs=cdbl(setupRs.pagesize) End IF end function sub WriteTableHeader %> " else %> '; document.forms.frmAdmin.submit(); return false; "><%=Label("ID")%> <% if Request.Form("orderby")="ID" and strOrderImage<>"" then Response.Write "" end if end if %>
<% if (rsDetails.Fields("ID").Attributes and 128) and ( rsDetails.Fields("ID").Type = 204 or rsDetails.Fields("ID").Type=205 ) then Response.Write Label("ID") & "
" else %> '; document.forms.frmAdmin.submit(); return false; "><%=Label("YEAR")%> <% if Request.Form("orderby")="YEAR" and strOrderImage<>"" then Response.Write "" end if end if %>
<% if (rsDetails.Fields("YEAR").Attributes and 128) and ( rsDetails.Fields("YEAR").Type = 204 or rsDetails.Fields("YEAR").Type=205 ) then Response.Write Label("YEAR") & "
" else %> '; document.forms.frmAdmin.submit(); return false; "><%=Label("MONTH")%> <% if Request.Form("orderby")="MONTH" and strOrderImage<>"" then Response.Write "" end if end if %>
<% if (rsDetails.Fields("MONTH").Attributes and 128) and ( rsDetails.Fields("MONTH").Type = 204 or rsDetails.Fields("MONTH").Type=205 ) then Response.Write Label("MONTH") & "
" else %> '; document.forms.frmAdmin.submit(); return false; "><%=Label("DAY")%> <% if Request.Form("orderby")="DAY" and strOrderImage<>"" then Response.Write "" end if end if %>
<% if (rsDetails.Fields("DAY").Attributes and 128) and ( rsDetails.Fields("DAY").Type = 204 or rsDetails.Fields("DAY").Type=205 ) then Response.Write Label("DAY") & "
" else %> '; document.forms.frmAdmin.submit(); return false; "><%=Label("PLACE")%> <% if Request.Form("orderby")="PLACE" and strOrderImage<>"" then Response.Write "" end if end if %>
<% if (rsDetails.Fields("PLACE").Attributes and 128) and ( rsDetails.Fields("PLACE").Type = 204 or rsDetails.Fields("PLACE").Type=205 ) then Response.Write Label("PLACE") & "
" else %> '; document.forms.frmAdmin.submit(); return false; "><%=Label("Province")%> <% if Request.Form("orderby")="Province" and strOrderImage<>"" then Response.Write "" end if end if %>
<% if (rsDetails.Fields("Province").Attributes and 128) and ( rsDetails.Fields("Province").Type = 204 or rsDetails.Fields("Province").Type=205 ) then Response.Write Label("Province") & "
" else %> '; document.forms.frmAdmin.submit(); return false; "><%=Label("KIND")%> <% if Request.Form("orderby")="KIND" and strOrderImage<>"" then Response.Write "" end if end if %>
<% if (rsDetails.Fields("KIND").Attributes and 128) and ( rsDetails.Fields("KIND").Type = 204 or rsDetails.Fields("KIND").Type=205 ) then Response.Write Label("KIND") & "
" else %> '; document.forms.frmAdmin.submit(); return false; "><%=Label("SOURCE")%> <% if Request.Form("orderby")="SOURCE" and strOrderImage<>"" then Response.Write "" end if end if %>
<% if (rsDetails.Fields("SOURCE").Attributes and 128) and ( rsDetails.Fields("SOURCE").Type = 204 or rsDetails.Fields("SOURCE").Type=205 ) then Response.Write Label("SOURCE") & "
" else %> '; document.forms.frmAdmin.submit(); return false; "><%=Label("Number")%> <% if Request.Form("orderby")="Number" and strOrderImage<>"" then Response.Write "" end if end if %>
<% if (rsDetails.Fields("Number").Attributes and 128) and ( rsDetails.Fields("Number").Type = 204 or rsDetails.Fields("Number").Type=205 ) then Response.Write Label("Number") & "
" else %> '; document.forms.frmAdmin.submit(); return false; "><%=Label("IMAGE")%> <% if Request.Form("orderby")="IMAGE" and strOrderImage<>"" then Response.Write "" end if end if %>
<% if (rsDetails.Fields("IMAGE").Attributes and 128) and ( rsDetails.Fields("IMAGE").Type = 204 or rsDetails.Fields("IMAGE").Type=205 ) then Response.Write Label("IMAGE") & "
" else %> '; document.forms.frmAdmin.submit(); return false; "><%=Label("UFO")%> <% if Request.Form("orderby")="UFO" and strOrderImage<>"" then Response.Write "" end if end if %>
<% if (rsDetails.Fields("UFO").Attributes and 128) and ( rsDetails.Fields("UFO").Type = 204 or rsDetails.Fields("UFO").Type=205 ) then Response.Write Label("UFO") & "
" else %> '; document.forms.frmAdmin.submit(); return false; "><%=Label("COMMENT")%> <% if Request.Form("orderby")="COMMENT" and strOrderImage<>"" then Response.Write "" end if end if %>
<% if (rsDetails.Fields("COMMENT").Attributes and 128) and ( rsDetails.Fields("COMMENT").Type = 204 or rsDetails.Fields("COMMENT").Type=205 ) then Response.Write Label("COMMENT") & "
" else %> '; document.forms.frmAdmin.submit(); return false; "><%=Label("IMAGE2")%> <% if Request.Form("orderby")="IMAGE2" and strOrderImage<>"" then Response.Write "" end if end if %>
<% if (rsDetails.Fields("IMAGE2").Attributes and 128) and ( rsDetails.Fields("IMAGE2").Type = 204 or rsDetails.Fields("IMAGE2").Type=205 ) then Response.Write Label("IMAGE2") & "
" else %> '; document.forms.frmAdmin.submit(); return false; "><%=Label("SOURCE2")%> <% if Request.Form("orderby")="SOURCE2" and strOrderImage<>"" then Response.Write "" end if end if %>
<% if (rsDetails.Fields("SOURCE2").Attributes and 128) and ( rsDetails.Fields("SOURCE2").Type = 204 or rsDetails.Fields("SOURCE2").Type=205 ) then Response.Write Label("SOURCE2") & "
<% end sub ' display table with results sub loopRs(rsData,nPageSize) ' Pagination: dim iShadeTheDetail dim iNumberOfRows iNumberOfRows = 0 if isObject(rsData) then ' Pagination: UNTIL iNumberOfRows>=maxrecs DO UNTIL rsData.eof OR iNumberOfRows>=nPageSize ' To insure that every other one is shaded If iShadeTheDetail = 0 then sShadeClass = "class=shade" iShadeTheDetail = 1 Else sShadeClass = "" iShadeTheDetail = 0 End If %> onmouseover="rowRollover(<%=iNumberOfRows%>, 1);" onmouseout="rowRollover(<%=iNumberOfRows%>, 0);" id="tr_<%=iNumberOfRows%>"> <% if IsBinaryField(rsData.Fields("ID")) then Response.Write CreateImageControl(rsData, "ID") else Response.Write ProcessLargeText(GetData(rsData.Fields("ID"), "")) end if %> <% if IsBinaryField(rsData.Fields("YEAR")) then Response.Write CreateImageControl(rsData, "YEAR") else Response.Write ProcessLargeText(GetData(rsData.Fields("YEAR"), "")) end if %> <% if IsBinaryField(rsData.Fields("MONTH")) then Response.Write CreateImageControl(rsData, "MONTH") else Response.Write ProcessLargeText(GetData(rsData.Fields("MONTH"), "")) end if %> <% if IsBinaryField(rsData.Fields("DAY")) then Response.Write CreateImageControl(rsData, "DAY") else Response.Write ProcessLargeText(GetData(rsData.Fields("DAY"), "")) end if %> <% if IsBinaryField(rsData.Fields("PLACE")) then Response.Write CreateImageControl(rsData, "PLACE") else Response.Write ProcessLargeText(GetData(rsData.Fields("PLACE"), "")) end if %> <% if IsBinaryField(rsData.Fields("Province")) then Response.Write CreateImageControl(rsData, "Province") else Response.Write ProcessLargeText(GetData(rsData.Fields("Province"), "")) end if %> <% if IsBinaryField(rsData.Fields("KIND")) then Response.Write CreateImageControl(rsData, "KIND") else Response.Write ProcessLargeText(GetData(rsData.Fields("KIND"), "")) end if %> <% if IsBinaryField(rsData.Fields("SOURCE")) then Response.Write CreateImageControl(rsData, "SOURCE") else Response.Write ProcessLargeText(GetData(rsData.Fields("SOURCE"), "")) end if %> <% if IsBinaryField(rsData.Fields("Number")) then Response.Write CreateImageControl(rsData, "Number") else Response.Write ProcessLargeText(GetData(rsData.Fields("Number"), "")) end if %> "> <% if IsBinaryField(rsData.Fields("UFO")) then Response.Write CreateImageControl(rsData, "UFO") else Response.Write ProcessLargeText(GetData(rsData.Fields("UFO"), "")) end if %> <% if IsBinaryField(rsData.Fields("COMMENT")) then Response.Write CreateImageControl(rsData, "COMMENT") else Response.Write ProcessLargeText(GetData(rsData.Fields("COMMENT"), "")) end if %> "> <% if IsBinaryField(rsData.Fields("SOURCE2")) then Response.Write CreateImageControl(rsData, "SOURCE2") else Response.Write ProcessLargeText(GetData(rsData.Fields("SOURCE2"), "")) end if %> <% iNumberOfRows = iNumberOfRows + 1 rsData.movenext Loop end if end sub Sub CalculateOrderBy if Request.Form("action")="OrderBy" then strOrderBy = " order by " & AddWrappers(Request.Form("orderby")) if Request.Form("SQL")<>"" then nInd = InStr(1, Request.Form("SQL"),"order by ") if nInd>0 then if Left(Mid(Request.Form("SQL"),nInd+Len("order by ")),Len(AddWrappers(Request.Form("orderby")))) = AddWrappers(Request.Form("orderby")) _ and Right(Request.Form("SQL"),3) = "asc" then strOrderBy = strOrderBy & " desc" else strOrderBy = strOrderBy & " asc" end if else strOrderBy = strOrderBy & " asc" end if else strOrderBy = strOrderBy & " asc" end if if right(strOrderBy,3)="asc" then strOrderImage="up.gif" else strOrderImage="down.gif" end if else strOrderBy = Request.Form("orderby") if strOrderBy="" and Request.Form("SQL")="" then strOrderBy=gstrOrderBy end if End Sub Function CheckSecurity(strValue, strAction) if (cAdvSecurityMethod = ADVSECURITY_ALL and Session("AccessLevel")<>ACCESS_LEVEL_GUEST ) _ or Session("AccessLevel")=ACCESS_LEVEL_ADMIN or (strAction="Add" and Session("AccessLevel")<>ACCESS_LEVEL_GUEST) then CheckSecurity = True Exit Function end if if Session("AccessLevel")=ACCESS_LEVEL_GUEST then CheckSecurity = False Exit Function end if if cAdvSecurityMethod = ADVSECURITY_EDIT_OWN then if RemoveWrappers(Session("OwnerID"))=CStr(strValue) then CheckSecurity = True else CheckSecurity = False end if else CheckSecurity = True end if End Function Function CreateImageControl(rsData, sFieldName) strImageWhere = " " & strKeyField & "=" & GetData(rsData.Fields(strKeyField), "") if strKeyField2<>"" then _ strImageWhere = strImageWhere & " and " & strKeyField2 & "=" & GetData(rsData.Fields(strKeyField2), "") if strKeyField3<>"" then _ strImageWhere = strImageWhere & " and " & strKeyField3 & "=" & GetData(rsData.Fields(strKeyField3), "") CreateImageControl = "" End Function %>