if ( !defined('MAIN_LOADED') ) { die("Direct access not allowed"); } /* bbcode functions !regexp leeched from phpBB */ function message_bbdecode($text) { GLOBAL $lang, $config; # func 0 - str, 1 -preg $enlarge_sz = (isset($lang['Enlarge_Image'])) ? $lang['Enlarge_Image'] : ''; $s_path = (isset($config['script_path'])) ? $config['script_path'] : ''; $text = preg_replace('#(script|about|applet|activex|chrome):#is', "\\1:", $text); $ru_preg = chr(0x7F)."-".chr(0xff); // set id if wanna to get rid of &? $bb_tags = array ( array ( 'func' => 1, 'pattern' => "/\[color=(\#[0-9A-F]array ( 6 )|[a-z]+)\]/si", 'replacement' => '' ), array ( 'func' => 0, 'pattern' => "[/color]", 'replacement' => '' ), array ( 'func' => 1, 'pattern' => "/\[size=([1-2]?[0-9])\]/si", 'replacement' => '' ), array ( 'func' => 0, 'pattern' => "[/size]", 'replacement' => '' ), array ( 'func' => 0, 'pattern' => "[b]", 'replacement' => '' ), array ( 'func' => 0, 'pattern' => "[/b]", 'replacement' => '' ), array ( 'func' => 0, 'pattern' => "[u]", 'replacement' => '' ), array ( 'func' => 0, 'pattern' => "[/u]", 'replacement' => '' ), array ( 'func' => 0, 'pattern' => "[i]", 'replacement' => '' ), array ( 'func' => 0, 'pattern' => "[/i]", 'replacement' => '' ), array ( 'func' => 0, 'pattern' => "[pre]", 'replacement' => '
' ), array ( 'func' => 0, 'pattern' => "[/pre]", 'replacement' => '
' ), // external images array ( 'func' => 1, 'pattern' => "#\[img\](http|ftp)([^?].*?)\[/img\]#i", 'replacement' => '' ), // internal array ( 'func' => 1, 'pattern' => "#\[img\]([^?].*?)\[/img\]#i", 'replacement' => '' ), //external urls array ( 'id' => '1', 'func' => 1, 'pattern' => "#\[url=([\w]+?://[\d\w\#$%&~/.\-;:=,?@\(\)\[\]+]*?)\]([^?\n\r\t].*?)\[/url\]#is" , 'replacement' => '$2' ), array ( 'id' => '1', 'func' => 1, 'pattern' => "#\[url\]([\w]+?://[\d\w\#$%&~/.\-;:=,?@\(\)\[\]+]*?)\[/url\]#is", 'replacement' => '$1' ), array ( 'id' => '1', 'func' => 1, 'pattern' => "#\[url\]((www|ftp)\.[\w\#$%&~/.\-;:=,?@\[\]+]*?)\[/url\]#is", 'replacement' => '$1' ), array ( 'id' => '1', 'func' => 1, 'pattern' => "#\[url=((www|ftp)\.[\w\#$%&~/.\-;:=,?@\[\]+]*?)\]([^?\n\r\t].*?)\[/url\]#is", 'replacement' => '$3' ), array ( 'func' => 1, 'pattern' => "#\[email\]([a-z0-9&\-_.]+?@[\w\-]+\.([\w\-\.]+\.)?[\w]+)\[/email\]#si", 'replacement' => '$1'), //internal urls array ( 'id' => '1', 'func' => 1, 'pattern' => "#\[url=([\w\d\#$%&~/.\-;:=,?@\[\]+]*?)\]([^?\n\r\t].*?)\[/url\]#is" , 'replacement' => '$2' ), // $config['self_url'] array ( 'id' => '1', 'func' => 1, 'pattern' => "#\[url\]([\w\d\#$%&~/.\-;:=,?@\[\]+]*?)\[/url\]#is", 'replacement' => '$1' ), /* style="margin:4px" */ //[thumb align=align title=title]pic.ext[/thumb] array ( 'id' => '1', 'func' => 1, 'pattern' => "#\[thumb align=(\w+) title=([{$ru_preg}\d\s\w\-_\(\)]+)\]([\w\d-_\^\?]+\.(?:gif|jpeg|jpg|png))\[/thumb\]#is" , 'replacement' => '' ), // [thumb align=align]thumb.ext[/thumb] array ( 'id' => '1', 'func' => 1, 'pattern' => "#\[thumb align=(\w+)\]([{$ru_preg}\w\d\-_\^\?]+\.(?:gif|jpeg|jpg|png))\[/thumb\]#is" , 'replacement' => '' ), // geshi array ( 'id' => 'geshi', 'func' => 1, 'pattern' => "#\[code type=(\w+)\](.*)\[/code\]#smU" ) ); # REPLACE while ( list($k,$v) = each($bb_tags) ) { # print "{$k} -> {$v['pattern']} -> " . htmlspecialchars($v['replacement']) ."{$buff}