mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 22:28:51 +00:00
fixed censoring (quote post, word boundaries, attachment comments)
git-svn-id: file:///svn/phpbb/trunk@4492 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
08161e09e2
commit
a363e8dcdb
3 changed files with 18 additions and 11 deletions
|
@ -739,7 +739,7 @@ function obtain_word_list(&$censors)
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
$censors['match'][] = '#(' . str_replace('\*', '\w*?', preg_quote($row['word'], '#')) . ')#i';
|
$censors['match'][] = '#\b(' . str_replace('\*', '\w*?', preg_quote($row['word'], '#')) . ')\b#i';
|
||||||
$censors['replace'][] = $row['replacement'];
|
$censors['replace'][] = $row['replacement'];
|
||||||
}
|
}
|
||||||
while ($row = $db->sql_fetchrow($result));
|
while ($row = $db->sql_fetchrow($result));
|
||||||
|
|
|
@ -290,10 +290,17 @@ function display_forums($root_data = '', $display_moderators = TRUE)
|
||||||
function display_attachments($attachment_data, &$update_count, $force_physical = false)
|
function display_attachments($attachment_data, &$update_count, $force_physical = false)
|
||||||
{
|
{
|
||||||
global $extensions, $template;
|
global $extensions, $template;
|
||||||
global $config, $user, $phpbb_root_path, $phpEx, $SID;
|
global $config, $user, $phpbb_root_path, $phpEx, $SID, $censors;
|
||||||
|
|
||||||
|
if (empty($censors))
|
||||||
|
{
|
||||||
|
$censors = array();
|
||||||
|
obtain_word_list($censors);
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($extensions) || !is_array($extensions))
|
if (empty($extensions) || !is_array($extensions))
|
||||||
{
|
{
|
||||||
|
$extensions = array();
|
||||||
obtain_attach_extensions($extensions);
|
obtain_attach_extensions($extensions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -323,7 +330,7 @@ function display_attachments($attachment_data, &$update_count, $force_physical =
|
||||||
$filesize = ($filesize >= 1048576) ? round((round($filesize / 1048576 * 100) / 100), 2) : (($filesize >= 1024) ? round((round($filesize / 1024 * 100) / 100), 2) : $filesize);
|
$filesize = ($filesize >= 1048576) ? round((round($filesize / 1048576 * 100) / 100), 2) : (($filesize >= 1024) ? round((round($filesize / 1024 * 100) / 100), 2) : $filesize);
|
||||||
|
|
||||||
$display_name = $attachment['real_filename'];
|
$display_name = $attachment['real_filename'];
|
||||||
$comment = str_replace("\n", '<br />', $attachment['comment']);
|
$comment = (sizeof($censors)) ? preg_replace($censors['match'], $censors['replace'], str_replace("\n", '<br />', $attachment['comment'])) : str_replace("\n", '<br />', $attachment['comment']);
|
||||||
|
|
||||||
$denied = FALSE;
|
$denied = FALSE;
|
||||||
|
|
||||||
|
|
|
@ -119,6 +119,12 @@ switch ($mode)
|
||||||
trigger_error($user->lang['NO_MODE']);
|
trigger_error($user->lang['NO_MODE']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (empty($censors))
|
||||||
|
{
|
||||||
|
$censors = array();
|
||||||
|
obtain_word_list($censors);
|
||||||
|
}
|
||||||
|
|
||||||
if ($sql != '')
|
if ($sql != '')
|
||||||
{
|
{
|
||||||
$result = $db->sql_query($sql);
|
$result = $db->sql_query($sql);
|
||||||
|
@ -749,12 +755,6 @@ if ($submit || $preview || $refresh)
|
||||||
// Preview
|
// Preview
|
||||||
if (!sizeof($error) && $preview)
|
if (!sizeof($error) && $preview)
|
||||||
{
|
{
|
||||||
if (empty($censors))
|
|
||||||
{
|
|
||||||
$censors = array();
|
|
||||||
obtain_word_list($censors);
|
|
||||||
}
|
|
||||||
|
|
||||||
$post_time = ($mode == 'edit') ? $post_time : $current_time;
|
$post_time = ($mode == 'edit') ? $post_time : $current_time;
|
||||||
|
|
||||||
$preview_subject = (sizeof($censors)) ? preg_replace($censors['match'], $censors['replace'], $subject) : $subject;
|
$preview_subject = (sizeof($censors)) ? preg_replace($censors['match'], $censors['replace'], $subject) : $subject;
|
||||||
|
@ -824,13 +824,13 @@ if (count($poll_options))
|
||||||
|
|
||||||
if ($mode == 'quote' && !$preview && !$refresh)
|
if ($mode == 'quote' && !$preview && !$refresh)
|
||||||
{
|
{
|
||||||
$post_text = '[quote="' . $quote_username . '"]' . trim($post_text) . "[/quote]\n";
|
$post_text = '[quote="' . $quote_username . '"]' . ((sizeof($censors)) ? preg_replace($censors['match'], $censors['replace'], trim($post_text)) : trim($post_text)) . "[/quote]\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (($mode == 'reply' || $mode == 'quote') && !$preview && !$refresh)
|
if (($mode == 'reply' || $mode == 'quote') && !$preview && !$refresh)
|
||||||
{
|
{
|
||||||
$post_subject = ((!preg_match('/^Re:/', $post_subject)) ? 'Re: ' : '') . $post_subject;
|
$post_subject = ((!preg_match('/^Re:/', $post_subject)) ? 'Re: ' : '') . ((sizeof($censors)) ? preg_replace($censors['match'], $censors['replace'], $post_subject) : $post_subject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue