Discuz! Plug-in: automatically hides page 1/2 of a post

Source: Internet
Author: User
Tags php switch

Preface
At the request of a netizen, the open volume studio created the plug-in for automatically hiding posts. The main purpose is to automatically hide all posted posts without manually adding the [hide] code, the member can view the post only after replying. This idea is quite good, and it is not very difficult to implement this function, so I just made a try. The plug-in provides two automatic hiding modes: one is to hide posts on the first floor, and the other is to hide all posts including replies. Because the green plug-in style of the open-volume studio can not be changed without changing the database, so this plug-in does not add the background switch function, but only provides the config. inc. php switch settings.
This plugin applies to Discuz! For all versions of the forum, only the installation methods of DZ4.1/DZ5.0/DZ5.5 are provided. For other versions of the forum, Please modify them as needed.
Update record:
Fixed the issue where posts that do not contain Forum code could not be hidden. added the settings for hiding all posts except the first floor. added the preview byte settings, after setting, you can preview some hidden post content, so that the posts with good content can attract more people to participate in the reply. You can also customize the setting of forums to enable the automatic hide function.
You can only read part of the content when visiting the website from. The effect is as follows:
Sorry, you are in the tourist status, so you can only read part of the content. To read the complete information, register or log on.
Correction of announcements and short messages will also be automatically hidden, and errors will be reported due to the lack of variables; added settings that allow or exclude the auto-hide function of the specified forum; two solutions are provided to solve the Page code disorder after text truncation. You can choose to use them as needed.
Added the compatibility modification with the interference code on February 4.
Added Discuz in! 5.5 installation method, and the test is successful.
Name: The opening studio automatically hides the post [enhanced version] For Discuz! All Version
Difficulty: Average
Applicable version: Discuz! All Versions
Author: KaijuanStudio
Release date: 2006-11-07
Updated on: 2007-03-14
Release site: China Manufacturing Forum
Technical support: http://madeinchn.cn/thread-4-13016-1-1.htm
The installation method is as follows:
Modify: viewthread. php
Open: viewthread. php
DZ4.1, find:
$ Post ['message'] = discuzcode ($ post ['message'], $ post ['smileyoff '], $ post ['bbcodeoff'], $ post ['htmlon'], $ forum ['allowsresults'], $ forum ['allowbucketcodes '], $ forum ['allowimgcode'], $ forum ['allowhtml'], ($ forum ['jammer'] & $ post ['authorid']! = $ Discuz_uid? 1: 0); replace:
$ Post ['message'] = discuzcode ($ post ['message'], $ post ['smileyoff '], $ post ['bbcodeoff'], $ post ['htmlon'], $ forum ['allowsresults'], $ forum ['allowbucketcodes '], $ forum ['allowimgcode'], $ forum ['allowhtml'], ($ forum ['jammer'] & $ post ['authorid']! = $ Discuz_uid? 1: 0), $ post ['first']); DZ5.0, locate:
$ Post ['message'] = discuzcode ($ post ['message'], $ post ['smileyoff '], $ post ['bbcodeoff'], $ post ['htmlon'], $ forum ['allowscloud'], $ forum ['allowbucketcodes '], ($ forum ['allowimgcode'] & $ showimages? 1: 0), $ forum ['allowhtml '], ($ forum ['jammer'] & $ post ['authorid']! = $ Discuz_uid? 1: 0), $ pasetype, $ post ['authorid']); replace:
$ Post ['message'] = discuzcode ($ post ['message'], $ post ['smileyoff '], $ post ['bbcodeoff'], $ post ['htmlon'], $ forum ['allowscloud'], $ forum ['allowbucketcodes '], ($ forum ['allowimgcode'] & $ showimages? 1: 0), $ forum ['allowhtml '], ($ forum ['jammer'] & $ post ['authorid']! = $ Discuz_uid? 1: 0), $ pasetype, $ post ['authorid'], $ post ['first']); DZ5.5, locate:
$ Post ['message'] = discuzcode ($ post ['message'], $ post ['smileyoff '], $ post ['bbcodeoff'], $ post ['htmlon'], $ forum ['allowscloud'], $ forum ['allowbucketcodes '], ($ forum ['allowimgcode'] & $ showimages? 1: 0), $ forum ['allowhtml '], ($ forum ['jammer'] & $ post ['authorid']! = $ Discuz_uid? 1: 0), 0, $ post ['authorid']); replace:
$ Post ['message'] = discuzcode ($ post ['message'], $ post ['smileyoff '], $ post ['bbcodeoff'], $ post ['htmlon'], $ forum ['allowscloud'], $ forum ['allowbucketcodes '], ($ forum ['allowimgcode'] & $ showimages? 1: 0), $ forum ['allowhtml '], ($ forum ['jammer'] & $ post ['authorid']! = $ Discuz_uid? 1: 0), 0, $ post ['authorid'], $ post ['first']);
Modify: discuzcode. func. php
Open: include \ discuzcode. func. php
DZ4.1, find:
Function discuzcode ($ message, $ smileyoff, $ bbcodeoff, $ htmlon = 0, $ allowsmilies = 1, $ allowbbcode = 1, $ allowimgcode = 1, $ allowhtml = 0, $ jammer = 0) {replace:
Function discuzcode ($ message, $ smileyoff, $ bbcodeoff, $ htmlon = 0, $ allowsmilies = 1, $ allowbbcode = 1, $ allowimgcode = 1, $ allowhtml = 0, $ jammer = 0, $ first = '0') {Add the following row:
Global $ discuzcodes, $ credits, $ tid, $ discuz_uid, $ highlight, $ maxsmilies, $ db, $ tablepre; replace:
Global $ discuzcodes, $ credits, $ fid, $ tid, $ discuz_uid, $ highlight, $ maxsmilies, $ db, $ tablepre, $ hidemsg, $ hidecut, $ leavemod, $ hidefids;
$ Bbcodeoff = $ hidemsg? '': $ Bbcodeoff; continue to find:
If (preg_match ("/\ [hide =? \ D * \]. +? \ [\/Hide \]/is ", $ message) {replace:
// 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 <strlen ($ message )){
$ Query = $ db-> query ("SELECT pid FROM {$ tablepre} posts WHERE tid = '$ tid' AND authorid =' $ discuz_uid 'LIMIT 1 ");
If ($ GLOBALS ['forum'] ['isderator'] | $ db-> result ($ query, 0 )){
$ Message = '<span class = "bold">'. $ language ['Post _ hide_reply '].' </span> <br/> '.
'=============================< Br/> <br/>'.
$ Message. '<br/> '.
'=============================== ';
} Else {
$ Message = $ hidecut? ($ Hidecut> = strlen ($ message )? $ Message: dhtmlspecialchars (cutstr ($ message, $ hidecut )). '<br/> <B> '. $ language ['Post _ hide_reply_hidden ']. '</B>'): '<B> '. $ language ['Post _ hide_reply_hidden ']. '</B> ';
}
}
} Elseif (! $ Discuz_uid & $ hidemsg = 4 & $ hidecut ){
$ Message = $ hidecut> = strlen ($ message )? $ Message: dhtmlspecialchars (cutstr ($ message, $ hidecut). '<br/>'. $ language ['Post _ hide_limit '];
}
} Elseif (preg_match ("/\ [hide =? \ D * \]. +? \ [\/Hide \]/is ", $ message) {DZ5.0/DZ5.5, locate:
Function discuzcode ($ message, $ smileyoff, $ bbcodeoff, $ htmlon = 0, $ allowsmilies = 1, $ allowbbcode = 1, $ allowimgcode = 1, $ allowhtml = 0, $ jammer = 0, $ parsetype = '0', $ authorid = '0') {replace:
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; replace:
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; replace:
Global $ discuzcodes, $ credits, $ fid, $ tid, $ discuz_uid, $ highlight, $ maxsmilies, $ db, $ tablepre, $ hideattach, $ hidemsg, $ hidecut, $ leavemod, $ hidefids;
$ Bbcodeoff = $ hidemsg? '': $ Bbcodeoff; DZ5.0 continue to find:
If (! In_array ($ parsetype, array (1, 2) & preg_match ("/\ [hide =? \ D * \]. +? \ [\/Hide \]/is ", $ message) {replace:
// 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 <strlen ($ message )){
$ Query = $ db-> query ("SELECT pid FROM {$ tablepre} posts WHERE tid = '$ tid' AND authorid =' $ discuz_uid 'LIMIT 1 ");
If ($ GLOBALS ['forum'] ['isderator'] | $ db-> result ($ query, 0 )){
$ Message = '<span class = "bold">'. $ language ['Post _ hide_reply '].' </span> <br/> '.
'=============================< Br/> <br/>'.
$ Message. '<br/> '.
'=============================== ';
} Else {
$ Message = $ hidecut? ($ Hidecut> = strlen ($ message )? $ Message: dhtmlspecialchars (cutstr ($ message, $ hidecut )). '<br/> <B> '. $ language ['Post _ hide_reply_hidden ']. '</B>'): '<B> '. $ language ['Post _ hide_reply_hidden ']. '</B> ';
}
}
} Elseif (! $ Discuz_uid & $ hidemsg = 4 & $ hidecut ){
$ Message = $ hidecut> = strlen ($ message )? $ Message: dhtmlspecialchars (cutstr ($ message, $ hidecut). '<br/>'. $ language ['Post _ hide_limit '];
}
} Elseif (! In_array ($ parsetype, array (1, 2) & preg_match ("/\ [hide =? \ D * \]. +? \ [\/Hide \]/is ", $ message) {DZ5.5 continue to find:
If ($ parsetype! = 1 & preg_match ("/\ [hide =? \ D * \]. +? \ [\/Hide \]/is ", $ message) {replace:
// 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 <strlen ($ message )){
$ Query = $ db-> query ("SELECT pid FROM {$ tablepre} posts WHERE tid = '$ tid' AND authorid =' $ discuz_uid 'LIMIT 1 ");
If ($ GLOBALS ['forum'] ['isderator'] | $ db-> result ($ query, 0 )){
$ Message = '<span class = "bold">'. $ language ['Post _ hide_reply '].' </span> <br/> '.
'=============================< Br/> <br/>'.
$ Message. '<br/> '.
'=============================== ';
} Else {
$ Message = $ hidecut? ($ Hidecut> = strlen ($ message )? $ Message: dhtmlspecialchars (cutstr ($ message, $ hidecut )). '<br/> <B> '. $ language ['Post _ hide_reply_hidden ']. '</B>'): '<B> '. $ language ['Post _ hide_reply_hidden ']. '</B> ';
}
}
} Elseif (! $ Discuz_uid & $ hidemsg = 4 & $ hidecut ){
$ Message = $ hidecut> = strlen ($ message )? $ Message: dhtmlspecialchars (cutstr ($ message, $ hidecut). '<br/>'. $ language ['Post _ hide_limit '];
}
} Elseif ($ parsetype! = 1 & preg_match ("/\ [hide =? \ D * \]. +? \ [\/Hide \]/is ", $ message )){
Solve code disorder after text truncation (same as DZ4.1/DZ5.0/DZ5.5)
Solution 1 (recommended ):
Select the modified Code from:
// Start with hidemsg by KaijuanStudio:
$ Message = preg_replace ("/\ [hide = (\ d +) \] \ s * (. + ?) \ S * \ [\/hide \]/ies "," creditshide (\ 1, '\ 2') ", $ message );
} All the code at the end, and then move this large piece of code:
If (! $ Bbcodeoff & $ allowbbcode) {in the following line.
This method is the simplest and applicable to forums where HTML code is not enabled. Code such as unclosed code appears at the end of text truncation, such as missing: the content of [/quote], [/url], and [/img] is displayed as code.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.