Home Backend Development PHP Tutorial Discuz!插件:自动隐藏帖子第1/2页_PHP教程

Discuz!插件:自动隐藏帖子第1/2页_PHP教程

Jul 21, 2016 pm 03:56 PM
discuz Preface studio Post plug-in netizen automatic Require this hide

前言
  应一位网友要求开卷工作室制作了这个自动隐藏帖子的插件,主要用途是无需手动添加 [hide] 代码,则自动隐藏所有发布的帖子内容,会员需要回复后才可以浏览该帖。这想法相当不错,要实现这一功能也不很难,所以就帮忙做了一个出来。插件提供两种自动隐藏的模式,一种是只隐藏一楼的帖子,另一种是隐藏包括回复在内的所有帖子。因为秉承开卷工作室绿色插件的作风,能够不改动数据库的就不改,所以本插件不增加后台开关功能,而只提供 config.inc.php 的开关设置。
  本插件适用于 Discuz! 所有版本的论坛,但这里只提供 DZ4.1 / DZ5.0 / DZ5.5 的安装方法,其它版本的论坛请参照着自行修改。
更新记录:
2007-01-25        修正不包含论坛代码的帖子无法隐藏的问题;增加隐藏除一楼以外的所有帖子的设置;增加可预览字节设置,设置后可以预览部分被隐藏的帖子内容,从而让内容好的帖子吸引更多人参与回帖;增加可自定义哪些论坛开启自动隐藏功能的设置。
2007-01-27        增加对游客访问时只能阅读部分内容的设置,效果如下:
  非常抱歉,您的当前状态为游客,因此只能阅读部分内容。要阅读完整内容请:注册 或 登录 。
2007-01-28        更正公告及短消息也会被自动隐藏,同时因缺少变量而报错的问题;增加可自定义允许或排除指定论坛自动隐藏功能的设置;提供解决文本截断后页面代码错乱问题的两种解决办法,大家可根据自己的情况选择使用。
2007-02-04        增加与干扰码的兼容性修改。
2007-03-14        增加 Discuz!5.5 的安装方法,并测试成功。
名称:开卷工作室自动隐藏帖子[增强版] For Discuz! All Version
难度:一般
适用版本:Discuz!所有版本
作者:KaijuanStudio
发布日期:2006-11-07
更新日期:2007-03-14
发布站点:中国制造论坛
技术支持:http://madeinchn.cn/thread-4-13016-1-1.htm
安装方法如下:
修改:viewthread.php
打开:viewthread.php
DZ4.1,找到:
$post['message'] = discuzcode($post['message'], $post['smileyoff'], $post['bbcodeoff'], $post['htmlon'], $forum['allowsmilies'], $forum['allowbbcode'], $forum['allowimgcode'], $forum['allowhtml'], ($forum['jammer'] && $post['authorid'] != $discuz_uid ? 1 : 0));替换为:
$post['message'] = discuzcode($post['message'], $post['smileyoff'], $post['bbcodeoff'], $post['htmlon'], $forum['allowsmilies'], $forum['allowbbcode'], $forum['allowimgcode'], $forum['allowhtml'], ($forum['jammer'] && $post['authorid'] != $discuz_uid ? 1 : 0), $post['first']);DZ5.0,找到:
$post['message'] = discuzcode($post['message'], $post['smileyoff'], $post['bbcodeoff'], $post['htmlon'], $forum['allowsmilies'], $forum['allowbbcode'], ($forum['allowimgcode'] && $showimages ? 1 : 0), $forum['allowhtml'], ($forum['jammer'] && $post['authorid'] != $discuz_uid ? 1 : 0), $pasetype, $post['authorid']);替换为:
$post['message'] = discuzcode($post['message'], $post['smileyoff'], $post['bbcodeoff'], $post['htmlon'], $forum['allowsmilies'], $forum['allowbbcode'], ($forum['allowimgcode'] && $showimages ? 1 : 0), $forum['allowhtml'], ($forum['jammer'] && $post['authorid'] != $discuz_uid ? 1 : 0), $pasetype, $post['authorid'], $post['first']);DZ5.5,找到:
$post['message'] = discuzcode($post['message'], $post['smileyoff'], $post['bbcodeoff'], $post['htmlon'], $forum['allowsmilies'], $forum['allowbbcode'], ($forum['allowimgcode'] && $showimages ? 1 : 0), $forum['allowhtml'], ($forum['jammer'] && $post['authorid'] != $discuz_uid ? 1 : 0), 0, $post['authorid']);替换为:
$post['message'] = discuzcode($post['message'], $post['smileyoff'], $post['bbcodeoff'], $post['htmlon'], $forum['allowsmilies'], $forum['allowbbcode'], ($forum['allowimgcode'] && $showimages ? 1 : 0), $forum['allowhtml'], ($forum['jammer'] && $post['authorid'] != $discuz_uid ? 1 : 0), 0, $post['authorid'], $post['first']);
修改:discuzcode.func.php
打开:include\discuzcode.func.php
DZ4.1,找到:
function discuzcode($message, $smileyoff, $bbcodeoff, $htmlon = 0, $allowsmilies = 1, $allowbbcode = 1, $allowimgcode = 1, $allowhtml = 0, $jammer = 0) {替换为:
function discuzcode($message, $smileyoff, $bbcodeoff, $htmlon = 0, $allowsmilies = 1, $allowbbcode = 1, $allowimgcode = 1, $allowhtml = 0, $jammer = 0, $first = '0') {再将下面一行的:
        global $discuzcodes, $credits, $tid, $discuz_uid, $highlight, $maxsmilies, $db, $tablepre;替换为:
        global $discuzcodes, $credits, $fid, $tid, $discuz_uid, $highlight, $maxsmilies, $db, $tablepre, $hidemsg, $hidecut, $leavemod, $hidefids;
        $bbcodeoff = $hidemsg ? '' : $bbcodeoff;继续找到:
if(preg_match("/\[hide=?\d*\].+?\[\/hide\]/is", $message)) {替换为:
//hidemsg by KaijuanStudio
                if($hidefids) {
                        foreach($hidefids as $hidefid) {
                                if($leavemod) {
                                        if($fid == $hidefid) {
                                                $unallowed = 1;
                                        } else {
                                                $allowhide = 1;
                                        }
                                } else {
                                        if($fid == $hidefid) {
                                                $allowhide = 1;
                                        }
                                }
                        }
                } elseif($fid) {
                        $allowhide = 1;
                }
                if($hidemsg && $allowhide && !$unallowed) {
                        global $language;
                        include_once language('misc');
                        $hidefirst = $hidemsg == 1 ? $first : ($hidemsg == 2 ? 1 : ($hidemsg == 3 ? ($first ? '' : 1) : ''));
                        if($hidefirst) {
                                if($hidecut                                         $query = $db->query("SELECT pid FROM {$tablepre}posts WHERE tid='$tid' AND authorid='$discuz_uid' LIMIT 1");
                                        if($GLOBALS['forum']['ismoderator'] || $db->result($query, 0)) {
                                                $message = ''.$language['post_hide_reply'].'
'.
                                                '==============================

'.
                                                $message.'

'.
                                                '==============================';
                                        } else {
                                                $message = $hidecut ? ($hidecut >= strlen($message) ? $message : dhtmlspecialchars(cutstr($message, $hidecut)).'

'.$language['post_hide_reply_hidden'].'') : ''.$language['post_hide_reply_hidden'].'';
                                        }
                                }
                        } elseif(!$discuz_uid && $hidemsg == 4 && $hidecut) {
                                $message = $hidecut >= strlen($message) ? $message : dhtmlspecialchars(cutstr($message, $hidecut)).'

'.$language['post_hide_limit'];
                        }
                } elseif(preg_match("/\[hide=?\d*\].+?\[\/hide\]/is", $message)) {DZ5.0/DZ5.5,找到:
function discuzcode($message, $smileyoff, $bbcodeoff, $htmlon = 0, $allowsmilies = 1, $allowbbcode = 1, $allowimgcode = 1, $allowhtml = 0, $jammer = 0, $parsetype = '0', $authorid = '0') {替换为:
function discuzcode($message, $smileyoff, $bbcodeoff, $htmlon = 0, $allowsmilies = 1, $allowbbcode = 1, $allowimgcode = 1, $allowhtml = 0, $jammer = 0, $parsetype = '0', $authorid = '0', $first = '0') {DZ5.0 再将下面一行的:
        global $discuzcodes, $credits, $tid, $discuz_uid, $highlight, $maxsmilies, $db, $tablepre;替换为:
        global $discuzcodes, $credits, $fid, $tid, $discuz_uid, $highlight, $maxsmilies, $db, $tablepre, $hidemsg, $hidecut, $leavemod, $hidefids;
        $bbcodeoff = $hidemsg ? '' : $bbcodeoff;DZ5.5 将下面一行的:
        global $discuzcodes, $credits, $tid, $discuz_uid, $highlight, $maxsmilies, $db, $tablepre, $hideattach;替换为:
        global $discuzcodes, $credits, $fid, $tid, $discuz_uid, $highlight, $maxsmilies, $db, $tablepre, $hideattach, $hidemsg, $hidecut, $leavemod, $hidefids;
        $bbcodeoff = $hidemsg ? '' : $bbcodeoff;DZ5.0 继续找到:
if(!in_array($parsetype, array(1, 2)) && preg_match("/\[hide=?\d*\].+?\[\/hide\]/is", $message)) {替换为:
//hidemsg by KaijuanStudio
                if($hidefids) {
                        foreach($hidefids as $hidefid) {
                                if($leavemod) {
                                        if($fid == $hidefid) {
                                                $unallowed = 1;
                                        } else {
                                                $allowhide = 1;
                                        }
                                } else {
                                        if($fid == $hidefid) {
                                                $allowhide = 1;
                                        }
                                }
                        }
                } elseif($fid) {
                        $allowhide = 1;
                }
                if($hidemsg && $allowhide && !$unallowed) {
                        global $language;
                        include_once language('misc');
                        $hidefirst = $hidemsg == 1 ? $first : ($hidemsg == 2 ? 1 : ($hidemsg == 3 ? ($first ? '' : 1) : ''));
                        if($hidefirst) {
                                if($hidecut                                         $query = $db->query("SELECT pid FROM {$tablepre}posts WHERE tid='$tid' AND authorid='$discuz_uid' LIMIT 1");
                                        if($GLOBALS['forum']['ismoderator'] || $db->result($query, 0)) {
                                                $message = ''.$language['post_hide_reply'].'
'.
                                                '==============================

'.
                                                $message.'

'.
                                                '==============================';
                                        } else {
                                                $message = $hidecut ? ($hidecut >= strlen($message) ? $message : dhtmlspecialchars(cutstr($message, $hidecut)).'

'.$language['post_hide_reply_hidden'].'') : ''.$language['post_hide_reply_hidden'].'';
                                        }
                                }
                        } elseif(!$discuz_uid && $hidemsg == 4 && $hidecut) {
                                $message = $hidecut >= strlen($message) ? $message : dhtmlspecialchars(cutstr($message, $hidecut)).'

'.$language['post_hide_limit'];
                        }
                } elseif(!in_array($parsetype, array(1, 2)) && preg_match("/\[hide=?\d*\].+?\[\/hide\]/is", $message)) {DZ5.5 继续找到:
if($parsetype != 1 && preg_match("/\[hide=?\d*\].+?\[\/hide\]/is", $message)) {替换为:
//hidemsg by KaijuanStudio
                if($hidefids) {
                        foreach($hidefids as $hidefid) {
                                if($leavemod) {
                                        if($fid == $hidefid) {
                                                $unallowed = 1;
                                        } else {
                                                $allowhide = 1;
                                        }
                                } else {
                                        if($fid == $hidefid) {
                                                $allowhide = 1;
                                        }
                                }
                        }
                } elseif($fid) {
                        $allowhide = 1;
                }
                if($hidemsg && $allowhide && !$unallowed) {
                        global $language;
                        include_once language('misc');
                        $hidefirst = $hidemsg == 1 ? $first : ($hidemsg == 2 ? 1 : ($hidemsg == 3 ? ($first ? '' : 1) : ''));
                        if($hidefirst) {
                                if($hidecut                                         $query = $db->query("SELECT pid FROM {$tablepre}posts WHERE tid='$tid' AND authorid='$discuz_uid' LIMIT 1");
                                        if($GLOBALS['forum']['ismoderator'] || $db->result($query, 0)) {
                                                $message = ''.$language['post_hide_reply'].'
'.
                                                '==============================

'.
                                                $message.'

'.
                                                '==============================';
                                        } else {
                                                $message = $hidecut ? ($hidecut >= strlen($message) ? $message : dhtmlspecialchars(cutstr($message, $hidecut)).'

'.$language['post_hide_reply_hidden'].'') : ''.$language['post_hide_reply_hidden'].'';
                                        }
                                }
                        } elseif(!$discuz_uid && $hidemsg == 4 && $hidecut) {
                                $message = $hidecut >= strlen($message) ? $message : dhtmlspecialchars(cutstr($message, $hidecut)).'

'.$language['post_hide_limit'];
                        }
                } elseif($parsetype != 1 && preg_match("/\[hide=?\d*\].+?\[\/hide\]/is", $message)) {
解决文本截断后代码错乱问题 (DZ4.1/DZ5.0/DZ5.5 相同)
解决方法一(推荐):
将上面已修改好的代码,选择从:
//hidemsg by KaijuanStudio开头,一直到:
                        $message = preg_replace("/\[hide=(\d+)\]\s*(.+?)\s*\[\/hide\]/ies", "creditshide(\\1,'\\2')", $message);
                }结尾的所有代码,然后将这一大段代码移动到:
if(!$bbcodeoff && $allowbbcode) {的下面一行里。
  这一方法最为简单,适用于没有启用 HTML 代码的论坛,对于文本截断末尾出现诸如没有闭合的代码,例如缺少:[/quote]、[/url]、[/img] 的内容,将以代码的方式显示。

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/318108.htmlTechArticle前言 应一位网友要求开卷工作室制作了这个自动隐藏帖子的插件,主要用途是无需手动添加[hide]代码,则自动隐藏所有发布的帖子内容,会...
Statement of this Website
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

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Two Point Museum: All Exhibits And Where To Find Them
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to hide WeChat friends without blocking or deleting them? How to hide WeChat friends without blocking or deleting them How to hide WeChat friends without blocking or deleting them? How to hide WeChat friends without blocking or deleting them Mar 13, 2024 pm 07:19 PM

How to hide WeChat friends without blocking or deleting them? Many users want to hide some friends but don’t know how to do it. Let this site carefully introduce to users how to hide WeChat friends without blocking or deleting them. Methods to hide WeChat friends without blocking or deleting Method 1: 1. First open the WeChat software, find the address book on the WeChat page, and click "My". 2. Then we enter the settings page. 3. Find the “Privacy” option and click on it. 4. Then click "Don't let him see". 5. Go to the Do Not Let Her View page and click "+" to check the friends you want to hide.

Share three solutions to why Edge browser does not support this plug-in Share three solutions to why Edge browser does not support this plug-in Mar 13, 2024 pm 04:34 PM

When users use the Edge browser, they may add some plug-ins to meet more of their needs. But when adding a plug-in, it shows that this plug-in is not supported. How to solve this problem? Today, the editor will share with you three solutions. Come and try it. Method 1: Try using another browser. Method 2: The Flash Player on the browser may be out of date or missing, causing the plug-in to be unsupported. You can download the latest version from the official website. Method 3: Press the "Ctrl+Shift+Delete" keys at the same time. Click "Clear Data" and reopen the browser.

How to hide works in Douyin short videos How to hide personal video works How to hide works in Douyin short videos How to hide personal video works Mar 12, 2024 pm 12:49 PM

There are many short video works provided in the Douyin short video app software. You can watch them as you like, and they are all permanently provided free of charge. Different types of live video channels are open, and all video content is original, with Give everyone the most satisfying way to watch. Enter your account to log in online, and a variety of exciting short videos will be pushed, which are accurately recommended based on what everyone watches every day. You can also enter the live broadcast room to interact and chat with the anchor, making you feel more happy. Works uploaded by individuals can also be hidden. It is very simple to set up with one click. You can see wherever you swipe. Swipe up and down to see the real-time comments of countless netizens. You can also share daily life dynamics. Now the editor has detailed online Douyin short videos. Users push for ways to hide personal video works. First open Douyin short video

How to hide Smart Island on Xiaomi Mi 14? How to hide Smart Island on Xiaomi Mi 14? Mar 18, 2024 pm 03:40 PM

In addition to the amazing hardware configuration and excellent functions, Xiaomi Mi 14 also hides a fascinating place - Smart Island. Here, users can enjoy personalized customization and unlimited creative mobile phone experience. But not everyone likes this feature, so how does Xiaomi Mi 14 hide Smart Island? Let’s find out together. How to hide Smart Island on Xiaomi Mi 14? 1. Open the settings application of Xiaomi 14 mobile phone. 2. Scroll to find the "Features" option and click to enter. 3. Find the "Hide Smart Island" option on the features page and turn it on. 4. After confirming that hiding the Smart Island is turned on, return to the desktop and you will see that the Smart Island has been hidden.

A must-have for Discuz users! Comprehensive analysis of renaming props! A must-have for Discuz users! Comprehensive analysis of renaming props! Mar 12, 2024 pm 10:15 PM

A must-have for Discuz users! Comprehensive analysis of renaming props! In the Discuz forum, the name change function has always received much attention and demand from users. For some users who need to change their name, name change props can easily modify the user name, and this is also an interesting way of interaction. Let’s take an in-depth look at the renaming props in Discuz, including how to obtain them, how to use them, and solutions to some common problems. 1. Obtain name-changing props in Discuz. Name-changing props are usually purchased through points or the administrator

Detailed tutorial on hiding works on Douyin Detailed tutorial on hiding works on Douyin Mar 25, 2024 pm 03:11 PM

1. First click [+] to shoot. 2. Then click the check mark in the lower right corner to confirm the completion of shooting. Click] Next[, 3. Click [Who can see]. Just select [Private]. Scenario 2: The work has been taken. 1. Click [Me] and select [Work]. 2. Click the [three dots] logo on the right. 3. Swipe left to find [Permission Settings], 4. Click [Set as Private].

How to deeply clean the hidden junk on your phone (completely remove junk from your phone's memory) How to deeply clean the hidden junk on your phone (completely remove junk from your phone's memory) Jun 01, 2024 am 09:29 AM

Mobile phones have become an indispensable part of our daily lives, with the continuous advancement of technology and the popularity of smartphones. These junk files take up valuable storage space, and over time, a large amount of hidden junk will accumulate in the phone and cause the performance of the phone to degrade, however. Knowing how to deeply clean hidden junk on your phone has become essential knowledge for every mobile phone user. 1. Find and clear useless application caches 2. Delete applications that are no longer used 3. Clean photo and video cache 4. Thoroughly clean temporary files and download folders 5. Organize and clean contact and text message records 6. Clean system cache 7. Uninstall useless system applications 8. Clean browser cache and history 9. Delete invalid music and audio files 10. Optimize mobile phone file system

Automount drives on Linux Automount drives on Linux Mar 20, 2024 am 11:30 AM

If you are using a Linux operating system and want the system to automatically mount the drive on boot, you can do this by adding the device's unique identifier (UID) and mount point path to the fstab configuration file. fstab is a file system table file located in the /etc directory. It contains information about the file systems that need to be mounted when the system starts. By editing the fstab file, you can ensure that the required drives are loaded correctly every time the system starts, thus ensuring stable system operation. Automatically mounting drivers can be conveniently used in a variety of situations. For example, I plan to back up my system to an external storage device. To achieve automation, ensure that the device remains connected to the system, even at startup. Likewise, many applications will directly

See all articles