vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 4.x Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=245)
-   -   BB Code Enhancements - Hide [code],[html],[php] BBCode from Unregistered/Unverified (https://vborg.vbsupport.ru/showthread.php?t=319095)

Kelvin Yong 06-15-2015 09:00 PM

Hide [code],[html],[php] BBCode from Unregistered/Unverified
 
1 Attachment(s)
I have searched for such mod on the forums and couldn't find a fully functional one - either due to post cache issue or etc.

I have created something similar and fully functional without any cache issue based on kh99's (moderator at vb.org) idea. This is my first release on this forum so hope that you guys don't go hard on me.



Features:
  • Hide [code], [html] and [php] from Unregistered/Unverified account.
  • Works on all normal postbit, printable view & mobile style.

Installation:
1) Go to AdminCP -> Styles & Templates -> Style Manager -> *PRIMARY PARENT STYLE* -> Expand Template
2) Select BB Code Layout Templates -> Replace bbcode_code with the following:

HTML Code:

<!-- START PRIVATE BBCODE -->
<div class="bbcode_container">
        <div class="bbcode_description">{vb:rawphrase code}:</div>
        <pre class="bbcode_code"<vb:if condition="$vboptions['codemaxlines']"> style="height:<vb:if condition="$blockheight<$vboptions['codemaxlines']">{vb:math {vb:raw blockheight}*{vb:stylevar mid_fontSize}+{vb:stylevar mid_fontSize}*2}<vb:else />{vb:math {vb:raw blockheight}*{vb:stylevar mid_fontSize}+{vb:stylevar mid_fontSize}}</vb:if>;"</vb:if>>{vb:raw code}</pre>
</div>
<!-- END PRIVATE BBCODE -->

3) Replace bbcode_code_printable with the following:

HTML Code:

<!-- START PRIVATE P_BBCODE -->
<div class="bbcode_container">
        <div class="bbcode_description">{vb:rawphrase code}:</div>
        <hr /><code class="bbcode_code">{vb:raw code}</code><hr />
</div>
<!-- END PRIVATE P_BBCODE -->

4) Replace bbcode_html with the following:

HTML Code:

<!-- START PRIVATE BBCODE -->
<div class="bbcode_container">
        <div class="bbcode_description">{vb:rawphrase html_code}:</div>
        <pre class="bbcode_code"<vb:if condition="$vboptions['codemaxlines']"> style="height:<vb:if condition="$blockheight<=$vboptions['codemaxlines']">{vb:math {vb:math {vb:raw blockheight}+2}}*{vb:stylevar mid_fontSize}}<vb:else />{vb:math {vb:math {vb:raw blockheight}+1}*{vb:stylevar mid_fontSize}}</vb:if>;"</vb:if>>{vb:raw code}</pre>
</div>
<!-- END PRIVATE BBCODE -->

5) Replace bbcode_html_printable with the following:

HTML Code:

<!-- START PRIVATE P_BBCODE -->
<div class="bbcode_container">
        <div class="bbcode_description">{vb:rawphrase html_code}:</div>
        <hr /><code class="bbcode_code">{vb:raw code}</code><hr />
</div>
<!-- END PRIVATE P_BBCODE -->

6) Replace bbcode_php with the following:

HTML Code:

<!-- START PRIVATE BBCODE -->
<div class="bbcode_container">
        <div class="bbcode_description">{vb:rawphrase php_code}:</div>
        <div class="bbcode_code"<vb:if condition="$vboptions['codemaxlines']"> style="height:<vb:if condition="$blockheight<$vboptions['codemaxlines']">{vb:math {vb:raw blockheight}*{vb:stylevar mid_fontSize}+{vb:stylevar mid_fontSize}*2}<vb:else />{vb:math {vb:raw blockheight}*{vb:stylevar mid_fontSize}+{vb:stylevar mid_fontSize}}</vb:if>;"</vb:if>><code>{vb:raw code}</code></div>
</div>
<!-- END PRIVATE BBCODE -->

7) Replace bbcode_php_printable with the following:

HTML Code:

<!-- START PRIVATE P_BBCODE -->
<div class="bbcode_container">
        <div class="bbcode_description">{vb:rawphrase php_code}:</div>
        <hr /><code class="bbcode_code">{vb:raw code}</code><hr />
</div>
<!-- END PRIVATE P_BBCODE -->

8) Select *PRIMARY MOBILE STYLE* -> Expand Template -> BB Code Layout Templates
9) Replace bbcode_code with the following:

HTML Code:

<!-- START PRIVATE M_BBCODE -->
<div class="bbcode_container">
        <div class="bbcode_description">{vb:rawphrase code}: [<a href="#" class="view">{vb:rawphrase view}</a>]</div>
        <pre class="bbcode_code">{vb:raw code}</pre>
</div>
<!-- END PRIVATE M_BBCODE -->

10) Replace bbcode_html with the following:

HTML Code:

<!-- START PRIVATE M_BBCODE -->
<div class="bbcode_container">
        <div class="bbcode_description">{vb:rawphrase html_code}: [<a href="#" class="view">{vb:rawphrase view}</a>]</div>
        <pre class="bbcode_code">{vb:raw code}</pre>
</div>
<!-- END PRIVATE M_BBCODE -->

11) Replace bbcode_php with the following:

HTML Code:

<!-- START PRIVATE M_BBCODE -->
<div class="bbcode_container">
        <div class="bbcode_description">{vb:rawphrase php_code}: [<a href="#" class="view">{vb:rawphrase view}</a>]</div>
        <div class="bbcode_code"><code>{vb:raw code}</code></div>
</div>
<!-- END PRIVATE M_BBCODE -->

12) Now we're done with the template modification, we'll now move on to plugin.
13) Select Plugins & Products -> Add New Plugin for the normal postbit with the following:

PHP Code:

ProductvBulletin
Hook Location
postbit_display_complete
Title
: Private BBCode Unregistered/Unverified
Plugin PHP Code
:

global 
$vbulletin;

static 
$unregistered_code_replacement '
    <div class="bbcode_container">
        <div class="bbcode_description" style="padding-bottom: 2px;"><b>Block Disabled:</b> please <a href="register.php">register</a> or <a href="#login-box" class="login-window">login</a> to view this content.</div>
        <pre class="bbcode_code">Unregistered or guests cannot view this content.</pre>
    </div>'
;
static 
$unverified_code_replacement '
    <div class="bbcode_container">
        <div class="bbcode_description" style="padding-bottom: 2px;"><b>Block Disabled:</b> request <a href="register.php?do=requestemail">activation</a> or <a href="sendmessage.php">contact us</a></div>
        <pre class="bbcode_code">Unverified account cannot view this content.</pre>
    </div>'
;

if (
is_member_of($vbulletin->userinfo1)) {
    
$post['message'] = preg_replace('#<!-- START PRIVATE BBCODE -->.*?<!-- END PRIVATE BBCODE -->#s'$unregistered_code_replacement$post['message']);
}
if (
is_member_of($vbulletin->userinfo34)) {
    
$post['message'] = preg_replace('#<!-- START PRIVATE BBCODE -->.*?<!-- END PRIVATE BBCODE -->#s'$unverified_code_replacement$post['message']);


14) Add New Plugin for the mobile style with the following:

PHP Code:

ProductvBulletin
Hook Location
postbit_display_complete
Title
: Private BBCode Unregistered/Unverified (M)
Plugin PHP Code:

global 
$vbulletin;

static 
$unregistered_code_replacement '
    <div class="bbcode_container">
        <div class="bbcode_description" style="padding-bottom: 2px;"><b>Block Disabled:</b> [<a href="#" class="view">View</a>]</div>
        <pre class="bbcode_code">Unregistered or guests cannot view this content.</pre>
    </div>'
;
static 
$unverified_code_replacement '
    <div class="bbcode_container">
        <div class="bbcode_description" style="padding-bottom: 2px;"><b>Block Disabled:</b> [<a href="#" class="view">View</a>]</div>
        <pre class="bbcode_code">Unverified account cannot view this content.</pre>
    </div>'
;

if (
is_member_of($vbulletin->userinfo1)) {
    
$post['message'] = preg_replace('#<!-- START PRIVATE M_BBCODE -->.*?<!-- END PRIVATE M_BBCODE -->#s'$unregistered_code_replacement$post['message']);
}
if (
is_member_of($vbulletin->userinfo34)) {
    
$post['message'] = preg_replace('#<!-- START PRIVATE M_BBCODE -->.*?<!-- END PRIVATE M_BBCODE -->#s'$unverified_code_replacement$post['message']);


14) Add New Plugin for the printable view with the following:

PHP Code:

ProductvBulletin
Hook Location
printthread_post
Title
: Private BBCode Unregistered/Unverified (P)
Plugin PHP Code:

global 
$vbulletin;

static 
$unregistered_code_replacement '
    <div class="bbcode_container">
        <div class="bbcode_description" style="padding-bottom: 2px;"><b>Block Disabled:</b></div>
        <hr /><code class="bbcode_code">Unregistered or guests cannot view this content.</code><hr />
    </div>'
;
static 
$unverified_code_replacement '
    <div class="bbcode_container">
        <div class="bbcode_description" style="padding-bottom: 2px;"><b>Block Disabled:</b></div>
        <hr /><code class="bbcode_code">Unverified account cannot view this content.</code><hr />
    </div>'
;

if (
is_member_of($vbulletin->userinfo1)) {
    
$post['message'] = preg_replace('#<!-- START PRIVATE P_BBCODE -->.*?<!-- END PRIVATE P_BBCODE -->#s'$unregistered_code_replacement$post['message']);
}
if (
is_member_of($vbulletin->userinfo34)) {
    
$post['message'] = preg_replace('#<!-- START PRIVATE P_BBCODE -->.*?<!-- END PRIVATE P_BBCODE -->#s'$unverified_code_replacement$post['message']);


15) DONE.

Now the [code],[html],[php] BBCode should be hidden from unregistered and unverified accounts - of course, feel free to alter the codes above to match your needs.

Have a great day.

Golzarion 07-19-2015 05:19 PM

Nice work !

Raptor 07-19-2015 06:03 PM

I found this works much better - a simple plugin - works with all custom bbcodes, signatures and usergroups too

https://vborg.vbsupport.ru/showthread.php?t=318467

friendlymela 10-08-2015 08:20 AM

how should i can hide keywords


All times are GMT. The time now is 02:32 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01069 seconds
  • Memory Usage 1,782KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (9)bbcode_html_printable
  • (3)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete