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 (126)
Released: 10-31-2006, 08: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 11-04-2006, 12:44 PM   #11
vB Newbie
Join Date: Nov 2006
Quarterbore is on a distinguished road

Default

I have got it "almost" working on my site but I need to head out and I will share my changes that seem to be helping:

Here is the code I am using at Global Start:

You must first be a registered member to view any code.
With this change I get some rather interesting behavior that I can't explain yet. When I have my usergroup added to the array and post I get the "No View Notice". When I refresh the notice is still there! When I go into my AdminCP and remove my usergroup from the "hide" array and refresh the code becomes visible.

BUT, when I add the usergroup back to the "hide" array and refresh they can still see the code?

The only other thing I have noticed is that by hitting the quote button it is possible to still read the code :confused:

Last edited by Quarterbore; 11-07-2006 at 11:18 AM..




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

Default

The issue seems to be the post caching. It still caches posts that shouldn't be cached which then stops it from working.




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

Default

Quote:
Originally Posted by SirAdrian View Post
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)
I am fealing pretty dumb but I didn't download this when I had asked... I ahd coded it from your notes as I really am a NewBie here I guess!

I still didn't get this working BUT I did do the download at least!




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

Default

Quote:
Originally Posted by rogersnm View Post
The issue seems to be the post caching. It still caches posts that shouldn't be cached which then stops it from working.
Are you using lowercase code/php/html tags? Use the download - not the code in the post because that has been slightly modified due to vBulletin barfing when you use [code] inside other tags.

Quarterbore, does the download work for you? Try changing your code to this
You must first be a registered member to view any code.




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 11-05-2006, 06:19 AM   #15
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 used the download before, tried it, fiddled with it, kept fiddling with it. And then gave up and went home.




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

Default

Yea, I did the same.

I am busy with another project but when I get a chance I will be back to try to figure this out as I really could use this!

Last edited by Quarterbore; 11-07-2006 at 11:19 AM..




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 12-10-2006, 04:58 AM   #17
Michael Biddle
Staff
Michael Biddle's Avatar
Join Date: Feb 2005
Real Name: Michael Biddle
Location: Anaheim
Michael Biddle is on a distinguished road

Default

greaty tut bro
__________________
Support will ONLY be offered through forums
Michael Biddle / 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 12-10-2006, 09:21 AM   #18
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 couldn't get it to work for the life of me, I just used a bit of regex in the end.




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 12-10-2006, 02:40 PM   #19
Coder
SirAdrian's Avatar
Join Date: Jun 2006
SirAdrian is on a distinguished road

Default

If you don't mind helping me debug it later on your board we can get it working. I'm sure a few others have had the same problem as you...

Anyway, it's working for me, and that was my goal (not to be selfish). I heard you are going to be writing your own? Fine with me, all I care about is the final result, and this seems to be quite a popular problem for coding boards. I actually originally had this working with a preg_replace, but that wasn't ideal for the HTML and Code tags, only the PHP one (but you can fix that by just editing the darn templates).




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

Default

Well I wasn't planning on releasing it. And no I don't mind at all. The only thing that seems to be wrong with it is it insists on caching the posts even when it's been told not to xD




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 02:54 AM
Suche - CODE PHP und HTML nur für Member - my-vB - Addons & Styles - MADE IN GERMANY This thread Refback 12-03-2006 05:29 PM
Suche - CODE PHP und HTML nur für Member - my-vB - Addons & Styles - MADE IN GERMANY This thread Refback 12-03-2006 05: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 10:39 AM
search hide hack code for VBB 3.5.4 brianvu vBulletin Modification Requests 10 05-07-2006 07:43 AM
hide urls code qoute from guset netzoner vBulletin Modification Requests 0 11-11-2005 09:35 AM


All times are GMT -3. The time now is 11:38 PM.

Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 ©2008, Crawlability, Inc. (Patent Pending)