当前位置: 首页 > 图文教程 > 网络编程 > PHP > DISCUZ架构:积分系统代码分析一

PHP
同台服务器使用缓存APC效率高于Memcached的演示代码
GBK的页面输出JSON格式的php函数
在字符串指定位置插入一段字符串的php代码
php 数组二分法查找函数代码
php htmlspecialchars加强版
支持数组的ADDSLASHES的php函数
判断是否为指定长度内字符串的php函数
php 读取文件乱码问题
PHP+ajax 无刷新删除数据
php microtime获取浮点的时间戳
php 魔术函数使用说明
php 高效率写法 推荐
PHP 学习路线与时间表
php中理解print EOT分界符和echo EOT的用法区别小结
Search File Contents PHP 搜索目录文本内容的代码
收藏的PHP常用函数 推荐收藏保存
PHP 伪静态隐藏传递参数名的四种方法
PHP实现域名whois查询的代码(数据源万网、新网)
php 用checkbox一次性删除多条记录的方法
php str_pad() 将字符串填充成指定长度的字符串

PHP 中的 DISCUZ架构:积分系统代码分析一


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-14   浏览: 79 ::
收藏到网摘: n/a

1.登陆积分显示
首先是登陆,登陆的时候论坛从cdb_members中取出一些发帖数,积分,扩展积分等等设置,在./include/common.inc.php中有如下代码:

以下为引用的内容:
$membertablefields = 'm.uid AS discuz_uid, m.username AS discuz_user, m.password AS discuz_pw, m.secques AS discuz_secques,
        m.adminid, m.groupid, m.groupexpiry, m.extgroupids, m.email, m.timeoffset, m.tpp, m.ppp, m.posts, m.digestposts,
        m.oltime, m.pageviews, m.credits, m.extcredits1, m.extcredits2, m.extcredits3, m.extcredits4, m.extcredits5,
        m.extcredits6, m.extcredits7, m.extcredits8, m.timeformat, m.dateformat, m.pmsound, m.sigstatus, m.invisible,
        m.lastvisit, m.lastactivity, m.lastpost, m.newpm, m.accessmasks, m.xspacestatus, m.editormode, m.customshow';

以上就是取出数据库中的会员用到的字段。

发帖,回复,发附件,下附件等的积分增加或减少

2.发帖,回复积分增减

(1)原理分析:

以下为引用的内容:
是这样一个过程,发帖的时候前台看到的文件是:post.php,
然后引用如下文件:
include/common.inc.php  DZ通用函数库
include/post.func.php  发帖用到的函数库
include/discuzcode.func.php  解析Discuz Code用到的

接下来跟据传入的action判断引用到哪个文件继续处理

以下为引用的内容:
include/newthread.inc.php(新帖)
include/newreply.inc.php(回复)
include/supesite_import.inc.php(导入到supersite)

(2)代码分析:

下面就以发新帖来分析一下Discuz对于积分的处理。

第一部分:post.php

以下为引用的内容:
这个文件是发新帖,回复,投票都会用到的,所以它的作用就是初始化一些全局的东西,我就不全文件分析了,只分析一些与积分有关的部分。

$postcredits = $forum['postcredits'] ? $forum['postcredits'] : $creditspolicy['post'];
$replycredits = $forum['replycredits'] ? $forum['replycredits'] : $creditspolicy['reply'];
$digestcredits = $forum['digestcredits'] ? $forum['digestcredits'] : $creditspolicy['digest'];
$postattachcredits = $forum['postattachcredits'] ? $forum['postattachcredits'] : $creditspolicy['postattach'];

这一部分的作用就是取出当前论坛的一些积分设置,和我们前面分析的数据表cdb_forumfields对应,得到会员发帖,回复等加多少分。