aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes')
-rw-r--r--phpBB/includes/functions.php36
-rw-r--r--phpBB/includes/functions_admin.php12
-rw-r--r--phpBB/includes/functions_display.php10
-rw-r--r--phpBB/includes/functions_messenger.php4
-rw-r--r--phpBB/includes/functions_posting.php21
-rw-r--r--phpBB/includes/functions_profile_fields.php15
-rw-r--r--phpBB/includes/mcp/mcp_main.php16
-rw-r--r--phpBB/includes/session.php11
-rw-r--r--phpBB/includes/ucp/ucp_activate.php2
-rw-r--r--phpBB/includes/ucp/ucp_confirm.php2
-rw-r--r--phpBB/includes/ucp/ucp_main.php6
-rw-r--r--phpBB/includes/ucp/ucp_prefs.php2
-rw-r--r--phpBB/includes/ucp/ucp_profile.php12
-rw-r--r--phpBB/includes/ucp/ucp_register.php4
-rw-r--r--phpBB/includes/ucp/ucp_remind.php2
-rw-r--r--phpBB/includes/ucp/ucp_zebra.php2
16 files changed, 85 insertions, 72 deletions
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index 4390b1be36..1885a66d02 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -1049,7 +1049,7 @@ function login_forum_box(&$forum_data)
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) . "')";
$db->sql_query($sql);
@@ -1066,7 +1066,7 @@ function login_forum_box(&$forum_data)
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)
{
global $config, $auth, $user;
@@ -1097,6 +1097,38 @@ function bump_topic_allowed($forum_id, $topic_bumped, $last_post_time, $topic_po
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
function msg_handler($errno, $msg_text, $errfile, $errline)
{
diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php
index 6309dda87d..865be1065e 100644
--- a/phpBB/includes/functions_admin.php
+++ b/phpBB/includes/functions_admin.php
@@ -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";
- $censors = array();
- if ($user->optionget('viewcensors'))
- {
- obtain_word_list($censors);
- }
-
switch ($mode)
{
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)
{
- if (sizeof($censors) && $user->optionget('viewcensors'))
- {
- $log_data = preg_replace($censors['match'], $censors['replace'], $log_data);
- }
- $log_data = str_replace("\n", '<br />', $log_data);
+ $log_data = str_replace("\n", '<br />', censor_text($log_data));
$log[$i]['action'] = preg_replace('#%s#', $log_data, $log[$i]['action'], 1);
}
diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php
index 3f0bee5d39..dc86e48ec9 100644
--- a/phpBB/includes/functions_display.php
+++ b/phpBB/includes/functions_display.php
@@ -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)
{
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 = $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))
{
$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);
$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;
diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php
index d758539bae..89e192a6e0 100644
--- a/phpBB/includes/functions_messenger.php
+++ b/phpBB/includes/functions_messenger.php
@@ -810,6 +810,8 @@ function smtpmail($addresses, $subject, $message, &$err_msg, $headers = '', $log
return true;
}
+// SMTP Class
+// Auth Mechanisms originally taken from the AUTH Modules found within the PHP Extension and Application Repository (PEAR)
class smtp_class
{
var $server_response = '';
@@ -1099,7 +1101,7 @@ class smtp_class
$md5_challenge = base64_decode($this->responses[0]);
- // Parse the md5 challenge - from PEAR
+ // Parse the md5 challenge - from AUTH_SASL (PEAR)
$tokens = array();
while (preg_match('/^([a-z-]+)=("[^"]+(?<!\\\)"|[^,]+)/i', $md5_challenge, $matches))
{
diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php
index 9a0aa1bd48..2383558100 100644
--- a/phpBB/includes/functions_posting.php
+++ b/phpBB/includes/functions_posting.php
@@ -91,22 +91,21 @@ function generate_smilies($mode, $forum_id)
// 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)
{
- 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
$bbcode->bbcode_second_pass($message, $uid);
// If we allow users to disable display of emoticons we'll need an appropriate
// 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
- 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("\n", '<br />', $message);
+ }*/
+ $message = str_replace("\n", '<br />', censor_text($message));
// Signature
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);
$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("\n", '<br />', $signature);
+ }*/
+ $signature = str_replace("\n", '<br />', censor_text($signature));
}
else
{
diff --git a/phpBB/includes/functions_profile_fields.php b/phpBB/includes/functions_profile_fields.php
index d59a150db3..c706508c52 100644
--- a/phpBB/includes/functions_profile_fields.php
+++ b/phpBB/includes/functions_profile_fields.php
@@ -568,7 +568,10 @@ class custom_profile_admin extends custom_profile
{
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);
$db->sql_freeresult($result);
@@ -602,7 +605,10 @@ class custom_profile_admin extends custom_profile
{
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);
$db->sql_freeresult($result);
@@ -639,7 +645,10 @@ class custom_profile_admin extends custom_profile
{
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);
$db->sql_freeresult($result);
diff --git a/phpBB/includes/mcp/mcp_main.php b/phpBB/includes/mcp/mcp_main.php
index 3f7b752c26..d9b88eca67 100644
--- a/phpBB/includes/mcp/mcp_main.php
+++ b/phpBB/includes/mcp/mcp_main.php
@@ -349,10 +349,6 @@ class mcp_main extends mcp
));
- // Define censored word matches
- $censors = array();
- obtain_word_list($censors);
-
$topic_rows = array();
// TODO: no global announcements here
@@ -438,12 +434,8 @@ class mcp_main extends mcp
$topic_type .= $user->lang['VIEW_TOPIC_POLL'] . ' ';
}
- $topic_title = $row['topic_title'];
- if (count($censors['match']))
- {
- $topic_title = preg_replace($censors['match'], $censors['replace'], $topic_title);
- }
-
+ $topic_title = censor_text($row['topic_title']);
+
$template->assign_block_vars('topicrow', array(
'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']);
}
- $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);
@@ -1364,7 +1356,7 @@ class mcp_main extends mcp
$bbcode = new bbcode($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(
'S_MCP_ACTION' => $this->url . '&amp;mode=modoptions',
diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php
index d6c561f872..81700c7415 100644
--- a/phpBB/includes/session.php
+++ b/phpBB/includes/session.php
@@ -622,9 +622,9 @@ class user extends session
$this->lang_name = $config['default_lang'];
}
- $sql = "SELECT lang_id
- FROM phpbb_lang
- WHERE lang_iso = '" . $this->lang_name . "'";
+ $sql = 'SELECT lang_id
+ FROM ' . LANG_TABLE . "
+ WHERE lang_iso = '{$this->lang_name}'";
$result = $db->sql_query($sql);
return (int) $db->sql_fetchfield('lang_id', 0, $result);
@@ -640,9 +640,8 @@ class user extends session
return;
}
- $sql = 'SELECT * FROM
- phpbb_profile_fields_data
- WHERE user_id = ' . $user_id;
+ $sql = 'SELECT * FROM ' . CUSTOM_PROFILE_DATA . "
+ WHERE user_id = $user_id";
$result = $db->sql_query_limit($sql, 1);
$user->profile_fields = (!($row = $db->sql_fetchrow($result))) ? array() : $row;
diff --git a/phpBB/includes/ucp/ucp_activate.php b/phpBB/includes/ucp/ucp_activate.php
index 43d04eda4a..0667f4dfa9 100644
--- a/phpBB/includes/ucp/ucp_activate.php
+++ b/phpBB/includes/ucp/ucp_activate.php
@@ -15,7 +15,7 @@ class ucp_activate extends module
{
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);
$key = request_var('k', '');
diff --git a/phpBB/includes/ucp/ucp_confirm.php b/phpBB/includes/ucp/ucp_confirm.php
index 2d44fc943a..cec4e18be1 100644
--- a/phpBB/includes/ucp/ucp_confirm.php
+++ b/phpBB/includes/ucp/ucp_confirm.php
@@ -22,7 +22,7 @@ class ucp_confirm extends module
{
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
if (empty($_GET['id']))
diff --git a/phpBB/includes/ucp/ucp_main.php b/phpBB/includes/ucp/ucp_main.php
index 96eddfe3de..c7783b88b9 100644
--- a/phpBB/includes/ucp/ucp_main.php
+++ b/phpBB/includes/ucp/ucp_main.php
@@ -15,7 +15,7 @@ class ucp_main extends module
{
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)
{
@@ -127,7 +127,7 @@ class ucp_main extends module
'TOPIC_ID' => $topic_id,
'LAST_POST_TIME' => $user->format_date($row['topic_last_post_time']),
'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,
'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_AUTHOR' => $last_post_author,
'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,
'LAST_POST_IMG' => $last_post_img,
diff --git a/phpBB/includes/ucp/ucp_prefs.php b/phpBB/includes/ucp/ucp_prefs.php
index 11efb5a64d..c2ebef5438 100644
--- a/phpBB/includes/ucp/ucp_prefs.php
+++ b/phpBB/includes/ucp/ucp_prefs.php
@@ -15,7 +15,7 @@ class ucp_prefs extends module
{
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;
$error = $data = array();
diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php
index 4e7ccc7d23..fcfbd8336d 100644
--- a/phpBB/includes/ucp/ucp_profile.php
+++ b/phpBB/includes/ucp/ucp_profile.php
@@ -15,7 +15,7 @@ class ucp_profile extends module
{
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;
$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);
}
-
// If we allow users to disable display of emoticons
// 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
- 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("\n", '<br />', $signature_preview);
+ }*/
+ $signature_preview = str_replace("\n", '<br />', censor_text($signature_preview));
}
$html_status = ($config['allow_html']) ? true : false;
diff --git a/phpBB/includes/ucp/ucp_register.php b/phpBB/includes/ucp/ucp_register.php
index b0440cedad..c1da4aa0a5 100644
--- a/phpBB/includes/ucp/ucp_register.php
+++ b/phpBB/includes/ucp/ucp_register.php
@@ -15,7 +15,7 @@ class ucp_register extends module
{
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)
@@ -200,7 +200,7 @@ class ucp_register extends module
if (sizeof($cp_data))
{
$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);
}
diff --git a/phpBB/includes/ucp/ucp_remind.php b/phpBB/includes/ucp/ucp_remind.php
index 80b863b321..f119633c82 100644
--- a/phpBB/includes/ucp/ucp_remind.php
+++ b/phpBB/includes/ucp/ucp_remind.php
@@ -15,7 +15,7 @@ class ucp_remind extends module
{
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;
diff --git a/phpBB/includes/ucp/ucp_zebra.php b/phpBB/includes/ucp/ucp_zebra.php
index 9807837729..c599effe38 100644
--- a/phpBB/includes/ucp/ucp_zebra.php
+++ b/phpBB/includes/ucp/ucp_zebra.php
@@ -15,7 +15,7 @@ class ucp_zebra extends module
{
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;