|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
x
进入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) {
- $rand = rand(1, 100);
- $rand_replycredit = $rand <= $replycredit_rule['random'] ? true : false ;
- } else {
- $rand_replycredit = true;
- }
复制代码
如果该帖回帖奖励的中奖率$replycredit_rule['random']大于0:
$rand为在1-100中间生成的一个随机数,如果$rand小于或等于$replycredit_rule['random'],则设置$rand_replycredit为true,否则为false。
如果该帖回帖奖励的中奖率$replycredit_rule['random']不大于0:
设置$rand_replycredit为true。- if($rand_replycredit) {
- if(!$posttable) {
- $posttable = getposttablebytid($_G['tid']);
- }
- updatemembercount($_G['uid'], array($replycredit_rule['extcreditstype'] => $replycredit_rule['extcredits']), 1, 'RCA', $_G[tid]);
- DB::update($posttable, array('replycredit' => $replycredit_rule['extcredits']), array('pid' => $pid));
- DB::update("forum_thread", array('replycredit' => $thread['replycredit'] - $replycredit_rule['extcredits']), array('tid' => $_G[tid]));
- }
复制代码
如果存在$rand_replycredit:- if(!$posttable) {
- $posttable = getposttablebytid($_G['tid']);
- }
复制代码
如果不存在回帖表$posttable,则通过tid获取$posttable。- updatemembercount($_G['uid'], array($replycredit_rule['extcreditstype'] => $replycredit_rule['extcredits']), 1, 'RCA', $_G[tid]);
复制代码
根 据回帖奖励的规则,更新当前登录用户的积分:在原有积分基础 上+$replycredit_rule['extcredits']。$replycredit_rule['extcreditstype']为积分 类型,$replycredit_rule['extcredits']为奖励积分数。- DB::update($posttable, array('replycredit' => $replycredit_rule['extcredits']), array('pid' => $pid));
复制代码
更新回帖表$posttable中当前用户回复的积分奖励。- DB::update("forum_thread", array('replycredit' => $thread['replycredit'] - $replycredit_rule['extcredits']), array('tid' => $_G[tid]));
复制代码
$thread['replycredit'] - $replycredit_rule['extcredits']为计算回帖奖励的剩余总积分。
更新主题表forum_thread中当前帖子的回帖奖励总积分replycredit。
|
|