电影站提供电影bt下载,由于使用宝丽通播放器,上传电影的时候会同时上传一个电影的hash文件。利用这个hash文件,第一次请求时动态的生成对应的bt种子保存(指定路径)并提供下载。当用户点击下载bt种子的时候,首先到对应的目录下检测对应的bt种子文件是否存在,如果存在,则直接提供下载,否则先生成,再下载。
bt种子的下载直接在文件中使用header跳转的方式。php文件本身是gbk编码。
后来发现,在chrome和firefox和ie6中都能正常工作,但是到了ie8中会出现找打不文件的情况。这让我很郁闷,ie6都能行,结果ie8还有问题。
[php]
//指向torrent文件,提供下载
//$torrent_file_url = torrent/tyvod1/科幻片/雷神托尔.torrent
$redirect_url = http://vod.cqjtu.edu.cn/.$torrent_file_url;
header(http/1.1 303 see other);
header(location: .$redirect_url);
exit ();
经过对比测试,发现如果路径中有中文,ie8就没法下载。php文件本身是gbk编码,于是我们在跳转之前,先将gbk编码的字符串转换为utf8编码。
[php]
//指向torrent文件,提供下载
//$torrent_file_url = torrent/tyvod1/科幻片/雷神托尔.torrent
$redirect_url = http://vod.cqjtu.edu.cn/.$torrent_file_url;
header(http/1.1 303 see other);
header(location: .iconv(gbk,utf-8,$redirect_url));
exit ();
这下,在chrome和firefox以及ie8和ie9中都没问题了,但是在ie6中又不能下载了。中文乱码。查资料之后说是因为ie6对utf-8的支持不够完善。尼玛ie还真难伺候,无论是gbk编码还是utf-8编码,chrome和firefox都能正确解析,ie自家兄弟居然出这样的问题。
没找到好的办法,只得专门为ie6做一下…
[php]
//指向torrent文件,提供下载
//$torrent_file_url = torrent/tyvod1/科幻片/雷神托尔.torrent
$redirect_url = http://vod.cqjtu.edu.cn/.$torrent_file_url;
header(http/1.1 303 see other);
if(strpos($_server['http_user_agent'],'msie 6.0')===false){//非ie6
header(location: .iconv(gbk,utf-8,$redirect_url));
}else{//ie6
header(location: .$redirect_url);
}
exit ();
作者:jdluojing
http://www.bkjia.com/phpjc/478141.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/478141.htmltecharticle电影站提供电影bt下载,由于使用宝丽通播放器,上传电影的时候会同时上传一个电影的hash文件。利用这个hash文件,第一次请求时动态的生...