бб коды function bb_code var var preg_replace_callbac array code code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/* бб коды */
function bb_code($var) {
$var = preg_replace_callback(array ('#\[code\](.*?)\[\/code\]#se'), array ("''.nosmiles(highlight('$1')).''"), str_replace("]\n", "]", $var));
$var = preg_replace('#\[b\](.*?)\[/b\]#si', '<span style="font-weight: bold;">\1</span>', $var);
$var = preg_replace('#\[i\](.*?)\[/i\]#si', '<span style="font-style:italic;">\1</span>', $var);
$var = preg_replace('#\[u\](.*?)\[/u\]#si', '<span style="text-decoration:underline;">\1</span>', $var);
$var = preg_replace('#\[small\](.*?)\[/small\]#si', '<small>\1</small>', $var);
$var = preg_replace('#\[marq\](.*?)\[/marq\]#si', '<marquee>\1</marquee>', $var);
$var = preg_replace('#\[del\](.*?)\[/del\]#si', '<del>\1</del>', $var);
$var = preg_replace('#\[big\](.*?)\[/big\]#si', '<big>\1</big>', $var);
$var = preg_replace('#\[img\](.*?)\[/img\]#si','<a href="$1"> <img src="$1" alt="" style="max-width:250px;"/></a>', $var);
$var = preg_replace('#\[code\](.+)\[/code\]#si','<div class="cit" style="display:none;"><code>\1</code></div>', $var);
$var = preg_replace('#\[php\](.+)\[/php\]#si','<div class="cit" style="display:none;"><code>\1</code></div>', $var);
$var = preg_replace('#\[dou\](.*?)\[/dou\]#si', '<span style="border:3px double black;">\1</span>', $var);
$var = preg_replace('#\[center\](.*?)\[/center\]#si', '<center>\1</center>', $var);
$var = preg_replace('#\[right\](.*?)\[/right\]#si', '<div align=right>\1</div>', $var);
$var = preg_replace('#\[red\](.*?)\[/red\]#si', '<span style="color:red">\1</span>', $var);
$var = preg_replace('#\[t\](.*?)\[/t\]#si', '<input name="text" type="text" value="\1">', $var);
$var = preg_replace('#\[green\](.*?)\[/green\]#si', '<span style="color:green">\1</span>', $var);
$var = preg_replace('#\[blue\](.*?)\[/blue\]#si', '<span style="color:blue">\1</span>', $var);
$var = preg_replace('#\[cit\](.*?)\[/cit\]#si', '<div class="cit"><b style="color:green">Цитата:</b><br/>" \1 "</div>', $var);
$var = preg_replace('#\[url\=(.*?)\](.*?)\[/url\]#sui','<a href="\1">\2</a>',$var);
$var = preg_replace('#\[url\](.*?)\[/url\]#sui','<a href="\1">\1</a>',$var);
$var = preg_replace_callback ('/file{(\d*)}/', 'fname', $var);
$var = preg_replace_callback ('/us{(\d*)}/' , 'Nick', $var);
$var = str_replace ("[br]", "<br/>", $var);
$query = DB :: $dbs -> query("SELECT `id`,`name`,`filename` FROM `smile`");
while ($smile = $query -> fetch ()){
$var = str_replace ($smile['name'], '<img src="/images/smile/' .$smile['filename'] . '" alt="smile"/>', $var);
}
return $var;
}