Discuz two times Development discuz! plugin: auto-hide post 1th 2 page

Source: Internet
Author: User
Tags php switch
Objective
Should one netizen request the open-book studio to make this auto-hide post plug-in, the main purpose is not to manually add the [hide] code, then automatically hide all posts posted content, members need to reply before you can browse the post. The idea is pretty good, and it's not hard to do that, so help out. Plug-ins offer two auto-hide modes, one that hides only the first-floor posts, and hides all posts, including replies. Because adhering to the open-book Studio Green plug-in style, can not change the database is not changed, so this plug-in does not increase the background switch function, and only provide config.inc.php switch settings.
This plugin is suitable for discuz! All editions of the forum, but here only to provide dz4.1/dz5.0/dz5.5 installation methods, other versions of the Forum please refer to the self-modification.
Update record:
2007-01-25 Fix the issue that does not contain forum code, add to hide all posts except the first floor settings, add preview byte settings, set up to preview some of the hidden post content, so that the content of good posts to attract more people to participate in the reply and add settings to customize which forums turn on the auto-hide feature.
2007-01-27 increased access to visitors only part of the content of the settings, the effect is as follows:
Sorry, your current status is visitors, so you can only read part of the content. To read the full content please: Sign up or sign in.
2007-01-28 correction announcements and short messages will also be automatically hidden, as well as errors due to the lack of variables; Add customizable settings that allow or exclude the auto-hide feature of the specified forum; provide two solutions to solve the problem of page code confusion after text truncation, you can choose to use according to your own situation.
2007-02-04 increased compatibility changes with interference codes.
2007-03-14 increased the installation method of discuz!5.5 and tested successfully.
Name: Open-book Studio Auto-hide post [enhanced] for discuz! All Version
Difficulty: General
Applicable version: discuz! all versions
Author: Kaijuanstudio
Release Date: 2006-11-07
Update on: 2007-03-14
Publishing site: China Manufacturing Forum
Technical Support: http://madeinchn.cn/thread-4-13016-1-1.htm
The installation method is as follows:
Modified: viewthread.php
Open: viewthread.php
DZ4.1, find:
$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)); Replace with:
$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 ']);D Z5.0, find:
$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 ']), replaced by:
$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 ']);D Z5.5, find:
$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 ']), replaced by:
$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 '];
Modified: 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) {Replaced by:
function Discuzcode ($message, $smileyoff, $bbcodeoff, $htmlon = 0, $allowsmilies = 1, $allowbbcode = 1, $allowimgcode = 1, $allowhtml = 0, $jammer = 0, $first = ' 0 ') {then the following line:
Global $discuzcodes, $credits, $tid, $discuz _uid, $highlight, $maxsmilies, $db, $tablepre; replaced by:
Global $discuzcodes, $credits, $fid, $tid, $discuz _uid, $highlight, $maxsmilies, $db, $tablepre, $hidemsg, $hidecut, $leav Emod, $hidefids;
$bbcodeoff = $hidemsg? ": $bbcodeoff; continue to find:
if (Preg_match ("/\[hide=?\d*\].+?\[\/hide\]/is", $message)) {Replace with:
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 '] [' 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, found:
function Discuzcode ($message, $smileyoff, $bbcodeoff, $htmlon = 0, $allowsmilies = 1, $allowbbcode = 1, $allowimgcode = 1, $allowhtml = 0, $jammer = 0, $parsetype = ' 0 ', $authorid = ' 0 ') {replaced by:
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 The following line again:
Global $discuzcodes, $credits, $tid, $discuz _uid, $highlight, $maxsmilies, $db, $tablepre; replaced by:
Global $discuzcodes, $credits, $fid, $tid, $discuz _uid, $highlight, $maxsmilies, $db, $tablepre, $hidemsg, $hidecut, $leav Emod, $hidefids;
$bbcodeoff = $hidemsg? ": $bbcodeoff;D Z5.5 will be the following line:
Global $discuzcodes, $credits, $tid, $discuz _uid, $highlight, $maxsmilies, $db, $tablepre, $hideattach; replaced by:
Global $discuzcodes, $credits, $fid, $tid, $discuz _uid, $highlight, $maxsmilies, $db, $tablepre, $hideattach, $hidemsg, $h Idecut, $leavemod, $hidefids;
$bbcodeoff = $hidemsg? ": $bbcodeoff;D Z5.0 continue to find:
if (!in_array ($parsetype, Array (1, 2)) && Preg_match ("/\[hide=?\d*\].+?\[\/hide\]/is", $message)) {Replace with:
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 '] [' 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 Continue to find:
if ($parsetype! = 1 && preg_match ("/\[hide=?\d*\].+?\[\/hide\]/is", $message)) {Replace with:
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 '] [' 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)) {
Troubleshoot code confusion after text truncation (dz4.1/dz5.0/dz5.5 same)
Workaround One (recommended):
Put the modified code above, select from:
Hidemsg by Kaijuanstudio begins, until:
$message = Preg_replace ("/\[hide= (\d+) \]\s* (. +?) \s*\[\/hide\]/ies "," Creditshide (\\1, ' \\2 ') ", $message);
} to the end of the code, and then move this large piece of code to:
if (! $bbcodeoff && $allowbbcode) {in the following line.
This is the simplest approach for a forum where HTML code is not enabled, and for text truncation at the end of a code such as no closure, such as missing: [/quote], [/url], [/img] content, will be displayed in code.

Current 1/2 Page 12 next page

The above describes the Discuz two times the development of discuz! plug-ins: Automatically hide posts 1th/2 pages, including the Discuz two development aspects, I hope to be interested in PHP tutorial friends helpful.

  • 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.