Issue with bbcode parser

Discussion forum for MOD Writers regarding MOD Development.
Locked
bielu
Registered User
Posts: 9
Joined: Wed Aug 29, 2012 8:41 pm

Issue with bbcode parser

Post by bielu »

I have with bbcode parse in phpbb3, because I would parse text with out mysql. This is my code:

Code: Select all

function bbcode_strip($text)
{
global $config,$phpEx;
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
  if (!class_exists('parse_message'))
      {
         include("message_parser.$phpEx");
      }
include_once ('./common.'. $phpEx);
include_once("functions_content.php");
include_once ('functions_display.php');
    

    static $RegEx = array();
    if(!empty($config['topic_preview_strip_bbcodes'])){
    $bbcode= preg_split('/|/',$config['topic_preview_strip_bbcodes']);
    $uid = $bitfield = $options = ''; // will be modified by generate_text_for_storage

    foreach($bbcode as $key=>$code){
    $bbcode[$key]='#\['.$code.'\](.*?)\[/'.$code.'\]#i';
    }
    $text=preg_replace($bbcode, '\\2', $text);
    $uid = $bitfield = $options = '';
$allowed_bbcode = $allowed_smilies = $allowed_urls = true;

/* to enable bbcode, urls and smilies parsing, be enable it when using
generate_text_for_stoarge function 
generate_text_for_storage($text, $uid, $bitfield, $options, true, true, true);

$text = generate_text_for_display($text, $uid, $bitfield, $options);*/
   $message_parser = new parse_message();
      $message_parser->message = $text;
      $message_parser->parse(true, true, true);
      $text = $message_parser->format_display(true, true, true, false);
      unset($message_parser);
    }
    else if($config['topic_preview_strip_bbcodes']=="all"){
    $uid = $bitfield = $options = '';
$allowed_bbcode = $allowed_smilies = $allowed_urls = true;

/* to enable bbcode, urls and smilies parsing, be enable it when using
generate_text_for_stoarge function */
generate_text_for_storage($text, $uid, $bitfield, $options, true, true, true);
$text = generate_text_for_display($text, $uid, $bitfield, $options);

    
    }
    else{
    $text= preg_replace('#\[(.*?)\](.*?)\[/(.*?)\]#i', '\\2', $text);
    
    }
    $text = str_replace("\n", '<br >', $text); // Preserve line breaks
    return trim($text);
}
 
And text after parse:
b:1e3ulb6ib:1e3ulb6i
Locked

Return to “[3.0.x] MOD Writers Discussion”