帝国cms中会员每日下载数限制的实现1.后台会员组设置,每日下载数 <input name="daydown" type="text" id="daydown" value="0" size="38">2.缓存 在文件 e/data/dbcache/MemberLevel.php中有缓存,假定会员组id为$groupid则该会员组的每日下载次数限制调用为 $level_r[$groupid]['daydown']; 当然,调用的前提是引用了这个缓存文件,例如: include(ECMS_PATH."e/data/dbcache/MemberLevel.php");3.检查下载次数在文件 /e/class/user.php中,有个函数,用来检查下载次数//检查下载数function DoCheckMDownNum($userid,$groupid,$ecms=0){ global $empire,$dbtbpre,$level_r; $ur=$empire->fetch1("select userid,todaydate,todaydown from {$dbtbpre}enewsmemberadd where userid='$userid' limit 1"); $thetoday=date("Y-m-d"); if($ur['userid']) { if($thetoday!=$ur['todaydate']) { $query="update {$dbtbpre}enewsmemberadd set todaydate='$thetoday',todaydown=1 where userid='$userid'"; } else { if($ur['todaydown']>=$level_r[$groupid]['daydown']) { if($ecms==1) { exit(); } elseif($ecms==2) { return 'error'; } else { printerror("CrossDaydown","history.go(-1)",1); } } $query="update {$dbtbpre}enewsmemberadd set todaydown=todaydown+1 where userid='$userid'"; } } else { $query="replace into {$dbtbpre}enewsmemberadd(userid,todaydate,todaydown) values('$userid','$thetoday',1);"; } return $query;}4. 检查的方法if($level_r[$u[$user_group]][daydown]) { $setuserday=DoCheckMDownNum($userid,$u[$user_group]); } 随后, 更新下载次数 //更新用户下载次数 if($setuserday) { $usql=$empire->query($setuserday); } 5.体会在二开的情况下,我们用DoCheckMDownNum($userid,$u[$user_group],2)更容易控制流程。随后 if($setuserday=='error') ,判断是否超数量下载。