protected function bbcode string string preg_replace color A-Za-z colo

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
protected function bbcode($string) {
$string = preg_replace("@\[color=([A-Za-z]+?)\](.+?)\[\/color\]@sui", "<span style='color:$1;'>$2</span>", $string);
$string = preg_replace("@\[b\](.+?)\[\/b\]@sui", "<span style='font-weight:bold;'>$1</span>", $string);
$string = preg_replace("@\[u\](.+?)\[\/u\]@sui", "<u>$1</u>", $string);
$string = preg_replace("@\[s\](.+?)\[\/s\]@sui", "<s>$1</s>", $string);
$string = preg_replace("@\[i\](.+?)\[\/i\]@sui", "<i>$1</i>", $string);
$string = preg_replace("@\[q\](.+?)\[\/q\]@sui", "<div class='quote'>$1</div>", $string);
$string = preg_replace("@\[url=http:\/\/" . $_SERVER['HTTP_HOST'] . "\/([^\s\n]{0,128}?)\](.+?)\[/url\]@sui", "<a href='/$1'><span style='color:#174'>$2</span></a>", $string);
$string = preg_replace("@http:\/\/" . $_SERVER['HTTP_HOST'] . "\/([^\s\n]{0,128})@sui", "<a href='/$1'><span style='color:#174'>" . $_SERVER['HTTP_HOST'] . "/$1</span></a>", $string);
$string = preg_replace("@\[url=http:\/\/([^\s\n]+?)\](.+?)\[/url\]@sui", "<a target='_blank' href='/go/$1'><span style='color:#174'>$2</span></a>", $string);
$string = preg_replace("@http:\/\/([^\s\n]+)@sui", "<a target='_blank' href='/go/$1'><span style='color:#174'>$1</span></a>", $string);
$string = preg_replace("@\@([a-zA-Zа-яА-Я0-9]{3,16})@sui", "[user=$1]", $string);
preg_match_all("@\[user=([a-zA-Zа-яА-Я0-9]{3,16})\]@sui", $string, $matches);
$matches = $matches[1];
for ($i = 0; $i < count($matches); $i++) {
$nick = $matches[$i];
$usr = $this->findUser($nick);
$string = str_replace("[user=$nick]", $this->fullUser($usr['id'], "/info/", false, "color:black;text-decoration:none;font-weight:bold"), $string);
}
return $string;
}