// ɾ³ý void CExplorerDlg::OnBnClickedButton1() { int tabIndex = m_tab.GetCurSel(); POSITION pos = m_pages[tabIndex]->m_list.GetFirstSelectedItemPosition(); if (pos == NULL) return; int index = m_pages[tabIndex]->m_list.GetNextSelectedItem(pos); CString code; if (tabIndex == 0) // Ö÷Ìâ { ThreadInfo& thread = m_exploreThreadPage.m_threads[index]; code = DeleteThread(thread.tid); if (code == _T("0")) g_deletedTID.insert(_ttoi64(thread.tid)); } else if (tabIndex == 1) // Ìû×Ó code = DeletePost(m_explorePostPage.m_tid, m_explorePostPage.m_posts[index].pid); else // Â¥ÖÐÂ¥ code = DeleteLZL(m_explorePostPage.m_tid, m_exploreLzlPage.m_lzls[index].pid); if (code != _T("0")) AfxMessageBox(_T("ɾ³ýʧ°Ü£¬´íÎó´úÂë" + code + _T("(") + GetTiebaErrorText(code) + _T(")")), MB_ICONERROR); else sndPlaySound(_T("ɾÌù.wav"), SND_ASYNC | SND_NODEFAULT); }
// ·â½û void CExplorerDlg::OnBnClickedButton2() { int tabIndex = m_tab.GetCurSel(); POSITION pos = m_pages[tabIndex]->m_list.GetFirstSelectedItemPosition(); if (pos == NULL) return; int index = m_pages[tabIndex]->m_list.GetNextSelectedItem(pos); CString author, pid; if (tabIndex == 0) // Ö÷Ìâ { author = m_exploreThreadPage.m_threads[index].author; vector<PostInfo> posts, lzls; GetPosts(m_exploreThreadPage.m_threads[index].tid, _T(""), _T("1"), posts, lzls); if (posts.size() > 0) pid = posts[0].pid; } else if (tabIndex == 1) // Ìû×Ó { author = m_explorePostPage.m_posts[index].author; pid = m_explorePostPage.m_posts[index].pid; } else // Â¥ÖÐÂ¥ { author = m_exploreLzlPage.m_lzls[index].author; pid = m_exploreLzlPage.m_lzls[index].pid; } if (pid == _T("")) { AfxMessageBox(_T("·â½ûʧ°Ü(»ñÈ¡Ìû×ÓIDʧ°Ü)"), MB_ICONERROR); return; } CString code = BanID(author, pid); if (code != _T("0")) AfxMessageBox(_T("·â½ûʧ°Ü£¬´íÎó´úÂë" + code + _T("(") + GetTiebaErrorText(code) + _T(")")), MB_ICONERROR); else sndPlaySound(_T("·âºÅ.wav"), SND_ASYNC | SND_NODEFAULT); }
UINT AFX_CDECL CDefriendPage::DefriendThread(LPVOID) { // 初始化 CTiebaManagerDlg* mainDlg = (CTiebaManagerDlg*)AfxGetApp()->m_pMainWnd; CoInitializeEx(NULL, COINIT_MULTITHREADED); CString sStartPage, sEndPage; if (m_instance != NULL) { m_instance->m_startPageEdit.GetWindowText(sStartPage); m_instance->m_endPageEdit.GetWindowText(sEndPage); } int startPage = _ttoi(sStartPage), endPage = _ttoi(sEndPage); if (startPage > endPage) { int t = startPage; startPage = endPage; endPage = t; } // 获取拉黑列表 int index = 0; std::vector<CString> userName, userID; for (int page = startPage; page <= endPage; page++) { if (m_stopFlag) break; CString state; state.Format(_T("采集第%d页"), page); if (m_instance != NULL) m_instance->m_stateStatic.SetWindowText(state); CString url; url.Format(_T("http://tieba.baidu.com/bawu2/platform/listMember?ie=utf-8&word=%s&pn=%d"), g_userTiebaInfo.m_encodedForumName, page); CString src = HTTPGet(url); if (m_stopFlag) break; CStringArray rawUsers; SplitString(rawUsers, src, _T("<tr><td class=\"left_cell\">")); if (rawUsers.GetSize() < 2) { if (src != NET_TIMEOUT_TEXT) WriteString(src, _T("defriend.txt")); else page--; continue; } userName.resize((int)userName.size() + (int)rawUsers.GetSize() - 1); userID.resize((int)userID.size() + (int)rawUsers.GetSize() - 1); CString tmp; for (int i = 1; i < rawUsers.GetSize(); i++, index++) { userName[index] = tmp = GetStringBetween(rawUsers[i], _T("un=\""), _T("\"")); userID[index] = tmp = GetStringBetween(rawUsers[i], _T("id=\""), _T("\"")); } } // 拉黑 for (UINT i = 0; i < userName.size(); i++) { if (m_stopFlag) break; /*if (g_defriendedUser.find(userName[i]) != g_defriendedUser.end()) continue;*/ CString state; state.Format(_T("拉黑中,剩余%u"), userName.size() - i - 1); if (m_instance != NULL) m_instance->m_stateStatic.SetWindowText(state); CString code = Defriend(userID[i]); if (code != _T("0")) { CString content; content.Format(_T("<font color=red>拉黑 </font>%s<font color=red> 失败!错误代码:%s(%s)</font><a href=") _T("\"df:%s\">重试</a>"), userName[i], code, GetTiebaErrorText(code), userID[i]); mainDlg->m_log.Log(content); } else { g_userCache.m_defriendedUser->insert(userName[i]); mainDlg->m_log.Log(_T("<font color=red>拉黑 </font>") + userName[i]); } if (i % 20 == 19 && i < userName.size() - 1) { if (m_instance != NULL) m_instance->m_stateStatic.SetWindowText(_T("延迟中")); for (int i = 0; i < 400; i++) { if (m_stopFlag) break; Sleep(100); } } } m_stopFlag = TRUE; CoUninitialize(); if (m_instance != NULL) { m_instance->m_startPageEdit.EnableWindow(TRUE); m_instance->m_endPageEdit.EnableWindow(TRUE); m_instance->m_startButton.EnableWindow(TRUE); m_instance->m_stopButton.EnableWindow(FALSE); m_instance->m_stateStatic.SetWindowText(_T("")); } return 0; }
// 循环封线程 UINT AFX_CDECL LoopBanThread(LPVOID _dlg) { class CLoopBanDate : public CConfigBase { public: COption<int> m_year; COption<int> m_month; COption<int> m_day; CLoopBanDate() : CConfigBase("LoopBanDate"), m_year("Year"), m_month("Month"), m_day("Day") { m_options.push_back(&m_year); m_options.push_back(&m_month); m_options.push_back(&m_day); } }; CTiebaManagerDlg* dlg = (CTiebaManagerDlg*)_dlg; // 一天内循环封过不再封 SYSTEMTIME time = {}; GetLocalTime(&time); CLoopBanDate lastTime; lastTime.Load(CURRENT_USER_PATH + _T("\\LoopBanDate.xml")); if (time.wDay == lastTime.m_day && time.wMonth == lastTime.m_month && time.wYear == lastTime.m_year) return 0; CLoopBanConfig config; config.Load(CURRENT_USER_PATH + _T("\\options2.xml")); if (!config.m_enable) return 0; BOOL updatePID = FALSE; // 循环封 dlg->m_stateStatic.SetWindowText(_T("循环封禁中")); CoInitializeEx(NULL, COINIT_MULTITHREADED); for (UINT i = 0; i < config.m_userList->size(); i++) { CString code; if (g_plan.m_wapBanInterface) code = BanIDWap((*config.m_userList)[i]); // 用WAP接口封禁 else { if ((*config.m_pidList)[i] != _T("")) // 尝试用PID封禁 code = BanID((*config.m_userList)[i], (*config.m_pidList)[i]); if ((*config.m_pidList)[i] == _T("") || code != _T("0")) // 尝试不用PID封禁(用户必须为本吧会员) { code = BanID((*config.m_userList)[i]); if (code != _T("0")) // 尝试获取新的PID并用PID封禁 { (*config.m_pidList)[i] = GetPIDFromUser((*config.m_userList)[i]); updatePID = TRUE; code = BanID((*config.m_userList)[i], (*config.m_pidList)[i]); } } } if (config.m_log) { if (code != _T("0")) { CString content; content.Format(_T("<font color=red>封禁 </font>%s<font color=red> 失败!错误代码:%s(%s)</font><a href=") _T("\"bd:%s,\">重试</a>"), (*config.m_userList)[i], code, GetTiebaErrorText(code), (*config.m_userList)[i]); dlg->m_log.Log(content); } else dlg->m_log.Log(_T("<font color=red>封禁 </font>") + (*config.m_userList)[i]); } if (code == _T("0") && i < config.m_userList->size() - 1) Sleep((DWORD)(config.m_banInterval * 1000)); } CoUninitialize(); // 更新PID if (updatePID) config.Save(CURRENT_USER_PATH + _T("\\options2.xml")); // 更新时间 *lastTime.m_year = time.wYear; *lastTime.m_month = time.wMonth; *lastTime.m_day = time.wDay; lastTime.Save(CURRENT_USER_PATH + _T("\\LoopBanDate.xml")); dlg->m_stateStatic.SetWindowText(_T("待机中")); return 0; }