Exemple #1
0
//---------------------------------------------------------------------------
void __fastcall TFormPassWord::sButton1Click(TObject *Sender)
{
	bool bRes = false;
	if (!Query1->Prepared)   Query1->Prepare();
	AnsiString LatText = GetLatinText(sEdit1->Text);
	AnsiString S = LatText.UpperCase();
	Query1->ParamByName("PASSWRD")->AsString = S;
	int FlagExit = 0;
	AnsiString Msg;
	if (ReOpenDSetStd(Query1)) {
	  FlagExit = Query1->FieldByName("Flag_Exit")->AsInteger;
	  int Cnt  = Query1->FieldByName("CNT")->AsInteger;
		switch (FlagExit) {
			case -1: Msg  = "Нет данных о пользователе с таким паролем"; break;
			case -2: Msg  = "В базе находятся "+IntToStr(Cnt)+" пользователей с таким паролем"; break;
			default: bRes = (Cnt == 1); break;
      }
	}
	if (bRes) {
		DModT->CurEmpID       = Query1->FieldByName("EMPLOYEE_ID")->AsInteger;
		DModT->Full_Name      = Query1->FieldByName("FULL_NAME")->AsString;
		DModT->Empl_Rights    = Query1->FieldByName("Empl_Rights")->AsInteger;
		ModalResult = mrOk;
	}
	else {
	  if (Msg != "") OutputMessage(Msg);
	}
}
Exemple #2
0
void TFwCalcMainDlg::ParseDecNumber(AnsiString number, AnsiString &nn, AnsiString &dn, AnsiString &en)
{
	dn = "";
	en = "";
	nn = "";

AnsiString tmp = number.UpperCase().Trim().c_str();
char *p = tmp.c_str();
char *pd, *pe;
char *e = p;
	while(*e)
	{
		if(*e == ',')
			*e = '.';
		e++;
	}

	pd = strchr(p, '.');
	pe = strchr(p, 'E');

	if(pe)
	{
		en = (pe+1);
		*pe = 0;
		if(en == "")
        	en = "0";
	}
	if(pd)
	{
		dn = (pd+1);
		*pd = 0;
	}
    nn = p;
}
Exemple #3
0
int TfrmMain::FieldExists(TADOQuery*Query,AnsiString szFieldName)
{
    int iRet = -1;
    AnsiString tmp=szFieldName.UpperCase();
    if(Query->Active)
        for(int i=0;i<Query->Fields->Count;i++)
        {
            if(Query->Fields->Fields[i]->FieldName.UpperCase()==tmp)
            {
                iRet = i;
                break;
            }
        }
    return iRet;
}
//---------------------------------------------------------------------------
void __fastcall TNewEn::btnOpenClick(TObject *Sender)
{
    OpenDialog->Filter = "Model File|*.xml";
    OpenDialog->DefaultExt = "*.XML";
    OpenDialog->FileName = "*.XML";
    if(g_pProject->m_bModified)
    {
      switch (Application->MessageBox("Model File has been modified, save£¿","Hint",MB_YESNOCANCEL))
      {  case ID_YES :
            SaveCommand();
            break;
         case ID_CANCEL :
            return;
      }
    }
    ClearProject();
    InitialProject();
    if(OpenDialog->Execute())
    {
        g_pProject->m_strFileName=OpenDialog->FileName;
        AnsiString exten = ExtractFileExt(OpenDialog->FileName);
        exten = exten.UpperCase();
        if(exten == ".XML")
        {
          g_pProject->XMLDoc = XMLDocument1;
          g_pProject->LoadFromXML(g_pProject->m_strFileName);

          if( graphic==NULL)
             graphic=new Graphics::TBitmap();
          if(g_pProject->m_strLayout.Length()>2)
          {
           try {
              graphic->LoadFromFile(g_pProject->m_strLayout);
           } catch (Exception &e)
           {  ShowMessage(e.Message);delete graphic;graphic=NULL;
           }
          }
          this->Caption="Smart Environment----"+g_pProject->m_strFileName;
        }
        else
        {
          return;
        }
        FrameProperty->RefreshProjectTree();
        Refresh();
    }

}
AnsiString tWWWClientSocket::getheader(AnsiString headername)
{
  int i=0;
  AnsiString s1,s2;
  s1=headername.UpperCase();
  for (i=0;i<=headercount;i++)
  {
    s2=HTTPHeaders[i].SubString(0,HTTPHeaders[i].Pos(":")-1).UpperCase().Trim();
    if ( s1==s2 )
    {
      s1="";
      s2="";
      return HTTPHeaders[i].SubString(HTTPHeaders[i].Pos(":")+1,500).Trim();
    }
  }
}
Exemple #6
0
//---------------------------------------------------------------------------
void __fastcall TFormClientRep::ProcHistory(bool All)
{
	AnsiString Title  = "ѕросмотр истории изменени¤";
	AnsiString FldKey = WrkGData->FieldKey;
	AnsiString TableName = GetPiece(FldKey,"_ID",1).UpperCase();
	int ID = WrkGData->WrkDSet->FieldByName(FldKey)->AsInteger;
	AnsiString FieldNames;
	AnsiString TitleNames;
	AnsiString SS;
	TDBGridEh* Grid = WrkGData->WrkGrid;
	TStringList* FieldNamesList = new TStringList();
	TStringList* TitleNamesList = new TStringList();
	AnsiString AllFieldNames;
	if (All) {
		TDBGridColumnsEh* Columns = Grid->Columns;
		int Cnt = Columns->Count;
		AnsiString S;
		bool KeyIncduded = true;
		for (int i = 0; i < Cnt; i++) {
			 TColumnEh* Column = Columns->Items[i];
			 if (Column->Visible) {
				 AnsiString X = ","+TranslateName(Column->FieldName);
				 if (!AllFieldNames.Pos(X)) {
					 AllFieldNames += X;
					 FieldNames += X ;
					 SS = Column->Title->Caption;
					 TitleNames += "," + GetPiece(SS, "|",1);
					 SS = GetPiece(SS, "|",2);
					 if (SS != "")  TitleNames += "-> " + SS;
					 if (FieldNames.Length() > 230 || TitleNames.Length() > 200) {
						 KeyIncduded = KeyIncduded || FieldNames.Pos("," + FldKey);
						 FieldNames  = FieldNames.SubString(2,1000);
						 TitleNames  = TitleNames.SubString(2,1000);
						 FieldNames  = FieldNames.UpperCase();
						 FieldNamesList->Add(FieldNames);
						 TitleNamesList->Add(TitleNames);
						 FieldNames = "";
						 TitleNames = "";
					 }
				 }
			 }
		}
		if (!KeyIncduded) {
			FieldNames = "," +FldKey + FieldNames  + ",STATUS";
			TitleNames = ",N записи"  + TitleNames + ",—осто¤ние";
		}
		else {
			FieldNames = FieldNames + ",STATUS";
			TitleNames = TitleNames + ",—осто¤ние";
		}
		FieldNames  = FieldNames.SubString(2,1000);
		TitleNames  = TitleNames.SubString(2,1000);
		FieldNames = FieldNames.UpperCase();
		FieldNamesList->Add(FieldNames);
		TitleNamesList->Add(TitleNames);
		FieldNames = "";
		TitleNames = "";

		Title = Title + " всех видимых полей";
	}
	else {
		TColumnEh* Column = Grid->Columns->Items[Grid->Col - 1];
		FieldNames = TranslateName(Column->FieldName);
		SS = Column->Title->Caption;
		TitleNames =  GetPiece(SS, "|",1);
		SS = GetPiece(SS, "|",2);
		if (SS != "")  TitleNames += "-> " + SS;
		Title = Title + " пол¤ > "+ TitleNames + " <";
		FieldNames = FieldNames.UpperCase();
		FieldNamesList->Add(FieldNames);
		TitleNamesList->Add(TitleNames);
	}
	RestValue RestData;
	if (SimpleSelHistoryID(this, 0,Title,TableName,ID,FieldNamesList,TitleNamesList,RestData)) {
//		RestoreValue(RestData,!All);
	}
}
//---------------------------------------------------------------------------
AnsiString __fastcall TPrintList::FilterMess(AnsiString mess)
{
  AnsiString str,tempstr;
  AnsiString retstr=mess;
  AnsiString fieldname,fname;
  switch (filter)
  {
    case 1:  // match whole record
      str=ListMatches->Edit1->Text;
      if(ListMatches->RadioButton2->Checked)
      {
        mess=mess.UpperCase();
        str=str.UpperCase();
      }
      if(!mess.Pos(str))
      {
        retstr="";
      }

    break;
    case 2:  // field
// get field name from box
      fieldname=ListMatches->CBox1->Items->Strings[ListMatches->CBox1->ItemIndex];

// get record from field in table
      tempstr=Main->ZTable->FieldByName(fieldname)->AsString;

// get string to match from item box
      str=ListMatches->CBox2->Items->Strings[ListMatches->CBox2->ItemIndex];
      if(str=="ALL")
      {// if items =all match all
        str=tempstr;
      }
      if((str=="Not Empty")&(tempstr.Length()>=0))
      {// if items =Not Empty match anything filled out
        str=tempstr;
      }
      if(ListMatches->RadioButton2->Checked)
      {
        str=str.UpperCase();
        tempstr=tempstr.UpperCase();
      }

      if(!tempstr.Pos(str))
      {
        retstr="";
      }
    break;

    case 3:  // match field AND whole record
      // get field name from box
      fname=ListMatches->ComboBox1->Items->Strings[ListMatches->ComboBox1->ItemIndex];
      // get record from field in table
      mess=Main->ZTable->FieldByName(fname)->AsString;
      str=ListMatches->Edit2->Text;
      if(ListMatches->RadioButton2->Checked)
      {
        mess=mess.UpperCase();
        str=str.UpperCase();
      }
      if(!mess.Pos(str))
      {
        retstr="";
      }
    break;

    case 4:  // field and/or field
      bool F1=false;
      bool F2=false;
      // get field name from box
      fieldname=ListMatches->ComboBox2->Items->Strings[ListMatches->ComboBox2->ItemIndex];
      // get record from field in table
      tempstr=Main->ZTable->FieldByName(fieldname)->AsString;

      // get string to match from item box
      str=ListMatches->ComboBox3->Items->Strings[ListMatches->ComboBox3->ItemIndex];
      if(str=="ALL")
      {// if items =all match all
        str=tempstr;
      }
      if((str=="Not Empty")&(tempstr.Length()>=0))
      {// if items =Not Empty match anything filled out
        str=tempstr;
      }
      if(ListMatches->RadioButton2->Checked)
      {
        str=str.UpperCase();
        tempstr=tempstr.UpperCase();
      }

      if(tempstr.Pos(str))  // first test - match found
      {
        F1=true;
      }
      // test 2
      // get field name from box
      fieldname=ListMatches->ComboBox5->Items->Strings[ListMatches->ComboBox5->ItemIndex];
      // get record from field in table
      tempstr=Main->ZTable->FieldByName(fieldname)->AsString;

      // get string to match from item box
      str=ListMatches->ComboBox4->Items->Strings[ListMatches->ComboBox4->ItemIndex];
      if(str=="ALL")
      {// if items =all match all
        str=tempstr;
      }
      if((str=="Not Empty")&(tempstr.Length()>=0))
      {// if items =Not Empty match anything filled out
        str=tempstr;
      }
      if(ListMatches->RadioButton2->Checked)
      {
        str=str.UpperCase();
        tempstr=tempstr.UpperCase();
      }
      if(tempstr.Pos(str))  // second test - match found
      {
        F2=true;
      }
      if(ListMatches->RadioButton3->Checked)// and
      {
        if((!F1)||(!F2))
          retstr="";
      }
      if(ListMatches->RadioButton4->Checked)// or
      {
        if((!F1)&&(!F2))
          retstr="";
      }
    break;
  }
  return retstr;
}
int         	AuthClientUser::ClientProcessThread(SingleThread * self)
{
	CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
	int   timeout = SOCKET_TIMEOUT;
	setsockopt(m_ClientSocket,   SOL_SOCKET,   SO_RCVTIMEO,(char*)&timeout,   sizeof(timeout));

	vector<BYTE>	output;
	//1. Auth
	if(!this->SocketReadBuff(sizeof(tagCClientAuth), &output))
	{
		SocketReadError("tagCClientAuth SocketReadBuff Error");
		return -1;
	}
	tagCClientAuth	*clietAuth = (tagCClientAuth	*)&output[0];
	clietAuth->UserName[sizeof(clietAuth->UserName)-1] = '\0';
	m_UserName = clietAuth->UserName;
	m_UserName = m_UserName.LowerCase();
	m_UserName = m_UserName.Trim();
	string input_username = clietAuth->UserName;
	SendLogMessage(FormatStr(GBText("用户[%s]开始验证..."), m_UserName));
	m_Build = clietAuth->Build;
	BigNumber A, s, B, K, M2;
	A.SetBinary(clietAuth->A, sizeof(clietAuth->A));
	m_IsChargeProcess = clietAuth->IsChargeProcess;
	if(!m_SRP6Server.CalcKey(input_username, input_username, A, &s, &B, &K))
	{
		SendLogMessage("错误(1)");
		SocketReadError("CalcKey Error");
		return -1;
	}

	tagSClientAuth	sendAuth;
	memcpy(sendAuth.s, s.AsByteArray(), sizeof(sendAuth.s));
	memcpy(sendAuth.B, B.AsByteArray(), sizeof(sendAuth.B));
	if(!this->SendAuthMessage((BYTE *)&sendAuth, sizeof(sendAuth)))
	{
		SocketReadError("tagSClientAuth SocketSend Error");
		return -1;
	}
	//2. Auth Check
	if(!this->SocketReadBuff(sizeof(tagCAuthCheck), &output))
	{
		SocketReadError("tagCAuthCheck SocketReadBuff Error");
		return -1;
	}
	tagCAuthCheck *clientAuthCheck = (tagCAuthCheck *)&output[0];
	if(!m_SRP6Server.CheckClientAuth(input_username, clientAuthCheck->M, &M2))
	{
		SendLogMessage("错误(2)");
		SocketReadError("Auth Check Error");
		return -1;
	}
	tagSAuthCheck	sendAuthCheck;
	memcpy(sendAuthCheck.M2, M2.AsByteArray(), sizeof(sendAuthCheck.M2));
	if(!this->SendAuthMessage((BYTE *)&sendAuthCheck, sizeof(sendAuthCheck)))
	{
		SocketReadError("tagSAuthCheck SocketSend Error");
		return -1;
	}
	m_AuthCrypt.Init(&K, WOWWGUserServerEncryptionKey, WOWWGUserServerDecryptionKey);

	vector<String> outputMsg;
	if(!CheckUserCanLogin(&outputMsg))
	{
		for(DWORD i=0; i<outputMsg.size(); i++)
		{
			SendLogMessage(outputMsg[i]);
		}
		SocketReadError(FormatStr("[RefuseLogin]:%s", m_RefuseLoginReason));
		return -1;
	}
	for(DWORD i=0; i<outputMsg.size(); i++)
	{
		SendLogMessage(outputMsg[i]);
	}
//	SendLogMessage(FormatStr(GBText("用户[%s]验证成功!"), m_UserName));

	TDateTime expTime;
	if(m_IsChargeProcess)
	{
		//充值
		BYTE len = 0;
		if(!this->SocketReadBYTE(&len))
		{
			SendLogMessage("错误(17)");
			SocketReadError("Charge CardNo Read Len Error");
			return -1;
		}
		if(!this->SocketReadBuff(len, &output))
		{
			SendLogMessage("错误(14)");
			SocketReadError("Charge CardNo Read Error");
			return -1;
		}
		AnsiString cardNo = AnsiString((char *)&output[0], len);
		cardNo = cardNo.Trim();
		cardNo = cardNo.UpperCase();
		outputMsg.clear();
		if(!Charge(m_ADOQuery, m_UserName, cardNo, &outputMsg))
		{
			for(DWORD i=0; i<outputMsg.size(); i++)
			{
				SendLogMessage(outputMsg[i]);
			}
			SocketReadError("Charge Fail!");
			return -1;
		}

		for(DWORD i=0; i<outputMsg.size(); i++)
		{
			SendLogMessage(outputMsg[i]);
		}

		outputMsg.clear();
		if(!GetExpireTime(m_ADOQuery, m_UserName, &outputMsg, &expTime))
		{
			for(DWORD i=0; i<outputMsg.size(); i++)
			{
				SendLogMessage(outputMsg[i]);
			}
			SocketReadError("Charge GetExpireTime Fail!");
			return -1;
		}
		for(DWORD i=0; i<outputMsg.size(); i++)
		{
			SendLogMessage(outputMsg[i]);
		}

		SendLogMessage(GBText("充值成功!"));
	}
	else
	{
		//验证
		tagWOWAddrInfo	addrInfo;
		if(!FindAddrInfo(m_Build, &addrInfo))
		{
			SendLogMessage("错误(3)");
			GetLog()->Error("No Build Msg. Build = %d", m_Build);
			SocketReadError("We Don't Have This Build!");
			return -1;
		}

		outputMsg.clear();
		if(!GetExpireTime(m_ADOQuery, m_UserName, &outputMsg, &expTime))
		{
			for(DWORD i=0; i<outputMsg.size(); i++)
			{
				SendLogMessage(outputMsg[i]);
			}
			SocketReadError("GetExpireTime Fail!");
			return -1;
		}

		for(DWORD i=0; i<outputMsg.size(); i++)
		{
			SendLogMessage(outputMsg[i]);
		}

		tagClientAddrInfo	info;
		info.Address = addrInfo.Addr;
		info.Offset = addrInfo.Offset;
		info.ExpireTime = expTime;
		if(!this->SendAuthMessage((BYTE *)&info, sizeof(tagClientAddrInfo)))
		{
			SocketReadError("tagClientAddrInfo SocketSend Error");
			return -1;
		}
		m_ADOQuery->SQL->Text = FormatStr("SELECT * FROM wow_msg where msg_key = '%s'", L"login");
		if(OpenSQL(m_ADOQuery))
		{
			if(m_ADOQuery->RecordCount)
			{
				m_ADOQuery->First();
				String	text = m_ADOQuery->FieldByName("msg")->AsString;
				SendLogMessage(text);
			}
		}
		SendLogMessage(GBText("验证成功!"));
	}

	SendLogMessage(GBText(FormatStr("你的帐号[%s]到期时间为:%s", m_UserName, DateTimeToStr(expTime))));
	OnLoginSuccess();
	Sleep(1000);
	this->SetIsClosed(1);
	return -1;
}