Exemple #1
0
void StringsListEdit (void)
{
    STRING *p, *q;

  AGAIN_P:
    for (p = pStringsList; p != NULL; p = p -> pNext)
    {
        if(p->nUserNum != IS_IN_TABLE)
        {
        if (p -> nRecognized  == 0  &&
            p -> yBottom - p -> yTop + 1 < pCurrentBlock -> nAverageHeight)
        {
            if (p == pStringsList)
                {
                  StringRemove (p);
                  goto AGAIN_P;
                }
            else if (p == pStringsListEnd)
                {
                   StringRemove (p);
                   break;
                }
            else
                {
                    p = p -> pPrev;
                    StringRemove (p -> pNext);
                 }
        }
        }

      AGAIN_Q:
        for (q = p -> pNext; q != NULL; q = q -> pNext)
        {
            if (StringIncludes (p, q))
            {
                if (q -> xLeft < p -> xLeft)
                    p -> xLeft = q -> xLeft;

                if (q -> xRight > q -> xRight)
                    p -> xRight = q -> xRight;
                StringRemove (q);
                goto AGAIN_Q;
            }
        }
    }
}
Exemple #2
0
HRESULT CLoginDlg::GetCookie(CString& cookie)
{
	DWORD size;
	InternetGetCookieEx(_T("http://tieba.baidu.com/"), _T("BDUSS"), NULL,
		&size, INTERNET_COOKIE_HTTPONLY, NULL); // size为字节数
	BOOL result = InternetGetCookieEx(_T("http://tieba.baidu.com/"), _T("BDUSS"), cookie.GetBuffer(size),
		&size, INTERNET_COOKIE_HTTPONLY, NULL); // BUG:size在XP下单位是字节,在win10是字符数,XP下传字符数会返回缓冲不够
	HRESULT hr = HRESULT_FROM_WIN32(GetLastError());
	cookie.ReleaseBuffer();

	if (result)
	{
		if (cookie.GetLength() < 100 || !StringIncludes(cookie, _T("BDUSS=")))
			return HRESULT_FROM_WIN32(ERROR_INVALID_DATA); // 无效的Cookie
		cookie += _T(";");
		return S_OK; // 成功
	}
	return hr;
}
Exemple #3
0
// 使用IE Cookie
void CLoginDlg::OnBnClickedButton3()
{
	DWORD size = 1024 * 1024;
	BOOL result = InternetGetCookieEx(_T("http://tieba.baidu.com/"), NULL, m_cookie.GetBuffer(size),
		&size, INTERNET_COOKIE_HTTPONLY, NULL);
	m_cookie.ReleaseBuffer();

	BOOL jump = TRUE;
CheckResult:
	if (!result)
	{
		if (jump)
			goto Win10;
		AfxMessageBox(_T("获取Cookie失败!"), MB_ICONERROR);
		return;
	}
	if (!StringIncludes(m_cookie, _T("BDUSS=")))
	{
		if (jump)
			goto Win10;
		AfxMessageBox(_T("请先在IE浏览器登陆百度账号并选中下次自动登录!"), MB_ICONERROR);
		return;
	}

	GetLoginUserName();
	if (m_userName == _T(""))
	{
		AfxMessageBox(_T("获取用户名失败!"), MB_ICONERROR);
		return;
	}

	AfxMessageBox(_T("登录完毕,不要在IE退出账号以免cookie失效,可以直接清除cookie"), MB_ICONINFORMATION);
	EndDialog(IDOK);
	return;

Win10:
	size = 1024 * 1024;
	result = SUCCEEDED(IEGetProtectedModeCookie(L"http://tieba.baidu.com/", NULL, m_cookie.GetBuffer(size),
		&size, INTERNET_COOKIE_HTTPONLY));
	jump = FALSE;
	goto CheckResult;
}
BOOL CWhiteContentPage::TestMatch(const CString& test, const CString& text, BOOL isRegex)
{
	return StringIncludes(test, text, isRegex);
}
BOOL CWhiteContentPage::CheckMatchTooMuch(const CString& text, BOOL isRegex)
{
	return StringIncludes(MATCH_TOO_MUCH_CONTENT_TEST1, text, isRegex) 
		&& StringIncludes(MATCH_TOO_MUCH_CONTENT_TEST2, text, isRegex);
}
BOOL CKeywordsPage::TestMatch(const CString& test, const CString& text, BOOL isRegex)
{
	return StringIncludes(test, text, isRegex);
}
Exemple #7
0
// 登录
void CLoginDlg::OnOK()
{
	CString userName, password, verifyCode;
	m_userNameEdit.GetWindowText(userName);
	if (userName == _T(""))
	{
		m_userNameEdit.SetFocus();
		return;
	}
	m_passwordEdit.GetWindowText(password);
	if (password == _T(""))
	{
		m_passwordEdit.SetFocus();
		return;
	}
	m_verifyCodeEdit.GetWindowText(verifyCode);
	if (verifyCode == _T(""))
	{
		m_verifyCodeEdit.SetFocus();
		return;
	}

	EnableWindow(FALSE);

	time_t timestamp;
	time(&timestamp);
	CString data;
	data.Format(_T("staticpage=http%%3A%%2F%%2Fwww.baidu.com%%2Fcache%%2Fuser%%2Fhtml%%2Fv3Jump.html&charset=utf-8&token=%s&tpl=mn")
				_T("&apiver=v3&tt=%I64d&codestring=%s&isPhone=false&safeflg=0&u=http%%3A%%2F%%2Fwww.baidu.com%%2F&username=%s&pass")
				_T("word=%s&verifycode=%s&mem_pass=on&ppui_logintime=35219&callback=parent.bd__pcbs__4y6hex"),
				m_token, timestamp, m_verifyStr, EncodeURI(userName), EncodeURI(password), verifyCode);
	CString result = HTTPPost(_T("https://passport.baidu.com/v2/api/?login"), data, TRUE, NULL, &m_cookie);

	EnableWindow(TRUE);
	if (result == NET_TIMEOUT_TEXT)
	{
		AfxMessageBox(_T("连接超时..."), MB_ICONERROR);
		OnStnClickedStatic4();
		m_verifyCodeEdit.SetWindowText(_T(""));
		return;
	}
	if (!StringIncludes(m_cookie, _T("BDUSS=")))
	{
		WriteString(result, _T("login.txt"));
		AfxMessageBox(_T("登录失败!"), MB_ICONERROR);
		if (userName.Left(1) == _T("1"))
			AfxMessageBox(_T("(不能用手机号哦)"), MB_ICONINFORMATION);
		goto error;
	}

	GetLoginUserName();
	if (m_userName == _T(""))
	{
		AfxMessageBox(_T("获取用户名失败!"), MB_ICONERROR);
		goto error;
	}

	CDialog::OnOK();
	return;

error:
	OnStnClickedStatic4();
	m_verifyCodeEdit.SetWindowText(_T(""));
}