<?
include "config.inc.php";
include "class/member.class.php";
include "include/movie.func.php";
			$domains=array(PLUS_URL);
			$member=new member();
			$user_info=$member->member_auth();
			//防盗链
			$check=1;
			$code=$_GET[code];
			$check_code="";
			$ctimes=explode(" ",microtime());
			$ctime=$ctimes[1];
			$check_code =$_COOKIE[check_code];
			//step_1
			if($code!=md5($check_code)){
				$check=0;
			}else{
			include "class/crypt.class.php";
			$hash_str = "88888";//这个需要和playmusic.php中的一致
			$crypt = new pcrypt(MODE_CBC, "BLOWFISH", $hash_str); 
			$str =$crypt->decrypt(base64_decode($check_code),$hash_str);
			$strs = explode("@@@",$str);
			$stime = $strs[0];
			$scode = $ctime - $stime;
			if($scode>2) $check=0;
			$fid = $strs[1];
			}
			//验证3
			//if(!stristr($refr,PLUS_URL)) $check=0;
			//end
			$fdb = $PlusDB->prefix(attachment);
			$adb = $PlusDB->prefix(articles);
			$sdb = $PlusDB->prefix(server);
			if($check=="0"){
						header("Content-type: text/plain");
						header("Content-disposition: attachment; filename=error.txt");
						echo "无权下载!你必须访问\n";
						foreach($domains as $dom) echo $dom."\n";
						echo "进行下载!";
						exit;
			}

			//扣点
			$aid=$row[aid];
			$atid=$row[atid];
			$point = $row[point];
			//扣点结束
			//if(!delThePoint($aid,$atid,$point)) exit;
			##update the hits
			$sql="update $adb set hits=hits+1 where id='$row[id]'";
			$PlusDB->queryF($sql);
			//trace( $url );
			if(!eregi("%|%2F|%20", $url)){
			$url = urlencode($url);
			$url=str_replace("%2F","/",$url);
			$url=str_replace("%3A",":",$url);
			}
			if(count(explode(",",$fid))>1) $fid.="0";
			
			$sql="select f.*,a.cid,a.title as atitle ,a.author as aatuhor from $fdb f left join $adb a on (a.id=f.aid) where f.id in ($fid)";
			$rt=$PlusDB->query($sql);
			$str="";
			while($row=$rt->fetchRow()){
				$server = $row[server];
				if($server!=0){
				$sql="select * from $sdb where id='$row[server]'";
				$srow =$PlusDB->GetRow($sql);
				$server_url=($srow[port]==80)?$srow[host]:$srow[host].":".$srow[port];
				$url  =  $server_url.$row[url];
				}else{
				$url = $row[url];
				}
				if(!eregi("%|%2F|%20", $url)){
				$url = urlencode($url);
				$url=str_replace("%2F","/",$url);
				$url=str_replace("%3A",":",$url);
				}
				$title = $row[title];
				$atitle = $row[atitle];
				$author = $row[aatuhor];
				$str.="
	<Entry>
<Title>$title</Title>
<author>$author</author>
<Copyright>仅供试听</Copyright>
<ref href=\"$url\"/>
</Entry>";
			}
						$stitle = "video/x-ms-asf";
						$filename = "player.asx";
						header("Content-type: $stitle");
						header("Content-disposition: attachment; filename=$filename");
						echo "<Asx Version = \"3.0\">";
						echo $str;
						echo "</Asx>";
exit;
?>