<?php

$id=$_GET['ID'];
$sID=intval($_GET["sID"]);
if($id=='' or !is_int(intval($id))){
	echo"非法操作！指定的参数不正确。";
	exit;
}
$conn = new com("ADODB.Connection");
$connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" . realpath("data/ishiondms.asa");
$conn->Open($connstr);
$rs = new com("ADODB.RecordSet"); 
$sql="select * from ishion_Down_Address where ID=" . $id;
$rs->Open($sql,$conn,1,3);
if($rs->eof or $rs->bof){
	echo"Sorry，下载地址无效，可能已经被删除！";
	exit;
}
$ResID1 = $rs->Fields(1);
$ResID = $ResID1->value;
$SiteID1 = $rs->Fields(5);
$SiteID =$SiteID1->value; 
$url1 = $rs->Fields(3);
$url =$url1->value; 
$rs->close(); 

/*$rss = new com("ADODB.RecordSet"); 
$sqls="select * from ishion_Down_Resource where ID=" . $ResID;
$rss->Open($sqls,$conn,1,1);
$FileLength=$rss["ResSize"];
$rss->close(); */

$u=explode("$",$url);
$u1=$u[$sID];
$u2=explode(",",$u1);
$url=$u2[0];
if($_GET['url1']<>"" and is_int(intval($_GET['url1']))) $url=$_GET['url1'];
$filename1=explode("/",$url);
$filename=$filename1[4];

//echo $filename;
//exit;
$fp =fopen($url,"rb");
if ( !$fp )
{
echo "无法从本站点下载 请选择其它站点下载";
}
else
{
Header( "Content-type: application/octet-stream" );
Header( "Content-Disposition: attachment; filename=" . $filename );
while ( !feof( $fp ) )
{
echo fread( $fp, filesize($fp) );
}
fclose( $fp );
}
?>

