View Full Version : bb code modification
hello,
here's one for you. i'd like to have a bb-code which works like this:
this text won't appear to guests even if they are allowed to view a thread
i think the bb code speaks for itself. the idea is to have a bb code which hides text or pictures and anything within the text to guests. i think thats not possible with just adding a complicated bb-code in the bb-code manager.
i hope that someone else also finds this useful and is encouraged to make a modification for it. if it is possible without modifying any code or if there already is a hack, please tell me where to find it. thanks a lot. :)
ps: would be cool instead of displaying nothing to guests showing text telling them to register to view the hidden message.
Marco van Herwaarden
01-26-2005, 01:36 PM
Just a quick solution, not tested!!!
Open file includes/functions_bbcodeparse.php.
Find:
// ###################### Start bbcodehandler_code #######################
function handle_bbcode_code($code)
{
Add before:
// ###################### Start bbcodehandler_noguest #######################
function handle_bbcode_noguest($code)
{
global $bbuserinfo;
// remove empty codes
if (trim($code) == '')
{
return '';
}
if ($bbuserinfo['userid'] == 0) // Guest
{
return "Sorry this text is not viewable by guests.";
}
else
{
return $code;
}
}
In the same file find:
// [U]
$bbcodes['standard']['find']['[u]'] = '#\[u\](.*)\[/u\]#esiU';
$bbcodes['standard']['replace']['[u]'] = "handle_bbcode_parameter('\\1','" . str_replace("'", "\'", '<u>\1</u>') . "')";
$bbcodes['standard']['recurse']['u'][0] = array('replace' => 'u');
Add After:
//[NOGUEST]
$bbcodes['custom']['find']['[noguest]'] = '#\[noguest\](.*)\[/noguest\]#esiU';
$bbcodes['custom']['replace']['[noguest]'] = "handle_bbcode_noguest('\\1')";
$bbcodes['custom']['recurse']['noguest'][0] = array('handler' => 'handle_bbcode_noguest');
This should do the trick.
Colin F
01-26-2005, 01:40 PM
hello,
here's one for you. i'd like to have a bb-code which works like this:
this text won't appear to guests even if they are allowed to view a thread
i think the bb code speaks for itself. the idea is to have a bb code which hides text or pictures and anything within the text to guests. i think thats not possible with just adding a complicated bb-code in the bb-code manager.
i hope that someone else also finds this useful and is encouraged to make a modification for it. if it is possible without modifying any code or if there already is a hack, please tell me where to find it. thanks a lot. :)
ps: would be cool instead of displaying nothing to guests showing text telling them to register to view the hidden message.
Interesting idea, but I have no idea how something like this would be done.
Edit: now that I think about it, I do... have a look at the hide hacks floating around. What you want to do should be rather similiar, except that it's a different condition.
Marco van Herwaarden
01-26-2005, 01:58 PM
No need to think Colin, just read back :D
wow. thanks a lot! :) works perfectly fine! you may want to publish it as a hack! i like it!
and thanks colin too for being helpful. :)
Marco van Herwaarden
01-26-2005, 03:08 PM
wow. thanks a lot! :) works perfectly fine! you may want to publish it as a hack! i like it!
and thanks colin too for being helpful. :)
Done :D
Andreas
01-26-2005, 03:10 PM
Hmm, I wonder if this won't cause problems with the postcache ...
Marco van Herwaarden
01-26-2005, 03:12 PM
Why would it Kirby?
Am i missing something?
Andreas
01-26-2005, 03:20 PM
In function parse_bbcode()
if (!empty($parsedtext))
{
if ($parsedhasimages)
{
return handle_bbcode_img($parsedtext, $dobbimagecode);
}
else
{
return $parsedtext;
}
}
If I am right, parse_bbcode2() won't be called if there is a cached parsed post?
of what kind of problems are you talking about? :)
Andreas
01-26-2005, 03:46 PM
If I am correct:
Guest is first to see Post => will be parsed as "Guests can't see this" => will be cached
Member is viewing this post => post is in parsed postcache => will not be parsed => Member will see "Guests can't see this"
Or the other way round.
i dont know if i understand what you said but what about this:
when i log out and i am a "guest" i see the notice "You are a guest....".
if i log in again, i see the actual content. or do you mean something different? if you do, you better talk to someone with a little more knowledge than me. :D
Andreas
01-26-2005, 04:38 PM
Vielleicht ist es auf Deutsch einfacher ;)
Der von Marco vorgestellte Code wird beim parsen von Beitr?gen (in der Funktion parse_bbcode2()) ausgef?hrt.
Nun gibt es aber einen Cache, damit nicht bei jedem Threadaufruf jeder Beitrag neu geparsed (BBCode in HTML ungewandelt) werden muss.
Liegt ein Beitrag in geparster Form im Cache vor, so wird dieser zur Anzeige verwendet und nicht neu geparsed - das kann einiges an CPU einsparen.
Und genau das ist das Problem: Im Cache steht dann halt entweder die Version f?r G?ste, oder die f?r Benutzer (je nachdem welche drin gelandet ist), beim n?chsten Aufruf des Threads erfolgt da kein Update.
Geh mal in vBulletin / Servereinstellungen & Optimierungen und schau mal was da f?r Lebensdauer gecachter Beitr?ge eingestellt ist.
Wenn da was anderes als 0 steht d?rfte dieses Verhalten zu beobachten seiin, andernfalls habe ich mich get?uscht.
@others
Sorry for speaking german ;)
This is basically just what I tried to explain 2 posts above
thanks a lot und dankesch?n. :D
i think i now understood what you tried to explain to me. and yes, i got a 0 in "chached posts lifespan" so this means the hack works for me... i think.
maybe this should be added to the hack itself in the subforum.
Marco van Herwaarden
01-27-2005, 12:43 PM
To solve the potential problems mentioned in this thread, a new version of this hack can be found at: https://vborg.vbsupport.ru/showthread.php?t=75228
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.