<% If Request.Cookies("Webmaster") <> "Validated" Then Response.Redirect("/ctrfiles/stats/login.asp") End if '' This code is absolute freeware. you can do with it as you please. '' There are no restrictions what so ever, but the code is AS IS, no warrenty or liabilty '' Please leave these commentlines intact '' Netherlands, February 2004 '' M.Blokdijk '' maarten@blokdijk.com '' V 1.0 Sub EditDb On error resume next If fs.FileExists(server.mappath(dbfile)) Then Response.Redirect dbfile & "?db=" & sFile Else Response.Write "No database found" &vbCrLf End If End Sub Sub CreateNewFolder On error resume next %>
Create Folder

Current folder: <%=spath%>

<% End Sub Sub EditFile On error resume next Session("lastpage") = Request.ServerVariables("HTTP_REFERER") Set ReadStream = fs.OpenTextFile(server.mappath(sFile)) filename=request.querystring("file") response.write ("
") Response.write "currently editing: " response.write ""&filename&"" response.write "
" Response.Write "
" &vbCrLf Response.Write "

" &vbCrLf response.write "Save file as: " Response.Write "

 

" &vbCrLf Response.Write "
" &vbCrLf End Sub Sub UploadFiles On error resume next %>
Current folder: <%=spath%>











<% End Sub Sub CreateFile On error resume next response.write "
Create new file
" Session("lastpage") = Request.ServerVariables("HTTP_REFERER") Response.Write "
" &vbCrLf Response.Write "

Give name including extensions.

" &vbCrLf Response.Write "

Contents of file

" &vbCrLf Response.Write "

" &vbCrLf Response.Write "
" &vbCrLf End Sub Sub SaveFile On error resume next '' the save as a new file routine if request.form("NewFileName")<>"" then NewFileName=request.form("NewFileName") spath=request("path") if spath="/" then slashvalue="" else slashvalue="/" end if filestuff=request.form("filestuff") NewPathFileName= spath&slashvalue&newfilename''creating the right path and filename Set fso = CreateObject("Scripting.FileSystemObject") Set textStreamObject = fso.CreateTextFile(server.mappath(NewPathFileName),true,false) textStreamObject.write filestuff Response.Redirect("" & Session("lastpage") & "") else '' done saving as routine If Request.Querystring("overwrite") = "yes" Then set fs=Server.CreateObject("Scripting.FileSystemObject") Set WriteFile = fs.CreateTextFile(server.mappath(sFile), true) WriteFile.Write Request.Form("filestuff")''filestuff''Session("filestuff") WriteFile.Close Response.Redirect("" & Session("lastpage") & "") Else Session("lastpage") = Request.ServerVariables("HTTP_Referer") If fs.FileExists(server.mappath(sFile)) Then Session("sFile") = sFile spath=request.querystring("path") Session("newfilestuff") = Request.Form("newfilestuff") Response.Write "

Filename already exists: " & sFile & "

" Response.Write "" Else Set WriteFile = fs.CreateTextFile(server.mappath(sFile), false) WriteFile.Write Request.Form("newfilestuff") WriteFile.Close Response.Redirect("default.asp?action=viewfolder&path="&spath&"") End If End If end if End Sub Sub CreateFolder On error resume next Session("lastpage") = request.querystring("path") If fs.FolderExists(server.mappath(sFolder)) Then response.write "A folder with the name " & sFolder & " already exists
" Else fs.CreateFolder(server.mappath(sFolder)) ''Response.Redirect("" & Session("lastpage") & "") response.redirect("default.asp?action=viewfolder&path="&session("lastpage")&"") End If End Sub Sub DeleteFile On error resume next response.write"
" If Request.Querystring("commit") <> "yes" Then Session("lastpage") = Request.ServerVariables("HTTP_REFERER") Session("sFile") = sFile Response.Write "

You are about to delete: " & sFile & ". " If sFileType = "jpg" OR sFileType = "gif" Then Response.Write "

" End If Response.Write "This cannot be undone!

" Response.Write "" Else fs.DeleteFile(server.mappath(Session("sFile"))) Response.Redirect("" & Session("lastpage") & "") End If End Sub Sub DeleteFolder On error resume next response.write"
" If Request.Querystring("commit") <> "yes" Then Session("lastpage") = Request.ServerVariables("HTTP_REFERER") Session("sFolder") = sFolder Response.Write "

You are about to delete: " & sFolder & ". " Response.Write "This cannot be undone!

" Response.Write "" Else Response.Write sPath & "
" Response.Write sFile & "
" fs.DeleteFolder(server.mappath(Session("sFolder"))) Response.Redirect("" & Session("lastpage") & "") End If End Sub Sub RenameFolder On error resume next response.write"
" Response.write "Rename folder
" If Request.querystring("commit") <> "yes" Then Session("lastpage") = Request.ServerVariables("HTTP_REFERER") Response.Write "

You are about to rename the folder named: " & request.querystring("folder") & "" %>

&commit=yes"> ">
<% Else NewFolderName=request.form("NewFolderName") sFolder=request.form("folder") if spath="/" then slashvalue="" else slashvalue="/" end if Set fso = CreateObject("Scripting.FileSystemObject") Set folderObject = fso.GetFolder(Server.MapPath(spath&slashvalue&sFolder)) FolderObject.Name=NewFolderName Set folderObject = Nothing Set fso = Nothing Response.Redirect("" & Session("lastpage") & "") End If End Sub Sub RenameFile On error resume next response.write"
" Response.write "Rename file
" If Request("commit") <> "yes" Then Session("lastpage") = Request.ServerVariables("HTTP_REFERER") Response.Write "

You are about to rename the file named: " & request.querystring("file") & "" %>

&commit=yes"> ">

<% Else NewFileName=request.form("NewFileName") Sfile=request.form("filename") if spath="/" then slashvalue="" else slashvalue="/" Set fso = CreateObject("Scripting.FileSystemObject") Set FileObject = fso.GetFile(Server.MapPath(spath&slashvalue&sfile)) FileObject.Name = NewFileName Set FilObject = Nothing Set fso = Nothing Response.Redirect("" & Session("lastpage") & "") End If End Sub Sub FileTypeUnsupported On error resume next Session("lastpage") = Request.ServerVariables("HTTP_REFERER") filename=request.querystring("file") response.write ("
") Response.write "Currently showing: " response.write ""&filename&"" response.write "
" If sFileType = "jpg" OR sFileType = "gif" OR sFileType = "GIF" OR sFileType = "JPG" Then Response.Write "

" else Response.Write "
The selected file was not recognized.

" End If Response.Write "back" End Sub Sub Size(itemsize) Response.Write "" &vbCrLf Select case Len(itemsize) Case "1", "2", "3" Response.Write itemsize & " bytes" Case "4", "5", "6" Response.Write Round(itemsize/1000) & " Kb" Case "7", "8", "9" Response.Write Round(itemsize/1000000) & " Mb" End Select Response.Write "" &vbCrLf End Sub Sub ShowList ' Start building the table to display the information we retrieve about the files and folders in the current directory. Response.Write "" &vbCrLf %> <% ' Use the GetFolder method of the filesystemobject to get the contents of the directory specified in sPath Set fileobject = fs.GetFolder(server.mappath(sPath)) ' Use the SubFolders property to get the folders contained in the directory specified in sPath Set foldercollection = fileobject.SubFolders ' Start the code to alternate line colors - just to make the display a little less visually confusing. lineid=0 bgcolor = "" bgcolor_off = "#FFFFFF" bgcolor_on = "#f0f0f0" ' Loop through the folders contained in the foldercollection and display their information on the page For Each folder in foldercollection ' Apply our alternating line coloring If lineid = 0 Then bgcolor = bgcolor_off lineid = 1 Else bgcolor = bgcolor_on lineid = 0 End if Response.Write "" &vbCrLf If Right(sPath,1)="/" Then Response.Write "" & vbCrLf Else Response.Write "" & vbCrLf End If Response.Write "" &vbCrLf Response.Write "" &vbCrLf Response.Write "" &vbCrLf Next Set foldercollection=nothing ' Use the Files property to get the files contained in the directory specified in sPath Set filecollection = fileobject.Files ' Loop through the files contained in the filescollection and dislay their information on the page For Each file in filecollection ' Apply our alternating line coloring If lineid = 0 Then bgcolor = bgcolor_off lineid = 1 Else bgcolor = bgcolor_on lineid = 0 End if Response.Write "" &vbCrLf %> <% if fs.GetExtensionName(file.name)="gif" then image="" if fs.GetExtensionName(file.name)="pdf" then image="" if fs.GetExtensionName(file.name)="css" then image="" if fs.GetExtensionName(file.name)="doc" then image="" if fs.GetExtensionName(file.name)="xls" then image="" if fs.GetExtensionName(file.name)="exe" then image="" if fs.GetExtensionName(file.name)="zip" then image="" if fs.GetExtensionName(file.name)="jpg" then image="" if fs.GetExtensionName(file.name)="jpeg" then image="" if fs.GetExtensionName(file.name)="htm" then image="" if fs.GetExtensionName(file.name)="html" then image="" if fs.GetExtensionName(file.name)="swf" then image="" if fs.GetExtensionName(file.name)="asp" then image="" if fs.GetExtensionName(file.name)="txt" then image="" if fs.GetExtensionName(file.name)="inc" then image="" if fs.GetExtensionName(file.name)="js" then image="" if fs.GetExtensionName(file.name)="mdb" then image="" if image="" then image= "" Response.Write "" &vbCrLf image="" Response.Write "" &vbCrLf Call Size(file.size) Response.Write "" &vbCrLf Response.Write "" &vbCrLf Response.Write "" &vbCrLf Next ' We are done displaying information about files and folders in this directory, so close the table. Response.Write "
Name
Type
Size
Date accessed
Action
" & folder.name & " " & folder.name & "folder" Call Size(folder.size) Response.Write "" & folder.datelastmodified & "rename delete
"&image&" " & file.name & "" & fs.GetExtensionName(file.name) & "" & file.datelastmodified & "rename delete
" &vbCrLf End Sub Sub DisplayErrors Response.Write "U heeft: " & errornum & " niet toegestane akties ondernomen." Response.Write "" & vbCrlf End Sub %>