Use ASP to hide file paths to achieve anti-theft chains

zhaozj2021-02-16  84

<% From_url = Cstr (Request.ServerVariables ( "HTTP_REFERER")) Serv_url = Cstr (Request.ServerVariables ( "SERVER_NAME")) if mid (From_url, 8, len (Serv_url)) <> Serv_url then response.write "illegal links ! "'Prevention of stense.endendiff

If Request.cookies ("logined") = "" "" "" The response.Redirect "/login.asp" needs to be logged in! end ifFunction GetFileName (longname) '/ folder1 / folder2 / file.asp => file.asp while instr (longname, "/") longname = right (longname, len (longname) -1) wend GetFileName = longnameEnd FunctionDim StreamDim ContentsDim FileNameDim TrueFileNameDim FileExtConst adTypeBinary = 1FileName = Request.QueryString ( "fileName") if fileName = "" Then Response.Write "invalid file name!" Response.EndEnd ifFileExt = Mid (fileName, InStrRev (fileName, ".") 1) Select Case Ucase (FileExt) Case "ASP", "ASA", "ASPX", "ASAX", "MDB" illegal operation! "Response.ndend selectResponse.clearif Lcase (Right (filename, 3)) =" GIF "OR LCASE (Right (FileName, 3)) =" JPG "or LCase (Right (filename, 3)) =" PNG "the response.contentType =" image / * "" Download dialog box ELSE Response.ContentType = "application / ms-download" end ifResponse.AddHeader "content-disposition", "attachment; filename =" & GetFileName (Request.QueryString ( "fileName")) Set Stream = server.CreateObject ( "ADODB.Stream ") Stream.type = adtypebinaryStream.openif Lcase (Right (Fi Lename, 3)) = "PDF" THEN 'Settings PDF Type File Directory TrueFileName = "/ THE_PDF_FILE_S /" & FileNameEnd if ifness (Right (FileName, 3)) = "DOC" TEN' Settings DOC Type File Directory TRUEFileName = "/ MY_D_O_C_FILE / "& FileNameEnd IFIF LCASE (Right (FileName, 3)) =" GIF "or LCase (Right (FileName, 3)) =" JPG "or LCase (Right (filename, 3)) =" PNG "

then TrueFileName = "/ all_images _ /" & FileName 'setting image file directory end ifStream.LoadFromFile Server.MapPath (TrueFileName) While Not Stream.EOS Response.BinaryWrite Stream.Read (1024 * 64) WendStream.CloseSet Stream = NothingResponse.FlushResponse.End %> Download people. It may be itself a biggest disaster of IIS ... Small system can be used. But it is absolutely not suitable for downloading. But anti-theft seems to be the most needed download station ...

EGLIC (2004-04-28) is slow, seriously affecting the performance of the server, is better than designing a timing transform directory location or directory depth program?

转载请注明原文地址:https://www.9cbs.com/read-13008.html

New Post(0)