View file core/autoload/BBcodes.func.php

File size: 1.37Kb
<?

function bbcodes($text) {
	$bbcode = array();
	$bbcode['/\[b\](.+)\[\/b\]/isU'] = '<strong style="color:#616060;font-size:11px;">$1</strong>';
	$bbcode['/\[anchor=([a-zA-Z0-9-а-яА-Я_:]+)\](.+)\[\/anchor\]/isU'] = "<a name='$1' href='#$1'>$2</a>";//<div name='$1'>$1</div>
	
	$bbcode['/\[color=([a-z0-9-#]+)\](.+)\[\/color\]/isU'] = "<span style='color:$1;'>$2</span>";
	$bbcode['/\[h=(1|2|3+)\](.+)\[\/h\]/isU'] = '<h$1 style="text-align: center;color:#6a91e8;"><span class="htags">$2</span></h$1>';
	$bbcode['/\[hr\]/isU'] = '<hr />';

	$bbcode['/\[q\](.+)\[\/q\]/isU'] = '<div class="bb_q" style="color:#8a560e;font-size:11px;">$1</div>';

	$text = preg_replace_callback('/@([\w]{4,16}+)/u', 'BBcodesCallback::LinksCheckUSER', $text); 

	$text = preg_replace("#\[img\][\s]*([\S]+)[\s]*\[\/img\]#isU",'<img src="\\1" alt="" class="FilesData"/>',$text);	
	
	$text = preg_replace('#(^|\s|\(|\])((https?://)?www\.youtube\.com/watch\?(.*?&)*v=([^ \r\n\t`\'"<]+))(,|\[|<|\s|$)#iuU','\1[youtube]\5[/youtube]\6', $text);
	
	$text = preg_replace_callback('/\[url=(.+)\](.+)\[\/url\]/isU', 'BBcodesCallback::LinksCheck', $text); //LinksCheckURL
	$text = preg_replace_callback('~(^|\s)([a-z]+://([^ \r\n\t`\'"]+))(\s|$)~iu', 'BBcodesCallback::LinksCheck', $text);	
	
	if (count($bbcode))
	$text = preg_replace(array_keys($bbcode), array_values($bbcode), $text);	

	return $text;
}