Home  >  Article  >  Backend Development  >  麻烦懂 Discuz 的朋友进来下 , 问题 .

麻烦懂 Discuz 的朋友进来下 , 问题 .

WBOY
WBOYOriginal
2016-06-23 14:03:061124browse

我只是粗粗用过 DZ 没有仔细用过它各个方面的功能 ,但现在研究它的代码了 . 有些地方因为没用过 , 光看代码有无法看出其意思来 , 请懂的朋友解答下 .

if(!empty($_G['forum']['threadsorts']['types'])) {	require_once libfile('function/threadsort');	$showpic = intval($_G['gp_showpic']);	$templatearray = $sortoptionarray = array();	foreach($_G['forum']['threadsorts']['types'] as $stid => $sortname) {		loadcache(array('threadsort_option_'.$stid, 'threadsort_template_'.$stid));		sortthreadsortselectoption($stid);		$templatearray[$stid] = $_G['cache']['threadsort_template_'.$stid]['subject'];		$sortoptionarray[$stid] = $_G['cache']['threadsort_option_'.$stid];	}	if(!empty($_G['forum']['threadsorts']['defaultshow']) && empty($_G['gp_sortid']) && empty($_G['gp_sortall'])) {		$_G['gp_sortid'] = $_G['forum']['threadsorts']['defaultshow'];		$_G['gp_filter'] = 'sortid';		$_SERVER['QUERY_STRING'] = $_SERVER['QUERY_STRING'] ? $_SERVER['QUERY_STRING'].'&sortid='.$_G['gp_sortid'] : 'sortid='.$_G['gp_sortid'];		$filterurladd = '&filter=sort';	}	$_G['gp_sortid'] = $_G['gp_sortid'] ? $_G['gp_sortid'] : $_G['gp_searchsortid'];	if(isset($_G['gp_sortid']) && $_G['forum']['threadsorts']['types'][$_G['gp_sortid']]) {		$searchsortoption = $sortoptionarray[$_G['gp_sortid']];		$quicksearchlist = quicksearch($searchsortoption);		$_G['forum_optionlist'] = $_G['cache']['threadsort_option_'.$_G['gp_sortid']];		$forum_optionlist = getsortedoptionlist();	}}

简单的来说 , 就这段 , 不知能否详细解释一下 ?


回复讨论(解决方案)

调试着才能说清楚

具体一点,没有人没事给你读代码玩。

额 , 不好意思 , 我忘了说了 , 这个就是 DZ 源码 . 
出自 : 
Discuz! X2 版本
/source/module/forum/forum_forumdisplay.php
的第 195 行 .
非常感谢 , 懂的人请解答下 , 这个文件的其他部分全都看懂了 , 这文件的作用很简单 , 就是帖子列表 .
但这一个判断我不知其意 . 请帮我解答下 , 谢谢 .

望各位喷子“嘴下留情”, 如果不是喷子那说话语气好点别那么喷 , 比如 : andyxl .
如果懂的话 , 请解答下 , 谢谢 .

对了 , 顺便对 #1 做一下解释 , 为啥我没调试着看呢 ... 因为你把这段都删掉 , 页面上也没任何影响 ...
而我对 DZ 的功能又不慎熟悉 , 不知道到底怎么操作 , 才能看出区别 ... 所以才请教懂的朋友的

而且 , 你就算把

if(!empty($_G['forum']['threadsorts']['types'])) {

改为
if(true)

强制其执行这一段 , 个被催的 , 也看不出区别 ...

var_dump($_G)
输出参数可以看到  这个变量保存了很多信息,诸如用户ID,名称神马神马的。
提交到source/目录下。具体看时function还是module

没用过discuz

我在单位局域网里也建立了这个论坛Discuz! X2 ,加入了在线考试插件,还不错,只是还没有空来研究后台的代码。

今天已经确认 , 这个来自于
/source/function/function_forum.php 的第 399 行 , loadforum 函数 . 在该文件第 506 行有对四个字段序列化的操作 , 其中有这个字段 .
代码 :

			foreach(array('threadtypes', 'threadsorts', 'creditspolicy', 'modrecommend') as $key) {				$forum[$key] = !empty($forum[$key]) ? unserialize($forum[$key]) : array();				if(!is_array($forum[$key])) {					$forum[$key] = array();				}			}

按照常理来讲 , 这个东西中存的应该是数组 .
而在该文件的第 467 行可以看到 $forum 是什么 :
$forum = DB::fetch_first("SELECT f.fid, f.*, ff.* $accessadd1 $modadd1, f.fid AS fidFROM ".DB::table('forum_forum')." fLEFT JOIN ".DB::table("forum_forumfield")." ff ON ff.fid=f.fid $accessadd2 $modadd2WHERE f.fid='$fid'");

显然可以知道 , 这个字段就是 forum_forum / forum_forumfield 表中的一个字段 , 经过确认 , 该字段为
forum_forumfield , 根据我前两天的研究 , 知道这个表是 discuz 版块的拓展表 . 所以到现在大部分问题已经解开了 , 而转到 
if(!empty($_G['forum']['threadsorts']['types']))

第一帖的第一行代码中 , 显然知道这个字段存放的是 serialize 之后的数组 , 可 TM 是什么 , 就是不清楚 , 希望某高人能说明白

顺便跟帖说明一下 
$_G['forum']....
来操作刚刚数据库中取到的 $forum , 是因为
/source/function/function_forum.php
中 loadforum 函数结尾部 ( 该文件的第 557 行 ) 写了如下几行代码 :

$_G['fid'] = $fid;$_G['tid'] = $tid;$_G['forum'] = &$forum;$_G['current_grouplevel'] = &$grouplevel;

呵呵 , 是引用哦 , 不是直接赋值 .
在线等懂的朋友出现

本人也是才接触这个东东。才疏学浅,无法提供具体指导。共同进步吧。楼主如果有好的资料,麻烦共享出来

if(!empty($_G['forum']['threadsorts']['types'])) {//分类信息是否为空    require_once libfile('function/threadsort');    $showpic = intval($_G['gp_showpic']);//图片?    $templatearray = $sortoptionarray = array();    foreach($_G['forum']['threadsorts']['types'] as $stid => $sortname) {        loadcache(array('threadsort_option_'.$stid, 'threadsort_template_'.$stid));        sortthreadsortselectoption($stid);        $templatearray[$stid] = $_G['cache']['threadsort_template_'.$stid]['subject'];        $sortoptionarray[$stid] = $_G['cache']['threadsort_option_'.$stid];//得到当前所有分类信息    }    if(!empty($_G['forum']['threadsorts']['defaultshow']) && empty($_G['gp_sortid']) && empty($_G['gp_sortall'])) {        $_G['gp_sortid'] = $_G['forum']['threadsorts']['defaultshow'];        $_G['gp_filter'] = 'sortid';        $_SERVER['QUERY_STRING'] = $_SERVER['QUERY_STRING'] ? $_SERVER['QUERY_STRING'].'&sortid='.$_G['gp_sortid'] : 'sortid='.$_G['gp_sortid'];        $filterurladd = '&filter=sort';    }    $_G['gp_sortid'] = $_G['gp_sortid'] ? $_G['gp_sortid'] : $_G['gp_searchsortid'];    if(isset($_G['gp_sortid']) && $_G['forum']['threadsorts']['types'][$_G['gp_sortid']]) {        $searchsortoption = $sortoptionarray[$_G['gp_sortid']];        $quicksearchlist = quicksearch($searchsortoption);        $_G['forum_optionlist'] = $_G['cache']['threadsort_option_'.$_G['gp_sortid']];        $forum_optionlist = getsortedoptionlist();    }}//以上代码应该是处理分类信息

额 , 感谢上面的大奖获得者 , 请问这个分类是指 ?
我从后台可以调吗 ? 或者从哪里可以调 ?
我想调一下 , 测试一下这段代码 , 也方便我理解具体的意思嘛 .

悲催的不得了 .
正如 #12 ( 我一直看不懂它下面有朵红花还有朵蓝花是什么意思 , 看了半天 , 我以为它是卖花的 . ) 所言 , 这东西是分类信息 , 什么叫分类信息 ? 个悲催的 Dz 搞的花头还挺多 . 
简单的来说 , 我折腾了半天代码 , 折腾到后台终于折腾明白了 ...
就是你发帖时选的那些 " 投票 " , " 求助 " .... 之类的 , 建议去
后台 - 论坛 - 板块管理
随便点一个主题后面的 " 编辑 "
然后选择 其他 - 分类信息 ...
被催的 ...

补一贴 , 设置之后在命令行下选择 DZ 数据库用这个 SQL 试试看 ...
select threadsorts from pre_forum_forumfield
就可以看到了

楼主,现在DZ学的怎么样?现在刚开始学习DZ,一穷二白的,没有资料,看半天程序一点儿感觉没有,头昏脑胀的,楼主有没有好的资料或者学习的网站,博客什么的呢?
不吝赐教啊~~~

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn