vBulletin Modifications

Mini Mods - Hide Code From Usergroups

Welcome to vBHackers.com! - vBHackers Updates:

Go Back   vBulletin Modifications > vBulletin Database System > vBulletin 3.5 / 3.6 Hack Releases

Reply
 
Thread Tools Search this Thread
Download Options
You Must Register First
To Download This Modification

Bugs
No bugs found in the system. If you have found a bug, please report a bug here
Submit A Bug | View All Bugs

Advertisement
  
Supported
[vB 3.6.2] Mini Mods - Hide Code From Usergroups (125)
Released: 10-31-2006, 07:36 PM
Modification Information:
SirAdrian's Avatar Author: SirAdrian
Last Online: 05-18-2008
Demo: View Online Demo!
Hack Version: 1.0 Installer Included: 1 Additional queries added to database: 0
New Templates: 0 Template Edits: 6 File Edits: 0
New Files: 2 New Phrases: 1 Installation Time (In Minutes): 1

vB 3.6.0 Compatible!
Extension
Description:
This hack will allow you to specify which usergroups can view "code" (PHP, HTML and CODE bbCodes).

To Install:
Read the supplied install instructions. Even though there are 6 template edits, they are done automatically. Posts you have already made that contain code in them will NOT show the changes because they are already cached. You have a few options with this:
  • Delete them from the postparsed table
  • Rebuild post cache from AdminCP
  • Edit them so it rebuilds

How it works:

vBulletin caches posts. What this means is, instead of parsing the bbCode templates each time, it will do it once per style and store the output in the database. This completely kills any chance you have of putting usergroup conditions inside of these templates.

The first step was to prevent vBulletin from caching posts which contain these tags, so in the showthread_postbit_create hook, I created the following plugin
You must first be a registered member to view any code.
vBulletin has the variable "$post_cachable" which basically checks for the whole thread(!) if posts are cachable. Not very helpful to us... So this plugin first makes a new variable ($posts_cachable) and sets it to whatever the $post_cachable variable is set to. Only once.

The next block uses the ternary operator (cleaner to read for me) and basically checks if those 3 bbcodes are found in the currently processing post. If any are found, it will set the $post_cachable variable to false so it will bypass the caching procedure for this post. If none of the 3 are found, it will fall back to that other variable I created (the original value of $post_cachable).

I am checking if it exists inside the post by using the strpos() function, which returns the position of the needle inside the haystack if it is found (integer) or FALSE if it isn't. We can't use a single if (!...) check because it may return 0 if its at the very beginning which evaulates to false. So we can check if not exactly equal to false by using !==

Note that I'm not using strstr() because this is much faster. This could could probably be improved using a regular expression or another function, because it's case sensitive.

The next step was to determine who can view the code. Using the global_start hook, I created the following plugin:
You must first be a registered member to view any code.
Since we only want this to run when the admin has entered any usergroups, we will wrap it inside an if so this happens. Using the explode() function we can convert the space-seperated-list into an array, which is must easier to work with. Now that we have an array, we can vBulletin's is_member_of() function which returns TRUE if you are a primary or secondary member of any of the groups, and FALSE if you aren't. Since I put a ! (NOT) in front of the function, it will return the opposite. I am setting the variable $show['hidecode'] to the return value of that whole statement, which in this case is TRUE if the code should be hidden (if you aren't in the usergroups) and FALSE if you can see it.

Finally, in all of the templates (the edits were done automatically), each $code variable is replaced with
You must first be a registered member to view any code.
which would check the variable to see if they can see it before attempting to show them anything.




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Add a Comment!
Old 10-31-2006, 09:48 PM   #2
Ken Iovino
Founder
Ken Iovino's Avatar
Join Date: Mar 2004
Real Name: Ken Iovino
Location: Miami, Florida
Ken Iovino is on a distinguished road

Default

A very handy hack. Thanks for releasing it.
__________________
Earnersforum.com - Learn how to make money online! New Look!

Ken Iovino / vBHackers.com
vBSEO 3.2.0 Launched - Maximum Overdrive for Your Web Traffic! Over 100 Instant SEO Optimizations

vBSEO Google Sitemap Generator - Version 2.2 Released Mandatory Upgrade for vBSEO 3.2.0 GOLD

6X Traffic - $1400 in One Day with vBSEO! Imagine What the vBSEO Patent Pending Technology Can Do For You.

Crawlability Network: vBulletin SEO | vBulletin Hackers




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 11-01-2006, 12:22 AM   #3
Joe Ward
Administrator
Joe Ward's Avatar
Join Date: Aug 2005
Joe Ward has disabled reputation

Default

Excellent. Great description.
__________________
Joe Ward / vBHackers.com
vBSEO 3.2.0 Launched - Maximum Overdrive for Your Web Traffic! Over 100 Instant SEO Optimizations

vBSEO Google Sitemap Generator - Version 2.2 Released Mandatory Upgrade for vBSEO 3.2.0 GOLD

6X Traffic - $1400 in One Day with vBSEO! Imagine What the vBSEO Patent Pending Technology Can Do For You.

Crawlability Network: vBulletin SEO | vBulletin Hackers




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 11-02-2006, 01:25 AM   #4
vB Newbie
Join Date: Jul 2006
sinister is on a distinguished road

Default

Mod nice ... I like it ... Install




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 11-03-2006, 04:30 PM   #5
vB Newbie
Join Date: Nov 2006
plop69 is on a distinguished road

Default

o is so nice




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 11-03-2006, 05:04 PM   #6
Coder
SirAdrian's Avatar
Join Date: Jun 2006
SirAdrian is on a distinguished road

Default

Glad to hear it...

I will hopefully get a chance to release an update within a week or two with some "side-effects" I've found. Nothing major though.

Last edited by SirAdrian; 11-04-2006 at 02:02 AM.




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 11-04-2006, 03:22 AM   #7
vB Newbie
Join Date: Nov 2006
Quarterbore is on a distinguished road

Default

Quote:
Originally Posted by SirAdrian View Post

Finally, in all of the templates (the edits were done automatically), each $code variable is replaced with
You must first be a registered member to view any code.
which would check the variable to see if they can see it before attempting to show them anything.
Thank You for sharing this and it explains my insanity trying to code this myself!

I noticed something VERY strange in vBulletin 3.6.2 that when I did a search for all templates to do the find and replace as in the quote that $code was not visable! It looks like vBulletin 3.6.2 is trying to display the value of the variable.

So, I hand coded the changes to be safe. The templates that this variable is used in includes the following:

bbcode_code
bbcode_code_printable
bbcode_html
bbcode_html_printable
bbcode_php
bbcode_php_printable

Now, I have a silly question but how do I add a setting for "hidecode_groups"? I could write a small product file to do it but I have never learned where or how to do this inside vBulletinvisible. (or am I supposed to use phpMyAdmin or similar)?

EDIT - OK, now that was cool!

I figured out that by turning on DeBug mode that I gain new features in my vBulletin Options including the option to make a new group. To think I was writing product files to do this!

Last edited by Quarterbore; 11-04-2006 at 03:29 AM.




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 11-04-2006, 04:13 AM   #8
Coder
SirAdrian's Avatar
Join Date: Jun 2006
SirAdrian is on a distinguished road

Default

The installer script *should* have edited those for you (style 1 by default). But yeah - I would imagine quote not to have it because its not really "code".

lol you learn something new every day - I remember when I discovered how easy it was to create options and what not (compared to 3.0.x)




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 11-04-2006, 10:48 AM   #9
vBulletin Guru
Nick R's Avatar
Join Date: May 2006
Real Name: Nick
Location: Cyberspace, UK
Nick R is on a distinguished road

Default

I tried to get this to work but couldn't for the life of me. I ended up just doing a simple edit in each of the templates and getting rid of the rest of the code. Nice hack but appears not to work in 3.6.0.




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 11-04-2006, 11:13 AM   #10
vB Newbie
Join Date: Nov 2006
Quarterbore is on a distinguished road

Default

I spent all night working with this in vBulletin 3.6.2. and I just can't quite get it to work either. It is really close but they changed something in the code or I am not doing something quite right.

With the code changes I always get the "No Permissions" message regardless to what usergroups I list in the settings array.

I also did a test by posting with both plugins on and getting my "no permssions" message. When I refresh I get the same "notice". Then, I went into the AdminCP and I turned off the pluggin on global start and refreshed the thread. I still got the same "No-Permissions" message. This tells me that I have a couple problems.

1st, I should not have been hidden from seeing the code (my usergroup was no in the list)
2nd, the posts are getting cached

I am still trying to figure it out and I will post if I get this to work.




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



LinkBacks (?)
LinkBack to this Thread: http://www.vbhackers.com/f76/mini-mods-hide-code-usergroups-5884/
Posted By For Type Date
Suche - CODE PHP und HTML nur für Member - my-vB - Addons & Styles - MADE IN GERMANY This thread Refback 12-04-2006 01:54 AM
Suche - CODE PHP und HTML nur für Member - my-vB - Addons & Styles - MADE IN GERMANY This thread Refback 12-03-2006 04:29 PM
Suche - CODE PHP und HTML nur für Member - my-vB - Addons & Styles - MADE IN GERMANY This thread Refback 12-03-2006 04:24 PM

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
User Cp Critical Error Nick R Site Feedback 6 08-03-2006 09:39 AM
search hide hack code for VBB 3.5.4 brianvu vBulletin Modification Requests 10 05-07-2006 06:43 AM
hide urls code qoute from guset netzoner vBulletin Modification Requests 0 11-11-2005 08:35 AM


All times are GMT -3. The time now is 06:37 AM.


SEO by vBSEO 3.2.0 ©2008, Crawlability, Inc. (Patent Pending)