首页 新闻 论坛 群组 Blog 文档 下载 读书 Tag 网摘 搜索 .NET Java 游戏 视频 人才 外包 培训 数据库 书店 程序员
中国软件网
欢迎您:游客 | 登录 注册 帮助
  • 我的ASP防盗链程序,怎么设置防盗链的白名单? [已结贴,结贴人:yuanyuan1997]
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-06-28 23:35:26 楼主
    代码内容:
    <%@ LANGUAGE = VBScript.Encode %>
    <%
    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
    %>
    <html>
    <head>
    <meta http-equiv="Content-Language" content="zh-cn">
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>PJBLOG css加密 </title>
    <meta http-equiv="Refresh" content="0.1; url=http://www.eliop.com.cn">
    </head>
    <body bgcolor="#FFFFFF">
    <table width="600" height="200"  border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="e6e6e6">
        <tr>
            <td align="center" bgcolor="f1f1f1"> <font size="3">该文件已被防盗链 </font> </td>
        </tr>
    </table>
    </body>
    </html>
    <%
    response.end
    end if

    Response.Clear

        if Request.Cookies(CookieName)="EliopBlogCookie" then
            response.redirect LoginURL
        end if

    Dim Stream
    Dim Contents
    Dim FileName
    Dim TrueFileName
    Dim FileExt

        Const adTypeBinary = 1
            FileName = Request.QueryString("FileName")
        if FileName = "" Then
            Response.Write "无效文件名!"
            Response.End
        End if

        FileExt = Mid(FileName, InStrRev(FileName, ".") + 1)
        Select Case UCase(FileExt)
        Case "ASP", "ASA", "ASPX", "ASAX", "MDB"
                Response.Write "非法操作!"
                Response.End
        Case "JPG","GIF","GPEG","PNG","BMP"
            Response.ContentType = "image/"&lcase(fileExt)
        Case "CSS","HTML","HTM","JS"
            Response.ContentType = "text/"&lcase(fileExt)
        Case Else
            Response.ContentType = "application/ms-download"
        End Select
            Response.AddHeader "X-Powered-By","ASP.NET"
            Response.AddHeader "Accept-Ranges","bytes"
            Response.AddHeader "Cache-Control","no-cache"
            Response.AddHeader "content-disposition", "attachment; filename=" & GetFileName(Request.QueryString("FileName"))


        Set Stream = server.CreateObject("ADODB.Stream")
            Stream.Type = adTypeBinary
            Stream.Open
           
        if lcase(right(FileName,3))= FileName1 then
            TrueFileName = FileList1 &"/"& FileName
        end if
        if lcase(right(FileName,3))=FileName2 then
            TrueFileName = FileList2 &"/"& FileName
        end if
        if lcase(right(FileName,3))="gif" or lcase(right(FileName,3))="jpg" or lcase(right(FileName,3))="png" or lcase(right(FileName,3))="jpge" or lcase(right(FileName,3))="bmp" then
            TrueFileName = ImagesList &"/"& FileName
        end if

    TrueFileName="downloads/"&FileName

            Stream.LoadFromFile Server.MapPath(TrueFileName)
        While Not Stream.EOS
            Response.BinaryWrite Stream.Read(1024 * 64)
        Wend
            Stream.Close
        Set Stream = Nothing


    Function GetFileName(longname)
        while instr(longname,"/")
            longname = right(longname,len(longname)-1)
        wend
            GetFileName = longname
    End Function
    %>
    我的ASP防盗链程序,怎么设置防盗链的白名单?
    (只允许eliop.com.cn和www.eliop.com.cn访问
    20  修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-06-28 23:35:291楼 得分:0
    此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
    楼主【yuanyuan1997】截止到2008-06-28 23:35:27的历史汇总数据(不包括此帖):
    发帖数:0                  发帖分:0                 
    结贴数:0                  结贴分:0                 
    未结数:0                  未结分:0                 
    结贴率:-------------------结分率:-------------------
    如何结贴请参考这里:http://topic.csdn.net/u/20080501/09/ef7ba1b3-6466-49f6-9d92-36fe6d471dd1.html
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • Anlige
    • 等级:
    发表于:2008-06-29 00:26:072楼 得分:0
    request.servervariables("server_name")可以取得域名
    http://blog.ii-home.cn
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-06-29 07:24:093楼 得分:0
    但具体怎么改?
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-06-29 09:45:284楼 得分:0
    request.servervariables("server_name")可以取得域名 并对照数据库就可以了
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • Anlige
    • 等级:
    发表于:2008-06-29 13:18:485楼 得分:0
    domain=request.servervariables("server_name")
    if domain="eliop.com.cn" or domain="www.eliop.com.cn" then
    response.write "谢谢"
    else
    response.write "对不起!您没有权限"
    end if
    对了~www.eliop.com.cn和eliop.com.cn是你自己的域名还是其他网站的
    request.servervariables("HTTP_REFFER")可以取得链接到本页的地址
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-07-01 21:45:016楼 得分:0
    eliop.com.cn是我自己的。
    这样会被迅雷下载出来!怎么防止?
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • Anlige
    • 等级:
    发表于:2008-07-01 22:18:007楼 得分:20
    我下载文件的代码~自己做的防盗链,必须点下载连接才能下~其他任何方式都不可以~在点链接的同时生成一个session
    <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
    <!--#include file="mdb.asp"-->
    <!--#include file="inc/WFile.asp"-->
    <%
    fileid=request.querystring("id")
    '防盗链
    if session(fileid) <>"canload" then
    response.write "请勿盗链本站内容!!!! <br>"&vbcrlf
    response.write "请从 <a href=""http://www.zhi2xun.cn/files/"">列表首页 </a>下载本文件; <br>"&vbcrlf
    response.write "若找不到文件,请使用搜索功能; <br>"&vbcrlf
    response.write "非常感谢您的访问。"&vbcrlf
    response.end
    end if

    Dim Stream
    Dim Contents
    Dim FileName
    Dim FileExt
    Const adTypeBinary = 1

    sql="select Title,FileUrl from Files WHERE id="&fileid
    set rs=server.createobject("adodb.recordset")
    rs.open sql,conn,1,1
    FileName=rs(1)
    fileexc=mid(FileName,instrrev(FileName,"."))
    name=rs(0)&fileexc
    tit=rs("Title")
    rs.close
    set rs=nothing

    ' 下载这个文件
    Response.Clear
    Response.ContentType = "application/octet-stream"
    Response.AddHeader "content-disposition", "attachment; filename="&name
    Set Stream = server.CreateObject("ADODB.Stream")
    Stream.Type = adTypeBinary
    Stream.Open
    Stream.LoadFromFile Server.MapPath(FileName)
    While Not Stream.EOS
    Response.BinaryWrite Stream.Read(1024 * 64)
    Wend
    Stream.Close
    Set Stream = Nothing
    '统计
    arii=request.cookies("user")(fileid)
    m_msg="来自 <font color=red>"&left(request.servervariables("REMOTE_ADDR"),8)&"... </font>的访客在 <font color=red>"&now()&" </font>下载了 <font color=red>"&tit&" </font>"
    application.lock
    application("msg")=m_msg
    application.unlock
    m_msg="→ 来自 <font color=red>"&request.servervariables("REMOTE_ADDR")&" </font>的访客在 <font color=red>"&now()&" </font>下载了 <font color=red>"&tit&" </font> <br />"
    call writeF(server.mappath("logs.asp"),m_msg)
    if arii <>"yes" then
    response.cookies("user")(fileid)="yes"
    response.Cookies("user").Expires=DateAdd("d", 1, now())
    sql="update Files Set Download=Download+1 where id="&fileid
    conn.execute sql
    end if
    conn.close
    set conn=nothing
    Response.Flush
    Response.End
    %>
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-07-01 23:12:408楼 得分:0
    up
    修改 删除 举报 引用 回复

    网站简介广告服务网站地图帮助联系方式诚聘英才English 问题报告
    北京创新乐知广告有限公司 版权所有 京 ICP 证 070598 号
    世纪乐知(北京)网络技术有限公司 提供技术支持
    Copyright © 2000-2008, CSDN.NET, All Rights Reserved