aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--phpBB/adm/admin_attachments.php1
-rw-r--r--phpBB/adm/admin_forums.php83
-rw-r--r--phpBB/adm/admin_users.php49
-rw-r--r--phpBB/includes/bbcode.php26
-rw-r--r--phpBB/includes/functions.php61
-rw-r--r--phpBB/includes/functions_messenger.php7
-rw-r--r--phpBB/includes/functions_posting.php163
-rw-r--r--phpBB/includes/functions_privmsgs.php376
-rw-r--r--phpBB/includes/functions_profile_fields.php2
-rw-r--r--phpBB/includes/functions_user.php12
-rw-r--r--phpBB/includes/message_parser.php465
-rw-r--r--phpBB/includes/session.php33
-rw-r--r--phpBB/includes/ucp/ucp_pm.php2
-rw-r--r--phpBB/includes/ucp/ucp_pm_compose.php475
-rw-r--r--phpBB/includes/ucp/ucp_pm_options.php12
-rw-r--r--phpBB/includes/ucp/ucp_pm_viewfolder.php4
-rw-r--r--phpBB/includes/ucp/ucp_prefs.php18
-rw-r--r--phpBB/includes/ucp/ucp_profile.php128
-rw-r--r--phpBB/index.php2
-rw-r--r--phpBB/install/schemas/mysql_schema.sql4
-rw-r--r--phpBB/install/schemas/schema_data.sql1
-rw-r--r--phpBB/language/en/mcp.php4
-rw-r--r--phpBB/language/en/ucp.php7
-rw-r--r--phpBB/memberlist.php4
-rw-r--r--phpBB/posting.php159
-rw-r--r--phpBB/report.php265
-rw-r--r--phpBB/styles/subSilver/template/report_body.html4
-rw-r--r--phpBB/styles/subSilver/template/ucp_header.html2
-rw-r--r--phpBB/styles/subSilver/template/ucp_prefs_personal.html4
-rw-r--r--phpBB/styles/subSilver/template/ucp_profile_avatar.html2
-rw-r--r--phpBB/viewonline.php2
-rw-r--r--phpBB/viewtopic.php2
32 files changed, 1309 insertions, 1070 deletions
diff --git a/phpBB/adm/admin_attachments.php b/phpBB/adm/admin_attachments.php
index 7dfb5416d7..0ffc556241 100644
--- a/phpBB/adm/admin_attachments.php
+++ b/phpBB/adm/admin_attachments.php
@@ -423,6 +423,7 @@ if ($submit && $mode == 'orphan')
upload_file($row['post_id'], $row['topic_id'], $row['forum_id'], $config['upload_dir'], $upload_list[$row['post_id']]);
}
}
+ unset($message_parser);
}
}
diff --git a/phpBB/adm/admin_forums.php b/phpBB/adm/admin_forums.php
index 8c96696f73..37a926a14f 100644
--- a/phpBB/adm/admin_forums.php
+++ b/phpBB/adm/admin_forums.php
@@ -100,9 +100,6 @@ if ($update)
'forum_desc' => str_replace("\n", '<br />', request_var('forum_desc', '')),
'forum_rules' => request_var('forum_rules', ''),
'forum_rules_link' => request_var('forum_rules_link', ''),
- 'rules_allow_bbcode' => request_var('parse_bbcode', false),
- 'rules_allow_smilies' => request_var('parse_smilies', false),
- 'rules_allow_urls' => request_var('parse_urls', false),
'forum_image' => request_var('forum_image', ''),
'forum_style' => request_var('forum_style', 0),
'display_on_index' => request_var('display_on_index', FALSE),
@@ -120,6 +117,25 @@ if ($update)
'forum_password_confirm'=> request_var('forum_password_confirm', '')
);
+ if ($forum_data['forum_rules'])
+ {
+ include_once($phpbb_root_path . 'includes/message_parser.' . $phpEx);
+
+ $allow_bbcode = request_var('parse_bbcode', false);
+ $allow_smilies = request_var('parse_smilies', false);
+ $allow_urls = request_var('parse_urls', false);
+
+ $forum_data['forum_rules_flags'] = (($allow_bbcode) ? 1 : 0) + (($allow_smilies) ? 2 : 0) + (($allow_urls) ? 4 : 0);
+
+ $message_parser = new parse_message($forum_data['forum_rules']);
+ $message_parser->parse(false, $allow_bbcode, $allow_urls, $allow_smilies);
+
+ $forum_data['forum_rules'] = $message_parser->message;
+ $forum_data['forum_rules_bbcode_uid'] = $message_parser->bbcode_uid;
+ $forum_data['forum_rules_bbcode_bitfield'] = $message_parser->bbcode_bitfield;
+ unset($message_parser);
+ }
+
$errors = update_forum_data($forum_data);
if ($errors)
@@ -144,6 +160,7 @@ switch ($mode)
{
case 'add':
case 'edit':
+
if (isset($_POST['update']))
{
extract($forum_data);
@@ -167,7 +184,7 @@ switch ($mode)
$forum_rules_flags += (request_var('parse_smilies', false)) ? 2 : 0;
$forum_rules_flags += (request_var('parse_urls', false)) ? 4 : 0;
}
-
+
// Show form to create/modify a forum
if ($mode == 'edit')
{
@@ -189,12 +206,9 @@ switch ($mode)
$forum_password_confirm = $forum_password;
- $flags = explode(':', $forum_rules_flags);
-
- $bbcode_checked = ((int) $flags[0] & 1) ? ' checked="checked"' : '';
- $smilies_checked = ((int) $flags[0] & 2) ? ' checked="checked"' : '';
- $urls_checked = ((int) $flags[0] & 4) ? ' checked="checked"' : '';
- unset($flags);
+ $bbcode_checked = ($forum_rules_flags & 1) ? ' checked="checked"' : '';
+ $smilies_checked = ($forum_rules_flags & 2) ? ' checked="checked"' : '';
+ $urls_checked = ($forum_rules_flags & 4) ? ' checked="checked"' : '';
}
else
{
@@ -221,22 +235,23 @@ switch ($mode)
}
}
- // Forum Rules
if ($forum_rules)
{
include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
-
- // Split text rules (we saved the status and bbcode codes here)
- if (strpos($forum_rules_flags, ':') === false && is_numeric($forum_rules_flags))
+ include_once($phpbb_root_path . 'includes/message_parser.' . $phpEx);
+
+ $message_parser = new parse_message($forum_rules);
+ if (isset($forum_rules_bbcode_uid))
{
- // text not parsed yet... a hard time for us...
- $forum_rules_flags = 0;
- $forum_rules = parse_text_insert($forum_rules, request_var('parse_bbcode', false), request_var('parse_smilies', false), request_var('parse_urls', false), $forum_rules_flags);
+ $message_parser->bbcode_uid = $forum_rules_bbcode_uid;
+ $message_parser->bbcode_bitfield = $forum_rules_bbcode_bitfield;
+ }
+ else
+ {
+ $message_parser->parse(false, ($forum_rules_flags & 1), ($forum_rules_flags & 4), ($forum_rules_flags & 2));
}
-
- $forum_rules_preview = parse_text_display($forum_rules, $forum_rules_flags);
}
-
+
$forum_type_options = '';
$forum_type_ary = array(FORUM_CAT => 'CAT', FORUM_POST => 'FORUM', FORUM_LINK => 'LINK');
foreach ($forum_type_ary as $value => $lang)
@@ -390,19 +405,26 @@ switch ($mode)
<td class="row2"><input class="post" type="text" size="40" name="forum_rules_link" value="<?php echo $forum_rules_link ?>" /></td>
</tr>
<?php
- if ($forum_rules_preview)
+ if ($forum_rules)
{
?>
<tr>
<td class="row1"><b><?php echo $user->lang['FORUM_RULES_PREVIEW'] ?>: </b></td>
- <td class="row2"><?php echo $forum_rules_preview; ?></td>
+ <td class="row2"><?php echo $message_parser->format_display(false, ($forum_rules_flags & 1), ($forum_rules_flags & 4), ($forum_rules_flags & 2), false); ?></td>
</tr>
<?php
}
?>
<tr>
<td class="row1"><b><?php echo $user->lang['FORUM_RULES'] ?>: </b><br /><span class="gensmall"><?php echo $user->lang['FORUM_RULES_EXPLAIN']; ?></span></td>
- <td class="row2"><table cellspacing="2" cellpadding="0" border="0"><tr><td colspan="6"><textarea class="post" rows="4" cols="70" name="forum_rules"><?php echo ($forum_rules) ? parse_text_form_display($forum_rules, $forum_rules_flags) : ''; ?></textarea></td></tr><tr>
+ <td class="row2"><table cellspacing="2" cellpadding="0" border="0"><tr><td colspan="6"><textarea class="post" rows="4" cols="70" name="forum_rules">
+<?php
+ if ($forum_rules)
+ {
+ $message_parser->decode_message();
+ echo $message_parser->message;
+ }
+?></textarea></td></tr><tr>
<td width="10"><input type="checkbox" name="parse_bbcode"<?php echo $bbcode_checked; ?> /></td><td><?php echo $user->lang['PARSE_BBCODE']; ?></td><td width="10"><input type="checkbox" name="parse_smilies"<?php echo $smilies_checked; ?> /></td><td><?php echo $user->lang['PARSE_SMILIES']; ?></td><td width="10"><input type="checkbox" name="parse_urls"<?php echo $urls_checked; ?> /></td><td><?php echo $user->lang['PARSE_URLS']; ?></td></tr></table>
</td>
</tr>
@@ -970,21 +992,6 @@ function update_forum_data(&$forum_data)
unset($forum_data['prune_sticky']);
unset($forum_data['forum_password_confirm']);
- // Parse Forum Rules
- $forum_data['forum_rules_flags'] = 0;
-
- if ($forum_data['forum_rules'])
- {
- global $phpbb_root_path, $phpEx;
- include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
-
- $forum_data['forum_rules'] = parse_text_insert($forum_data['forum_rules'], $forum_data['rules_allow_bbcode'], $forum_data['rules_allow_smilies'], $forum_data['rules_allow_urls'], $forum_data['forum_rules_flags']);
- }
-
- unset($forum_data['rules_allow_smilies']);
- unset($forum_data['rules_allow_urls']);
- unset($forum_data['rules_allow_bbcode']);
-
// What are we going to do tonight Brain? The same thing we do everynight,
// try to take over the world ... or decide whether to continue update
// and if so, whether it's a new forum/cat/link or an existing one
diff --git a/phpBB/adm/admin_users.php b/phpBB/adm/admin_users.php
index de8ff4fe30..bed04d8f91 100644
--- a/phpBB/adm/admin_users.php
+++ b/phpBB/adm/admin_users.php
@@ -1044,7 +1044,6 @@ function marklist(match, status)
'user_notify_pm' => true,
'user_allow_pm' => true,
'user_notify' => false,
- 'user_min_karma' => (int) -5,
'sk' => (string) 't',
'sd' => (string) 'd',
@@ -1072,7 +1071,6 @@ function marklist(match, status)
'user_dateformat' => array('string', false, 3, 15),
'user_lang' => array('match', false, '#^[a-z_]{2,}$#i'),
'user_tz' => array('num', false, -13, 13),
- 'user_min_karma' => array('num', false, -5, 5),
'sk' => array('string', false, 1, 1),
'sd' => array('string', false, 1, 1),
@@ -1101,7 +1099,6 @@ function marklist(match, status)
'user_notify_pm' => $user_notify_pm,
'user_options' => $user_options,
'user_notify' => $user_notify,
- 'user_min_karma' => $user_min_karma,
'user_dst' => $user_dst,
'user_dateformat' => $user_dateformat,
'user_lang' => $user_lang,
@@ -1127,7 +1124,7 @@ function marklist(match, status)
$colspan = 2;
- $option_ary = array('user_allow_viewemail', 'user_allow_massemail', 'user_allow_pm', 'user_allow_viewonline', 'user_notify_pm', 'user_dst', 'user_notify', 'user_min_karma');
+ $option_ary = array('user_allow_viewemail', 'user_allow_massemail', 'user_allow_pm', 'user_allow_viewonline', 'user_notify_pm', 'user_dst', 'user_notify');
foreach ($option_ary as $option)
{
@@ -1495,13 +1492,18 @@ function marklist(match, status)
$$var = request_var($var, $default);
}
- if (!$preview)
- {
- include($phpbb_root_path . 'includes/message_parser.'.$phpEx);
+ // NOTE: allow_img and allow_flash do not exist in config table
+ $img_status = ($config['allow_img']) ? true : false;
+ $flash_status = ($config['allow_flash']) ? true : false;
+
+ include($phpbb_root_path . 'includes/message_parser.'.$phpEx);
+ $message_parser = new parse_message($signature);
- $message_parser = new parse_message($signature);
- $message_parser->parse($enable_html, $enable_bbcode, $enable_urls, $enable_smilies);
+ // Allowing Quote BBCode
+ $message_parser->parse($enable_html, $enable_bbcode, $enable_urls, $enable_smilies, $img_status, $flash_status, true);
+ if ($submit)
+ {
$sql_ary = array(
'user_sig' => (string) $message_parser->message,
'user_sig_bbcode_uid' => (string) $message_parser->bbcode_uid,
@@ -1513,6 +1515,7 @@ function marklist(match, status)
WHERE user_id = $user_id";
$db->sql_query($sql);
+ unset($message_parser);
trigger_error($user->lang['PROFILE_UPDATED']);
}
}
@@ -1524,32 +1527,12 @@ function marklist(match, status)
$signature_preview = '';
if ($preview)
{
- $signature_preview = $signature;
-
- // Fudge-o-rama ...
- include($phpbb_root_path . 'includes/message_parser.'.$phpEx);
-
- $message_parser = new parse_message($signature_preview);
- $message_parser->parse($enable_html, $enable_bbcode, $enable_urls, $enable_smilies);
- $signature_preview = $message_parser->message;
-
- if ($enable_bbcode)
- {
- include($phpbb_root_path . 'includes/bbcode.'.$phpEx);
- $bbcode = new bbcode($message_parser->bbcode_bitfield);
-
- $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 = smilie_text($signature_preview, !$enable_smilies);
-
- // Replace naughty words such as farty pants
- $signature_preview = str_replace("\n", '<br />', censor_text($signature_preview));
+ // Now parse it for displaying
+ $signature_preview = $message_parser->format_display($enable_html, $enable_bbcode, $enable_urls, $enable_smilies, false);
+ unset($message_parser);
}
- decode_text($user_sig, $user_sig_bbcode_uid);
+ decode_message($user_sig, $user_sig_bbcode_uid);
?>
<tr>
diff --git a/phpBB/includes/bbcode.php b/phpBB/includes/bbcode.php
index 144dafbb30..f9b8fcbce3 100644
--- a/phpBB/includes/bbcode.php
+++ b/phpBB/includes/bbcode.php
@@ -11,6 +11,9 @@
//
// -------------------------------------------------------------
+// BBCODE - able to be used standalone
+//
+
class bbcode
{
var $bbcode_uid = '';
@@ -18,6 +21,8 @@ class bbcode
var $bbcode_cache = array();
var $bbcode_template = array();
+ var $bbcodes = array();
+
var $template_bitfield = 0;
var $template_filename = '';
@@ -30,14 +35,14 @@ class bbcode
}
}
- function bbcode_second_pass(&$message, $bbcode_uid = '', $bbcode_bitfield = FALSE)
+ function bbcode_second_pass(&$message, $bbcode_uid = '', $bbcode_bitfield = false)
{
if ($bbcode_uid)
{
$this->bbcode_uid = $bbcode_uid;
}
- if ($bbcode_bitfield !== FALSE)
+ if ($bbcode_bitfield !== false)
{
$this->bbcode_bitfield = $bbcode_bitfield;
// Init those added with a new bbcode_bitfield (already stored codes will not get parsed again)
@@ -371,6 +376,8 @@ class bbcode
function bbcode_tpl_replace($tpl_name, $tpl)
{
+ global $user;
+
static $replacements = array(
'quote_username_open' => array('{USERNAME}' => '$1'),
'color' => array('{COLOR}' => '$1', '{TEXT}' => '$2'),
@@ -458,7 +465,19 @@ class bbcode
$code = str_replace("\t", '&nbsp; &nbsp;', $code);
$code = str_replace(' ', '&nbsp; ', $code);
$code = str_replace(' ', ' &nbsp;', $code);
- $code = preg_replace('#<!\-\- s(.*?) \-\-><img src="\{SMILE_PATH\}\/.*? \/><!\-\- s\1 \-\->#', '\1', $code);
+
+ $match = array(
+ '#<!\-\- e \-\-><a href="mailto:(.*?)">.*?</a><!\-\- e \-\->#',
+ '#<!\-\- m \-\-><a href="(.*?)" target="_blank">.*?</a><!\-\- m \-\->#',
+ '#<!\-\- w \-\-><a href="http:\/\/(.*?)" target="_blank">.*?</a><!\-\- w \-\->#',
+ '#<!\-\- l \-\-><a href="(.*?)" target="_blank">.*?</a><!\-\- l \-\->#',
+ '#<!\-\- s(.*?) \-\-><img src="\{SMILE_PATH\}\/.*? \/><!\-\- s\1 \-\->#',
+ '#^[\n]#'
+ );
+
+ $replace = array('\1', '\1', '\1', '\1', '\1', '');
+
+ $code = preg_replace($match, $replace, $code);
}
$code = $this->bbcode_tpl('code_open') . $code . $this->bbcode_tpl('code_close');
@@ -466,4 +485,5 @@ class bbcode
return $code;
}
}
+
?> \ No newline at end of file
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index c914fb7db8..939de4b1ab 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -117,49 +117,6 @@ function get_userdata($user)
return ($row = $db->sql_fetchrow($result)) ? $row : false;
}
-// prepare text to be displayed/previewed...
-// This function is here to save memory (this function is used by viewforum/viewtopic/posting... and to include another huge file is pure memory waste)
-function parse_text_display($text, $text_rules)
-{
- global $bbcode, $user;
-
- $text_flags = explode(':', $text_rules);
-
- $allow_bbcode = (int) $text_flags[0] & 1;
- $allow_smilies = (int) $text_flags[0] & 2;
- $allow_magic_url = (int) $text_flags[0] & 4;
-
- $bbcode_uid = trim($text_flags[1]);
- $bbcode_bitfield = (int) $text_flags[2];
-
- // Really, really process bbcode only if we have something to process...
- if (!$bbcode && $allow_bbcode && strpos($text, '[') !== false)
- {
- global $phpbb_root_path, $phpEx;
-
- include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx);
- $bbcode = new bbcode();
- }
-
- // Second parse bbcode here
- if ($allow_bbcode)
- {
- $bbcode->bbcode_second_pass($text, $bbcode_uid, $bbcode_bitfield);
- }
-
- // If we allow users to disable display of emoticons we'll need an appropriate
- // check and preg_replace here
- if ($allow_smilies)
- {
- $text = smilie_text($text, !$allow_smilies);
- }
-
- // Replace naughty words such as farty pants
- $text = str_replace("\n", '<br />', censor_text($text));
-
- return $text;
-}
-
// Create forum rules for given forum
function generate_forum_rules($forum_data)
{
@@ -172,13 +129,20 @@ function generate_forum_rules($forum_data)
if ($forum_data['forum_rules'])
{
- $text_flags = explode(':', $forum_data['forum_rules_flags']);
+ include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx);
+ $bbcode = new bbcode($forum_data['forum_rules_bbcode_bitfield']);
+
+ $bbcode->bbcode_second_pass($forum_data['forum_rules'], $forum_data['forum_rules_bbcode_uid']);
+
+ $forum_data['forum_rules'] = smilie_text($forum_data['forum_rules'], !($forum_data['forum_rules_flags'] & 2));
+ $forum_data['forum_rules'] = str_replace("\n", '<br />', censor_text($forum_data['forum_rules']));
+ unset($bbcode);
}
$template->assign_vars(array(
'S_FORUM_RULES' => true,
'U_FORUM_RULES' => $forum_data['forum_rules_link'],
- 'FORUM_RULES' => (!$forum_data['forum_rules_link']) ? parse_text_display($forum_data['forum_rules'], $forum_data['forum_rules_flags']) : '')
+ 'FORUM_RULES' => $forum_data['forum_rules'])
);
}
@@ -834,10 +798,7 @@ function generate_pagination($base_url, $num_items, $per_page, $start_item, $add
$page_string .= ($on_page == $total_pages) ? '<strong>' . $total_pages . '</strong>' : '<a href="' . $base_url . '&amp;start=' . (($total_pages - 1) * $per_page) . '">' . $total_pages . '</a>&nbsp;&nbsp;<a href="' . $base_url . "&amp;start=" . ($on_page * $per_page) . '">' . $user->lang['NEXT'] . '</a>';
// $page_string = $user->lang['GOTO_PAGE'] . ' ' . $page_string;
- if ($user->theme['primary']['pagination_goto_page'])
- {
- $page_string = '<a href="javascript:jumpto();">' . $user->lang['GOTO_PAGE'] . '</a> ' . $page_string;
- }
+ $page_string = '<a href="javascript:jumpto();">' . $user->lang['GOTO_PAGE'] . '</a> ' . $page_string;
$template->assign_var('BASE_URL', $base_url);
$template->assign_var('PER_PAGE', $per_page);
@@ -1544,7 +1505,7 @@ function page_header($page_title = '')
$row['username'] = '<b style="color:#' . $row['user_colour'] . '">' . $row['username'] . '</b>';
}
- if ($row['user_allow_viewonline'] && $row['session_allow_viewonline'])
+ if ($row['user_allow_viewonline'] && $row['session_viewonline'])
{
$user_online_link = $row['username'];
$logged_visible_online++;
diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php
index 71c775864f..573423fb19 100644
--- a/phpBB/includes/functions_messenger.php
+++ b/phpBB/includes/functions_messenger.php
@@ -147,7 +147,7 @@ class messenger
}
// Send the mail out to the recipients set previously in var $this->address
- function send($method = NOTIFY_EMAIL)
+ function send($method = NOTIFY_EMAIL, $break = false)
{
global $config, $user;
@@ -198,6 +198,11 @@ class messenger
$this->msg = trim(preg_replace('#' . $drop_header . '#s', '', $this->msg));
}
+ if ($break)
+ {
+ return;
+ }
+
switch ($method)
{
case NOTIFY_EMAIL:
diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php
index 9edca24ff2..fede697d1e 100644
--- a/phpBB/includes/functions_posting.php
+++ b/phpBB/includes/functions_posting.php
@@ -90,101 +90,6 @@ 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, $enable_html, $enable_bbcode, $enable_url, $enable_smilies, $enable_sig, $bbcode = '')
-{
- global $auth, $forum_id, $config, $user, $phpbb_root_path;
-
- if (!$bbcode)
- {
- global $bbcode;
- }
-
- // Second parse bbcode here
- if ($enable_bbcode)
- {
- $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 = smilie_text($message, !$enable_smilies);
-
- // Replace naughty words such as farty pants
- $message = str_replace("\n", '<br />', censor_text($message));
-
- // Signature
- if ($enable_sig && $config['allow_sig'] && $signature && $auth->acl_get('f_sigs', $forum_id))
- {
- $signature = trim($signature);
-
- $bbcode->bbcode_second_pass($signature, $siguid);
- $signature = smilie_text($signature);
-
- $signature = str_replace("\n", '<br />', censor_text($signature));
- }
- else
- {
- $signature = '';
- }
-
- return $message;
-}
-
-// Three simple functions we use for bbcode/smilie/url capable text
-
-// prepare text to be inserted into db...
-function parse_text_insert($text, $allow_bbcode, $allow_smilies, $allow_magic_url, &$text_flags)
-{
- global $message_parser;
-
- $text_flags += ($allow_bbcode) ? 1 : 0;
- $text_flags += ($allow_smilies) ? 2 : 0;
- $text_flags += ($allow_magic_url) ? 4 : 0;
-
- $match = array('#\r\n?#', '#sid=[a-z0-9]*?&amp;?#', "#([\n][\s]+){3,}#", '#&amp;(\#[0-9]+;)#');
- $replace = array("\n", '', "\n\n", '&\1');
- $text = preg_replace($match, $replace, $text);
-
- // Parse BBCode
- if (!method_exists('parse_message', 'parse_message') || !isset($message_parser))
- {
- global $phpbb_root_path, $phpEx;
- include_once($phpbb_root_path . 'includes/message_parser.' . $phpEx);
- $message_parser = new parse_message();
- }
-
- $message_parser->message = $text;
-
- if ($allow_bbcode && strpos($text, '[') !== false)
- {
- $message_parser->bbcode_init();
- $message_parser->bbcode();
- }
-
- // Parse Emoticons
- $message_parser->emoticons($allow_smilies);
-
- // Parse URL's
- $message_parser->magic_url($allow_magic_url);
-
- $text_flags = $text_flags . ':' . $message_parser->bbcode_uid . ':' . $message_parser->bbcode_bitfield;
-
- return $message_parser->message;
-}
-
-// prepare text to be displayed within a form (fetched from db)
-function parse_text_form_display($text, $text_rules)
-{
- // We use decode_text here...
- $text_rules = explode(':', $text_rules);
- $bbcode_uid = trim($text_rules[1]);
-
- decode_text($text, $bbcode_uid);
-
- return $text;
-}
-
// Update Last Post Informations
function update_last_post_information($type, $id)
{
@@ -444,6 +349,7 @@ function get_img_size_format($width, $height)
}
}
+// Return supported image types
function get_supported_image_types($type)
{
if (@extension_loaded('gd'))
@@ -581,31 +487,31 @@ function create_thumbnail($source, $new_file, $mimetype)
}
// DECODE TEXT -> This will/should be handled by bbcode.php eventually
-function decode_text(&$message, $bbcode_uid = '')
+function decode_message(&$message, $bbcode_uid = '')
{
global $config;
$server_protocol = ($config['cookie_secure']) ? 'https://' : 'http://';
$server_port = ($config['server_port'] <> 80) ? ':' . trim($config['server_port']) . '/' : '/';
- $match = array(
- '<br />',
- "[/*:m:$bbcode_uid]",
- ":u:$bbcode_uid",
- ":o:$bbcode_uid",
- ":$bbcode_uid"
- );
-
- $replace = array(
- "\n",
- '',
- '',
- '',
- ''
- );
+ $match = array('<br />', "[/*:m:$bbcode_uid]", ":u:$bbcode_uid", ":o:$bbcode_uid", ":$bbcode_uid");
+ $replace = array("\n", '', '', '', '');
$message = ($bbcode_uid) ? str_replace($match, $replace, $message) : str_replace('<br />', "\n", $message);
+ // HTML
+ if ($config['allow_html_tags'])
+ {
+ // If $html is true then "allowed_tags" are converted back from entity
+ // form, others remain
+ $allowed_tags = split(',', $config['allow_html_tags']);
+
+ if (sizeof($allowed_tags))
+ {
+ $message = preg_replace('#\<(\/?)(' . str_replace('*', '.*?', implode('|', $allowed_tags)) . ')\>#is', '&lt;$1$2&gt;', $message);
+ }
+ }
+
$match = array(
'#<!\-\- e \-\-><a href="mailto:(.*?)">.*?</a><!\-\- e \-\->#',
'#<!\-\- m \-\-><a href="(.*?)" target="_blank">.*?</a><!\-\- m \-\->#',
@@ -626,19 +532,6 @@ function decode_text(&$message, $bbcode_uid = '')
$message = preg_replace($match, $replace, $message);
- // HTML
- if ($config['allow_html_tags'])
- {
- // If $html is true then "allowed_tags" are converted back from entity
- // form, others remain
- $allowed_tags = split(',', $config['allow_html_tags']);
-
- if (sizeof($allowed_tags))
- {
- $message = preg_replace('#\<(\/?)(' . str_replace('*', '.*?', implode('|', $allowed_tags)) . ')\>#is', '&lt;$1$2&gt;', $message);
- }
- }
-
return;
}
@@ -663,6 +556,7 @@ function phpbb_strtolower($string)
return $new_string;
}
+// Generate Topic Icons for display
function posting_gen_topic_icons($mode, $icon_id)
{
global $phpbb_root_path, $config, $template;
@@ -700,15 +594,16 @@ function posting_gen_topic_icons($mode, $icon_id)
return false;
}
-function posting_gen_inline_attachments($message_parser)
+// Assign Inline attachments (build option fields)
+function posting_gen_inline_attachments($attachment_data)
{
global $template;
- if (sizeof($message_parser->attachment_data))
+ if (sizeof($attachment_data))
{
$s_inline_attachment_options = '';
- foreach ($message_parser->attachment_data as $i => $attachment)
+ foreach ($attachment_data as $i => $attachment)
{
$s_inline_attachment_options .= '<option value="' . $i . '">' . $attachment['real_filename'] . '</option>';
}
@@ -721,6 +616,7 @@ function posting_gen_inline_attachments($message_parser)
return false;
}
+// Build topic types able to be selected
function posting_gen_topic_types($forum_id, $cur_topic_type = POST_NORMAL)
{
global $auth, $user, $template, $topic_type;
@@ -776,7 +672,7 @@ function posting_gen_topic_types($forum_id, $cur_topic_type = POST_NORMAL)
return $toggle;
}
-function posting_gen_attachment_entry($message_parser)
+function posting_gen_attachment_entry($attachment_data, $filename_data)
{
global $template, $config, $phpbb_root_path, $SID, $phpEx;
@@ -784,14 +680,14 @@ function posting_gen_attachment_entry($message_parser)
'S_SHOW_ATTACH_BOX' => true)
);
- if (sizeof($message_parser->attachment_data))
+ if (sizeof($attachment_data))
{
$template->assign_vars(array(
'S_HAS_ATTACHMENTS' => true)
);
$count = 0;
- foreach ($message_parser->attachment_data as $attach_row)
+ foreach ($attachment_data as $attach_row)
{
$hidden = '';
$attach_row['real_filename'] = stripslashes($attach_row['real_filename']);
@@ -819,12 +715,12 @@ function posting_gen_attachment_entry($message_parser)
}
$template->assign_vars(array(
- 'FILE_COMMENT' => $message_parser->filename_data['filecomment'],
+ 'FILE_COMMENT' => $filename_data['filecomment'],
'FILESIZE' => $config['max_filesize'],
- 'FILENAME' => $message_parser->filename_data['filename'])
+ 'FILENAME' => $filename_data['filename'])
);
- return sizeof($message_parser->attachment_data);
+ return sizeof($attachment_data);
}
// Load Drafts
@@ -1027,7 +923,6 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id
}
$topic_title = ($topic_notification) ? $topic_title : $subject;
- decode_text($topic_title);
$topic_title = censor_text($topic_title);
// Get banned User ID's
diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php
index 97054a6a74..019c8f8826 100644
--- a/phpBB/includes/functions_privmsgs.php
+++ b/phpBB/includes/functions_privmsgs.php
@@ -1019,7 +1019,14 @@ function get_folder_status($folder_id, $folder)
{
global $db, $user, $config;
- $folder = $folder[$folder_id];
+ if (isset($folder[$folder_id]))
+ {
+ $folder = $folder[$folder_id];
+ }
+ else
+ {
+ return false;
+ }
$return = array();
$message_limit = (!$user->data['group_message_limit']) ? $config['pm_max_msgs'] : $user->data['group_message_limit'];
@@ -1037,4 +1044,371 @@ function get_folder_status($folder_id, $folder)
return $return;
}
+//
+// COMPOSE MESSAGES
+//
+
+// Submit PM
+function submit_pm($mode, $subject, $data, $update_message, $put_in_outbox = true)
+{
+ global $db, $auth, $user, $config, $phpEx, $SID, $template;
+
+ // We do not handle erasing posts here
+ if ($mode == 'delete')
+ {
+ return;
+ }
+
+ $current_time = time();
+
+ // Collect some basic informations about which tables and which rows to update/insert
+ $sql_data = array();
+ $root_level = 0;
+
+ // Recipient Informations
+ $recipients = $to = $bcc = array();
+
+ if ($mode != 'edit')
+ {
+ // Build Recipient List
+ // u|g => array($user_id => 'to'|'bcc')
+ foreach (array('u', 'g') as $ug_type)
+ {
+ if (sizeof($data['address_list'][$ug_type]))
+ {
+ foreach ($data['address_list'][$ug_type] as $id => $field)
+ {
+ $field = ($field == 'to') ? 'to' : 'bcc';
+ if ($ug_type == 'u')
+ {
+ $recipients[$id] = $field;
+ }
+ ${$field}[] = $ug_type . '_' . (int) $id;
+ }
+ }
+ }
+
+ if (sizeof($data['address_list']['g']))
+ {
+ $sql = 'SELECT group_id, user_id
+ FROM ' . USER_GROUP_TABLE . '
+ WHERE group_id IN (' . implode(', ', array_keys($data['address_list']['g'])) . ')
+ AND user_pending = 0';
+ $result = $db->sql_query($sql);
+
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $field = ($data['address_list']['g'][$row['group_id']] == 'to') ? 'to' : 'bcc';
+ $recipients[$row['user_id']] = $field;
+ }
+ $db->sql_freeresult($result);
+ }
+
+ if (!sizeof($recipients))
+ {
+ trigger_error('NO_RECIPIENT');
+ }
+ }
+
+ $sql = '';
+
+ switch ($mode)
+ {
+ case 'reply':
+ case 'quote':
+ $root_level = ($data['reply_from_root_level']) ? $data['reply_from_root_level'] : $data['reply_from_msg_id'];
+
+ // Set message_replied switch for this user
+ $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . '
+ SET replied = 1
+ WHERE user_id = ' . $user->data['user_id'] . '
+ AND msg_id = ' . $data['reply_from_msg_id'];
+
+ case 'forward':
+ case 'post':
+ $sql_data = array(
+ 'root_level' => $root_level,
+ 'author_id' => (int) $user->data['user_id'],
+ 'icon_id' => $data['icon_id'],
+ 'author_ip' => $user->ip,
+ 'message_time' => $current_time,
+ 'enable_bbcode' => $data['enable_bbcode'],
+ 'enable_html' => $data['enable_html'],
+ 'enable_smilies' => $data['enable_smilies'],
+ 'enable_magic_url' => $data['enable_urls'],
+ 'enable_sig' => $data['enable_sig'],
+ 'message_subject' => $subject,
+ 'message_text' => $data['message'],
+ 'message_checksum' => $data['message_md5'],
+ 'message_encoding' => $user->lang['ENCODING'],
+ 'message_attachment'=> (sizeof($data['filename_data']['physical_filename'])) ? 1 : 0,
+ 'bbcode_bitfield' => $data['bbcode_bitfield'],
+ 'bbcode_uid' => $data['bbcode_uid'],
+ 'to_address' => implode(':', $to),
+ 'bcc_address' => implode(':', $bcc)
+ );
+ break;
+
+ case 'edit':
+ $sql_data = array(
+ 'icon_id' => $data['icon_id'],
+ 'message_edit_time' => $current_time,
+ 'enable_bbcode' => $data['enable_bbcode'],
+ 'enable_html' => $data['enable_html'],
+ 'enable_smilies' => $data['enable_smilies'],
+ 'enable_magic_url' => $data['enable_urls'],
+ 'enable_sig' => $data['enable_sig'],
+ 'message_subject' => $subject,
+ 'message_text' => $data['message'],
+ 'message_checksum' => $data['message_md5'],
+ 'message_encoding' => $user->lang['ENCODING'],
+ 'message_attachment'=> (sizeof($data['filename_data']['physical_filename'])) ? 1 : 0,
+ 'bbcode_bitfield' => $data['bbcode_bitfield'],
+ 'bbcode_uid' => $data['bbcode_uid']
+ );
+ break;
+ }
+
+ if (sizeof($sql_data))
+ {
+ if ($mode == 'post' || $mode == 'reply' || $mode == 'quote' || $mode == 'forward')
+ {
+ $db->sql_query('INSERT INTO ' . PRIVMSGS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_data));
+ $data['msg_id'] = $db->sql_nextid();
+ }
+ else if ($mode == 'edit')
+ {
+ $sql = 'UPDATE ' . PRIVMSGS_TABLE . '
+ SET message_edit_count = message_edit_count + 1, ' . $db->sql_build_array('UPDATE', $sql_data) . '
+ WHERE msg_id = ' . $data['msg_id'];
+ $db->sql_query($sql);
+ }
+ }
+
+ if ($mode != 'edit')
+ {
+ $db->sql_transaction();
+
+ if ($sql)
+ {
+ $db->sql_query($sql);
+ }
+ unset($sql);
+
+ foreach ($recipients as $user_id => $type)
+ {
+ $db->sql_query('INSERT INTO ' . PRIVMSGS_TO_TABLE . ' ' . $db->sql_build_array('INSERT', array(
+ 'msg_id' => $data['msg_id'],
+ 'user_id' => $user_id,
+ 'author_id' => $user->data['user_id'],
+ 'folder_id' => PRIVMSGS_NO_BOX,
+ 'new' => 1,
+ 'unread' => 1,
+ 'forwarded' => ($mode == 'forward') ? 1 : 0))
+ );
+ }
+
+ $sql = 'UPDATE ' . USERS_TABLE . '
+ SET user_new_privmsg = user_new_privmsg + 1, user_unread_privmsg = user_unread_privmsg + 1
+ WHERE user_id IN (' . implode(', ', array_keys($recipients)) . ')';
+ $db->sql_query($sql);
+
+ // Put PM into outbox
+ if ($put_in_outbox)
+ {
+ $db->sql_query('INSERT INTO ' . PRIVMSGS_TO_TABLE . ' ' . $db->sql_build_array('INSERT', array(
+ 'msg_id' => (int) $data['msg_id'],
+ 'user_id' => (int) $user->data['user_id'],
+ 'author_id' => (int) $user->data['user_id'],
+ 'folder_id' => PRIVMSGS_OUTBOX,
+ 'new' => 0,
+ 'unread' => 0,
+ 'forwarded' => ($mode == 'forward') ? 1 : 0))
+ );
+ }
+
+ $db->sql_transaction('commit');
+ }
+
+ // Set user last post time
+ if ($mode == 'reply' || $mode == 'quote' || $mode == 'forward' || $mode == 'post')
+ {
+ $sql = 'UPDATE ' . USERS_TABLE . "
+ SET user_lastpost_time = $current_time
+ WHERE user_id = " . $user->data['user_id'];
+ $db->sql_query($sql);
+ }
+
+ $db->sql_transaction();
+
+ // Submit Attachments
+ if (sizeof($data['attachment_data']) && $data['msg_id'] && in_array($mode, array('post', 'reply', 'quote', 'edit', 'forward')))
+ {
+ $space_taken = $files_added = 0;
+
+ foreach ($data['attachment_data'] as $pos => $attach_row)
+ {
+ if ($attach_row['attach_id'])
+ {
+ // update entry in db if attachment already stored in db and filespace
+ $sql = 'UPDATE ' . ATTACHMENTS_TABLE . "
+ SET comment = '" . $db->sql_escape($attach_row['comment']) . "'
+ WHERE attach_id = " . (int) $attach_row['attach_id'];
+ $db->sql_query($sql);
+ }
+ else
+ {
+ // insert attachment into db
+ $attach_sql = array(
+ 'post_msg_id' => $data['msg_id'],
+ 'topic_id' => 0,
+ 'in_message' => 1,
+ 'poster_id' => $user->data['user_id'],
+ 'physical_filename' => $attach_row['physical_filename'],
+ 'real_filename' => $attach_row['real_filename'],
+ 'comment' => $attach_row['comment'],
+ 'extension' => $attach_row['extension'],
+ 'mimetype' => $attach_row['mimetype'],
+ 'filesize' => $attach_row['filesize'],
+ 'filetime' => $attach_row['filetime'],
+ 'thumbnail' => $attach_row['thumbnail']
+ );
+
+ $sql = 'INSERT INTO ' . ATTACHMENTS_TABLE . ' ' .
+ $db->sql_build_array('INSERT', $attach_sql);
+ $db->sql_query($sql);
+
+ $space_taken += $attach_row['filesize'];
+ $files_added++;
+ }
+ }
+
+ if (sizeof($data['attachment_data']))
+ {
+ $sql = 'UPDATE ' . PRIVMSGS_TABLE . '
+ SET message_attachment = 1
+ WHERE msg_id = ' . $data['msg_id'];
+ $db->sql_query($sql);
+ }
+
+ if ($space_taken && $files_added)
+ {
+ set_config('upload_dir_size', $config['upload_dir_size'] + $space_taken, true);
+ set_config('num_files', $config['num_files'] + $files_added, true);
+ }
+ }
+
+ $db->sql_transaction('commit');
+
+ // Delete draft if post was loaded...
+ $draft_id = request_var('draft_loaded', 0);
+ if ($draft_id)
+ {
+ $sql = 'DELETE FROM ' . DRAFTS_TABLE . "
+ WHERE draft_id = $draft_id
+ AND user_id = " . $user->data['user_id'];
+ $db->sql_query($sql);
+ }
+
+ // Send Notifications
+ if ($mode != 'edit')
+ {
+ pm_notification($mode, stripslashes($user->data['username']), $recipients, stripslashes($subject), stripslashes($data['message']));
+ }
+
+ return $data['msg_id'];
+}
+
+// PM Notification
+function pm_notification($mode, $author, $recipients, $subject, $message)
+{
+ global $db, $user, $config, $phpbb_root_path, $phpEx, $auth;
+
+ $subject = censor_text($subject);
+
+ // Get banned User ID's
+ $sql = 'SELECT ban_userid
+ FROM ' . BANLIST_TABLE;
+ $result = $db->sql_query($sql);
+
+ unset($recipients[ANONYMOUS], $recipients[$user->data['user_id']]);
+
+ while ($row = $db->sql_fetchrow($result))
+ {
+ if (isset($row['ban_userid']))
+ {
+ unset($recipients[$row['ban_userid']]);
+ }
+ }
+ $db->sql_freeresult($result);
+
+ if (!sizeof($recipients))
+ {
+ return;
+ }
+
+ $recipient_list = implode(', ', array_keys($recipients));
+
+ $sql = 'SELECT user_id, username, user_email, user_lang, user_notify_type, user_jabber
+ FROM ' . USERS_TABLE . "
+ WHERE user_id IN ($recipient_list)";
+ $result = $db->sql_query($sql);
+
+ $msg_list_ary = array();
+ while ($row = $db->sql_fetchrow($result))
+ {
+ if (trim($row['user_email']))
+ {
+ $msg_list_ary[] = array(
+ 'method' => $row['method'],
+ 'email' => $row['user_email'],
+ 'jabber' => $row['user_jabber'],
+ 'name' => $row['username'],
+ 'lang' => $row['user_lang']
+ );
+ }
+ }
+ $db->sql_freeresult($result);
+
+ if (!sizeof($msg_list_ary))
+ {
+ return;
+ }
+
+ include_once($phpbb_root_path . 'includes/functions_messenger.'.$phpEx);
+ $messenger = new messenger();
+
+ $email_sig = str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']);
+
+ foreach ($msg_list_ary as $pos => $addr)
+ {
+ $messenger->template('privmsg_notify', $addr['lang']);
+
+ $messenger->replyto($config['board_email']);
+ $messenger->to($addr['email'], $addr['name']);
+ $messenger->im($addr['jabber'], $addr['name']);
+
+ $messenger->assign_vars(array(
+ 'EMAIL_SIG' => $email_sig,
+ 'SITENAME' => $config['sitename'],
+ 'SUBJECT' => $subject,
+ 'AUTHOR_NAME' => $author,
+
+ 'U_INBOX' => generate_board_url() . "/ucp.$phpEx?i=pm&mode=unread")
+ );
+
+ $messenger->send($addr['method']);
+ $messenger->reset();
+ }
+ unset($msg_list_ary);
+
+ if ($messenger->queue)
+ {
+ $messenger->queue->save();
+ }
+
+ unset($messenger);
+}
+
+
?> \ No newline at end of file
diff --git a/phpBB/includes/functions_profile_fields.php b/phpBB/includes/functions_profile_fields.php
index 913e19b365..41b76f0bba 100644
--- a/phpBB/includes/functions_profile_fields.php
+++ b/phpBB/includes/functions_profile_fields.php
@@ -323,7 +323,7 @@ class custom_profile
$profile_row['field_name'] = (isset($profile_row['var_name'])) ? $profile_row['var_name'] : 'pf_' . $profile_row['field_ident'];
- $value = (isset($_REQUEST[$profile_row['field_name']])) ? request_var($profile_row['field_name'], 0) : ((!isset($user->profile_fields[$profile_row['field_ident']]) || $preview) ? $default_value : $user->profile_fields[$profile_row['field_ident']]);
+ $value = (isset($_REQUEST[$profile_row['field_name']])) ? request_var($profile_row['field_name'], $default_value) : ((!isset($user->profile_fields[$profile_row['field_ident']]) || $preview) ? $default_value : $user->profile_fields[$profile_row['field_ident']]);
switch ($field_validation)
{
diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php
index c058cd2b9d..92cd42d521 100644
--- a/phpBB/includes/functions_user.php
+++ b/phpBB/includes/functions_user.php
@@ -1038,10 +1038,15 @@ function avatar_upload($data, &$error)
function avatar_gallery($category, &$error)
{
- global $config;
+ global $config, $phpbb_root_path, $user;
$path = $phpbb_root_path . $config['avatar_gallery_path'];
+ if (!file_exists($path) || !is_dir($path))
+ {
+ return array($user->lang['NONE'] => array());
+ }
+
// To be replaced with SQL ... before M3 completion
$dp = @opendir($path);
@@ -1073,6 +1078,11 @@ function avatar_gallery($category, &$error)
}
closedir($dp);
+ if (!sizeof($data))
+ {
+ return array($user->lang['NONE'] => array());
+ }
+
@ksort($data);
return $data;
diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php
index 0894d94614..1229055b9d 100644
--- a/phpBB/includes/message_parser.php
+++ b/phpBB/includes/message_parser.php
@@ -18,6 +18,11 @@
- need size limit checks on img/flash tags ... probably warrants some discussion
*/
+if (!defined('IN_PHPBB'))
+{
+ exit;
+}
+
// case-insensitive strpos() - needed for some functions
if (!function_exists('stripos'))
{
@@ -32,183 +37,22 @@ if (!function_exists('stripos'))
}
}
-// Main message parser for posting, pm, etc. takes raw message
-// and parses it for attachments, html, bbcode and smilies
-class parse_message
+if (!class_exists('bbcode'))
{
- var $message = '';
- var $warn_msg = array();
-
- var $bbcodes = array();
- var $bbcode_uid = '';
- var $bbcode_bitfield = 0;
-
- var $attachment_data = array();
- var $filename_data = array();
-
- var $smilies = '';
-
- // Init - give message here or manually
- function parse_message($message = '')
- {
- // Init BBCode UID
- $this->bbcode_uid = substr(md5(time()), 0, BBCODE_UID_LEN);
-
- if ($message)
- {
- $this->message = $message;
- }
- }
-
- // Parse Message : public
- function parse($allow_html, $allow_bbcode, $allow_magic_url, $allow_smilies, $allow_img_bbcode = true, $allow_flash_bbcode = true, $allow_quote_bbcode = true)
- {
- global $config, $db, $user;
-
- // Do some general 'cleanup' first before processing message,
- // e.g. remove excessive newlines(?), smilies(?)
- // Transform \r\n and \r into \n
- $match = array('#\r\n?#', '#sid=[a-z0-9]*?&amp;?#', "#([\n][\s]+){3,}#");
- $replace = array("\n", '', "\n\n");
- $this->message = preg_replace($match, $replace, trim($this->message));
-
- // Message length check
- if (!strlen($this->message) || ($config['max_post_chars'] && strlen($this->message) > $config['max_post_chars']))
- {
- $this->warn_msg[] = (!strlen($this->message)) ? $user->lang['TOO_FEW_CHARS'] : $user->lang['TOO_MANY_CHARS'];
- return $this->warn_msg;
- }
-
- // Parse HTML
- if ($allow_html && $config['allow_html_tags'])
- {
- $this->html($config['allow_html_tags']);
- }
-
- // Parse BBCode
- if ($allow_bbcode && strpos($this->message, '[') !== false)
- {
- $this->bbcode_init();
- $disallow = array('img', 'flash', 'quote');
- foreach ($disallow as $bool)
- {
- if (!${'allow_' . $bool . '_bbcode'})
- {
- $this->bbcodes[$bool]['disabled'] = true;
- }
- }
- $this->bbcode();
- }
-
- // Parse Emoticons
- if ($allow_smilies)
- {
- $this->emoticons($config['max_post_smilies']);
- }
-
- // Parse URL's
- if ($allow_magic_url)
- {
- $this->magic_url((($config['cookie_secure']) ? 'https://' : 'http://'), $config['server_name'], $config['server_port'], $config['script_path']);
- }
-
- return implode('<br />', $this->warn_msg);
- }
-
- // Parse HTML
- function html($allowed_tags)
- {
- // If $allow_html is true then "allowed_tags" are converted back from entity
- // form, others remain
- $allowed_tags = split(',', $allowed_tags);
-
- if (sizeof($allowed_tags))
- {
- $this->message = preg_replace('#&lt;(\/?)(' . str_replace('*', '.*?', implode('|', $allowed_tags)) . ')&gt;#is', '<$1$2>', $this->message);
- }
- }
-
- // Replace magic urls of form http://xxx.xxx., www.xxx. and xxx@xxx.xxx.
- // Cuts down displayed size of link if over 50 chars, turns absolute links
- // into relative versions when the server/script path matches the link
- function magic_url($server_protocol, $server_name, $server_port, $script_path)
- {
- $server_port = ($server_port <> 80 ) ? ':' . trim($server_port) . '/' : '/';
-
- $match = $replace = array();
-
- // Be sure to not let the matches cross over. ;)
-
- // relative urls for this board
- $match[] = '#(^|[\n ]|\()(' . preg_quote($server_protocol . trim($server_name) . $server_port . preg_replace('/^\/?(.*?)(\/)?$/', '$1', trim($script_path)), '#') . ')/(.*?([^ \t\n\r<"\'\)]*)?)#i';
- $replace[] = '$1<!-- l --><a href="$2/$3" target="_blank">$3</a><!-- l -->';
-
- // matches a xxxx://aaaaa.bbb.cccc. ...
- $match[] = '#(^|[\n ]|\()([\w]+?://.*?([^ \t\n\r<"\'\)]*)?)#ie';
- $replace[] = "'\$1<!-- m --><a href=\"\$2\" target=\"_blank\">' . ((strlen('\$2') > 55) ? substr('\$2', 0, 39) . ' ... ' . substr('\$2', -10) : '\$2') . '</a><!-- m -->'";
-
- // matches a "www.xxxx.yyyy[/zzzz]" kinda lazy URL thing
- $match[] = '#(^|[\n ]|\()(www\.[\w\-]+\.[\w\-.\~]+(?:/[^ \t\n\r<"\'\)]*)?)#ie';
- $replace[] = "'\$1<!-- w --><a href=\"http://\$2\" target=\"_blank\">' . ((strlen('\$2') > 55) ? substr(str_replace(' ', '%20', '\$2'), 0, 39) . ' ... ' . substr('\$2', -10) : '\$2') . '</a><!-- w -->'";
-
- // matches an email@domain type address at the start of a line, or after a space.
- $match[] = '#(^|[\n ]|\()([a-z0-9&\-_.]+?@[\w\-]+\.([\w\-\.]+\.)?[\w]+)#ie';
- $replace[] = "'\$1<!-- e --><a href=\"mailto:\$2\">' . ((strlen('\$2') > 55) ? substr('\$2', 0, 39) . ' ... ' . substr('\$2', -10) : '\$2') . '</a><!-- e -->'";
-
- /* IMPORTANT NOTE (Developer inability to do advanced regular expressions) - Acyd Burn:
- Transforming &lt; (<) to <&amp;lt; in order to bypass the inability of preg_replace
- supporting multi-character sequences (POSIX - [..]). Since all message text is specialchared by
- default a match against < will always fail, since it is a &lt; sequence within the text.
- Replacing with <&amp;lt; and switching back thereafter produces no problems, because < will never show up with &amp;lt; in
- the same text (due to this specialcharing). The < is put in front of &amp;lt; to let the url break gracefully.
- I hope someone can lend me a hand here, telling me how to achive the wanted result without switching to ereg_replace.
- */
- $this->message = preg_replace($match, $replace, str_replace('&lt;', '<&amp;lt;', $this->message));
- $this->message = str_replace('<&amp;lt;', '&lt;', $this->message);
- }
-
- // Parse Emoticons
- function emoticons($max_smilies = 0)
- {
- global $db, $user, $phpbb_root_path;
-
- // NOTE: obtain_* function? chaching the table contents?
- // For now setting the ttl to 10 minutes
- $sql = 'SELECT *
- FROM ' . SMILIES_TABLE;
- $result = $db->sql_query($sql, 600);
-
- if ($row = $db->sql_fetchrow($result))
- {
- $match = $replace = array();
-
- do
- {
- // (assertion)
- $match[] = '#(?<=^|[\n ]|\.)' . preg_quote($row['code'], '#') . '#';
- $replace[] = '<!-- s' . $row['code'] . ' --><img src="{SMILE_PATH}/' . $row['smile_url'] . '" border="0" alt="' . $row['emoticon'] . '" title="' . $row['emoticon'] . '" /><!-- s' . $row['code'] . ' -->';
- }
- while ($row = $db->sql_fetchrow($result));
-
- if ($max_smilies)
- {
- $num_matches = preg_match_all('#' . str_replace('#', '', implode('|', $match)) . '#', $this->message, $matches);
- unset($matches);
+ include($phpbb_root_path . 'includes/bbcode.' . $phpEx);
+}
- if ($num_matches !== false && $num_matches > $max_smilies)
- {
- $this->warn_msg[] = $user->lang['TOO_MANY_SMILIES'];
- return;
- }
- }
+// BBCODE_FIRSTPASS
+//
- $this->message = trim(preg_replace($match, $replace, $this->message));
- }
- $db->sql_freeresult($result);
- }
+// BBCODE first pass class (functions for parsing messages for db storage)
+class bbcode_firstpass extends bbcode
+{
+ var $message = '';
+ var $warn_msg = array();
// Parse BBCode
- function bbcode()
+ function parse_bbcode()
{
if (!$this->bbcodes)
{
@@ -288,6 +132,7 @@ class parse_message
$rowset[] = $row;
}
}
+
foreach ($rowset as $row)
{
$this->bbcodes[$row['bbcode_tag']] = array(
@@ -336,7 +181,7 @@ class parse_message
}
$code = substr($code, 0, -7);
- $code = preg_replace('#^[\r\n]*(.*?)[\n\r\s\t]*$#s', '$1', $code);
+// $code = preg_replace('#^[\r\n]*(.*?)[\n\r\s\t]*$#s', '$1', $code);
switch (strtolower($stx))
{
@@ -392,7 +237,7 @@ class parse_message
$str_from = array('<', '>', '[', ']', '.');
$str_to = array('&lt;', '&gt;', '&#91;', '&#93;', '&#46;');
- $out .= '[code:' . $this->bbcode_uid . ']' . trim(str_replace($str_from, $str_to, $code)) . '[/code:' . $this->bbcode_uid . ']';
+ $out .= '[code:' . $this->bbcode_uid . ']' . str_replace($str_from, $str_to, $code) . '[/code:' . $this->bbcode_uid . ']';
}
if (preg_match('#(.*?)\[code(?:=[a-z]+)?\](.+)#is', $in, $m))
@@ -576,7 +421,7 @@ class parse_message
array_push($close_tags, '/quote:' . $this->bbcode_uid);
- if ($m[1])
+ if (isset($m[1]) && $m[1])
{
$username = preg_replace('#\[(?!b|i|u|color|url|email|/b|/i|/u|/color|/url|/email)#iU', '&#91;$1', $m[1]);
$end_tags = array();
@@ -709,6 +554,271 @@ class parse_message
return '[url' . (($var1) ? '=' . stripslashes($var1) : '') . ']' . stripslashes($var2) . '[/url]';
}
+}
+
+// PARSE_MESSAGE EXTENDS BBCODE
+//
+
+// Main message parser for posting, pm, etc. takes raw message
+// and parses it for attachments, html, bbcode and smilies
+class parse_message extends bbcode_firstpass
+{
+ var $attachment_data = array();
+ var $filename_data = array();
+
+ // Helps ironing out user error
+ var $message_status = '';
+
+ var $allow_img_bbcode = true;
+ var $allow_flash_bbcode = true;
+ var $allow_quote_bbcode = true;
+
+ // Init - give message here or manually
+ function parse_message($message = '')
+ {
+ // Init BBCode UID
+ $this->bbcode_uid = substr(md5(time()), 0, BBCODE_UID_LEN);
+
+ if ($message)
+ {
+ $this->message = $message;
+ }
+ }
+
+ // Parse Message : public
+ function parse($allow_html, $allow_bbcode, $allow_magic_url, $allow_smilies, $allow_img_bbcode = true, $allow_flash_bbcode = true, $allow_quote_bbcode = true, $update_this_message = true)
+ {
+ global $config, $db, $user;
+
+ $this->allow_img_bbcode = $allow_img_bbcode;
+ $this->allow_flash_bbcode = $allow_flash_bbcode;
+ $this->allow_quote_bbcode = $allow_quote_bbcode;
+
+ // If false, then the parsed message get returned but internal message not processed.
+ if (!$update_this_message)
+ {
+ $tmp_message = $this->message;
+ $return_message = &$this->message;
+ }
+
+ if ($this->message_status == 'display')
+ {
+ $this->decode_message();
+ }
+
+ // Do some general 'cleanup' first before processing message,
+ // e.g. remove excessive newlines(?), smilies(?)
+ // Transform \r\n and \r into \n
+ $match = array('#\r\n?#', '#sid=[a-z0-9]*?&amp;?#', "#([\n][\s]+){3,}#");
+ $replace = array("\n", '', "\n\n");
+ $this->message = preg_replace($match, $replace, trim($this->message));
+
+ // Message length check
+ if (!strlen($this->message) || ($config['max_post_chars'] && strlen($this->message) > $config['max_post_chars']))
+ {
+ $this->warn_msg[] = (!strlen($this->message)) ? $user->lang['TOO_FEW_CHARS'] : $user->lang['TOO_MANY_CHARS'];
+ return $this->warn_msg;
+ }
+
+ // Parse HTML
+ if ($allow_html && $config['allow_html_tags'])
+ {
+ $this->html($config['allow_html_tags']);
+ }
+
+ // Parse BBCode
+ if ($allow_bbcode && strpos($this->message, '[') !== false)
+ {
+ $this->bbcode_init();
+ $disallow = array('img', 'flash', 'quote');
+ foreach ($disallow as $bool)
+ {
+ if (!${'allow_' . $bool . '_bbcode'})
+ {
+ $this->bbcodes[$bool]['disabled'] = true;
+ }
+ }
+ $this->parse_bbcode();
+ }
+
+ // Parse Emoticons
+ if ($allow_smilies)
+ {
+ $this->emoticons($config['max_post_smilies']);
+ }
+
+ // Parse URL's
+ if ($allow_magic_url)
+ {
+ $this->magic_url((($config['cookie_secure']) ? 'https://' : 'http://'), $config['server_name'], $config['server_port'], $config['script_path']);
+ }
+
+ if (!$update_this_message)
+ {
+ unset($this->message);
+ $this->message = $tmp_message;
+ return $return_message;
+ }
+
+ $this->message_status = 'parsed';
+ return;
+ //return implode('<br />', $this->warn_msg);
+ }
+
+ // Formatting text for display
+ function format_display($allow_html, $allow_bbcode, $allow_magic_url, $allow_smilies, $update_this_message = true)
+ {
+ // If false, then the parsed message get returned but internal message not processed.
+ if (!$update_this_message)
+ {
+ $tmp_message = $this->message;
+ $return_message = &$this->message;
+ }
+
+ if ($this->message_status == 'plain')
+ {
+ // Force updating message - of course.
+ $this->parse($allow_html, $allow_bbcode, $allow_magic_url, $allow_smilies, $this->allow_img_bbcode, $this->allow_flash_bbcode, $this->allow_quote_bbcode, true);
+ }
+
+ // Parse BBcode
+ if ($allow_bbcode)
+ {
+ $this->bbcode_cache_init();
+
+ // We are giving those parameters to be able to use the bbcode class on its own
+ $this->bbcode_second_pass($this->message, $this->bbcode_uid);
+ }
+
+ $this->message = smilie_text($this->message, !$allow_smilies);
+
+ // Replace naughty words such as farty pants
+ $this->message = str_replace("\n", '<br />', censor_text($this->message));
+
+ if (!$update_this_message)
+ {
+ unset($this->message);
+ $this->message = $tmp_message;
+ return $return_message;
+ }
+
+ $this->message_status = 'display';
+ return;
+ }
+
+ // Decode message to be placed back into form box
+ function decode_message($custom_bbcode_uid = '', $update_this_message = true)
+ {
+ // If false, then the parsed message get returned but internal message not processed.
+ if (!$update_this_message)
+ {
+ $tmp_message = $this->message;
+ $return_message = &$this->message;
+ }
+
+ ($custom_bbcode_uid) ? decode_message($this->message, $custom_bbcode_uid) : decode_message($this->message, $this->bbcode_uid);
+
+ if (!$update_this_message)
+ {
+ unset($this->message);
+ $this->message = $tmp_message;
+ return $return_message;
+ }
+
+ $this->message_status = 'plain';
+ }
+
+ // Parse HTML
+ function html($allowed_tags)
+ {
+ // If $allow_html is true then "allowed_tags" are converted back from entity
+ // form, others remain
+ $allowed_tags = split(',', $allowed_tags);
+
+ if (sizeof($allowed_tags))
+ {
+ $this->message = preg_replace('#&lt;(\/?)(' . str_replace('*', '.*?', implode('|', $allowed_tags)) . ')&gt;#is', '<$1$2>', $this->message);
+ }
+ }
+
+ // Replace magic urls of form http://xxx.xxx., www.xxx. and xxx@xxx.xxx.
+ // Cuts down displayed size of link if over 50 chars, turns absolute links
+ // into relative versions when the server/script path matches the link
+ function magic_url($server_protocol, $server_name, $server_port, $script_path)
+ {
+ $server_port = ($server_port <> 80 ) ? ':' . trim($server_port) . '/' : '/';
+
+ $match = $replace = array();
+
+ // Be sure to not let the matches cross over. ;)
+
+ // relative urls for this board
+ $match[] = '#(^|[\n ]|\()(' . preg_quote($server_protocol . trim($server_name) . $server_port . preg_replace('/^\/?(.*?)(\/)?$/', '$1', trim($script_path)), '#') . ')/(.*?([^ \t\n\r<"\'\)]*)?)#i';
+ $replace[] = '$1<!-- l --><a href="$2/$3" target="_blank">$3</a><!-- l -->';
+
+ // matches a xxxx://aaaaa.bbb.cccc. ...
+ $match[] = '#(^|[\n ]|\()([\w]+?://.*?([^ \t\n\r<"\'\)]*)?)#ie';
+ $replace[] = "'\$1<!-- m --><a href=\"\$2\" target=\"_blank\">' . ((strlen('\$2') > 55) ? substr('\$2', 0, 39) . ' ... ' . substr('\$2', -10) : '\$2') . '</a><!-- m -->'";
+
+ // matches a "www.xxxx.yyyy[/zzzz]" kinda lazy URL thing
+ $match[] = '#(^|[\n ]|\()(www\.[\w\-]+\.[\w\-.\~]+(?:/[^ \t\n\r<"\'\)]*)?)#ie';
+ $replace[] = "'\$1<!-- w --><a href=\"http://\$2\" target=\"_blank\">' . ((strlen('\$2') > 55) ? substr(str_replace(' ', '%20', '\$2'), 0, 39) . ' ... ' . substr('\$2', -10) : '\$2') . '</a><!-- w -->'";
+
+ // matches an email@domain type address at the start of a line, or after a space.
+ $match[] = '#(^|[\n ]|\()([a-z0-9&\-_.]+?@[\w\-]+\.([\w\-\.]+\.)?[\w]+)#ie';
+ $replace[] = "'\$1<!-- e --><a href=\"mailto:\$2\">' . ((strlen('\$2') > 55) ? substr('\$2', 0, 39) . ' ... ' . substr('\$2', -10) : '\$2') . '</a><!-- e -->'";
+
+ /* IMPORTANT NOTE (Developer inability to do advanced regular expressions) - Acyd Burn:
+ Transforming &lt; (<) to <&amp;lt; in order to bypass the inability of preg_replace
+ supporting multi-character sequences (POSIX - [..]). Since all message text is specialchared by
+ default a match against < will always fail, since it is a &lt; sequence within the text.
+ Replacing with <&amp;lt; and switching back thereafter produces no problems, because < will never show up with &amp;lt; in
+ the same text (due to this specialcharing). The < is put in front of &amp;lt; to let the url break gracefully.
+ I hope someone can lend me a hand here, telling me how to achive the wanted result without switching to ereg_replace.
+ */
+ $this->message = preg_replace($match, $replace, str_replace('&lt;', '<&amp;lt;', $this->message));
+ $this->message = str_replace('<&amp;lt;', '&lt;', $this->message);
+ }
+
+ // Parse Emoticons
+ function emoticons($max_smilies = 0)
+ {
+ global $db, $user, $phpbb_root_path;
+
+ // NOTE: obtain_* function? chaching the table contents?
+ // For now setting the ttl to 10 minutes
+ $sql = 'SELECT *
+ FROM ' . SMILIES_TABLE;
+ $result = $db->sql_query($sql, 600);
+
+ if ($row = $db->sql_fetchrow($result))
+ {
+ $match = $replace = array();
+
+ do
+ {
+ // (assertion)
+ $match[] = '#(?<=^|[\n ]|\.)' . preg_quote($row['code'], '#') . '#';
+ $replace[] = '<!-- s' . $row['code'] . ' --><img src="{SMILE_PATH}/' . $row['smile_url'] . '" border="0" alt="' . $row['emoticon'] . '" title="' . $row['emoticon'] . '" /><!-- s' . $row['code'] . ' -->';
+ }
+ while ($row = $db->sql_fetchrow($result));
+
+ if ($max_smilies)
+ {
+ $num_matches = preg_match_all('#' . str_replace('#', '', implode('|', $match)) . '#', $this->message, $matches);
+ unset($matches);
+
+ if ($num_matches !== false && $num_matches > $max_smilies)
+ {
+ $this->warn_msg[] = $user->lang['TOO_MANY_SMILIES'];
+ return;
+ }
+ }
+
+ $this->message = trim(preg_replace($match, $replace, $this->message));
+ }
+ $db->sql_freeresult($result);
+ }
// Parse Attachments
function parse_attachments($mode, $post_id, $submit, $preview, $refresh, $is_message = false)
@@ -889,6 +999,9 @@ class parse_message
{
global $auth, $forum_id, $user, $config;
+ // Need a second look at
+ return;
+ /*
// Process poll options
if ($poll_data['poll_option_text'] && (($auth->acl_get('f_poll', $forum_id) && !$poll_data['poll_last_vote']) || $auth->acl_get('m_edit', $forum_id)))
{
@@ -902,6 +1015,7 @@ class parse_message
$poll_data['poll_option_text'] = $this->message;
$this->message = $message;
+ unset($message);
$poll['poll_options'] = explode("\n", trim($poll_data['poll_option_text']));
$poll['poll_options_size'] = sizeof($poll['poll_options']);
@@ -934,6 +1048,7 @@ class parse_message
$poll['poll_start'] = $poll_data['poll_start'];
$poll['poll_max_options'] = ($poll_data['poll_max_options'] < 1) ? 1 : (($poll_data['poll_max_options'] > $config['max_poll_options']) ? $config['max_poll_options'] : $poll_data['poll_max_options']);
+ */
}
}
diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php
index aecb6dcb79..5aa9d52b77 100644
--- a/phpBB/includes/session.php
+++ b/phpBB/includes/session.php
@@ -476,7 +476,7 @@ class user extends session
var $lang_path;
var $img_lang;
- var $keyoptions = array('viewimg' => 0, 'viewflash' => 1, 'viewsmilies' => 2, 'viewsigs' => 3, 'viewavatars' => 4, 'viewcensors' => 5, 'attachsig' => 6, 'html' => 7, 'bbcode' => 8, 'smile' => 9, 'popuppm' => 10);
+ var $keyoptions = array('viewimg' => 0, 'viewflash' => 1, 'viewsmilies' => 2, 'viewsigs' => 3, 'viewavatars' => 4, 'viewcensors' => 5, 'attachsig' => 6, 'html' => 7, 'bbcode' => 8, 'smile' => 9, 'popuppm' => 10, 'report_pm_notify' => 11);
var $keyvalues = array();
function setup($lang_set = false, $style = false)
@@ -571,34 +571,11 @@ class user extends session
// Set theme info
$theme_info = array();
- $default_theme_info = array(
- 'pagination_sep' => ', ',
- 'pagination_goto_page' => true,
- 'avatar_img_class' => ''
- );
-
- foreach ($this->theme as $style_priority => $row)
+ // Add to template database
+ foreach (array_keys($this->theme) as $style_priority)
{
- if (file_exists($phpbb_root_path . 'styles/' . $row['theme_path'] . '/theme/theme_info.' . $phpEx))
- {
- $theme_info = array();
- include($phpbb_root_path . 'styles/' . $row['theme_path'] . '/theme/theme_info.' . $phpEx);
-
- if (sizeof($theme_info))
- {
- $this->theme[$style_priority] = array_merge($this->theme[$style_priority], $theme_info);
- }
- }
-
- foreach ($default_theme_info as $key => $value)
- {
- if (!isset($this->theme[$style_priority][$key]))
- {
- $this->theme[$style_priority][$key] = $value;
- }
- }
+ $this->theme[$style_priority]['pagination_sep'] = ', ';
}
- unset($theme_info, $default_theme_info);
$template->set_template();
@@ -776,7 +753,7 @@ class user extends session
if (empty($imgs[$img . $suffix]) || $width)
{
- if (!$this->theme['primary'][$img])
+ if (!isset($this->theme['primary'][$img]) || !$this->theme['primary'][$img])
{
// Do not fill the image to let designers decide what to do if the image is empty
$imgs[$img . $suffix] = '';
diff --git a/phpBB/includes/ucp/ucp_pm.php b/phpBB/includes/ucp/ucp_pm.php
index d1b2db35ad..c7d9fc11d3 100644
--- a/phpBB/includes/ucp/ucp_pm.php
+++ b/phpBB/includes/ucp/ucp_pm.php
@@ -347,7 +347,7 @@ class ucp_pm extends module
$template->assign_vars(array(
'L_TITLE' => $user->lang['UCP_PM_' . strtoupper($mode)],
- 'S_UCP_ACTION' => "{$phpbb_root_path}ucp.$phpEx$SID&amp;i=$id&amp;mode=$mode&amp;action=$action")
+ 'S_UCP_ACTION' => "{$phpbb_root_path}ucp.$phpEx$SID&amp;i=$id&amp;mode=$mode" . ((isset($action)) ? "&amp;action=$action" : ''))
);
$this->display($user->lang['UCP_PM'], $tpl_file);
diff --git a/phpBB/includes/ucp/ucp_pm_compose.php b/phpBB/includes/ucp/ucp_pm_compose.php
index eb9de78055..9727f5b63c 100644
--- a/phpBB/includes/ucp/ucp_pm_compose.php
+++ b/phpBB/includes/ucp/ucp_pm_compose.php
@@ -196,6 +196,8 @@ function compose_pm($id, $mode, $action)
// Rebuild TO and BCC Header
$address_list = rebuild_header(array('to' => $to_address, 'bcc' => $bcc_address));
}
+
+ $check_value = (($enable_html+1) << 16) + (($enable_bbcode+1) << 8) + (($enable_smilies+1) << 4) + (($enable_urls+1) << 2) + (($enable_sig+1) << 1);
}
else
{
@@ -211,6 +213,8 @@ function compose_pm($id, $mode, $action)
$address_list['g'][$to_group_id] = 'to';
}
unset($to_user_id, $to_group_id);
+
+ $check_value = 0;
}
if ($action == 'edit' && !$refresh && !$preview && !$submit)
@@ -221,11 +225,16 @@ function compose_pm($id, $mode, $action)
}
}
+ if (!isset($icon_id))
+ {
+ $icon_id = 0;
+ }
+
$message_parser = new parse_message();
$message_subject = (isset($message_subject)) ? $message_subject : '';
- $message_text = ($action == 'reply') ? '' : ((isset($message_text)) ? $message_text : '');
- $icon_id = 0;
+ $message_parser->message = ($action == 'reply') ? '' : ((isset($message_text)) ? $message_text : '');
+ unset($message_text);
$s_action = "{$phpbb_root_path}ucp.$phpEx?sid={$user->session_id}&amp;i=$id&amp;mode=$mode&amp;action=$action";
$s_action .= ($msg_id) ? "&amp;p=$msg_id" : '';
@@ -406,10 +415,15 @@ function compose_pm($id, $mode, $action)
$enable_urls = (isset($_POST['disable_magic_url'])) ? 0 : 1;
$enable_sig = (!$config['allow_sig']) ? false : ((isset($_POST['attach_sig'])) ? true : false);
- // Faster than crc32
- $check_value = (($preview || $refresh) && isset($_POST['status_switch'])) ? (int) $_POST['status_switch'] : (($enable_html+1) << 16) + (($enable_bbcode+1) << 8) + (($enable_smilies+1) << 4) + (($enable_urls+1) << 2) + (($enable_sig+1) << 1);
- $status_switch = (isset($_POST['status_switch']) && (int) $_POST['status_switch'] != $check_value);
-
+ if ($submit)
+ {
+ $status_switch = (($enable_html+1) << 16) + (($enable_bbcode+1) << 8) + (($enable_smilies+1) << 4) + (($enable_urls+1) << 2) + (($enable_sig+1) << 1);
+ $status_switch = ($status_switch != $check_value);
+ }
+ else
+ {
+ $status_switch = 1;
+ }
// Parse Attachments - before checksum is calculated
$message_parser->parse_attachments($action, $msg_id, $submit, $preview, $refresh, true);
@@ -418,11 +432,16 @@ function compose_pm($id, $mode, $action)
$message_md5 = md5($message_parser->message);
// Check checksum ... don't re-parse message if the same
- if ($action != 'edit' || $message_md5 != $post_checksum || $status_switch || $preview)
+ $update_message = ($action != 'edit' || $message_md5 != $post_checksum || $status_switch || $preview) ? true : false;
+
+ if ($update_message)
{
- // Parse message
$message_parser->parse($enable_html, $enable_bbcode, $enable_urls, $enable_smilies, $img_status, $flash_status, $quote_status);
}
+ else
+ {
+ $message_parser->bbcode_bitfield = $bbcode_bitfield;
+ }
if ($action != 'edit' && !$preview && !$refresh && $config['flood_interval'] && !$auth->acl_get('u_ignoreflood'))
{
@@ -475,13 +494,24 @@ function compose_pm($id, $mode, $action)
'post_edit_user' => ($action == 'edit') ? $user->data['user_id'] : (int) $post_edit_user,
'author_ip' => (int) $author_ip,
'bbcode_bitfield' => (int) $message_parser->bbcode_bitfield,
+ 'bbcode_uid' => $message_parser->bbcode_uid,
+ 'message' => $message_parser->message,
+ 'attachment_data' => $message_parser->attachment_data,
+ 'filename_data' => $message_parser->filename_data,
'address_list' => $address_list
);
+ unset($message_parser);
- submit_pm($action, $message_parser->message, $subject, $message_parser->bbcode_uid, $message_parser->attachment_data, $message_parser->filename_data, $pm_data);
+ $msg_id = submit_pm($action, $subject, $username, $pm_data, $update_message);
+
+ $return_message_url = "{$phpbb_root_path}ucp.$phpEx$SID&amp;i=pm&amp;mode=view_messages&amp;action=view_message&amp;p=" . $data['msg_id'];
+ $return_folder_url = "{$phpbb_root_path}ucp.$phpEx$SID&amp;i=pm&amp;folder=outbox";
+ meta_refresh(3, $return_message_url);
+
+ $message = $user->lang['MESSAGE_STORED'] . '<br /><br />' . sprintf($user->lang['VIEW_MESSAGE'], '<a href="' . $return_message_url . '">', '</a>') . '<br /><br />' . sprintf($user->lang['RETURN_FOLDER'], '<a href="' . $return_folder_url . '">', '</a>');
+ trigger_error($message);
}
- $message_text = $message_parser->message;
$message_subject = stripslashes($subject);
}
@@ -490,17 +520,27 @@ function compose_pm($id, $mode, $action)
{
$post_time = ($action == 'edit') ? $post_time : $current_time;
- $preview_subject = censor_text($subject);
+ $preview_message = $message_parser->format_display($enable_html, $enable_bbcode, $enable_urls, $enable_smilies, false);
$preview_signature = $user->data['user_sig'];
$preview_signature_uid = $user->data['user_sig_bbcode_uid'];
$preview_signature_bitfield = $user->data['user_sig_bbcode_bitfield'];
- include($phpbb_root_path . 'includes/bbcode.' . $phpEx);
- $bbcode = new bbcode($message_parser->bbcode_bitfield | $preview_signature_bitfield);
+ // Signature
+ if ($enable_sig && $config['allow_sig'] && $preview_signature)
+ {
+ $parse_sig = new parse_message($preview_signature);
+ $parse_sig->bbcode_uid = $preview_signature_uid;
+ $parse_sig->bbcode_bitfield = $preview_signature_bitfield;
- $preview_message = $message_parser->message;
- format_display($preview_message, $preview_signature, $message_parser->bbcode_uid, $preview_signature_uid, $enable_html, $enable_bbcode, $enable_urls, $enable_smilies, $enable_sig, $bbcode);
+ $parse_sig->format_display($enable_html, $enable_bbcode, $enable_urls, $enable_smilies);
+ $preview_signature = $parse_sig->message;
+ unset($parse_sig);
+ }
+ else
+ {
+ $preview_signature = '';
+ }
// Attachment Preview
if (sizeof($message_parser->attachment_data))
@@ -511,23 +551,30 @@ function compose_pm($id, $mode, $action)
$template->assign_var('S_HAS_ATTACHMENTS', true);
display_attachments(0, 'attachment', $message_parser->attachment_data, $update_count, true);
}
- }
+ $preview_subject = censor_text($subject);
+
+ if (!sizeof($error))
+ {
+ $template->assign_vars(array(
+ 'PREVIEW_SUBJECT' => $preview_subject,
+ 'PREVIEW_MESSAGE' => $preview_message,
+ 'PREVIEW_SIGNATURE' => $preview_signature,
+
+ 'S_DISPLAY_PREVIEW' => true)
+ );
+ }
+ unset($message_text);
+ }
// Decode text for message display
$bbcode_uid = (($action == 'quote' || $action == 'forward')&& !$preview && !$refresh && !sizeof($error)) ? $bbcode_uid : $message_parser->bbcode_uid;
- decode_text($message_text, $bbcode_uid);
-
- if ($subject)
- {
- decode_text($subject, $bbcode_uid);
- }
-
+ $message_parser->decode_message($bbcode_uid);
if ($action == 'quote' && !$preview && !$refresh)
{
- $message_text = '[quote="' . $quote_username . '"]' . censor_text(trim($message_text)) . "[/quote]\n";
+ $message_parser->message = '[quote="' . $quote_username . '"]' . censor_text(trim($message_parser->message)) . "[/quote]\n";
}
if (($action == 'reply' || $action == 'quote') && !$preview && !$refresh)
@@ -537,12 +584,6 @@ function compose_pm($id, $mode, $action)
if ($action == 'forward' && !$preview && !$refresh)
{
- $user->lang['FWD_ORIGINAL_MESSAGE'] = '-------- Original Message --------';
- $user->lang['FWD_SUBJECT'] = 'Subject: %s';
- $user->lang['FWD_DATE'] = 'Date: %s';
- $user->lang['FWD_FROM'] = 'From: %s';
- $user->lang['FWD_TO'] = 'To: %s';
-
$fwd_to_field = write_pm_addresses(array('to' => $to_address), 0, true);
$forward_text = array();
@@ -552,10 +593,14 @@ function compose_pm($id, $mode, $action)
$forward_text[] = sprintf($user->lang['FWD_FROM'], $quote_username);
$forward_text[] = sprintf($user->lang['FWD_TO'], implode(', ', $fwd_to_field['to']));
- $message_text = implode("\n", $forward_text) . "\n\n[quote=\"[url=" . generate_board_url() . "/memberlist.$phpEx$SID&mode=viewprofile&u={$author_id}]{$quote_username}[/url]\"]\n" . censor_text(trim($message_text)) . "\n[/quote]";
+ $message_parser->message = implode("\n", $forward_text) . "\n\n[quote=\"[url=" . generate_board_url() . "/memberlist.$phpEx$SID&mode=viewprofile&u={$author_id}]{$quote_username}[/url]\"]\n" . censor_text(trim($message_parser->message)) . "\n[/quote]";
$message_subject = ((!preg_match('/^Fwd:/', $message_subject)) ? 'Fwd: ' : '') . censor_text($message_subject);
}
+ $attachment_data = $message_parser->attachment_data;
+ $filename_data = $message_parser->filename_data;
+ $message_text = $message_parser->message;
+ unset($message_parser);
// MAIN PM PAGE BEGINS HERE
@@ -570,7 +615,7 @@ function compose_pm($id, $mode, $action)
}
// Generate inline attachment select box
- posting_gen_inline_attachments($message_parser);
+ posting_gen_inline_attachments($attachment_data);
// Build address list for display
// array('u' => array($author_id => 'to'));
@@ -683,10 +728,7 @@ function compose_pm($id, $mode, $action)
'L_MESSAGE_BODY_EXPLAIN'=> (intval($config['max_post_chars'])) ? sprintf($user->lang['MESSAGE_BODY_EXPLAIN'], intval($config['max_post_chars'])) : '',
'SUBJECT' => (isset($message_subject)) ? $message_subject : '',
- 'MESSAGE' => trim($message_text),
- 'PREVIEW_SUBJECT' => ($preview && !sizeof($error)) ? $preview_subject : '',
- 'PREVIEW_MESSAGE' => ($preview && !sizeof($error)) ? $preview_message : '',
- 'PREVIEW_SIGNATURE' => ($preview && !sizeof($error)) ? $preview_signature : '',
+ 'MESSAGE' => $message_text,
'HTML_STATUS' => ($html_status) ? $user->lang['HTML_IS_ON'] : $user->lang['HTML_IS_OFF'],
'BBCODE_STATUS' => ($bbcode_status) ? sprintf($user->lang['BBCODE_IS_ON'], '<a href="' . "faq.$phpEx$SID&amp;mode=bbcode" . '" target="_phpbbcode">', '</a>') : sprintf($user->lang['BBCODE_IS_OFF'], '<a href="' . "faq.$phpEx$SID&amp;mode=bbcode" . '" target="_phpbbcode">', '</a>'),
'IMG_STATUS' => ($img_status) ? $user->lang['IMAGES_ARE_ON'] : $user->lang['IMAGES_ARE_OFF'],
@@ -695,7 +737,6 @@ function compose_pm($id, $mode, $action)
'MINI_POST_IMG' => $user->img('icon_post', $user->lang['POST']),
'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '',
- 'S_DISPLAY_PREVIEW' => ($preview && !sizeof($error)),
'S_EDIT_POST' => ($action == 'edit'),
'S_SHOW_PM_ICONS' => $s_pm_icons,
'S_HTML_ALLOWED' => $html_status,
@@ -719,276 +760,8 @@ function compose_pm($id, $mode, $action)
// Attachment entry
if ($auth->acl_get('u_pm_attach') && $config['allow_pm_attach'] && $form_enctype)
{
- posting_gen_attachment_entry($message_parser);
- }
-}
-
-// Submit PM
-function submit_pm($mode, $message, $subject, $bbcode_uid, $attach_data, $filename_data, $data)
-{
- global $db, $auth, $user, $config, $phpEx, $SID, $template;
-
- // We do not handle erasing posts here
- if ($mode == 'delete')
- {
- return;
- }
-
- $current_time = time();
-
- // Collect some basic informations about which tables and which rows to update/insert
- $sql_data = array();
- $root_level = 0;
-
- // Recipient Informations
- $recipients = $to = $bcc = array();
-
- if ($mode != 'edit')
- {
- // Build Recipient List
- foreach (array('u', 'g') as $ug_type)
- {
- if (sizeof($data['address_list'][$ug_type]))
- {
- foreach ($data['address_list'][$ug_type] as $id => $field)
- {
- $field = ($field == 'to') ? 'to' : 'bcc';
- if ($ug_type == 'u')
- {
- $recipients[$id] = $field;
- }
- ${$field}[] = $ug_type . '_' . (int) $id;
- }
- }
- }
-
- if (sizeof($data['address_list']['g']))
- {
- $sql = 'SELECT group_id, user_id
- FROM ' . USER_GROUP_TABLE . '
- WHERE group_id IN (' . implode(', ', array_keys($data['address_list']['g'])) . ')
- AND user_pending = 0';
- $result = $db->sql_query($sql);
-
- while ($row = $db->sql_fetchrow($result))
- {
- $field = ($data['address_list']['g'][$row['group_id']] == 'to') ? 'to' : 'bcc';
- $recipients[$row['user_id']] = $field;
- }
- $db->sql_freeresult($result);
- }
-
- if (!sizeof($recipients))
- {
- trigger_error('NO_RECIPIENT');
- }
- }
-
- $sql = '';
- switch ($mode)
- {
- case 'reply':
- case 'quote':
- $root_level = ($data['reply_from_root_level']) ? $data['reply_from_root_level'] : $data['reply_from_msg_id'];
-
- // Set message_replied switch for this user
- $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . '
- SET replied = 1
- WHERE user_id = ' . $user->data['user_id'] . '
- AND msg_id = ' . $data['reply_from_msg_id'];
-
- case 'forward':
- case 'post':
- $sql_data = array(
- 'root_level' => $root_level,
- 'author_id' => (int) $user->data['user_id'],
- 'icon_id' => $data['icon_id'],
- 'author_ip' => $user->ip,
- 'message_time' => $current_time,
- 'enable_bbcode' => $data['enable_bbcode'],
- 'enable_html' => $data['enable_html'],
- 'enable_smilies' => $data['enable_smilies'],
- 'enable_magic_url' => $data['enable_urls'],
- 'enable_sig' => $data['enable_sig'],
- 'message_subject' => $subject,
- 'message_text' => $message,
- 'message_checksum' => $data['message_md5'],
- 'message_encoding' => $user->lang['ENCODING'],
- 'message_attachment'=> (sizeof($filename_data['physical_filename'])) ? 1 : 0,
- 'bbcode_bitfield' => $data['bbcode_bitfield'],
- 'bbcode_uid' => $bbcode_uid,
- 'to_address' => implode(':', $to),
- 'bcc_address' => implode(':', $bcc)
- );
- break;
-
- case 'edit':
- $sql_data = array(
- 'icon_id' => $data['icon_id'],
- 'message_edit_time' => $current_time,
- 'enable_bbcode' => $data['enable_bbcode'],
- 'enable_html' => $data['enable_html'],
- 'enable_smilies' => $data['enable_smilies'],
- 'enable_magic_url' => $data['enable_urls'],
- 'enable_sig' => $data['enable_sig'],
- 'message_subject' => $subject,
- 'message_text' => $message,
- 'message_checksum' => $data['message_md5'],
- 'message_encoding' => $user->lang['ENCODING'],
- 'message_attachment'=> (sizeof($filename_data['physical_filename'])) ? 1 : 0,
- 'bbcode_bitfield' => $data['bbcode_bitfield'],
- 'bbcode_uid' => $bbcode_uid
- );
- break;
- }
-
- if (sizeof($sql_data))
- {
- if ($mode == 'post' || $mode == 'reply' || $mode == 'quote' || $mode == 'forward')
- {
- $db->sql_query('INSERT INTO ' . PRIVMSGS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_data));
- $data['msg_id'] = $db->sql_nextid();
- }
- else if ($mode == 'edit')
- {
- $sql = 'UPDATE ' . PRIVMSGS_TABLE . '
- SET message_edit_count = message_edit_count + 1, ' . $db->sql_build_array('UPDATE', $sql_data) . '
- WHERE msg_id = ' . $data['msg_id'];
- $db->sql_query($sql);
- }
- }
-
- if ($mode != 'edit')
- {
- $db->sql_transaction();
-
- if ($sql)
- {
- $db->sql_query($sql);
- }
- unset($sql);
-
- foreach ($recipients as $user_id => $type)
- {
- $db->sql_query('INSERT INTO ' . PRIVMSGS_TO_TABLE . ' ' . $db->sql_build_array('INSERT', array(
- 'msg_id' => $data['msg_id'],
- 'user_id' => $user_id,
- 'author_id' => $user->data['user_id'],
- 'folder_id' => PRIVMSGS_NO_BOX,
- 'new' => 1,
- 'unread' => 1,
- 'forwarded' => ($mode == 'forward') ? 1 : 0))
- );
- }
-
- $sql = 'UPDATE ' . USERS_TABLE . '
- SET user_new_privmsg = user_new_privmsg + 1, user_unread_privmsg = user_unread_privmsg + 1
- WHERE user_id IN (' . implode(', ', array_keys($recipients)) . ')';
- $db->sql_query($sql);
-
- // Put PM into outbox
- $db->sql_query('INSERT INTO ' . PRIVMSGS_TO_TABLE . ' ' . $db->sql_build_array('INSERT', array(
- 'msg_id' => (int) $data['msg_id'],
- 'user_id' => (int) $user->data['user_id'],
- 'author_id' => (int) $user->data['user_id'],
- 'folder_id' => PRIVMSGS_OUTBOX,
- 'new' => 0,
- 'unread' => 0,
- 'forwarded' => ($mode == 'forward') ? 1 : 0))
- );
-
- $db->sql_transaction('commit');
- }
-
- // Set user last post time
- if ($mode == 'reply' || $mode == 'quote' || $mode == 'forward' || $mode == 'post')
- {
- $sql = 'UPDATE ' . USERS_TABLE . "
- SET user_lastpost_time = $current_time
- WHERE user_id = " . $user->data['user_id'];
- $db->sql_query($sql);
- }
-
- $db->sql_transaction();
-
- // Submit Attachments
- if (count($attach_data) && $data['msg_id'] && in_array($mode, array('post', 'reply', 'quote', 'edit', 'forward')))
- {
- $space_taken = $files_added = 0;
-
- foreach ($attach_data as $pos => $attach_row)
- {
- if ($attach_row['attach_id'])
- {
- // update entry in db if attachment already stored in db and filespace
- $sql = 'UPDATE ' . ATTACHMENTS_TABLE . "
- SET comment = '" . $db->sql_escape($attach_row['comment']) . "'
- WHERE attach_id = " . (int) $attach_row['attach_id'];
- $db->sql_query($sql);
- }
- else
- {
- // insert attachment into db
- $attach_sql = array(
- 'post_msg_id' => $data['msg_id'],
- 'topic_id' => 0,
- 'in_message' => 1,
- 'poster_id' => $user->data['user_id'],
- 'physical_filename' => $attach_row['physical_filename'],
- 'real_filename' => $attach_row['real_filename'],
- 'comment' => $attach_row['comment'],
- 'extension' => $attach_row['extension'],
- 'mimetype' => $attach_row['mimetype'],
- 'filesize' => $attach_row['filesize'],
- 'filetime' => $attach_row['filetime'],
- 'thumbnail' => $attach_row['thumbnail']
- );
-
- $sql = 'INSERT INTO ' . ATTACHMENTS_TABLE . ' ' .
- $db->sql_build_array('INSERT', $attach_sql);
- $db->sql_query($sql);
-
- $space_taken += $attach_row['filesize'];
- $files_added++;
- }
- }
-
- if (count($attach_data))
- {
- $sql = 'UPDATE ' . PRIVMSGS_TABLE . '
- SET message_attachment = 1
- WHERE msg_id = ' . $data['msg_id'];
- $db->sql_query($sql);
- }
-
- set_config('upload_dir_size', $config['upload_dir_size'] + $space_taken, true);
- set_config('num_files', $config['num_files'] + $files_added, true);
- }
-
- $db->sql_transaction('commit');
-
- // Delete draft if post was loaded...
- $draft_id = request_var('draft_loaded', 0);
- if ($draft_id)
- {
- $sql = 'DELETE FROM ' . DRAFTS_TABLE . "
- WHERE draft_id = $draft_id
- AND user_id = " . $user->data['user_id'];
- $db->sql_query($sql);
+ posting_gen_attachment_entry($attachment_data, $filename_data);
}
-
- // Send Notifications
- if ($mode != 'edit')
- {
- pm_notification($mode, stripslashes($user->data['username']), $recipients, stripslashes($subject), stripslashes($message));
- }
-
- $return_message_url = "{$phpbb_root_path}ucp.$phpEx$SID&amp;i=pm&amp;mode=view_messages&amp;action=view_message&amp;p=" . $data['msg_id'];
- $return_folder_url = "{$phpbb_root_path}ucp.$phpEx$SID&amp;i=pm&amp;folder=outbox";
- meta_refresh(3, $return_message_url);
-
- $message = $user->lang['MESSAGE_STORED'] . '<br /><br />' . sprintf($user->lang['VIEW_MESSAGE'], '<a href="' . $return_message_url . '">', '</a>') . '<br /><br />' . sprintf($user->lang['RETURN_FOLDER'], '<a href="' . $return_folder_url . '">', '</a>');
- trigger_error($message);
}
// For composing messages, handle list actions
@@ -1060,96 +833,6 @@ function handle_message_list_actions(&$address_list, $remove_u, $remove_g, $add_
}
-// PM Notification
-function pm_notification($mode, $author, $recipients, $subject, $message)
-{
- global $db, $user, $config, $phpbb_root_path, $phpEx, $auth;
-
- decode_text($subject);
- $subject = censor_text($subject);
-
- // Get banned User ID's
- $sql = 'SELECT ban_userid
- FROM ' . BANLIST_TABLE;
- $result = $db->sql_query($sql);
-
- unset($recipients[ANONYMOUS], $recipients[$user->data['user_id']]);
-
- while ($row = $db->sql_fetchrow($result))
- {
- if (isset($row['ban_userid']))
- {
- unset($recipients[$row['ban_userid']]);
- }
- }
- $db->sql_freeresult($result);
-
- if (!sizeof($recipients))
- {
- return;
- }
-
- $recipient_list = implode(', ', array_keys($recipients));
-
- $sql = 'SELECT user_id, username, user_email, user_lang, user_notify_type, user_jabber
- FROM ' . USERS_TABLE . "
- WHERE user_id IN ($recipient_list)";
- $result = $db->sql_query($sql);
-
- $msg_list_ary = array();
- while ($row = $db->sql_fetchrow($result))
- {
- if (trim($row['user_email']))
- {
- $msg_list_ary[] = array(
- 'method' => $row['method'],
- 'email' => $row['user_email'],
- 'jabber' => $row['user_jabber'],
- 'name' => $row['username'],
- 'lang' => $row['user_lang']
- );
- }
- }
- $db->sql_freeresult($result);
-
- if (!sizeof($msg_list_ary))
- {
- return;
- }
-
- include_once($phpbb_root_path . 'includes/functions_messenger.'.$phpEx);
- $messenger = new messenger();
-
- $email_sig = str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']);
-
- foreach ($msg_list_ary as $pos => $addr)
- {
- $messenger->template('privmsg_notify', $addr['lang']);
-
- $messenger->replyto($config['board_email']);
- $messenger->to($addr['email'], $addr['name']);
- $messenger->im($addr['jabber'], $addr['name']);
-
- $messenger->assign_vars(array(
- 'EMAIL_SIG' => $email_sig,
- 'SITENAME' => $config['sitename'],
- 'SUBJECT' => $subject,
- 'AUTHOR_NAME' => $author,
-
- 'U_INBOX' => generate_board_url() . "/ucp.$phpEx?i=pm&mode=unread")
- );
-
- $messenger->send($addr['method']);
- $messenger->reset();
- }
- unset($msg_list_ary);
-
- if ($messenger->queue)
- {
- $messenger->queue->save();
- }
-}
-
// Return number of recipients
function num_recipients($address_list)
{
diff --git a/phpBB/includes/ucp/ucp_pm_options.php b/phpBB/includes/ucp/ucp_pm_options.php
index 699452fe69..69e802b4da 100644
--- a/phpBB/includes/ucp/ucp_pm_options.php
+++ b/phpBB/includes/ucp/ucp_pm_options.php
@@ -212,7 +212,17 @@ function message_options($id, $mode, $global_privmsgs_rules, $global_rule_condit
$db->sql_freeresult($result);
$s_full_folder_options = $s_to_folder_options = $s_folder_options = '';
-
+
+ if ($user->data['user_full_folder'] == FULL_FOLDER_NONE)
+ {
+ // -3 here to let the correct folder id be selected
+ $to_folder_id = $config['full_folder_action']-3;
+ }
+ else
+ {
+ $to_folder_id = $user->data['user_full_folder'];
+ }
+
foreach ($folder as $folder_id => $folder_ary)
{
$s_full_folder_options .= '<option value="' . $folder_id . '"' . (($user->data['user_full_folder'] == $folder_id) ? ' selected="selected"' : '') . '>' . $folder_ary['folder_name'] . ' (' . $folder_ary['message_status'] . ')</option>';
diff --git a/phpBB/includes/ucp/ucp_pm_viewfolder.php b/phpBB/includes/ucp/ucp_pm_viewfolder.php
index 8c82ca7c5d..990bcc09d5 100644
--- a/phpBB/includes/ucp/ucp_pm_viewfolder.php
+++ b/phpBB/includes/ucp/ucp_pm_viewfolder.php
@@ -167,8 +167,6 @@ function view_folder($id, $mode, $folder_id, $folder, $type)
// 'U_MCP_QUEUE' => "mcp.$phpEx?sid={$user->session_id}&amp;mode=mod_queue&amp;t=$topic_id")
);
- $i++;
-
unset($folder_info['rowset'][$message_id]);
}
@@ -270,7 +268,7 @@ function get_pm_from($folder_id, $folder, $user_id, $url, $type = 'folder')
'PAGE_NUMBER' => on_page($pm_count, $config['topics_per_page'], $start),
'TOTAL_MESSAGES'=> (($pm_count == 1) ? $user->lang['VIEW_PM_MESSAGE'] : sprintf($user->lang['VIEW_PM_MESSAGES'], $pm_count)),
- 'POST_IMG' => (!$auth->acl_get('u_sendpm')) ? $user->img('btn_locked', $post_alt) : $user->img('btn_post_pm', $post_alt),
+ 'POST_IMG' => (!$auth->acl_get('u_sendpm')) ? $user->img('btn_locked', 'PM_LOCKED') : $user->img('btn_post_pm', 'POST_PM'),
'REPORTED_IMG' => $user->img('icon_reported', 'MESSAGE_REPORTED'),
diff --git a/phpBB/includes/ucp/ucp_prefs.php b/phpBB/includes/ucp/ucp_prefs.php
index dc344a8765..a463df778a 100644
--- a/phpBB/includes/ucp/ucp_prefs.php
+++ b/phpBB/includes/ucp/ucp_prefs.php
@@ -42,6 +42,8 @@ class ucp_prefs extends module
'allowpm' => true,
);
+ $var_ary['report_pm_notify'] = false;
+
foreach ($var_ary as $var => $default)
{
$data[$var] = request_var($var, $default);
@@ -57,11 +59,11 @@ class ucp_prefs extends module
extract($data);
unset($data);
- // Set the popuppm option
- $user->optionset('popuppm', $popuppm);
-
if (!sizeof($error))
{
+ $user->optionset('popuppm', $popuppm);
+ $user->optionset('report_pm_notify', $report_pm_notify);
+
$sql_ary = array(
'user_allow_pm' => $allowpm,
'user_allow_viewemail' => $viewemail,
@@ -107,6 +109,9 @@ class ucp_prefs extends module
$popuppm = (isset($popuppm)) ? $popuppm : $user->optionget('popuppm');
$popup_pm_yes = ($popuppm) ? ' checked="checked"' : '';
$popup_pm_no = (!$popuppm) ? ' checked="checked"' : '';
+ $report_pm_notify = (isset($report_pm_notify)) ? $report_pm_notify : $user->optionget('report_pm_notify');
+ $report_pm_notify_yes = ($report_pm_notify) ? ' checked="checked"' : '';
+ $report_pm_notify_no = (!$report_pm_notify) ? ' checked="checked"' : '';
$dst = (isset($dst)) ? $dst : $user->data['user_dst'];
$dst_yes = ($dst) ? ' checked="checked"' : '';
$dst_no = (!$dst) ? ' checked="checked"' : '';
@@ -132,6 +137,8 @@ class ucp_prefs extends module
'NOTIFY_PM_NO' => $notify_pm_no,
'POPUP_PM_YES' => $popup_pm_yes,
'POPUP_PM_NO' => $popup_pm_no,
+ 'REPORT_PM_YES' => $report_pm_notify_yes,
+ 'REPORT_PM_NO' => $report_pm_notify_no,
'DST_YES' => $dst_yes,
'DST_NO' => $dst_no,
'NOTIFY_EMAIL' => ($notifymethod == NOTIFY_EMAIL) ? 'checked="checked"' : '',
@@ -143,9 +150,8 @@ class ucp_prefs extends module
'S_LANG_OPTIONS' => language_select($lang),
'S_STYLE_OPTIONS' => style_select($style),
'S_TZ_OPTIONS' => tz_select($tz),
- 'S_CAN_HIDE_ONLINE' => true,
- 'S_SELECT_NOTIFY' => ($config['jab_enable'] && $user->data['user_jabber'] && @extension_loaded('xml')) ? true : false,
- )
+ 'S_CAN_HIDE_ONLINE' => true,
+ 'S_SELECT_NOTIFY' => ($config['jab_enable'] && $user->data['user_jabber'] && @extension_loaded('xml')) ? true : false)
);
break;
diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php
index 9e84e5fba3..e89ce7947f 100644
--- a/phpBB/includes/ucp/ucp_profile.php
+++ b/phpBB/includes/ucp/ucp_profile.php
@@ -359,6 +359,8 @@ class ucp_profile extends module
include($phpbb_root_path . 'includes/functions_posting.'.$phpEx);
+ $s_hidden_fields = '';
+
$var_ary = array(
'enable_html' => (bool) $config['allow_html'],
'enable_bbcode' => (bool) $config['allow_bbcode'],
@@ -373,8 +375,18 @@ class ucp_profile extends module
$$var = request_var($var, $default);
}
- if ($submit)
+ $html_status = ($config['allow_html']) ? true : false;
+ $bbcode_status = ($config['allow_bbcode']) ? true : false;
+ $smilies_status = ($config['allow_smilies']) ? true : false;
+
+ // NOTE: allow_img and allow_flash do not exist in config table
+ $img_status = ($config['allow_img']) ? true : false;
+ $flash_status = ($config['allow_flash']) ? true : false;
+
+ if ($submit || $preview)
{
+ include($phpbb_root_path . 'includes/message_parser.'.$phpEx);
+
if (strlen($signature) > $config['max_sig_chars'])
{
$error[] = $user->lang['SIGNATURE_TOO_LONG'];
@@ -382,62 +394,44 @@ class ucp_profile extends module
if (!sizeof($error))
{
- include($phpbb_root_path . 'includes/message_parser.'.$phpEx);
-
$message_parser = new parse_message($signature);
- $message_parser->parse($enable_html, $enable_bbcode, $enable_urls, $enable_smilies);
- $sql_ary = array(
- 'user_sig' => (string) $message_parser->message,
- 'user_sig_bbcode_uid' => (string) $message_parser->bbcode_uid,
- 'user_sig_bbcode_bitfield' => (int) $message_parser->bbcode_bitfield
- );
+ // Allowing Quote BBCode
+ $message_parser->parse($enable_html, $enable_bbcode, $enable_urls, $enable_smilies, $img_status, $flash_status, true);
+
+ if (sizeof($message_parser->warn_msg))
+ {
+ $error[] = implode('<br />', $message_parser->warn_msg);
+ }
+
+ if (!sizeof($error) && $submit)
+ {
+ $sql_ary = array(
+ 'user_sig' => (string) $message_parser->message,
+ 'user_sig_bbcode_uid' => (string) $message_parser->bbcode_uid,
+ 'user_sig_bbcode_bitfield' => (int) $message_parser->bbcode_bitfield
+ );
- $sql = 'UPDATE ' . USERS_TABLE . '
- SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
- WHERE user_id = ' . $user->data['user_id'];
- $db->sql_query($sql);
+ $sql = 'UPDATE ' . USERS_TABLE . '
+ SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
+ WHERE user_id = ' . $user->data['user_id'];
+ $db->sql_query($sql);
- $message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], "<a href=\"ucp.$phpEx$SID&amp;i=$id&amp;mode=$mode\">", '</a>');
- trigger_error($message);
+ $message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], "<a href=\"ucp.$phpEx$SID&amp;i=$id&amp;mode=$mode\">", '</a>');
+ trigger_error($message);
+ }
}
}
$signature_preview = '';
if ($preview)
{
- $signature_preview = $signature;
-
- // Fudge-o-rama ...
- include($phpbb_root_path . 'includes/message_parser.'.$phpEx);
-
- $message_parser = new parse_message($signature_preview);
- $message_parser->parse($enable_html, $enable_bbcode, $enable_urls, $enable_smilies);
- $signature_preview = $message_parser->message;
-
- if ($enable_bbcode)
- {
- include($phpbb_root_path . 'includes/bbcode.'.$phpEx);
- $bbcode = new bbcode($message_parser->bbcode_bitfield);
-
- $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 = smilie_text($signature_preview, !$enable_smilies);
-
- // Replace naughty words such as farty pants
- $signature_preview = str_replace("\n", '<br />', censor_text($signature_preview));
+ // Now parse it for displaying
+ $signature_preview = $message_parser->format_display($enable_html, $enable_bbcode, $enable_urls, $enable_smilies, false);
+ unset($message_parser);
}
- $html_status = ($config['allow_html']) ? true : false;
- $bbcode_status = ($config['allow_bbcode']) ? true : false;
- $smilies_status = ($config['allow_smilies']) ? true : false;
- // NOTE: allow_img and allow_flash do not exist in config table
- $img_status = ($config['allow_img']) ? true : false;
- $flash_status = ($config['allow_flash']) ? true : false;
-
- decode_text($signature, $user->data['user_sig_bbcode_uid']);
+ decode_message($signature, $user->data['user_sig_bbcode_uid']);
$template->assign_vars(array(
'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '',
@@ -449,24 +443,27 @@ class ucp_profile extends module
'S_SMILIES_CHECKED' => (!$enable_smilies) ? 'checked="checked"' : '',
'S_MAGIC_URL_CHECKED' => (!$enable_urls) ? 'checked="checked"' : '',
- 'HTML_STATUS' => ($html_status) ? $user->lang['HTML_IS_ON'] : $user->lang['HTML_IS_OFF'],
- 'BBCODE_STATUS' => ($bbcode_status) ? sprintf($user->lang['BBCODE_IS_ON'], '<a href="' . "faq.$phpEx$SID&amp;mode=bbcode" . '" target="_phpbbcode">', '</a>') : sprintf($user->lang['BBCODE_IS_OFF'], '<a href="' . "faq.$phpEx$SID&amp;mode=bbcode" . '" target="_phpbbcode">', '</a>'),
- 'SMILIES_STATUS'=> ($smilies_status) ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'],
- 'IMG_STATUS' => ($img_status) ? $user->lang['IMAGES_ARE_ON'] : $user->lang['IMAGES_ARE_OFF'],
- 'FLASH_STATUS' => ($flash_status) ? $user->lang['FLASH_IS_ON'] : $user->lang['FLASH_IS_OFF'],
+ 'HTML_STATUS' => ($html_status) ? $user->lang['HTML_IS_ON'] : $user->lang['HTML_IS_OFF'],
+ 'BBCODE_STATUS' => ($bbcode_status) ? sprintf($user->lang['BBCODE_IS_ON'], '<a href="' . "faq.$phpEx$SID&amp;mode=bbcode" . '" target="_phpbbcode">', '</a>') : sprintf($user->lang['BBCODE_IS_OFF'], '<a href="' . "faq.$phpEx$SID&amp;mode=bbcode" . '" target="_phpbbcode">', '</a>'),
+ 'SMILIES_STATUS' => ($smilies_status) ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'],
+ 'IMG_STATUS' => ($img_status) ? $user->lang['IMAGES_ARE_ON'] : $user->lang['IMAGES_ARE_OFF'],
+ 'FLASH_STATUS' => ($flash_status) ? $user->lang['FLASH_IS_ON'] : $user->lang['FLASH_IS_OFF'],
'L_SIGNATURE_EXPLAIN' => sprintf($user->lang['SIGNATURE_EXPLAIN'], $config['max_sig_chars']),
- 'S_HTML_ALLOWED' => $config['allow_html'],
- 'S_BBCODE_ALLOWED' => $config['allow_bbcode'],
- 'S_SMILIES_ALLOWED' => $config['allow_smilies'],)
+ 'S_HTML_ALLOWED' => $config['allow_html'],
+ 'S_BBCODE_ALLOWED' => $config['allow_bbcode'],
+ 'S_SMILIES_ALLOWED' => $config['allow_smilies'],)
);
break;
case 'avatar':
$display_gallery = (isset($_POST['displaygallery'])) ? true : false;
- $avatar_category = request_var('category', '');
+ $category = request_var('category', '');
+ $delete = (isset($_POST['delete'])) ? true : false;
+ $avatarselect = request_var('avatarselect', '');
+ $s_hidden_fields = '';
// Can we upload?
$can_upload = ($config['allow_avatar_upload'] && file_exists($phpbb_root_path . $config['avatar_path']) && is_writeable($phpbb_root_path . $config['avatar_path']) && $auth->acl_get('u_chgavatar') && (@ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on')) ? true : false;
@@ -506,6 +503,12 @@ class ucp_profile extends module
{
list($type, $filename, $width, $height) = avatar_remote($data, $error);
}
+ else if ($avatarselect && $auth->acl_get('u_chgavatar') && $config['allow_avatar_local'])
+ {
+ $type = AVATAR_GALLERY;
+ $filename = $avatarselect;
+ list($width, $height) = getimagesize($phpbb_root_path . $config['avatar_gallery_path'] . '/' . $filename);
+ }
else if ($delete && $auth->acl_get('u_chgavatar'))
{
$type = $filename = $width = $height = '';
@@ -530,7 +533,7 @@ class ucp_profile extends module
$db->sql_query($sql);
// Delete old avatar if present
- if ($user->data['user_avatar'] && $filename != $user->data['user_avatar'])
+ if ($user->data['user_avatar'] && $filename != $user->data['user_avatar'] && $user->data['user_avatar_type'] != AVATAR_GALLERY)
{
avatar_delete($user->data['user_avatar']);
}
@@ -543,6 +546,9 @@ class ucp_profile extends module
extract($data);
unset($data);
+
+ // Replace "error" strings with their real, localised form
+ $error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$lang['\\1'])) ? \$lang['\\1'] : '\\1'", $error);
}
// Generate users avatar
@@ -573,16 +579,16 @@ class ucp_profile extends module
'L_AVATAR_EXPLAIN' => sprintf($user->lang['AVATAR_EXPLAIN'], $config['avatar_max_width'], $config['avatar_max_height'], round($config['avatar_filesize'] / 1024)),)
);
+ $s_categories = $s_pages = '';
if ($display_gallery && $auth->acl_get('u_chgavatar') && $config['allow_avatar_local'])
{
$avatar_list = avatar_gallery($category, $error);
-
$category = (!$category) ? key($avatar_list) : $category;
$s_category_options = '';
foreach (array_keys($avatar_list) as $cat)
{
- $s_category_options .= '<option value="' . $cat . '">' . $cat . '</option>';
+ $s_category_options .= '<option value="' . $cat . '"' . (($cat == $category) ? ' selected="selected"' : '') . '>' . $cat . '</option>';
}
$template->assign_vars(array(
@@ -590,7 +596,9 @@ class ucp_profile extends module
'S_CAT_OPTIONS' => $s_category_options)
);
- foreach ($avatar_list[$category] as $avatar_row_ary)
+ $avatar_list = $avatar_list[$category];
+
+ foreach ($avatar_list as $avatar_row_ary)
{
$template->assign_block_vars('avatar_row', array());
@@ -602,10 +610,12 @@ class ucp_profile extends module
);
$template->assign_block_vars('avatar_row.avatar_option_column', array(
- 'AVATAR_IMAGE' => $phpbb_root_path . $config['avatar_gallery_path'] . '/' . $avatar_col_ary['file'],)
+ 'AVATAR_IMAGE' => $phpbb_root_path . $config['avatar_gallery_path'] . '/' . $avatar_col_ary['file'],
+ 'S_OPTIONS_AVATAR' => $avatar_col_ary['file'])
);
}
}
+ unset($avatar_list);
}
else
{
diff --git a/phpBB/index.php b/phpBB/index.php
index b7e6bed2ef..32c60f0785 100644
--- a/phpBB/index.php
+++ b/phpBB/index.php
@@ -44,7 +44,7 @@ $result = $db->sql_query($sql);
$legend = '';
while ($row = $db->sql_fetchrow($result))
{
- $legend .= (($legend != '') ? ', ' : '') . '<a style="color:#' . $row['group_colour'] . '" href="memberlist.' . $phpEx . $SID . '&amp;mode=group&amp;g=' . $row['group_id'] . '">' . (($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name']) . '</span>';
+ $legend .= (($legend != '') ? ', ' : '') . '<a style="color:#' . $row['group_colour'] . '" href="memberlist.' . $phpEx . $SID . '&amp;mode=group&amp;g=' . $row['group_id'] . '">' . (($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name']) . '</a>';
}
$db->sql_freeresult($result);
diff --git a/phpBB/install/schemas/mysql_schema.sql b/phpBB/install/schemas/mysql_schema.sql
index 18733cc6ea..32981c93bd 100644
--- a/phpBB/install/schemas/mysql_schema.sql
+++ b/phpBB/install/schemas/mysql_schema.sql
@@ -201,7 +201,9 @@ CREATE TABLE phpbb_forums (
forum_image varchar(50) DEFAULT '' NOT NULL,
forum_rules text DEFAULT '' NOT NULL,
forum_rules_link varchar(200) DEFAULT '' NOT NULL,
- forum_rules_flags varchar(50) DEFAULT '' NOT NULL,
+ forum_rules_flags tinyint(4) UNSIGNED DEFAULT 0 NOT NULL,
+ forum_rules_bbcode_bitfield int(11) UNSIGNED DEFAULT '0' NOT NULL,
+ forum_rules_bbcode_uid varchar(5) DEFAULT '' NOT NULL,
forum_topics_per_page tinyint(4) UNSIGNED DEFAULT '0' NOT NULL,
forum_type tinyint(4) DEFAULT '0' NOT NULL,
forum_status tinyint(4) DEFAULT '0' NOT NULL,
diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql
index 143cdc1404..81cc718abb 100644
--- a/phpBB/install/schemas/schema_data.sql
+++ b/phpBB/install/schemas/schema_data.sql
@@ -147,6 +147,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('img_min_thumb_file
INSERT INTO phpbb_config (config_name, config_value) VALUES ('img_imagick', '');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('pm_max_boxes', '4');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('pm_max_msgs', '50');
+INSERT INTO phpbb_config (config_name, config_value) VALUES ('full_folder_action', '2');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('auth_html_pm', '0');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('auth_bbcode_pm', '1');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('auth_smilies_pm', '1');
diff --git a/phpBB/language/en/mcp.php b/phpBB/language/en/mcp.php
index 88a8305ca3..81a19460a9 100644
--- a/phpBB/language/en/mcp.php
+++ b/phpBB/language/en/mcp.php
@@ -138,6 +138,7 @@ $lang += array(
'MERGE_POSTS_CONFIRM' => 'Are you sure you want to merge the selected posts?',
'MERGE_TOPIC_EXPLAIN' => 'Using the form below you can merge selected posts into another topic. These posts will not be reordered and will appear as if the users posted them to the new topic.<br />Please enter the destination topic id or click on the "Select" button to search for one',
'MERGE_TOPIC_ID' => 'Destination topic id',
+ 'MESSAGE_REPORTED_SUCCESS' => 'This message has been successfully reported',
'MOD_OPTIONS' => 'Moderator Options',
'MORE_INFO' => 'Further information',
'MOVE_TOPIC_CONFIRM' => 'Are you sure you want to move the topic into a new forum?',
@@ -181,13 +182,14 @@ $lang += array(
'REPORTS_TOTAL' => 'In total there are <b>%d</b> reports to review',
'REPORTS_ZERO_TOTAL' => 'There are no reports to review',
'REPORT_MESSAGE' => 'Report this message',
- 'REPORT_MESSAGE_EXPLAIN'=> 'Use this form to report the selected message to the private message moderators and board administrators. Reporting should generally be used only if the message breaks forum rules.',
+ 'REPORT_MESSAGE_EXPLAIN'=> 'Use this form to report the selected message to the board administrators. Reporting should generally be used only if the message breaks forum rules.',
'REPORT_NOTIFY' => 'Notify me',
'REPORT_NOTIFY_EXPLAIN' => 'Informs you when your report is dealt with',
'REPORT_POST' => 'Report this post',
'REPORT_POST_EXPLAIN' => 'Use this form to report the selected post to the forum moderators and board administrators. Reporting should generally be used only if the post breaks forum rules.',
'REPORT_TOTAL' => 'In total there is <b>1</b> report to review',
'RESYNC' => 'Resync',
+ 'RETURN_MESSAGE' => 'Click %sHere%s to return to the message',
'RETURN_NEW_FORUM' => 'Click %sHere%s to return to the new forum',
'RETURN_NEW_TOPIC' => 'Click %sHere%s to return to the new topic',
diff --git a/phpBB/language/en/ucp.php b/phpBB/language/en/ucp.php
index a81c52248a..f59e0c343e 100644
--- a/phpBB/language/en/ucp.php
+++ b/phpBB/language/en/ucp.php
@@ -142,6 +142,11 @@ $lang += array(
'FRIENDS_ONLINE' => 'Online',
'FRIENDS_UPDATED' => 'Your friends list has been updated successfully',
'FULL_FOLDER_OPTION_CHANGED'=> 'Full Folder Option changed successfully',
+ 'FWD_ORIGINAL_MESSAGE' => '-------- Original Message --------',
+ 'FWD_SUBJECT' => 'Subject: %s',
+ 'FWD_DATE' => 'Date: %s',
+ 'FWD_FROM' => 'From: %s',
+ 'FWD_TO' => 'To: %s',
'HIDE_ONLINE' => 'Hide my online status',
'HOLD_NEW_MESSAGES' => 'Do not accept new messages (New messages will be held back until enough space is available)',
@@ -229,6 +234,8 @@ $lang += array(
'REMOVE_FOLDER' => 'Remove folder',
'REPLIED_MESSAGE' => 'Replied to Message',
'REPORT_PM' => 'Report PM',
+ 'REPORT_PM_NOTIFY' => 'Send report notifications as PM',
+ 'REPORT_PM_NOTIFY_EXPLAIN' => 'If enabled, notifications and status updates to new reports get send as PM instead of emailing them.',
'RETURN_UCP' => 'Click %sHere%s to return to the User Control Panel',
'RULE_ADDED' => 'Rule successfully added',
'RULE_ALREADY_DEFINED' => 'This rule was defined previously',
diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php
index 1116d58820..754b286370 100644
--- a/phpBB/memberlist.php
+++ b/phpBB/memberlist.php
@@ -783,7 +783,7 @@ switch ($mode)
'AVATAR_IMG' => $avatar_img,
'RANK_IMG' => $rank_img,
- 'U_PM' => ($auth->acl_get('u_sendpm')) ? "ucp.$phpEx$SID&amp;i=pm&amp;mode=compose&amp;address_list[g][$group_id]=to" : '',)
+ 'U_PM' => ($auth->acl_get('u_sendpm')) ? "ucp.$phpEx$SID&amp;i=pm&amp;mode=compose&amp;g=$group_id" : '',)
);
$sql_from = ', ' . USER_GROUP_TABLE . ' ug ';
@@ -997,7 +997,7 @@ function show_profile($data)
'U_PROFILE' => "memberlist.$phpEx$SID&amp;mode=viewprofile&amp;u=$user_id",
'U_SEARCH_USER' => ($auth->acl_get('u_search')) ? "search.$phpEx$SID&amp;search_author=" . urlencode($username) . "&amp;show_results=posts" : '',
- 'U_PM' => ($auth->acl_get('u_sendpm')) ? "ucp.$phpEx$SID&amp;mode=pm&amp;action=send&amp;u=$user_id" : '',
+ 'U_PM' => ($auth->acl_get('u_sendpm')) ? "ucp.$phpEx$SID&amp;i=pm&amp;mode=compose&amp;u=$user_id" : '',
'U_EMAIL' => $email,
'U_WWW' => (!empty($data['user_website'])) ? $data['user_website'] : '',
'U_ICQ' => ($data['user_icq']) ? "memberlist.$phpEx$SID&amp;mode=contact&amp;action=icq&amp;u=$user_id" : '',
diff --git a/phpBB/posting.php b/phpBB/posting.php
index 71fd451565..fed6c55f26 100644
--- a/phpBB/posting.php
+++ b/phpBB/posting.php
@@ -157,6 +157,11 @@ if ($sql)
$poll_length = (isset($poll_length)) ? (($poll_length) ? (int) $poll_length / 86400 : (int) $poll_length) : 0;
$poll_start = (isset($poll_start)) ? (int) $poll_start : 0;
$poll_options = array();
+
+ if (!isset($icon_id))
+ {
+ $icon_id = 0;
+ }
// Get Poll Data
if ($poll_start)
@@ -176,6 +181,12 @@ if ($sql)
$message_parser = new parse_message();
+ if (isset($post_text))
+ {
+ $message_parser->message = $post_text;
+ unset($post_text);
+ }
+
$message_parser->get_submitted_attachment_data();
// Set uninitialized variables
@@ -187,6 +198,7 @@ if ($sql)
$$var_name = $default_value;
}
}
+ unset($uninit, $var_name, $default_value);
if ($post_attachment && !$submit && !$refresh && !$preview && $mode == 'edit')
{
@@ -212,7 +224,8 @@ if ($sql)
}
$enable_urls = $enable_magic_url;
-
+
+ $enable_html = (isset($enable_html)) ? $enable_html : $config['allow_html'];
if (!in_array($mode, array('quote', 'edit', 'delete')))
{
@@ -240,6 +253,8 @@ if ($sql)
}
$db->sql_freeresult($result);
}
+
+ $check_value = (($enable_html+1) << 16) + (($enable_bbcode+1) << 8) + (($enable_smilies+1) << 4) + (($enable_urls+1) << 2) + (($enable_sig+1) << 1);
}
// Notify user checkbox
@@ -479,7 +494,6 @@ if ($submit || $preview || $refresh)
$topic_cur_post_id = request_var('topic_cur_post_id', 0);
$subject = request_var('subject', '');
-// $subject = request_var('subject', '', false, true);
if (strcmp($subject, strtoupper($subject)) == 0 && $subject)
{
@@ -488,8 +502,6 @@ if ($submit || $preview || $refresh)
$message_parser->message = (isset($_POST['message'])) ? htmlspecialchars(str_replace(array('\\\'', '\\"', '\\0', '\\\\'), array('\'', '"', '\0', '\\'), $_POST['message'])) : '';
$message_parser->message = preg_replace('#&amp;(\#[0-9]+;)#', '&\1', $message_parser->message);
-// $message_parser->message = request_var('message', '', true, true);
-
$username = (isset($_POST['username'])) ? request_var('username', '') : $username;
$post_edit_reason = (isset($_POST['edit_reason']) && !empty($_POST['edit_reason']) && $mode == 'edit' && $user->data['user_id'] != $poster_id) ? request_var('edit_reason', '') : '';
@@ -510,10 +522,15 @@ if ($submit || $preview || $refresh)
$poll_delete = (isset($_POST['poll_delete']));
- // Faster than crc32
- $check_value = (($preview || $refresh) && isset($_POST['status_switch'])) ? (int) $_POST['status_switch'] : (($enable_html+1) << 16) + (($enable_bbcode+1) << 8) + (($enable_smilies+1) << 4) + (($enable_urls+1) << 2) + (($enable_sig+1) << 1);
- $status_switch = (isset($_POST['status_switch']) && (int) $_POST['status_switch'] != $check_value);
-
+ if ($submit)
+ {
+ $status_switch = (($enable_html+1) << 16) + (($enable_bbcode+1) << 8) + (($enable_smilies+1) << 4) + (($enable_urls+1) << 2) + (($enable_sig+1) << 1);
+ $status_switch = ($status_switch != $check_value);
+ }
+ else
+ {
+ $status_switch = 1;
+ }
if ($poll_delete && (($mode == 'edit' && $poll_options && !$poll_last_vote && $poster_id == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id)) || $auth->acl_get('m_delete', $forum_id)))
{
@@ -564,9 +581,9 @@ if ($submit || $preview || $refresh)
// Grab md5 'checksum' of new message
$message_md5 = md5($message_parser->message);
- $update_message = ($mode != 'edit' || $message_md5 != $post_checksum || $status_switch || $preview) ? true : false;
// Check checksum ... don't re-parse message if the same
+ $update_message = ($mode != 'edit' || $message_md5 != $post_checksum || $status_switch) ? true : false;
// Parse message
if ($update_message)
@@ -773,14 +790,18 @@ if ($submit || $preview || $refresh)
'notify_set' => $notify_set,
'poster_ip' => (isset($poster_ip)) ? (int) $poster_ip : $user->ip,
'post_edit_locked' => (int) $post_edit_locked,
- 'bbcode_bitfield' => (int) $message_parser->bbcode_bitfield
+ 'bbcode_bitfield' => (int) $message_parser->bbcode_bitfield,
+ 'bbcode_uid' => $message_parser->bbcode_uid,
+ 'message' => $message_parser->message,
+ 'attachment_data' => $message_parser->attachment_data,
+ 'filename_data' => $message_parser->filename_data
);
+ unset($message_parser);
- submit_post($mode, $message_parser->message, $subject, $username, $topic_type, $message_parser->bbcode_uid, $poll, $message_parser->attachment_data, $message_parser->filename_data, $post_data, $update_message);
+ submit_post($mode, $subject, $username, $topic_type, $poll, $post_data, $update_message);
}
}
- $post_text = $message_parser->message;
$post_subject = stripslashes($subject);
}
@@ -789,33 +810,43 @@ if (!sizeof($error) && $preview)
{
$post_time = ($mode == 'edit') ? $post_time : $current_time;
- $preview_subject = censor_text($subject);
+ $preview_message = $message_parser->format_display($enable_html, $enable_bbcode, $enable_urls, $enable_smilies, false);
$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_bitfield = ($mode == 'edit') ? $user_sig_bbcode_bitfield : $user->data['user_sig_bbcode_bitfield'];
- include($phpbb_root_path . 'includes/bbcode.' . $phpEx);
- $bbcode = new bbcode($message_parser->bbcode_bitfield | $preview_signature_bitfield);
-
- $preview_message = $message_parser->message;
- format_display($preview_message, $preview_signature, $message_parser->bbcode_uid, $preview_signature_uid, $enable_html, $enable_bbcode, $enable_urls, $enable_smilies, $enable_sig);
-
+ // Signature
+ if ($enable_sig && $config['allow_sig'] && $preview_signature && $auth->acl_get('f_sigs', $forum_id))
+ {
+ $parse_sig = new parse_message($preview_signature);
+ $parse_sig->bbcode_uid = $preview_signature_uid;
+ $parse_sig->bbcode_bitfield = $preview_signature_bitfield;
+
+ // Not sure about parameters for bbcode/smilies/urls... in signatures
+ $parse_sig->format_display($config['allow_html'], $config['allow_bbcode'], true, $config['allow_smilies']);
+ $preview_signature = $parse_sig->message;
+ unset($parse_sig);
+ }
+ else
+ {
+ $preview_signature = '';
+ }
+
+ $preview_subject = censor_text($subject);
+
// Poll Preview
if (($mode == 'post' || ($mode == 'edit' && $post_id == $topic_first_post_id && !$poll_last_vote)) && ($auth->acl_get('f_poll', $forum_id) || $auth->acl_get('m_edit', $forum_id)) && $poll_title)
{
- decode_text($poll_title, $message_parser->bbcode_uid);
- $preview_poll_title = format_display($poll_title, $null, $message_parser->bbcode_uid, false, $enable_html, $enable_bbcode, $enable_urls, $enable_smilies, false, false);
-
$template->assign_vars(array(
'S_HAS_POLL_OPTIONS' => (sizeof($poll_options)),
- 'POLL_QUESTION' => $preview_poll_title)
+ 'POLL_QUESTION' => $poll_title)
);
foreach ($poll_options as $option)
{
$template->assign_block_vars('poll_option', array(
- 'POLL_OPTION_CAPTION' => format_display(stripslashes($option), $enable_html, $enable_bbcode, $message_parser->bbcode_uid, $enable_urls, $enable_smilies, false, false))
+ 'POLL_OPTION_CAPTION' => $option)
);
}
}
@@ -829,39 +860,39 @@ if (!sizeof($error) && $preview)
$template->assign_var('S_HAS_ATTACHMENTS', true);
display_attachments($forum_id, 'attachment', $message_parser->attachment_data, $update_count, true);
}
-}
+ if (!sizeof($error))
+ {
+ $template->assign_vars(array(
+ 'PREVIEW_SUBJECT' => $preview_subject,
+ 'PREVIEW_MESSAGE' => $preview_message,
+ 'PREVIEW_SIGNATURE' => $preview_signature,
-// Decode text for message display
-$bbcode_uid = ($mode == 'quote' && !$preview && !$refresh && !sizeof($error)) ? $bbcode_uid : $message_parser->bbcode_uid;
-
-decode_text($post_text, $bbcode_uid);
-
-if ($subject)
-{
- decode_text($subject, $bbcode_uid);
-}
+ 'S_DISPLAY_PREVIEW' => true)
+ );
+ }
-// Save us some processing time. ;)
-if (is_array($poll_options) && sizeof($poll_options))
-{
- $poll_options_tmp = implode("\n", $poll_options);
- decode_text($poll_options_tmp);
- $poll_options = explode("\n", $poll_options_tmp);
+ unset($post_text);
}
+// Decode text for message display
+$bbcode_uid = ($mode == 'quote' && !$preview && !$refresh && !sizeof($error)) ? $bbcode_uid : $message_parser->bbcode_uid;
+$message_parser->decode_message($bbcode_uid);
if ($mode == 'quote' && !$preview && !$refresh)
{
- $post_text = '[quote="' . $quote_username . '"]' . censor_text(trim($post_text)) . "[/quote]\n";
+ $message_parser->message = '[quote="' . $quote_username . '"]' . censor_text(trim($message_parser->message)) . "[/quote]\n";
}
-
if (($mode == 'reply' || $mode == 'quote') && !$preview && !$refresh)
{
$post_subject = ((!preg_match('/^Re:/', $post_subject)) ? 'Re: ' : '') . censor_text($post_subject);
}
+$attachment_data = $message_parser->attachment_data;
+$filename_data = $message_parser->filename_data;
+$post_text = $message_parser->message;
+unset($message_parser);
// MAIN POSTING PAGE BEGINS HERE
@@ -872,7 +903,7 @@ get_moderators($moderators, $forum_id);
generate_smilies('inline', $forum_id);
// Generate inline attachment select box
-posting_gen_inline_attachments($message_parser);
+posting_gen_inline_attachments($attachment_data);
// Do show topic type selection only in first post.
@@ -930,6 +961,8 @@ $forum_data = array(
'forum_desc' => $forum_desc,
'forum_rules' => $forum_rules,
'forum_rules_flags' => $forum_rules_flags,
+ 'forum_rules_bbcode_uid' => $forum_rules_bbcode_uid,
+ 'forum_rules_bbcode_bitfield' => $forum_rules_bbcode_bitfield,
'forum_rules_link' => $forum_rules_link
);
@@ -941,7 +974,6 @@ generate_forum_rules($forum_data);
$s_hidden_fields = ($mode == 'reply' || $mode == 'quote') ? '<input type="hidden" name="topic_cur_post_id" value="' . $topic_last_post_id . '" />' : '';
$s_hidden_fields .= '<input type="hidden" name="lastclick" value="' . $current_time . '" />';
-$s_hidden_fields .= (isset($check_value)) ? '<input type="hidden" name="status_switch" value="' . $check_value . '" />' : '';
$s_hidden_fields .= ($draft_id || isset($_REQUEST['draft_loaded'])) ? '<input type="hidden" name="draft_loaded" value="' . ((isset($_REQUEST['draft_loaded'])) ? intval($_REQUEST['draft_loaded']) : $draft_id) . '" />' : '';
$form_enctype = (@ini_get('file_uploads') == '0' || strtolower(@ini_get('file_uploads')) == 'off' || @ini_get('file_uploads') == '0' || !$config['allow_attachments'] || !$auth->acl_gets('f_attach', 'u_attach', $forum_id)) ? '' : ' enctype="multipart/form-data"';
@@ -958,10 +990,7 @@ $template->assign_vars(array(
'MODERATORS' => (sizeof($moderators)) ? implode(', ', $moderators[$forum_id]) : '',
'USERNAME' => ((!$preview && $mode != 'quote') || $preview) ? stripslashes($username) : '',
'SUBJECT' => $post_subject,
- 'MESSAGE' => trim($post_text),
- 'PREVIEW_SUBJECT' => ($preview && !sizeof($error)) ? $preview_subject : '',
- 'PREVIEW_MESSAGE' => ($preview && !sizeof($error)) ? $preview_message : '',
- 'PREVIEW_SIGNATURE' => ($preview && !sizeof($error)) ? $preview_signature : '',
+ 'MESSAGE' => $post_text,
'HTML_STATUS' => ($html_status) ? $user->lang['HTML_IS_ON'] : $user->lang['HTML_IS_OFF'],
'BBCODE_STATUS' => ($bbcode_status) ? sprintf($user->lang['BBCODE_IS_ON'], '<a href="' . "faq.$phpEx$SID&amp;mode=bbcode" . '" target="_phpbbcode">', '</a>') : sprintf($user->lang['BBCODE_IS_OFF'], '<a href="' . "faq.$phpEx$SID&amp;mode=bbcode" . '" target="_phpbbcode">', '</a>'),
'IMG_STATUS' => ($img_status) ? $user->lang['IMAGES_ARE_ON'] : $user->lang['IMAGES_ARE_OFF'],
@@ -979,7 +1008,6 @@ $template->assign_vars(array(
'S_PRIVMSGS' => false,
'S_CLOSE_PROGRESS_WINDOW' => isset($_POST['add_file']),
- 'S_DISPLAY_PREVIEW' => ($preview && !sizeof($error)),
'S_EDIT_POST' => ($mode == 'edit'),
'S_EDIT_REASON' => ($mode == 'edit' && $user->data['user_id'] != $poster_id),
'S_DISPLAY_USERNAME' => ($user->data['user_id'] == ANONYMOUS || ($mode == 'edit' && $post_username)),
@@ -1032,9 +1060,10 @@ else if ($mode == 'edit' && $poll_last_vote && ($auth->acl_get('f_poll', $forum_
}
// Attachment entry
-if ($auth->acl_gets('f_attach', 'u_attach', $forum_id) && $config['allow_attachments'] && $form_enctype)
+// Not using acl_gets here, because it is using OR logic
+if ($auth->acl_get('f_attach', $forum_id) && $auth->acl_get('u_attach') && $config['allow_attachments'] && $form_enctype)
{
- posting_gen_attachment_entry($message_parser);
+ posting_gen_attachment_entry($attachment_data, $filename_data);
}
// Output page ...
@@ -1200,7 +1229,7 @@ function delete_post($mode, $post_id, $topic_id, $forum_id, $data)
// Submit Post
-function submit_post($mode, $message, $subject, $username, $topic_type, $bbcode_uid, $poll, $attach_data, $filename_data, $data, $update_message = true)
+function submit_post($mode, $subject, $username, $topic_type, $poll, $data, $update_message = true)
{
global $db, $auth, $user, $config, $phpEx, $SID, $template, $phpbb_root_path;
@@ -1251,12 +1280,12 @@ function submit_post($mode, $message, $subject, $username, $topic_type, $bbcode_
'enable_sig' => $data['enable_sig'],
'post_username' => ($user->data['user_id'] == ANONYMOUS) ? stripslashes($username) : '',
'post_subject' => $subject,
- 'post_text' => $message,
+ 'post_text' => $data['message'],
'post_checksum' => $data['message_md5'],
'post_encoding' => $user->lang['ENCODING'],
- 'post_attachment' => (isset($filename_data['physical_filename']) && sizeof($filename_data['physical_filename'])) ? 1 : 0,
+ 'post_attachment' => (isset($data['filename_data']['physical_filename']) && sizeof($data['filename_data']['physical_filename'])) ? 1 : 0, // sizeof($data['filename_data']['physical_filename'])
'bbcode_bitfield' => $data['bbcode_bitfield'],
- 'bbcode_uid' => $bbcode_uid,
+ 'bbcode_uid' => $data['bbcode_uid'],
'post_edit_locked' => $data['post_edit_locked']
);
break;
@@ -1305,15 +1334,15 @@ function submit_post($mode, $message, $subject, $username, $topic_type, $bbcode_
'post_edit_user' => (int) $data['post_edit_user'],
'post_checksum' => $data['message_md5'],
'post_encoding' => $user->lang['ENCODING'],
- 'post_attachment' => (isset($filename_data['physical_filename']) && sizeof($filename_data['physical_filename'])) ? 1 : 0,
+ 'post_attachment' => (isset($data['filename_data']['physical_filename']) && sizeof($data['filename_data']['physical_filename'])) ? 1 : 0,
'bbcode_bitfield' => $data['bbcode_bitfield'],
- 'bbcode_uid' => $bbcode_uid,
+ 'bbcode_uid' => $data['bbcode_uid'],
'post_edit_locked' => $data['post_edit_locked'])
);
if ($update_message)
{
- $sql_data[POSTS_TABLE]['sql']['post_text'] = $message;
+ $sql_data[POSTS_TABLE]['sql']['post_text'] = $data['message'];
}
break;
@@ -1333,7 +1362,7 @@ function submit_post($mode, $message, $subject, $username, $topic_type, $bbcode_
'topic_first_poster_name' => ($user->data['user_id'] == ANONYMOUS && $username) ? stripslashes($username) : $user->data['username'],
'topic_type' => $topic_type,
'topic_time_limit' => ($topic_type == POST_STICKY || $topic_type == POST_ANNOUNCE) ? ($data['topic_time_limit'] * 86400) : 0,
- 'topic_attachment' => (isset($filename_data['physical_filename']) && sizeof($filename_data['physical_filename'])) ? 1 : 0
+ 'topic_attachment' => (isset($data['filename_data']['physical_filename']) && sizeof($data['filename_data']['physical_filename'])) ? 1 : 0
);
if (isset($poll['poll_options']) && !empty($poll['poll_options']))
@@ -1379,7 +1408,7 @@ function submit_post($mode, $message, $subject, $username, $topic_type, $bbcode_
'poll_max_options' => ($poll['poll_options']) ? $poll['poll_max_options'] : 1,
'poll_length' => ($poll['poll_options']) ? $poll['poll_length'] * 86400 : 0,
- 'topic_attachment' => ($post_mode == 'edit_topic') ? ((sizeof($filename_data['physical_filename'])) ? 1 : 0) : $data['topic_attachment']
+ 'topic_attachment' => ($post_mode == 'edit_topic') ? ((sizeof($data['filename_data']['physical_filename'])) ? 1 : 0) : $data['topic_attachment']
);
break;
}
@@ -1539,11 +1568,11 @@ function submit_post($mode, $message, $subject, $username, $topic_type, $bbcode_
}
// Submit Attachments
- if (count($attach_data) && $data['post_id'] && in_array($mode, array('post', 'reply', 'quote', 'edit')))
+ if (sizeof($data['attachment_data']) && $data['post_id'] && in_array($mode, array('post', 'reply', 'quote', 'edit')))
{
$space_taken = $files_added = 0;
- foreach ($attach_data as $pos => $attach_row)
+ foreach ($data['attachment_data'] as $pos => $attach_row)
{
if ($attach_row['attach_id'])
{
@@ -1580,7 +1609,7 @@ function submit_post($mode, $message, $subject, $username, $topic_type, $bbcode_
}
}
- if (count($attach_data))
+ if (sizeof($data['attachment_data']))
{
$sql = 'UPDATE ' . POSTS_TABLE . '
SET post_attachment = 1
@@ -1675,10 +1704,10 @@ function submit_post($mode, $message, $subject, $username, $topic_type, $bbcode_
}
// Fulltext parse
- if ($data['message_md5'] != $data['post_checksum'] && $data['enable_indexing'])
+ if ($update_message && $data['enable_indexing'])
{
$search = new fulltext_search();
- $result = $search->add($mode, $data['post_id'], $message, $subject);
+ $result = $search->add($mode, $data['post_id'], $data['message'], $subject);
}
$db->sql_transaction('commit');
diff --git a/phpBB/report.php b/phpBB/report.php
index 3090b9a7d6..cd4727adfa 100644
--- a/phpBB/report.php
+++ b/phpBB/report.php
@@ -21,19 +21,19 @@ $user->start();
$auth->acl($user->data);
$user->setup('mcp');
-// var definitions
-$post_id = request_var('p', 0);
-$msg_id = request_var('pm', 0);
-$reason_id = request_var('reason_id', 0);
-$user_notify= (!empty($_REQUEST['notify']) && $user->data['user_id'] != ANONYMOUS) ? true : false;
-$report_text= request_var('report_text', '');
-
-if (!$post_id && !$msg_id)
+// Report PM or Post?
+$id = request_var('p', request_var('pm', 0));
+$report_post = (request_var('p', 0)) ? true : false;
+$reason_id = request_var('reason_id', 0);
+$user_notify = (!empty($_REQUEST['notify']) && $user->data['user_id'] != ANONYMOUS) ? true : false;
+$report_text = request_var('report_text', '');
+
+if (!$id)
{
- trigger_error('NO_MODE');
+ trigger_error('INVALID_MODE');
}
-$redirect_url = ($post_id) ? "{$phpbb_root_path}viewtopic.$phpEx$SID&p=$post_id#$post_id" : "{$phpbb_root_path}ucp.$phpEx$SID&i=pm&mode=view_messages&action=view_message&p=$msg_id";
+$redirect_url = ($report_post) ? "{$phpbb_root_path}viewtopic.$phpEx$SID&p=$id#$id" : "{$phpbb_root_path}ucp.$phpEx$SID&i=pm&p=$id";
// Has the report been cancelled?
if (isset($_POST['cancel']))
@@ -42,42 +42,39 @@ if (isset($_POST['cancel']))
}
// Grab all relevant data
-if ($post_id)
+if ($report_post)
{
$sql = 'SELECT f.*, t.*, p.*
FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . " f
- WHERE p.post_id = $post_id
+ WHERE p.post_id = $id
AND p.topic_id = t.topic_id
AND p.forum_id = f.forum_id";
}
-else if ($msg_id)
+else
{
// Only the user itself is able to report his Private Messages
$sql = 'SELECT p.*, t.*
FROM ' . PRIVMSGS_TABLE . ' p, ' . PRIVMSGS_TO_TABLE . " t
- WHERE t.msg_id = $msg_id
+ WHERE t.msg_id = $id
AND t.user_id = " . $user->data['user_id'] . '
AND t.msg_id = p.msg_id';
}
-else
-{
- trigger_error('INVALID_MODE');
-}
-
$result = $db->sql_query($sql);
if (!($report_data = $db->sql_fetchrow($result)))
{
- trigger_error($user->lang['POST_NOT_EXIST']);
+ $message = ($report_post) ? $user->lang['POST_NOT_EXIST'] : $user->lang['PM_NOT_EXIST'];
+ trigger_error($message);
}
-if ($post_id)
+if ($report_post)
{
$forum_id = $report_data['forum_id'];
$topic_id = $report_data['topic_id'];
// Check required permissions
$acl_check_ary = array('f_list' => 'POST_NOT_EXIST', 'f_read' => 'USER_CANNOT_READ', 'f_report' => 'USER_CANNOT_REPORT');
+
foreach ($acl_check_ary as $acl => $error)
{
if (!$auth->acl_get($acl, $forum_id))
@@ -98,7 +95,7 @@ else
// Check if the post has already been reported by this user
$sql = 'SELECT *
FROM ' . REPORTS_TABLE . '
- WHERE ' . (($post_id) ? "post_id = $post_id" : "msg_id = $msg_id") . '
+ WHERE ' . (($report_post) ? "post_id = $id" : "msg_id = $id") . '
AND user_id = ' . $user->data['user_id'];
$result = $db->sql_query($sql);
@@ -107,10 +104,9 @@ if ($row = $db->sql_fetchrow($result))
if ($user->data['user_id'] != ANONYMOUS)
{
// A report exists, extract $row if we're going to display the form
-
- if (!empty($_POST['reason_id']))
+ if ($reason_id)
{
- $report_id = intval($row['report_id']);
+ $report_id = (int) $row['report_id'];
}
else
{
@@ -120,7 +116,7 @@ if ($row = $db->sql_fetchrow($result))
}
else
{
- trigger_error($user->lang['ALREADY_REPORTED'] . '<br /><br />' . sprintf($user->lang[(($post_id) ? 'RETURN_TOPIC' : 'RETURN_MESSAGE')], '<a href="' . $redirect_url . '">', '</a>'));
+ trigger_error($user->lang['ALREADY_REPORTED'] . '<br /><br />' . sprintf($user->lang[(($report_post) ? 'RETURN_TOPIC' : 'RETURN_MESSAGE')], '<a href="' . $redirect_url . '">', '</a>'));
}
}
else
@@ -129,9 +125,9 @@ else
}
// Has the report been confirmed?
-if (!empty($_POST['reason_id']))
+if (isset($_POST['submit']) && $reason_id)
{
- $sql = 'SELECT reason_name
+ $sql = 'SELECT reason_name
FROM ' . REASONS_TABLE . "
WHERE reason_id = $reason_id";
$result = $db->sql_query($sql);
@@ -142,10 +138,12 @@ if (!empty($_POST['reason_id']))
}
$db->sql_freeresult($result);
+ $reason_desc = (!empty($user->lang['report_reasons']['DESCRIPTION'][$row['reason_name']])) ? $user->lang['report_reasons']['DESCRIPTION'][$row['reason_name']] : $row['reason_name'];
+
$sql_ary = array(
'reason_id' => (int) $reason_id,
- 'post_id' => (int) $post_id,
- 'msg_id' => (int) $msg_id,
+ 'post_id' => ($report_post) ? $id : 0,
+ 'msg_id' => ($report_post) ? 0 : $id,
'user_id' => (int) $user->data['user_id'],
'user_notify' => (int) $user_notify,
'report_time' => (int) time(),
@@ -164,57 +162,108 @@ if (!empty($_POST['reason_id']))
$sql = 'INSERT INTO ' . REPORTS_TABLE . ' ' .
$db->sql_build_array('INSERT', $sql_ary);
$db->sql_query($sql);
+ $report_id = $db->sql_nextid();
}
- if ($post_id)
+ if ($report_post)
{
- if (!$row['post_reported'])
+ if (!$report_data['post_reported'])
{
$sql = 'UPDATE ' . POSTS_TABLE . '
SET post_reported = 1
- WHERE post_id = ' . $post_id;
+ WHERE post_id = ' . $id;
$db->sql_query($sql);
}
- if (!$row['topic_reported'])
+ if (!$report_data['topic_reported'])
{
$sql = 'UPDATE ' . TOPICS_TABLE . '
SET topic_reported = 1
- WHERE topic_id = ' . $topic_id;
+ WHERE topic_id = ' . $report_data['topic_id'];
$db->sql_query($sql);
}
}
else
{
- if (!$row['message_reported'])
+ if (!$report_data['message_reported'])
{
$sql = 'UPDATE ' . PRIVMSGS_TABLE . "
SET message_reported = 1
- WHERE msg_id = $msg_id";
+ WHERE msg_id = $id";
$db->sql_query($sql);
}
}
- meta_refresh(3, $redirect_url);
+ // Send Notifications
+ // PM: Reported Post is put into all admin's boxes (not notifying about 'this' PM)
+ // All persons get notified about a new report, if notified by PM, send out email notifications too
+
+ // Send notifications to moderators
+ $acl_list = ($report_post) ? $auth->acl_get_list(false, array('m_', 'a_'), array(0, $report_data['forum_id'])) : $auth->acl_get_list(false, 'a_', 0);
+ $notify_user = ($report_post) ? $acl_list[$report_data['forum_id']]['m_'] : array();
+ $notify_user = array_unique(array_merge($notify_user, $acl_list[0]['a_']));
+ unset($acl_list);
+
+ // Send reported PM to responsible persons (admins)
+ if (!$report_post)
+ {
+ foreach ($notify_user as $user_id)
+ {
+ $db->sql_query('INSERT INTO ' . PRIVMSGS_TO_TABLE . ' ' . $db->sql_build_array('INSERT', array(
+ 'msg_id' => (int) $id,
+ 'user_id' => (int) $user_id,
+ 'author_id' => (int) $report_data['author_id'],
+ 'folder_id' => PRIVMSGS_NO_BOX,
+ 'new' => 1,
+ 'unread' => 1,
+ 'forwarded' => 0))
+ );
+ }
- $message = $user->lang[(($post_id) ? 'POST' : 'MESSAGE') . '_REPORTED_SUCCESS'] . '<br /><br />' . sprintf($user->lang[(($post_id) ? 'RETURN_TOPIC' : 'RETURN_MESSAGE')], '<a href="' . $redirect_url . '">', '</a>');
- trigger_error($message);
+ // Update Status
+ $sql = 'UPDATE ' . USERS_TABLE . '
+ SET user_new_privmsg = user_new_privmsg + 1, user_unread_privmsg = user_unread_privmsg + 1
+ WHERE user_id IN (' . implode(', ', $notify_user) . ')';
+ $db->sql_query($sql);
+ }
- // Which moderators are responsible for private messages? ;)
- /*
- $db->sql_query('INSERT INTO ' . PRIVMSGS_TO_TABLE . ' ' . $db->sql_build_array('INSERT', array(
- 'msg_id' => (int) $msg_id,
- 'user_id' => (int) $moderator_id,
- 'author_id' => (int) $row['author_id'],
- 'folder_id' => PRIVMSGS_NO_BOX,
- 'new' => 1,
- 'unread' => 1,
- 'forwarded' => 0,
- 'reported' => 1)
+ // How to notify them?
+ $sql = 'SELECT user_id, username, user_options, user_lang, user_email, user_notify_type, user_jabber
+ FROM ' . USERS_TABLE . '
+ WHERE user_id IN (' . implode(', ', $notify_user) . ')';
+ $result = $db->sql_query($sql);
+
+ $notify_user = array();
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $notify_user[$row['user_id']] = array(
+ 'name' => $row['username'],
+ 'email' => $row['user_email'],
+ 'jabber'=> $row['user_jabber'],
+ 'lang' => $row['user_lang'],
+ 'notify_type' => $row['user_notify_type'],
+
+ 'pm' => $user->optionget('report_pm_notify', $row['user_options'])
);
- */
-
- // TODO: warn moderators or something ;)
+ }
+ $db->sql_freeresult($result);
+
+ $report_data = array(
+ 'id' => $id,
+ 'report_id' => $report_id,
+ 'reporter' => $user->data['username'],
+ 'reason' => $reason_desc,
+ 'text' => $report_text,
+ 'subject' => ($report_post) ? $report_data['post_subject'] : $report_data['message_subject'],
+ 'view_post' => ($report_post) ? "viewtopic.$phpEx?f={$report_data['forum_id']}&t={$report_data['topic_id']}&p=$id&e=$id" : ''
+ );
+
+ report_notification($notify_user, $report_post, $report_data);
+
+ meta_refresh(3, $redirect_url);
+
+ $message = $user->lang[(($report_post) ? 'POST' : 'MESSAGE') . '_REPORTED_SUCCESS'] . '<br /><br />' . sprintf($user->lang[(($report_post) ? 'RETURN_TOPIC' : 'RETURN_MESSAGE')], '<a href="' . $redirect_url . '">', '</a>');
+ trigger_error($message);
}
@@ -236,27 +285,29 @@ while ($row = $db->sql_fetchrow($result))
'ID' => $row['reason_id'],
'NAME' => htmlspecialchars($reason_title),
'DESCRIPTION' => htmlspecialchars($reason_desc),
- 'S_SELECTED' => ($row['reason_id'] == $reason_id) ? TRUE : FALSE
- ));
+ 'S_SELECTED' => ($row['reason_id'] == $reason_id) ? true : false)
+ );
}
-$u_report = ($post_id) ? "p=$post_id" : "pm=$msg_id";
+$u_report = ($report_post) ? "p=$id" : "pm=$id";
$template->assign_vars(array(
- 'REPORT_TEXT' => $report_text,
- 'S_REPORT_ACTION' => "report.$phpEx$SID&amp;$u_report" . (($report_id) ? "&amp;report_id=$report_id" : ''),
+ 'REPORT_TEXT' => $report_text,
+ 'S_REPORT_ACTION' => "{$phpbb_root_path}report.$phpEx$SID&amp;$u_report" . (($report_id) ? "&amp;report_id=$report_id" : ''),
- 'S_NOTIFY' => (!empty($user_notify)) ? TRUE : FALSE,
- 'S_CAN_NOTIFY' => ($user->data['user_id'] == ANONYMOUS) ? FALSE : TRUE)
+ 'S_NOTIFY' => (!empty($user_notify)) ? true : false,
+ 'S_CAN_NOTIFY' => ($user->data['user_id'] == ANONYMOUS) ? false : true,
+ 'S_REPORT_POST' => $report_post)
);
-if ($post_id)
+if ($report_post)
{
generate_forum_nav($report_data);
}
// Start output of page
-page_header($user->lang['REPORT_POST']);
+$page_title = ($report_post) ? $user->lang['REPORT_POST'] : $user->lang['REPORT_MESSAGE'];
+page_header($page_title);
$template->set_filenames(array(
'body' => 'report_body.html')
@@ -264,4 +315,92 @@ $template->set_filenames(array(
page_footer();
+function report_notification($notify_user, $report_post, $report_data)
+{
+ global $config, $phpbb_root_path, $phpEx;
+
+ include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
+ include_once($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx);
+ $messenger = new messenger();
+
+ $email_sig = str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']);
+ $email_template = ($report_post) ? 'new_report_post' : 'new_report_pm';
+ $view_report_url = ($report_post) ? "mcp.$phpEx?i=queue&r=" . $report_data['report_id'] : "ucp.$phpEx?i=pm&p=" . $report_data['id'] . "&r=" . $report_data['report_id'];
+
+ foreach ($notify_user as $user_id => $notify_row)
+ {
+ // Send notification by email
+ if (!$notify_row['pm'])
+ {
+ $messenger->to($notify_row['email'], $notify_row['name']);
+ $messenger->im($notify_row['jabber'], $notify_row['name']);
+ $messenger->replyto($config['board_email']);
+
+ $messenger->template($email_template, $notify_row['lang']);
+
+ $messenger->assign_vars(array(
+ 'EMAIL_SIG' => $email_sig,
+ 'SITENAME' => $config['sitename'],
+ 'USERNAME' => $notify_row['name'],
+ 'SUBJECT' => $report_data['subject'],
+ 'REPORTER' => $report_data['reporter'],
+
+ 'REPORT_REASON' => $report_data['reason'],
+ 'REPORT_TEXT' => $report_data['text'],
+
+ 'U_VIEW_REPORT' => generate_board_url() . '/' . $view_report_url,
+ 'U_VIEW_POST' => generate_board_url() . '/' . $report_data['view_post'])
+ );
+
+ $messenger->send($notify_row['notify_type']);
+ $messenger->reset();
+
+ if ($messenger->queue)
+ {
+ $messenger->queue->save();
+ }
+ }
+ else
+ {
+ // Use messenger for getting the correct message, we use the email template
+ $messenger->template($email_template, $notify_row['lang']);
+
+ $messenger->assign_vars(array(
+ 'EMAIL_SIG' => $email_sig,
+ 'SITENAME' => $config['sitename'],
+ 'USERNAME' => $notify_row['name'],
+ 'SUBJECT' => $report_data['subject'],
+ 'REPORTER' => $report_data['reporter'],
+
+ 'REPORT_REASON' => $report_data['reason'],
+ 'REPORT_TEXT' => $report_data['text'],
+
+ 'U_VIEW_REPORT' => generate_board_url() . '/' . $view_report_url)
+ );
+
+ // break the sending process...
+ $messenger->send(false, true);
+ $messenger->reset();
+
+ // do not put in reporters outbox
+ submit_pm('post', $report_data['subject'], '', array(), array(), array(
+ 'address_list' => array('u' => array($user_id => 'to')),
+ 'icon_id' => 0,
+ 'enable_bbcode' => 0,
+ 'enable_html' => 0,
+ 'enable_smilies' => 0,
+ 'enable_magic_url' => 1,
+ 'enable_sig' => 0,
+ 'message_md5' => md5($messenger->msg),
+ 'bbcode_bitfield' => 0,
+ 'bbcode_uid' => 0,
+ 'attachment_data' => array(),
+ 'filename_data' => array(),
+ 'message' => $messenger->msg
+ ), true, false);
+ }
+ }
+ unset($messenger);
+}
+
?> \ No newline at end of file
diff --git a/phpBB/styles/subSilver/template/report_body.html b/phpBB/styles/subSilver/template/report_body.html
index ee9cc3987c..dac3fdc28c 100644
--- a/phpBB/styles/subSilver/template/report_body.html
+++ b/phpBB/styles/subSilver/template/report_body.html
@@ -5,10 +5,10 @@
<form method="post" action="{S_REPORT_ACTION}" name="report">
<table class="tablebg" width="100%" cellspacing="1">
<tr>
- <th colspan="2">{L_REPORT_POST}</th>
+ <th colspan="2"><!-- IF S_REPORT_POST -->{L_REPORT_POST}<!-- ELSE -->{L_REPORT_MESSAGE}<!-- ENDIF --></th>
</tr>
<tr>
- <td class="row3" colspan="2"><span class="gensmall">{L_REPORT_POST_EXPLAIN}</span></td>
+ <td class="row3" colspan="2"><span class="gensmall"><!-- IF S_REPORT_POST -->{L_REPORT_POST_EXPLAIN}<!-- ELSE -->{L_REPORT_MESSAGE_EXPLAIN}<!-- ENDIF --></span></td>
</tr>
<tr>
<td class="row1" width="22%"><b class="gen">{L_REASON}:</b></td>
diff --git a/phpBB/styles/subSilver/template/ucp_header.html b/phpBB/styles/subSilver/template/ucp_header.html
index 31905d4b3e..4c2b8e9fba 100644
--- a/phpBB/styles/subSilver/template/ucp_header.html
+++ b/phpBB/styles/subSilver/template/ucp_header.html
@@ -134,4 +134,4 @@
</td>
<td><img src="images/spacer.gif" width="4" alt="" /></td>
- <td width="80%" valign="top"><!-- IF not S_PRIVMSGS --><form name="ucp" method="post" action="{S_UCP_ACTION}"><!-- ENDIF -->
+ <td width="80%" valign="top"><!-- IF not S_PRIVMSGS --><form name="ucp" method="post" action="{S_UCP_ACTION}"{S_FORM_ENCTYPE}><!-- ENDIF -->
diff --git a/phpBB/styles/subSilver/template/ucp_prefs_personal.html b/phpBB/styles/subSilver/template/ucp_prefs_personal.html
index 4dc19db1a1..6d3464b24e 100644
--- a/phpBB/styles/subSilver/template/ucp_prefs_personal.html
+++ b/phpBB/styles/subSilver/template/ucp_prefs_personal.html
@@ -44,6 +44,10 @@
<td class="row2"><input type="radio" name="popuppm" value="1"{POPUP_PM_YES} /><span class="genmed">{L_YES}</span>&nbsp;&nbsp;<input type="radio" name="popuppm" value="0"{POPUP_PM_NO} /><span class="genmed">{L_NO}</span></td>
</tr>
<tr>
+ <td class="row1" width="50%"><b class="genmed">{L_REPORT_PM_NOTIFY}:</b><br /><span class="gensmall">{L_REPORT_PM_NOTIFY_EXPLAIN}</span></td>
+ <td class="row2"><input type="radio" name="report_pm_notify" value="1"{REPORT_PM_YES} /><span class="genmed">{L_YES}</span>&nbsp;&nbsp;<input type="radio" name="report_pm_notify" value="0"{REPORT_PM_NO} /><span class="genmed">{L_NO}</span></td>
+ </tr>
+ <tr>
<td class="row1" width="50%"><b class="genmed">{L_BOARD_LANGUAGE}:</b></td>
<td class="row2"><select name="lang">{S_LANG_OPTIONS}</select></td>
</tr>
diff --git a/phpBB/styles/subSilver/template/ucp_profile_avatar.html b/phpBB/styles/subSilver/template/ucp_profile_avatar.html
index ed17adc228..aa8c4f1d06 100644
--- a/phpBB/styles/subSilver/template/ucp_profile_avatar.html
+++ b/phpBB/styles/subSilver/template/ucp_profile_avatar.html
@@ -48,7 +48,7 @@
<th colspan="2">{L_AVATAR_GALLERY}</th>
</tr>
<tr>
- <td class="cat" colspan="2" align="center" valign="middle"><span class="genmed">{L_AVATAR_CATEGORY}: </span><select name="avatarcat">{S_CAT_OPTIONS}</select>&nbsp; <span class="genmed">{L_AVATAR_PAGE}: </span><select name="avatarpage">{S_PAGE_OPTIONS}</select>&nbsp;<input class="btnlite" type="submit" value="{L_GO}" name="avatargallery" /></td>
+ <td class="cat" colspan="2" align="center" valign="middle"><span class="genmed">{L_AVATAR_CATEGORY}: </span><select name="category">{S_CAT_OPTIONS}</select>&nbsp; <span class="genmed">{L_AVATAR_PAGE}: </span><select name="page">{S_PAGE_OPTIONS}</select>&nbsp;<input class="btnlite" type="submit" value="{L_GO}" name="displaygallery" /></td>
</tr>
<tr>
<td class="row1" colspan="2" align="center"><table cellspacing="1" cellpadding="4" border="0">
diff --git a/phpBB/viewonline.php b/phpBB/viewonline.php
index 9bc3819574..98c47157bd 100644
--- a/phpBB/viewonline.php
+++ b/phpBB/viewonline.php
@@ -107,7 +107,7 @@ while ($row = $db->sql_fetchrow($result))
if (!$row['user_allow_viewonline'] || !$row['session_viewonline'])
{
- $view_online = ($auth->acl_gets('u_viewonline')) ? true : false;
+ $view_online = ($auth->acl_get('u_viewonline')) ? true : false;
$logged_hidden_online++;
$username = '<i>' . $username . '</i>';
diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php
index 847194c06b..589c414bbb 100644
--- a/phpBB/viewtopic.php
+++ b/phpBB/viewtopic.php
@@ -172,7 +172,7 @@ if ($user->data['user_id'] != ANONYMOUS)
// whereupon we join on the forum_id passed as a parameter ... this
// is done so navigation, forum name, etc. remain consistent with where
// user clicked to view a global topic
-$sql = 'SELECT t.topic_id, t.forum_id, t.topic_title, t.topic_attachment, t.topic_status, t.topic_approved, t.topic_replies_real, t.topic_replies, t.topic_last_post_id, t.topic_last_poster_id, t.topic_last_post_time, t.topic_poster, t.topic_time, t.topic_time_limit, t.topic_type, t.topic_bumped, t.topic_bumper, t.poll_max_options, t.poll_start, t.poll_length, t.poll_title, f.forum_name, f.forum_desc, f.forum_parents, f.parent_id, f.left_id, f.right_id, f.forum_status, f.forum_type, f.forum_id, f.forum_style, f.forum_password, f.forum_rules, f.forum_rules_link, f.forum_rules_flags' . $extra_fields . '
+$sql = 'SELECT t.topic_id, t.forum_id, t.topic_title, t.topic_attachment, t.topic_status, t.topic_approved, t.topic_replies_real, t.topic_replies, t.topic_last_post_id, t.topic_last_poster_id, t.topic_last_post_time, t.topic_poster, t.topic_time, t.topic_time_limit, t.topic_type, t.topic_bumped, t.topic_bumper, t.poll_max_options, t.poll_start, t.poll_length, t.poll_title, f.forum_name, f.forum_desc, f.forum_parents, f.parent_id, f.left_id, f.right_id, f.forum_status, f.forum_type, f.forum_id, f.forum_style, f.forum_password, f.forum_rules, f.forum_rules_link, f.forum_rules_flags, f.forum_rules_bbcode_uid, f.forum_rules_bbcode_bitfield' . $extra_fields . '
FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . ' f' . $join_sql_table . "
WHERE $join_sql
AND (f.forum_id = t.forum_id