<% Set RSnuke = Conn.Execute("TRUNCATE TABLE Gallery") ' This function takes a filename and returns the appropriate image for ' that file type based on it's extension. If you pass it "dir", it assumes ' that the corresponding item is a directory and shows the folder icon. Dim strPath 'Path of directory to show Dim objFSO 'FileSystemObject variable Dim objFolder 'Folder variable Dim objItem 'Variable used to loop through the contents of the folder ' You could just as easily read this from some sort of input, but I don't ' need you guys and gals roaming around our server so I've hard coded it to ' a directory I set up to illustrate the sample. ' NOTE: As currently implemented, this needs to end with the / strPath = "./UserFiles/Image/Gallery" ' Create our FSO Set objFSO = Server.CreateObject("Scripting.FileSystemObject") ' Get a handle on our folder Set objFolder = objFSO.GetFolder(Server.MapPath(strPath)) ' Show a little description line and the title row of our table ' First I deal with any subdirectories. I just display them and when you ' click you go to them via plain HTTP. You might want to loop them back ' through this file once you've set it up to take a path as input. It seems ' like the logical thing to do to me at least! 'For Each objItem In objFolder.SubFolders ' Deal with the stupid VTI's that keep giving our visitors 404's If InStr(1, objItem, "_vti", 1) = 0 AND 1=2 Then %> <%= ShowImageForType("dir") %> <%= objItem.Name %> <%= objItem.Size %> <%= objItem.DateCreated %> <%= objItem.Type %> <% End If 'Next 'objItem ' Now that I've done the SubFolders, do the files! For Each objItem In objFolder.Files Set RSfilecheck = Conn.Execute("SELECT gID FROM Gallery WHERE gActive=1 AND gFileName like '" & replace("" & objItem.Name,"'","''") & "'") If NOT RSfilecheck.eof Then Do While NOT RSfilecheck.eof RSfilecheck.MoveNext Loop Else NewFileName = objItem.Name If instr("" & NewFilename, "80_")=0 Then Set RSins = Conn.Execute("INSERT INTO Gallery (gFilename) VALUES ('" & replace("" & NewFileName,"'","''") & "')") End If End If RSfilecheck.Close Set RSfilecheck = Nothing Next 'objItem ' All done! Kill off our object variables. Set objItem = Nothing Set objFolder = Nothing Set objFSO = Nothing ' Oops... I almost forgot to close up the table. IE will forgive you, ' but Netscape will catch you on this error - AS IT SHOULD! ' Ok, so I'm a little odd being a Microsoft supporter and yet I still ' use Netscapes's browser... I just like it better... so sue me! ' ' I probably shouldn't say that too loudly... ' ...you never know what the next lawsuit will be! %> Image Gallery
<% CountPics = 0 Set RS = Conn.Execute("SELECT gID, gFilename FROM Gallery WHERE gActive=1 ORDER BY NewID()") Do While NOT RS.eof If FileExists("/UserFiles/Image/Gallery/","80_" & RS("gFileName"))<>True Then ResizePic 80, "/UserFiles/Image/Gallery/" & RS("gFileName"), "/UserFiles/Image/Gallery/80_" & RS("gFileName") End If %> <% CountPics = CountPics + 1 If CountPics MOD 4 = 0 Then %><% End If RS.MoveNext Loop RS.Close Set RS = Nothing %>
" target="_blank">" border="0" width="80">