vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   How do I stop parsing of BB code? (https://vborg.vbsupport.ru/showthread.php?t=103152)

kau 12-17-2005 06:23 PM

How do I stop parsing of BB code?
 
Right now on my current version I hacked it so function handle_bbcode_img($bbcode, $dobbimagecode) does not work unless you are a certain user group, to stop trolls.

Now with 3.5 this is gone. I can't update until I find where this code is now.

What file is the parsing of the IMG tag in now???????

akanevsky 12-17-2005 08:22 PM

class_bbcode

merk 12-17-2005 09:46 PM

You should be able to use a plugin to achieve what you want.

kau 12-18-2005 12:22 AM

How would I use a plugin to do that? I'm not very technical.

I looked throughout class_bbcode and I can't see a clear cut function that does it. Can someone point me to which function in that file handles the parsing of the IMG tag or explain how to setup a plugin to do what I need.

akanevsky 12-18-2005 12:56 AM

File class_bbcode.php, around line 1714:

PHP Code:

    /**
    * Handles an [img] tag.
    *
    * @param    string    The text to search for an image in.
    * @param    string    Whether to parse matching images into pictures or just links.
    *
    * @return    string    HTML representation of the tag.
    */
    
function handle_bbcode_img($bbcode$do_imgcode$has_img_code false


kau 12-18-2005 01:16 AM

Great! Thanks very much.

merk 12-18-2005 01:21 AM

Wait. Thats not the best method. (modifying code when you dont have to is baaad :))

plugin bbcode_parse_start,

PHP Code:

if(is_member_of($this->registry->userinfoX)) { 
$dobbimagecode true
}
else
{
$dobbimagecode false;



akanevsky 12-18-2005 01:24 AM

I didn't say that it's a best method. I just pointed at a location. As for your method, which is definitely better, the most error-proof solution would be simply:

PHP Code:

if(!(is_member_of($this->registry->userinfoX) OR is_member_of($this->registry->userinfoY)))
{
    
$dobbimagecode false;


Whereas the "true" assignment in your code might cause unexpected behavior in some cases when imgcode should not be parsed.

The easiest to use modify code would be:

PHP Code:

$usergroupids_no_img 'X,Y,Z';
$usergroupids_no_img explode(','$usergroupids_no_img);

foreach (
$usergroupids_no_img as $usergroupid)
{
    if(!
is_member_of($this->registry->userinfo$usergroupid))
    {
        
$dobbimagecode false;
        break;
    }


The reason there is a break statement is to stop checking for usergroups once a restricted one has been found - in other words, for optimization.

;)

merk 12-18-2005 01:27 AM

It is unnecessary to use multiple is_member_of calls. You can pass an array of usergroupids.

akanevsky 12-18-2005 01:29 AM

Really? I didn't know. Thanks for pointing that out :) It's not really an "array", though. Rather an expanded list of parameters.

Code:

if(!is_member_of($this->registry->userinfo, X, Y, Z))
{
    $dobbimagecode = false;
}



All times are GMT. The time now is 10:07 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.01206 seconds
  • Memory Usage 1,743KB
  • 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
  • (1)bbcode_code_printable
  • (4)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete