From b76222cb6e9ed69ee8ed0c09f0196eaaafd33fad Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Wed, 13 Sep 2006 16:08:36 +0000 Subject: - fixed some bugs - changed attachment handling a bit - tried to remove target tags out of the code - do not add session ids to urls for bots as well as not creating a new session on each page view for them I bet i introduced some bugs too. ;) git-svn-id: file:///svn/phpbb/trunk@6364 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions.php | 73 +++++++++++++++++++------------------------- 1 file changed, 31 insertions(+), 42 deletions(-) (limited to 'phpBB/includes/functions.php') diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 88cdab17d2..620b64a54a 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2146,21 +2146,10 @@ function decode_message(&$message, $bbcode_uid = '') $message = str_replace($match, $replace, $message); - $match = array( - '#.*?#', - '#.*?#', - '#.*?#', - '#.*?#', - '#.*?#', - '#.*?#', - '#.*?#', - '#.*?#', - '#', censor_text($text)); // Parse bbcode if bbcode uid stored and bbcode enabled - if ($uid && ($flags & 1)) + if ($uid && ($flags & OPTION_FLAG_BBCODE)) { if (!class_exists('bbcode')) { @@ -2226,7 +2206,7 @@ function generate_text_for_display($text, $uid, $bitfield, $flags) $bbcode->bbcode_second_pass($text, $uid); } - $text = smiley_text($text, !($flags & 2)); + $text = smiley_text($text, !($flags & OPTION_FLAG_SMILIES)); return $text; } @@ -2282,9 +2262,9 @@ function generate_text_for_edit($text, $uid, $flags) decode_message($text, $uid); return array( - 'allow_bbcode' => ($flags & 1) ? 1 : 0, - 'allow_smilies' => ($flags & 2) ? 1 : 0, - 'allow_urls' => ($flags & 4) ? 1 : 0, + 'allow_bbcode' => ($flags & OPTION_FLAG_BBCODE) ? 1 : 0, + 'allow_smilies' => ($flags & OPTION_FLAG_SMILIES) ? 1 : 0, + 'allow_urls' => ($flags & OPTION_FLAG_LINKS) ? 1 : 0, 'text' => $text ); } @@ -2317,11 +2297,11 @@ function make_clickable($text, $server_url = false) // matches a xxxx://aaaaa.bbb.cccc. ... $magic_url_match[] = '#(^|[\n ]|\()([\w]+:/{2}.*?([^[ \t\n\r<"\'\)&]+|&(?!lt;|quot;))*)#ie'; - $magic_url_replace[] = "'\$1' . ((strlen('\$2') > 55) ? substr(str_replace('&', '&', '\$2'), 0, 39) . ' ... ' . substr(str_replace('&', '&', '\$2'), -10) : '\$2') . ''"; + $magic_url_replace[] = "'\$1' . ((strlen('\$2') > 55) ? substr(str_replace('&', '&', '\$2'), 0, 39) . ' ... ' . substr(str_replace('&', '&', '\$2'), -10) : '\$2') . ''"; // matches a "www.xxxx.yyyy[/zzzz]" kinda lazy URL thing $magic_url_match[] = '#(^|[\n ]|\()(w{3}\.[\w\-]+\.[\w\-.\~]+(?:[^[ \t\n\r<"\'\)&]+|&(?!lt;|quot;))*)#ie'; - $magic_url_replace[] = "'\$1' . ((strlen('\$2') > 55) ? substr(str_replace('&', '&', '\$2'), 0, 39) . ' ... ' . substr(str_replace('&', '&', '\$2'), -10) : '\$2') . ''"; + $magic_url_replace[] = "'\$1' . ((strlen('\$2') > 55) ? substr(str_replace('&', '&', '\$2'), 0, 39) . ' ... ' . substr(str_replace('&', '&', '\$2'), -10) : '\$2') . ''"; // matches an email@domain type address at the start of a line, or after a space or after what might be a BBCode. $magic_url_match[] = '/(^|[\n ]|\()(' . get_preg_expression('email') . ')/ie'; @@ -2336,19 +2316,18 @@ function make_clickable($text, $server_url = false) */ function censor_text($text) { - global $censors, $user, $cache; + static $censors; + global $cache; - if (!isset($censors)) + if (!isset($censors) || !is_array($censors)) { $censors = array(); - if ($user->optionget('viewcensors')) - { - $cache->obtain_word_list($censors); - } + // obtain_word_list is taking care of the users censor option and the board-wide option + $cache->obtain_word_list($censors); } - if (sizeof($censors) && $user->optionget('viewcensors')) + if (sizeof($censors)) { return preg_replace($censors['match'], $censors['replace'], $text); } @@ -2645,8 +2624,8 @@ function get_backtrace() /** * This function returns a regular expression pattern for commonly used expressions -* Use with / as delimiter -* mode can be: email| +* Use with / as delimiter for email mode +* mode can be: email|bbcode_htm */ function get_preg_expression($mode) { @@ -2655,6 +2634,16 @@ function get_preg_expression($mode) case 'email': return '[a-z0-9&\'\.\-_\+]+@[a-z0-9\-]+\.([a-z0-9\-]+\.)*[a-z]+'; break; + + case 'bbcode_htm': + return array( + '#.*?#', + '#.*?#', + '#