$topic_type = $topic_type != $post_data['topic_type'] && !$is_auth['auth_sticky'] && !$is_auth['auth_announce'] ? $post_data['topic_type'] : $topic_type; submit_post($mode, $post_data, $return_message, $return_meta, $forum_id, $topic_id, $post_id, $poll_id, $topic_type, $bbcode_on, $html_on, $smilies_on, $attach_sig, $bbcode_uid, str_replace("\\'", "''", $username), str_replace("\\'", "''", $subject), str_replace("\\'", "''", $message), str_replace("\\'", "''", $poll_title), $poll_options, $poll_length); } break; case 'delete': case 'poll_delete': if ($error_msg != '') { message_die(GENERAL_MESSAGE, $error_msg); } delete_post($mode, $post_data, $return_message, $return_meta, $forum_id, $topic_id, $post_id, $poll_id); break; } if ($error_msg == '') { if ($mode != 'editpost') { $user_id = $mode == 'reply' || $mode == 'newtopic' ? $userdata['user_id'] : $post_data['poster_id']; update_post_stats($mode, $post_data, $forum_id, $topic_id, $post_id, $user_id); } if ($error_msg == '' && $mode != 'poll_delete') { user_notification($mode, $post_data, $post_info['topic_title'], $forum_id, $topic_id, $post_id, $notify_user); } if ($mode == 'newtopic' || $mode == 'reply') { $tracking_topics = !empty($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) : array(); $tracking_forums = !empty($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) : array(); if (count($tracking_topics) + count($tracking_forums) == 100 && empty($tracking_topics[$topic_id])) { asort($tracking_topics); unset($tracking_topics[key($tracking_topics)]); } $tracking_topics[$topic_id] = time(); setcookie($board_config['cookie_name'] . '_t', serialize($tracking_topics), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']); } $template->assign_vars(array('META' => $return_meta));
$last_msg = DB()->escape($row['post_text']); if ($last_msg == $message) { $this->ajax_die($lang['DOUBLE_POST_ERROR']); } } } if ($bb_cfg['max_smilies']) { $count_smilies = substr_count(bbcode2html($message), '<img class="smile" src="' . $bb_cfg['smilies_path']); if ($count_smilies > $bb_cfg['max_smilies']) { $this->ajax_die(sprintf($lang['MAX_SMILIES_PER_POST'], $bb_cfg['max_smilies'])); } } DB()->sql_query("INSERT INTO " . BB_POSTS . " (topic_id, forum_id, poster_id, post_time, poster_ip) VALUES ({$topic_id}, " . $post['forum_id'] . ", " . $userdata['user_id'] . ", '" . TIMENOW . "', '" . USER_IP . "')"); $post_id = DB()->sql_nextid(); DB()->sql_query("INSERT INTO " . BB_POSTS_TEXT . " (post_id, post_text) VALUES ({$post_id}, '" . DB()->escape($message) . "')"); update_post_stats('reply', $post, $post['forum_id'], $topic_id, $post_id, $userdata['user_id']); $s_message = str_replace('\\n', "\n", $message); $s_topic_title = str_replace('\\n', "\n", $post['topic_title']); add_search_words($post_id, stripslashes($s_message), stripslashes($s_topic_title)); update_post_html(array('post_id' => $post_id, 'post_text' => $message)); if ($bb_cfg['topic_notify_enabled']) { $notify = !empty($this->request['notify']); user_notification('reply', $post, $post['topic_title'], $post['forum_id'], $topic_id, $notify); } // Update atom feed update_atom('topic', (int) $this->request['topic_id']); $this->response['redirect'] = make_url(POST_URL . "{$post_id}#{$post_id}"); break; default: $this->ajax_die('empty type'); break;
function phpbb_insert_reply($topic_id = null, $username = null, $subject = null, $message = null) { global $CFG, $userdata, $phpbb_root_path, $phpEx; include_once $phpbb_root_path . 'includes/functions_post.' . $phpEx; if (empty($username)) { phpbb_raise_error('Username must not be empty.'); } if (empty($subject)) { phpbb_raise_error('Subject must not be empty.'); } if (empty($message)) { phpbb_raise_error('Message must not be empty.'); } if (empty($topic_id)) { phpbb_raise_error('Topic does not exists.'); } $sql = 'SELECT f.*, t.topic_status, t.topic_title FROM ' . FORUMS_TABLE . ' f, ' . TOPICS_TABLE . ' t WHERE t.topic_id = ' . $topic_id . ' AND f.forum_id = t.forum_id'; $result = phpbb_fetch_row($sql); if ($result) { $forum_id = $result['forum_id']; $forum_name = $result['forum_name']; } else { phpbb_raise_error('Forum does not exists.', __FILE__, __LINE__, $sql); } // // save the username and override it for assigning the post to the given // user // $old_username = $userdata['user_id']; $userdata['user_id'] = $username; $error_msg = ''; $return_message = ''; $return_meta = ''; $mode = 'reply'; $post_data = array(); $bbcode_on = TRUE; $html_on = TRUE; $smilies_on = 0; $poll_title = ''; $poll_options = ''; $poll_length = ''; $bbcode_uid = ''; $attach_sig = 0; prepare_post($mode, $post_data, $bbcode_on, $html_on, $smilies_on, $error_msg, $username, $bbcode_uid, $subject, $message, $poll_title, $poll_options, $poll_length); if ($error_msg == '') { $topic_type = POST_NORMAL; submit_post($mode, $post_data, $return_message, $return_meta, $forum_id, $topic_id, $post_id, $poll_id, $topic_type, $bbcode_on, $html_on, $smilies_on, $attach_sig, $bbcode_uid, str_replace("\\'", "''", $username), str_replace("\\'", "''", $subject), str_replace("\\'", "''", $message), str_replace("\\'", "''", $poll_title), $poll_options, $poll_length); if ($error_msg == '') { update_post_stats($mode, $post_data, $forum_id, $topic_id, $post_id, $username); if ($error_msg != '') { phpbb_raise_error($error_msg); } add_search_words('single', $post_id, stripslashes($message), stripslashes($subject)); } else { phpbb_raise_error($error_msg); } } else { phpbb_raise_error($error_msg); } $userdata['user_id'] = $old_username; return $post_id; }
/** * Add a reply to this topic. * * */ public function addReply($message) { global $phpbb_root_path, $phpEx, $user_ip, $userdata, $db, $themes_id, $board_config, $template, $theme, $lang, $page_title, $SID, $html_entities_match, $html_entities_replace, $user_ip, $attachment_mod, $unhtml_specialchars_match, $unhtml_specialchars_replace; require_once $phpbb_root_path . 'includes/bbcode.' . $phpEx; require_once $phpbb_root_path . 'includes/functions_post.' . $phpEx; $forum_id = $this->getForumId(); $topic_id = $this->getTopicId(); $message = addslashes($message); $post_id = null; $poll_id = null; $attach_sig = 0; $mode = 'reply'; $post_data = array('first_post' => 0, 'last_post' => false, 'has_poll' => false, 'edit_poll' => false); $bbcode_on = '1'; $html_on = '0'; $smilies_on = '1'; $error_msg = ''; $username = ''; $bbcode_uid = ''; $subject = ''; $poll_title = ''; $poll_options = ''; $poll_length = '0'; $poll_length_h = '0'; $poll_length = $poll_length * 24; $poll_length = $poll_length_h + $poll_length; $poll_length = 0; $max_vote = ''; $hide_vote = ''; $tothide_vote = ''; prepare_post($mode, $post_data, $bbcode_on, $html_on, $smilies_on, $error_msg, $username, $bbcode_uid, $subject, $message, $poll_title, $poll_options, $poll_length, $max_vote, $hide_vote, $tothide_vote); if ($error_msg == '') { $topic_type = 0; submit_post($mode, $post_data, $return_message, $return_meta, $forum_id, $topic_id, $post_id, $poll_id, $topic_type, $bbcode_on, $html_on, $smilies_on, $attach_sig, $bbcode_uid, str_replace("\\'", "''", $username), str_replace("\\'", "''", $subject), str_replace("\\'", "''", $message), str_replace("\\'", "''", $poll_title), $poll_options, $poll_length, $max_vote, $hide_vote, $tothide_vote); } if ($error_msg == '') { $user_id = $userdata['user_id']; update_post_stats($mode, $post_data, $forum_id, $topic_id, $post_id, $user_id); //$attachment_mod['posting']->insert_attachment($post_id); if ($error_msg == '') { $notify_user = true; user_notification($mode, $post_data, $this->getTopicTitle(), $forum_id, $topic_id, $post_id, $notify_user); } $tracking_topics = !empty($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) : array(); $tracking_forums = !empty($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) : array(); if (count($tracking_topics) + count($tracking_forums) == 100 && empty($tracking_topics[$topic_id])) { asort($tracking_topics); unset($tracking_topics[key($tracking_topics)]); } $tracking_topics[$topic_id] = time(); setcookie($board_config['cookie_name'] . '_t', serialize($tracking_topics), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']); return $post_id; } else { message_die(GENERAL_ERROR, 'An error occured when posting a reply.'); } }