diff options
Diffstat (limited to 'phpBB/includes')
-rw-r--r-- | phpBB/includes/bbcode.php | 26 | ||||
-rw-r--r-- | phpBB/includes/functions.php | 61 | ||||
-rw-r--r-- | phpBB/includes/functions_messenger.php | 7 | ||||
-rw-r--r-- | phpBB/includes/functions_posting.php | 163 | ||||
-rw-r--r-- | phpBB/includes/functions_privmsgs.php | 376 | ||||
-rw-r--r-- | phpBB/includes/functions_profile_fields.php | 2 | ||||
-rw-r--r-- | phpBB/includes/functions_user.php | 12 | ||||
-rw-r--r-- | phpBB/includes/message_parser.php | 465 | ||||
-rw-r--r-- | phpBB/includes/session.php | 33 | ||||
-rw-r--r-- | phpBB/includes/ucp/ucp_pm.php | 2 | ||||
-rw-r--r-- | phpBB/includes/ucp/ucp_pm_compose.php | 475 | ||||
-rw-r--r-- | phpBB/includes/ucp/ucp_pm_options.php | 12 | ||||
-rw-r--r-- | phpBB/includes/ucp/ucp_pm_viewfolder.php | 4 | ||||
-rw-r--r-- | phpBB/includes/ucp/ucp_prefs.php | 18 | ||||
-rw-r--r-- | phpBB/includes/ucp/ucp_profile.php | 128 |
15 files changed, 924 insertions, 860 deletions
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", ' ', $code); $code = str_replace(' ', ' ', $code); $code = str_replace(' ', ' ', $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 . '&start=' . (($total_pages - 1) * $per_page) . '">' . $total_pages . '</a> <a href="' . $base_url . "&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]*?&?#', "#([\n][\s]+){3,}#", '#&(\#[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', '<$1$2>', $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', '<$1$2>', $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]*?&?#', "#([\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('#<(\/?)(' . str_replace('*', '.*?', implode('|', $allowed_tags)) . ')>#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 < (<) to <&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 < sequence within the text. - Replacing with <&lt; and switching back thereafter produces no problems, because < will never show up with &lt; in - the same text (due to this specialcharing). The < is put in front of &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;', $this->message)); - $this->message = str_replace('<&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('<', '>', '[', ']', '.'); - $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', '[$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]*?&?#', "#([\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('#<(\/?)(' . str_replace('*', '.*?', implode('|', $allowed_tags)) . ')>#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 < (<) to <&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 < sequence within the text. + Replacing with <&lt; and switching back thereafter produces no problems, because < will never show up with &lt; in + the same text (due to this specialcharing). The < is put in front of &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;', $this->message)); + $this->message = str_replace('<&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&i=$id&mode=$mode&action=$action") + 'S_UCP_ACTION' => "{$phpbb_root_path}ucp.$phpEx$SID&i=$id&mode=$mode" . ((isset($action)) ? "&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}&i=$id&mode=$mode&action=$action"; $s_action .= ($msg_id) ? "&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&i=pm&mode=view_messages&action=view_message&p=" . $data['msg_id']; + $return_folder_url = "{$phpbb_root_path}ucp.$phpEx$SID&i=pm&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&mode=bbcode" . '" target="_phpbbcode">', '</a>') : sprintf($user->lang['BBCODE_IS_OFF'], '<a href="' . "faq.$phpEx$SID&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&i=pm&mode=view_messages&action=view_message&p=" . $data['msg_id']; - $return_folder_url = "{$phpbb_root_path}ucp.$phpEx$SID&i=pm&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}&mode=mod_queue&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&i=$id&mode=$mode\">", '</a>'); - trigger_error($message); + $message = $user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], "<a href=\"ucp.$phpEx$SID&i=$id&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&mode=bbcode" . '" target="_phpbbcode">', '</a>') : sprintf($user->lang['BBCODE_IS_OFF'], '<a href="' . "faq.$phpEx$SID&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&mode=bbcode" . '" target="_phpbbcode">', '</a>') : sprintf($user->lang['BBCODE_IS_OFF'], '<a href="' . "faq.$phpEx$SID&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 { |