View file games/inc/inc_bb_codes.php

File size: 1.48Kb
<?php
function url_replace($m) { 
if( !isset($m[3]) ) { 
return '<a href="' . $m[1] . '">' . $m[2] . '</a>'; 
} else { 
return '<a href="' . $m[3] . '">' . $m[3] . '</a>';         
}} 


//------------------ Функция вставки BB-кода --------------------//
function bb_code($text){ 
$text = str_replace("[br]", "<br/>", $text);
$text = preg_replace('#\[code\](.*?)\[/code\]#ie', 'highlight_code("\1")', $text); 
$text = preg_replace('#\[big\](.*?)\[/big\]#si', '<big>\1</big>', $text);
$text = preg_replace('#\[b\](.*?)\[/b\]#si', '<b>\1</b>', $text);
$text = preg_replace('#\[i\](.*?)\[/i\]#si', '<i>\1</i>', $text);
$text = preg_replace('#\[u\](.*?)\[/u\]#si', '<u>\1</u>', $text);
$text = preg_replace('#\[small\](.*?)\[/small\]#si', '<small>\1</small>', $text);
$text = preg_replace('#\[red\](.*?)\[/red\]#si', '<font color="#FF0000">\1</font>', $text);
$text = preg_replace('#\[green\](.*?)\[/green\]#si', '<font color="green">\1</font>', $text);
$text = preg_replace('#\[blue\](.*?)\[/blue\]#si', '<font color="#0000FF">\1</font>', $text);
$text = preg_replace('#\[yellow\](.*?)\[/yellow\]#si', '<font color="#FFFF00">\1</font>', $text);
$text = preg_replace('#\[q\](.*?)\[/q\]#si', '<q>\1</q>', $text);
$text = preg_replace('#\[del\](.*?)\[/del\]#si', '<del>\1</del>', $text);
$text = preg_replace_callback('~\\[url=(http://.+?)\\](.+?)\\[/url\\]|(http://(www.)?[0-9a-z\.-]+\.[0-9a-z]{2,6}[0-9a-zA-Z/\?\.\~&amp;_=/%-:#]*)~', 'url_replace', $text); 
return $text;
}
?>