Go Back   vb.org Archive > Community Central > Community Lounge
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 06-23-2004, 05:45 PM
royli57 royli57 is offline
 
Join Date: Mar 2004
Posts: 16
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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
Reply With Quote
  #2  
Old 06-23-2004, 06:03 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

strip_bbcode() or parse_bbcode() depends on if you want to parse it or strip it
Reply With Quote
  #3  
Old 06-23-2004, 07:41 PM
royli57 royli57 is offline
 
Join Date: Mar 2004
Posts: 16
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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)
Reply With Quote
  #4  
Old 06-23-2004, 07:48 PM
Zachery's Avatar
Zachery Zachery is offline
 
Join Date: Jul 2002
Location: Ontario, Canada
Posts: 11,440
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

No, they are built into vBulletin
Reply With Quote
  #5  
Old 06-23-2004, 09:49 PM
royli57 royli57 is offline
 
Join Date: Mar 2004
Posts: 16
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Reply With Quote
  #6  
Old 06-23-2004, 11:20 PM
colicab-d's Avatar
colicab-d colicab-d is offline
 
Join Date: Dec 2002
Location: Glasgow
Posts: 382
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok this may be dumb but try including your vbulletin global.php or functions_bbcode.php then adding the strip_bbcode(); function
Reply With Quote
  #7  
Old 06-24-2004, 04:01 AM
Serge's Avatar
Serge Serge is offline
 
Join Date: Jan 2002
Location: The Matrix
Posts: 115
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #8  
Old 06-24-2004, 06:08 AM
royli57 royli57 is offline
 
Join Date: Mar 2004
Posts: 16
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Reply With Quote
  #9  
Old 06-24-2004, 06:12 AM
royli57 royli57 is offline
 
Join Date: Mar 2004
Posts: 16
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #10  
Old 06-26-2004, 01:11 PM
liquidx liquidx is offline
 
Join Date: Nov 2002
Posts: 20
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
Reply


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

Forum Jump


All times are GMT. The time now is 11:34 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.07100 seconds
  • Memory Usage 2,263KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete