1、首先在后台的数据库备份/还原地方做一个数据库备份,因为接下来要执行几个sql文件,做好数据备份以免出现未知错误。
2、建立dede_xiazai 这个数据库表,执行以下sql:
CREATE TABLE `dede_xiazai` ( `mid` int(11) NOT NULL, `aid` int(11) NOT NULL, `mtime` int(11) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; |
3、在原数据库表dede_arcrank内增加两个字段 daydowns hourdowns 分别为 每天限制次数 每日限制次数,在这里默认是10次,大家可以按照自己的需求更改这个次数:DEFAULT '10'
ALTER TABLE `dede_arcrank` ADD `daydowns` INT(6) NOT NULL DEFAULT '10' AFTER `purviews`, ADD `hourdowns` INT(6) NOT NULL DEFAULT '10' AFTER `daydowns`; |
4、找到plus文件夹下的download.php文件在191行插入:
//获取用户级别// $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); } |
本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!