search
HomeBackend DevelopmentPHP Tutorial论坛里有人熟悉discuz X3.1吗?怎样将主题内容完整的显示出来

论坛里有人熟悉discuz X3.1吗?怎样将主题内容完整的显示出来。


主题容易读出来forum_thread表就行了,但容易表forum_post里的内容不容易读出来呀。

毕竟里面含有[attach]4[/attach][img=500,666]http://pic.qiushibaike.com/system/pictures/5726/57264521/medium/app57264521.jpg[/img]

等,杂七杂八的数据。

人家官方不交流代码,只交流怎样安装。我晕倒了。只能想到CSDN来了,看看有人能不能搞定这个。


回复讨论(解决方案)

论坛里有人熟悉discuz X3.1吗?怎样将主题内容完整的显示出来。


主题容易读出来forum_thread表就行了,但容易表forum_post里的内容不容易读出来呀。

毕竟里面含有[attach]4[/attach][img=500,666]http://pic.qiushibaike.com/system/pictures/5726/57264521/medium/app57264521.jpg[/img]

等,杂七杂八的数据。

人家官方不交流代码,只交流怎样安装。我晕倒了。只能想到CSDN来了,看看有人能不能搞定这个。


人家的代码本身就含有一个这样的转换函数

@chinmo 版主

关键是我找到discuzcode()、parseattach()解析函数后,似乎没用。目前还在找原因。

@chinmo 版主

关键是我找到discuzcode()、parseattach()解析函数后,似乎没用。目前还在找原因。


晕死,你直接到他的帖子内容页去找不就知道他用的什么函数了?这还纠结什么

@chinmo

大版主呀,帖子内容应该是source\module\forum\forum_viewthread.php这个文件

可我找来找去,感觉就只有这两个函数相关。但还没有起到作用。

找了两天,晕死

@chinmo

大版主呀,帖子内容应该是source\module\forum\forum_viewthread.php这个文件

可我找来找去,感觉就只有这两个函数相关。但还没有起到作用。

找了两天,晕死


你再他模板找干嘛,DZ的他基本都是用$post这个数组保存数据的,你在他的控制器文件里输出这个数组就知道是哪个字段保存着文章内容了,然后你在在他的控制器里查找他对这个字段所用的处理函数不就可以了

做程序这点最起码的查找能力应该有的吧

@chinmo

大版主呀,我肯定不会去模板层找了,真的没有你想象的那么简单,我用的是discuz X3.1utf8版本。

帖子内容应该是source\module\forum\forum_viewthread.php这个文件

大概903行左右:
parseattach($_G['forum_attachpids'], $_G['forum_attachtags'], $postlist, $skipaids);

用来解析附件的。

大概是在1228行:
        $post['message'] = discuzcode($post['message'], $post['smileyoff'], $post['bbcodeoff'], $post['htmlon'] & 1, $_G['forum']['allowsmilies'], $forum_allowbbcode, ($_G['forum']['allowimgcode'] && $_G['setting']['showimages'] ? 1 : 0), $_G['forum']['allowhtml'], ($_G['forum']['jammer'] && $post['authorid'] != $_G['uid'] ? 1 : 0), 0, $post['authorid'], $_G['cache']['usergroups'][$post['groupid']]['allowmediacode'] && $_G['forum']['allowmediacode'], $post['pid'], $_G['setting']['lazyload'], $post['dbdateline'], $post['first']);

用来解析内容的

但不晓得为什么就是不成功。

discuzcode 就是了用的这个函数
不成功的话
最简单的排查就是在这个函数里断句输出,看看他在那里替换不成功

这样也可以找出你具体是在什么环节上弄错了

各路PHP牛人,我把代码奉上:
define('APPTYPEID', 2);
define('CURSCRIPT', 'forum');

require './source/class/class_core.php';
require './source/function/function_forum.php';

$cachelist = array();
C::app()->cachelist = $cachelist;
C::app()->init();



//$navtitle = str_replace('{bbname}', $_G['setting']['bbname'], $_G['setting']['seotitle']['forum']);
//$_G['setting']['threadhidethreshold'] = 1;


//$query = C::t('forum_thread')->fetch_all_for_guide1($view, $limittid, $tids, $_G['setting']['heatthread']['guidelimit'], $dateline); 

//$query = C::t('forum_thread')->fetch_all_search('', 'forum_thread', 0,'', '', '');;
//print_r($query);

require_once libfile('function/discuzcode');
require_once libfile('function/attachment');
require_once libfile('function/forum');
   $sql = "SELECT a.*, b.message,b.htmlon,b.bbcodeoff,b.smileyoff,b.parseurloff,b.pid,b.first FROM ".DB::table('forum_thread')." a left join ".DB::table('forum_post')." b on a.authorid=b.authorid and a.tid=b.tid and b.first=1  WHERE 1=1 AND a.heats>=1" ;
   $sql = "SELECT a.*, b.message,b.htmlon,b.bbcodeoff,b.smileyoff,b.parseurloff,b.pid,b.first FROM ".DB::table('forum_thread')." a left join ".DB::table('forum_post')." b on a.authorid=b.authorid and a.tid=b.tid and b.first=1 WHERE a.tid>0 AND a.heats>=0  ORDER BY a.lastpost DESC LIMIT 600";
  $query = DB::fetch_all($sql);
  $postlist     = array();
  foreach($query as $post){
      $post['message'] = discuzcode($post['message'], $post['smileyoff'], $post['bbcodeoff'], $post['htmlon'] & 1, $_G['forum']['allowsmilies'], $forum_allowbbcode, ($_G['forum']['allowimgcode'] && $_G['setting']['showimages'] ? 1 : 0), $_G['forum']['allowhtml'], ($_G['forum']['jammer'] && $post['authorid'] != $_G['uid'] ? 1 : 0), 0, $post['authorid'], $_G['cache']['usergroups'][$post['groupid']]['allowmediacode'] && $_G['forum']['allowmediacode'], $post['pid'], $_G['setting']['lazyload'], $post['dbdateline'], $post['first']);
      
      $_G['forum_attachpids'][] = $post['pid'];
      if(preg_match_all("/\[attach\](\d+)\[\/attach\]/i", $post['message'], $matchaids)) {
   $_G['forum_attachtags'][$post['pid']] = $matchaids[1];
      }
      $postlist[$post['pid']] = $post;
  }
    
  parseattach($_G['forum_attachpids'], $_G['forum_attachtags'], $postlist);
  
  print_r($postlist);
  
?>

死活找不到那里有问题。

形如[img=500,666]http://pic.qiushibaike.com/system/pictures/5726/57264521/medium/app57264521.jpg[/img]
这样的是 ubb 代码
你可以找到 ubb 解码程序相关的部分切入
他好像是 bbcode 类

我也是跟lz一样,找到类似函数后没法解析了。这里看来大神没空解释这个问题

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
The Continued Use of PHP: Reasons for Its EnduranceThe Continued Use of PHP: Reasons for Its EnduranceApr 19, 2025 am 12:23 AM

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python: Exploring Their Similarities and DifferencesPHP and Python: Exploring Their Similarities and DifferencesApr 19, 2025 am 12:21 AM

PHP and Python are both high-level programming languages ​​that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP and Python: Different Paradigms ExplainedPHP and Python: Different Paradigms ExplainedApr 18, 2025 am 12:26 AM

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP and Python: A Deep Dive into Their HistoryPHP and Python: A Deep Dive into Their HistoryApr 18, 2025 am 12:25 AM

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

Choosing Between PHP and Python: A GuideChoosing Between PHP and Python: A GuideApr 18, 2025 am 12:24 AM

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP and Frameworks: Modernizing the LanguagePHP and Frameworks: Modernizing the LanguageApr 18, 2025 am 12:14 AM

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHP's Impact: Web Development and BeyondPHP's Impact: Web Development and BeyondApr 18, 2025 am 12:10 AM

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

How does PHP type hinting work, including scalar types, return types, union types, and nullable types?How does PHP type hinting work, including scalar types, return types, union types, and nullable types?Apr 17, 2025 am 12:25 AM

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values ​​and handle functions that may return null values.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.