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 12-11-2006, 10:45 AM   #21
vB Newbie
Join Date: Nov 2006
Quarterbore is on a distinguished road

Default

Quote:
Originally Posted by rogersnm View Post
I couldn't get it to work for the life of me, I just used a bit of regex in the end.
I would really like your help with your solution! Heck, I'll give you $30 if you can help me get this to work as I need to figure this out and like you said I can not get my forum code not to cache the threads and posts! I just need a head start and I can do the coding!

E-mail me if you are intersted in the $30 and I will paypal you as soon as I can get it working... I spent too much time on getting this to work already so I really am despirate!

quarterbore@yahoo.com

I won't be rereleasing, I need it for a couple projects where I want to allow paid customers to get access to hacks but non-customers should not be able to see them!
__________________
vbClassified.com




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
Old 03-03-2007, 08:16 PM   #22
vB User
Join Date: Nov 2006
bartek24m is on a distinguished road

Default

i have a little problem with hack
i cant add product

Importing Product, Proszę czekać...

[:]
Database Error Database error
The Clubbers' Forum database has encountered a problem.
Please try the following:

* Load the page again by clicking the Refresh button in your web browser.
* Open the www.forum home page, then try to open another page.
* Click the Back button to try another link.

The www.forum forum technical staff have been notified of the error, though you may contact them if the problem persists.

We apologise for any inconvenience.

Quote:
Database error in vBulletin 3.6.3:

Invalid SQL:

INSERT INTO template
(`styleid`, `version`, `title`, `templatetype`, `product`, `template`, `template_un`)
VALUES (1, '', 'bbcode_code', 'template', 'vbulletin', '<div style=\\\"margin:20px; margin-top:5px\\\">\r\n <div class=\\\"smallfont\\\" style=\\\"margin-bottom:2px\\\">$vbphrase[code]:</div>\r\n <pre class=\\\"alt2\\\" style=\\\"margin:0px; padding:$stylevar[cellpadding]px; border:1px inset; width:$stylevar[codeblockwidth]; height:{$blockheight}px; overflow:auto\\\"><div dir=\\\"ltr\\\" style=\\\"text-align:left;\\\">$code</div></pre>\r\n</div>', '<div style=\"margin:20px; margin-top:5px\">\r\n <div class=\"smallfont\" style=\"margin-bottom:2px\">$vbphrase[code]:</div>\r\n <pre class=\"alt2\" style=\"margin:0px; padding:$stylevar[cellpadding]px; border:1px inset; width:$stylevar[codeblockwidth]; height:{$blockheight}px; overflow:auto\"><div dir=\"ltr\" style=\"text-align:left;\">$code</div></pre>\r\n</div>');

MySQL Error : Duplicate entry 'bbcode_code-1' for key 2
Error Number : 1062
Date : Sunday, March 4th 2007 @ 01:13:07 AM
Script : http://www.forum.pl/admincp/plugin.php?do=productimport
Referrer : http://www.forum.pl/admincp/plugin.php?do=productadd
IP Address :
Username : Bartek
Classname : vb_database




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 03-05-2007, 01:43 PM   #23
Junior Member
Join Date: Oct 2005
Nneel is on a distinguished road

Default

nice...any one help me
to hide
[img]....[/img] code from guest ?




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 05-29-2007, 06:17 AM   #24
vB User
Join Date: Aug 2006
Cobra SA is on a distinguished road

Default

I need this hack so badly but it didn't work at all for me.
Do you plan on fixing it?




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 08-11-2007, 06:20 PM   #25
vB Newbie
Join Date: Aug 2007
framecode is on a distinguished road

Default

Anyone able to update this for 2.6.8?




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 11-01-2007, 06:15 PM   #26
vB Newbie
Join Date: Mar 2007
flvfiles is on a distinguished road

Default

this hack doesn't work on my forum I use vbulletin 3.6.8




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 11:02 PM.


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