mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-05 00:07:44 +02:00
- 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:
@@ -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)
|
||||
{
|
||||
|
@@ -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&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);
|
||||
}
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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))
|
||||
{
|
||||
|
@@ -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
|
||||
{
|
||||
|
@@ -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);
|
||||
|
||||
|
@@ -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&t=" . $row['topic_id'] . '&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 . '&mode=modoptions',
|
||||
|
@@ -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;
|
||||
|
@@ -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', '');
|
||||
|
@@ -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']))
|
||||
|
@@ -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,
|
||||
|
@@ -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();
|
||||
|
@@ -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;
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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;
|
||||
|
||||
|
Reference in New Issue
Block a user