Ejemplo n.º 1
0
// ·â½û
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);
}
Ejemplo n.º 2
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;
}