欢迎您访问我爱IT技术网,今天小编为你分享的编程技术是:【DISCUZ架构:积分系统代码分析二】,下面是详细的分享!
DISCUZ架构:积分系统代码分析二
这个文件处理发新帖的特定请求。
if(isset($poll)) {
$special=1;
} elseif(isset($trade)) {
$special=2;
} elseif(isset($reward)) {
$special=3;
} elseif(isset($activity)) {
$special=4;
} else {
$special=0;
}
这一部分的代码是用来判断帖子的类型的,1为投票,2为交易帖,3为悬赏,4为活动,0为普通帖。
$price=intval($price);
$price=$maxprice && !$special ? ($price <=$maxprice ? $price : $maxprice) : 0;
这里是帖子价格的赋值,超过了最大的价格的处理,特殊帖子的价格处理。
} elseif($special==3 && $allowpostreward) {
$rewardprice=intval($rewardprice);
if(!$rewardprice) {
showmessage('reward_credits_please');
} elseif($rewardprice > 32767) {
showmessage('reward_credits_overflow');
} elseif($rewardprice < $minrewardprice || ($maxrewardprice > 0 && $rewardprice > $maxrewardprice)) {
showmessage('reward_credits_between');
} elseif(($realprice=$rewardprice + ceil($rewardprice * $creditstax)) > $_DSESSION["extcredits$creditstrans"]) {
showmessage('reward_credits_shortage');
}
$price=$rewardprice;
$db->query("UPDATE {$tablepre}members SET extcredits$creditstrans=extcredits$creditstrans-$realprice WHERE uid='$discuz_uid'");
前面说过3表示悬赏帖子,那么当你发表成功了一个悬赏帖子后,就会相应在cdb_members表中减少相应的扩展积分,便是上面的代码的作用了。
elseif($special==3 && $allowpostreward) {
$db->query("INSERT INTO {$tablepre}rewardlog (tid, authorid, netamount, dateline) VALUES ('$tid', '$discuz_uid', $realprice, '$timestamp')");
}
后续判断如果为悬赏帖子的话就往cdb_rewardlog(悬赏记录表)里写入一条记录。
if($attachment) {
$searcharray=$pregarray=$replacearray=array();
foreach($attachments as $key=> $attach) {
$db->query("INSERT INTO {$tablepre}attachments (tid, pid, dateline, readperm, price, filename, description, filetype, filesize, attachment, downloads, isimage, uid, thumb, remote)
VALUES ('$tid', '$pid', '$timestamp', '$attach[perm]', '$attach[price]', '$attach[name]', '$attach[description]', '$attach[type]', '$attach[size]', '$attach[attachment]', '0', '$attach[isimage]', '$attach[uid]', '$attach[thumb]', '$attach[remote]')");
$searcharray[]='[local]'.$localid[$key].'[/local]';
$pregarray[]='/\[localimg=(\d{1,3}),(\d{1,3})\]'.$localid[$key].'\[\/localimg\]/is';
$replacearray[]='[attach]'.$db->insert_id().'[/attach]';
}
$message=str_replace($searcharray, $replacearray, preg_replace($pregarray, $replacearray, $message));
$db->query("UPDATE {$tablepre}posts SET message='$message' WHERE pid='$pid'");
updatecredits($discuz_uid, $postattachcredits, count($attachments));
}
如果帖子中带有附件的话,就把附件插入cdb_attachments表,然后注意到$message这一个变量在这里用到了替换,这里的作用是图文混排。接下来往cdb_posts写一条记录,再用include/global.func.php定义到一个函数updatecredits来更新积分。
给Discuz的一个小建议:可以判断是不是postattachcredits为0,为0就可以不执行updatecredits这个函数,虽然在函数定义的时候也有判断,不过在这里判断似乎更好。
if($modnewthreads) {
$db->query("UPDATE {$tablepre}forums SET todayposts=todayposts+1 WHERE fid='$fid'", 'UNBUFFERED');
$allowuseblog && $isblog && $blog ? showmessage('post_newthread_mod_blog_succeed', "blog.php?uid=$discuz_uid") :
showmessage('post_newthread_mod_succeed', "forumdisplay.php?fid=$fid");
} else {
if($digest) {
foreach($digestcredits as $id=> $addcredits) {
$postcredits[$id]=(isset($postcredits[$id]) ? $postcredits[$id] : 0) + $addcredits;
}
}
updatepostcredits('+', $discuz_uid, $postcredits);
$lastpost="$tid\t$subject\t$timestamp\t$author";
$db->query("UPDATE {$tablepre}forums SET lastpost='$lastpost', threads=threads+1, posts=posts+1, todayposts=todayposts+1 WHERE fid='$fid'", 'UNBUFFERED');
if($forum['type']=='sub') {
$db->query("UPDATE {$tablepre}forums SET lastpost='$lastpost' WHERE fid='$forum[fup]'", 'UNBUFFERED');
}
if($allowuseblog && $isblog && $blog) {
showmessage('post_newthread_blog_succeed', "blog.php?tid=$tid");
} else {
showmessage('post_newthread_succeed', "viewthread.php?tid=$tid&extra=$extra");
}
}
这里是最后一段代码,作用是这样的:
首先看看是不是在发新帖的时候就被加为文集
以上所分享的是关于DISCUZ架构:积分系统代码分析二,下面是编辑为你推荐的有价值的用户互动:
相关问题:Discuz x3.2积分策略设置和积分规则注意事项有哪些
答:积分就像流通的货币,合理的积分策略对论坛帖子量,用户间的互动以及防灌水有很大的协助作用,下面我在享客网和大家一起分享下Discuz x3.2积分策略的设置方法和一些注意事项。 Discuz x3.2积分设置涉及到的地方: 1、后台--全局--积分设置--基本... >>详细
相关问题:discuz X3.1 发贴时修改会员积分的是哪个文个的哪...
答:你是学php 的?自己研究不行埃目前discuz都被收购了,而且discuz 的技术人员都被抽调给腾讯其他业务做事了。目前discuz基本停止更新的。建议换个还在更新的,而且二次开发有开发文件和教程的系统吧。目前在php是基本没有,.net到有不错的你可以... >>详细
相关问题:discuz怎么给不同的用户组设置不同的积分系统
答:你好,在管理后台----用户---用户组进行设置,希望能帮到你 >>详细
- 评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
-
