进入source\include\post\post_newreply.php文件,在438行附近找到如下代码:
- if($thread['replycredit'] > 0 && $thread['authorid'] != $_G['uid'] && $_G['uid']) {
如果$thread['replycredit']大于0,同时帖子作者不是当前登录用户,则进入下面的处理流程。
$thread['replycredit']为当前帖子的回帖奖励总积分。
- $replycredit_rule = DB::fetch_first("SELECT * FROM ".DB::table('forum_replycredit')." WHERE tid = '$_G[tid]' LIMIT 1");
- $have_replycredit = DB::result_first("SELECT COUNT(*) FROM ".DB::table('common_credit_log')." WHERE relatedid = '{$_G[tid]}'
AND uid = '{$_G[uid]}' AND operation = 'RCA' LIMIT {$replycredit_rule['times']} ");
$replycredit_rule为从forum_replycredit表中查询该帖的回帖奖励设置数组,具体格式为
- array(
- 'tid' => '帖子tid',
- 'extcredits' => '每次回帖的奖励积分',
- 'times' => '奖励次数',
- 'membertimes' => '每个人最多奖励的次数',
- 'random' => '中奖率',
- 'extcreditstype' => '奖励的积分类型',
- )
$have_replycredit为从common_credit_log表中查询该帖中当前登录用户的已奖励次数。
- if($replycredit_rule['membertimes'] - $have_replycredit > 0 && $thread['replycredit'] - $replycredit_rule['extcredits'] >= 0) {
如果该帖的每个人最多奖励次数$replycredit_rule['membertimes']大于该帖中当前登录用户的已奖励次数$have_replycredit,同时该帖的回帖奖励总积分$thread['replycredit']大于或等于该帖每次回帖的奖励积分$replycredit_rule['extcredits']。
- $replycredit_rule['extcreditstype'] = $replycredit_rule['extcreditstype'] ? $replycredit_rule['extcreditstype'] :
$_G['setting']['creditstransextra'][10];
$replycredit_rule['extcreditstype']为该帖奖励积分的积分类型,如果存在$replycredit_rule['extcreditstype']的话就为$replycredit_rule['extcreditstype'],否则为$_G['setting']['creditstransextra'][10]。
$_G['setting']['creditstransextra'][10]为后台->全局->积分设置下设置的回帖奖励使用的积分。
- if($replycredit_rule['random'] > 0) {
- $randrand = rand(1, 100);
- $rand_replycredit = $rand <= $replycredit_rule['random'] ? true : false ;
- } else {
- $rand_replycredit = true;
- }