关于下载系统防盗链的问题!!!

在asp的下载系统上我试过多种办法,没有一种有效。今日发现一种php的防盗链方法十分有效,根本不能得到真实下载地址,各位不妨一试:

http://www.df365.org/modules/mydownloads/

其代码如下:

1   
2$dir=$HTTP_GET_VARS["dir"];   
3$file=$HTTP_GET_VARS["file"];   
4$url=parse_url($HTTP_REFERER);   
5if($url[host]!=$HTTP_HOST){echo "要下载本软件请到

<a href="http://www.df365.org">东方小屋</a>

 1";exit;}   
 2if(empty($dir))$dir="/";   
 3if(empty($file)){echo "未指定要下载的文件!";exit;}   
 4$rootdir="文件存放的根目录";   
 5$realurl=$rootdir.$dir;   
 6chdir($realurl);   
 7if(!file_exists($file)){echo "对不起,此链接已经失效,请在下载页面上向我们报告,谢谢!";exit;}   
 8$filename=$file;   
 9header("Cache-control: private"); // fix for IE   
10header("Content-Type: application/octet-stream");   
11header("Content-Length: ".filesize($filename));   
12header("Content-Disposition: attachment; filename=$filename");   
13$fp = fopen($filename, 'r');   
14fpassthru($fp); // ** CORRECT **   
15fclose($fp);   

使用时向这个页传递两个参数
$dir=文件所在子母录
$file=文件名

我想要在asp中实现,问题是这一行:
$fp = fopen($filename, 'r');
在PHP中fopen函数可以打开文件或url,而asp的fso好象只可以打开文件,请问各位大虾有无解决办法?或者有其他类似的解决方案?

---------------------------------------------------------------

另外,下载的文件不要放在虚拟目录下

http://www.csdn.net/Develop/read_article.asp?id=13004

Published At
Categories with Web编程
Tagged with
comments powered by Disqus