下载盗链的问题,仁者见仁,智者见智;这里只纯粹的讨论技术。
如果是页面防盗链的话,通常的方法都是用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("<script>alert('请从正确的页面登入!')</script>")
Response.End
else
......
End If
还有就是可以结合Session来防止页面盗链和文件盗链。
另外,可以通过javascript来进行简单的防止文件地址盗链。下面我详细说一下我的心德。
首先,比如我们有一音乐视听页面。源码如下:
Music.htm
-----------------
<html>
<head>
<title>Music</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<script language="JavaScript">
function Play(URL){
Yxplay_Win=window.open( 'play.htm?url='+URL,'bluedestiny', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=470,height=290,top=210,left=158');
}
</script>
<body>
<p> <a href="javascript:Play('XPGpycsXPGpycsXPGLSNLSNSXNXPGJFUESRYVIESRSXNJFUXQDKWD&Music1')">Music1</a></p>
<p> <a href="javascript:Play('XPGpycsXPGpycsXPGLSNLSNSXNXPGJFUESRYVIESRSXNJFUXQDKWD&Music1')">Music2</a></p>
<p> <a href="javascript:Play('XPGpycsXPGpycsXPGLSNLSNSXNXPGJFUESRYVIESRSXNJFUXQDKWD&Music1')">Music3</a> </p>
</body>
</html>
怎么会有一长串的字符?请注意这一长串参数的格式,等会儿有用的。
---------------------------------------------------------------------
**********************************************
Play.htm
------------
<html>
<head>
<title>PlayMusic</title>
<script language=jscript src=Play_url.js></script>
</head>
<body>
<TABLE cellSpacing=0 cellPadding=0 width=468 align=center border=0>
<!--DWLayoutTable-->
<TBODY>
<TR>
<TD width="468" height=60 align=middle valign="top"><font size="2">您现在收听的是:</font><font color="#FF0000" size=2>
<script language="javascript">document.write(" + wor + ");</script>
</font></TD>
</TR>
</TBODY>
</TABLE>
<TABLE height=60 cellSpacing=0 cellPadding=0 width=468 align=center border=0>
<TBODY>
<TR>
<TD class=box bgColor=#eeeeee height=60 align="center">
<div align="center">
<script language="javascript">
<!--
document.write ("<OBJECT id=Player2 name=Player classid=CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95 border=\"0\" width=100% height=68 type=application/x-oleobject standby=\"Loading Windows Media Player components...\">\n")
document.write ("<param name=\"AudioStream\" value=\"-1\">\n")
document.write ("<param name=\"AutoSize\" value=\"0\">\n")
document.write ("<param name=\"AutoStart\" value=\"-1\">\n")
document.write ("<param name=\"AnimationAtStart\" value=\"-1\">\n")
document.write ("<param name=\"AllowScan\" value=\"-1\">\n")
document.write ("<param name=\"AllowChangeDisplaySize\" value=\"-1\">\n")
document.write ("<param name=\"AutoRewind\" value=\"0\">\n")
document.write ("<param name=\"Balance\" value=\"10\">\n")
document.write ("<param name=\"BaseURL\" value>\n")
document.write ("<param name=\"BufferingTime\" value=\"5\">\n")
document.write ("<param name=\"CaptioningID\" value>\n")
document.write ("<param name=\"ClickToPlay\" value=\"-1\">\n")
document.write ("<param name=\"CursorType\" value=\"0\">\n")
document.write ("<param name=\"CurrentPosition\" value=\"-1\">\n")
document.write ("<param name=\"CurrentMarker\" value=\"0\">\n")
document.write ("<param name=\"DefaultFrame\" value>\n")
document.write ("<param name=\"DisplayBackColor\" value=\"0\">\n")
document.write ("<param name=\"DisplayForeColor\" value=\"16777215\">\n")
document.write ("<param name=\"DisplayMode\" value=\"0\">\n")
document.write ("<param name=\"DisplaySize\" value=\"4\">\n")
document.write ("<param name=\"Enabled\" value=\"-1\">\n")
document.write ("<param name=\"EnableContextMenu\" value=\"0\">\n")
document.write ("<param name=\"EnablePositionControls\" value=\"-1\">\n")
document.write ("<param name=\"EnableFullScreenControls\" value=\"0\">\n")
document.write ("<param name=\"EnableTracker\" value=\"-1\">\n")
document.write ("<param name=\"Filename\" value='" + str + "'>\n")
document.write ("<param name=\"InvokeURLs\" value=\"-1\">\n")
document.write ("<param name=\"Language\" value=\"-1\">\n")
document.write ("<param name=\"Mute\" value=\"0\">\n")
document.write ("<param name=\"PlayCount\" value=\"0\">\n")
document.write ("<param name=\"PreviewMode\" value=\"0\">\n")
document.write ("<param name=\"Rate\" value=\"1\">\n")
document.write ("<param name=\"SAMILang\" value>\n")
document.write ("<param name=\"SAMIStyle\" value>\n")
document.write ("<param name=\"SAMIFileName\" value>\n")
document.write ("<param name=\"SelectionStart\" value=\"0\">\n")
document.write ("<param name=\"SelectionEnd\" value=\"0\">\n")
document.write ("<param name=\"SendOpenStateChangeEvents\" value=\"-1\">\n")
document.write ("<param name=\"SendWarningEvents\" value=\"-1\">\n")
document.write ("<param name=\"SendErrorEvents\" value=\"-1\">\n")
document.write ("<param name=\"SendKeyboardEvents\" value=\"0\">\n")
document.write ("<param name=\"SendMouseClickEvents\" value=\"0\">\n")
document.write ("<param name=\"SendMouseMoveEvents\" value=\"0\">\n")
document.write ("<param name=\"SendPlayStateChangeEvents\" value=\"-1\">\n")
document.write ("<param name=\"ShowCaptioning\" value=\"0\">\n")
document.write ("<param name=\"ShowControls\" value=\"-1\">\n")
document.write ("<param name=\"ShowAudioControls\" value=\"-1\">\n")
document.write ("<param name=\"ShowDisplay\" value=\"0\">\n")
document.write ("<param name=\"ShowGotoBar\" value=\"0\">\n")
document.write ("<param name=\"ShowPositionControls\" value=\"-1\">\n")
document.write ("<param name=\"ShowStatusBar\" value=\"-1\">\n")
document.write ("<param name=\"ShowTracker\" value=\"-1\">\n")
document.write ("<param name=\"TransparentAtStart\" value=\"0\">\n")
document.write ("<param name=\"VideoBorderWidth\" value=\"0\">\n")
document.write ("<param name=\"VideoBorderColor\" value=\"0\">\n")
document.write ("<param name=\"VideoBorder3D\" value=\"0\">\n")
document.write ("<param name=\"Volume\" value=\"0\">\n")
document.write ("<param name=\"WindowlessVideo\" value=\"0\">\n")
document.write ("<embed type=\"application/x-mplayer2\" pluginspage=\"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 ("</OBJECT>\n")
//-->
</script>
</div>
</TD>
</TR>
</TBODY>
</TABLE>
<div align="center">
</body>
</html>
上面有一段引入了js的代码Play_url.js,这里就是关键了。接下来我们就来看看这段代码。
-------------------------------------------------------------------------------------------
************************************
Play_url.js
----------------------