151
Discussion & Troubleshooting / Re: What is wrong with my emails in gallery?
« on: September 20, 2011, 12:32:19 PM »
I guess the simplest solution would be replace the whole format_text function with default one:
function format_text($text, $html = 0, $word_wrap = 0, $bbcode = 0, $bbcode_img = 0) {
if ($word_wrap && $text != "") {
$text = preg_replace("/([^\n\r ?&\.\/<>\"\\-]{".$word_wrap."})/i", " \\1\n", $text);
}
if ($html == 0 || $html == 2) {
$text = safe_htmlspecialchars($text);
}
// Replace { to prevent parsing in templates
global $site_template;
$text = preg_replace(
'='.preg_quote($site_template->start).'([A-Z0-9_]+)'.preg_quote($site_template->end).'=Usi',
'&#123;\1&#125;',
$text
);
if ($html !== 2) {
$text = nl2br(trim($text));
$text = replace_url($text);
}
if ($bbcode == 1) {
$search_array = array(
"/(\[)(list)(=)(['\"]?)([^\"']*)(\\4])(.*)(\[\/list)(((=)(\\4)([^\"']*)(\\4]))|(\]))/siU",
"/(\[)(list)(])(.*)(\[\/list\])/siU",
"/(\[\*\])/siU",
"/(\[\/\*\])/siU",
"/(\[)(url)(=)(['\"]?)(www\.)([^\"']*)(\\4])(.*)(\[\/url\])/siU",
"/(\[)(url)(=)(['\"]?)([^\"']*)(\\4])(.*)(\[\/url\])/siU",
"/(\[)(url)(])(www\.)([^\"]*)(\[\/url\])/siU",
"/(\[)(url)(])([^\"]*)(\[\/url\])/siU",
"/(\[)(code)(])(\r\n)*(.*)(\[\/code\])/siU",
"/javascript:/si",
"/about:/si"
);
$replace_array = array(
"<ol type=\"\\5\">\\7</ol>",
"<ul>\\4</ul>",
"<li>",
"</li>",
"<a href=\"http://www.\\6\" target=\"_blank\" rel=\"nofollow\">\\8</a>",
"<a href=\"\\5\" target=\"_blank\" rel=\"nofollow\">\\7</a>",
"<a href=\"http://www.\\5\" target=\"_blank\" rel=\"nofollow\">www.\\5</a>",
"<a href=\"\\4\" target=\"_blank\" rel=\"nofollow\">\\4</a>",
"<pre>Code:<hr size=1>\\5<hr size=1></pre>",
"java script:",
"about :"
);
$text = preg_replace($search_array, $replace_array, $text);
if (!$bbcode_img) {
$text = preg_replace("/(\[)(img)(])(\r\n)*([^\"]*)(\[\/img\])/siU", "<a href=\"\\5\" target=\"_blank\">\\5</a>", $text);
}
else {
$text = preg_replace("/(\[)(img)(])(\r\n)*([^\"]*)(\[\/img\])/siU", "<img src=\"\\5\">", $text);
}
$text = preg_replace("/(\[)(b)(])(\r\n)*([^\"]*)(\[\/b\])/siU", "<b>\\5</b>", $text);
$text = preg_replace("/(\[)(i)(])(\r\n)*([^\"]*)(\[\/i\])/siU", "<i>\\5</i>", $text);
$text = preg_replace("/(\[)(u)(])(\r\n)*([^\"]*)(\[\/u\])/siU", "<u>\\5</u>", $text);
$text = replace_badwords($text);
}
$text = str_replace("\\'", "'", $text);
return $text;
}
(don't miss the last bracket )
function format_text($text, $html = 0, $word_wrap = 0, $bbcode = 0, $bbcode_img = 0) {
if ($word_wrap && $text != "") {
$text = preg_replace("/([^\n\r ?&\.\/<>\"\\-]{".$word_wrap."})/i", " \\1\n", $text);
}
if ($html == 0 || $html == 2) {
$text = safe_htmlspecialchars($text);
}
// Replace { to prevent parsing in templates
global $site_template;
$text = preg_replace(
'='.preg_quote($site_template->start).'([A-Z0-9_]+)'.preg_quote($site_template->end).'=Usi',
'&#123;\1&#125;',
$text
);
if ($html !== 2) {
$text = nl2br(trim($text));
$text = replace_url($text);
}
if ($bbcode == 1) {
$search_array = array(
"/(\[)(list)(=)(['\"]?)([^\"']*)(\\4])(.*)(\[\/list)(((=)(\\4)([^\"']*)(\\4]))|(\]))/siU",
"/(\[)(list)(])(.*)(\[\/list\])/siU",
"/(\[\*\])/siU",
"/(\[\/\*\])/siU",
"/(\[)(url)(=)(['\"]?)(www\.)([^\"']*)(\\4])(.*)(\[\/url\])/siU",
"/(\[)(url)(=)(['\"]?)([^\"']*)(\\4])(.*)(\[\/url\])/siU",
"/(\[)(url)(])(www\.)([^\"]*)(\[\/url\])/siU",
"/(\[)(url)(])([^\"]*)(\[\/url\])/siU",
"/(\[)(code)(])(\r\n)*(.*)(\[\/code\])/siU",
"/javascript:/si",
"/about:/si"
);
$replace_array = array(
"<ol type=\"\\5\">\\7</ol>",
"<ul>\\4</ul>",
"<li>",
"</li>",
"<a href=\"http://www.\\6\" target=\"_blank\" rel=\"nofollow\">\\8</a>",
"<a href=\"\\5\" target=\"_blank\" rel=\"nofollow\">\\7</a>",
"<a href=\"http://www.\\5\" target=\"_blank\" rel=\"nofollow\">www.\\5</a>",
"<a href=\"\\4\" target=\"_blank\" rel=\"nofollow\">\\4</a>",
"<pre>Code:<hr size=1>\\5<hr size=1></pre>",
"java script:",
"about :"
);
$text = preg_replace($search_array, $replace_array, $text);
if (!$bbcode_img) {
$text = preg_replace("/(\[)(img)(])(\r\n)*([^\"]*)(\[\/img\])/siU", "<a href=\"\\5\" target=\"_blank\">\\5</a>", $text);
}
else {
$text = preg_replace("/(\[)(img)(])(\r\n)*([^\"]*)(\[\/img\])/siU", "<img src=\"\\5\">", $text);
}
$text = preg_replace("/(\[)(b)(])(\r\n)*([^\"]*)(\[\/b\])/siU", "<b>\\5</b>", $text);
$text = preg_replace("/(\[)(i)(])(\r\n)*([^\"]*)(\[\/i\])/siU", "<i>\\5</i>", $text);
$text = preg_replace("/(\[)(u)(])(\r\n)*([^\"]*)(\[\/u\])/siU", "<u>\\5</u>", $text);
$text = replace_badwords($text);
}
$text = str_replace("\\'", "'", $text);
return $text;
}
(don't miss the last bracket )