关于防止文件下载盗链之用js来防止文件地址盗链

  下载盗链的问题,仁者见仁,智者见智;这里只纯粹的讨论技术。
  如果是页面防盗链的话,通常的方法都是用ServerVariables(“Server_Name“)结合ServerVariables(“Http_Referer”)来防止。如下:
DIM servUrl, fromUrl
servUrl = Request.ServerVariables("SERVER_NAME")
fromUrl = Request.ServerVariables("HTTP_REFERER")
If (mid(fromUrl,8,len(servUrl))) <> servUrl then
  Response.Write("")
  Response.End
else
......
End If
  还有就是可以结合Session来防止页面盗链和文件盗链。
  再有就是在服务器端来设置。
  以上方法,我会在以后的文章写出来,下面让我们来看看用javascript(纯静态文件)如何来实现防止文件盗链呢?如下源码只起一个抛砖引玉的作用,希望大家多提意见。
---------------------------------------------------------------------
**********************************************

  首先,比如我们有一音乐视听页面。源码如下:
  先建一文件夹为:MusicMP3,在此文件夹下面放一首MP3,MP3重命名为921239.mp3

---------------------------------------------------------------------
**********************************************
Music.htm
-----------------


Music




Music1




怎么会有一长串的字符?请注意这一长串参数的格式,等会儿有用的。

---------------------------------------------------------------------------------
**************************************************

Music.htm
-----------------


PlayMusic




 
 
   
     
   
 
您现在收听的是:
       
       


 
 
   



 







上面有一段引入了两段js的代码Play_url.js,MP.js这里就是关键了。接下来我们就来看看这段代码。
-------------------------------------------------------------------------------------------
****************************************************************************
MP.jps
---------------------------------
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("\n")
document.write ("http://www.microsoft.com/windows/mediaplayer/download/default.asp\" Name=\"Player\" width=\"300\" height=\"66\" border=\"0\" SHOWSTATUSBAR=\"-1\" SHOWCONTROLS=\"0\" SHOWGOTOBAR=\"0\" SHOWDISPLAY=\"-1\" INVOKEURLS=\"-1\" AUTOSTART=\"1\" CLICKTOPLAY=\"0\" DisplayForeColor=\"12945678\">\n")
document.write ("
\n")

----------------------------------------------
************************************
Play_url.js
----------------------

转载于:https://www.cnblogs.com/kangtr/archive/2005/07/24/199115.html

你可能感兴趣的:(关于防止文件下载盗链之用js来防止文件地址盗链)