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 submit_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_id, &$post_id, &$topic_type, $post_username, $post_subject, $post_message, $update_post_time, $poster_rg_id, $attach_rg_sig) { global $userdata, $post_info, $is_auth, $bb_cfg, $lang, $datastore; $current_time = TIMENOW; // Flood control $row = null; $where_sql = IS_GUEST ? "p.poster_ip = '" . USER_IP . "'" : "p.poster_id = {$userdata['user_id']}"; if ($mode == 'newtopic' || $mode == 'reply') { $sql = "SELECT MAX(p.post_time) AS last_post_time FROM " . BB_POSTS . " p WHERE {$where_sql}"; if ($row = DB()->fetch_row($sql) and $row['last_post_time']) { if ($userdata['user_level'] == USER) { if (TIMENOW - $row['last_post_time'] < $bb_cfg['flood_interval']) { bb_die($lang['FLOOD_ERROR']); } } } } // Double Post Control if ($mode != 'editpost' && !empty($row['last_post_time']) && !IS_AM) { $sql = "\n\t\t\tSELECT pt.post_text\n\t\t\tFROM " . BB_POSTS . " p, " . BB_POSTS_TEXT . " pt\n\t\t\tWHERE\n\t\t\t\t\t{$where_sql}\n\t\t\t\tAND p.post_time = " . (int) $row['last_post_time'] . "\n\t\t\t\tAND pt.post_id = p.post_id\n\t\t\tLIMIT 1\n\t\t"; if ($row = DB()->fetch_row($sql)) { $last_msg = DB()->escape($row['post_text']); if ($last_msg == $post_message) { bb_die($lang['DOUBLE_POST_ERROR']); } } } if ($mode == 'newtopic' || $mode == 'editpost' && $post_data['first_post']) { $topic_dl_type = isset($_POST['topic_dl_type']) && ($post_info['allow_reg_tracker'] || $is_auth['auth_mod']) ? TOPIC_DL_TYPE_DL : TOPIC_DL_TYPE_NORMAL; $sql_insert = "\n\t\t\tINSERT INTO\n\t\t\t\t" . BB_TOPICS . " (topic_title, topic_poster, topic_time, forum_id, topic_status, topic_type, topic_dl_type)\n\t\t\tVALUES\n\t\t\t\t('{$post_subject}', " . $userdata['user_id'] . ", {$current_time}, {$forum_id}, " . TOPIC_UNLOCKED . ", {$topic_type}, {$topic_dl_type})\n\t\t"; $sql_update = "\n\t\t\tUPDATE\n\t\t\t\t" . BB_TOPICS . "\n\t\t\tSET\n\t\t\t\ttopic_title = '{$post_subject}',\n\t\t\t\ttopic_type = {$topic_type},\n\t\t\t\ttopic_dl_type = {$topic_dl_type}\n\t\t\tWHERE\n\t\t\t\ttopic_id = {$topic_id}\n\t\t"; $sql = $mode != "editpost" ? $sql_insert : $sql_update; if (!DB()->sql_query($sql)) { bb_die('Error in posting #1'); } if ($mode == 'newtopic') { $topic_id = DB()->sql_nextid(); } } $edited_sql = $mode == 'editpost' && !$post_data['last_post'] && $post_data['poster_post'] ? ", post_edit_time = {$current_time}, post_edit_count = post_edit_count + 1" : ""; if ($update_post_time && $mode == 'editpost' && $post_data['last_post'] && !$post_data['first_post']) { $edited_sql .= ", post_time = {$current_time} "; //lpt DB()->sql_query("UPDATE " . BB_TOPICS . " SET topic_last_post_time = {$current_time} WHERE topic_id = {$topic_id} LIMIT 1"); } $sql = $mode != "editpost" ? "INSERT INTO " . BB_POSTS . " (topic_id, forum_id, poster_id, post_username, post_time, poster_ip, poster_rg_id, attach_rg_sig) VALUES ({$topic_id}, {$forum_id}, " . $userdata['user_id'] . ", '{$post_username}', {$current_time}, '" . USER_IP . "', {$poster_rg_id}, {$attach_rg_sig})" : "UPDATE " . BB_POSTS . " SET post_username = '******'" . $edited_sql . ", poster_rg_id = {$poster_rg_id}, attach_rg_sig = {$attach_rg_sig} WHERE post_id = {$post_id}"; if (!DB()->sql_query($sql)) { bb_die('Error in posting #2'); } if ($mode != 'editpost') { $post_id = DB()->sql_nextid(); } $sql = $mode != 'editpost' ? "INSERT INTO " . BB_POSTS_TEXT . " (post_id, post_text) VALUES ({$post_id}, '{$post_message}')" : "UPDATE " . BB_POSTS_TEXT . " SET post_text = '{$post_message}' WHERE post_id = {$post_id}"; if (!DB()->sql_query($sql)) { bb_die('Error in posting #3'); } if ($userdata['user_id'] != BOT_UID) { $s_post_message = str_replace('\\n', "\n", $post_message); $s_post_subject = str_replace('\\n', "\n", $post_subject); add_search_words($post_id, stripslashes($s_post_message), stripslashes($s_post_subject)); } update_post_html(array('post_id' => $post_id, 'post_text' => $post_message)); //Обновление кеша новостей на главной if ($bb_cfg['show_latest_news']) { $news_forums = array_flip(explode(',', $bb_cfg['latest_news_forum_id'])); if (isset($news_forums[$forum_id]) && $bb_cfg['show_latest_news'] && $mode == 'newtopic') { $datastore->enqueue('latest_news'); $datastore->update('latest_news'); } } if ($bb_cfg['show_network_news']) { $net_forums = array_flip(explode(',', $bb_cfg['network_news_forum_id'])); if (isset($net_forums[$forum_id]) && $bb_cfg['show_network_news'] && $mode == 'newtopic') { $datastore->enqueue('network_news'); $datastore->update('network_news'); } } meta_refresh(POST_URL . "{$post_id}#{$post_id}"); set_die_append_msg($forum_id, $topic_id); return $mode; }