diff options
Diffstat (limited to 'phpBB/posting.php')
-rw-r--r-- | phpBB/posting.php | 230 |
1 files changed, 6 insertions, 224 deletions
diff --git a/phpBB/posting.php b/phpBB/posting.php index a9de09ddbe..8368584767 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -415,6 +415,7 @@ if ($save && $user->data['user_id'] != ANONYMOUS && $auth->acl_get('u_savedrafts $subject = (!$subject && $mode != 'post') ? $topic_title : $subject; $message = (isset($_POST['message'])) ? htmlspecialchars(trim(str_replace(array('\\\'', '\\"', '\\0', '\\\\'), array('\'', '"', '\0', '\\'), $_POST['message']))) : ''; $message = preg_replace('#&(\#[0-9]+;)#', '&\1', $message); +// $message = request_var('message', '', true, true); if ($subject && $message) { @@ -473,17 +474,19 @@ if ($load && $drafts) 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) { $subject = phpbb_strtolower($subject); } - $subject = preg_replace('#&(\#[0-9]+;)#', '&\1', $subject); - $message_parser->message = (isset($_POST['message'])) ? htmlspecialchars(str_replace(array('\\\'', '\\"', '\\0', '\\\\'), array('\'', '"', '\0', '\\'), $_POST['message'])) : ''; $message_parser->message = preg_replace('#&(\#[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', '') : ''; @@ -790,7 +793,7 @@ if (!sizeof($error) && $preview) format_display($preview_message, $preview_signature, $message_parser->bbcode_uid, $preview_signature_uid, $enable_html, $enable_bbcode, $enable_urls, $enable_smilies, $enable_sig); // 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))) + 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); @@ -1050,227 +1053,6 @@ page_footer(); // FUNCTIONS // - -// User Notification -function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id, $topic_id, $post_id) -{ - global $db, $user, $config, $phpbb_root_path, $phpEx, $auth; - - $topic_notification = ($mode == 'reply' || $mode == 'quote'); - $forum_notification = ($mode == 'post'); - - if (!$topic_notification && !$forum_notification) - { - trigger_error('WRONG_NOTIFICATION_MODE'); - } - - $topic_title = ($topic_notification) ? $topic_title : $subject; - decode_text($topic_title); - $topic_title = censor_text($topic_title); - - // Get banned User ID's - $sql = 'SELECT ban_userid - FROM ' . BANLIST_TABLE; - $result = $db->sql_query($sql); - - $sql_ignore_users = ANONYMOUS . ', ' . $user->data['user_id']; - while ($row = $db->sql_fetchrow($result)) - { - if (isset($row['ban_userid'])) - { - $sql_ignore_users .= ', ' . $row['ban_userid']; - } - } - $db->sql_freeresult($result); - - $notify_rows = array(); - - // -- get forum_userids || topic_userids - $sql = 'SELECT u.user_id, u.username, u.user_email, u.user_lang, u.user_notify_type, u.user_jabber - FROM ' . (($topic_notification) ? TOPICS_WATCH_TABLE : FORUMS_WATCH_TABLE) . ' w, ' . USERS_TABLE . ' u - WHERE w.' . (($topic_notification) ? 'topic_id' : 'forum_id') . ' = ' . (($topic_notification) ? $topic_id : $forum_id) . " - AND w.user_id NOT IN ($sql_ignore_users) - AND w.notify_status = 0 - AND u.user_id = w.user_id"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $notify_rows[$row['user_id']] = array( - 'user_id' => $row['user_id'], - 'username' => $row['username'], - 'user_email' => $row['user_email'], - 'user_jabber' => $row['user_jabber'], - 'user_lang' => $row['user_lang'], - 'notify_type' => ($topic_notification) ? 'topic' : 'forum', - 'template' => ($topic_notification) ? 'topic_notify' : 'newtopic_notify', - 'method' => $row['user_notify_type'], - 'allowed' => false - ); - } - $db->sql_freeresult($result); - - // forum notification is sent to those not receiving post notification - if ($topic_notification) - { - if (sizeof($notify_rows)) - { - $sql_ignore_users .= ', ' . implode(', ', array_keys($notify_rows)); - } - - $sql = 'SELECT u.user_id, u.username, u.user_email, u.user_lang, u.user_notify_type, u.user_jabber - FROM ' . FORUMS_WATCH_TABLE . ' fw, ' . USERS_TABLE . " u - WHERE fw.forum_id = $forum_id - AND fw.user_id NOT IN ($sql_ignore_users) - AND fw.notify_status = 0 - AND u.user_id = fw.user_id"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $notify_rows[$row['user_id']] = array( - 'user_id' => $row['user_id'], - 'username' => $row['username'], - 'user_email' => $row['user_email'], - 'user_jabber' => $row['user_jabber'], - 'user_lang' => $row['user_lang'], - 'notify_type' => 'forum', - 'template' => 'forum_notify', - 'method' => $row['user_notify_type'], - 'allowed' => false - ); - } - $db->sql_freeresult($result); - } - - if (!sizeof($notify_rows)) - { - return; - } - - foreach ($auth->acl_get_list(array_keys($notify_rows), 'f_read', $forum_id) as $forum_id => $forum_ary) - { - foreach ($forum_ary as $auth_option => $user_ary) - { - foreach ($user_ary as $user_id) - { - $notify_rows[$user_id]['allowed'] = true; - } - } - } - - - // Now, we have to do a little step before really sending, we need to distinguish our users a little bit. ;) - $msg_users = $delete_ids = $update_notification = array(); - foreach ($notify_rows as $user_id => $row) - { - if (!$row['allowed'] || !trim($row['user_email'])) - { - $delete_ids[$row['notify_type']][] = $row['user_id']; - } - else - { - $msg_users[] = $row; - $update_notification[$row['notify_type']][] = $row['user_id']; - } - } - unset($notify_rows); - - // Now, we are able to really send out notifications - if (sizeof($msg_users)) - { - include_once($phpbb_root_path . 'includes/functions_messenger.'.$phpEx); - $messenger = new messenger(); - - $email_sig = str_replace('<br />', "\n", "-- \n" . $config['board_email_sig']); - - $msg_list_ary = array(); - foreach ($msg_users as $row) - { - $pos = sizeof($msg_list_ary[$row['template']]); - - $msg_list_ary[$row['template']][$pos]['method'] = $row['method']; - $msg_list_ary[$row['template']][$pos]['email'] = $row['user_email']; - $msg_list_ary[$row['template']][$pos]['jabber'] = $row['user_jabber']; - $msg_list_ary[$row['template']][$pos]['name'] = $row['username']; - $msg_list_ary[$row['template']][$pos]['lang'] = $row['user_lang']; - } - unset($msg_users); - - foreach ($msg_list_ary as $email_template => $email_list) - { - foreach ($email_list as $addr) - { - $messenger->template($email_template, $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'], - 'USERNAME' => $addr['name'], - 'TOPIC_TITLE' => $topic_title, - 'FORUM_NAME' => $forum_name, - - 'U_FORUM' => generate_board_url() . "/viewforum.$phpEx?f=$forum_id&e=0", - 'U_TOPIC' => generate_board_url() . "/viewtopic.$phpEx?f=$forum_id&t=$topic_id&e=0", - 'U_NEWEST_POST' => generate_board_url() . "/viewtopic.$phpEx?f=$forum_id&t=$topic_id&p=$post_id&e=$post_id", - 'U_STOP_WATCHING_TOPIC' => generate_board_url() . "/viewtopic.$phpEx?f=$forum_id&t=$topic_id&unwatch=topic", - 'U_STOP_WATCHING_FORUM' => generate_board_url() . "/viewforum.$phpEx?f=$forum_id&unwatch=forum", - )); - - $messenger->send($addr['method']); - $messenger->reset(); - } - } - unset($msg_list_ary); - - if ($messenger->queue) - { - $messenger->queue->save(); - } - } - - // Handle the DB updates - $db->sql_transaction(); - - if (sizeof($update_notification['topic'])) - { - $db->sql_query('UPDATE ' . TOPICS_WATCH_TABLE . " - SET notify_status = 1 - WHERE topic_id = $topic_id - AND user_id IN (" . implode(', ', $update_notification['topic']) . ")"); - } - - if (sizeof($update_notification['forum'])) - { - $db->sql_query('UPDATE ' . FORUMS_WATCH_TABLE . " - SET notify_status = 1 - WHERE forum_id = $forum_id - AND user_id IN (" . implode(', ', $update_notification['forum']) . ")"); - } - - // Now delete the user_ids not authorized to receive notifications on this topic/forum - if (sizeof($delete_ids['topic'])) - { - $db->sql_query('DELETE FROM ' . TOPICS_WATCH_TABLE . " - WHERE topic_id = $topic_id - AND user_id IN (" . implode(', ', $delete_ids['topic']) . ")"); - } - - if (sizeof($delete_ids['forum'])) - { - $db->sql_query('DELETE FROM ' . FORUMS_WATCH_TABLE . " - WHERE forum_id = $forum_id - AND user_id IN (" . implode(', ', $delete_ids['forum']) . ")"); - } - - $db->sql_transaction('commit'); - -} - // Delete Post function delete_post($mode, $post_id, $topic_id, $forum_id, $data) { |