示例#1
0
void CScraperParser::InsertToken(CStdString& strOutput, int buf, const char* token)
{
  char temp[4];
  sprintf(temp,"\\%i",buf);
  int i2=0;
  while ((i2 = strOutput.Find(temp,i2)) != -1)
  {
    strOutput.Insert(i2,token);
    i2 += strlen(token);
    strOutput.Insert(i2+strlen(temp),token);
    i2 += strlen(temp);
  }
}
示例#2
0
void CServer::ShowStatus(_int64 eventDate, LPCTSTR msg, int nType)
{
	USES_CONVERSION;
	TIME_ZONE_INFORMATION tzInfo;
	BOOL res=GetTimeZoneInformation(&tzInfo);
	_int64 offset = tzInfo.Bias+((res==TIME_ZONE_ID_DAYLIGHT)?tzInfo.DaylightBias:tzInfo.StandardBias);
	offset*=60*10000000;
	eventDate-=offset;
	LPCSTR str=T2CA(msg);
	char *pBuffer=new char[strlen(str) + 1 + 8];
	*pBuffer=nType;
	memcpy(pBuffer + 1, &eventDate, 8);
	memcpy(pBuffer + 1 + 8, str, strlen(str));
	if (m_pAdminInterface)
		m_pAdminInterface->SendCommand(2, 4, pBuffer, strlen(str) + 1 + 8);
	delete [] pBuffer;

	//Log string
	if (m_pFileLogger)
	{
		FILETIME fFileTime;
		SYSTEMTIME sFileTime;
		fFileTime.dwHighDateTime = (DWORD)(eventDate>>32);
		fFileTime.dwLowDateTime = (DWORD)(eventDate %0xFFFFFFFF);
		FileTimeToSystemTime(&fFileTime, &sFileTime);
		char text[80];
		if (!GetDateFormat(
			LOCALE_USER_DEFAULT,               // locale for which date is to be formatted
			DATE_SHORTDATE,             // flags specifying function options
			&sFileTime,  // date to be formatted
			0,          // date format string
			text,          // buffer for storing formatted string
			80                // size of buffer
			))
			return;
		
		CStdString text2=" ";
		text2+=text;
		
		if (!GetTimeFormat(
			LOCALE_USER_DEFAULT,               // locale for which date is to be formatted
			TIME_FORCE24HOURFORMAT,             // flags specifying function options
			&sFileTime,  // date to be formatted
			0,          // date format string
			text,          // buffer for storing formatted string
			80                // size of buffer
			))
			return;

		text2+=" ";
		text2+=text;
		CStdString str = msg;
		int pos=str.Find("-");
		if (pos!=-1)
		{
			str.Insert(pos, text2 + " ");
		}
		m_pFileLogger->Log(str);
	}
}
示例#3
0
void CServer::ShowStatus(DWORD eventDateHigh, DWORD eventDateLow, LPCTSTR msg, int nType)
{
	auto utf8 = ConvToNetwork(msg);
	if (utf8.empty())
		return;

	char *pBuffer = new char[utf8.size() + 1 + 8];
	*pBuffer = nType;
	memcpy(pBuffer + 1, &eventDateHigh, 4);
	memcpy(pBuffer + 5, &eventDateLow, 4);
	memcpy(pBuffer + 1 + 8, utf8.c_str(), utf8.size());
	if (m_pAdminInterface)
		m_pAdminInterface->SendCommand(2, 4, pBuffer, utf8.size() + 1 + 8);
	delete [] pBuffer;

	//Log string
	if (m_pFileLogger) {
		FILETIME fFileTime;
		SYSTEMTIME sFileTime;
		fFileTime.dwHighDateTime = eventDateHigh;
		fFileTime.dwLowDateTime = eventDateLow;
		if (!FileTimeToSystemTime(&fFileTime, &sFileTime)) {
			return;
		}
		TCHAR text[80];
		if (!GetDateFormat(
			LOCALE_USER_DEFAULT,			// locale for which date is to be formatted
			DATE_SHORTDATE,					// flags specifying function options
			&sFileTime,						// date to be formatted
			0,								// date format string
			text,							// buffer for storing formatted string
			80								// size of buffer
			))
			return;

		CStdString text2 = _T(" ");
		text2 += text;

		if (!GetTimeFormat(
			LOCALE_USER_DEFAULT,			// locale for which date is to be formatted
			TIME_FORCE24HOURFORMAT,			// flags specifying function options
			&sFileTime,						// date to be formatted
			0,								// date format string
			text,							// buffer for storing formatted string
			80								// size of buffer
			))
			return;

		text2 += _T(" ");
		text2 += text;
		CStdString str = msg;
		int pos = str.Find(_T("-"));
		if (pos!=-1)
		{
			str.Insert(pos, text2 + _T(" "));
		}
		m_pFileLogger->Log(str);
	}
}
示例#4
0
void CScraperParser::Clean(CStdString& strDirty)
{
  int i=0;
  CStdString strBuffer;
  while ((i=strDirty.Find("!!!CLEAN!!!",i)) != -1)
  {
    int i2;
    if ((i2=strDirty.Find("!!!CLEAN!!!",i+11)) != -1)
    {
      strBuffer = strDirty.substr(i+11,i2-i-11);
      CStdString strConverted(strBuffer);
      HTML::CHTMLUtil::RemoveTags(strConverted);
      RemoveWhiteSpace(strConverted);
      strDirty.erase(i,i2-i+11);
      strDirty.Insert(i,strConverted);
      i += strConverted.size();
    }
    else
      break;
  }
  i=0;
  while ((i=strDirty.Find("!!!TRIM!!!",i)) != -1)
  {
    int i2;
    if ((i2=strDirty.Find("!!!TRIM!!!",i+10)) != -1)
    {
      strBuffer = strDirty.substr(i+10,i2-i-10);
      RemoveWhiteSpace(strBuffer);
      strDirty.erase(i,i2-i+10);
      strDirty.Insert(i,strBuffer);
      i += strBuffer.size();
    }
    else
      break;
  }
  i=0;
  while ((i=strDirty.Find("!!!FIXCHARS!!!",i)) != -1)
  {
    int i2;
    if ((i2=strDirty.Find("!!!FIXCHARS!!!",i+14)) != -1)
    {
      strBuffer = strDirty.substr(i+14,i2-i-14);
      CStdStringW wbuffer;
      g_charsetConverter.toW(strBuffer,wbuffer,GetSearchStringEncoding());
      CStdStringW wConverted;
      HTML::CHTMLUtil::ConvertHTMLToW(wbuffer,wConverted);
      g_charsetConverter.fromW(wConverted,strBuffer,GetSearchStringEncoding());
      RemoveWhiteSpace(strBuffer);
      strDirty.erase(i,i2-i+14);
      strDirty.Insert(i,strBuffer);
      i += strBuffer.size();
    }
    else
      break;
  }
  i=0;
  while ((i=strDirty.Find("!!!ENCODE!!!",i)) != -1)
  {
    int i2;
    if ((i2=strDirty.Find("!!!ENCODE!!!",i+12)) != -1)
    {
      strBuffer = strDirty.substr(i+12,i2-i-12);
      CURL::Encode(strBuffer);
      strDirty.erase(i,i2-i+12);
      strDirty.Insert(i,strBuffer);
      i += strBuffer.size();
    }
    else
      break;
  }
}