vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Community Lounge (https://vborg.vbsupport.ru/forumdisplay.php?f=13)
-   -   How to handle BBCode - Eval or Parse out (https://vborg.vbsupport.ru/showthread.php?t=66452)

royli57 06-23-2004 04:45 PM

How to handle BBCode - Eval or Parse out
 
Hello

I want to take some of the posts from one of my vbulletin threads and output it onto one of my webpages. The problem if I do this is that the BBCode tags are outputted with the rest of the tags.

I would like to either get rid of the bbcode all together or somehow evaluate it so that it is presentable on my page.

Does anyone know any functions that can help me deal with the bbcode in either way?

Thanks

Roy

Xenon 06-23-2004 05:03 PM

strip_bbcode() or parse_bbcode() depends on if you want to parse it or strip it ;)

royli57 06-23-2004 06:41 PM

Quote:

Originally Posted by Xenon
strip_bbcode() or parse_bbcode() depends on if you want to parse it or strip it ;)

Hmm, are these functions built into PHP? I tried strip_bbcode but it is undefined.

(haha, I did mean 'strip' by the way, thanks for the correction)

Zachery 06-23-2004 06:48 PM

No, they are built into vBulletin ;)

royli57 06-23-2004 08:49 PM

Hmm I see what you mean.

I wanted to do a database query and output the information directly. Vbulletin functions aside, can someone suggest a function or a way to strip or evaluate the bbcode?

Or is there a way I can integrate the vbulletin function into my page?

colicab-d 06-23-2004 10:20 PM

Ok this may be dumb but try including your vbulletin global.php or functions_bbcode.php :) then adding the strip_bbcode(); function :)

Serge 06-24-2004 03:01 AM

Quote:

Originally Posted by colicab-d
Ok this may be dumb but try including your vbulletin global.php or functions_bbcode.php :) then adding the strip_bbcode(); function :)

That would be the easiest way. Don't try to reinvent the wheel use what you have. If you don't have a vbulletin then you are going to have to use regulare expressions and write your own functions for strip and phrase bbcode.

royli57 06-24-2004 05:08 AM

colicab, I like your idea. If I can find the strip_bbcode function, I will gladly copy and paste it over to my page.

I checked globals.php and functions_bbcode.php but could not find that function though. Any idea where it might be?

royli57 06-24-2004 05:12 AM

Ah ha, I found it in functions.php.

PHP Code:

function strip_bbcode($message$stripquotes false$fast_and_dirty false)
{
    
$find = array();
    
$replace = array();
 
    if (
$stripquotes)
    {
        
// [quote=username] and [quote]
        
$message strip_quotes($message);
    }
 
    
// a really quick and rather nasty way of removing vbcode
    
if ($fast_and_dirty)
    {
        
// any old thing in square brackets
        
$find[] = '#\[.*/?\]#siU';
        
$replace[] = '';
 
        
$message preg_replace($find$replace$message);
    }
    
// the preferable way to remove vbcode
    
else
    {
        
// simple links
        
$find[] = '#\[(email|url)=("??)(.+)\\2\]\\3\[/\\1\]#siU';
        
$replace[] = '\3';
 
        
// named links
        
$find[] = '#\[(email|url)=("??)(.+)\\2\](.+)\[/\\1\]#siU';
        
$replace[] = '\4 (\3)';
 
        
// replace links (and quotes if specified) from message
        
$message preg_replace($find$replace$message);
 
        
// strip out all other instances of [x]...[/x]
        
while(preg_match_all('#\[([\w]+?)[^\]]*\](.*)(\[/\1\])#siU'$message$regs))
        {
            foreach(
$regs[0] AS $key => $val)
            {
                
$message str_replace($val$regs[2]["$key"], $message);
            }
        }
        
$message str_replace('[*]'' '$message);
    }
 
    return 
trim($message);


Seems to work fine. Thanks everyone!

Roy

liquidx 06-26-2004 12:11 PM

I would like to be able to parse instead of strip the bbcode, could someone help me with this?

When I try to include global.php I get:
Fatal error: Call to a member function on a non-object in /www/forums/includes/functions_bbcodeparse.php on line 384


All times are GMT. The time now is 07:30 PM.

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.01624 seconds
  • Memory Usage 1,744KB
  • 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_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete