01//获取用户级别//02 $rank = $dsql->GetOne("SELECT rank FROM `dede_member` WHERE mid='" . $cfg_ml->M_ID . "'");03 $level = $dsql->GetOne("SELECT membername,daydowns,hourdowns FROM `dede_arcrank` WHERE rank='" . $rank['rank'] . "'");04 //查询下载次数,限制下载次数//05 $row = $dsql->GetOne("SELECT COUNT(mid) FROM `dede_xiazai` WHERE mid='" . $cfg_ml->M_ID . "' AND to_days(curdate())=to_days(from_unixtime(mtime))");06 $daycishu = $row['COUNT(mid)'];07 $date = date("Y-m-d H:00", time());08 $hour = strtotime($date);09 $row2 = $dsql->GetOne("SELECT COUNT(mid) FROM `dede_xiazai` WHERE mid='" . $cfg_ml->M_ID . "' AND mtime >= '" . $hour . "'");10 $hourcishu = $row2['COUNT(mid)'];11 if ($level['daydowns'] != 0) {12 if ($daycishu >= $level['daydowns']) {13 $errtype = 3;14 $moremsg = $level['membername'] . "24小时内最多能下载" . $level['daydowns'] . "个资源,您的下载次数已到达" . $daycishu . "次";15 include_once (DEDETEMPLATE . '/plus/view_msg.htm');16 exit(0);17 }18 }19 if ($level['hourdowns'] != 0) {20 if ($hourcishu >= $level['hourdowns']) {21 $errtype = 3;22 $moremsg = $level['membername'] . "1小时内最多能下载" . $level['hourdowns'] . "个资源,您的下载次数已到达" . $hourcishu . "次";23 include_once (DEDETEMPLATE . '/plus/view_msg.htm');24 exit(0);25 }26 }27//用户为注册会员以上级别,做下载次数记录////28if ($cfg_ml->M_Rank >= 10) {29//下载次数记录30$inquery = "INSERT INTO `dede_xiazai`(mid,mtime,aid) VALUES ('" . $cfg_ml->M_ID . "','" . time() . "','.$id.'); ";31//记录定单32if (!$dsql->ExecuteNoneQuery($inquery)) {33ShowMsg('记录定单失败, 请返回', '-1');34exit(0);35} |