<% ' Version 4.001 ' Revised 19th Sept 07 On Error Resume Next ' Security check if session("admin") = "" then %> <% response.End() end if dim Path, SubFolder dim SelectedFileName, EditorSource, EditorSourceObject dim ActionCopyFile, ActionDeleteFile, ActionRenameFile dim ActionRenameFolder, ActionDeleteFolder, ActionCreateFolder dim NewFileName, OldFileName dim NewFolderName, CreateFolderName dim i Path = trim(request("Path")) if Path = "undefined" then Path = "images" SubFolder = trim(request("SubFolder")) if SubFolder <> "" then if Path = "" then Path = Path & SubFolder else Path = Path & "\" & SubFolder end if end if SelectedFileName = trim(request("SelectedFileName")) EditorSource = trim(request("EditorSource")) ' editor, filename, filepath, nothing EditorSourceObject = trim(request("EditorSourceObject")) ' object id to return filename or filepath to if EditorSourceObject = "" then EditorSourceObject = "none" ActionCopyFile = trim(request("ActionCopyFile")) if ActionCopyFile = "" then ActionCopyFile = false else ActionCopyFile = true end if ActionDeleteFile = trim(request("ActionDeleteFile")) if ActionDeleteFile = "" then ActionDeleteFile = false else ActionDeleteFile = true end if ActionRenameFile = trim(request("ActionRenameFile")) if ActionRenameFile = "" then ActionRenameFile = false else ActionRenameFile = true end if NewFileName = trim(request("NewFileName")) OldFileName = trim(request("OldFileName")) ActionDeleteFolder = trim(request("ActionDeleteFolder")) if ActionDeleteFolder = "" then ActionDeleteFolder = false else ActionDeleteFolder = true end if ActionCreateFolder = trim(request("ActionCreateFolder")) if ActionCreateFolder = "" then ActionCreateFolder = false else ActionCreateFolder = true end if CreateFolderName = trim(request("CreateFolderName")) ActionRenameFolder = trim(request("ActionRenameFolder")) if ActionRenameFolder = "" then ActionRenameFolder = false else ActionRenameFolder = true end if NewFolderName = trim(request("NewFolderName")) ' Actions dim ActionFS set ActionFS = CreateObject("Scripting.FileSystemObject") ' Files ' Rename File if ActionRenameFile then if ActionFS.FileExists(EditorRootFolderPath & Path & "\" & NewFileName) then call FMPageMessage("File with that name already exists", "Warning") else if ActionFS.FileExists(EditorRootFolderPath & Path & "\" & OldFileName) then ActionFS.MoveFile(EditorRootFolderPath & Path & "\" & OldFileName), (EditorRootFolderPath & Path & "\" & NewFileName) if err.number = 0 then call FMPageMessage("Renamed " & OldFileName & " to " & NewFileName & " successfully", "Success") else call FMPageMessage("Error renaming " & OldFileName & ". Please try again", "Warning") end if end if end if ' Copy File if ActionCopyFile then if ActionFS.FileExists(EditorRootFolderPath & Path & "\" & OldFileName) then ActionFS.CopyFile(EditorRootFolderPath & Path & "\" & OldFileName), (EditorRootFolderPath & Path & "\" & "1111_" & OldFileName) if err.number = 0 then call FMPageMessage("Copied " & OldFileName & " successfully", "Success") else call FMPageMessage("Error copying " & OldFileName & ". Please try again", "Warning") end if end if ' Delete File if ActionDeleteFile then if ActionFS.FileExists(EditorRootFolderPath & Path & "\" & OldFileName) then ActionFS.DeleteFile(EditorRootFolderPath & Path & "\" & OldFileName) if err.number = 0 then call FMPageMessage("Deleted " & OldFileName & " successfully", "Success") else call FMPageMessage("Error deleting " & OldFileName & ". Please try again", "Warning") end if end if ' Folders ' Rename Folder if ActionRenameFolder then ' Get existing folder path and new folder path dim TempRenameFolderNewPath TempRenameFolderNewPath = StrReverse(Path) if instr(TempRenameFolderNewPath,"\") > 0 then TempRenameFolderNewPath = mid(TempRenameFolderNewPath,instr(TempRenameFolderNewPath,"\")+1,len(TempRenameFolderNewPath)) else TempRenameFolderNewPath = "" end if TempRenameFolderNewPath = StrReverse(TempRenameFolderNewPath) if TempRenameFolderNewPath <> "" then TempRenameFolderNewPath = TempRenameFolderNewPath & "\" if ActionFS.FolderExists(EditorRootFolderPath & TempRenameFolderNewPath & NewFolderName) then call FMPageMessage("Folder with that name already exists", "Warning") else ' Rename if ActionFS.FolderExists(EditorRootFolderPath & Path) then ActionFS.MoveFolder(EditorRootFolderPath & Path), (EditorRootFolderPath & TempRenameFolderNewPath & NewFolderName) if err.number = 0 then call FMPageMessage("Renamed folder successfully", "Success") Path = TempRenameFolderNewPath & NewFolderName else call FMPageMessage("Error renaming folder. Please try again", "Warning") end if end if end if ' Delete Folder if ActionDeleteFolder then ' Get existing folder path and new folder path dim TempDeleteFolderNewPath TempDeleteFolderNewPath = StrReverse(Path) if instr(TempDeleteFolderNewPath,"\") > 0 then TempDeleteFolderNewPath = mid(TempDeleteFolderNewPath,instr(TempDeleteFolderNewPath,"\")+1,len(TempDeleteFolderNewPath)) else TempDeleteFolderNewPath = "" end if TempDeleteFolderNewPath = StrReverse(TempDeleteFolderNewPath) ' Delete if ActionFS.FolderExists(EditorRootFolderPath & Path) then ActionFS.DeleteFolder(EditorRootFolderPath & Path) if err.number = 0 then call FMPageMessage("Deleted folder successfully", "Success") Path = TempDeleteFolderNewPath else call FMPageMessage("Error deleting folder. Please try again", "Warning") end if end if ' Create Folder if ActionCreateFolder then if CreateFolderName <> "" then ActionFS.CreateFolder(EditorRootFolderPath & Path & "\" & CreateFolderName) if err.number = 0 then call FMPageMessage("Created " & CreateFolderName & " successfully", "Success") Path = Path & "\" & CreateFolderName else call FMPageMessage("Error creating folder. Please try again", "Warning") end if end if set ActionFS = nothing ' Page Setup dim TotalFiles dim StartNumber, EndNumber, CurrentNumber, PageMaxNumber, NumberNext, NumberPrevious dim FileList, SubFolderList, TempFileName, TempFileSize, TempFileType, TempLastUpdated, TempShowFile, TempFileTitle, TempThumb dim View, TopFolders, TopFoldersArray dim FS, FSFolder View = trim(request("View")) if View = "" then View = session("FileManagerView") if View = "" then View = "details" session("FileManagerView") = View set FS = CreateObject("Scripting.FileSystemObject") set FSFolder = FS.GetFolder(EditorRootFolderPath & Path) ' Page Navigation TotalFiles = FSFolder.Files.count StartNumber = trim(request("StartNumber")) EndNumber = trim(request("EndNumber")) ' Defaults CurrentNumber = 1 PageMaxNumber = 50 if View <> "thumbs" then PageMaxNumber = 300 if StartNumber = "" or isNumeric(StartNumber) = false then StartNumber = 1 StartNumber = CInt(StartNumber) if EndNumber = "" or isNumeric(EndNumber) = false then EndNumber = PageMaxNumber EndNumber = CInt(EndNumber) NumberNext = "Next" NumberPrevious = "Prev" if EndNumber >= TotalFiles then NumberNext = "" if StartNumber = 1 then NumberPrevious = "" ' Top Folder drop-down TopFoldersArray = split(FileManagerFolderList,",") dim TempTopFoldersName, TempTopFoldersValue for i = 0 to UBound(TopFoldersArray) TempTopFoldersName = TopFoldersArray(i) TempTopFoldersValue = TopFoldersArray(i) if TempTopFoldersName = "" then TempTopFoldersName = "Root" TopFolders = TopFolders & "" & vbcrlf next TopFolders = "" & vbcrlf ' Up Folder SubFolderList = "
" & _ "
" ' SubFolderList dim TempSubFolderList for each item in FSFolder.SubFolders TempSubFolderList = " " & _ "" & item.Name & "
" & vbcrlf if Path = "" then ' Show allowed folders if Root for i = 0 to UBound(TopFoldersArray) if lcase(TopFoldersArray(i)) = lcase(item.Name) then SubFolderList = SubFolderList & TempSubFolderList next else SubFolderList = SubFolderList & TempSubFolderList end if next ' FileList for each item in FSFolder.Files TempFileName = item.Name TempFileSize = item.Size TempFileType = item.Type TempLastUpdated = item.DateLastModified TempFileSize = CInt(TempFileSize/1024) TempFileSize = TempFileSize & "KB" TempShowFile = false ' Show current page files only if CurrentNumber => StartNumber and CurrentNumber <= EndNumber then TempShowFile = true else TempShowFile = false end if ' Show/hide Root files if FileManagerShowRootFiles = false and Path = "" then TempShowFile = false if TempShowFile then if View = "thumbs" then ' Avoid fm_xxx files if left(lcase(TempFileName),3) <> "fm_" then TempFileTitle = TempFileName if len(TempFileTitle) > 13 then TempFileTitle = left(TempFileTitle,12) & ".." ' Thumb if IsImage(TempFileName) then TempThumb = "\" & Path & "\" & TempFileName elseif lcase(TempFileType) = "doc" or lcase(TempFileType) = "xls" or lcase(TempFileType) = "mdb" or lcase(TempFileType) = "pdf" then TempThumb = "\editor\fm_" & lcase(TempFileType) & ".gif" else TempThumb = "\editor\fm_other.gif" end if ' Create thumb FileList = FileList & "
" & vbcrlf & _ "
" & vbcrlf & _ TempFileTitle & vbcrlf & _ "
" & vbcrlf end if else ' Avoid fm_xxx files if left(lcase(TempFileName),3) <> "fm_" then ' Create row FileList = FileList & "" & vbcrlf & _ "" & TempFileName & "" & vbcrlf & _ "" & TempFileSize & "" & vbcrlf & _ "" & TempFileType & "" & vbcrlf & _ "" & TempLastUpdated & "" & vbcrlf & _ "" & vbcrlf end if end if end if CurrentNumber = CurrentNumber + 1 next if FileList = "" then FileList = " No files in this folder to edit." else if View = "details" then FileList = "" & FileList & "
" end if ' Local Functions Function IsImage(filename) ' Checks if file is jpg, gif or png filename = lcase(filename) if instr(filename,".jpg") >0 then IsImage = true:exit function if instr(filename,".jpeg") >0 then IsImage = true:exit function if instr(filename,".gif") >0 then IsImage = true:exit function if instr(filename,".png") >0 then IsImage = true:exit function IsImage = false End Function Sub FMPageMessage(Message,Format) %> <% End Sub %> File Manager



Click for larger image
Width:  Height:
Vspace:  Hspace:
Align:
Border:
Alt:
Click for larger image
Path: View:
Top Folders: <%=TopFolders%> Total Files: <%=TotalFiles%>  <%=NumberPrevious%> <%=NumberNext%>
<%=SubFolderList%>
<%=FileList%>