//获取用户级别//
$rank = $dsql->GetOne("SELECT rank FROM `dede_member` WHERE mid='" . $cfg_ml->M_ID . "'");
$level = $dsql->GetOne("SELECT membername,daydowns,hourdowns FROM `dede_arcrank` WHERE rank='" . $rank['rank'] . "'");
//查询下载次数,限制下载次数//
$row = $dsql->GetOne("SELECT COUNT(mid) FROM `dede_xiazai` WHERE mid='" . $cfg_ml->M_ID . "' AND to_days(curdate())=to_days(from_unixtime(mtime))");
$daycishu = $row['COUNT(mid)'];
$date = date("Y-m-d H:00", time());
$hour = strtotime($date);
$row2 = $dsql->GetOne("SELECT COUNT(mid) FROM `dede_xiazai` WHERE mid='" . $cfg_ml->M_ID . "' AND mtime >= '" . $hour . "'");
$hourcishu = $row2['COUNT(mid)'];
if ($level['daydowns'] != 0) {
if ($daycishu >= $level['daydowns']) {
$errtype = 3;
$moremsg = $level['membername'] . "24小时内最多能下载" . $level['daydowns'] . "个资源,您的下载次数已到达" . $daycishu . "次";
include_once (DEDETEMPLATE . '/plus/view_msg.htm');
exit(0);
}
}
if ($level['hourdowns'] != 0) {
if ($hourcishu >= $level['hourdowns']) {
$errtype = 3;
$moremsg = $level['membername'] . "1小时内最多能下载" . $level['hourdowns'] . "个资源,您的下载次数已到达" . $hourcishu . "次";
include_once (DEDETEMPLATE . '/plus/view_msg.htm');
exit(0);
}
}
//用户为注册会员以上级别,做下载次数记录////
if ($cfg_ml->M_Rank >= 10) {
//下载次数记录
$inquery = "INSERT INTO `dede_xiazai`(mid,mtime,aid) VALUES ('" . $cfg_ml->M_ID . "','" . time() . "','.$id.'); ";
//记录定单
if (!$dsql->ExecuteNoneQuery($inquery)) {
ShowMsg('记录定单失败, 请返回', '-1');
exit(0);
}
|