<?php
require_once(dirname(__FILE__)."/../include/common.inc.php");
if(isset($aid)) $arcID = $aid;

$cid = empty($cid)? 1 : intval(preg_replace("/[^-\d]+[^\d]/",'', $cid));
$arcID = $aid = empty($arcID)? 0 : intval(preg_replace("/[^\d]/",'', $arcID));

$maintable = '#@__archives';$idtype='id';
if($aid==0) exit();

//获得频道模型ID
if($cid < 0)
{
    $row = $dsql->GetOne("SELECT addtable FROM `#@__channeltype` WHERE id='$cid' AND issystem='-1';");
    $maintable = empty($row['addtable'])? '' : $row['addtable'];
    $idtype='aid';
}
$mid = (isset($mid) && is_numeric($mid)) ? $mid : 0;

//UpdateStat();
if(!empty($maintable))
{
    $dsql->ExecuteNoneQuery(" UPDATE `{$maintable}` SET downhits=downhits+1 WHERE {$idtype}='$aid' ");
    $dsql->ExecuteNoneQuery(" Update `{$maintable}` set lasttime=".time()." where {$idtype}='$aid' ");
}
if(!empty($mid))
{
    $dsql->ExecuteNoneQuery(" UPDATE `#@__member_tj` SET pagecount=pagecount+1 WHERE mid='$mid' ");
}
if(isset($aid)) $arcID = $aid;
{
    $row = $dsql->GetOne(" SELECT click FROM `{$maintable}` WHERE {$idtype}='$aid' ");
}
if(isset($arcID))
{
	$aid = $arcID;
}
$arcID = $aid = (isset($aid) && is_numeric($aid)) ? $aid : 0;
if($aid==0)
{
	die(" Request Error! ");
}

require_once(DEDEINC.'/memberlogin.class.php');
$cfg_ml = new MemberLogin();
//判断登录
    if(($cfg_ml->M_ID<=0))
{
				exit("<script language=javascript>alert('出错了，请登陆后再下载！');location.href = '/member/login.php';</script>");
}
else{
$row = $dsql->GetOne("select mp3_url from `dede_addondj` where aid='$aid'");
$musicurl= "".$dting."".$row['mp3_url']."";
header("location: $musicurl");
}
?>