vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   bb code modification (https://vborg.vbsupport.ru/showthread.php?t=74940)

rin 01-23-2005 05:37 PM

bb code modification
 
hello,

here's one for you. i'd like to have a bb-code which works like this:

[noguest]this text won't appear to guests even if they are allowed to view a thread[/noguest]

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.

rin 01-25-2005 06:58 AM

anyone? :)

rin 01-26-2005 12:52 PM

tralalala.

Marco van Herwaarden 01-26-2005 01:36 PM

Just a quick solution, not tested!!!

Open file includes/functions_bbcodeparse.php.

Find:
PHP Code:

// ###################### Start bbcodehandler_code #######################
function handle_bbcode_code($code)


Add before:
PHP Code:

// ###################### 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:
PHP Code:

        // [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:
PHP Code:

        //[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

Quote:

Originally Posted by rin
hello,

here's one for you. i'd like to have a bb-code which works like this:

[noguest]this text won't appear to guests even if they are allowed to view a thread[/noguest]

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

rin 01-26-2005 02:25 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. :)

Marco van Herwaarden 01-26-2005 03:08 PM

Quote:

Originally Posted by rin
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()
PHP Code:

        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?

rin 01-26-2005 03:28 PM

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.

rin 01-26-2005 04:06 PM

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

rin 01-26-2005 05:34 PM

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


All times are GMT. The time now is 05:26 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.01400 seconds
  • Memory Usage 1,771KB
  • 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
  • (5)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (17)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