<% per_page = Cint(Request.querystring("per")) If per_page = 0 then per_page = 6 End If page_num = Cint(Request.querystring("page")) If page_num = 0 then page_num = 1 End If cat = Request.querystring("cat") 'If cat = "" then 'cat = "ford" 'End If strQuery = Request.querystring("search") CONST DIRECTORY = "/" ' relative path in virtual directories ' Specify one of these constants for "sortBy"... CONST FILE_NAME = 0 CONST FILE_MODIFIED = 1 sortBy = FILE_MODIFIED reverse = true 'get files set fs = CreateObject("Scripting.FileSystemObject") if not cat = "" then set folder = fs.GetFolder(Server.MapPath("photos/" & cat & "/")) else set folder = fs.GetFolder(Server.MapPath("photos/")) end if Set curFiles = folder.Files Dim sortedFiles(500) Dim filteredFiles(500) currentSlot = -1 searchCount = 0 For Each fileItem in curFiles fname = fileItem.Name fmod = fileItem.DateLastModified if not strQuery = "" then If InStr(1, fileItem.Name, strQuery, vbTextCompare) <> 0 Then searchCount = searchCount + 1 currentSlot = currentSlot + 1 sortedFiles (currentSlot) = Array(fname,fmod) end if else currentSlot = currentSlot + 1 sortedFiles(currentSlot) = Array(fname,fmod) end if Next if searchCount = 0 and not strQuery = "" then Response.Write "
Sorry, no photos found" %>

" method="get">

<% Response.Write "See all photos " Response.Write "
" else 'Response.Write searchCount & " photos found with '" & strQuery & "' in the name
" fileCount = currentSlot If VarType( sortedFiles( 0 )( sortBy ) ) = 8 Then If reverse Then kind = 1 Else kind = 2 ' sorting strings... Else If reverse Then kind = 3 Else kind = 4 ' non-strings (numbers, dates) End If 'sort files For i = fileCount TO 0 Step -1 minmax = sortedFiles( 0 )( sortBy ) minmaxSlot = 0 For j = 1 To i Select Case kind ' which kind of sort are we doing? ' after the "is bigger/smaller" test (as appropriate), ' mark will be true if we need to "remember" this slot... Case 1 ' string, reverse...we do case INsensitive! mark = (strComp( sortedFiles(j)(sortBy), minmax, vbTextCompare ) < 0) Case 2 ' string, forward...we do case INsensitive! mark = (strComp( sortedFiles(j)(sortBy), minmax, vbTextCompare ) > 0) Case 3 ' non-string, reverse ... mark = (sortedFiles( j )( sortBy ) < minmax) Case 4 ' non-string, forward ... mark = (sortedFiles( j )( sortBy ) > minmax) End Select ' so is the current slot bigger/smaller than the remembered one? If mark Then ' yep, so remember this one instead! minmax = sortedFiles( j )( sortBy ) minmaxSlot = j End If Next ' is the last slot the min (or max), as it should be? If minmaxSlot <> i Then ' nope...so do the needed swap... temp = sortedFiles( minmaxSlot ) sortedFiles( minmaxSlot ) = sortedFiles( i ) sortedFiles( i ) = temp End If Next 'count files 'calc how many pages needed if not searchCount = 0 then filtered_count = searchCount else filtered_count = folder.files.count end if 'Response.Write filtered_count & " - Filtered count
" pageCount = filtered_count / per_page 'Response.Write folder.files.count & " - Total count
" If pageCount > Int(pageCount) then pageCount = Int(pageCOunt) + 1 Else pageCount = Int(pageCount) End If Response.Write "
" Response.Write "" Response.Write "" Response.Write "" Response.Write "" Response.Write "
" Response.Write "Categories  -  " Response.Write "Ford   " Response.Write "Mustang   " Response.Write "4WD   " Response.Write "Camaro   " Response.Write "Chevy   " Response.Write "Corvette   " Response.Write "High-end   " Response.Write "Honda   " Response.Write "Imports   " Response.Write "Mopar   " Response.Write "Race Cars   " Response.Write "Trucks   " Response.Write "VW  

" Response.Write "
Page - " For index = 1 to pageCount If index = page_num then Response.Write "" & index & " " Else Response.Write "" & index & " " End If Next Response.Write "Photo's Per Page - " Response.Write "2 " Response.Write "4 " Response.Write "6 " Response.Write "8 " Response.Write "10 " Response.Write "
" 'Response.Write "" %>
<% start = Cint(((page_num - 1) * per_page)) index = Cint(start) last_page_vids = filtered_count - ((pageCount - 1) * per_page) on_page = per_page if page_num = pageCount then on_page = last_page_vids end if 'Response.Write last_page_vids & " - Last Page vids
" end_vid = (start + on_page) - 1 'Response.Write end_vid & " - End vid
" Response.Write "" for index = Cint(start) to Cint(end_vid) name = sortedFiles(index)(0) name = Replace(name,"_"," ") name = Replace(name,".jpg","") Response.Write "" row = index - start if abs(row) mod 2 then if not index = ((start + on_page) - 1) then Response.Write "" end if end if next Response.Write "
" 'Response.Write "

" & name & "

" Response.Write "
" end if %>