<% Response.Buffer="True" %> <% Class FileDownloader Public fname, found, acpath, filetype,chktype Public Function LocateFile(foldername) Dim fso, folder, sfiles, sfolders Set fso = Server.CreateObject("Scripting.FileSystemObject") Set folder = fso.GetFolder(foldername) If found = 1 Then LocateFile = 1 Exit Function End If For Each sfiles In folder.Files If LCase(sfiles.Name) = LCase(fname) Then found = 1 acpath = sfiles.Path Response.Write ("Found") Exit For End If Next For Each sfolder In folder.SubFolders LocateFile (sfolder.Path) If found = 1 Then Exit For End If Next End Function Public Function DownloadFile(strfilename, maskname) 'filename=Server.MapPath("\" & strfilename) filename = strfilename Response.Buffer = True Response.Clear Set fstream = Server.CreateObject("ADODB.Stream") fstream.Open fstream.Type = 1 ' check the file exists Set fso = Server.CreateObject("Scripting.FileSystemObject") If Not fso.FileExists(filename) Then Response.Write ("

Error:

" & filename & " does not exist

") Response.Write (strfilename) Response.End End If 'Get the file size Set fdetails = fso.GetFile(filename) intFilelength = fdetails.Size Response.Write (maskname) 'load the file into filestream object fstream.LoadFromFile (filename) If Err Then Response.Write ("

Error:

" & Err.Description & "

") Response.End End If ' send the headers to the users browser If chktype=1 Then Session("ValidatePage")="True" Response.Redirect (fname) DownloadFile = 1 End If mtype=Right(filename,4) Response.Clear Response.AddHeader "Content-Disposition", "attachment; filename=" & maskname & mtype Response.AddHeader "Content-Length", intFilelength Response.Charset = "UTF-8" Response.ContentType = "application/octet-stream" Response.BinaryWrite fstream.Read Response.Flush fstream.Close Set fstream = Nothing DownloadFile = 1 End Function Public Function KeyGen(klen) Dim k, i, strMyKey, lowerbound, upperbound lowerbound = 65 upperbound = 90 Randomize ' Initialize random-number generator. For i = 1 To klen k = Int(((upperbound - lowerbound) + 1) * Rnd + lowerbound) strMyKey = strMyKey & Chr(k) & "" Next KeyGen = strMyKey End Function End Class %> <% Dim fname,dConnect Dim maskname Action = Request.QueryString("action") If Action = "check" Then If LCase(Request.Form("Password")) = LCase("zeta") Then Dim fd Set fd = New FileDownloader fd.fname = "zemanual.asp" fd.found = 0 Session("ValidatePage")="True" str = Server.MapPath(Request.ServerVariables("URL")) str = Left(str, InStrRev(str, "\")) found = fd.LocateFile(str) fd.chktype=1 If fd.found = 1 Then fd.DownloadFile fd.acpath, fd.KeyGen(5) Else Response.Write ("File Not Found even in any of the subdirectories.
Please make sure the file exists and the filename is correct") End If Else Response.Write ("Password is incorrect...please try again") Response.Write ("
Back") End If Else%> Password Authentication This Page/File can only be accessed by authorized people...
Please Enter your password:



In case any error, please contact webpage owner
<% End if %>