Exemple #1
0
bool	CWordFilter::VerifyDspNameString(const TCHAR * sString)	// 验证字符是否合法
{
    CWordFilterDataMapItr itr;
    for(itr = m_mapWordFilterData.begin(); itr != m_mapWordFilterData.end(); itr++)
    {
        if(KMP_Match(sString, itr->second.m_szWordFilters, itr->second.m_kmpvalue))
        {
            return false;	// 关键词命中了,被fliter了
        }
    }

    for(itr = m_mapDspNameWordFilterData.begin(); itr != m_mapDspNameWordFilterData.end(); itr++)
    {
        if(KMP_Match(sString, itr->second.m_szWordFilters, itr->second.m_kmpvalue))
        {
            return false;	// 关键词命中了,被fliter了
        }
    }

    return true;
}
Exemple #2
0
TCHAR*	CWordFilter::VerifyString(const TCHAR * sString)	// 验证字符是否合法
{
    CWordFilterDataMapItr itr;
    for(itr = m_mapWordFilterData.begin(); itr != m_mapWordFilterData.end(); itr++)
    {
        if(KMP_Match(sString, itr->second.m_szWordFilters, itr->second.m_kmpvalue))
        {
            return itr->second.m_szWordFilters;	// 关键词命中了,被fliter了
        }
    }
    return NULL;
}
Exemple #3
0
bool	CWordFilter::VerifyString(const CString & sString)	// 验证字符是否合法
{
	bool bIsRm = sString.Right(3)==_T(".rm");
	CString sReduceString=sString;
	CString sInterpunctionString = _T("(),().。·;:-《》『』~ “”〓!【】★×┇");
	try // VC-Huby[2007-03-20]:满足中国国情特色,加强过滤
	{		
		int j=0;
		for( int i=0; i<sString.GetLength(); i++ )
		{
			if( sString.GetAt(i)<=_T('/') && sString.GetAt(i)>=_T(' ') ) //从空格到'/'之间的字符减掉后再过滤
			{
				continue;
			}
			else if( sString.GetAt(i)<=_T('@') && sString.GetAt(i)>=_T(':') )
			{
				continue;
			}
			else if( sString.GetAt(i)<=_T('`') && sString.GetAt(i)>=_T('[') )
			{
				continue;
			}
			else if( sString.GetAt(i)<=_T('~') && sString.GetAt(i)>=_T('{') )
			{
				continue;
			}
			else if( sInterpunctionString.Find(sString.GetAt(i))>=0 )
			{
				continue;
			}
			else
			{
				sReduceString.SetAt(j,sString.GetAt(i));
				j++;
			}
		}
		if( j<sString.GetLength() )
			sReduceString.SetAt(j,_T('\0'));
	}
	catch (...) 
	{
	}

	if(m_filterall){
		//AddLogLine(false,_T("m_filterall"));
		return true;	// 检测不到文件,或者读取错误的情况下放弃过滤
	}
	if(m_count == 0){
		//AddLogLine(false,_T("m_count == 0"));
		return true;	// 文件是空的时候,放弃过滤功能
	}
	CString strSearch = ((CString)sReduceString).MakeLower();

	//vc-huby: 过滤中文字符超过15字符
	//CString sReduceString2=strSearch;		
	int k=0;
	for( int i=0; i<strSearch.GetLength(); i++ )
	{
		if( strSearch.GetAt(i)<=_T('9') && strSearch.GetAt(i)>=_T('0') )
		{
			continue;
		}
		if( strSearch.GetAt(i)<=_T('z') && strSearch.GetAt(i)>=_T('a') )
		{
			continue;
		}
		else
		{
			k++;
		}
	}

	if( k>=20 && bIsRm )
		return false;
	//int m = sReduceString2.GetLength();
/*
	if( k>=60 )
		return false;*/


	/*if (strSearch.GetLength() > 20)
	{
		return false;
	}*/

	for(int i = 0; i < m_count; i ++)
	{
		if(KMP_Match(strSearch, m_filterwords[i], m_kmpvalue[i]))
		{
			//AddLogLine(false,_T("KMP_Match"));
			return false;	// 关键词命中了,被fliter了
		}
	}
	//AddLogLine(false,_T("漏掉的"));
	return true;

}