include "./admin/include/global.php";
include "./admin/include/mysql_class.php";
$db=new dbstuff();
$db->connect($dbhost,$dbuser,$dbpasswd,$dbname);
if(!empty($id))
{
$res1=$db->query("select filename from info_files where id='$id' limit 1 ");
while($rs1=$db->fetch_array($res1))
{
$filename=trim($rs1["filename"]);
$filerealname=eregi_replace("./files/download/","",$filename);
$filename=eregi_replace("./files/","./admin/infofiles/files/",$filename);
//echo $filename;exit;
if(!file_exists($filename))
{
echo "";
exit;
}
header ( "Content-Type: application/octet-stream");
header("Accept-Ranges: bytes");
header ( "Content-Length: ".filesize($filename));
header( "Content-Disposition: attachment; filename=$filerealname");
readfile($filename);
}
}
else
{
// if(!empty($pid) && !empty($sys_username))
// {
$res1=$db->query("select data3 from info_product where id='$pid' limit 1");
while($rs1=$db->fetch_array($res1))
{
$filename=trim($rs1["data3"]);
$filerealname=eregi_replace("./files/download/","",$filename);
$filename=eregi_replace("./files/","./admin/infofiles/files/",$filename);
//echo $filename;exit;
if(!file_exists($filename))
{
echo "";
exit;
}
header ( "Content-Type: application/octet-stream");
header("Accept-Ranges: bytes");
header ( "Content-Length: ".filesize($filename));
header( "Content-Disposition: attachment; filename=$filerealname");
readfile($filename);
}
// }
// else
// {
// echo "";
// exit;
// }
}
?>