1. 论坛系统升级为Xenforo,欢迎大家测试!
    排除公告

郁闷了2天了.再不能解我真的要郁闷死了.!

本帖由 零度2005-09-11 发布。版面名称:新人报道

  1. 零度

    零度 New Member

    注册:
    2005-09-11
    帖子:
    3
    赞:
    0
    我的论坛用了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.write "非法链接!" '防止盗链
    response.end
    end if


    Function GetFileName(longname)'/folder1/folder2/file.asp=>file.asp
    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.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
    End Select
    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
    if lcase(right(FileName,2))="rm" then '设置rm类型文件目录
    TrueFileName = "/kang/"&FileName
    end if
    if lcase(right(FileName,3))="wmv" then '设置wmv类型文件目录
    TrueFileName = "/kangkang/"&FileName
    end if
    if lcase(right(FileName,3))="gif" or lcase(right(FileName,3))="jpg" or lcase(right(FileName,3))="png" then
    TrueFileName = "/kang/2005-9/"&FileName '设置图像文件目录
    end if
    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
    %>
    大家注意,现在我用这个防盗链在论坛里插入一张图片:
    www.51755.com/ceshi.asp?filename=1.jpg 这张图片可以正常显示在论坛里
    下面再插入个影音文件在线播放的:
    [rm]www.51755.com/ceshi.asp?filename=intro.rm[/rm]问题出现了.这个影音文件不能播放.播放器提示需要附加组件才能播放文件.然后就是找不到组件,不能播放此文件!但我用这个地址提供下载一切正常,我实在郁闷,为什么可以下载,而不能在线播放呢,问题出在那里,小弟拜跪求解!
    (注:以上网址并非有效路径,只是让大家明白我说的意思)
     
  2. 小叶

    小叶 New Member

    注册:
    2005-09-04
    帖子:
    17,941
    赞:
    33
    你看看这里已经被代码当作二进制的流下载了.
    所以不会播放了..
     
  3. 零度

    零度 New Member

    注册:
    2005-09-11
    帖子:
    3
    赞:
    0
    大哥.你告诉具体该怎么改呀..怎么弄才能实现在线播放!!!!谢谢
     
  4. simu

    simu New Member

    注册:
    2005-09-10
    帖子:
    816
    赞:
    3
    佩服ING
     
  5. 零度

    零度 New Member

    注册:
    2005-09-11
    帖子:
    3
    赞:
    0
    各位高手...那你们到是告诉我怎么实现我想要的功能呀.怎么可以在线播放呀..别光笑话我..小弟虚心求教就是了.........