<% '' 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 "Banco de dados não encontrado" &vbCrLf End If End Sub Sub CreateNewFolder On error resume next %>
Nova Pasta

Pasta atual: <%=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 "Alterando: " response.write ""&filename&"" response.write "
" Response.Write "
" &vbCrLf Response.Write "

" &vbCrLf response.write "Salvar arquivo como: " Response.Write "

 

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











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

De um nome incluindo extensão.

" &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 "

Este nome de arquivo já existe: " & 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 "Uma pasta com o nome " & sFolder & " já existe
" Else fs.CreateFolder(server.mappath(sFolder)) ''Response.Redirect("" & Session("lastpage") & "") response.redirect(scriptname & "?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 "

Você vai apagar o arquivo: " & sFile & ". " If sFileType = "jpg" OR sFileType = "gif" Then Response.Write "

" End If Response.Write "Esta operação não poderá ser desfeita!

" Response.Write "Continuar?" Response.Write "Cancelar" 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 "

Você vai apagar a pasta: " & sFolder & ". " Response.Write "Esta operação não poderá ser desfeita!

" 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 "Renomear Pasta
" If Request.querystring("commit") <> "yes" Then Session("lastpage") = Request.ServerVariables("HTTP_REFERER") Response.Write "

Tem certeza que deseja trocar o nome da pasta chamada: " & 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 "Renomear arquivo
" If Request("commit") <> "yes" Then Session("lastpage") = Request.ServerVariables("HTTP_REFERER") Response.Write "

Tem certeza que deseja trocar o nome do arquivo: " & 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 "Exibindo: " response.write ""&filename&"" response.write "
" If sFileType = "jpg" OR sFileType = "gif" OR sFileType = "GIF" OR sFileType = "JPG" Then Response.Write "

" else Response.Write "
O arquivo selecionado não foi reconhecido.

" End If Response.Write "Voltar" 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 "
Nome
Tipo
Tamanho
Acessado em
Ação
" & folder.name & " " & folder.name & "pasta" 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 "Erro: " & errornum & "_." Response.Write "" & vbCrlf End Sub %>