当前位置:首页 > 文章 > 正文
leadbbs图片防盗简易安装方法
作者:网络 | 来源:花香盈路 | 时间:2005-05-21 | 阅读权限:游客 | 会员币:0 | 【
           第一步:将以下代码存为down.asp,也可以为任意文件名,放在论坛根目录下
            ///////////
            <!-- #include file=inc/Upload_Setup.asp -->
            <%
            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.redirect "/bbs/images/logo.gif"
             response.end
            end if

            Function GetFileName(longname)
             while instr(longname,"/")
              longname = right(longname,len(longname)-1)
             wend
             GetFileName = longname
            End Function
            Dim Stream
            Dim Contents
            Dim FileName
            Dim TrueFileName
            Dim FileExt

            Const adTypeBinary = 1
            FileName = Request.QueryString("FileName")
            if FileName = "" Then
                Response.End
            End if
            FileExt = Mid(FileName, InStrRev(FileName, ".") + 1)

            Response.Clear
            if lcase(right(FileName,3))="gif" or lcase(right(FileName,3))="jpg" 
            or lcase(right(FileName,3))="png" then
             Response.ContentType = "image/*" '对图像文件不出现下载对话框
            else
             Response.ContentType = "application/ms-download"
            end if

            Response.AddHeader "content-disposition", "attachment; filename=" & 
            GetFileName(Request.QueryString("FileName"))
            Set Stream = server.CreateObject("ADODB.Stream")
            Stream.Type = adTypeBinary
            Stream.Open
            '设置服务器文件真实地址
             TrueFileName = DEF_BBS_UploadPhotoUrl&FileName

             Stream.LoadFromFile Server.MapPath(TrueFileName)

            While Not Stream.EOS
                Response.BinaryWrite Stream.Read(1024 * 64)
            Wend
            Stream.Close
            Set Stream = Nothing
            Response.Flush
            Response.End
            %>
            //////////////////////

            第二步:打开Announce\uploadfile.asp文件,用记事本功能搜索:
            3.14版本:
            UploadPhotoUrl = UploadPhotoUrl & year(DEF_Now) & "/"
            3.14以前版本:
            UploadPhotoUrl = UploadPhotoUrl & year(date) & "/"
            替换为:
            3.14版本:
            UploadPhotoUrl = "../down.asp?filename=" & year(DEF_Now) & "/"
            3.14以前版本:
            UploadPhotoUrl = "../down.asp?filename=" & year(date) & "/"

            第三步:修改images/upload文件夹名为任何长窜的英文名,例如:修改为:
            images/jfhaufheouhefdsgsg

            第四步:进入最高管理后台,在上传路径里面将上传文件夹修改为以上的文件夹同名。

             
            如出现:
            删除上传的图,删除不到的!!
            Server.MapPath() 错误 'ASP 0173 : 80004005' 

            无效 Path 字符 
            解决办法:
            恢复图片的真实上传路径。执行一次setup.asp,并重新生成UBB。
文章录入:admin | 浏览次数:
相关评论(以下网友评论只代表其个人观点,不代表花香盈路的观点或立场)
Open LoginBar
关闭此窗口