Файл: sys/classes/text.class.php
Строк: 1498
<?php
#Работа с текстом
class text {
static function censure($s, $delta = 3, $continue = "xe2x80xa6") {
#предлоги русского языка:
#[всуо]|
#по|за|на|об|до|от|вы|вс|вз|из|ис|
#под|про|при|над|низ|раз|рас|воз|вос|
#пооб|повы|пона|поза|недо|пере|одно|
#полуза|произ|пораз|много|
static $pretext = array(
#1
'[уyоo]_? (?=[еёeхx])', #у, о (уебать, охуеть)
'[вvbсc]_? (?=[хпбмгжxpmgj])', #в, с (впиздячить, схуярить)
'[вvbсc]_?[ъь]_? (?=[еёe])', #въ, съ (съебаться, въебать)
'ё_? (?=[бb])', #ё (ёбля)
#2
'[вvb]_?[ыi]_?', #вы
'[зz3]_?[аa]_?', #за
'[нnh]_?[аaеeиi]_?', #на, не, ни
'[вvb]_?[сc]_? (?=[хпбмгжxpmgj])', #вс (вспизднуть)
'[оo]_?[тtбb]_? (?=[хпбмгжxpmgj])', #от, об
'[оo]_?[тtбb]_?[ъь]_? (?=[еёe])', #отъ, объ
'[иiвvb]_?[зz3]_? (?=[хпбмгжxpmgj])', #[ив]з
'[иiвvb]_?[зz3]_?[ъь]_? (?=[еёe])', #[ив]зъ
'[иi]_?[сc]_? (?=[хпбмгжxpmgj])', #ис
'[пpдdg]_?[оo]_? (?> [бb]_? (?=[хпбмгжxpmgj])
| [бb]_? [ъь]_? (?=[еёe])
| [зz3]_? [аa] _?
)?', #по, до, пообъ, дообъ, поза, доза (двойные символы вырезаются!)
#3
'[пp]_?[рr]_?[оoиi]_?', #пр[ои]
'[зz3]_?[лl]_?[оo]_?', #зло (злоебучая)
'[нnh]_?[аa]_?[дdg]_? (?=[хпбмгжxpmgj])', #над
'[нnh]_?[аa]_?[дdg]_?[ъь]_? (?=[еёe])', #надъ
'[пp]_?[оo]_?[дdg]_? (?=[хпбмгжxpmgj])', #под
'[пp]_?[оo]_?[дdg]_?[ъь]_? (?=[еёe])', #подъ
'[рr]_?[аa]_?[зz3сc]_? (?=[хпбмгжxpmgj])', #ра[зс]
'[рr]_?[аa]_?[зz3сc]_?[ъь]_? (?=[еёe])', #ра[зс]ъ
'[вvb]_?[оo]_?[зz3сc]_? (?=[хпбмгжxpmgj])', #во[зс]
'[вvb]_?[оo]_?[зz3сc]_?[ъь]_? (?=[еёe])', #во[зс]ъ
#4
'[нnh]_?[еe]_?[дdg]_?[оo]_?', #недо
'[пp]_?[еe]_?[рr]_?[еe]_?', #пере
'[oо]_?[дdg]_?[нnh]_?[оo]_?', #одно
'[кk]_?[oо]_?[нnh]_?[оo]_?', #коно (коноебиться)
'[мm]_?[уy]_?[дdg]_?[оoаa]_?', #муд[оа] (мудаёб)
'[oо]_?[сc]_?[тt]_?[оo]_?', #осто (остопиздело)
'[дdg]_?[уy]_?[рpr]_?[оoаa]_?', #дур[оа]
'[хx]_?[уy]_?[дdg]_?[оoаa]_?', #худ[оа] (худоебина)
#5
'[мm]_?[нnh]_?[оo]_?[гg]_?[оo]_?', #много
'[мm]_?[оo]_?[рpr]_?[дdg]_?[оoаa]_?', #морд[оа]
'[мm]_?[оo]_?[зz3]_?[гg]_?[оoаa]_?', #мозг[оа]
'[дdg]_?[оo]_?[лl]_?[бb6]_?[оoаa]_?', #долб[оа]
);
static $badwords = array(
#Слово на букву Х
'(?<=[_d]) {RE_PRETEXT}?
[hхx]_?[уyu]_?[йiеeёяюju] #хуй, хуя, хую, хуем, хуёвый
#исключения:
(?<! _hue(?=_) #HUE -- цветовая палитра
| _hue(?=so_) #hueso -- испанское слово
| _хуе(?=дин) #Хуедин -- город в Румынии
)',
#Слово на букву П
'(?<=[_d]) {RE_PRETEXT}?
[пp]_?[иi]_?[зz3]_?[дd]_?[:vowel:]', #пизда, пизде, пиздёж, пизду, пиздюлина, пиздобол, опиздинеть, пиздых
#Слово на букву Е
'(?<=[_d]) {RE_PRETEXT}?
[eеё]_? (?<!не[её]_) [бb6]_?(?: [уyиi]_ #ебу, еби
| [ыиiоoaаеeёуy]_?[:consonant:] #ебут, ебать, ебись, ебёт, поеботина, выебываться, ёбарь
| [лl][оoаaыиi] #ебло, ебла, ебливая, еблись, еблысь
| [нn]_?[уy] #ёбнул, ёбнутый
| [кk]_?[аa] #взъёбка
)',
'(?<=[_d]) {RE_PRETEXT}
(?<=[^_d][^_d]|[^_d]_[^_d]_) [eеё]_?[бb6] (?:_|_?[аa]_?[^_d])', #долбоёб, дураёб, изъёб, заёб, разъебай
#Слово на букву Б
'(?<=[_d]) {RE_PRETEXT}?
[бb6]_?[лl]_?(?:я|ya)(?: _ #бля
| _?[тд] #блять, бляди
)',
#ПИДОР
'(?<=[_d]) [пp]_?[иieе]_?[дdg]_?[eеaаoо]_?[rpр]', #п[ие]д[оеа]р
#МУДАК
'(?<=[_d]) [мm]_?[уy]_?[дdg]_?[аa]', #муда
#ЖОПА
'(?<=[_d]) [zж]_?h?_?[оo]_?[pп]_?[aаyуыiеeoо]', #жоп[ауыео]
#МАНДА
#исключения: город Мандалай, округ Мандаль, индейский народ Мандан, фамилия Мандель
'(?<=[_d]) [мm]_?[аa]_?[нnh]_?[дdg]_?[aаyуыiеeoо](?<! манда(?=[лн])|манде(?=ль ))', #манд[ауыео]
#ГОВНО
'(?<=[_d]) [гg]_?[оo]_?[вvb]_?[нnh]_?[оoаaяеeyу]', #говн[оаяеу]
#FUCK
'(?<=[_d]) f_?u_?[cс]_?k', #fuck
#ЛОХ
' л_?[оo]_?[хx]',
#СУКА
'[^р]_?[scс]_?[yуu]_?[kк]_?[aаiи]', #сука (кроме слова "барсука" - это животное-грызун)
'[^р]_?[scс]_?[yуu]_?[4ч]_?[кk]', #сучк(и) (кроме слова "барсучка")
#ХЕР
' {RE_PRETEXT}?[хxh]_?[еe]_?[рpr](_?[нnh]_?(я|ya)| )', #{RE_PRETEXT}хер(ня)
#ЗАЛУПА
' [зz3]_?[аa]_?[лl]_?[уy]_?[пp]_?[аa]',
);
static $re_trans = array(
'_' => 'x20', #пробел
'[:vowel:]' => '[аеиоуыэюяёaeioyu]', #гласные буквы
'[:consonant:]' => '[^аеиоуыэюяёaeioyux20d]', #согласные буквы
);
$re_badwords = str_replace('{RE_PRETEXT}', '(?>' . implode('|', $pretext) . ')', '~' . implode('|', $badwords) . '~sxu');
$re_badwords = strtr($re_badwords, $re_trans);
#вырезаем все лишнее
#скрипты не вырезаем, т.к. м.б. обходной маневр на с кодом на javascript:
#<script>document.write('сло'+'во')</script>
#хотя давать пользователю возможность использовать код на javascript нехорошо
#оптимизация скорости include_once
$s = self::strip_tags_smart($s, null, true, array('comment', 'style', 'map', 'frameset', 'object', 'applet'));
#заменяем html-сущности в "чистый" UTF-8
#оптимизация скорости include_once
$s = self::utf8_html_entity_decode($s, $is_htmlspecialchars = true);
#оптимизация скорости include_once
$s = self::utf8_convert_case($s, CASE_LOWER);
static $trans = array(
"xc2xad" => '', #вырезаем "мягкий" перенос строки (­)
"xccx81" => '', #вырезаем знак ударения (U+0301 «combining acute accent»)
'/\' => 'л', #Б/Я
'/|' => 'л', #Б/|Я
"xd0xb5xd0xb5" => "xd0xb5xd1x91", #ее => её
);
$s = strtr($s, $trans);
#получаем в массив только буквы и цифры
#"с_л@о#во,сxc2xa7лово.Слово" -> "слово слово слово"
preg_match_all('/(?> xd0[xb0-xbf]|xd1[x80-x8fx91] #[а-я]
| [a-zd]+
)+
/sx', $s, $m);
$s = ' ' . implode(' ', $m[0]) . ' ';
#убираем все повторяющиеся символы
#"сллоооовоо слово" -> "слово слово"
$s = preg_replace('/( [xd0xd1][x80-xbf] #оптимизированное [а-я]
| [a-zd]
) \1+
/sx', '$1', $s);
#d($s);
if (preg_match($re_badwords, $s, $m, PREG_OFFSET_CAPTURE)) {
list($word, $offset) = $m[0];
$s1 = substr($s, 0, $offset);
$s2 = substr($s, $offset + strlen($word));
$delta = intval($delta);
if ($delta < 1 || $delta > 10) {
$delta = 3;
}
preg_match('/ (?> x20 (?>[xd0xd1][x80-xbf]|[a-zd]+)+ ){1,' . $delta . '}
x20?
$/sx', $s1, $m1);
preg_match('/^ (?>[xd0xd1][x80-xbf]|[a-zd]+)* #окончание
x20?
(?> (?>[xd0xd1][x80-xbf]|[a-zd]+)+ x20 ){1,' . $delta . '}
/sx', $s2, $m2);
$fragment = (ltrim(@$m1[0]) !== ltrim($s1) ? $continue : '') .
trim(@$m1[0] . '[' . trim($word) . ']' . @$m2[0]) .
(rtrim(@$m2[0]) !== rtrim($s2) ? $continue : '');
return $fragment;
}
return false;
}
static function utf8_convert_case($s, $mode) {
static $trans = array(
"x41" => "x61",
"x42" => "x62",
"x43" => "x63",
"x44" => "x64",
"x45" => "x65",
"x46" => "x66",
"x47" => "x67",
"x48" => "x68",
"x49" => "x69",
"x4a" => "x6a",
"x4b" => "x6b",
"x4c" => "x6c",
"x4d" => "x6d",
"x4e" => "x6e",
"x4f" => "x6f",
"x50" => "x70",
"x51" => "x71",
"x52" => "x72",
"x53" => "x73",
"x54" => "x74",
"x55" => "x75",
"x57" => "x77",
"x56" => "x76",
"x58" => "x78",
"x59" => "x79",
"x5a" => "x7a",
"xd0x81" => "xd1x91",
"xd0x90" => "xd0xb0",
"xd0x91" => "xd0xb1",
"xd0x92" => "xd0xb2",
"xd0x93" => "xd0xb3",
"xd0x94" => "xd0xb4",
"xd0x95" => "xd0xb5",
"xd0x96" => "xd0xb6",
"xd0x97" => "xd0xb7",
"xd0x98" => "xd0xb8",
"xd0x99" => "xd0xb9",
"xd0x9a" => "xd0xba",
"xd0x9b" => "xd0xbb",
"xd0x9c" => "xd0xbc",
"xd0x9d" => "xd0xbd",
"xd0x9e" => "xd0xbe",
"xd0x9f" => "xd0xbf",
"xd0xa0" => "xd1x80",
"xd0xa1" => "xd1x81",
"xd0xa2" => "xd1x82",
"xd0xa3" => "xd1x83",
"xd0xa4" => "xd1x84",
"xd0xa5" => "xd1x85",
"xd0xa6" => "xd1x86",
"xd0xa7" => "xd1x87",
"xd0xa8" => "xd1x88",
"xd0xa9" => "xd1x89",
"xd0xaa" => "xd1x8a",
"xd0xab" => "xd1x8b",
"xd0xac" => "xd1x8c",
"xd0xad" => "xd1x8d",
"xd0xae" => "xd1x8e",
"xd0xaf" => "xd1x8f",
"xd2x96" => "xd2x97",
"xd2xa2" => "xd2xa3",
"xd2xae" => "xd2xaf",
"xd2xba" => "xd2xbb",
"xd3x98" => "xd3x99",
"xd3xa8" => "xd3xa9",
"xd2x90" => "xd2x91",
"xd0x84" => "xd1x94",
"xd0x86" => "xd1x96",
"xd0x87" => "xd1x97",
"xd0x8e" => "xd1x9e",
"xc3x84" => "xc3xa4",
"xc3x87" => "xc3xa7",
"xc3x91" => "xc3xb1",
"xc3x96" => "xc3xb6",
"xc3x9c" => "xc3xbc",
"xc4x9e" => "xc4x9f",
"xc4xb0" => "xc4xb1",
"xc5x9e" => "xc5x9f",
"xc4x8c" => "xc4x8d",
"xc4x86" => "xc4x87",
"xc4x90" => "xc4x91",
"xc5xa0" => "xc5xa1",
"xc5xbd" => "xc5xbe",
"xc3x80" => "xc3xa0",
"xc3x82" => "xc3xa2",
"xc3x86" => "xc3xa6",
"xc3x88" => "xc3xa8",
"xc3x89" => "xc3xa9",
"xc3x8a" => "xc3xaa",
"xc3x8b" => "xc3xab",
"xc3x8e" => "xc3xae",
"xc3x8f" => "xc3xaf",
"xc3x94" => "xc3xb4",
"xc5x92" => "xc5x93",
"xc3x99" => "xc3xb9",
"xc3x9b" => "xc3xbb",
"xc5xb8" => "xc3xbf",
);
if ($mode == CASE_UPPER) {
if (function_exists('mb_strtoupper')) {
return mb_strtoupper($s, 'utf-8');
}
if (preg_match('/^[x00-x7e]*$/', $s)) {
return strtoupper($s);
}
strtr($s, array_flip($trans));
} elseif ($mode == CASE_LOWER) {
if (function_exists('mb_strtolower')) {
return mb_strtolower($s, 'utf-8');
}
if (preg_match('/^[x00-x7e]*$/', $s)) {
return strtolower($s);
}
strtr($s, $trans);
} else {
trigger_error('Parameter 2 should be a constant of CASE_LOWER or CASE_UPPER!', E_USER_WARNING);
return $s;
}
return $s;
}
static function utf8_lowercase($s) {
return utf8_convert_case($s, CASE_LOWER);
}
static function utf8_uppercase($s) {
return utf8_convert_case($s, CASE_UPPER);
}
static function utf8_html_entity_decode($s, $is_htmlspecialchars = false) {
if (strlen($s) < 4 || ($pos = strpos($s, '&') === false) || strpos($s, ';', $pos) === false) {
return $s;
}
$table = array(
' ' => "xc2xa0",
'¡' => "xc2xa1",
'¢' => "xc2xa2",
'£' => "xc2xa3",
'¤' => "xc2xa4",
'¥' => "xc2xa5",
'¦' => "xc2xa6",
'§' => "xc2xa7",
'¨' => "xc2xa8",
'©' => "xc2xa9",
'ª' => "xc2xaa",
'«' => "xc2xab",
'¬' => "xc2xac",
'­' => "xc2xad",
'®' => "xc2xae",
'¯' => "xc2xaf",
'°' => "xc2xb0",
'±' => "xc2xb1",
'²' => "xc2xb2",
'³' => "xc2xb3",
'´' => "xc2xb4",
'µ' => "xc2xb5",
'¶' => "xc2xb6",
'·' => "xc2xb7",
'¸' => "xc2xb8",
'¹' => "xc2xb9",
'º' => "xc2xba",
'»' => "xc2xbb",
'¼' => "xc2xbc",
'½' => "xc2xbd",
'¾' => "xc2xbe",
'¿' => "xc2xbf",
'À' => "xc3x80",
'Á' => "xc3x81",
'Â' => "xc3x82",
'Ã' => "xc3x83",
'Ä' => "xc3x84",
'Å' => "xc3x85",
'Æ' => "xc3x86",
'Ç' => "xc3x87",
'È' => "xc3x88",
'É' => "xc3x89",
'Ê' => "xc3x8a",
'Ë' => "xc3x8b",
'Ì' => "xc3x8c",
'Í' => "xc3x8d",
'Î' => "xc3x8e",
'Ï' => "xc3x8f",
'Ð' => "xc3x90",
'Ñ' => "xc3x91",
'Ò' => "xc3x92",
'Ó' => "xc3x93",
'Ô' => "xc3x94",
'Õ' => "xc3x95",
'Ö' => "xc3x96",
'×' => "xc3x97",
'Ø' => "xc3x98",
'Ù' => "xc3x99",
'Ú' => "xc3x9a",
'Û' => "xc3x9b",
'Ü' => "xc3x9c",
'Ý' => "xc3x9d",
'Þ' => "xc3x9e",
'ß' => "xc3x9f",
'à' => "xc3xa0",
'á' => "xc3xa1",
'â' => "xc3xa2",
'ã' => "xc3xa3",
'ä' => "xc3xa4",
'å' => "xc3xa5",
'æ' => "xc3xa6",
'ç' => "xc3xa7",
'è' => "xc3xa8",
'é' => "xc3xa9",
'ê' => "xc3xaa",
'ë' => "xc3xab",
'ì' => "xc3xac",
'í' => "xc3xad",
'î' => "xc3xae",
'ï' => "xc3xaf",
'ð' => "xc3xb0",
'ñ' => "xc3xb1",
'ò' => "xc3xb2",
'ó' => "xc3xb3",
'ô' => "xc3xb4",
'õ' => "xc3xb5",
'ö' => "xc3xb6",
'÷' => "xc3xb7",
'ø' => "xc3xb8",
'ù' => "xc3xb9",
'ú' => "xc3xba",
'û' => "xc3xbb",
'ü' => "xc3xbc",
'ý' => "xc3xbd",
'þ' => "xc3xbe",
'ÿ' => "xc3xbf",
'ƒ' => "xc6x92",
'Α' => "xcex91",
'Β' => "xcex92",
'Γ' => "xcex93",
'Δ' => "xcex94",
'Ε' => "xcex95",
'Ζ' => "xcex96",
'Η' => "xcex97",
'Θ' => "xcex98",
'Ι' => "xcex99",
'Κ' => "xcex9a",
'Λ' => "xcex9b",
'Μ' => "xcex9c",
'Ν' => "xcex9d",
'Ξ' => "xcex9e",
'Ο' => "xcex9f",
'Π' => "xcexa0",
'Ρ' => "xcexa1",
'Σ' => "xcexa3",
'Τ' => "xcexa4",
'Υ' => "xcexa5",
'Φ' => "xcexa6",
'Χ' => "xcexa7",
'Ψ' => "xcexa8",
'Ω' => "xcexa9",
'α' => "xcexb1",
'β' => "xcexb2",
'γ' => "xcexb3",
'δ' => "xcexb4",
'ε' => "xcexb5",
'ζ' => "xcexb6",
'η' => "xcexb7",
'θ' => "xcexb8",
'ι' => "xcexb9",
'κ' => "xcexba",
'λ' => "xcexbb",
'μ' => "xcexbc",
'ν' => "xcexbd",
'ξ' => "xcexbe",
'ο' => "xcexbf",
'π' => "xcfx80",
'ρ' => "xcfx81",
'ς' => "xcfx82",
'σ' => "xcfx83",
'τ' => "xcfx84",
'υ' => "xcfx85",
'φ' => "xcfx86",
'χ' => "xcfx87",
'ψ' => "xcfx88",
'ω' => "xcfx89",
'ϑ' => "xcfx91",
'ϒ' => "xcfx92",
'ϖ' => "xcfx96",
'•' => "xe2x80xa2",
'…' => "xe2x80xa6",
'′' => "xe2x80xb2",
'″' => "xe2x80xb3",
'‾' => "xe2x80xbe",
'⁄' => "xe2x81x84",
'℘' => "xe2x84x98",
'ℑ' => "xe2x84x91",
'ℜ' => "xe2x84x9c",
'™' => "xe2x84xa2",
'ℵ' => "xe2x84xb5",
'←' => "xe2x86x90",
'↑' => "xe2x86x91",
'→' => "xe2x86x92",
'↓' => "xe2x86x93",
'↔' => "xe2x86x94",
'↵' => "xe2x86xb5",
'⇐' => "xe2x87x90",
'⇑' => "xe2x87x91",
'⇒' => "xe2x87x92",
'⇓' => "xe2x87x93",
'⇔' => "xe2x87x94",
'∀' => "xe2x88x80",
'∂' => "xe2x88x82",
'∃' => "xe2x88x83",
'∅' => "xe2x88x85",
'∇' => "xe2x88x87",
'∈' => "xe2x88x88",
'∉' => "xe2x88x89",
'∋' => "xe2x88x8b",
'∏' => "xe2x88x8f",
'∑' => "xe2x88x91",
'−' => "xe2x88x92",
'∗' => "xe2x88x97",
'√' => "xe2x88x9a",
'∝' => "xe2x88x9d",
'∞' => "xe2x88x9e",
'∠' => "xe2x88xa0",
'∧' => "xe2x88xa7",
'∨' => "xe2x88xa8",
'∩' => "xe2x88xa9",
'∪' => "xe2x88xaa",
'∫' => "xe2x88xab",
'∴' => "xe2x88xb4",
'∼' => "xe2x88xbc",
'≅' => "xe2x89x85",
'≈' => "xe2x89x88",
'≠' => "xe2x89xa0",
'≡' => "xe2x89xa1",
'≤' => "xe2x89xa4",
'≥' => "xe2x89xa5",
'⊂' => "xe2x8ax82",
'⊃' => "xe2x8ax83",
'⊄' => "xe2x8ax84",
'⊆' => "xe2x8ax86",
'⊇' => "xe2x8ax87",
'⊕' => "xe2x8ax95",
'⊗' => "xe2x8ax97",
'⊥' => "xe2x8axa5",
'⋅' => "xe2x8bx85",
'⌈' => "xe2x8cx88",
'⌉' => "xe2x8cx89",
'⌊' => "xe2x8cx8a",
'⌋' => "xe2x8cx8b",
'⟨' => "xe2x8cxa9",
'⟩' => "xe2x8cxaa",
'◊' => "xe2x97x8a",
'♠' => "xe2x99xa0",
'♣' => "xe2x99xa3",
'♥' => "xe2x99xa5",
'♦' => "xe2x99xa6",
'Œ' => "xc5x92",
'œ' => "xc5x93",
'Š' => "xc5xa0",
'š' => "xc5xa1",
'Ÿ' => "xc5xb8",
'ˆ' => "xcbx86",
'˜' => "xcbx9c",
' ' => "xe2x80x82",
' ' => "xe2x80x83",
' ' => "xe2x80x89",
'‌' => "xe2x80x8c",
'‍' => "xe2x80x8d",
'‎' => "xe2x80x8e",
'‏' => "xe2x80x8f",
'–' => "xe2x80x93",
'—' => "xe2x80x94",
'‘' => "xe2x80x98",
'’' => "xe2x80x99",
'‚' => "xe2x80x9a",
'“' => "xe2x80x9c",
'”' => "xe2x80x9d",
'„' => "xe2x80x9e",
'†' => "xe2x80xa0",
'‡' => "xe2x80xa1",
'‰' => "xe2x80xb0",
'‹' => "xe2x80xb9",
'›' => "xe2x80xba",
'€' => "xe2x82xac",
);
$htmlspecialchars = array(
'"' => "x22",
'&' => "x26",
'<' => "x3c",
'>' => "x3e",
);
if ($is_htmlspecialchars) {
$table += $htmlspecialchars;
}
preg_match_all('/&[a-zA-Z]+d*;/s', $s, $m, null, $pos);
foreach (array_unique($m[0]) as $entity) {
if (array_key_exists($entity, $table)) {
$s = str_replace($entity, $table[$entity], $s);
}
}
if (($pos = strpos($s, '&#')) !== false) {
$htmlspecialchars_flip = array_flip($htmlspecialchars);
$s = preg_replace(
'/&#((x)[da-fA-F]{2,4}|d{1,4});/se', '(array_key_exists($a = pack("C", $d = ("$2") ? hexdec("$1") : "$1"), $htmlspecialchars_flip) && ! $is_htmlspecialchars) ?
$htmlspecialchars_flip[$a] :
iconv("UCS-2BE", "UTF-8", pack("n", $d))', $s, -1, $pos);
}
return $s;
}
static function strip_tags_smart(
$s, array $allowable_tags = null, $is_format_spaces = false, array $pair_tags = array('script', 'style', 'map', 'iframe', 'frameset', 'object', 'applet', 'comment', 'button'), array $para_tags = array('p', 'td', 'th', 'li', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'div', 'form', 'title')
) {
static $_callback_type = false;
static $_allowable_tags = array();
static $_para_tags = array();
static $re_attrs_fast_safe = '(?> (?>[x20rnt]+|xc2xa0)+ #пробельные символы (д.б. обязательно)
(?>
#правильные атрибуты
[^>"']+
| (?<=[=x20rnt]|xc2xa0) "[^"]*"
| (?<=[=x20rnt]|xc2xa0) '[^']*'
#разбитые атрибуты
| [^>]+
)*
)?';
if (is_array($s) && $_callback_type === 'strip_tags') {
$tag = strtolower($s[1]);
if ($_allowable_tags &&
(array_key_exists($tag, $_allowable_tags) || array_key_exists('<' . trim(strtolower($s[0]), '< />') . '>', $_allowable_tags))
) {
return $s[0];
}
if ($tag == 'br') {
return "rn";
}
if ($_para_tags && array_key_exists($tag, $_para_tags)) {
return "rnrn";
}
return '';
}
if (($pos = strpos($s, '<') === false) || strpos($s, '>', $pos) === false) {
return $s;
}
$re_tags = '/<[/!]? ([a-zA-Z][a-zA-Zd]* (?>:[a-zA-Z][a-zA-Zd]*)?)' . $re_attrs_fast_safe . '/?>/sx';
$patterns = array(
'/<([?%]) .*? \1>/sx',
'/<![CDATA[ .*? ]]>/sx',
'/<!--.*?-->/s',
'/<! (?>--)?
[
(?> [^]"']+ | "[^"]*" | '[^']*' )*
]
(?>--)?
>/sx',
);
if ($pair_tags) {
foreach ($pair_tags as $k => $v) {
$pair_tags[$k] = preg_quote($v, '/');
}
$patterns[] = '/<((?i:' . implode('|', $pair_tags) . '))' . $re_attrs_fast_safe . '> .*? </(?i:\1)' . $re_attrs_fast_safe . '>/sx';
}
$i = 0;
$max = 99;
while ($i < $max) {
$s2 = preg_replace($patterns, '', $s);
if ($i == 0) {
$is_html = ($s2 != $s || preg_match($re_tags, $s2));
if ($is_html) {
$s2 = strtr($s2, "x09x0ax0cx0d", ' ');
if ($allowable_tags) {
$_allowable_tags = array_flip($allowable_tags);
}
if ($para_tags) {
$_para_tags = array_flip($para_tags);
}
}
}
if ($is_html) {
$_callback_type = 'strip_tags';
$s2 = preg_replace_callback($re_tags, __FUNCTION__, $s2);
$_callback_type = false;
}
if ($s === $s2) {
break;
}
$s = $s2;
$i++;
}
if ($i >= $max) {
$s = strip_tags($s);
}
if ($is_format_spaces || $is_html) {
$s = preg_replace('/x20x20+/s', ' ', trim($s));
$s = str_replace(array("rnx20", "x20rn"), "rn", $s);
$s = preg_replace('/rn[rn]+/s', "rnrn", $s);
}
return $s;
}
#антимат сделает автоматическое предупреждение, а затем бан
static function antimat($str) {
global $user, $time, $set;
if ($set['antimat']) {
$antimat = &$_SESSION['antimat'];
$censure = self::censure($str);
if ($censure) {
$antimat[$censure] = $time;
if (count($antimat) > 3 && isset($user) && $user['level']) { // если сделано больше 3-х предупреждений
$prich = "Обнаружен мат: $censure";
$timeban = $time + 60 * 60; // бан на час
mysql_query("INSERT INTO `ban` (`id_user`, `id_ban`, `prich`, `time`) VALUES ('$user[id]', '0', '$prich', '$timeban')");
admin_log('Пользователи', 'Бан', "Бан пользователя '[url=/amd_panel/ban.php?id=$user[id]]$user[nick][/url]' (id#$user[id]) до " . vremja($timeban) . " по причине '$prich'");
header('Location: /ban.php?' . SID);
exit;
}
return $censure;
} else
return false;
} else
return false;
}
static function extract16color($color16) {
$mask16 = array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F");
$color_mask = array("r", "g", "b");
$true_color = array(
"r" => 0,
"g" => 0,
"b" => 0);
$color16 = substr($color16, 1);
for ($icm = 0; $icm < count($color_mask); $icm++) {
$color16_temp = array(substr($color16, ($icm * 2), 1), substr($color16, ($icm * 2) + 1, 1));
for ($ic = 0; $ic < 2; $ic++) {
for ($i = 0; $i < count($mask16); $i++) {
if ($color16_temp[$ic] == $mask16[$i]) {
$color16_temp[$ic] = $i;
break;
}
}
}
$true_color[$color_mask[$icm]] = ((int) $color16_temp[0] * 16) + (int) $color16_temp[1];
}
return $true_color;
}
static function make16color($color10) {
$mask16 = array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F");
$color_mask = array("r", "g", "b");
$true_color = "#";
for ($icm = 0; $icm < count($color_mask); $icm++) {
$color10_temp = (int) $color10[$color_mask[$icm]];
$true_color .= $mask16[(int) ($color10_temp / 16)];
$true_color .= $mask16[$color10_temp % 16];
}
return $true_color;
}
static function gradient($text, $sColor, $eColor) {
$color_mask = array("r", "g", "b");
$color_move = array(
"r" => 0,
"g" => 0,
"b" => 0);
$color_add = array(
"r" => 0,
"g" => 0,
"b" => 0);
$word = array();
$length = strlen($text);
$output = "";
$Gzip = "";
$current_color = "";
$max = 0;
if ($length > 0) {
$sColor = self::extract16color($sColor);
$eColor = self::extract16color($eColor);
$cColor = $sColor;
for ($i = 0; $i < count($color_mask); $i++) {
$temp = $sColor[$color_mask[$i]] - $eColor[$color_mask[$i]];
$color_add[$color_mask[$i]] = abs($temp);
if (abs($temp) > $max) {
$max = abs($temp);
}
if ($temp < 0) {
$color_move[$color_mask[$i]] = 1;
} else if ($temp > 0) {
$color_move[$color_mask[$i]] = - 1;
} else {
$color_move[$color_mask[$i]] = 0;
}
}
for ($i = 0; $i < $length; $i++) {
$char = substr($text, $i, 1);
$test = ord($char);
if ($test >= 128 and $test <= 255 | $test = "") {
$char = substr($text, $i, 2);
$i++;
}
$word[] = $char;
}
}
$length = count($word);
$koeff_add = @(($max / $length) / $max) * 100;
for ($i = 0; $i < $length; $i++) {
for ($i2 = 0; $i2 < count($color_mask); $i2++) {
$add = (($color_add[$color_mask[$i2]] / 100) * $koeff_add) * $color_move[$color_mask[$i2]];
$cColor[$color_mask[$i2]] += $add;
}
$current_color = self::make16color($cColor);
if (!$i) {
$output .= '<font color = "' . $current_color . '">' . $word[$i];
$Gzip = $current_color;
} else {
if ($current_color == $Gzip | $word[$i] == " ") {
$output .= $word[$i];
} else {
$output .= '</font><font color = "' . $current_color . '">' . $word[$i];
$Gzip = $current_color;
}
}
}
if (strlen($output)) {
$output .= "</font>";
}
return $output;
}
static function smiles($msg) {
$q = mysql_query("SELECT * FROM `smiles_spis`");
while ($post = mysql_fetch_array($q)) {
$msg = str_replace($post['sim'], "<img src = '/style/img/smiles/emotion_$post[name].png' alt = '$post[name]' />", $msg);
}
return $msg;
}
static function cut_text($text, $maxwords = 10, $maxchar = 30) {
$sep = ' ';
$words = @preg_split(" ", $text);
$char = iconv_strlen($text, 'utf-8');
if (count($words) > $maxwords) {
$text = join($sep, array_slice($words, 0, $maxwords));
}
return $text;
}
#Получение подстроки
static function substr($text, $len, $start = 0, $mn = ' (...)') {
$text = trim($text);
if (function_exists('mb_substr')) {
return mb_substr($text, $start, $len) . (mb_strlen($text) > $len - $start ? $mn : null);
}
if (function_exists('iconv')) {
return iconv_substr($text, $start, $len) . (iconv_strlen($text) > $len - $start ? $mn : null);
}
return $text;
}
#Фильтрация текста с ограничением длины в зависимости от типа браузера.
static function for_opis($text) {
$text = self::substr($text, IS_WEB == 'web' ? 1000 : 300);
$text = self::toOutput($text);
return $text;
}
static function toOutput($str, $br = 1, $html = 1, $smiles = 1, $links = 1, $bbcode = 1) {
if ($html) {
$str = htmlentities($str, ENT_QUOTES, 'UTF-8');
} // преобразуем все к нормальному перевариванию браузером
if ($links) {
$str = links($str);
} // обработка ссылок
if ($bbcode) {
$tmp_str = $str;
$str = self::bbcode($str); // обработка bbcode
}
if ($smiles && $tmp_str == $str) {
$str = self::smiles($str);
} // вставка смайлов
if ($br) {
$str = self::br($str); // переносы строк
}
// обработка старых цитат с числом в теге
$str = preg_replace('#[(/?)quote_([0-9]+)(]|=)#ui', '[1quote3', $str);
// преобразование ссылки на youtube ролик в ИИсщву
$str = preg_replace('#(^|s|(|])((https?://)?www.youtube.com/watch?(.*?&)*v=([^ rnt`'"<]+))(,|[|<|s|$)#iuU', '1[youtube]5[/youtube]6', $str);
// преобразование ссылок в тег URL
$str = preg_replace('#(^|s|(|])([a-z]+://([^ rnt`'"<]+))(,|[|<|s|$)#iuU', '1[url="2"]2[/url]4', $str);
return $str;
}
# переносы строк
static function br($msg, $br = '<br />') {
return preg_replace("#((<br( ?/?)>)|n|r)+#i", $br, $msg);
}
# Вырезает все нечитаемые символы
static function esc($text, $br = NULL) {
if ($br != NULL) {
for ($i = 0; $i <= 31; $i++) {
$text = str_replace(chr($i), NULL, $text);
}
} else {
for ($i = 0; $i < 10; $i++) {
$text = str_replace(chr($i), NULL, $text);
}
for ($i = 11; $i < 20; $i++) {
$text = str_replace(chr($i), NULL, $text);
}
for ($i = 21; $i <= 31; $i++) {
$text = str_replace(chr($i), NULL, $text);
}
}
return $text;
}
static function auto_bb($form, $field) {
global $bb_start;
$out = '';
if (!$bb_start) {
$out = '<script language="JavaScript" type="text/javascript">;
function tag(text1, text2) {
if ((document.selection)) {
document.' . $form . '.' . $field . '.focus();
document.' . $form . '.document.selection.createRange().text = text1+document.' . $form . '.document.selection.createRange().text+text2;
} else if(document.forms['' . $form . ''].elements['' . $field . ''].selectionStart!=undefined) {
var element = document.forms['' . $form . ''].elements['' . $field . ''];
var str = element.value;
var start = element.selectionStart;
var length = element.selectionEnd - element.selectionStart;
element.value = str.substr(0, start) + text1 + str.substr(start, length) + text2 + str.substr(start + length);
document.forms['' . $form . ''].elements['' . $field . ''].focus();
} else document.' . $form . '.' . $field . '.value += text1+text2;
document.forms['' . $form . ''].elements['' . $field . ''].focus();}</script>';
$bb_start = 1;
}
return $out . '<div style="margin:1px;padding:2px;">
<a href="javascript:tag('[b]', '[/b]')"><img src="/style/img/bb/b.png" alt="b" title="Жирный"/></a>
<a href="javascript:tag('[i]', '[/i]')"><img src="/style/img/bb/i.png" alt="i" title="Наклонный"/></a>
<a href="javascript:tag('[u]', '[/u]')"><img src="/style/img/bb/u.png" alt="u" title="Подчёркнутый"/></a>
<a href="javascript:tag('[s]', '[/s]')"><img src="/style/img/bb/s.png" alt="s" title="Перечёркнутый"/></a>
<a href="javascript:tag('[php]', '[/php]')"><img src="/style/img/bb/php.png" alt="cod" title="Код"/></a>
<a href="javascript:tag('[url=]', '[/url]')"><img src="/style/img/bb/l.png" alt="url" title="Ссылка" /></a>
<a href="javascript:tag('[red]', '[/red]')"><img src="/style/img/bb/red.png" alt="red" title="Красный"/></a>
<a href="javascript:tag('[green]', '[/green]')"><img src="/style/img/bb/green.png" alt="green" title="Зелёный"/></a>
<a href="javascript:tag('[blue]', '[/blue]')"><img src="/style/img/bb/blue.png" alt="blue" title="Синий"/></a><br />
</div>';
}
#получение кол-ва символов строки
static function utf8_strlen($str) {
if (function_exists('mb_substr')) {
return mb_strlen($str);
}
if (function_exists('iconv')) {
return iconv_strlen($str);
} else {
#извращенный способ при отсутствии библиотек
static $rus;
if (!isset($rus)) {
$rus = array('й', 'ц', 'у', 'к', 'е', 'н', 'г', 'ш', 'щ', 'з', 'х', 'ъ', 'ф', 'ы', 'в', 'а', 'п', 'р', 'о', 'л', 'д', 'ж', 'э', 'я', 'ч', 'с', 'м', 'и', 'т', 'ь', 'б', 'ю', 'Й', 'Ц', 'У', 'К', 'Е', 'Н', 'Г', 'Ш', 'Щ', 'З', 'Х', 'Ъ', 'Ф', 'Ы', 'В', 'А', 'П', 'Р', 'О', 'Л', 'Д', 'Ж', 'Э', 'Я', 'Ч', 'С', 'М', 'И', 'Т', 'Ь', 'Б', 'Ю');
}
return strlen(str_replace($rus, '0', $str));
}
}
#Получение подстроки
static function utf8_substr($str, $len, $dot = 1, $start = 0) {
if (self::utf8_strlen($str) > $len) {
if (function_exists('mb_substr')) {
$str = mb_substr($str, $start, $len);
}
if (function_exists('iconv')) {
$str = iconv_substr($str, $start, $len);
} else {
$out = substr($str, $start, $len);
} // могут появиться нечитаемые символы
if ($dot) {
$str.=' ...';
}
}
return $str;
}
#Транслитерация русского текста в английский
static function translit($string) {
$table = array(
'А' => 'A',
'Б' => 'B',
'В' => 'V',
'Г' => 'G',
'Ґ' => 'G',
'Д' => 'D',
'Е' => 'E',
'Є' => 'YE',
'Ё' => 'YO',
'Ж' => 'ZH',
'З' => 'Z',
'И' => 'I',
'І' => 'I',
'Ї' => 'YI',
'Й' => 'J',
'К' => 'K',
'Л' => 'L',
'М' => 'M',
'Н' => 'N',
'О' => 'O',
'П' => 'P',
'Р' => 'R',
'С' => 'S',
'Т' => 'T',
'У' => 'U',
'Ў' => 'U',
'Ф' => 'F',
'Х' => 'H',
'Ц' => 'C',
'Ч' => 'CH',
'Ш' => 'SH',
'Щ' => 'CSH',
'Ь' => '',
'Ы' => 'Y',
'Ъ' => '',
'Э' => 'E',
'Ю' => 'YU',
'Я' => 'YA',
'а' => 'a',
'б' => 'b',
'в' => 'v',
'г' => 'g',
'ґ' => 'g',
'д' => 'd',
'е' => 'e',
'є' => 'ye',
'ё' => 'yo',
'ж' => 'zh',
'з' => 'z',
'и' => 'i',
'і' => 'i',
'ї' => 'yi',
'й' => 'j',
'к' => 'k',
'л' => 'l',
'м' => 'm',
'н' => 'n',
'о' => 'o',
'п' => 'p',
'р' => 'r',
'с' => 's',
'т' => 't',
'у' => 'u',
'ў' => 'u',
'ф' => 'f',
'х' => 'h',
'ц' => 'c',
'ч' => 'ch',
'ш' => 'sh',
'щ' => 'csh',
'ь' => '',
'ы' => 'y',
'ъ' => '',
'э' => 'e',
'ю' => 'yu',
'я' => 'ya',
);
return str_replace(array_keys($table), array_values($table), $string);
}
static function tr_loads($in) {
return preg_replace('#[^A-z0-9_-.()]+#ui', '_', $in);
}
static function bbcodehightlight($arr) {
$arr[0] = html_entity_decode($arr[0], ENT_QUOTES, 'UTF-8');
return '<div class="cit" style="overflow:scroll;clip:auto;max-width:480px;">' . preg_replace('#<code>(.*?)</code>#si', '\1', highlight_string($arr[0], 1)) . '</div>' . "n";
}
static function BBcode($msg) {
global $set, $user;
$bbcode = array(
'/[i](.+)[/i]/isU' => '<em>$1</em>',
'/[dotss](.+)[/dotss]/isU' => '<span style="text-decoration:underline">$1</span>',
'/[b](.+)[/b]/isU' => '<strong>$1</strong>',
'/[u](.+)[/u]/isU' => '<span style="text-decoration:underline;">$1</span>',
'/[ut](.+)[/ut]/isU' => '<span style="border-bottom: 1px dotted;">$1</span>',
'/[xx-small](.+)[/xx-small]/isU' => '<span style="font-size:xx-small;">$1</span>',
'/[x-small](.+)[/x-small]/isU' => '<span style="font-size:x-small;">$1</span>',
'/[in](.+)[/in]/isU' => '<input type="text" value="$1" />',
'/[das](.+)[/das]/isU' => '<span style="border:1px dashed;">$1</span>',
'/[marq](.+)[/marq]/isU' => '<marquee>$1</marquee>',
'/[c](.+)[/c]/isU' => '<center>$1</center>',
'/[sol](.+)[/sol]/isU' => '<span style="border:1px solid;">$1</span>',
'/[s](.+)[/s]/isU' => '<span style="text-decoration:line-through;">$1</span>',
'/[up](.+)[/up]/isU' => '<span style="text-decoration:overline;">$1</span>',
'/[bl](.+)[/bl]/isU' => '<span style="text-decoration:blink;">$1</span>',
'/[bblue](.+)[/bblue]/isU' => '<span style="background-color : blue;">$1</span>',
'/[bDeepPink](.+)[/bDeepPink]/isU' => '<span style="background-color : bDeepPink;">$1</span>',
'/[bLightSalmon](.+)[/bLightSalmon]/isU' => '<span style="background-color : bLightSalmon;">$1</span>',
'/[bLime](.+)[/bLime]/isU' => '<span style="background-color : bLime;">$1</span>',
'/[bDarkOrange](.+)[/bDarkOrange]/isU' => '<span style="background-color : bDarkOrange;">$1</span>',
'/[dLimeGreen](.+)[/dLimeGreen]/isU' => '<span style="background-color : LimeGreen;">$1</span>',
'/[bFireBrick](.+)[/bFireBrick]/isU' => '<span style="background-color : bFireBrick;">$1</span>',
'/[bOrangeRed](.+)[/bOrangeRed]/isU' => '<span style="background-color : bOrangeRed;">$1</span>',
'/[bGoldenrod](.+)[/bGoldenrod]/isU' => '<span style="background-color : Goldenrod;">$1</span>',
'/[bTurquoise](.+)[/bTurquoise]/isU' => '<span style="background-color : Turquoise;">$1</span>',
'/[byellow](.+)[/byellow]/isU' => '<span style="background-color : yellow;">$1</span>',
'/[bbrown](.+)[/bbrown]/isU' => '<span style="background-color : brown;">$1</span>',
'/[bwhite](.+)[/bwhite]/isU' => '<span style="background-color : white;">$1</span>',
'/[borange](.+)[/borange]/isU' => '<span style="background-color : orange;">$1</span>',
'/[bblack](.+)[/bblack]/isU' => '<span style="background-color : black;">$1</span>',
'/[bgrey](.+)[/bgrey]/isU' => '<span style="background-color : grey;">$1</span>',
'/[bpink](.+)[/bpink]/isU' => '<span style="background-color : pink;">$1</span>',
'/[bviolet](.+)[/bviolet]/isU' => '<span style="background-color : violet;">$1</span>', '/[bblue](.+)[/bblue]/isU' => '<span style="background-color : blue;">$1</span>',
'/[byellow](.+)[/byellow]/isU' => '<span style="background-color : yellow;">$1</span>',
'/[bbrown](.+)[/bbrown]/isU' => '<span style="background-color : brown;">$1</span>',
'/[bwhite](.+)[/bwhite]/isU' => '<span style="background-color : white;">$1</span>',
'/[borange](.+)[/borange]/isU' => '<span style="background-color : orange;">$1</span>',
'/[bblack](.+)[/bblack]/isU' => '<span style="background-color : black;">$1</span>',
'/[bgrey](.+)[/bgrey]/isU' => '<span style="background-color : grey;">$1</span>',
'/[bpink](.+)[/bpink]/isU' => '<span style="background-color : pink;">$1</span>',
'/[bviolet](.+)[/bviolet]/isU' => '<span style="background-color : violet;">$1</span>', '/[bred](.+)[/bred]/isU' => '<span style="background-color : red;">$1</span>',
'/[bgreen](.+)[/bgreen]/isU' => '<span style="background-color : green;">$1</span>', '/[big](.+)[/big]/isU' => '<span style="font-size:large;">$1</span>',
'/[das](.+)[/das]/isU' => '<span style="border:1px dashed;">$1</span>',
'/[dot](.+)[/dot]/isU' => '<span style="border:1px dotted;">$1</span>',
'/[dou](.+)[/dou]/isU' => '<span style="border:3px double #E1E1E4;">$1</span>', '/[dot](.+)[/dot]/isU' => '<span style="border:1px dotted;">$1</span>',
'/[dou](.+)[/dot]/isU' => '<span style="border:3px double #E1E1E4;">$1</span>', '/[dot](.+)[/dot]/isU' => '<span style="border:1px dotted;">$1</span>',
'/[scr-1](.+)[/scr-1]/isU' => '<span style="background-color:Peru;"><span style="color:LightPink;"><span style="border:1px dashed;">$1</span></span></span>',
'/[scr-w](.+)[/scr-w]/isU' => '<span style="background-color:#ffffff;"><span style="color:#ffffff;"><span style="border:1px dashed;">$1</span></span></span>',
'/[scr-b](.+)[/scr-b]/isU' => '<span style="background-color:#000000;"><span style="color:#000000;"><span style="border:1px dashed;">$1</span></span></span>',
'/[scr-bl](.+)[/scr-bl]/isU' => '<span style="background-color:Blue;"><span style="color:Blue;"><span style="border:1px dashed;">$1</span></span></span>',
'/[scr-r](.+)[/scr-r]/isU' => '<span style="background-color:red;"><span style="color:red;"><span style="border:1px dashed;">$1</span></span></span>',
'/[scr-g](.+)[/scr-g]/isU' => '<span style="background-color:green;"><span style="color:green;"><span style="border:1px dashed;">$1</span></span></span>',
'/[scr-d](.+)[/scr-d]/isU' => '<span style="background-color:DarkMagenta;"><span style="color:DarkMagenta;"><span style="border:1px dashed;">$1</span></span></span>',
'/[scr-c](.+)[/scr-c]/isU' => '<span style="background-color:Crimson;"><span style="color:Crimson;"><span style="border:1px dashed;">$1</span></span></span>',
'/[scr-bu](.+)[/scr-bu]/isU' => '<span style="background-color:Burlywood;"><span style="color:Burlywood;"><span style="border:1px dashed;">$1</span></span></span>',
'/[scr-k](.+)[/scr-k]/isU' => '<span style="background-color:Khaki;"><span style="color:Khaki;"><span style="border:1px dashed;">$1</span></span></span>',
'/[scr-bl](.+)[/scr-bl]/isU' => '<span style="background-color:Blue;"><span style="color:Blue;"><span style="border:1px dashed;">$1</span></span></span>',
'/[scr-r](.+)[/scr-r]/isU' => '<span style="background-color:red;"><span style="color:red;"><span style="border:1px dashed;">$1</span></span></span>',
'/[scr-g](.+)[/scr-g]/isU' => '<span style="background-color:green;"><span style="color:green;"><span style="border:1px dashed;">$1</span></span></span>',
'/[scr-d](.+)[/scr-d]/isU' => '<span style="background-color:DarkMagenta;"><span style="color:DarkMagenta;"><span style="border:1px dashed;">$1</span></span></span>',
'/[scr-c](.+)[/scr-c]/isU' => '<span style="background-color:Crimson;"><span style="color:Crimson;"><span style="border:1px dashed;">$1</span></span></span>',
'/[scr-bu](.+)[/scr-bu]/isU' => '<span style="background-color:Burlywood;"><span style="color:Burlywood;"><span style="border:1px dashed;">$1</span></span></span>',
'/[scr-k](.+)[/scr-k]/isU' => '<span style="background-color:Khaki;"><span style="color:Khaki;"><span style="border:1px dashed;">$1</span></span></span>',
'/[ramk-1](.+)[/ramk-1]/isU' => '<span style="background-color:LightGreen;"><span style="color:Khaki;"><span style="border:1px dashed;">$1</span></span></span>',
'/[ramk-2](.+)[/ramk-2]/isU' => '<span style="background-color:MediumSeaGreen;"><span style="color:Khaki;"><span style="border:1px dashed;">$1</span></span></span>',
'/[ramk-3](.+)[/ramk-3]/isU' => '<span style="background-color:ForestGreen;"><span style="color:Khaki;"><span style="border:1px dashed;">$1</span></span></span>',
'/[ramk-4](.+)[/ramk-4]/isU' => '<span style="background-color:PaleTurquoise;"><span style="color:Khaki;"><span style="border:1px dashed;">$1</span></span></span>',
'/[ramk-5](.+)[/ramk-5]/isU' => '<span style="background-color:SteelBlue;"><span style="color:Khaki;"><span style="border:1px dashed;">$1</span></span></span>',
'/[ramk-6](.+)[/ramk-6]/isU' => '<span style="background-color:Orchid;"><span style="color:Khaki;"><span style="border:1px dashed;">$1</span></span></span>',
'/[ramk-7](.+)[/ramk-7]/isU' => '<span style="background-color:DimGray;"><span style="color:Khaki;"><span style="border:1px dashed;">$1</span></span></span>',
'/[bit](.+)[/bit]/isU' => '<marquee behavior=alternate>$1</marquee>',
'/[sizem1](.+)[/sizem1]/isU' => '<font size=-1>$1</font size>',
'/[sizem2](.+)[/sizem2]/isU' => '<font size=-2>$1</font size>',
'/[sizem3](.+)[/sizem3]/isU' => '<font size=3>$1</font size>',
'/[sizem4](.+)[/sizem4]/isU' => '<font size=4>$1</font size>',
'/[sizem5](.+)[/sizem5]/isU' => '<font size=5>$1</font size>',
'/[sizem6](.+)[/sizem6]/isU' => '<font size=6>$1</font size>',
'/[sizem7](.+)[/sizem7]/isU' => '<font size=7>$1</font size>',
'/[textp](.+)[/textp]/isU' => '<p align="right">$1</p>',
'/[prlink](.+)[/prlink]/isU' => '<blockquote style="border: 3px solid rgb(218, 112, 214); margin: 0px; padding: 5px;">$1</blockquote>',
'/[prlink2](.+)[/prlink2]/isU' => '<blockquote style="border: 1px solid rgb(218, 112, 214); margin: 0px; padding: 5px;">$1</blockquote>',
'/[prlink3](.+)[/prlink3]/isU' => '<blockquote style="border: 1px solid rgb(218, 112, 214); margin: 1px; padding: 1px;">$1</blockquote>',
'/[prlink4](.+)[/prlink4]/isU' => '<blockquote style="border: 1px solid rgb(110, 112, 214); margin: 1px; padding: 1px;">$1</blockquote>',
'/[prlink5](.+)[/prlink5]/isU' => '<blockquote style="border: 1px solid rgb(666, 43, 211); margin: 1px; padding: 1px;">$1</blockquote>',
'/[prlink6](.+)[/prlink6]/isU' => '<blockquote style="border: 3px solid rgb(218, 112, 214); margin: 0px; padding: 5px;">$1</blockquote>',
'/[prlink7](.+)[/prlink7]/isU' => '<blockquote style="border: 1px solid rgb(777, 43, 666); center: 0px; padding: 1px;">$1</blockquote>',
'/[ramkt](.+)[/ramkt]/isU' => '<blockquote style="BORDER-LEFT: #F70000 3px solid; padding: 15px; BORDER-TOP: #999931 3px solid; padding: 15px; BORDER-BOTTOM: #E3AF40 3px solid; padding: 15px; BORDER-RIGHT: #924E96 3px solid" padding: 15px>$1</blockquote>',
'/[rams](.+)[/rams]/isU' => '<blockquote style="BORDER-LEFT: #F70000 3px solid; padding: 15px; BORDER-TOP: #119931 3px solid; padding: 15px; BORDER-BOTTOM: #E3AF40 3px solid; padding: 15px; BORDER-RIGHT: #924E96 3px solid" padding: 15px>$1</blockquote>',
'/[rams2](.+)[/rams2]/isU' => '<blockquote style=:BORDER-LEFT: #F70000 1px solid; padding: 5px; BORDER-TOP: #119931 1px solid; padding: 3px; BORDER-BOTTOM: red 3px solid; padding: 1px; BORDER-RIGHT: #924E96 3px solid: padding: 1px>$1</blockquote>>',
'/[ramkt2](.+)[/ramkt2]/isU' => '<span style="border-style: dashed; border-color:yellow">$1</span> <br />',
'/[ramkt3](.+)[/ramkt3]/isU' => '<span style="border-style: dashed; border-color:LightGreen">$1</span>',
'/[ramkt4](.+)[/ramkt4]/isU' => '<span style="border-style: dashed; border-color:SteelBlue">$1</span>',
'/[ramkt5](.+)[/ramkt5]/isU' => '<span style="border-style: dashed; border-color:LightPink">$1</span>',
'/[ramkt6](.+)[/ramkt6]/isU' => '<span style="border-style: dashed; border-color:Gray">$1</span>',
'/[ramkt7](.+)[/ramkt7]/isU' => '<span style="border-style: dashed; border-color:White">$1</span>',
'/[ramkt8](.+)[/ramkt8]/isU' => '<span style="border-style: dashed; border-color:MediumSlateBlue">$1</span> ',
'/[ramkt9](.+)[/ramkt9]/isU' => '<span style="border-style: dashed; border-color:LightSalmon">$1</span>',
'/[ramkt10](.+)[/ramkt10]/isU' => '<span style="border-style: dashed; border-color:DarkOrange">$1</span>',
'/[ramkt11](.+)[/ramkt11]/isU' => '<span style="border-style: dashed; border-color:SpringGreen">$1</span>',
'/[ramkt12](.+)[/ramkt12]/isU' => '<span style="border-style: dashed; border-color:Yellow">$1</span>',
'/[ramkt13](.+)[/ramkt13]/isU' => '<span style="border-style: dashed; border-color:Gold">$1</span>',
'/[ramkt14](.+)[/ramkt14]/isU' => '<span style="border-style: dashed; border-color:DarkRed">$1</span>',
'/[ramkt15](.+)[/ramkt15]/isU' => '<span style="border-style: dashed; border-color:DeepPink">$1</span>',
'/[dou](.+)[/dou]/isU' => '<span style="border:3px double #E1E1E4;">$1</span>',
'/[dou](.+)[/dou]/isU' => '<span style="border:3px double #E1E1E4;">$1</span>',
'/[big](.+)[/big]/isU' => '<span style="font-size:large;">$1</span>',
'/[small](.+)[/small]/isU' => '<span style="font-size:small;">$1</span>',
'/[code](.+)[/code]/isU' => '<code>$1</code>',
'/[f=([0-9]+)/([0-9]+)/([0-9]+)](.+)[/f]/isU' => "<a href='/forum/$1/$2/$3'>$4</a>",
'/[u=([0-9]+)](.+)[/u]/isU' => "<a href='/info.php?id=$1'>$2</a>",
'/[red](.+)[/red]/isU' => '<span style="color:#ff0000;">$1</span>',
'/[yellow](.+)[/yellow]/isU' => '<span style="color:#ffff22;">$1</span>',
'/[green](.+)[/green]/isU' => '<span style="color:#00bb00;">$1</span>',
'/[blue](.+)[/blue]/isU' => '<span style="color:#0000bb;">$1</span>',
'/[brown](.+)[/brown]/isU' => '<span style="color:brown;">$1</span>',
'/[white](.+)[/white]/isU' => '<span style="color:#ffffff;">$1</span>',
'/[black](.+)[/black]/isU' => '<span style="color:black;">$1</span>',
'/[orange](.+)[/orange]/isU' => '<span style="color:orange;">$1</span>',
'/[pink](.+)[/pink]/isU' => '<span style="color:pink;">$1</span>',
'/[violet](.+)[/violet]/isU' => '<span style="color:violet;">$1</span>',
'/[gray](.+)[/gray]/isU' => '<span style="color:gray;">$1</span>',
'/[size=([0-9]+)](.+)[/size]/isU' => '<span style="font-size:$1px;">$2</span>',
'/[maroon](.+)[/maroon]/isU' => '<span style="color:maroon;">$1</span>',
'/[teal](.+)[/teal]/isU' => '<span style="color:teal;">$1</span>',
'/[scarlet](.+)[/scarlet]/isU' => '<span style="color:scarlet;">$1</span>',
'/[carmine](.+)[/carmine]/isU' => '<span style="color:carmine;">$1</span>',
'/[vermilion](.+)[/vermilion]/isU' => '<span style="color:vermilion;">$1</span>',
'/[alizarin](.+)[/alizarin]/isU' => '<span style="color:alizarin;">$1</span>',
'/[chestnut](.+)[/chestnut]/isU' => '<span style="color:chestnut;">$1</span>',
'/[crimson](.+)[/crimson]/isU' => '<span style="color:crimson;">$1</span>',
'/[darkcoral](.+)[/darkcoral]/isU' => '<span style="color:darkcoral;">$1</span>',
'/[burntsiena](.+)[/burntsiena]/isU' => '<span style="color:burntsiena;">$1</span>',
'/[burntsiena](.+)[/burntsiena]/isU' => '<span style="color:burntsiena;">$1</span>',
'/[coral](.+)[/coral]/isU' => '<span style="color:coral;">$1</span>',
'/[salmon](.+)[/salmon]/isU' => '<span style="color:salmon;">$1</span>',
'/[pinkorange](.+)[/pinkorange]/isU' => '<span style="color:#ff9966;">$1</span>',
'/[palepink](.+)[/palepink]/isU' => '<span style="color:palepink;">$1</span>',
'/[lavenderblush](.+)[/lavenderblush]/isU' => '<span style="color:lavenderblush;">$1</span>',
'/[carrot](.+)[/carrot]/isU' => '<span style="color:carrot;">$1</span>',
'/[jaco](.+)[/jaco]/isU' => '<span style="color:jaco;">$1</span>',
'/[tangerine](.+)[/tangerine]/isU' => '<span style="color:#ff8800;">$1</span>',
'/[margarine](.+)[/margarine]/isU' => '<span style="color:margarine;">$1</span>',
'/[safetyorange](.+)[/safetyorange]/isU' => '<span style="color:safetyorange;">$1</span>',
'/[palebrown](.+)[/palebrown]/isU' => '<span style="color:#987654;">$1</span>',
'/[palebrown](.+)[/palebrown]/isU' => '<span style="color:#442d25;">$1</span>',
'/[coffee](.+)[/coffee]/isU' => '<span style="color:#442d25;">$1</span>',
'/[bistre](.+)[/bistre]/isU' => '<span style="color:#3d2b1f;">$1</span>',
'/[cinnamon](.+)[/cinnamon]/isU' => '<span style="color:cinnamon;">$1</span>',
'/[byron](.+)[/byron]/isU' => '<span style="color:byron;">$1</span>',
'/[sepia](.+)[/sepia]/isU' => '<span style="color:sepia;">$1</span>',
'/[umber](.+)[/umber]/isU' => '<span style="color:umber;">$1</span>',
'/[schoolbus](.+)[/schoolbus]/isU' => '<span style="color:#ff8d00;">$1</span>',
'/[gold](.+)[/gold]/isU' => '<span style="color:gold;">$1</span>',
'/[mustard](.+)[/mustard]/isU' => '<span style="color:#ffdb58;">$1</span>',
'/[sandybrown](.+)[/sandybrown]/isU' => '<span style="color:#fcdd78;">$1</span>',
'/[lemon](.+)[/lemon]/isU' => '<span style="color:#fde910;">$1</span>',
'/[lime](.+)[/lime]/isU' => '<span style="color:lime;">$1</span>',
'/[olive](.+)[/olive]/isU' => '<span style="color:olive;">$1</span>',
'/[asparagus](.+)[/asparagus]/isU' => '<span style="color:asparagus;">$1</span>',
'/[ferngreen](.+)[/ferngreen]/isU' => '<span style="color:#4f7942;">$1</span>',
'/[toadinlove](.+)[/toadinlove]/isU' => '<span style="color:toadinlove;">$1</span>',
'/[vertdepomme](.+)[/vertdepomme]/isU' => '<span style="color:#34c924;">$1</span>',
'/[brightgreen](.+)[/brightgreen]/isU' => '<span style="color:#66ff00;">$1</span>',
'/[pistachio](.+)[/pistachio]/isU' => '<span style="color:#bef574;">$1</span>',
'/[Saint](.+)[/Saint]/isU' => ' <span style="color:green;"><marquee><span style="border:0px dotted;"><em><span style="text-decoration:underline;">TEKCT 3aMEHeH Ha CEKPETHbIN bb code <br /> </span></em></span></marquee><strong>xakep by Saint JumanG.ru i WmSait.ru</strong> </span>',
'/[greenyellow](.+)[/greenyellow]/isU' => '<span style="color:#adff2f;">$1</span>',
'/[chartreuse](.+)[/chartreuse]/isU' => '<span style="color:chartreuse;">$1</span>',
'/[mossgreen](.+)[/mossgreen]/isU' => '<span style="color:mossgreen;">$1</span>',
'/[palegreen](.+)[/palegreen]/isU' => '<span style="color:palegreen;">$1</span>',
'/[darkspringgreen](.+)[/darkspringgreen]/isU' => '<span style="color:#177245;">$1</span>',
'/[jade](.+)[/jade]/isU' => '<span style="color:jade;">$1</span>',
'/[navy](.+)[/navy]/isU' => '<span style="color:navy;">$1</span>',
'/[aqua](.+)[/aqua]/isU' => '<span style="color:aqua;">$1</span>',
'/[st](.+)[/st]/isU' => '<span style="color:#082567;"><span style="color:red;">[SUPPORT]</span> kidaem HA koh R329486466357 deneg 100000000 dolars i bb code propadet :D Saint</span>',
'/[moray](.+)[/moray]/isU' => '<span style="color:moray;">$1</span>',
'/[pinegreen](.+)[/pinegreen]/isU' => '<span style="color:#01796f;">$1</span>',
'/[robineggblue](.+)[/robineggblue]/isU' => '<span style="color:#00cccc;">$1</span>',
'/[turquoise](.+)[/turquoise]/isU' => '<span style="color:turquoise;">$1</span>',
'/[brightturquoise](.+)[/brightturquoise]/isU' => '<span style="color:#08e0de;">$1</span>',
'/[electric](.+)[/electric]/isU' => '<span style="color:#7df9ff;">$1</span>',
'/[paleblue](.+)[/paleblue]/isU' => '<span style="color:#afeeee;">$1</span>',
'/[sapphire](.+)[/sapphire]/isU' => '<span style="color:#082567;">$1</span>',
'/[powderblue](.+)[/powderblue]/isU' => '<span style="color:powderblue;">$1</span>',
'/[blacksea](.+)[/blacksea]/isU' => '<span style="color:#1a4780;">$1</span>',
'/[cobalt](.+)[/cobalt]/isU' => '<span style="color:cobalt;">$1</span>',
'/[denim](.+)[/denim]/isU' => '<span style="color:#0047ab;">$1</span>',
'/[royalblue](.+)[/royalblue]/isU' => '<span style="color:royalblue;">$1</span>',
'/[kleinblue](.+)[/kleinblue]/isU' => '<span style="color:#3a75c4;">$1</span>',
'/[azure](.+)[/azure]/isU' => '<span style="color:#007fff;">$1</span>',
'/[purple](.+)[/purple]/isU' => '<span style="color:purple;">$1</span>',
'/[amethyst](.+)[/amethyst]/isU' => '<span style="color:amethyst;">$1</span>',
'/[seroburomalinovyj](.+)[/seroburomalinovyj]/isU' => '<span style="color:#735184;">$1</span>',
'/[darkviolet](.+)[/darkviolet]/isU' => '<span style="color:#423181;">$1</span>',
'/[indigo](.+)[/indigo]/isU' => '<span style="color:indigo;">$1</span>',
'/[plum](.+)[/plum]/isU' => '<span style="color:plum;">$1</span>',
'/[silver](.+)[/silver]/isU' => '<span style="color:silver;">$1</span>',
'/[wetasphalt](.+)[/wetasphalt]/isU' => '<span style="color:#505050;">$1</span>',
'/[anthracite](.+)[/anthracite]/isU' => '<span style="color:#808080;">$1</span>',
'/[slategray](.+)[/slategray]/isU' => '<span style="color:slategray;">$1</span>',
'/[lightgrey](.+)[/lightgrey]/isU' => '<span style="color:lightgrey;">$1</span>',
'/[quartz](.+)[/quartz]/isU' => '<span style="color:quartz;">$1</span>',
'/[darkbrown](.+)[/darkbrown]/isU' => '<span style="color:darkbrown;">$1</span>',
'/[f=([0-9]+)/([0-9]+)/([0-9]+)](.+)[/f]/isU' => "<a href='/forum/$1/$2/$3'>$4</a>",
'/[u=([0-9]+)](.+)[/u]/isU' => "<a href='/info.php?id=$1'>$2</a>",
'/[img](.+)[/img]/isU' => '<img src="$1" alt="" />'
);
$bbcode['/[color=([ -9a-zA-Z]+)](.+)[/color]/isU'] = '<span style="color:#$1;">$2</span>';
$bbcode['/[color=([ -9a-zA-Z]+)](.+)[/color]/isU'] = '<span style="color:#$1;">$2</span>';
$bbcode['/[cvet=([ -9a-zA-Z]+)](.+)[/cvet]/isU'] = '<span style="color:#$1;">$2</span>';
$bbcode['/[cvet=([ -9a-zA-Z]+)](.+)[/cvet]/isU'] = '<span style="color:#$1;">$2</span>';
if ($set['bb_admin']) {
if ($user['group_access'] > 1) {
$bbcode['/[A](.+)[/A]/isU'] = "<span style = 'text-decoration: underline;'><span style = 'color: green;'>*</span></span><span style = 'color: green;'> $1 </span><span style = 'text-decoration: underline;'><span style = 'color: green'>*</span></span>";
} else {
$bbcode['/[A](.+)[/A]/isU'] = '<span style="text-decoration:underline;">Текст доступен только Администрации</span>';
}
}
if ($set['bb_admin']) {
if ($user['group_access'] > 2) {
$bbcode['/[M](.+)[/M]/isU'] = '<span style="text-decoration:underline;"><span style="color:green">*</span></span><span style="color:green"> $1 </span><span style="text-decoration:underline;"><span style="color:green">*</span></span>';
} else {
$bbcode['/[M](.+)[/M]/isU'] = '<span style="text-decoration:underline;">Текст доступен только Администрации </span>';
}
}
if ($set['bb_admin']) {
if ($user['group_access'] > 3) {
$bbcode['/[ex](.+)[/ex]/isU'] = '<span style="text-decoration:underline;"><span style="color:green">*</span></span><span style="color:green"> $1 </span><span style="text-decoration:underline;"><span style="color:green">*</span></span>';
} else {
$bbcode['/[ex](.+)[/ex]/isU'] = '<span style="text-decoration:underline;">Текст доступен только Администрации </span>';
}
}
if ($set['bb_admin']) {
if ($user['group_access'] > 4) {
$bbcode['/[G](.+)[/G]/isU'] = "<span style = 'border-style: dashed; border-color: gold;'>*</span><span style = 'color: green;'> $1 </span><span style = 'border-style: dashed; border-color: gold;'>*</span>";
} else {
$bbcode['/[G](.+)[/G]/isU'] = "<span style = 'text-decoration: underline;'>Текст доступен только Администрации </span>";
}
}
$bbcode['/[color=([#0-9a-zA-Z]+)](.+)[/color]/isU'] = '<span style="color:$1;">$2</span>';
$msg = preg_replace(array_keys($bbcode), array_values($bbcode), $msg);
$msg = preg_replace('#<?(.*?)?>#sui', 'bbcodehightlight', $msg);
$msg = preg_replace('#[you100](.*?)[/you100]#si', '
<object width="100" height="80">
<param name="movie" value="http://www.youtube.com/v/1?version=3">
</param>
<param name="allowFullScreen" value="true">
</param>
<embed src="http://www.youtube.com/v/1?version=3" type="application/x-shockwave-flash" width="100" height="80" allowfullscreen="true">
</embed></object>', $msg); #
$msg = preg_replace('#[you150](.*?)[/you150]#si', '
<object width="150" height="100">
<param name="movie" value="http://www.youtube.com/v/1?version=3">
</param>
<param name="allowFullScreen" value="true">
</param>
<embed src="http://www.youtube.com/v/1?version=3" type="application/x-shockwave-flash" width="150" height="100" allowfullscreen="true">
</embed></object>', $msg); #
$msg = preg_replace('#[you300](.*?)[/you300]#si', '
<object width="300" height="300">
<param name="movie" value="http://www.youtube.com/v/1?version=3">
</param>
<param name="allowFullScreen" value="true">
</param>
<embed src="http://www.youtube.com/v/1?version=3" type="application/x-shockwave-flash" width="300" height="300" allowfullscreen="true">
</embed></object>', $msg); #
$msg = preg_replace('#[you250](.*?)[/you250]#si', '
<object width="250" height="200">
<param name="movie" value="http://www.youtube.com/v/1?version=3">
</param>
<param name="allowFullScreen" value="true">
</param>
<embed src="http://www.youtube.com/v/1?version=3" type="application/x-shockwave-flash" width="250" height="200" allowfullscreen="true">
</embed></object>', $msg); #
$msg = preg_replace('#[you400](.*?)[/you400]#si', '
<object width="400" height="250">
<param name="movie" value="http://www.youtube.com/v/1?version=3">
</param>
<param name="allowFullScreen" value="true">
</param>
<embed src="http://www.youtube.com/v/1?version=3" type="application/x-shockwave-flash" width="400" height="250" allowfullscreen="true">
</embed></object>', $msg); #
$msg = preg_replace('#[you500](.*?)[/you500]#si', '
<object width="500" height="340">
<param name="movie" value="http://www.youtube.com/v/1?version=3">
</param>
<param name="allowFullScreen" value="true">
</param>
<embed src="http://www.youtube.com/v/1?version=3" type="application/x-shockwave-flash" width="500" height="340" allowfullscreen="true">
</embed></object>', $msg); #
$msg = preg_replace('#[you250](.*?)[/you250]#si', '
<object width="250" height="150">
<param name="movie" value="http://www.youtube.com/v/1?version=3">
</param>
<param name="allowFullScreen" value="true">
</param>
<embed src="http://www.youtube.com/v/1?version=3" type="application/x-shockwave-flash" width="250" height="150" allowfullscreen="true">
</embed></object>', $msg); #
$msg = preg_replace('#[google](.*?)[/google]#si', '
<a href="http://www.google.ru/search?q=$1">Link <span style="color:#6600ff">G</span><span style="color:green">o</span><span style="color:black">o</span><span style="color:#0000ff">g</span><span style="color:#008000">l</span><span style="color:#7700ff">e</span> <i> :$1</i></a> ', $msg);
$msg = preg_replace('#[googleimg](.*?)[/googleimg]#si', '<a href="http://www.google.com.ua/images?q=$1">Link imG <span style="color:#6600ff">G</span><span style="color:green">o</span><span style="color:black">o</span><span style="color:#0000ff">g</span><span style="color:#008000">l</span><span style="color:#7700ff">e</span> <i>$1</i></a> ', $msg);
$msg = preg_replace('#[vkman](.*?)[/vkman]#si', '<a href=http://vkontakte.ru/gsearch.php?section=people&q=$1">vkontakte <i>$1</i></a> ', $msg);
$msg = preg_replace('#[vkmusic](.*?)[/vkmusic]#si', '<a href="http://vkontakte.ru/gsearch.php?section=audio&q=$1"><span style="color:#6600ff">Music</span> vkontake <i>$1</i></a> ', $msg);
$msg = preg_replace('#[vkvideo](.*?)[/vkvideo]#si', '<a href="http://vkontakte.ru/gsearch.php?section=video&q=$1">Video <span style="color:#6600ff">vkontakte </span><i>1</i></a> ', $msg);
$msg = preg_replace('#[wiki](.*?)[/wiki]#si', '[url=http://ru.wikipedia.org/wiki/1]Wiki <i>1</i>[/url] ', $msg);
$msg = preg_replace('#[ya](.*?)[/ya]#si', '<a href="http://yandex.ru/yandsearch?text=$1"> <span style="color:#ff0000">Y</span>andex <span style="color:#6600ff">Link </span> <i>$1</i></a> ', $msg);
$msg = preg_replace('#[yaimg](.*?)[/yaimg]#si', '<a href="http://images.yandex.ru/yandsearch?text=$1"> <span style="color:#ff0000">Y</span>andex <span style="color:#6600ff">Link </span> <i>$1</i></a> ', $msg);
$msg = preg_replace('#[yaavto](.*?)[/yaavto]#si', '<a href="http://auto.yandex.ru/models.xml?text=$1"> Avto <span style="color:#ff0000">Y</span>andex <span style="color:#6600ff">Link </span> <i>$1</i></a> ', $msg);
$msg = preg_replace('#[yavideo](.*?)[/yavideo]#si', '<a href="http://video.yandex.ru/#search?text=$1">Video <span style="color:#ff0000">Y</span>andex <span style="color:#6600ff">Link </span> <i>$1</i></a> ', $msg);
$msg = preg_replace('#[yamusic](.*?)[/yamusic]#si', '<a href="http://music.yandex.ru/#!/search?text=$1">Music <span style="color:#ff0000">Y</span>andex <span style="color:#6600ff">Link </span> <i>$1</i></a> ', $msg);
$msg = preg_replace('#[yaPeople](.*?)[/yaPeople]#si', '<a href="http://yandex.ru/yandsearch?text=$1">People <span style="color:#ff0000">Y</span>andex <span style="color:#6600ff">Link </span> <i>$1</i></a> ', $msg);
$msg = preg_replace('#[yablogs](.*?)[/yablogs]#si', '<a href="http://blogs.yandex.ru/search.xml?text=$1">blogs <span style="color:#ff0000">Y</span>andex <span style="color:#6600ff">Link </span> <i>$1</i></a> ', $msg);
$msg = preg_replace('#[translateru](.*?)[/translateru]#si', '<a href="http://translate.google.ru/#ru/en/$1">translate ru-en <span style="color:#ff0000">G</span>oogle translate <span style="color:#6600ff">The text of the translation Link </span> <i>$1</i></a> ', $msg);
$msg = preg_replace('#[translateen](.*?)[/translateen]#si', '<a href="http://translate.google.ru/#en/ru/$1">translate en-ru <span style="color:#ff0000">G</span>oogle translate <span style="color:#6600ff">The text of the translation Link </span> <i>$1</i></a> ', $msg);
$msg = preg_replace('#[translateruuk](.*?)[/translateruuk]#si', '<a href="http://translate.google.ru/#ru/uk/$1">translate ru-uk <span style="color:#ff0000">G</span>oogle translate <span style="color:#6600ff">The text of the translation Link </span> <i>$1</i></a> ', $msg);
$msg = preg_replace('#[translateukru](.*?)[/translateukru]#si', '<a href="http://translate.google.ru/#ru/uk/$1">translate uk-ru <span style="color:#ff0000">G</span>oogle translate <span style="color:#6600ff">The text of the translation Link </span> <i>$1</i></a> ', $msg);
$msg = preg_replace('#[bing](.*?)[/bing]#si', '<a href="http://www.bing.com/search?q=$1">bing Link </span> <i>$1</i></a> ', $msg);
$msg = preg_replace('#[mail](.*?)[/mail]#si', '<a href="http://go.mail.ru/search?q=$1">Mail.Ru <i>$1</i></a> ', $msg);
return $msg;
}
}