10 && $n < 20) return $form5; if ($n1 > 1 && $n1 < 5) return $form2; if ($n1 == 1) return $form1;return $form5; } static function age($birthday) { $birthday_timestamp = strtotime($birthday); $age = date('Y') - date('Y', $birthday_timestamp); if (date('md', $birthday_timestamp) > date('md')) $age--; return $age; } static function filter ($text, $break = false, $bbcode = false, $smiles = false) { # Защита от HTML $text = htmlspecialchars(trim($text)); # Обработка переносов if($break == true) { $text = preg_replace("/[ ]{2,}/", " ", $text); $text = preg_replace("/[\s]{3,}/", "\n\n", $text); $text = nl2br($text); } # Обработка BBcode if($bbcode == true) { // цветной текст $text = preg_replace('#\[color=([a-zA-Z]*|\#?[0-9a-fA-F]{6})](.+)\[/color\]#Usi', '$2', $text); // жирный шрифт $text = preg_replace('#\[b\](.+)\[/b\]#Usi', '$1', $text); // подчеркивание $text = preg_replace('#\[u\](.+)\[/u\]#Usi', '$1', $text); // курсив $text = preg_replace('#\[i\](.+)\[/i\]#Usi', '$1', $text); // зачеркивание $text = preg_replace('#\[s\](.+)\[/s\]#Usi', '$1', $text); // ссылки внутренние $text = preg_replace('#\[url=' . Config::SITE_NAME_ADDR . '(.*)\](.+)\[/url\]#Usi', '$2', $text); // ссылки внешние $text = preg_replace('#\[url=http://(.+)\](.+)\[/url\]#Usi', '$2', $text); } # Обработка смайлов if($smiles == true) { $text .= ' '; // чтобы работали смайлы в конце $text = Smiles::handler($text); $text = trim($text); } return $text; } } ?>