- put consoring and smilie processing into functions (we use them all over the place) for better changing and consistency.

- changed docs/AUTHORS to reflect the recent code re-use in functions_messenger.php
- pleasing the users a little bit more by using table constants. :D
- login box if "mode" is not allowed -> posting (thought about trigger_error integration, but we do not need this that often).


git-svn-id: file:///svn/phpbb/trunk@4836 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen 2004-02-21 12:47:35 +00:00
parent 9c12fe83db
commit c74d2538ec
26 changed files with 211 additions and 254 deletions

View file

@ -125,7 +125,7 @@ $cp = new custom_profile_admin();
// Based on this, we decide which elements need to be edited later and which language items are missing // Based on this, we decide which elements need to be edited later and which language items are missing
$lang_ids = $lang_entry = $lang_diff = array(); $lang_ids = $lang_entry = $lang_diff = array();
$result = $db->sql_query('SELECT lang_id FROM phpbb_lang'); $result = $db->sql_query('SELECT lang_id FROM ' . LANG_TABLE);
while ($row = $db->sql_fetchrow($result)) while ($row = $db->sql_fetchrow($result))
{ {
@ -592,7 +592,7 @@ if ($mode == 'delete')
$db->sql_query('DELETE FROM phpbb_profile_fields WHERE field_id = ' . $field_id); $db->sql_query('DELETE FROM phpbb_profile_fields WHERE field_id = ' . $field_id);
$db->sql_query('DELETE FROM phpbb_profile_fields_lang WHERE field_id = ' . $field_id); $db->sql_query('DELETE FROM phpbb_profile_fields_lang WHERE field_id = ' . $field_id);
$db->sql_query('DELETE FROM phpbb_profile_lang WHERE field_id = ' . $field_id); $db->sql_query('DELETE FROM phpbb_profile_lang WHERE field_id = ' . $field_id);
$db->sql_query('ALTER TABLE phpbb_profile_fields_data DROP ' . $field_ident); $db->sql_query('ALTER TABLE ' . CUSTOM_PROFILE_DATA . ' DROP ' . $field_ident);
$order = 0; $order = 0;
@ -633,7 +633,10 @@ if ($mode == 'activate')
trigger_error('INVALID_MODE'); trigger_error('INVALID_MODE');
} }
$result = $db->sql_query("SELECT lang_id FROM phpbb_lang WHERE lang_iso = '" . $config['default_lang'] . "'"); $sql = 'SELECT lang_id
FROM ' . LANG_TABLE . "
WHERE lang_iso = '{$config['default_lang']}'";
$result = $db->sql_query($sql);
$default_lang_id = (int) $db->sql_fetchfield('lang_id', 0, $result); $default_lang_id = (int) $db->sql_fetchfield('lang_id', 0, $result);
$db->sql_freeresult($result); $db->sql_freeresult($result);
@ -754,7 +757,9 @@ function build_language_options($field_type, $mode = 'new')
{ {
global $user, $config, $db, $cp; global $user, $config, $db, $cp;
$sql = 'SELECT lang_id, lang_iso FROM phpbb_lang' . (($mode == 'new') ? " WHERE lang_iso <> '" . $config['default_lang'] . "'" : ''); $sql = 'SELECT lang_id, lang_iso
FROM ' . LANG_TABLE .
(($mode == 'new') ? " WHERE lang_iso <> '" . $config['default_lang'] . "'" : '');
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
$languages = array(); $languages = array();
@ -858,7 +863,10 @@ function save_profile_field($field_type, $field_ident)
// Collect all informations, if something is going wrong, abort the operation // Collect all informations, if something is going wrong, abort the operation
$profile_sql = $profile_lang = $empty_lang = $profile_lang_fields = array(); $profile_sql = $profile_lang = $empty_lang = $profile_lang_fields = array();
$result = $db->sql_query("SELECT lang_id FROM phpbb_lang WHERE lang_iso = '" . $config['default_lang'] . "'"); $sql = 'SELECT lang_id
FROM ' . LANG_TABLE . '
WHERE lang_iso = '" . $config['default_lang'] . "'";
$result = $db->sql_query($sql);
$default_lang_id = (int) $db->sql_fetchfield('lang_id', 0, $result); $default_lang_id = (int) $db->sql_fetchfield('lang_id', 0, $result);
$db->sql_freeresult($result); $db->sql_freeresult($result);
@ -888,7 +896,7 @@ function save_profile_field($field_type, $field_ident)
$field_id = $db->sql_nextid(); $field_id = $db->sql_nextid();
$sql = "ALTER TABLE phpbb_profile_fields_data ADD $field_ident "; $sql = 'ALTER TABLE ' . CUSTOM_PROFILE_DATA . " ADD $field_ident ";
switch ($field_type) switch ($field_type)
{ {
case FIELD_STRING: case FIELD_STRING:

View file

@ -614,7 +614,7 @@ if ($submit || $preview || $deleteall || $deletemark)
// Update Custom Fields // Update Custom Fields
if (sizeof($cp_data)) if (sizeof($cp_data))
{ {
$sql = 'UPDATE phpbb_profile_fields_data $sql = 'UPDATE ' . CUSTOM_PROFILE_DATA . '
SET ' . $db->sql_build_array('UPDATE', $cp_data) . " SET ' . $db->sql_build_array('UPDATE', $cp_data) . "
WHERE user_id = $user_id"; WHERE user_id = $user_id";
$db->sql_query($sql); $db->sql_query($sql);
@ -1557,15 +1557,15 @@ function marklist(match, status)
// If we allow users to disable display of emoticons // If we allow users to disable display of emoticons
// we'll need an appropriate check and preg_replace here // we'll need an appropriate check and preg_replace here
$signature_preview = (empty($enable_smilies) || empty($config['allow_smilies'])) ? preg_replace('#<!\-\- s(.*?) \-\-><img src="\{SMILE_PATH\}\/.*? \/><!\-\- s\1 \-\->#', '\1', $signature_preview) : str_replace('<img src="{SMILE_PATH}', '<img src="' . $phpbb_root_path . $config['smilies_path'], $signature_preview); $signature_preview = smilie_text($signature_preview, !$enable_smilies);
// Replace naughty words such as farty pants // Replace naughty words such as farty pants
if (sizeof($censors)) /* if (sizeof($censors))
{ {
$signature_preview = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace(\$censors['match'], \$censors['replace'], '\\0')", '>' . $signature_preview . '<'), 1, -1)); $signature_preview = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace(\$censors['match'], \$censors['replace'], '\\0')", '>' . $signature_preview . '<'), 1, -1));
} }*/
$signature_preview = str_replace("\n", '<br />', $signature_preview); $signature_preview = str_replace("\n", '<br />', censor_text($signature_preview));
} }
decode_text($user_sig, $user_sig_bbcode_uid); decode_text($user_sig, $user_sig_bbcode_uid);

View file

@ -1,23 +1,15 @@
<?php <?php
/*************************************************************************** // -------------------------------------------------------------
* admin_words.php //
* ------------------- // $Id$
* begin : Thursday, Jul 12, 2001 //
* copyright : (C) 2001 The phpBB Group // FILENAME : admin_words.php
* email : support@phpbb.com // STARTED : Thu Jul 12, 2001
* // COPYRIGHT : © 2001, 2003 phpBB Group
* $Id$ // WWW : http://www.phpbb.com/
* // LICENCE : GPL vs2.0 [ see /docs/COPYING ]
***************************************************************************/ //
// -------------------------------------------------------------
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
if (!empty($setmodules)) if (!empty($setmodules))
{ {
@ -32,7 +24,7 @@ if (!empty($setmodules))
define('IN_PHPBB', 1); define('IN_PHPBB', 1);
// Include files // Include files
$phpbb_root_path = '../'; $phpbb_root_path = './../';
$phpEx = substr(strrchr(__FILE__, '.'), 1); $phpEx = substr(strrchr(__FILE__, '.'), 1);
require('pagestart.' . $phpEx); require('pagestart.' . $phpEx);
@ -42,57 +34,35 @@ if (!$auth->acl_get('a_words'))
trigger_error($user->lang['NO_ADMIN']); trigger_error($user->lang['NO_ADMIN']);
} }
// What do we want to do? $mode = request_var('mode', '');
if (isset($_REQUEST['mode'])) $mode = (isset($_POST['add'])) ? 'add' : ((isset($_POST['save'])) ? 'save' : $mode);
$s_hidden_fields = '';
$word_info = array();
switch ($mode)
{ {
$mode = $_REQUEST['mode']; case 'edit':
} $word_id = request_var('id', 0);
else
{ if (!$word_id)
// These could be entered via a form button {
if (isset($_POST['add'])) trigger_error($user->lang['NO_WORD']);
{ }
$mode = 'add';
}
else if (isset($_POST['save']))
{
$mode = 'save';
}
else
{
$mode = '';
}
}
if ($mode != '') $sql = 'SELECT *
{ FROM ' . WORDS_TABLE . "
switch ($mode) WHERE word_id = $word_id";
{ $result = $db->sql_query_limit($sql, 1);
case 'edit':
case 'add':
$word_id = (isset($_GET['id'])) ? intval($_GET['id']) : 0;
$s_hidden_fields = ''; $word_info = $db->sql_fetchrow($result);
if ($mode == 'edit') $db->sql_freeresult($result);
{
if (!$word_id)
{
trigger_error($user->lang['NO_WORD']);
}
$sql = "SELECT * $s_hidden_fields .= '<input type="hidden" name="id" value="' . $word_id . '" />';
FROM " . WORDS_TABLE . "
WHERE word_id = $word_id";
$result = $db->sql_query($sql);
$word_info = $db->sql_fetchrow($result); case 'add':
$db->sql_freeresult($result);
$s_hidden_fields .= '<input type="hidden" name="id" value="' . $word_id . '" />';
}
adm_page_header($user->lang['WORDS_TITLE']);
adm_page_header($user->lang['WORDS_TITLE']);
?> ?>
<h1><?php echo $user->lang['WORDS_TITLE']; ?></h1> <h1><?php echo $user->lang['WORDS_TITLE']; ?></h1>
@ -104,11 +74,11 @@ if ($mode != '')
<th colspan="2"><?php echo $user->lang['EDIT_WORD']; ?></th> <th colspan="2"><?php echo $user->lang['EDIT_WORD']; ?></th>
</tr> </tr>
<tr> <tr>
<td class="row1"><?php echo $user->lang['WORD']; ?></td> <td class="row1"><b><?php echo $user->lang['WORD']; ?></b>:</td>
<td class="row2"><input class="post" type="text" name="word" value="<?php echo $word_info['word']; ?>" /></td> <td class="row2"><input class="post" type="text" name="word" value="<?php echo $word_info['word']; ?>" /></td>
</tr> </tr>
<tr> <tr>
<td class="row1"><?php echo $user->lang['REPLACEMENT']; ?></td> <td class="row1"><b><?php echo $user->lang['REPLACEMENT']; ?></b>:</td>
<td class="row2"><input class="post" type="text" name="replacement" value="<?php echo $word_info['replacement']; ?>" /></td> <td class="row2"><input class="post" type="text" name="replacement" value="<?php echo $word_info['replacement']; ?>" /></td>
</tr> </tr>
<tr> <tr>
@ -122,11 +92,11 @@ if ($mode != '')
break; break;
case 'save': case 'save':
$word_id = (isset($_POST['id'])) ? intval($_POST['id']) : 0; $word_id = request_var('id', 0);
$word = (isset($_POST['word'])) ? trim($_POST['word']) : ''; $word = request_var('word', '');
$replacement = (isset($_POST['replacement'])) ? trim($_POST['replacement']) : ''; $replacement = request_var('replacement', '');
if ($word == '' || $replacement == '') if (!$word || !$replacement)
{ {
trigger_error($user->lang['ENTER_WORD']); trigger_error($user->lang['ENTER_WORD']);
} }
@ -140,20 +110,19 @@ if ($mode != '')
add_log('admin', $log_action, stripslashes($word)); add_log('admin', $log_action, stripslashes($word));
$message = ($word_id) ? $user->lang['WORD_UPDATED'] : $user->lang['WORD_ADDED']; $message = ($word_id) ? $user->lang['WORD_UPDATED'] : $user->lang['WORD_ADDED'];
trigger_error($message);
break; break;
case 'delete': case 'delete':
if (isset($_POST['id']) || isset($_GET['id'])) $word_id = request_var('id', 0);
{
$word_id = (isset($_POST['id'])) ? intval($_POST['id']) : intval($_GET['id']); if (!$word_id)
}
else
{ {
trigger_error($user->lang['NO_WORD']); trigger_error($user->lang['NO_WORD']);
} }
$sql = "DELETE FROM " . WORDS_TABLE . " $sql = 'DELETE FROM ' . WORDS_TABLE . "
WHERE word_id = $word_id"; WHERE word_id = $word_id";
$db->sql_query($sql); $db->sql_query($sql);
@ -162,18 +131,13 @@ if ($mode != '')
add_log('admin', 'log_delete_word'); add_log('admin', 'log_delete_word');
$message = $user->lang['WORD_REMOVE']; $message = $user->lang['WORD_REMOVE'];
trigger_error($message);
break; break;
} default:
trigger_error($message);
}
else
{
adm_page_header($user->lang['WORDS_TITLE']);
adm_page_header($user->lang['WORDS_TITLE']);
?> ?>
<h1><?php echo $user->lang['WORDS_TITLE']; ?></h1> <h1><?php echo $user->lang['WORDS_TITLE']; ?></h1>
@ -189,16 +153,16 @@ else
<?php <?php
$sql = "SELECT * $sql = 'SELECT *
FROM " . WORDS_TABLE . " FROM ' . WORDS_TABLE . '
ORDER BY word"; ORDER BY word';
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
if ($row = $db->sql_fetchrow($result)) if ($row = $db->sql_fetchrow($result))
{
do
{ {
$row_class = ($row_class == 'row1') ? 'row2' : 'row1'; do
{
$row_class = ($row_class == 'row1') ? 'row2' : 'row1';
?> ?>
<tr> <tr>
@ -209,10 +173,10 @@ else
</tr> </tr>
<?php <?php
}
while ($row = $db->sql_fetchrow($result));
} }
while ($row = $db->sql_fetchrow($result)); $db->sql_freeresult($result);
}
$db->sql_freeresult($result);
?> ?>
<tr> <tr>
@ -222,8 +186,8 @@ else
<?php <?php
adm_page_footer(); adm_page_footer();
break;
} }
?> ?>

View file

@ -28,3 +28,6 @@ Smarty
GPL licenced: GPL licenced:
phpMyAdmin © 2001,2003 phpMyAdmin Devel team, http://www.phpmyadmin.net/ phpMyAdmin © 2001,2003 phpMyAdmin Devel team, http://www.phpmyadmin.net/
Jabber class © 2003 Carlo Zottmann, http://phpjabber.g-blog.net Jabber class © 2003 Carlo Zottmann, http://phpjabber.g-blog.net
PHP License, version 3.0:
Pear © 2001-2004 PHP Group, http://pear.php.net

View file

@ -1049,7 +1049,7 @@ function login_forum_box(&$forum_data)
if ($password == $forum_data['forum_password']) if ($password == $forum_data['forum_password'])
{ {
$sql = 'INSERT INTO phpbb_forum_access (forum_id, user_id, session_id) $sql = 'INSERT INTO ' . FORUMS_ACCESS_TABLE . ' (forum_id, user_id, session_id)
VALUES (' . $forum_data['forum_id'] . ', ' . $user->data['user_id'] . ", '" . $db->sql_escape($user->session_id) . "')"; VALUES (' . $forum_data['forum_id'] . ', ' . $user->data['user_id'] . ", '" . $db->sql_escape($user->session_id) . "')";
$db->sql_query($sql); $db->sql_query($sql);
@ -1066,7 +1066,7 @@ function login_forum_box(&$forum_data)
page_footer(); page_footer();
} }
// Bump Topic Check - used by posting and viewtopic (do not want another included file) // Bump Topic Check - used by posting and viewtopic
function bump_topic_allowed($forum_id, $topic_bumped, $last_post_time, $topic_poster, $last_topic_poster) function bump_topic_allowed($forum_id, $topic_bumped, $last_post_time, $topic_poster, $last_topic_poster)
{ {
global $config, $auth, $user; global $config, $auth, $user;
@ -1097,6 +1097,38 @@ function bump_topic_allowed($forum_id, $topic_bumped, $last_post_time, $topic_po
return $bump_time; return $bump_time;
} }
// Censoring
function censor_text($text)
{
global $censors, $user;
if (!isset($censors))
{
$censors = array();
// For ANONYMOUS, this option should be enabled by default
if ($user->optionget('viewcensors'))
{
obtain_word_list($censors);
}
}
if (sizeof($censors) && $user->optionget('viewcensors'))
{
return preg_replace($censors['match'], $censors['replace'], $text);
}
return $text;
}
// Smilie processing
function smilie_text($text, $force_option = false)
{
global $config, $user, $phpbb_root_path;
return ($force_option || !$config['allow_smilies'] || !$user->optionget('viewsmilies')) ? preg_replace('#<!\-\- s(.*?) \-\-><img src="\{SMILE_PATH\}\/.*? \/><!\-\- s\1 \-\->#', '\1', $text) : str_replace('<img src="{SMILE_PATH}', '<img src="' . $phpbb_root_path . $config['smilies_path'], $text);
}
// Error and message handler, call with trigger_error if reqd // Error and message handler, call with trigger_error if reqd
function msg_handler($errno, $msg_text, $errfile, $errline) function msg_handler($errno, $msg_text, $errfile, $errline)
{ {

View file

@ -1745,12 +1745,6 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id
$profile_url = (defined('IN_ADMIN')) ? "admin_users.$phpEx$SID" : "memberlist.$phpEx$SID&amp;mode=viewprofile"; $profile_url = (defined('IN_ADMIN')) ? "admin_users.$phpEx$SID" : "memberlist.$phpEx$SID&amp;mode=viewprofile";
$censors = array();
if ($user->optionget('viewcensors'))
{
obtain_word_list($censors);
}
switch ($mode) switch ($mode)
{ {
case 'admin': case 'admin':
@ -1824,11 +1818,7 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id
{ {
foreach ($log_data_ary as $log_data) foreach ($log_data_ary as $log_data)
{ {
if (sizeof($censors) && $user->optionget('viewcensors')) $log_data = str_replace("\n", '<br />', censor_text($log_data));
{
$log_data = preg_replace($censors['match'], $censors['replace'], $log_data);
}
$log_data = str_replace("\n", '<br />', $log_data);
$log[$i]['action'] = preg_replace('#%s#', $log_data, $log[$i]['action'], 1); $log[$i]['action'] = preg_replace('#%s#', $log_data, $log[$i]['action'], 1);
} }

View file

@ -334,7 +334,7 @@ function display_forums($root_data = '', $display_moderators = TRUE)
function display_attachments($blockname, $attachment_data, &$update_count, $force_physical = false, $return = false) function display_attachments($blockname, $attachment_data, &$update_count, $force_physical = false, $return = false)
{ {
global $extensions, $template, $cache, $attachment_tpl; global $extensions, $template, $cache, $attachment_tpl;
global $config, $user, $phpbb_root_path, $phpEx, $SID, $censors; global $config, $user, $phpbb_root_path, $phpEx, $SID;
// $starttime = explode(' ', microtime()); // $starttime = explode(' ', microtime());
// $starttime = $starttime[1] + $starttime[0]; // $starttime = $starttime[1] + $starttime[0];
@ -377,12 +377,6 @@ function display_attachments($blockname, $attachment_data, &$update_count, $forc
} }
} }
if (empty($censors))
{
$censors = array();
obtain_word_list($censors);
}
if (empty($extensions) || !is_array($extensions)) if (empty($extensions) || !is_array($extensions))
{ {
$extensions = array(); $extensions = array();
@ -413,7 +407,7 @@ function display_attachments($blockname, $attachment_data, &$update_count, $forc
$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 = (sizeof($censors)) ? preg_replace($censors['match'], $censors['replace'], str_replace("\n", '<br />', $attachment['comment'])) : str_replace("\n", '<br />', $attachment['comment']); $comment = str_replace("\n", '<br />', censor_text($attachment['comment']));
$denied = FALSE; $denied = FALSE;

View file

@ -810,6 +810,8 @@ function smtpmail($addresses, $subject, $message, &$err_msg, $headers = '', $log
return true; return true;
} }
// SMTP Class
// Auth Mechanisms originally taken from the AUTH Modules found within the PHP Extension and Application Repository (PEAR)
class smtp_class class smtp_class
{ {
var $server_response = ''; var $server_response = '';
@ -1099,7 +1101,7 @@ class smtp_class
$md5_challenge = base64_decode($this->responses[0]); $md5_challenge = base64_decode($this->responses[0]);
// Parse the md5 challenge - from PEAR // Parse the md5 challenge - from AUTH_SASL (PEAR)
$tokens = array(); $tokens = array();
while (preg_match('/^([a-z-]+)=("[^"]+(?<!\\\)"|[^,]+)/i', $md5_challenge, $matches)) while (preg_match('/^([a-z-]+)=("[^"]+(?<!\\\)"|[^,]+)/i', $md5_challenge, $matches))
{ {

View file

@ -91,22 +91,21 @@ function generate_smilies($mode, $forum_id)
// Format text to be displayed - from viewtopic.php - centralizing this would be nice ;) // Format text to be displayed - from viewtopic.php - centralizing this would be nice ;)
function format_display(&$message, &$signature, $uid, $siguid, $html, $bbcode, $url, $smilies, $sig) function format_display(&$message, &$signature, $uid, $siguid, $html, $bbcode, $url, $smilies, $sig)
{ {
global $auth, $forum_id, $config, $censors, $user, $bbcode, $phpbb_root_path; global $auth, $forum_id, $config, $user, $bbcode, $phpbb_root_path;
// Second parse bbcode here // Second parse bbcode here
$bbcode->bbcode_second_pass($message, $uid); $bbcode->bbcode_second_pass($message, $uid);
// If we allow users to disable display of emoticons we'll need an appropriate // If we allow users to disable display of emoticons we'll need an appropriate
// check and preg_replace here // check and preg_replace here
$message = (!$smilies || !$config['allow_smilies']) ? preg_replace('#<!\-\- s(.*?) \-\-><img src="\{SMILE_PATH\}\/.*? \/><!\-\- s\1 \-\->#', '\1', $message) : str_replace('<img src="{SMILE_PATH}', '<img src="' . $phpbb_root_path . $config['smilies_path'], $message); $message = smilie_text($message, !$smilies);
// Replace naughty words such as farty pants // Replace naughty words such as farty pants
if (sizeof($censors)) /* if (sizeof($censors))
{ {
$message = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace(\$censors['match'], \$censors['replace'], '\\0')", '>' . $message . '<'), 1, -1)); $message = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace(\$censors['match'], \$censors['replace'], '\\0')", '>' . $message . '<'), 1, -1));
} }*/
$message = str_replace("\n", '<br />', censor_text($message));
$message = str_replace("\n", '<br />', $message);
// Signature // Signature
if ($sig && $config['allow_sig'] && $signature && $auth->acl_get('f_sigs', $forum_id)) if ($sig && $config['allow_sig'] && $signature && $auth->acl_get('f_sigs', $forum_id))
@ -114,15 +113,13 @@ function format_display(&$message, &$signature, $uid, $siguid, $html, $bbcode, $
$signature = trim($signature); $signature = trim($signature);
$bbcode->bbcode_second_pass($signature, $siguid); $bbcode->bbcode_second_pass($signature, $siguid);
$signature = smilie_text($signature);
$signature = (!$config['allow_smilies']) ? preg_replace('#<!\-\- s(.*?) \-\-><img src="\{SMILE_PATH\}\/.*? \/><!\-\- s\1 \-\->#', '\1', $signature) : str_replace('<img src="{SMILE_PATH}', '<img src="' . $phpbb_root_path . $config['smilies_path'], $signature); /* if (sizeof($censors))
if (sizeof($censors))
{ {
$signature = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace(\$censors['match'], \$censors['replace'], '\\0')", '>' . $signature . '<'), 1, -1)); $signature = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace(\$censors['match'], \$censors['replace'], '\\0')", '>' . $signature . '<'), 1, -1));
} }*/
$signature = str_replace("\n", '<br />', censor_text($signature));
$signature = str_replace("\n", '<br />', $signature);
} }
else else
{ {

View file

@ -568,7 +568,10 @@ class custom_profile_admin extends custom_profile
{ {
global $user, $config, $db; global $user, $config, $db;
$result = $db->sql_query("SELECT lang_id FROM phpbb_lang WHERE lang_iso = '" . $config['default_lang'] . "'"); $sql = 'SELECT lang_id
FROM ' . LANG_TABLE . "
WHERE lang_iso = '" . $config['default_lang'] . "'";
$result = $db->sql_query($sql);
$default_lang_id = (int) $db->sql_fetchfield('lang_id', 0, $result); $default_lang_id = (int) $db->sql_fetchfield('lang_id', 0, $result);
$db->sql_freeresult($result); $db->sql_freeresult($result);
@ -602,7 +605,10 @@ class custom_profile_admin extends custom_profile
{ {
global $user, $config, $db; global $user, $config, $db;
$result = $db->sql_query("SELECT lang_id FROM phpbb_lang WHERE lang_iso = '" . $config['default_lang'] . "'"); $sql = 'SELECT lang_id
FROM ' . LANG_TABLE . "
WHERE lang_iso = '" . $config['default_lang'] . "'";
$result = $db->sql_query($sql);
$default_lang_id = (int) $db->sql_fetchfield('lang_id', 0, $result); $default_lang_id = (int) $db->sql_fetchfield('lang_id', 0, $result);
$db->sql_freeresult($result); $db->sql_freeresult($result);
@ -639,7 +645,10 @@ class custom_profile_admin extends custom_profile
{ {
global $user, $config, $db; global $user, $config, $db;
$result = $db->sql_query("SELECT lang_id FROM phpbb_lang WHERE lang_iso = '" . $config['default_lang'] . "'"); $sql = 'SELECT lang_id
FROM ' . LANG_TABLE . "
WHERE lang_iso = '" . $config['default_lang'] . "'";
$result = $db->sql_query($sql);
$default_lang_id = (int) $db->sql_fetchfield('lang_id', 0, $result); $default_lang_id = (int) $db->sql_fetchfield('lang_id', 0, $result);
$db->sql_freeresult($result); $db->sql_freeresult($result);

View file

@ -349,10 +349,6 @@ class mcp_main extends mcp
)); ));
// Define censored word matches
$censors = array();
obtain_word_list($censors);
$topic_rows = array(); $topic_rows = array();
// TODO: no global announcements here // TODO: no global announcements here
@ -438,12 +434,8 @@ class mcp_main extends mcp
$topic_type .= $user->lang['VIEW_TOPIC_POLL'] . ' '; $topic_type .= $user->lang['VIEW_TOPIC_POLL'] . ' ';
} }
$topic_title = $row['topic_title']; $topic_title = censor_text($row['topic_title']);
if (count($censors['match']))
{
$topic_title = preg_replace($censors['match'], $censors['replace'], $topic_title);
}
$template->assign_block_vars('topicrow', array( $template->assign_block_vars('topicrow', array(
'U_VIEW_TOPIC' => "mcp.$phpEx$SID&amp;t=" . $row['topic_id'] . '&amp;mode=topic_view', 'U_VIEW_TOPIC' => "mcp.$phpEx$SID&amp;t=" . $row['topic_id'] . '&amp;mode=topic_view',
@ -841,7 +833,7 @@ class mcp_main extends mcp
$bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']); $bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']);
} }
$message = (empty($config['allow_smilies']) || !$user->data['user_viewsmilies']) ? preg_replace('#<!\-\- s(.*?) \-\-><img src="\{SMILE_PATH\}\/.*? \/><!\-\- s\1 \-\->#', '\1', $message) : str_replace('<img src="{SMILE_PATH}', '<img src="' . $config['smilies_path'], $message); $message = smilie_text($message);
$message = nl2br($message); $message = nl2br($message);
@ -1364,7 +1356,7 @@ class mcp_main extends mcp
$bbcode = new bbcode($post_info['bbcode_bitfield']); $bbcode = new bbcode($post_info['bbcode_bitfield']);
$bbcode->bbcode_second_pass($message, $post_info['bbcode_uid'], $post_info['bbcode_bitfield']); $bbcode->bbcode_second_pass($message, $post_info['bbcode_uid'], $post_info['bbcode_bitfield']);
} }
$message = (empty($config['allow_smilies']) || !$user->optionget('viewsmilies')) ? preg_replace('#<!\-\- s(.*?) \-\-><img src="\{SMILE_PATH\}\/.*? \/><!\-\- s\1 \-\->#', '\1', $message) : str_replace('<img src="{SMILE_PATH}', '<img src="' . $config['smilies_path'], $message); $message = smilie_text($message);
$template->assign_vars(array( $template->assign_vars(array(
'S_MCP_ACTION' => $this->url . '&amp;mode=modoptions', 'S_MCP_ACTION' => $this->url . '&amp;mode=modoptions',

View file

@ -622,9 +622,9 @@ class user extends session
$this->lang_name = $config['default_lang']; $this->lang_name = $config['default_lang'];
} }
$sql = "SELECT lang_id $sql = 'SELECT lang_id
FROM phpbb_lang FROM ' . LANG_TABLE . "
WHERE lang_iso = '" . $this->lang_name . "'"; WHERE lang_iso = '{$this->lang_name}'";
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
return (int) $db->sql_fetchfield('lang_id', 0, $result); return (int) $db->sql_fetchfield('lang_id', 0, $result);
@ -640,9 +640,8 @@ class user extends session
return; return;
} }
$sql = 'SELECT * FROM $sql = 'SELECT * FROM ' . CUSTOM_PROFILE_DATA . "
phpbb_profile_fields_data WHERE user_id = $user_id";
WHERE user_id = ' . $user_id;
$result = $db->sql_query_limit($sql, 1); $result = $db->sql_query_limit($sql, 1);
$user->profile_fields = (!($row = $db->sql_fetchrow($result))) ? array() : $row; $user->profile_fields = (!($row = $db->sql_fetchrow($result))) ? array() : $row;

View file

@ -15,7 +15,7 @@ class ucp_activate extends module
{ {
function ucp_activate($id, $mode) function ucp_activate($id, $mode)
{ {
global $censors, $config, $db, $user, $auth, $SID, $template, $phpbb_root_path, $phpEx; global $config, $db, $user, $auth, $SID, $template, $phpbb_root_path, $phpEx;
$user_id = request_var('u', 0); $user_id = request_var('u', 0);
$key = request_var('k', ''); $key = request_var('k', '');

View file

@ -22,7 +22,7 @@ class ucp_confirm extends module
{ {
function ucp_confirm($id, $mode) function ucp_confirm($id, $mode)
{ {
global $censors, $config, $db, $user, $auth, $SID, $template, $phpbb_root_path, $phpEx; global $config, $db, $user, $auth, $SID, $template, $phpbb_root_path, $phpEx;
// Do we have an id? No, then just exit // Do we have an id? No, then just exit
if (empty($_GET['id'])) if (empty($_GET['id']))

View file

@ -15,7 +15,7 @@ class ucp_main extends module
{ {
function ucp_main($id, $mode) function ucp_main($id, $mode)
{ {
global $censors, $config, $db, $user, $auth, $SID, $template, $phpbb_root_path, $phpEx; global $config, $db, $user, $auth, $SID, $template, $phpbb_root_path, $phpEx;
switch ($mode) switch ($mode)
{ {
@ -127,7 +127,7 @@ class ucp_main extends module
'TOPIC_ID' => $topic_id, 'TOPIC_ID' => $topic_id,
'LAST_POST_TIME' => $user->format_date($row['topic_last_post_time']), 'LAST_POST_TIME' => $user->format_date($row['topic_last_post_time']),
'LAST_POST_AUTHOR' => $last_post_author, 'LAST_POST_AUTHOR' => $last_post_author,
'TOPIC_TITLE' => (!empty($censors)) ? preg_replace($censors['match'], $censors['replace'], $row['topic_title']) : $row['topic_title'], 'TOPIC_TITLE' => censor_text($row['topic_title']),
'TOPIC_TYPE' => $topic_type, 'TOPIC_TYPE' => $topic_type,
'LAST_POST_IMG' => $last_post_img, 'LAST_POST_IMG' => $last_post_img,
@ -483,7 +483,7 @@ class ucp_main extends module
'LAST_POST_TIME' => $user->format_date($row['topic_last_post_time']), 'LAST_POST_TIME' => $user->format_date($row['topic_last_post_time']),
'LAST_POST_AUTHOR' => $last_post_author, 'LAST_POST_AUTHOR' => $last_post_author,
'GOTO_PAGE' => $goto_page, 'GOTO_PAGE' => $goto_page,
'TOPIC_TITLE' => (!empty($censors)) ? preg_replace($censors['match'], $censors['replace'], $row['topic_title']) : $row['topic_title'], 'TOPIC_TITLE' => censor_text($row['topic_title']),
'TOPIC_TYPE' => $topic_type, 'TOPIC_TYPE' => $topic_type,
'LAST_POST_IMG' => $last_post_img, 'LAST_POST_IMG' => $last_post_img,

View file

@ -15,7 +15,7 @@ class ucp_prefs extends module
{ {
function ucp_prefs($id, $mode) function ucp_prefs($id, $mode)
{ {
global $censors, $config, $db, $user, $auth, $SID, $template, $phpbb_root_path, $phpEx; global $config, $db, $user, $auth, $SID, $template, $phpbb_root_path, $phpEx;
$submit = (isset($_POST['submit'])) ? true : false; $submit = (isset($_POST['submit'])) ? true : false;
$error = $data = array(); $error = $data = array();

View file

@ -15,7 +15,7 @@ class ucp_profile extends module
{ {
function ucp_profile($id, $mode) function ucp_profile($id, $mode)
{ {
global $censors, $config, $db, $user, $auth, $SID, $template, $phpbb_root_path, $phpEx; global $config, $db, $user, $auth, $SID, $template, $phpbb_root_path, $phpEx;
$preview = (!empty($_POST['preview'])) ? true : false; $preview = (!empty($_POST['preview'])) ? true : false;
$submit = (!empty($_POST['submit'])) ? true : false; $submit = (!empty($_POST['submit'])) ? true : false;
@ -420,18 +420,16 @@ class ucp_profile extends module
$bbcode->bbcode_second_pass($signature_preview, $message_parser->bbcode_uid); $bbcode->bbcode_second_pass($signature_preview, $message_parser->bbcode_uid);
} }
// If we allow users to disable display of emoticons // If we allow users to disable display of emoticons
// we'll need an appropriate check and preg_replace here // we'll need an appropriate check and preg_replace here
$signature_preview = (empty($enable_smilies) || empty($config['allow_smilies'])) ? preg_replace('#<!\-\- s(.*?) \-\-><img src="\{SMILE_PATH\}\/.*? \/><!\-\- s\1 \-\->#', '\1', $signature_preview) : str_replace('<img src="{SMILE_PATH}', '<img src="' . $phpbb_root_path . $config['smilies_path'], $signature_preview); $signature_preview = smilie_text($signature_preview, !$enable_smilies);
// Replace naughty words such as farty pants // Replace naughty words such as farty pants
if (sizeof($censors)) /* if (sizeof($censors))
{ {
$signature_preview = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace(\$censors['match'], \$censors['replace'], '\\0')", '>' . $signature_preview . '<'), 1, -1)); $signature_preview = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace(\$censors['match'], \$censors['replace'], '\\0')", '>' . $signature_preview . '<'), 1, -1));
} }*/
$signature_preview = str_replace("\n", '<br />', censor_text($signature_preview));
$signature_preview = str_replace("\n", '<br />', $signature_preview);
} }
$html_status = ($config['allow_html']) ? true : false; $html_status = ($config['allow_html']) ? true : false;

View file

@ -15,7 +15,7 @@ class ucp_register extends module
{ {
function ucp_register($id, $mode) function ucp_register($id, $mode)
{ {
global $censors, $config, $db, $user, $auth, $SID, $template, $phpbb_root_path, $phpEx; global $config, $db, $user, $auth, $SID, $template, $phpbb_root_path, $phpEx;
// //
if ($config['require_activation'] == USER_ACTIVATION_DISABLE) if ($config['require_activation'] == USER_ACTIVATION_DISABLE)
@ -200,7 +200,7 @@ class ucp_register extends module
if (sizeof($cp_data)) if (sizeof($cp_data))
{ {
$cp_data['user_id'] = (int) $user_id; $cp_data['user_id'] = (int) $user_id;
$sql = 'INSERT INTO phpbb_profile_fields_data ' . $db->sql_build_array('INSERT', $cp->build_insert_sql_array($cp_data)); $sql = 'INSERT INTO ' CUSTOM_PROFILE_DATA . ' ' . $db->sql_build_array('INSERT', $cp->build_insert_sql_array($cp_data));
$db->sql_query($sql); $db->sql_query($sql);
} }

View file

@ -15,7 +15,7 @@ class ucp_remind extends module
{ {
function ucp_remind($id, $mode) function ucp_remind($id, $mode)
{ {
global $censors, $config, $db, $user, $auth, $SID, $template, $phpbb_root_path, $phpEx; global $config, $db, $user, $auth, $SID, $template, $phpbb_root_path, $phpEx;
$submit = (isset($_POST['submit'])) ? true : false; $submit = (isset($_POST['submit'])) ? true : false;

View file

@ -15,7 +15,7 @@ class ucp_zebra extends module
{ {
function ucp_zebra($id, $mode) function ucp_zebra($id, $mode)
{ {
global $censors, $config, $db, $user, $auth, $SID, $template, $phpbb_root_path, $phpEx; global $config, $db, $user, $auth, $SID, $template, $phpbb_root_path, $phpEx;
$submit = (!empty($_POST['submit']) || !empty($_GET['add'])) ? true : false; $submit = (!empty($_POST['submit']) || !empty($_GET['add'])) ? true : false;

View file

@ -335,7 +335,7 @@ switch ($mode)
if ($member['user_sig']) if ($member['user_sig'])
{ {
$member['user_sig'] = ($config['allow_smilies']) ? preg_replace('#<!\-\- s(.*?) \-\-><img src="\{SMILE_PATH\}\/.*? \/><!\-\- s\1 \-\->#', '\1', $member['user_sig']) : str_replace('<img src="{SMILE_PATH}', '<img src="' . $config['smilies_path'], $member['user_sig']); $member['user_sig'] = smilie_text($member['user_sig']);
} }
$poster_avatar = ''; $poster_avatar = '';

View file

@ -110,9 +110,6 @@ switch ($mode)
trigger_error('NO_POST_MODE'); trigger_error('NO_POST_MODE');
} }
$censors = array();
obtain_word_list($censors);
if ($sql) if ($sql)
{ {
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
@ -252,10 +249,14 @@ else
$notify_set = 0; $notify_set = 0;
} }
if (!$auth->acl_get('f_' . $mode, $forum_id) && $forum_type == FORUM_POST) if (!$auth->acl_get('f_' . $mode, $forum_id) && $forum_type == FORUM_POST)
{ {
trigger_error('USER_CANNOT_' . strtoupper($mode)); if ($user->data['user_id'] != ANONYMOUS)
{
trigger_error('USER_CANNOT_' . strtoupper($mode));
}
login_box(preg_replace('#.*?([a-z]+?\.' . $phpEx . '.*?)$#i', '\1', htmlspecialchars($_SERVER['REQUEST_URI'])), '', $user->lang['USER_CANNOT_' . strtoupper($mode)]);
} }
@ -784,7 +785,7 @@ if (!sizeof($error) && $preview)
{ {
$post_time = ($mode == 'edit') ? $post_time : $current_time; $post_time = ($mode == 'edit') ? $post_time : $current_time;
$preview_subject = (sizeof($censors['match'])) ? preg_replace($censors['match'], $censors['replace'], $subject) : $subject; $preview_subject = censor_text($preview_subject);
$preview_signature = ($mode == 'edit') ? $user_sig : $user->data['user_sig']; $preview_signature = ($mode == 'edit') ? $user_sig : $user->data['user_sig'];
$preview_signature_uid = ($mode == 'edit') ? $user_sig_bbcode_uid : $user->data['user_sig_bbcode_uid']; $preview_signature_uid = ($mode == 'edit') ? $user_sig_bbcode_uid : $user->data['user_sig_bbcode_uid'];
@ -849,13 +850,13 @@ if (count($poll_options))
if ($mode == 'quote' && !$preview && !$refresh) if ($mode == 'quote' && !$preview && !$refresh)
{ {
$post_text = '[quote="' . $quote_username . '"]' . ((sizeof($censors['match'])) ? preg_replace($censors['match'], $censors['replace'], trim($post_text)) : trim($post_text)) . "[/quote]\n"; $post_text = '[quote="' . $quote_username . '"]' . censor_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: ' : '') . ((sizeof($censors['match'])) ? preg_replace($censors['match'], $censors['replace'], $post_subject) : $post_subject); $post_subject = ((!preg_match('/^Re:/', $post_subject)) ? 'Re: ' : '') . censor_text($post_subject);
} }
@ -1168,7 +1169,7 @@ page_footer();
// User Notification // User Notification
function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id, $topic_id, $post_id) function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id, $topic_id, $post_id)
{ {
global $db, $user, $censors, $config, $phpbb_root_path, $phpEx, $auth; global $db, $user, $config, $phpbb_root_path, $phpEx, $auth;
$topic_notification = ($mode == 'reply' || $mode == 'quote'); $topic_notification = ($mode == 'reply' || $mode == 'quote');
$forum_notification = ($mode == 'post'); $forum_notification = ($mode == 'post');
@ -1178,15 +1179,9 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id
trigger_error('WRONG_NOTIFICATION_MODE'); trigger_error('WRONG_NOTIFICATION_MODE');
} }
if (!$censors)
{
$censors = array();
obtain_word_list($censors);
}
$topic_title = ($topic_notification) ? $topic_title : $subject; $topic_title = ($topic_notification) ? $topic_title : $subject;
decode_text($topic_title); decode_text($topic_title);
$topic_title = (sizeof($censors['match'])) ? preg_replace($censors['match'], $censors['replace'], $topic_title) : $topic_title; $topic_title = censor_text($topic_title);
// Get banned User ID's // Get banned User ID's
$sql = 'SELECT ban_userid $sql = 'SELECT ban_userid
@ -1394,14 +1389,7 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id
function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id = 0) function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id = 0)
{ {
global $user, $auth, $db, $template, $bbcode, $template; global $user, $auth, $db, $template, $bbcode, $template;
global $censors, $config, $phpbb_root_path, $phpEx, $SID; global $config, $phpbb_root_path, $phpEx, $SID;
// Define censored word matches
if (!$censors)
{
$censors = array();
obtain_word_list($censors);
}
// Go ahead and pull all data for this topic // Go ahead and pull all data for this topic
$sql = 'SELECT u.username, u.user_id, u.user_karma, p.post_id, p.post_username, p.post_subject, p.post_text, p.enable_smilies, p.bbcode_uid, p.bbcode_bitfield, p.post_time $sql = 'SELECT u.username, u.user_id, u.user_karma, p.post_id, p.post_username, p.post_subject, p.post_text, p.enable_smilies, p.bbcode_uid, p.bbcode_bitfield, p.post_time
@ -1454,13 +1442,10 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id
$bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']); $bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']);
} }
$message = (!$row['enable_smilies'] || !$config['allow_smilies']) ? preg_replace('#<!\-\- s(.*?) \-\-><img src="\{SMILE_PATH\}\/.*? \/><!\-\- s\1 \-\->#', '\1', $message) : str_replace('<img src="{SMILE_PATH}', '<img src="' . $phpbb_root_path . $config['smilies_path'], $message); $message = smilie_text($message, !$row['enable_smilies']);
if (sizeof($censors['match'])) $post_subject = censor_text($post_subject);
{ $message = censor_text($message);
$post_subject = preg_replace($censors['match'], $censors['replace'], $post_subject);
$message = preg_replace($censors['match'], $censors['replace'], $message);
}
$template->assign_block_vars($mode . '_row', array( $template->assign_block_vars($mode . '_row', array(
'KARMA_IMG' => '<img src="images/karma' . $row['user_karma'] . '.gif" alt="' . $user->lang['KARMA_LEVEL'] . ': ' . $user->lang['KARMA'][$row['user_karma']] . '" title="' . $user->lang['KARMA_LEVEL'] . ': ' . $user->lang['KARMA'][$row['user_karma']] . '" />', 'KARMA_IMG' => '<img src="images/karma' . $row['user_karma'] . '.gif" alt="' . $user->lang['KARMA_LEVEL'] . ': ' . $user->lang['KARMA'][$row['user_karma']] . '" title="' . $user->lang['KARMA_LEVEL'] . ': ' . $user->lang['KARMA'][$row['user_karma']] . '" />',

View file

@ -584,9 +584,8 @@ if ($search_keywords || $search_author || $search_id)
$per_page = ($show_results == 'posts') ? $config['posts_per_page'] : $config['topics_per_page']; $per_page = ($show_results == 'posts') ? $config['posts_per_page'] : $config['topics_per_page'];
// Grab icons // Grab icons
$icons = $censors = array(); $icons = array();
obtain_icons($icons); obtain_icons($icons);
obtain_word_list($censors);
// Output header // Output header
$l_search_matches = ($total_match_count == 1) ? sprintf($user->lang['FOUND_SEARCH_MATCH'], $total_match_count) : sprintf($user->lang['FOUND_SEARCH_MATCHES'], $total_match_count); $l_search_matches = ($total_match_count == 1) ? sprintf($user->lang['FOUND_SEARCH_MATCH'], $total_match_count) : sprintf($user->lang['FOUND_SEARCH_MATCHES'], $total_match_count);
@ -733,10 +732,11 @@ if ($search_keywords || $search_author || $search_id)
continue; continue;
} }
if (!empty($censors)) /* if (!empty($censors))
{ {
$row['post_text'] = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace(\$censors['match'], \$censors['replace'], '\\0')", '>' . $row['post_text'] . '<'), 1, -1)); $row['post_text'] = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace(\$censors['match'], \$censors['replace'], '\\0')", '>' . $row['post_text'] . '<'), 1, -1));
} }*/
$row['post_text'] = censor_text($row['post_text']);
if ($row['bbcode_bitfield']) if ($row['bbcode_bitfield'])
{ {
@ -752,7 +752,7 @@ if ($search_keywords || $search_author || $search_id)
// via php.net's annotated manual // via php.net's annotated manual
$row['post_text'] = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace('#\b(" . $hilit . ")\b#i', '<span class=\"posthilit\">\\\\1</span>', '\\0')", '>' . $row['post_text'] . '<'), 1, -1)); $row['post_text'] = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace('#\b(" . $hilit . ")\b#i', '<span class=\"posthilit\">\\\\1</span>', '\\0')", '>' . $row['post_text'] . '<'), 1, -1));
$row['post_text'] = (empty($config['allow_smilies']) || !$user->data['user_viewsmilies']) ? preg_replace('#<!\-\- s(.*?) \-\-><img src="\{SMILE_PATH\}\/.*? \/><!\-\- s\1 \-\->#', '\1', $row['post_text']) : str_replace('<img src="{SMILE_PATH}', '<img src="' . $config['smilies_path'], $row['post_text']); $row['post_text'] = smilie_text($row['post_text']);
} }
$template->assign_block_vars('searchresults', array( $template->assign_block_vars('searchresults', array(
@ -769,11 +769,11 @@ if ($search_keywords || $search_author || $search_id)
'TOPIC_REPLIES' => ($auth->acl_get('m_approve')) ? $row['topic_replies_real'] : $row['topic_replies'], 'TOPIC_REPLIES' => ($auth->acl_get('m_approve')) ? $row['topic_replies_real'] : $row['topic_replies'],
'TOPIC_VIEWS' => $row['topic_views'], 'TOPIC_VIEWS' => $row['topic_views'],
'FORUM_TITLE' => $row['forum_name'], 'FORUM_TITLE' => $row['forum_name'],
'TOPIC_TITLE' => (!empty($censors)) ? preg_replace($censors['match'], $censors['replace'], $row['topic_title']) : $row['topic_title'], 'TOPIC_TITLE' => censor_text($row['topic_title']),
'TOPIC_TYPE' => $topic_type, 'TOPIC_TYPE' => $topic_type,
'POSTER_NAME' => ($row['poster_id'] == ANONYMOUS) ? ((!empty($row['post_username'])) ? $row['post_username'] : $user->lang['GUEST']) : $row['username'], 'POSTER_NAME' => ($row['poster_id'] == ANONYMOUS) ? ((!empty($row['post_username'])) ? $row['post_username'] : $user->lang['GUEST']) : $row['username'],
'POST_SUBJECT' => (!empty($row['post_subject'])) ? ((!empty($censors)) ? preg_replace($censors['match'], $censors['replace'], $row['post_subject']) : $row['post_subject']) : '', 'POST_SUBJECT' => censor_text($row['post_subject']),
'POST_DATE' => (!empty($row['post_time'])) ? $user->format_date($row['post_time']) : '', 'POST_DATE' => (!empty($row['post_time'])) ? $user->format_date($row['post_time']) : '',
'MESSAGE' => (!empty($row['post_text'])) ? str_replace("\n", '<br />', $row['post_text']) : '', 'MESSAGE' => (!empty($row['post_text'])) ? str_replace("\n", '<br />', $row['post_text']) : '',

View file

@ -298,11 +298,6 @@ if ($user->data['user_id'] == ANONYMOUS || $user->data['user_type'] == USER_INAC
} }
// Word censors $censors['match'] & $censors['replace']
$censors = array();
obtain_word_list($censors);
// Output listing of friends online // Output listing of friends online
$update_time = $config['load_online_time'] * 60; $update_time = $config['load_online_time'] * 60;

View file

@ -112,7 +112,7 @@ if ($forum_data['forum_password'])
} }
// Redirect to login upon emailed notification links // Redirect to login upon emailed notification links
if (!empty($_GET['e']) && $user->data['user_id'] == ANONYMOUS) if (isset($_GET['e']) && $user->data['user_id'] == ANONYMOUS)
{ {
login_box(preg_replace('#.*?([a-z]+?\.' . $phpEx . '.*?)$#i', '\1', htmlspecialchars($_SERVER['REQUEST_URI'])), '', $user->lang['LOGIN_NOTIFY_FORUM']); login_box(preg_replace('#.*?([a-z]+?\.' . $phpEx . '.*?)$#i', '\1', htmlspecialchars($_SERVER['REQUEST_URI'])), '', $user->lang['LOGIN_NOTIFY_FORUM']);
} }
@ -183,7 +183,7 @@ if ($forum_data['forum_type'] == FORUM_POST || ($forum_data['forum_flags'] & 16)
} }
} }
// Forum rules, subscription info and word censors // Forum rules amd subscription info
$s_watching_forum = $s_watching_forum_img = ''; $s_watching_forum = $s_watching_forum_img = '';
if (($config['email_enable'] || $config['jab_enable']) && $config['allow_forum_notify'] && $auth->acl_get('f_subscribe', $forum_id)) if (($config['email_enable'] || $config['jab_enable']) && $config['allow_forum_notify'] && $auth->acl_get('f_subscribe', $forum_id))
{ {
@ -194,9 +194,6 @@ if ($forum_data['forum_type'] == FORUM_POST || ($forum_data['forum_flags'] & 16)
$s_forum_rules = ''; $s_forum_rules = '';
gen_forum_rules('forum', $forum_id); gen_forum_rules('forum', $forum_id);
$censors = array();
obtain_word_list($censors);
// Topic ordering options // Topic ordering options
$limit_days = array(0 => $user->lang['ALL_TOPICS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 364 => $user->lang['1_YEAR']); $limit_days = array(0 => $user->lang['ALL_TOPICS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 364 => $user->lang['1_YEAR']);
@ -539,7 +536,7 @@ if ($forum_data['forum_type'] == FORUM_POST || ($forum_data['forum_flags'] & 16)
'GOTO_PAGE' => $goto_page, 'GOTO_PAGE' => $goto_page,
'REPLIES' => ($auth->acl_get('m_approve')) ? $row['topic_replies_real'] : $row['topic_replies'], 'REPLIES' => ($auth->acl_get('m_approve')) ? $row['topic_replies_real'] : $row['topic_replies'],
'VIEWS' => $row['topic_views'], 'VIEWS' => $row['topic_views'],
'TOPIC_TITLE' => (!empty($censors)) ? preg_replace($censors['match'], $censors['replace'], $row['topic_title']) : $row['topic_title'], 'TOPIC_TITLE' => censor_text($row['topic_title']),
'TOPIC_TYPE' => $topic_type, 'TOPIC_TYPE' => $topic_type,
'LAST_POST_IMG' => $last_post_img, 'LAST_POST_IMG' => $last_post_img,

View file

@ -432,10 +432,6 @@ $topic_mod .= ($auth->acl_get('m_', $forum_id)) ? '<option value="viewlogs">' .
$pagination_url = "viewtopic.$phpEx$SID&amp;f=$forum_id&amp;t=$topic_id&amp;sk=$sort_key&amp;st=$sort_days&amp;sd=$sort_dir" . (($highlight_match) ? "&amp;hilit=$highlight" : ''); $pagination_url = "viewtopic.$phpEx$SID&amp;f=$forum_id&amp;t=$topic_id&amp;sk=$sort_key&amp;st=$sort_days&amp;sd=$sort_dir" . (($highlight_match) ? "&amp;hilit=$highlight" : '');
$pagination = generate_pagination($pagination_url, $total_posts, $config['posts_per_page'], $start); $pagination = generate_pagination($pagination_url, $total_posts, $config['posts_per_page'], $start);
// Grab censored words
$censors = array();
obtain_word_list($censors);
// Navigation links // Navigation links
generate_forum_nav($topic_data); generate_forum_nav($topic_data);
@ -447,10 +443,7 @@ get_moderators($forum_moderators, $forum_id);
$server_path = (!$view) ? '' : generate_board_url() . '/'; $server_path = (!$view) ? '' : generate_board_url() . '/';
// Replace naughty words in title // Replace naughty words in title
if (sizeof($censors)) $topic_title = censor_text($topic_title);
{
$topic_title = preg_replace($censors['match'], $censors['replace'], $topic_title);
}
// Send vars to template // Send vars to template
$template->assign_vars(array( $template->assign_vars(array(
@ -640,7 +633,8 @@ if (!empty($poll_start))
foreach ($poll_info as $poll_option) foreach ($poll_info as $poll_option)
{ {
$poll_option['poll_option_text'] = (sizeof($censors)) ? preg_replace($censors['match'], $censors['replace'], $poll_option['poll_option_text']) : $poll_option['poll_option_text']; $poll_option['poll_option_text'] = censor_text($poll_option['poll_option_text']);
$option_pct = ($poll_total > 0) ? $poll_option['poll_option_total'] / $poll_total : 0; $option_pct = ($poll_total > 0) ? $poll_option['poll_option_total'] / $poll_total : 0;
$option_pct_txt = sprintf("%.1d%%", ($option_pct * 100)); $option_pct_txt = sprintf("%.1d%%", ($option_pct * 100));
@ -655,7 +649,7 @@ if (!empty($poll_start))
} }
$template->assign_vars(array( $template->assign_vars(array(
'POLL_QUESTION' => (sizeof($censors)) ? preg_replace($censors['match'], $censors['replace'], $poll_title) : $poll_title, 'POLL_QUESTION' => censor_text($poll_title),
'TOTAL_VOTES' => $poll_total, 'TOTAL_VOTES' => $poll_total,
'POLL_LEFT_CAP_IMG' => $user->img('poll_left'), 'POLL_LEFT_CAP_IMG' => $user->img('poll_left'),
'POLL_RIGHT_CAP_IMG'=> $user->img('poll_right'), 'POLL_RIGHT_CAP_IMG'=> $user->img('poll_right'),
@ -1090,19 +1084,18 @@ for ($i = 0; $i < count($post_list); ++$i)
// End signature parsing, only if needed // End signature parsing, only if needed
if ($user_cache[$poster_id]['sig'] && empty($user_cache[$poster_id]['sig_parsed'])) if ($user_cache[$poster_id]['sig'] && empty($user_cache[$poster_id]['sig_parsed']))
{ {
$user_cache[$poster_id]['sig'] = (!$config['allow_smilies'] || !$user->optionget('viewsmilies')) ? preg_replace('#<!\-\- s(.*?) \-\-><img src="\{SMILE_PATH\}\/.*? \/><!\-\- s\1 \-\->#', '\1', $user_cache[$poster_id]['sig']) : str_replace('<img src="{SMILE_PATH}', '<img src="' . $config['smilies_path'], $user_cache[$poster_id]['sig']);
if ($user_cache[$poster_id]['sig_bbcode_bitfield']) if ($user_cache[$poster_id]['sig_bbcode_bitfield'])
{ {
$bbcode->bbcode_second_pass($user_cache[$poster_id]['sig'], $user_cache[$poster_id]['sig_bbcode_uid'], $user_cache[$poster_id]['sig_bbcode_bitfield']); $bbcode->bbcode_second_pass($user_cache[$poster_id]['sig'], $user_cache[$poster_id]['sig_bbcode_uid'], $user_cache[$poster_id]['sig_bbcode_bitfield']);
} }
if (count($censors)) $user_cache[$poster_id]['sig'] = smilie_text($user_cache[$poster_id]['sig']);
/*if (count($censors))
{ {
$user_cache[$poster_id]['sig'] = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace(\$censors['match'], \$censors['replace'], '\\0')", '>' . $user_cache[$poster_id]['sig'] . '<'), 1, -1)); $user_cache[$poster_id]['sig'] = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace(\$censors['match'], \$censors['replace'], '\\0')", '>' . $user_cache[$poster_id]['sig'] . '<'), 1, -1));
} }*/
$user_cache[$poster_id]['sig'] = str_replace("\n", '<br />', censor_text($user_cache[$poster_id]['sig']));
$user_cache[$poster_id]['sig'] = str_replace("\n", '<br />', $user_cache[$poster_id]['sig']);
$user_cache[$poster_id]['sig_parsed'] = TRUE; $user_cache[$poster_id]['sig_parsed'] = TRUE;
} }
@ -1124,9 +1117,8 @@ for ($i = 0; $i < count($post_list); ++$i)
$bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']); $bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']);
} }
// If we allow users to disable display of emoticons // Always process smilies after parsing bbcodes
// we'll need an appropriate check and preg_replace here $message = smilie_text($message);
$message = (empty($config['allow_smilies']) || !$user->optionget('viewsmilies')) ? preg_replace('#<!\-\- s(.*?) \-\-><img src="\{SMILE_PATH\}\/.*? \/><!\-\- s\1 \-\->#', '\1', $message) : str_replace('<img src="{SMILE_PATH}', '<img src="' . $config['smilies_path'], $message);
// Highlight active words (primarily for search) // Highlight active words (primarily for search)
if ($highlight_match) if ($highlight_match)
@ -1137,13 +1129,13 @@ for ($i = 0; $i < count($post_list); ++$i)
} }
// Replace naughty words such as farty pants // Replace naughty words such as farty pants
if (sizeof($censors)) /* if (sizeof($censors))
{ {
$row['post_subject'] = preg_replace($censors['match'], $censors['replace'], $row['post_subject']); $row['post_subject'] = preg_replace($censors['match'], $censors['replace'], $row['post_subject']);
$message = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace(\$censors['match'], \$censors['replace'], '\\0')", '>' . $message . '<'), 1, -1)); $message = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace(\$censors['match'], \$censors['replace'], '\\0')", '>' . $message . '<'), 1, -1));
} }*/
$row['post_subject'] = censor_text($row['post_subject']);
$message = str_replace("\n", '<br />', $message); $message = str_replace("\n", '<br />', censor_text($message));
// Editing information // Editing information
if (($row['post_edit_count'] && $config['display_last_edited']) || $row['post_edit_reason']) if (($row['post_edit_count'] && $config['display_last_edited']) || $row['post_edit_reason'])