|
Познающий
Регистрация: 22.10.2005
Сообщений: 37
Провел на форуме: 520745
Репутация:
141
|
|
$content = preg_replace("/\[FONT=(.+?)\](.+?)\[\/FONT\]/", "<font face=\"\\1\">\\2</font>", $content);
ЧТО??? ИМХО даже в phpbb 1.0 не было такой защиты... Чуть поправил (правил на ходу, поэтому могут быть всякие parse-ошибки...)
PHP код:
<?php
function bth($content) {
// Переносы строк
$content = nl2br($content);
// Горизонтальная линия
$content = str_replace("[HR]", "<hr />", $content);
// Жирный, Курсив (Наклонный), Подчеркнутый, Перечеркнутый
$content = preg_replace("/\[B\](.+?)\[\/B\]/", "<b>\\1</b>", $content);
$content = preg_replace("/\[I\](.+?)\[\/I\]/", "<i>\\1</i>", $content);
$content = preg_replace("/\[U\](.+?)\[\/U\]/", "<u>\\1</u>", $content);
$content = preg_replace("/\[S\](.+?)\[\/S\]/", "<s>\\1</s>", $content);
// Нижний и верхний регистр
$content = preg_replace("/\[SUB\](.+?)\[\/SUB\]/", "<sub>\\1</sub>", $content);
$content = preg_replace("/\[SUP\](.+?)\[\/SUP\]/", "<sup>\\1</sup>", $content);
// Мелкий шрифт
$content = preg_replace("/\[SMALL\](.+?)\[\/SMALL\]/", "<small>\\1</small>", $content);
// Нестандартный шрифт
$content = preg_replace("/\[FONT=([^\"]+?)\](.+?)\[\/FONT\]/", "<font face=\"\\1\">\\2</font>", $content);
// Название шрифта
$content = preg_replace("/\[SIZE=(\d+?)\](.+?)\[\/SIZE\]/", "<font size=\"\\1\">\\2</font>", $content);
// Цвет шрифта
$content = preg_replace("/\[COLOR=([^\"]+?)\](.+?)\[\/COLOR\]/", "<font color=\"\\1\">\\2</font>", $content);
// Выравнивание (По левому краю, По центру, По правому краю)
$content = preg_replace("/\[LEFT\](.+?)\[\/LEFT\]/", "<div align=\"left\">\\1</div>", $content);
$content = preg_replace("/\[CENTER\](.+?)\[\/CENTER\]/", "<div align=\"center\">\\1</div>", $content);
$content = preg_replace("/\[RIGHT\](.+?)\[\/RIGHT\]/", "<div align=\"right\">\\1</div>", $content);
// Ссылки
$content = preg_replace("/\[URL\]([a-z]+?)(:\/\/)([^\"]+?)\[\/URL\]/", "<a href=\"\\1\\2\\3\" target=\"_blank\">\\1</a>", $content);
$content = preg_replace("/\[URL=([a-z]+?)(:\/\/)[^\"]+?)\](.+?)\[\/URL\]/", "<a href=\"\\1\\2\\3\" target=\"_blank\">\\2</a>", $content);
$content = preg_replace("/\[URL\]([^\"]+?)\[\/URL\]/", "<a href=\"http:\/\/\\1\" target=\"_blank\">\\1</a>", $content);
$content = preg_replace("/\[URL=([^\"]+?)\](.+?)\[\/URL\]/", "<a href=\"http:\/\/\\1\" target=\"_blank\">\\2</a>", $content);
// E-Mail
$content = preg_replace("/\[EMAIL\]([^\"]+?)\[\/EMAIL\]/", "<a href=\"mailto:\\1\">\\1</a>", $content);
$content = preg_replace("/\[EMAIL=([^\"]+?)\](.+?)\[\/EMAIL\]/", "<a href=\"mailto:\\1\">\\2</a>", $content);
// Изображение
$content = preg_replace("/\[IMG\](http:\/\/)([^\"]+?)\[\/IMG\]/", "<img src=\"\\1\\2\" border=\"0\" alt=\"\">", $content);
$content = preg_replace("/\[IMG=(http:\/\/)([^\"]+?)\](.+?)\[\/IMG\]/", "<img src=\"\\1\\2\" border=\"0\" alt=\"\\2\">", $content);
$content = preg_replace("/\[IMG\]([^\"]+?)\[\/IMG\]/", "<img src=\"http:\/\/\\1\" border=\"0\" alt=\"\">", $content);
$content = preg_replace("/\[IMG=([^\"]+?)\](.+?)\[\/IMG\]/", "<img src=\"http:\/\/\\1\" border=\"0\" alt=\"\\2\">", $content);
// Список
$content = preg_replace("/\[LIST\]([^\"]+?)\[\/LIST\]/", "<ul type=\"square\">\\1</ul>", $content);
$content = preg_replace("/\[LIST=([^\"]+?)\](.+?)\[\/LIST\]/", "<ul type=\"\\1\">\\2</ul>", $content);
$content = preg_replace("/\[\*\](.+?)\[\/\*\]/", "<li>\\1</li>", $content);
// Цитата
$content = preg_replace("/\[Q\](.+?)\[\/Q\]/", "<b>Цитата:</b><br /><div class=\"quote\">\\1</div>", $content);
// Смайлики
$content = preg_replace("/:(.+?):/", "<img src=\"/images/smiles/\\1.gif\" border=\"0\">", $content);
return $content;
}
Последний раз редактировалось pch; 02.05.2006 в 23:26..
|