From 9b1c8531e36b9b88d676985a43e59bdf7e819516 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Wed, 26 Dec 2007 15:33:06 +0000 Subject: re-allow disabling of word censors (we somehow forgot to commit this, i really do not know why :/) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8286 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_content.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'phpBB/includes/functions_content.php') diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index b072895226..c0acd2eb41 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -647,12 +647,21 @@ function make_clickable($text, $server_url = false, $class = 'postlink') function censor_text($text) { static $censors; - global $cache; + // We moved the word censor checks in here because we call this function quite often - and then only need to do the check once if (!isset($censors) || !is_array($censors)) { - // obtain_word_list is taking care of the users censor option and the board-wide option - $censors = $cache->obtain_word_list(); + global $config, $user, $auth, $cache; + + // We check here if the user is having viewing censors disabled (and also allowed to do so). + if (!$user->optionget('viewcensors') && $config['allow_nocensors'] && $auth->acl_get('u_chgcensors')) + { + $censors = array(); + } + else + { + $censors = $cache->obtain_word_list(); + } } if (sizeof($censors)) -- cgit v1.2.1 From 325ff1fa1b0f75b7da6a6abbc9d6bbf032bcdedf Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Wed, 30 Jan 2008 16:01:15 +0000 Subject: One commit for those fixes having a very tiny impact (mostly only whitespaces or forgotten spans, etc.) Although i somehow mistakingly got #20445 and #15249 into it. :/ Removing s_watching_img from watch_topic_forum() function (Bug #20445) Changing order for post review if more than one post affected (Bug #15249) Language typos/fixes (Bug #20425, #15719, #15429, #14669, #13479) Style/Template fixes (Bug #20065, #19405, #19205, #15028, #14934, #14821, #14752, #14497, #13707, #14738) Tiny code fixes (Bug #20165, #20025, #19795, #14804) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8350 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_content.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'phpBB/includes/functions_content.php') diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index c0acd2eb41..a5a8683df3 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -67,7 +67,7 @@ function gen_sort_selects(&$limit_days, &$sort_by_text, &$sort_days, &$sort_key, $sort_dir = key($sort_dir_text); } - $s_limit_days = ''; foreach ($limit_days as $day => $text) { $selected = ($sort_days == $day) ? ' selected="selected"' : ''; @@ -75,7 +75,7 @@ function gen_sort_selects(&$limit_days, &$sort_by_text, &$sort_days, &$sort_key, } $s_limit_days .= ''; - $s_sort_key = ''; foreach ($sort_by_text as $key => $text) { $selected = ($sort_key == $key) ? ' selected="selected"' : ''; @@ -83,7 +83,7 @@ function gen_sort_selects(&$limit_days, &$sort_by_text, &$sort_days, &$sort_key, } $s_sort_key .= ''; - $s_sort_dir = ''; foreach ($sort_dir_text as $key => $value) { $selected = ($sort_dir == $key) ? ' selected="selected"' : ''; @@ -382,7 +382,7 @@ function strip_bbcode(&$text, $uid = '') $match = get_preg_expression('bbcode_htm'); $replace = array('\1', '\1', '\2', '\1', '', ''); - + $text = preg_replace($match, $replace, $text); } @@ -418,7 +418,7 @@ function generate_text_for_display($text, $uid, $bitfield, $flags) { $bbcode->bbcode($bitfield); } - + $bbcode->bbcode_second_pass($text, $uid); } @@ -801,7 +801,7 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count, $template->destroy_block_vars('_file'); $block_array = array(); - + // Some basics... $attachment['extension'] = strtolower(trim($attachment['extension'])); $filename = $phpbb_root_path . $config['upload_path'] . '/' . basename($attachment['physical_filename']); @@ -1083,7 +1083,7 @@ function truncate_string($string, $max_length = 60, $allow_reply = true, $append { $string = 'Re: ' . $string; } - + if ($append != '' && $stripped) { $string = $string . $append; @@ -1202,7 +1202,7 @@ class bitfield if (strlen($this->data) >= $byte + 1) { $c = $this->data[$byte]; - + // Lookup the ($n % 8)th bit of the byte $bit = 7 - ($n & 7); return (bool) (ord($c) & (1 << $bit)); -- cgit v1.2.1 From 6accc46024d436e69802793956653412cde8f404 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 23 Feb 2008 13:18:33 +0000 Subject: some language/style/code fixes (refer to the diff of the changelog) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8389 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_content.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions_content.php') diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index a5a8683df3..f851309a1e 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -823,7 +823,7 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count, $filesize = $attachment['filesize']; $size_lang = ($filesize >= 1048576) ? $user->lang['MB'] : ( ($filesize >= 1024) ? $user->lang['KB'] : $user->lang['BYTES'] ); - $filesize = ($filesize >= 1048576) ? round((round($filesize / 1048576 * 100) / 100), 2) : (($filesize >= 1024) ? round((round($filesize / 1024 * 100) / 100), 2) : $filesize); + $filesize = get_formatted_filesize($filesize, false); $comment = bbcode_nl2br(censor_text($attachment['attach_comment'])); -- cgit v1.2.1 From 3aa3ea89f98b5bc2def149e9ecaf43bd3d3d1dfa Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Thu, 28 Feb 2008 19:55:46 +0000 Subject: #22355 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8420 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_content.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions_content.php') diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index f851309a1e..0d367f953f 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -822,7 +822,7 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count, } $filesize = $attachment['filesize']; - $size_lang = ($filesize >= 1048576) ? $user->lang['MB'] : ( ($filesize >= 1024) ? $user->lang['KB'] : $user->lang['BYTES'] ); + $size_lang = ($filesize >= 1048576) ? $user->lang['MIB'] : (($filesize >= 1024) ? $user->lang['KIB'] : $user->lang['BYTES']); $filesize = get_formatted_filesize($filesize, false); $comment = bbcode_nl2br(censor_text($attachment['attach_comment'])); -- cgit v1.2.1 From 50e1d938879db3385eb446eade2a3b7950b85fe3 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Mon, 24 Mar 2008 00:16:13 +0000 Subject: - [Fix] Do not detect the board URL as a link twice in posts (Bug #19215) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8462 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_content.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'phpBB/includes/functions_content.php') diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index 0d367f953f..9eab477a8a 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -492,6 +492,7 @@ function generate_text_for_edit($text, $uid, $flags) */ function make_clickable_callback($type, $whitespace, $url, $relative_url, $class) { + $orig_url = $url . $relative_url; $append = ''; $url = htmlspecialchars_decode($url); $relative_url = htmlspecialchars_decode($relative_url); @@ -558,29 +559,39 @@ function make_clickable_callback($type, $whitespace, $url, $relative_url, $class break; } + $short_url = (strlen($url) > 55) ? substr($url, 0, 39) . ' ... ' . substr($url, -10) : $url; + switch ($type) { case MAGIC_URL_LOCAL: $tag = 'l'; $relative_url = preg_replace('/[&?]sid=[0-9a-f]{32}$/', '', preg_replace('/([&?])sid=[0-9a-f]{32}&/', '$1', $relative_url)); $url = $url . '/' . $relative_url; - $text = ($relative_url) ? $relative_url : $url; + $text = $relative_url; + + // this url goes to http://domain.tld/path/to/board/ which + // would result in an empty link if treated as local so + // don't touch it and let MAGIC_URL_FULL take care of it. + if (!$relative_url) + { + return $orig_url . '/'; // slash is taken away by relative url pattern + } break; case MAGIC_URL_FULL: $tag = 'm'; - $text = (strlen($url) > 55) ? substr($url, 0, 39) . ' ... ' . substr($url, -10) : $url; + $text = $short_url; break; case MAGIC_URL_WWW: $tag = 'w'; $url = 'http://' . $url; - $text = (strlen($url) > 55) ? substr($url, 0, 39) . ' ... ' . substr($url, -10) : $url; + $text = $short_url; break; case MAGIC_URL_EMAIL: $tag = 'e'; - $text = (strlen($url) > 55) ? substr($url, 0, 39) . ' ... ' . substr($url, -10) : $url; + $text = $short_url; $url = 'mailto:' . $url; break; } -- cgit v1.2.1 From af63e0ee845187db24a137317849c4619c137a3b Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 18 May 2008 18:57:37 +0000 Subject: fix for bug #27355 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8561 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_content.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions_content.php') diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index 9eab477a8a..79c32c4e08 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -574,7 +574,7 @@ function make_clickable_callback($type, $whitespace, $url, $relative_url, $class // don't touch it and let MAGIC_URL_FULL take care of it. if (!$relative_url) { - return $orig_url . '/'; // slash is taken away by relative url pattern + return $whitespace . $orig_url . '/'; // slash is taken away by relative url pattern } break; -- cgit v1.2.1 From 230eb5a01853fae0ca57bf05e5b74bd8c5d2b9b7 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 14 Jun 2008 11:15:40 +0000 Subject: correctly set flags if text is empty git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8657 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_content.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions_content.php') diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index 79c32c4e08..97ec78abcc 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -438,6 +438,7 @@ function generate_text_for_storage(&$text, &$uid, &$bitfield, &$flags, $allow_bb global $phpbb_root_path, $phpEx; $uid = $bitfield = ''; + $flags = (($allow_bbcode) ? OPTION_FLAG_BBCODE : 0) + (($allow_smilies) ? OPTION_FLAG_SMILIES : 0) + (($allow_urls) ? OPTION_FLAG_LINKS : 0); if (!$text) { @@ -461,7 +462,6 @@ function generate_text_for_storage(&$text, &$uid, &$bitfield, &$flags, $allow_bb $uid = ''; } - $flags = (($allow_bbcode) ? OPTION_FLAG_BBCODE : 0) + (($allow_smilies) ? OPTION_FLAG_SMILIES : 0) + (($allow_urls) ? OPTION_FLAG_LINKS : 0); $bitfield = $message_parser->bbcode_bitfield; return; @@ -568,7 +568,7 @@ function make_clickable_callback($type, $whitespace, $url, $relative_url, $class $relative_url = preg_replace('/[&?]sid=[0-9a-f]{32}$/', '', preg_replace('/([&?])sid=[0-9a-f]{32}&/', '$1', $relative_url)); $url = $url . '/' . $relative_url; $text = $relative_url; - + // this url goes to http://domain.tld/path/to/board/ which // would result in an empty link if treated as local so // don't touch it and let MAGIC_URL_FULL take care of it. -- cgit v1.2.1 From 11f27bee84447bf769e10fc7d099bb34209e9c2d Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 21 Jun 2008 16:05:02 +0000 Subject: further checks on maximum storage length git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8667 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_content.php | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/functions_content.php') diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index 97ec78abcc..ced5106c14 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -1066,8 +1066,16 @@ function extension_allowed($forum_id, $extension, &$extensions) /** * Truncates string while retaining special characters if going over the max length * The default max length is 60 at the moment +* The maximum storage length is there to fit the string within the given length. The string may be further truncated due to html entities. +* For example: string given is 'a "quote"' (length: 9), would be a stored as 'a "quote"' (length: 19) +* +* @param string $string The text to truncate to the given length. String is specialchared. +* @param int $max_length Maximum length of string (multibyte character count as 1 char / Html entity count as 1 char) +* @param int $max_store_length Maximum character length of string (multibyte character count as 1 char / Html entity count as entity chars). +* @param bool $allow_reply Allow Re: in front of string +* @param string $append String to be appended */ -function truncate_string($string, $max_length = 60, $allow_reply = true, $append = '') +function truncate_string($string, $max_length = 60, $max_store_length = 255, $allow_reply = true, $append = '') { $chars = array(); @@ -1090,6 +1098,21 @@ function truncate_string($string, $max_length = 60, $allow_reply = true, $append $stripped = true; } + // Due to specialchars, we may not be able to store the string... + if (utf8_strlen($string) > $max_store_length) + { + // let's split again, we do not want half-baked strings where entities are split + $_chars = utf8_str_split(htmlspecialchars_decode($string)); + $chars = array_map('utf8_htmlspecialchars', $_chars); + + do + { + array_pop($chars); + $string = implode('', $chars); + } + while (utf8_strlen($string) > $max_store_length || !sizeof($chars)); + } + if ($strip_reply) { $string = 'Re: ' . $string; -- cgit v1.2.1 From 9ecbd0edb64368193f96111d7164bb824c8f16cd Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Wed, 13 Aug 2008 14:37:33 +0000 Subject: #31185 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8752 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_content.php | 87 ++++++++++++++++++------------------ 1 file changed, 43 insertions(+), 44 deletions(-) (limited to 'phpBB/includes/functions_content.php') diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index ced5106c14..33df0314a7 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -41,57 +41,56 @@ if (!defined('IN_PHPBB')) /** * Generate sort selection fields */ -function gen_sort_selects(&$limit_days, &$sort_by_text, &$sort_days, &$sort_key, &$sort_dir, &$s_limit_days, &$s_sort_key, &$s_sort_dir, &$u_sort_param) +function gen_sort_selects(&$limit_days, &$sort_by_text, &$sort_days, &$sort_key, &$sort_dir, &$s_limit_days, &$s_sort_key, &$s_sort_dir, &$u_sort_param, $def_st = false, $def_sk = false, $def_sd = false) { global $user; $sort_dir_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']); - // Check if the key is selectable. If not, we reset to the first key found. - // This ensures the values are always valid. - if (!isset($limit_days[$sort_days])) - { - @reset($limit_days); - $sort_days = key($limit_days); - } - - if (!isset($sort_by_text[$sort_key])) - { - @reset($sort_by_text); - $sort_key = key($sort_by_text); - } - - if (!isset($sort_dir_text[$sort_dir])) - { - @reset($sort_dir_text); - $sort_dir = key($sort_dir_text); - } - - $s_limit_days = ''; - - $s_sort_key = ''; - - $s_sort_dir = ''; + foreach ($sort_ary['options'] as $option => $text) + { + $selected = ($sort_ary['selected']== $option) ? ' selected="selected"' : ''; + $sort_ary['output'] .= ''; + } + $sort_ary['output'] .= ''; + $u_sort_param .= ($sort_ary['selected'] !== $sort_ary['default']) ? ((strlen($u_sort_param)) ? '&' : '') . "{$name}={$sort_ary['selected']}" : ''; } - $s_sort_dir .= ''; - - $u_sort_param = "st=$sort_days&sk=$sort_key&sd=$sort_dir"; return; } -- cgit v1.2.1 From 88e56ee90cdfe6b24533108a5fb29505e99a2f76 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 30 Sep 2008 15:13:20 +0000 Subject: Wrong parameter count for preg_replace in get_context() (IMO we need no limit there - nils, you may check this again to be sure) - #34135 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8960 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_content.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions_content.php') diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index 33df0314a7..a15efbcebb 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -238,7 +238,7 @@ function bump_topic_allowed($forum_id, $topic_bumped, $last_post_time, $topic_po function get_context($text, $words, $length = 400) { // first replace all whitespaces with single spaces - $text = preg_replace('/ +/', ' ', strtr($text, "\t\n\r\x0C ", ' '), $text); + $text = preg_replace('/ +/', ' ', strtr($text, "\t\n\r\x0C ", ' ')); $word_indizes = array(); if (sizeof($words)) -- cgit v1.2.1 From 9f0b6766f9040d420cd9795520ed8b446612d987 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Mon, 6 Oct 2008 05:44:32 +0000 Subject: Fix for r8752 (the code removed actually was quite important - this checkin merges this with the new code) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8970 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_content.php | 38 +++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 14 deletions(-) (limited to 'phpBB/includes/functions_content.php') diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index a15efbcebb..627e6a71cd 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -49,47 +49,57 @@ function gen_sort_selects(&$limit_days, &$sort_by_text, &$sort_days, &$sort_key, $sorts = array( 'st' => array( - 'selected' => $sort_days, + 'key' => 'sort_days', 'default' => $def_st, 'options' => $limit_days, - 'output' => &$s_limit_days,), + 'output' => &$s_limit_days, + ), + 'sk' => array( - 'selected' => $sort_key, + 'key' => 'sort_key', 'default' => $def_sk, 'options' => $sort_by_text, - 'output' => &$s_sort_key,), + 'output' => &$s_sort_key, + ), + 'sd' => array( - 'selected' => $sort_dir, + 'key' => 'sort_dir', 'default' => $def_sd, 'options' => $sort_dir_text, - 'output' => &$s_sort_dir,), + 'output' => &$s_sort_dir, + ), ); $u_sort_param = ''; + foreach ($sorts as $name => $sort_ary) { + $key = $sort_ary['key']; + $selected = $$sort_ary['key']; + // Check if the key is selectable. If not, we reset to the default or first key found. - // This ensures the values are always valid. - if (!isset($sort_ary['options'][$sort_ary['selected']])) + // This ensures the values are always valid. We also set $sort_dir/sort_key/etc. to the + // correct value, else the protection is void. ;) + if (!isset($sort_ary['options'][$selected])) { if ($sort_ary['default'] !== false) { - $sort_ary['selected'] = $sort_ary['default']; + $selected = $$key = $sort_ary['default']; } else { @reset($sort_ary['options']); - $sort_ary['selected'] = key($sort_ary['options']); + $selected = $$key = key($sort_ary['options']); } } - + $sort_ary['output'] = ''; - $u_sort_param .= ($sort_ary['selected'] !== $sort_ary['default']) ? ((strlen($u_sort_param)) ? '&' : '') . "{$name}={$sort_ary['selected']}" : ''; + + $u_sort_param .= ($selected !== $sort_ary['default']) ? ((strlen($u_sort_param)) ? '&' : '') . "{$name}={$selected}" : ''; } return; -- cgit v1.2.1 From dcea9f082a3392f09f2753f1cba761f36a6b74ec Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sat, 22 Nov 2008 21:18:35 +0000 Subject: - Properly treat punctuation marks after local urls [Bug #37055] git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9084 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_content.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/functions_content.php') diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index 627e6a71cd..caa1b470d6 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -565,6 +565,14 @@ function make_clickable_callback($type, $whitespace, $url, $relative_url, $class { $url = substr($url, 0, -1); } + // appends last_char to orig_url to retrieve real original url + $orig_url = substr($orig_url, 0, -1); + break; + + // set last_char to empty here, so the variable can be used later to + // check whether a character was removed + default: + $last_char = ''; break; } @@ -583,7 +591,7 @@ function make_clickable_callback($type, $whitespace, $url, $relative_url, $class // don't touch it and let MAGIC_URL_FULL take care of it. if (!$relative_url) { - return $whitespace . $orig_url . '/'; // slash is taken away by relative url pattern + return $whitespace . $orig_url . '/' . $last_char; // slash is taken away by relative url pattern } break; -- cgit v1.2.1 From 81a1803c439f99863a499685b0e519b03b5362a1 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sat, 22 Nov 2008 23:17:05 +0000 Subject: better fix for (Bug #37055) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9085 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_content.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'phpBB/includes/functions_content.php') diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index caa1b470d6..88b7e77caa 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -501,7 +501,8 @@ function generate_text_for_edit($text, $uid, $flags) */ function make_clickable_callback($type, $whitespace, $url, $relative_url, $class) { - $orig_url = $url . $relative_url; + $orig_url = $url; + $orig_relative = $relative_url; $append = ''; $url = htmlspecialchars_decode($url); $relative_url = htmlspecialchars_decode($relative_url); @@ -565,8 +566,6 @@ function make_clickable_callback($type, $whitespace, $url, $relative_url, $class { $url = substr($url, 0, -1); } - // appends last_char to orig_url to retrieve real original url - $orig_url = substr($orig_url, 0, -1); break; // set last_char to empty here, so the variable can be used later to @@ -591,7 +590,7 @@ function make_clickable_callback($type, $whitespace, $url, $relative_url, $class // don't touch it and let MAGIC_URL_FULL take care of it. if (!$relative_url) { - return $whitespace . $orig_url . '/' . $last_char; // slash is taken away by relative url pattern + return $whitespace . $orig_url . '/' . $orig_relative; // slash is taken away by relative url pattern } break; -- cgit v1.2.1 From f766dccc3b7edaf850b0aff2dec6335b413cd4a3 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 2 Dec 2008 16:19:09 +0000 Subject: Performance increase for get_username_string() (Bug #37545 - Patch by BartVB) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9148 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_content.php | 93 +++++++++++++++++------------------- 1 file changed, 45 insertions(+), 48 deletions(-) (limited to 'phpBB/includes/functions_content.php') diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index 88b7e77caa..2741d5ed17 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -1144,6 +1144,7 @@ function truncate_string($string, $max_length = 60, $max_store_length = 255, $al /** * Get username details for placing into templates. +* This function caches all modes on first call, except for no_profile - determined by $user_id/$guest_username combination. * * @param string $mode Can be profile (for getting an url to the profile), username (for obtaining the username), colour (for obtaining the user colour), full (for obtaining a html string representing a coloured link to the users profile) or no_profile (the same as full but forcing no profile link) * @param int $user_id The users id @@ -1153,12 +1154,30 @@ function truncate_string($string, $max_length = 60, $max_store_length = 255, $al * @param string $custom_profile_url optional parameter to specify a profile url. The user id get appended to this url as &u={user_id} * * @return string A string consisting of what is wanted based on $mode. +* @author BartVB, Acyd Burn */ function get_username_string($mode, $user_id, $username, $username_colour = '', $guest_username = false, $custom_profile_url = false) { + static $_profile_cache; + static $_base_profile_url; + + $cache_key = $user_id . (string) $guest_username; + + // If the get_username_string() function had been executed once with an (to us) unkown mode, all modes are pre-filled and we can just grab it. + if (isset($_profile_cache[$cache_key][$mode])) + { + // If the mode is 'no_profile', we simply construct the TPL code due to calls to this mode being very very rare + if ($mode == 'no_profile') + { + $tpl = (!$_profile_cache[$cache_key][$mode]['colour']) ? '{USERNAME}' : '{USERNAME}'; + return str_replace(array('{USERNAME_COLOUR}', '{USERNAME}'), array($_profile_cache[$cache_key][$mode]['colour'], $_profile_cache[$cache_key][$mode]['username']), $tpl); + } + + return $_profile_cache[$cache_key][$mode]; + } + global $phpbb_root_path, $phpEx, $user, $auth; - $profile_url = ''; $username_colour = ($username_colour) ? '#' . $username_colour : ''; if ($guest_username === false) @@ -1170,64 +1189,42 @@ function get_username_string($mode, $user_id, $username, $username_colour = '', $username = ($user_id && $user_id != ANONYMOUS) ? $username : ((!empty($guest_username)) ? $guest_username : $user->lang['GUEST']); } - // Only show the link if not anonymous - if ($mode != 'no_profile' && $user_id && $user_id != ANONYMOUS) + // Build cache for all modes + $_profile_cache[$cache_key]['colour'] = $username_colour; + $_profile_cache[$cache_key]['username'] = $username; + $_profile_cache[$cache_key]['no_profile'] = true; + + // Profile url - only show if not anonymous and permission to view profile if registered user + // For anonymous the link leads to a login page. + if ($user_id && $user_id != ANONYMOUS && ($user->data['user_id'] == ANONYMOUS || $auth->acl_get('u_viewprofile'))) { - // Do not show the link if the user is already logged in but do not have u_viewprofile permissions (relevant for bots mostly). - // For all others the link leads to a login page or the profile. - if ($user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile')) + if (empty($_base_profile_url)) { - $profile_url = ''; - } - else - { - $profile_url = ($custom_profile_url !== false) ? $custom_profile_url . '&u=' . (int) $user_id : append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u=' . (int) $user_id); + $_base_profile_url = append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u={USER_ID}'); } + + $profile_url = ($custom_profile_url !== false) ? $custom_profile_url . '&u=' . (int) $user_id : str_replace('={USER_ID}', '=' . (int) $user_id, $_base_profile_url); + $tpl = (!$username_colour) ? '{USERNAME}' : '{USERNAME}'; + $_profile_cache[$cache_key]['full'] = str_replace(array('{PROFILE_URL}', '{USERNAME_COLOUR}', '{USERNAME}'), array($profile_url, $username_colour, $username), $tpl); } else { + $tpl = (!$username_colour) ? '{USERNAME}' : '{USERNAME}'; + $_profile_cache[$cache_key]['full'] = str_replace(array('{USERNAME_COLOUR}', '{USERNAME}'), array($username_colour, $username), $tpl); $profile_url = ''; } - switch ($mode) - { - case 'profile': - return $profile_url; - break; - - case 'username': - return $username; - break; + // Use the profile url from above + $_profile_cache[$cache_key]['profile'] = $profile_url; - case 'colour': - return $username_colour; - break; - - case 'no_profile': - case 'full': - default: - - $tpl = ''; - if (!$profile_url && !$username_colour) - { - $tpl = '{USERNAME}'; - } - else if (!$profile_url && $username_colour) - { - $tpl = '{USERNAME}'; - } - else if ($profile_url && !$username_colour) - { - $tpl = '{USERNAME}'; - } - else if ($profile_url && $username_colour) - { - $tpl = '{USERNAME}'; - } - - return str_replace(array('{PROFILE_URL}', '{USERNAME_COLOUR}', '{USERNAME}'), array($profile_url, $username_colour, $username), $tpl); - break; + // If - by any chance - no_profile is called before any other mode, we need to do the calculation here + if ($mode == 'no_profile') + { + $tpl = (!$_profile_cache[$cache_key]['colour']) ? '{USERNAME}' : '{USERNAME}'; + return str_replace(array('{USERNAME_COLOUR}', '{USERNAME}'), array($_profile_cache[$cache_key]['colour'], $_profile_cache[$cache_key]['username']), $tpl); } + + return $_profile_cache[$cache_key][$mode]; } /** -- cgit v1.2.1 From 10da18e82974374dda9dc6f4e1a90f2ccb403153 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Wed, 3 Dec 2008 11:15:50 +0000 Subject: fix the no_profile one called after another mode with the same user_id and guest_username git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9160 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_content.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions_content.php') diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index 2741d5ed17..1228f8e567 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -1169,8 +1169,8 @@ function get_username_string($mode, $user_id, $username, $username_colour = '', // If the mode is 'no_profile', we simply construct the TPL code due to calls to this mode being very very rare if ($mode == 'no_profile') { - $tpl = (!$_profile_cache[$cache_key][$mode]['colour']) ? '{USERNAME}' : '{USERNAME}'; - return str_replace(array('{USERNAME_COLOUR}', '{USERNAME}'), array($_profile_cache[$cache_key][$mode]['colour'], $_profile_cache[$cache_key][$mode]['username']), $tpl); + $tpl = (!$_profile_cache[$cache_key]['colour']) ? '{USERNAME}' : '{USERNAME}'; + return str_replace(array('{USERNAME_COLOUR}', '{USERNAME}'), array($_profile_cache[$cache_key]['colour'], $_profile_cache[$cache_key]['username']), $tpl); } return $_profile_cache[$cache_key][$mode]; -- cgit v1.2.1 From 5a0d7717f67578636acf8300f0ddf5b9a862ead4 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Thu, 11 Dec 2008 14:46:38 +0000 Subject: Fix bug #38655 - Since guest_username is only used for anonymous we revert back to user_id being the cache key and not caching anonymous usernames at all - the code changes are as minimal as possible git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9184 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_content.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/includes/functions_content.php') diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index 1228f8e567..f5c0786fed 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -1144,7 +1144,7 @@ function truncate_string($string, $max_length = 60, $max_store_length = 255, $al /** * Get username details for placing into templates. -* This function caches all modes on first call, except for no_profile - determined by $user_id/$guest_username combination. +* This function caches all modes on first call, except for no_profile and anonymous user - determined by $user_id. * * @param string $mode Can be profile (for getting an url to the profile), username (for obtaining the username), colour (for obtaining the user colour), full (for obtaining a html string representing a coloured link to the users profile) or no_profile (the same as full but forcing no profile link) * @param int $user_id The users id @@ -1161,10 +1161,10 @@ function get_username_string($mode, $user_id, $username, $username_colour = '', static $_profile_cache; static $_base_profile_url; - $cache_key = $user_id . (string) $guest_username; + $cache_key = $user_id; // If the get_username_string() function had been executed once with an (to us) unkown mode, all modes are pre-filled and we can just grab it. - if (isset($_profile_cache[$cache_key][$mode])) + if ($user_id && $user_id != ANONYMOUS && isset($_profile_cache[$cache_key][$mode])) { // If the mode is 'no_profile', we simply construct the TPL code due to calls to this mode being very very rare if ($mode == 'no_profile') -- cgit v1.2.1 From 516734979ce6baa85929187e7ba4c07be362e2d1 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Wed, 24 Dec 2008 12:06:14 +0000 Subject: change get_username_string() again. This time we do not try to "guess" something. We also do not cache the modes. Instead we try to only run required code and pre-compile the URL and TPL. This should give the optimal performance given the circumstances. Additionally fix a small bug with profile urls if the RokBridge is used. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9217 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_content.php | 117 ++++++++++++++++++++--------------- 1 file changed, 66 insertions(+), 51 deletions(-) (limited to 'phpBB/includes/functions_content.php') diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index f5c0786fed..845f87c8da 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -1159,72 +1159,87 @@ function truncate_string($string, $max_length = 60, $max_store_length = 255, $al function get_username_string($mode, $user_id, $username, $username_colour = '', $guest_username = false, $custom_profile_url = false) { static $_profile_cache; - static $_base_profile_url; - $cache_key = $user_id; - - // If the get_username_string() function had been executed once with an (to us) unkown mode, all modes are pre-filled and we can just grab it. - if ($user_id && $user_id != ANONYMOUS && isset($_profile_cache[$cache_key][$mode])) + // We cache some common variables we need within this function + if (empty($_profile_cache)) { - // If the mode is 'no_profile', we simply construct the TPL code due to calls to this mode being very very rare - if ($mode == 'no_profile') - { - $tpl = (!$_profile_cache[$cache_key]['colour']) ? '{USERNAME}' : '{USERNAME}'; - return str_replace(array('{USERNAME_COLOUR}', '{USERNAME}'), array($_profile_cache[$cache_key]['colour'], $_profile_cache[$cache_key]['username']), $tpl); - } + global $phpbb_root_path, $phpEx; - return $_profile_cache[$cache_key][$mode]; + $_profile_cache['base_url'] = append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u={USER_ID}'); + $_profile_cache['tpl_noprofile'] = '{USERNAME}'; + $_profile_cache['tpl_noprofile_colour'] = '{USERNAME}'; + $_profile_cache['tpl_profile'] = '{USERNAME}'; + $_profile_cache['tpl_profile_colour'] = '{USERNAME}'; } - global $phpbb_root_path, $phpEx, $user, $auth; + global $user, $auth; - $username_colour = ($username_colour) ? '#' . $username_colour : ''; - - if ($guest_username === false) - { - $username = ($username) ? $username : $user->lang['GUEST']; - } - else + // This switch makes sure we only run code required for the mode + switch ($mode) { - $username = ($user_id && $user_id != ANONYMOUS) ? $username : ((!empty($guest_username)) ? $guest_username : $user->lang['GUEST']); - } + case 'full': + case 'noprofile': + case 'colour': - // Build cache for all modes - $_profile_cache[$cache_key]['colour'] = $username_colour; - $_profile_cache[$cache_key]['username'] = $username; - $_profile_cache[$cache_key]['no_profile'] = true; + // Build correct username colour + $username_colour = ($username_colour) ? '#' . $username_colour : ''; - // Profile url - only show if not anonymous and permission to view profile if registered user - // For anonymous the link leads to a login page. - if ($user_id && $user_id != ANONYMOUS && ($user->data['user_id'] == ANONYMOUS || $auth->acl_get('u_viewprofile'))) - { - if (empty($_base_profile_url)) - { - $_base_profile_url = append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u={USER_ID}'); - } + // Return colour + if ($mode == 'colour') + { + return $username_colour; + } - $profile_url = ($custom_profile_url !== false) ? $custom_profile_url . '&u=' . (int) $user_id : str_replace('={USER_ID}', '=' . (int) $user_id, $_base_profile_url); - $tpl = (!$username_colour) ? '{USERNAME}' : '{USERNAME}'; - $_profile_cache[$cache_key]['full'] = str_replace(array('{PROFILE_URL}', '{USERNAME_COLOUR}', '{USERNAME}'), array($profile_url, $username_colour, $username), $tpl); - } - else - { - $tpl = (!$username_colour) ? '{USERNAME}' : '{USERNAME}'; - $_profile_cache[$cache_key]['full'] = str_replace(array('{USERNAME_COLOUR}', '{USERNAME}'), array($username_colour, $username), $tpl); - $profile_url = ''; - } + // no break; + + case 'username': - // Use the profile url from above - $_profile_cache[$cache_key]['profile'] = $profile_url; + // Build correct username + if ($guest_username === false) + { + $username = ($username) ? $username : $user->lang['GUEST']; + } + else + { + $username = ($user_id && $user_id != ANONYMOUS) ? $username : ((!empty($guest_username)) ? $guest_username : $user->lang['GUEST']); + } + + // Return username + if ($mode == 'username') + { + return $username; + } + + // no break; + + case 'profile': + + // Build correct profile url - only show if not anonymous and permission to view profile if registered user + // For anonymous the link leads to a login page. + if ($user_id && $user_id != ANONYMOUS && ($user->data['user_id'] == ANONYMOUS || $auth->acl_get('u_viewprofile'))) + { + $profile_url = ($custom_profile_url !== false) ? $custom_profile_url . '&u=' . (int) $user_id : str_replace(array('={USER_ID}', '=%7BUSER_ID%7D'), '=' . (int) $user_id, $_profile_cache['base_url']); + } + else + { + $profile_url = ''; + } + + // Return profile + if ($mode == 'profile') + { + return $profile_url; + } + + // no break; + } - // If - by any chance - no_profile is called before any other mode, we need to do the calculation here - if ($mode == 'no_profile') + if (($mode == 'full' && !$profile_url) || $mode == 'no_profile') { - $tpl = (!$_profile_cache[$cache_key]['colour']) ? '{USERNAME}' : '{USERNAME}'; - return str_replace(array('{USERNAME_COLOUR}', '{USERNAME}'), array($_profile_cache[$cache_key]['colour'], $_profile_cache[$cache_key]['username']), $tpl); + return str_replace(array('{USERNAME_COLOUR}', '{USERNAME}'), array($username_colour, $username), (!$username_colour) ? $_profile_cache['tpl_noprofile'] : $_profile_cache['tpl_noprofile_colour']); } - return $_profile_cache[$cache_key][$mode]; + return str_replace(array('{PROFILE_URL}', '{USERNAME_COLOUR}', '{USERNAME}'), array($profile_url, $username_colour, $username), (!$username_colour) ? $_profile_cache['tpl_profile'] : $_profile_cache['tpl_profile_colour']); } /** -- cgit v1.2.1 From 67775c5332bece3638ba3d10764bea2e4f0d3255 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 3 Jan 2009 12:20:05 +0000 Subject: fix tiny typo... the mode is no_profile instead of noprofile. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9247 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_content.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions_content.php') diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index 845f87c8da..268755ab44 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -1178,7 +1178,7 @@ function get_username_string($mode, $user_id, $username, $username_colour = '', switch ($mode) { case 'full': - case 'noprofile': + case 'no_profile': case 'colour': // Build correct username colour -- cgit v1.2.1 From 3b918a234e3917080982581d200e5baab2a5bd79 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Mon, 16 Mar 2009 15:59:53 +0000 Subject: Fix download count increments for image attachments without corresponding thumbnails. (Bug #42505) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9373 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_content.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'phpBB/includes/functions_content.php') diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index 268755ab44..21c595053f 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -950,6 +950,8 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count, 'S_THUMBNAIL' => true, 'THUMB_IMAGE' => $thumbnail_link, ); + + $update_count[] = $attachment['attach_id']; break; // Windows Media Streams -- cgit v1.2.1 From d4ac2d4209505075fefaa76a5be227d6a413c2ec Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 17 Mar 2009 14:42:13 +0000 Subject: Flash files do not display anymore after update to flash player 10 (Bug #41315) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9384 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_content.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/includes/functions_content.php') diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index 21c595053f..1859941c76 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -998,6 +998,7 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count, 'S_FLASH_FILE' => true, 'WIDTH' => $width, 'HEIGHT' => $height, + 'U_VIEW_LINK' => $download_link . '&view=1', ); // Viewed/Heared File ... update the download count -- cgit v1.2.1 From 66a33c75a5e5185f1640ec686beaf8349543fde8 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 4 Apr 2009 10:55:58 +0000 Subject: Fix infinite loop in truncate_string (Bug #43475) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9423 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_content.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions_content.php') diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index 1859941c76..c365b4d684 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -1129,7 +1129,7 @@ function truncate_string($string, $max_length = 60, $max_store_length = 255, $al array_pop($chars); $string = implode('', $chars); } - while (utf8_strlen($string) > $max_store_length || !sizeof($chars)); + while (!empty($char) && utf8_strlen($string) > $max_store_length); } if ($strip_reply) -- cgit v1.2.1 From e2f445ae14471027ecd6045288b7ce81d571c16d Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 4 Apr 2009 11:05:47 +0000 Subject: Fix infinite loop in truncate_string (Bug #43475) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9424 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_content.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions_content.php') diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index c365b4d684..23cbff7e8f 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -1129,7 +1129,7 @@ function truncate_string($string, $max_length = 60, $max_store_length = 255, $al array_pop($chars); $string = implode('', $chars); } - while (!empty($char) && utf8_strlen($string) > $max_store_length); + while (!empty($chars) && utf8_strlen($string) > $max_store_length); } if ($strip_reply) -- cgit v1.2.1 From 29cd21102d1f64483839762da8c213f4a401b3b0 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Wed, 13 May 2009 10:42:44 +0000 Subject: late fix for #44845 (phpBB debug notice for some search terms) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9515 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_content.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'phpBB/includes/functions_content.php') diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index 23cbff7e8f..3107177137 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -261,6 +261,11 @@ function get_context($text, $words, $length = 400) { if (preg_match('#(?:[^\w]|^)(' . $word . ')(?:[^\w]|$)#i', $text, $match)) { + if (empty($match[1])) + { + continue; + } + $pos = utf8_strpos($text, $match[1]); if ($pos !== false) { -- cgit v1.2.1 From 54ee31972af4f84e09ad5b12ca512e5712bbd87a Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sat, 11 Jul 2009 10:05:20 +0000 Subject: Fix bug #47775 - Properly convert and show filesize information Authorised by: naderman git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9748 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_content.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'phpBB/includes/functions_content.php') diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index 3107177137..630f4105d0 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -853,16 +853,14 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count, } } - $filesize = $attachment['filesize']; - $size_lang = ($filesize >= 1048576) ? $user->lang['MIB'] : (($filesize >= 1024) ? $user->lang['KIB'] : $user->lang['BYTES']); - $filesize = get_formatted_filesize($filesize, false); + $filesize = get_formatted_filesize($attachment['filesize'], false); $comment = bbcode_nl2br(censor_text($attachment['attach_comment'])); $block_array += array( 'UPLOAD_ICON' => $upload_icon, - 'FILESIZE' => $filesize, - 'SIZE_LANG' => $size_lang, + 'FILESIZE' => $filesize['value'], + 'SIZE_LANG' => $filesize['unit'], 'DOWNLOAD_NAME' => basename($attachment['real_filename']), 'COMMENT' => $comment, ); -- cgit v1.2.1 From 433f03107de1162744a1d0b8c9fa3c4ba1b3ed21 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 24 Jul 2009 08:56:06 +0000 Subject: Fix bug #31505 - Do not cut post-message in between HTML-Entities on search.php - Patch by leviatan21 Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9842 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_content.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions_content.php') diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index 630f4105d0..de5df37299 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -250,6 +250,11 @@ function get_context($text, $words, $length = 400) // first replace all whitespaces with single spaces $text = preg_replace('/ +/', ' ', strtr($text, "\t\n\r\x0C ", ' ')); + // we need to turn the entities back into their original form, to not cut the message in between them + $entities = array('<', '>', '[', ']', '.', ':', ':'); + $characters = array('<', '>', '[', ']', '.', ':', ':'); + $text = str_replace($entities, $characters, $text); + $word_indizes = array(); if (sizeof($words)) { @@ -345,13 +350,13 @@ function get_context($text, $words, $length = 400) } } } - return $final_text; + return str_replace($characters, $entities, $final_text); } } if (!sizeof($words) || !sizeof($word_indizes)) { - return (utf8_strlen($text) >= $length + 3) ? utf8_substr($text, 0, $length) . '...' : $text; + return str_replace($characters, $entities, ((utf8_strlen($text) >= $length + 3) ? utf8_substr($text, 0, $length) . '...' : $text)); } } -- cgit v1.2.1 From 2958890439f29b9cf45997c52c8cfa57e0f16bc8 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 1 Aug 2009 12:28:50 +0000 Subject: Apply locale-independent basename() to attachment filenames. New function added: utf8_basename(). (Bug #43335 - Patch by ocean=Yohsuke) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9905 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_content.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/includes/functions_content.php') diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index de5df37299..c4ac48e8e8 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -841,8 +841,8 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count, // Some basics... $attachment['extension'] = strtolower(trim($attachment['extension'])); - $filename = $phpbb_root_path . $config['upload_path'] . '/' . basename($attachment['physical_filename']); - $thumbnail_filename = $phpbb_root_path . $config['upload_path'] . '/thumb_' . basename($attachment['physical_filename']); + $filename = $phpbb_root_path . $config['upload_path'] . '/' . utf8_basename($attachment['physical_filename']); + $thumbnail_filename = $phpbb_root_path . $config['upload_path'] . '/thumb_' . utf8_basename($attachment['physical_filename']); $upload_icon = ''; @@ -866,7 +866,7 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count, 'UPLOAD_ICON' => $upload_icon, 'FILESIZE' => $filesize['value'], 'SIZE_LANG' => $filesize['unit'], - 'DOWNLOAD_NAME' => basename($attachment['real_filename']), + 'DOWNLOAD_NAME' => utf8_basename($attachment['real_filename']), 'COMMENT' => $comment, ); -- cgit v1.2.1 From f7009291e20969421f90ab81eed1347a4d977501 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Mon, 17 Aug 2009 14:45:14 +0000 Subject: Ability to define constant PHPBB_USE_BOARD_URL_PATH to use board url for images/avatars/ranks/imageset... This feature does not change anything for those not using the constant and this feature is also quite in-flux. We need to test this with some applications and bridges and there may be other locations able to benefit from it. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10008 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_content.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/functions_content.php') diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index c4ac48e8e8..7a30f0069e 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -733,7 +733,8 @@ function smiley_text($text, $force_option = false) } else { - return preg_replace('#', $text); + $root_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $phpbb_root_path; + return preg_replace('#', $text); } } -- cgit v1.2.1 From 5d2e4e88ab3266b44101714a101d337e0053361e Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Fri, 21 Aug 2009 09:44:55 +0000 Subject: Allow "0" as censor word and replacement. Only obtain word censor list if text is not empty. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10039 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_content.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'phpBB/includes/functions_content.php') diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index 7a30f0069e..c265d0ae41 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -685,6 +685,12 @@ function censor_text($text) { static $censors; + // Nothing to do? + if ($text === '') + { + return ''; + } + // We moved the word censor checks in here because we call this function quite often - and then only need to do the check once if (!isset($censors) || !is_array($censors)) { -- cgit v1.2.1 From 4eda4855efa2392226f9267b25094402886a64d2 Mon Sep 17 00:00:00 2001 From: Josh Woody Date: Mon, 25 Jan 2010 18:02:37 +0000 Subject: Deprecate $allow_reply parameter to truncate_string() (Bug #56675) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10442 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_content.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions_content.php') diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index c265d0ae41..faff9dd0de 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -1106,10 +1106,11 @@ function extension_allowed($forum_id, $extension, &$extensions) * @param string $string The text to truncate to the given length. String is specialchared. * @param int $max_length Maximum length of string (multibyte character count as 1 char / Html entity count as 1 char) * @param int $max_store_length Maximum character length of string (multibyte character count as 1 char / Html entity count as entity chars). -* @param bool $allow_reply Allow Re: in front of string +* @param bool $allow_reply Allow Re: in front of string +* NOTE: This parameter can cause undesired behavior (returning strings longer than $max_store_legnth) and is deprecated. * @param string $append String to be appended */ -function truncate_string($string, $max_length = 60, $max_store_length = 255, $allow_reply = true, $append = '') +function truncate_string($string, $max_length = 60, $max_store_length = 255, $allow_reply = false, $append = '') { $chars = array(); -- cgit v1.2.1