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 post_delete($mode_or_post_id, $user_id = null, $exclude_first = true) { global $log_action; $del_user_posts = $mode_or_post_id === 'user'; // Delete all user posts // Get required params if ($del_user_posts) { if (!($user_csv = get_id_csv($user_id))) { return false; } } else { if (!($post_csv = get_id_csv($mode_or_post_id))) { return false; } // фильтр заглавных сообщений в теме if ($exclude_first) { $sql = "SELECT topic_first_post_id FROM " . BB_TOPICS . " WHERE topic_first_post_id IN({$post_csv})"; if ($first_posts = DB()->fetch_rowset($sql, 'topic_first_post_id')) { $posts_without_first = array_diff(explode(',', $post_csv), $first_posts); if (!($post_csv = get_id_csv($posts_without_first))) { return false; } } } } // Collect data for logs, sync.. $log_topics = $sync_forums = $sync_topics = $sync_users = array(); if ($del_user_posts) { $sync_topics = DB()->fetch_rowset("SELECT DISTINCT topic_id FROM " . BB_POSTS . " WHERE poster_id IN({$user_csv})", 'topic_id'); if ($topic_csv = get_id_csv($sync_topics)) { foreach (DB()->fetch_rowset("SELECT DISTINCT forum_id FROM " . BB_TOPICS . " WHERE topic_id IN({$topic_csv})") as $row) { $sync_forums[$row['forum_id']] = true; } } $sync_users = explode(',', $user_csv); } else { $sql = "\n\t\t\tSELECT p.topic_id, p.forum_id, t.topic_title\n\t\t\tFROM " . BB_POSTS . " p, " . BB_TOPICS . " t\n\t\t\tWHERE p.post_id IN({$post_csv})\n\t\t\t\tAND t.topic_id = p.topic_id\n\t\t\tGROUP BY t.topic_id\n\t\t"; foreach (DB()->fetch_rowset($sql) as $row) { $log_topics[] = $row; $sync_topics[] = $row['topic_id']; $sync_forums[$row['forum_id']] = true; } $sync_users = DB()->fetch_rowset("SELECT DISTINCT poster_id FROM " . BB_POSTS . " WHERE post_id IN({$post_csv})", 'poster_id'); } // Get all post_id for deleting $tmp_delete_posts = 'tmp_delete_posts'; DB()->query("\n\t\tCREATE TEMPORARY TABLE {$tmp_delete_posts} (\n\t\t\tpost_id INT UNSIGNED NOT NULL DEFAULT '0',\n\t\t\tPRIMARY KEY (post_id)\n\t\t) ENGINE = MEMORY\n\t"); DB()->add_shutdown_query("DROP TEMPORARY TABLE IF EXISTS {$tmp_delete_posts}"); if ($del_user_posts) { $where_sql = "poster_id IN({$user_csv})"; $exclude_posts_ary = array(); foreach (DB()->fetch_rowset("SELECT topic_first_post_id FROM " . BB_TOPICS . " WHERE topic_poster IN({$user_csv})") as $row) { $exclude_posts_ary[] = $row['topic_first_post_id']; } if ($exclude_posts_csv = get_id_csv($exclude_posts_ary)) { $where_sql .= " AND post_id NOT IN({$exclude_posts_csv})"; } } else { $where_sql = "post_id IN({$post_csv})"; } DB()->query("INSERT INTO {$tmp_delete_posts} SELECT post_id FROM " . BB_POSTS . " WHERE {$where_sql}"); // Deleted posts count $row = DB()->fetch_row("SELECT COUNT(*) AS posts_count FROM {$tmp_delete_posts}"); if (!($deleted_posts_count = $row['posts_count'])) { DB()->query("DROP TEMPORARY TABLE {$tmp_delete_posts}"); return 0; } // Delete attachments (from disk) $attach_dir = get_attachments_dir(); $result = DB()->query("\n\t\tSELECT\n\t\t\td.physical_filename\n\t\tFROM\n\t\t\t" . $tmp_delete_posts . " del,\n\t\t\t" . BB_ATTACHMENTS . " a,\n\t\t\t" . BB_ATTACHMENTS_DESC . " d\n\t\tWHERE\n\t\t\t a.post_id = del.post_id\n\t\t\tAND d.attach_id = a.attach_id\n\t"); while ($row = DB()->fetch_next($result)) { if ($filename = basename($row['physical_filename'])) { @unlink("{$attach_dir}/" . $filename); @unlink("{$attach_dir}/" . THUMB_DIR . '/t_' . $filename); } } unset($row, $result); // Delete posts, posts_text, attachments (from DB) DB()->query("\n\t\tDELETE p, pt, ps, tor, a, d, ph\n\t\tFROM " . $tmp_delete_posts . " del\n\t\tLEFT JOIN " . BB_POSTS . " p ON(p.post_id = del.post_id)\n\t\tLEFT JOIN " . BB_POSTS_TEXT . " pt ON(pt.post_id = del.post_id)\n\t\tLEFT JOIN " . BB_POSTS_HTML . " ph ON(ph.post_id = del.post_id)\n\t\tLEFT JOIN " . BB_POSTS_SEARCH . " ps ON(ps.post_id = del.post_id)\n\t\tLEFT JOIN " . BB_BT_TORRENTS . " tor ON(tor.post_id = del.post_id)\n\t\tLEFT JOIN " . BB_ATTACHMENTS . " a ON(a.post_id = del.post_id)\n\t\tLEFT JOIN " . BB_ATTACHMENTS_DESC . " d ON(d.attach_id = a.attach_id)\n\t"); // Log action if ($del_user_posts) { $log_action->admin('mod_post_delete', array('log_msg' => 'user: '******'IN_CRON')) { foreach ($log_topics as $row) { $log_action->mod('mod_post_delete', array('forum_id' => $row['forum_id'], 'topic_id' => $row['topic_id'], 'topic_title' => $row['topic_title'])); } } } // Sync sync('topic', $sync_topics); sync('forum', array_keys($sync_forums)); sync('user_posts', $sync_users); // Update atom feed foreach ($sync_topics as $atom_topic) { update_atom('topic', $atom_topic); } foreach ($sync_users as $atom_user) { update_atom('user', $atom_user); } DB()->query("DROP TEMPORARY TABLE {$tmp_delete_posts}"); return $deleted_posts_count; }
$sub_forums[] = $forum_id; $sub_forums = join(',', $sub_forums); // Подсчет проверенных релизов в форумах раздела $count_checked_releases = DB()->fetch_row("\n\t\t\t\t\t\tSELECT COUNT(*) AS checked_releases\n\t\t\t\t\t\tFROM " . BB_BT_TORRENTS . "\n\t\t\t\t\t\tWHERE poster_id = " . $userdata['user_id'] . "\n\t\t\t\t\t\t AND forum_id IN({$sub_forums})\n\t\t\t\t\t\t AND tor_status IN(" . TOR_APPROVED . "," . TOR_DOUBTFUL . "," . TOR_TMP . ")\n\t\t\t\t\t\tLIMIT 1\n\t\t\t\t\t", 'checked_releases'); if ($count_checked_releases || IS_AM) { tracker_register(TORRENT_ATTACH_ID, 'newtopic', TOR_NOT_APPROVED); } else { tracker_register(TORRENT_ATTACH_ID, 'newtopic', TOR_PREMOD); } } else { tracker_register(TORRENT_ATTACH_ID, 'newtopic', TOR_NOT_APPROVED); } } } // Update atom feed update_atom('topic', $topic_id); if ($mode == 'reply' && $post_info['topic_status'] == TOPIC_LOCKED) { $locked_warn = ' <div class="warnColor1"> <b>' . $lang['LOCKED_WARN'] . '</b> </div> <br /><hr /><br /> '; $return_message = $locked_warn . $return_message; } bb_die($return_message); } } if ($refresh || $error_msg || $submit && $topic_has_new_posts) { $username = !empty($_POST['username']) ? clean_username($_POST['username']) : ''; $subject = !empty($_POST['subject']) ? clean_title($_POST['subject']) : '';