From 5906e45e654c496a800950a6c3e1efcec2fc4cce Mon Sep 17 00:00:00 2001 From: anderson.peterle@previdencia.gov.br Date: Fri, 3 Apr 2009 18:54:18 +0000 Subject: [PATCH] Adequacoes ao uso de library unica, para reaproveitamento de codigos, propriedades e metodos, faxina de codigo. --- CACIC_Library.pas | 303 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------- main.pas | 422 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- mapa/acesso.pas | 32 +++++++++++++++++++++----------- mapa/main_mapa.pas | 516 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 4 files changed, 598 insertions(+), 675 deletions(-) diff --git a/CACIC_Library.pas b/CACIC_Library.pas index 56b4cb7..7dd33bc 100644 --- a/CACIC_Library.pas +++ b/CACIC_Library.pas @@ -46,9 +46,15 @@ unit CACIC_Library; interface -uses - Windows, SysUtils, StrUtils, md5; - +uses + Windows, + Classes, + SysUtils, + StrUtils, + MD5, + DCPcrypt2, + DCPrijndael, + DCPbase64; type { ------------------------------------------------------------------------------ @@ -84,19 +90,20 @@ type g_osVersionInfoExtended: boolean; public - function isWindowsVista() : boolean; - function isWindowsGEVista() : boolean; - function isWindowsXP() : boolean; - function isWindowsGEXP() : boolean; - function isWindowsNTPlataform() : boolean; - function isWindows2000() : boolean; - function isWindowsNT() : boolean; - function isWindows9xME() : boolean; - function getWindowsStrId() : string; - function isWindowsAdmin(): Boolean; - function createSampleProcess(p_cmd: string; p_wait: boolean ): boolean; + function isWindowsVista() : boolean; + function isWindowsGEVista() : boolean; + function isWindowsXP() : boolean; + function isWindowsGEXP() : boolean; + function isWindowsNTPlataform() : boolean; + function isWindows2000() : boolean; + function isWindowsNT() : boolean; + function isWindows9xME() : boolean; + function getWindowsStrId() : string; + function getWinDir() : string; + function getHomeDrive : string; + function isWindowsAdmin() : boolean; + function createSampleProcess(p_cmd: string; p_wait: boolean ) : boolean; procedure showTrayIcon(p_visible:boolean); - function GetFileHash(strFileName : String) : String; end; {*------------------------------------------------------------------------------ @@ -128,16 +135,49 @@ type public Windows : TCACIC_Windows; /// objeto de informacoes de windows - Debug : TCACIC_Debug; /// objeto de tratamento de debug + Debug : TCACIC_Debug; /// objeto de tratamento de debug procedure setCacicPath(p_cacic_path: string); - function getCacicPath(): string; - function trimEspacosExcedentes(p_str: string): string; - function isAppRunning( p_app_name: PAnsiChar ): boolean; + function deCrypt(p_Data : String) : String; + function enCrypt(p_Data : String) : String; + function explode(p_String, p_Separador : String) : TStrings; + function implode(p_Array : TStrings ; p_Separador : String) : String; + function getCacicPath() : String; + function getCipherKey() : String; + function getIV() : String; + function getKeySize() : integer; + function getBlockSize() : integer; + function getDatFileName() : String; + function getSeparatorKey() : String; + function getFileHash(strFileName : String) : String; + function isAppRunning( p_app_name: PAnsiChar ) : boolean; + function padWithZeros(const str : string; size : integer) : String; + function trimEspacosExcedentes(p_str: string) : String; + end; // Declaração de constantes para a biblioteca -const CACIC_PROCESS_WAIT = true; // aguardar fim do processo -const CACIC_PROCESS_NOWAIT = false; // não aguardar o fim do processo +const + CACIC_PROCESS_WAIT = true; // aguardar fim do processo + CACIC_PROCESS_NOWAIT = false; // não aguardar o fim do processo + +// Some constants that are dependant on the cipher being used +// Assuming MCRYPT_RIJNDAEL_128 (i.e., 128bit blocksize, 256bit keysize) +const + CACIC_KEYSIZE = 32; // 32 bytes = 256 bits + CACIC_BLOCKSIZE = 16; // 16 bytes = 128 bits + +// Chave AES. Recomenda-se que cada empresa altere a sua chave. +// Esta chave é passada como parâmetro para o Gerente de Coletas que, por sua vez, +// passa para o Inicializador de Coletas e este passa para os coletores... +const + CACIC_CIPHERKEY = 'CacicBrasil'; + CACIC_IV = 'abcdefghijklmnop'; + CACIC_SEPARATORKEY = '=CacicIsFree='; // Usada apenas para o cacic2.dat + +// Arquivo local para armazenamento de configurações e informações coletadas +const + CACIC_DATFILENAME = 'cacic2.dat'; + var P_OSVersionInfo: POSVersionInfo; @@ -178,6 +218,80 @@ begin end; {*------------------------------------------------------------------------------ + Retorna a pasta de instalação do MS-Windows +-------------------------------------------------------------------------------} +function TCACIC_Windows.getWinDir : string; +var + WinPath: array[0..MAX_PATH + 1] of char; +begin + GetWindowsDirectory(WinPath,MAX_PATH); + Result := StrPas(WinPath)+'\'; +end; + +{*------------------------------------------------------------------------------ + Retorna a unidade de instalação do MS-Windows +-------------------------------------------------------------------------------} +function TCACIC_Windows.getHomeDrive : string; +begin + Result := MidStr(getWinDir,1,3); //x:\ +end; + +{*------------------------------------------------------------------------------ + Retorna array de elementos com base em separador + + @param p_String String contendo campos e valores separados por caracter ou string + @param p_Separador String separadora de campos e valores +-------------------------------------------------------------------------------} +Function TCACIC.explode(p_String, p_Separador : String) : TStrings; +var + strItem : String; + ListaAuxUTILS : TStrings; + NumCaracteres, + TamanhoSeparador, + I : Integer; +Begin + ListaAuxUTILS := TStringList.Create; + strItem := ''; + NumCaracteres := Length(p_String); + TamanhoSeparador := Length(p_Separador); + I := 1; + While I <= NumCaracteres Do + Begin + If (Copy(p_String,I,TamanhoSeparador) = p_Separador) or (I = NumCaracteres) Then + Begin + if (I = NumCaracteres) then strItem := strItem + p_String[I]; + ListaAuxUTILS.Add(trim(strItem)); + strItem := ''; + I := I + (TamanhoSeparador-1); + end + Else + strItem := strItem + p_String[I]; + + I := I + 1; + End; + Explode := ListaAuxUTILS; +end; + +{*------------------------------------------------------------------------------ + Retorna string com campos e valores separados por caracter ou string + + @param p_Array Array contendo campos e valores + @param p_Separador String separadora de campos e valores +-------------------------------------------------------------------------------} +Function TCACIC.implode(p_Array : TStrings ; p_Separador : String) : String; +var intAux : integer; + strAux : string; +Begin + strAux := ''; + For intAux := 0 To p_Array.Count -1 do + Begin + if (strAux<>'') then strAux := strAux + p_Separador; + strAux := strAux + p_Array[intAux]; + End; + Implode := strAux; +end; + +{*------------------------------------------------------------------------------ Elimina espacos excedentes na string @param p_str String a excluir espacos @@ -537,7 +651,7 @@ end; @autor: Anderson Peterle @param p_strFileName - Nome do arquivo para extração do HashCode -------------------------------------------------------------------------------} -function TCACIC_Windows.GetFileHash(strFileName : String) : String; +function TCACIC.GetFileHash(strFileName : String) : String; Begin Result := 'Arquivo "'+strFileName+'" Inexistente!'; if (FileExists(strFileName)) then @@ -575,4 +689,149 @@ procedure TCACIC_Windows.showTrayIcon(p_visible:boolean); End; End; +{*------------------------------------------------------------------------------ + Obter a chave para criptografia simétrica + + @return String contendo a chave simétrica +-------------------------------------------------------------------------------} +function TCACIC.getCipherKey(): string; +begin + Result := CACIC_CIPHERKEY; +end; + +{*------------------------------------------------------------------------------ + Obter o vetor de inicialização para criptografia + + @return String contendo o vetor de inicialização +-------------------------------------------------------------------------------} +function TCACIC.getIV(): string; +begin + Result := CACIC_IV; +end; + +{*------------------------------------------------------------------------------ + Obter o valor para tamanho da chave de criptografia + + @return Integer contendo o tamanho para chave de criptografia +-------------------------------------------------------------------------------} +function TCACIC.getKeySize(): Integer; +begin + Result := CACIC_KEYSIZE; +end; + +{*------------------------------------------------------------------------------ + Obter o valor para tamanho do bloco de criptografia + + @return Integer contendo o tamanho para bloco de criptografia +-------------------------------------------------------------------------------} +function TCACIC.getBlockSize(): Integer; +begin + Result := CACIC_BLOCKSIZE; +end; + +{*------------------------------------------------------------------------------ + Obter o nome do arquivo de informações de configurações e dados locais + + @return String contendo o nome do arquivo de configurações e dados locais +-------------------------------------------------------------------------------} +function TCACIC.getDatFileName(): string; +begin + Result := CACIC_DATFILENAME; +end; + +{*------------------------------------------------------------------------------ + Obter o separador para criação de listas locais + + @return String contendo o separador de campos e valores +-------------------------------------------------------------------------------} +function TCACIC.getSeparatorKey(): string; +begin + Result := CACIC_SEPARATORKEY; +end; + +// Encrypt a string and return the Base64 encoded result +function TCACIC.enCrypt(p_Data : String) : String; +var + l_Cipher : TDCP_rijndael; + l_Data, l_Key, l_IV : string; +begin + Try + // Pad Key, IV and Data with zeros as appropriate + l_Key := PadWithZeros(CACIC_CIPHERKEY,CACIC_KEYSIZE); + l_IV := PadWithZeros(CACIC_IV,CACIC_BLOCKSIZE); + l_Data := PadWithZeros(p_Data,CACIC_BLOCKSIZE); + + // Create the cipher and initialise according to the key length + l_Cipher := TDCP_rijndael.Create(nil); + if Length(CACIC_CIPHERKEY) <= 16 then + l_Cipher.Init(l_Key[1],128,@l_IV[1]) + else if Length(CACIC_CIPHERKEY) <= 24 then + l_Cipher.Init(l_Key[1],192,@l_IV[1]) + else + l_Cipher.Init(l_Key[1],256,@l_IV[1]); + + // Encrypt the data + l_Cipher.EncryptCBC(l_Data[1],l_Data[1],Length(l_Data)); + + // Free the cipher and clear sensitive information + l_Cipher.Free; + FillChar(l_Key[1],Length(l_Key),0); + + // Return the Base64 encoded result + Result := Base64EncodeStr(l_Data); + Except +// LogDiario('Erro no Processo de Criptografia'); + End; +end; + +function TCACIC.deCrypt(p_Data : String) : String; +var + l_Cipher : TDCP_rijndael; + l_Data, l_Key, l_IV : string; +begin + Try + // Pad Key and IV with zeros as appropriate + l_Key := PadWithZeros(CACIC_CIPHERKEY,CACIC_KEYSIZE); + l_IV := PadWithZeros(CACIC_IV,CACIC_BLOCKSIZE); + + // Decode the Base64 encoded string + l_Data := Base64DecodeStr(p_Data); + + // Create the cipher and initialise according to the key length + l_Cipher := TDCP_rijndael.Create(nil); + if Length(CACIC_CIPHERKEY) <= 16 then + l_Cipher.Init(l_Key[1],128,@l_IV[1]) + else if Length(CACIC_CIPHERKEY) <= 24 then + l_Cipher.Init(l_Key[1],192,@l_IV[1]) + else + l_Cipher.Init(l_Key[1],256,@l_IV[1]); + + // Decrypt the data + l_Cipher.DecryptCBC(l_Data[1],l_Data[1],Length(l_Data)); + + // Free the cipher and clear sensitive information + l_Cipher.Free; + FillChar(l_Key[1],Length(l_Key),0); + + // Return the result + Result := l_Data; + Except +// LogDiario('Erro no Processo de Decriptografia'); + End; +end; + +// Pad a string with zeros so that it is a multiple of size +function TCACIC.padWithZeros(const str : string; size : integer) : string; +var origsize, i : integer; +begin + Result := str; + origsize := Length(Result); + if ((origsize mod size) <> 0) or (origsize = 0) then + begin + SetLength(Result,((origsize div size)+1)*size); + for i := origsize+1 to Length(Result) do + Result[i] := #0; + end; +end; + end. diff --git a/main.pas b/main.pas index 29198fe..08879b3 100755 --- a/main.pas +++ b/main.pas @@ -32,9 +32,6 @@ uses Windows, registry, dialogs, PJVersionInfo, - DCPcrypt2, - DCPrijndael, - DCPbase64, ComCtrls, IdBaseComponent, IdComponent, @@ -48,16 +45,9 @@ uses Windows, const WM_MYMESSAGE = WM_USER+100; // Declaração das variáveis globais. -var p_path_cacic, - p_path_cacic_ini, - p_Shell_Command, +var p_Shell_Command, p_Shell_Path, v_versao, - g_te_so, - v_CipherKey, - v_SeparatorKey, - v_IV, - v_DatFileName, v_DataCacic2DAT, v_Tamanho_Arquivo, strConfigsPatrimonio : string; @@ -235,9 +225,6 @@ type Function Explode(Texto, Separador : String) : TStrings; Function GetValorDatMemoria(p_Chave : String; p_tstrCipherOpened : TStrings) : String; Procedure SetValorDatMemoria(p_Chave : string; p_Valor : String; p_tstrCipherOpened : TStrings); - function PadWithZeros(const str : string; size : integer) : string; - function EnCrypt(p_Data : String) : String; - function DeCrypt(p_Data : String) : String; function URLDecode(const S: string): string; Function XML_RetornaValor(Tag : String; Fonte : String): String; end; @@ -245,11 +232,6 @@ type var FormularioGeral : TFormularioGeral; boolServerON : Boolean; -// Some constants that are dependant on the cipher being used -// Assuming MCRYPT_RIJNDAEL_128 (i.e., 128bit blocksize, 256bit keysize) -const KeySize = 32; // 32 bytes = 256 bits - BlockSize = 16; // 16 bytes = 128 bits - implementation @@ -287,20 +269,6 @@ var VetorUON1 : TVetorUON1; VetorUON1a : TVetorUON1a; VetorUON2 : TVetorUON2; -// Pad a string with zeros so that it is a multiple of size -function TFormularioGeral.PadWithZeros(const str : string; size : integer) : string; -var - origsize, i : integer; -begin - Result := str; - origsize := Length(Result); - if ((origsize mod size) <> 0) or (origsize = 0) then - begin - SetLength(Result,((origsize div size)+1)*size); - for i := origsize+1 to Length(Result) do - Result[i] := #0; - end; -end; Function TFormularioGeral.RetornaValorVetorUON1(id1 : string) : String; var I : Integer; begin @@ -355,7 +323,7 @@ begin strTagName := '' else if (Parser.CurPartType in [ptContent, ptCData]) and (strTagName='IT1')Then Begin - strAux1 := DeCrypt(Parser.CurContent); + strAux1 := g_oCacic.deCrypt(Parser.CurContent); if (strItemName = 'ID1') then Begin VetorUON1[i].id1 := strAux1; @@ -387,7 +355,7 @@ begin strTagName := '' else if (Parser.CurPartType in [ptContent, ptCData]) and (strTagName='IT1A')Then Begin - strAux1 := DeCrypt(Parser.CurContent); + strAux1 := g_oCacic.deCrypt(Parser.CurContent); if (strItemName = 'ID1') then Begin VetorUON1a[i].id1 := strAux1; @@ -433,7 +401,7 @@ begin strTagName := '' else if (Parser.CurPartType in [ptContent, ptCData]) and (strTagName='IT2')Then Begin - strAux1 := DeCrypt(Parser.CurContent); + strAux1 := g_oCacic.deCrypt(Parser.CurContent); if (strItemName = 'ID1A') then Begin VetorUON2[i].id1a := strAux1; @@ -460,89 +428,6 @@ begin Parser.Free; end; -// Encrypt a string and return the Base64 encoded result -function TFormularioGeral.EnCrypt(p_Data : String) : String; -var - l_Cipher : TDCP_rijndael; - l_Data, l_Key, l_IV : string; -begin - if boolCrypt then - Begin - Try - // Pad Key, IV and Data with zeros as appropriate - l_Key := PadWithZeros(v_CipherKey,KeySize); - log_DEBUG('Encrypt: l_Key => "'+l_Key+'"'); - l_IV := PadWithZeros(v_IV,BlockSize); - log_DEBUG('Encrypt: l_IV => "'+l_IV+'"'); - l_Data := PadWithZeros(p_Data,BlockSize); - log_DEBUG('Encrypt: l_Data antes CBC => "'+l_Data+'"'); - // Create the cipher and initialise according to the key length - l_Cipher := TDCP_rijndael.Create(nil); - if Length(v_CipherKey) <= 16 then - l_Cipher.Init(l_Key[1],128,@l_IV[1]) - else if Length(v_CipherKey) <= 24 then - l_Cipher.Init(l_Key[1],192,@l_IV[1]) - else - l_Cipher.Init(l_Key[1],256,@l_IV[1]); - - // Encrypt the data - l_Cipher.EncryptCBC(l_Data[1],l_Data[1],Length(l_Data)); - log_DEBUG('Encrypt: l_Data após CBC e Antes do Base64Encode=> "'+l_Data+'"'); - // Free the cipher and clear sensitive information - l_Cipher.Free; - FillChar(l_Key[1],Length(l_Key),0); - - // Return the Base64 encoded result - Result := Base64EncodeStr(l_Data); - log_DEBUG('Encrypt: l_Data após Base64Encode=> "'+l_Data+'"'); - Except - log_diario('Erro no Processo de Criptografia'); - End; - End - else - Result := p_Data; -end; - -function TFormularioGeral.DeCrypt(p_Data : String) : String; -var - l_Cipher : TDCP_rijndael; - l_Data, l_Key, l_IV : string; -begin - if boolCrypt then - Begin - Try - // Pad Key and IV with zeros as appropriate - l_Key := PadWithZeros(v_CipherKey,KeySize); - l_IV := PadWithZeros(v_IV,BlockSize); - - // Decode the Base64 encoded string - l_Data := Base64DecodeStr(p_Data); - - // Create the cipher and initialise according to the key length - l_Cipher := TDCP_rijndael.Create(nil); - if Length(v_CipherKey) <= 16 then - l_Cipher.Init(l_Key[1],128,@l_IV[1]) - else if Length(v_CipherKey) <= 24 then - l_Cipher.Init(l_Key[1],192,@l_IV[1]) - else - l_Cipher.Init(l_Key[1],256,@l_IV[1]); - - // Decrypt the data - l_Cipher.DecryptCBC(l_Data[1],l_Data[1],Length(l_Data)); - - // Free the cipher and clear sensitive information - l_Cipher.Free; - FillChar(l_Key[1],Length(l_Key),0); - - // Return the result - Result := trim(RemoveZerosFimString(l_Data)); - Except - log_diario('Erro no Processo de Decriptografia'); - End; - End - else - Result := p_Data; -end; function Pode_Coletar : boolean; var v_JANELAS_EXCECAO, v_plural1, v_plural2 : string; @@ -551,15 +436,15 @@ var v_JANELAS_EXCECAO, v_plural1, v_plural2 : string; v_contador, intContaJANELAS, intAux : integer; Begin // Se eu conseguir matar o arquivo abaixo é porque Ger_Cols e Ini_Cols já finalizaram suas atividades... - FormularioGeral.Matar(p_path_cacic+'temp\','aguarde_SRCACIC.txt'); - FormularioGeral.Matar(p_path_cacic+'temp\','aguarde_GER.txt'); - FormularioGeral.Matar(p_path_cacic+'temp\','aguarde_INI.txt'); + FormularioGeral.Matar(g_oCacic.getCacicPath+'temp\','aguarde_SRCACIC.txt'); + FormularioGeral.Matar(g_oCacic.getCacicPath+'temp\','aguarde_GER.txt'); + FormularioGeral.Matar(g_oCacic.getCacicPath+'temp\','aguarde_INI.txt'); intContaJANELAS := 0; h := 0; - if (not FileExists(p_path_cacic + 'temp\aguarde_GER.txt') and - not FileExists(p_path_cacic + 'temp\aguarde_SRCACIC.txt') and - not FileExists(p_path_cacic + 'temp\aguarde_INI.txt')) then + if (not FileExists(g_oCacic.getCacicPath + 'temp\aguarde_GER.txt') and + not FileExists(g_oCacic.getCacicPath + 'temp\aguarde_SRCACIC.txt') and + not FileExists(g_oCacic.getCacicPath + 'temp\aguarde_INI.txt')) then Begin FormularioGeral.CipherOpen; // Verificação das janelas abertas para que não aconteça coletas caso haja aplicações pesadas rodando (configurado no Módulo Gerente) @@ -611,19 +496,19 @@ Begin if (intContaJANELAS = 0) and (h = 0) and - (not FileExists(p_path_cacic + 'temp\aguarde_GER.txt')) and - (not FileExists(p_path_cacic + 'temp\aguarde_SRCACIC.txt')) and - (not FileExists(p_path_cacic + 'temp\aguarde_INI.txt')) then + (not FileExists(g_oCacic.getCacicPath + 'temp\aguarde_GER.txt')) and + (not FileExists(g_oCacic.getCacicPath + 'temp\aguarde_SRCACIC.txt')) and + (not FileExists(g_oCacic.getCacicPath + 'temp\aguarde_INI.txt')) then Result := true else Begin FormularioGeral.log_DEBUG('Ação NEGADA!'); if (intContaJANELAS=0) then - if (FileExists(p_path_cacic + 'temp\aguarde_SRCACIC.txt')) then + if (FileExists(g_oCacic.getCacicPath + 'temp\aguarde_SRCACIC.txt')) then FormularioGeral.log_DEBUG('Suporte Remoto em atividade.') - else if (FileExists(p_path_cacic + 'temp\aguarde_GER.txt')) then + else if (FileExists(g_oCacic.getCacicPath + 'temp\aguarde_GER.txt')) then FormularioGeral.log_DEBUG('Gerente de Coletas em atividade.') - else if (FileExists(p_path_cacic + 'temp\aguarde_INI.txt')) then + else if (FileExists(g_oCacic.getCacicPath + 'temp\aguarde_INI.txt')) then FormularioGeral.log_DEBUG('Inicializador de Coletas em atividade.') else FormularioGeral.CipherClose; Result := false; @@ -680,33 +565,33 @@ var v_DatFile : TextFile; v_strCipherClosed : string; begin - log_DEBUG('Fechando '+v_DatFileName); + log_DEBUG('Fechando '+g_oCacic.getDatFileName); if boolDebugs then for intAux := 0 to (v_tstrCipherOpened.Count-1) do log_DEBUG('Posição ['+inttostr(intAux)+']='+v_tstrCipherOpened[intAux]); try - FileSetAttr (v_DatFileName,0); // Retira os atributos do arquivo para evitar o erro FILE ACCESS DENIED em máquinas 2000 + FileSetAttr (g_oCacic.getDatFileName,0); // Retira os atributos do arquivo para evitar o erro FILE ACCESS DENIED em máquinas 2000 - log_DEBUG('Localizando arquivo: '+v_DatFileName); - AssignFile(v_DatFile,v_DatFileName); {Associa o arquivo a uma variável do tipo TextFile} + log_DEBUG('Localizando arquivo: '+g_oCacic.getDatFileName); + AssignFile(v_DatFile,g_oCacic.getDatFileName); {Associa o arquivo a uma variável do tipo TextFile} {$IOChecks off} - log_DEBUG('Abrindo arquivo: '+v_DatFileName); + log_DEBUG('Abrindo arquivo: '+g_oCacic.getDatFileName); ReWrite(v_DatFile); {Abre o arquivo texto} {$IOChecks on} - log_DEBUG('Append(2) no arquivo: '+v_DatFileName); + log_DEBUG('Append(2) no arquivo: '+g_oCacic.getDatFileName); Append(v_DatFile); log_DEBUG('Criando vetor para criptografia.'); - v_strCipherOpenImploded := Implode(v_tstrCipherOpened,v_SeparatorKey); + v_strCipherOpenImploded := Implode(v_tstrCipherOpened,g_oCacic.getSeparatorKey); - log_DEBUG('Salvando a string "'+v_strCipherOpenImploded+'" em '+v_DatFileName); - v_strCipherClosed := EnCrypt(v_strCipherOpenImploded); + log_DEBUG('Salvando a string "'+v_strCipherOpenImploded+'" em '+g_oCacic.getDatFileName); + v_strCipherClosed := g_oCacic.enCrypt(v_strCipherOpenImploded); Writeln(v_DatFile,v_strCipherClosed); {Grava a string Texto no arquivo texto} CloseFile(v_DatFile); except - log_diario('ERRO NA GRAVAÇÃO DO ARQUIVO DE CONFIGURAÇÕES.('+v_DatFileName+')'); + log_diario('ERRO NA GRAVAÇÃO DO ARQUIVO DE CONFIGURAÇÕES.('+g_oCacic.getDatFileName+')'); end; - log_DEBUG(v_DatFileName+' fechado com sucesso!'); + log_DEBUG(g_oCacic.getDatFileName+' fechado com sucesso!'); end; function TFormularioGeral.Get_File_Size(sFileToExamine: string; bInKBytes: Boolean): string; @@ -734,22 +619,22 @@ var v_DatFile : TextFile; v_strCipherClosed : string; begin - if (v_DataCacic2DAT = '') or (v_DataCacic2DAT <> FormatDateTime('ddmmyyyyhhnnsszzz', GetFolderDate(p_path_cacic + 'cacic2.dat'))) then + if (v_DataCacic2DAT = '') or (v_DataCacic2DAT <> FormatDateTime('ddmmyyyyhhnnsszzz', GetFolderDate(g_oCacic.getCacicPath + 'cacic2.dat'))) then Begin - v_DataCacic2DAT := FormatDateTime('ddmmyyyyhhnnsszzz', GetFolderDate(p_path_cacic + 'cacic2.dat')); - log_DEBUG('Abrindo '+v_DatFileName +' - DateTime Cacic2.dat=> '+v_DataCacic2DAT); + v_DataCacic2DAT := FormatDateTime('ddmmyyyyhhnnsszzz', GetFolderDate(g_oCacic.getCacicPath + 'cacic2.dat')); + log_DEBUG('Abrindo '+g_oCacic.getDatFileName +' - DateTime Cacic2.dat=> '+v_DataCacic2DAT); v_strCipherOpened := ''; - v_Tamanho_Arquivo := Get_File_Size(v_DatFileName,true); + v_Tamanho_Arquivo := Get_File_Size(g_oCacic.getDatFileName,true); if (v_Tamanho_Arquivo = '0') or - (v_Tamanho_Arquivo = '-1') then FormularioGeral.Matar(p_path_cacic,'cacic2.dat'); + (v_Tamanho_Arquivo = '-1') then FormularioGeral.Matar(g_oCacic.getCacicPath,'cacic2.dat'); - if FileExists(v_DatFileName) then + if FileExists(g_oCacic.getDatFileName) then begin - log_DEBUG(v_DatFileName+' já existe!'); - AssignFile(v_DatFile,v_DatFileName); - log_DEBUG('Abrindo '+v_DatFileName); + log_DEBUG(g_oCacic.getDatFileName+' já existe!'); + AssignFile(v_DatFile,g_oCacic.getDatFileName); + log_DEBUG('Abrindo '+g_oCacic.getDatFileName); {$IOChecks off} Reset(v_DatFile); @@ -758,30 +643,30 @@ begin log_DEBUG('Verificação de Existência.'); if (IOResult <> 0)then // Arquivo não existe, será recriado. begin - log_DEBUG('Recriando "'+v_DatFileName+'"'); + log_DEBUG('Recriando "'+g_oCacic.getDatFileName+'"'); Rewrite (v_DatFile); log_DEBUG('Inserindo Primeira Linha.'); Append(v_DatFile); end; - log_DEBUG('Lendo '+v_DatFileName); + log_DEBUG('Lendo '+g_oCacic.getDatFileName); Readln(v_DatFile,v_strCipherClosed); log_DEBUG('Povoando Variável'); while not EOF(v_DatFile) do Readln(v_DatFile,v_strCipherClosed); - log_DEBUG('Fechando '+v_DatFileName); + log_DEBUG('Fechando '+g_oCacic.getDatFileName); CloseFile(v_DatFile); log_DEBUG('Chamando Criptografia de conteúdo'); - v_strCipherOpened:= Decrypt(v_strCipherClosed); + v_strCipherOpened:= g_oCacic.deCrypt(v_strCipherClosed); end; if (trim(v_strCipherOpened)<>'') then - v_tstrCipherOpened := explode(v_strCipherOpened,v_SeparatorKey) + v_tstrCipherOpened := explode(v_strCipherOpened,g_oCacic.getSeparatorKey) else Begin - v_tstrCipherOpened := explode('Configs.ID_SO'+v_SeparatorKey+ g_oCacic.getWindowsStrId() +v_SeparatorKey+ - 'Configs.Endereco_WS'+v_SeparatorKey+'/cacic2/ws/',v_SeparatorKey); - log_DEBUG(v_DatFileName+' Inexistente. Criado o DAT em memória.'); + v_tstrCipherOpened := explode('Configs.ID_SO'+g_oCacic.getSeparatorKey+ g_oCacic.getWindowsStrId() +g_oCacic.getSeparatorKey+ + 'Configs.Endereco_WS'+g_oCacic.getSeparatorKey+'/cacic2/ws/',g_oCacic.getSeparatorKey); + log_DEBUG(g_oCacic.getDatFileName+' Inexistente. Criado o DAT em memória.'); End; Result := v_tstrCipherOpened; @@ -920,7 +805,7 @@ Begin Result := true; log_DEBUG('Verificando existência e tamanho do Gerente de Coletas...'); - v_Tamanho_Arquivo := Get_File_Size(p_path_cacic + 'modulos\ger_cols.exe',true); + v_Tamanho_Arquivo := Get_File_Size(g_oCacic.getCacicPath + 'modulos\ger_cols.exe',true); log_DEBUG('Resultado: #'+v_Tamanho_Arquivo); @@ -928,7 +813,7 @@ Begin Begin Result := false; - Matar(p_path_cacic + 'modulos\','ger_cols.exe'); + Matar(g_oCacic.getCacicPath + 'modulos\','ger_cols.exe'); InicializaTray; @@ -937,7 +822,7 @@ Begin WinExec(PChar(HomeDrive + '\chksis.exe'),SW_HIDE); sleep(30000); // 30 segundos de espera para download do ger_cols.exe - v_Tamanho_Arquivo := Get_File_Size(p_path_cacic + 'modulos\ger_cols.exe',true); + v_Tamanho_Arquivo := Get_File_Size(g_oCacic.getCacicPath + 'modulos\ger_cols.exe',true); if not(v_Tamanho_Arquivo = '0') and not(v_Tamanho_Arquivo = '-1') then Begin log_diario('Módulo Gerente de Coletas RECUPERADO COM SUCESSO!'); @@ -1142,20 +1027,20 @@ Begin log_debug('Verificando concomitância de sessões'); // Se eu conseguir matar o arquivo abaixo é porque não há outra sessão deste agente aberta... (POG? Nããão! :) ) - FormularioGeral.Matar(p_path_cacic,'aguarde_CACIC.txt'); - if (not (FileExists(p_path_cacic + 'aguarde_CACIC.txt'))) then + FormularioGeral.Matar(g_oCacic.getCacicPath,'aguarde_CACIC.txt'); + if (not (FileExists(g_oCacic.getCacicPath + 'aguarde_CACIC.txt'))) then result := true; End; procedure TFormularioGeral.VerificaDebugs; Begin boolDebugs := false; - if DirectoryExists(p_path_cacic + 'Temp\Debugs') then + if DirectoryExists(g_oCacic.getCacicPath + 'Temp\Debugs') then Begin - if (FormatDateTime('ddmmyyyy', GetFolderDate(p_path_cacic + 'Temp\Debugs')) = FormatDateTime('ddmmyyyy', date)) then + if (FormatDateTime('ddmmyyyy', GetFolderDate(g_oCacic.getCacicPath + 'Temp\Debugs')) = FormatDateTime('ddmmyyyy', date)) then Begin boolDebugs := true; - log_DEBUG('Pasta "' + p_path_cacic + 'Temp\Debugs" com data '+FormatDateTime('dd-mm-yyyy', GetFolderDate(p_path_cacic + 'Temp\Debugs'))+' encontrada. DEBUG ativado.'); + log_DEBUG('Pasta "' + g_oCacic.getCacicPath + 'Temp\Debugs" com data '+FormatDateTime('dd-mm-yyyy', GetFolderDate(g_oCacic.getCacicPath + 'Temp\Debugs'))+' encontrada. DEBUG ativado.'); End; End; End; @@ -1174,7 +1059,7 @@ begin Application.ShowMainForm:=false; g_oCacic := TCACIC.Create; //g_oCacic.showTrayIcon(false); - boolCrypt := true; + boolCrypt := true; Try // De acordo com a versão do OS, determino o ShellCommand para chamadas externas. @@ -1197,30 +1082,30 @@ begin // Caminho do aplicativo if (v_cacic_dir <> '') then - p_path_cacic := v_cacic_dir + g_oCacic.setCacicPath(v_cacic_dir) else - p_path_cacic := ExtractFilePath(Application.Exename) ; + g_oCacic.setCacicPath(ExtractFilePath(Application.Exename)) ; - if not DirectoryExists(p_path_cacic + 'Temp') then + if not DirectoryExists(g_oCacic.getCacicPath + 'Temp') then begin - ForceDirectories(p_path_cacic + 'Temp'); - Log_Diario('Criando pasta '+p_path_cacic + 'Temp'); + ForceDirectories(g_oCacic.getCacicPath + 'Temp'); + Log_Diario('Criando pasta '+g_oCacic.getCacicPath + 'Temp'); end; - if not DirectoryExists(p_path_cacic + 'Modulos') then + if not DirectoryExists(g_oCacic.getCacicPath + 'Modulos') then begin - ForceDirectories(p_path_cacic + 'Modulos'); - Log_Diario('Criando pasta '+p_path_cacic + 'Modulos'); + ForceDirectories(g_oCacic.getCacicPath + 'Modulos'); + Log_Diario('Criando pasta '+g_oCacic.getCacicPath + 'Modulos'); end; VerificaDebugs; - log_DEBUG('Pasta do Sistema: "' + p_path_cacic + '"'); + log_DEBUG('Pasta do Sistema: "' + g_oCacic.getCacicPath + '"'); if Posso_Rodar then Begin // Uma forma fácil de evitar que outra sessão deste agente seja iniciada! (POG? Nããããooo!) :)))) - AssignFile(v_Aguarde,p_path_cacic + 'aguarde_CACIC.txt'); {Associa o arquivo a uma variável do tipo TextFile} + AssignFile(v_Aguarde,g_oCacic.getCacicPath + 'aguarde_CACIC.txt'); {Associa o arquivo a uma variável do tipo TextFile} {$IOChecks off} Reset(v_Aguarde); {Abre o arquivo texto} {$IOChecks on} @@ -1233,36 +1118,29 @@ begin Writeln(v_Aguarde,'Futuramente penso em colocar aqui o pID, para possibilitar finalização via software externo...'); Append(v_Aguarde); - // Chave AES. Recomenda-se que cada empresa altere a sua chave. - // Esta chave é passada como parâmetro para o Gerente de Coletas que, por sua vez, - // passa para o Inicializador de Coletas e este passa para os coletores... - v_CipherKey := 'CacicBrasil'; - v_IV := 'abcdefghijklmnop'; - v_SeparatorKey := '=CacicIsFree='; // Usada apenas para o cacic2.dat - v_DatFileName := p_path_cacic + 'cacic2.dat'; v_DataCacic2DAT := ''; v_tstrCipherOpened := TStrings.Create; v_tstrCipherOpened := CipherOpen; - if FileExists(p_path_cacic + 'cacic2.ini') then + if FileExists(g_oCacic.getCacicPath + 'cacic2.ini') then Begin - log_DEBUG('O arquivo "'+p_path_cacic + 'cacic2.ini" ainda existe. Vou resgatar algumas chaves/valores'); - SetValorDatMemoria('Configs.EnderecoServidor' ,getValorChaveRegIni('Configs' ,'EnderecoServidor' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened); - SetValorDatMemoria('Configs.IN_EXIBE_BANDEJA' ,getValorChaveRegIni('Configs' ,'IN_EXIBE_BANDEJA' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened); - SetValorDatMemoria('Configs.TE_JANELAS_EXCECAO' ,getValorChaveRegIni('Configs' ,'TE_JANELAS_EXCECAO' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened); - SetValorDatMemoria('Configs.NU_EXEC_APOS' ,getValorChaveRegIni('Configs' ,'NU_EXEC_APOS' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened); - SetValorDatMemoria('Configs.NU_INTERVALO_EXEC' ,getValorChaveRegIni('Configs' ,'NU_INTERVALO_EXEC' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened); - SetValorDatMemoria('Configs.Endereco_WS' ,getValorChaveRegIni('Configs' ,'Endereco_WS' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened); - SetValorDatMemoria('Configs.TE_SENHA_ADM_AGENTE' ,getValorChaveRegIni('Configs' ,'TE_SENHA_ADM_AGENTE' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened); - SetValorDatMemoria('Configs.NU_INTERVALO_RENOVACAO_PATRIM' ,getValorChaveRegIni('Configs' ,'NU_INTERVALO_RENOVACAO_PATRIM' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened); - SetValorDatMemoria('Configs.DT_HR_ULTIMA_COLETA' ,getValorChaveRegIni('Configs' ,'DT_HR_ULTIMA_COLETA' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened); - SetValorDatMemoria('TcpIp.TE_ENDERECOS_MAC_INVALIDOS' ,getValorChaveRegIni('TcpIp' ,'TE_ENDERECOS_MAC_INVALIDOS' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened); - SetValorDatMemoria('TcpIp.ID_IP_REDE' ,getValorChaveRegIni('TcpIp' ,'ID_IP_REDE' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened); - SetValorDatMemoria('TcpIp.TE_IP' ,getValorChaveRegIni('TcpIp' ,'TE_IP' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened); - SetValorDatMemoria('TcpIp.TE_MASCARA' ,getValorChaveRegIni('TcpIp' ,'TE_MASCARA' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened); - SetValorDatMemoria('Patrimonio.ultima_rede_obtida' ,getValorChaveRegIni('Patrimonio' ,'ultima_rede_obtida' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened); - SetValorDatMemoria('Patrimonio.dt_ultima_renovacao' ,getValorChaveRegIni('Patrimonio' ,'dt_ultima_renovacao' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened); - Matar(p_path_cacic,'cacic2.ini'); + log_DEBUG('O arquivo "'+g_oCacic.getCacicPath + 'cacic2.ini" ainda existe. Vou resgatar algumas chaves/valores'); + SetValorDatMemoria('Configs.EnderecoServidor' ,getValorChaveRegIni('Configs' ,'EnderecoServidor' ,g_oCacic.getCacicPath + 'cacic2.ini'),v_tstrCipherOpened); + SetValorDatMemoria('Configs.IN_EXIBE_BANDEJA' ,getValorChaveRegIni('Configs' ,'IN_EXIBE_BANDEJA' ,g_oCacic.getCacicPath + 'cacic2.ini'),v_tstrCipherOpened); + SetValorDatMemoria('Configs.TE_JANELAS_EXCECAO' ,getValorChaveRegIni('Configs' ,'TE_JANELAS_EXCECAO' ,g_oCacic.getCacicPath + 'cacic2.ini'),v_tstrCipherOpened); + SetValorDatMemoria('Configs.NU_EXEC_APOS' ,getValorChaveRegIni('Configs' ,'NU_EXEC_APOS' ,g_oCacic.getCacicPath + 'cacic2.ini'),v_tstrCipherOpened); + SetValorDatMemoria('Configs.NU_INTERVALO_EXEC' ,getValorChaveRegIni('Configs' ,'NU_INTERVALO_EXEC' ,g_oCacic.getCacicPath + 'cacic2.ini'),v_tstrCipherOpened); + SetValorDatMemoria('Configs.Endereco_WS' ,getValorChaveRegIni('Configs' ,'Endereco_WS' ,g_oCacic.getCacicPath + 'cacic2.ini'),v_tstrCipherOpened); + SetValorDatMemoria('Configs.TE_SENHA_ADM_AGENTE' ,getValorChaveRegIni('Configs' ,'TE_SENHA_ADM_AGENTE' ,g_oCacic.getCacicPath + 'cacic2.ini'),v_tstrCipherOpened); + SetValorDatMemoria('Configs.NU_INTERVALO_RENOVACAO_PATRIM' ,getValorChaveRegIni('Configs' ,'NU_INTERVALO_RENOVACAO_PATRIM' ,g_oCacic.getCacicPath + 'cacic2.ini'),v_tstrCipherOpened); + SetValorDatMemoria('Configs.DT_HR_ULTIMA_COLETA' ,getValorChaveRegIni('Configs' ,'DT_HR_ULTIMA_COLETA' ,g_oCacic.getCacicPath + 'cacic2.ini'),v_tstrCipherOpened); + SetValorDatMemoria('TcpIp.TE_ENDERECOS_MAC_INVALIDOS' ,getValorChaveRegIni('TcpIp' ,'TE_ENDERECOS_MAC_INVALIDOS' ,g_oCacic.getCacicPath + 'cacic2.ini'),v_tstrCipherOpened); + SetValorDatMemoria('TcpIp.ID_IP_REDE' ,getValorChaveRegIni('TcpIp' ,'ID_IP_REDE' ,g_oCacic.getCacicPath + 'cacic2.ini'),v_tstrCipherOpened); + SetValorDatMemoria('TcpIp.TE_IP' ,getValorChaveRegIni('TcpIp' ,'TE_IP' ,g_oCacic.getCacicPath + 'cacic2.ini'),v_tstrCipherOpened); + SetValorDatMemoria('TcpIp.TE_MASCARA' ,getValorChaveRegIni('TcpIp' ,'TE_MASCARA' ,g_oCacic.getCacicPath + 'cacic2.ini'),v_tstrCipherOpened); + SetValorDatMemoria('Patrimonio.ultima_rede_obtida' ,getValorChaveRegIni('Patrimonio' ,'ultima_rede_obtida' ,g_oCacic.getCacicPath + 'cacic2.ini'),v_tstrCipherOpened); + SetValorDatMemoria('Patrimonio.dt_ultima_renovacao' ,getValorChaveRegIni('Patrimonio' ,'dt_ultima_renovacao' ,g_oCacic.getCacicPath + 'cacic2.ini'),v_tstrCipherOpened); + Matar(g_oCacic.getCacicPath,'cacic2.ini'); End; if (ParamCount > 0) then //Caso o Cacic2 seja chamado com passagem de parâmetros... @@ -1388,8 +1266,8 @@ var strDataArqLocal, strDataAtual : string; begin try - FileSetAttr (p_path_cacic + 'cacic2.log',0); // Retira os atributos do arquivo para evitar o erro FILE ACCESS DENIED em máquinas 2000 - AssignFile(HistoricoLog,p_path_cacic + 'cacic2.log'); {Associa o arquivo a uma variável do tipo TextFile} + FileSetAttr (g_oCacic.getCacicPath + 'cacic2.log',0); // Retira os atributos do arquivo para evitar o erro FILE ACCESS DENIED em máquinas 2000 + AssignFile(HistoricoLog,g_oCacic.getCacicPath + 'cacic2.log'); {Associa o arquivo a uma variável do tipo TextFile} {$IOChecks off} Reset(HistoricoLog); {Abre o arquivo texto} {$IOChecks on} @@ -1401,7 +1279,7 @@ begin end; if (trim(strMsg) <> '') then begin - DateTimeToString(strDataArqLocal, 'yyyymmdd', FileDateToDateTime(Fileage(p_path_cacic + 'cacic2.log'))); + DateTimeToString(strDataArqLocal, 'yyyymmdd', FileDateToDateTime(Fileage(g_oCacic.getCacicPath + 'cacic2.log'))); DateTimeToString(strDataAtual , 'yyyymmdd', Date); if (strDataAtual <> strDataArqLocal) then // Se o arquivo INI não é da data atual... begin @@ -1444,8 +1322,8 @@ end; procedure TFormularioGeral.Invoca_GerCols(Sender: TObject;p_acao:string); var v_versao : string; begin - Matar(p_path_cacic + 'temp\','*.txt'); - Matar(p_path_cacic + 'temp\','*.ini'); + Matar(g_oCacic.getCacicPath + 'temp\','*.txt'); + Matar(g_oCacic.getCacicPath + 'temp\','*.ini'); // Caso exista o Gerente de Coletas será verificada a versão e excluída caso antiga(Uma forma de ação pró-ativa) if ChecaGERCOLS then @@ -1454,7 +1332,7 @@ begin CipherClose; log_diario('Invocando Gerente de Coletas com ação: "'+p_acao+'"'); Timer_Nu_Exec_Apos.Enabled := False; - WinExec(PChar(p_path_cacic + 'modulos\GER_COLS.EXE /'+p_acao+' /p_CipherKey='+v_CipherKey),SW_HIDE); + WinExec(PChar(g_oCacic.getCacicPath + 'modulos\GER_COLS.EXE /'+p_acao+' /p_CipherKey='+g_oCacic.getCipherKey),SW_HIDE); End else log_diario('Não foi possível invocar o Gerente de Coletas!'); @@ -1501,7 +1379,7 @@ begin CipherOpen; - SetValorDatMemoria('Configs.TE_SO',g_te_so,v_tstrCipherOpened); + SetValorDatMemoria('Configs.TE_SO',g_oCacic.getWindowsStrId,v_tstrCipherOpened); try if FindCmdLineSwitch('execute', True) or @@ -1511,26 +1389,26 @@ begin log_DEBUG('Preparando chamada ao Gerente de Coletas...'); // Se foi gerado o arquivo ger_erro.txt o Log conterá a mensagem alí gravada como valor de chave // O Gerente de Coletas deverá ser eliminado para que seja baixado novamente por ChecaGERCOLS - if (FileExists(p_path_cacic + 'ger_erro.txt')) then + if (FileExists(g_oCacic.getCacicPath + 'ger_erro.txt')) then Begin log_diario('Gerente de Coletas eliminado devido a falha:'); log_diario(getValorDatMemoria('Erro_Fatal_Descricao',v_tstrCipherOpened)); SetaVariaveisGlobais; - Matar(p_path_cacic,'ger_erro.txt'); - Matar(p_path_cacic+'modulos\','ger_cols.exe'); + Matar(g_oCacic.getCacicPath,'ger_erro.txt'); + Matar(g_oCacic.getCacicPath+'modulos\','ger_cols.exe'); End; - if (FileExists(p_path_cacic + 'temp\reset.txt')) then + if (FileExists(g_oCacic.getCacicPath + 'temp\reset.txt')) then Begin - Matar(p_path_cacic+'temp\','reset.txt'); + Matar(g_oCacic.getCacicPath+'temp\','reset.txt'); log_diario('Reinicializando...'); SetaVariaveisGlobais; End; Timer_Nu_Exec_Apos.Enabled := False; intContaExec := 1; - If (FileExists(p_path_cacic + 'temp\cacic2.bat') or - FileExists(p_path_cacic + 'temp\ger_cols.exe')) Then + If (FileExists(g_oCacic.getCacicPath + 'temp\cacic2.bat') or + FileExists(g_oCacic.getCacicPath + 'temp\ger_cols.exe')) Then intContaExec := 2; // Muda HINT @@ -1632,33 +1510,33 @@ begin End; // Caso tenha sido baixada nova cópia do Gerente de Coletas, esta deverá ser movida para cima da atual - if (FileExists(p_path_cacic + 'temp\ger_cols.exe')) then + if (FileExists(g_oCacic.getCacicPath + 'temp\ger_cols.exe')) then Begin - log_diario('Atualizando versão do Gerente de Coletas para '+getVersionInfo(p_path_cacic + 'temp\ger_cols.exe')); + log_diario('Atualizando versão do Gerente de Coletas para '+getVersionInfo(g_oCacic.getCacicPath + 'temp\ger_cols.exe')); // O MoveFileEx não se deu bem no Win98! :| - // MoveFileEx(PChar(p_path_cacic + 'temp\ger_cols.exe'),PChar(p_path_cacic + 'modulos\ger_cols.exe'),MOVEFILE_REPLACE_EXISTING); + // MoveFileEx(PChar(g_oCacic.getCacicPath + 'temp\ger_cols.exe'),PChar(g_oCacic.getCacicPath + 'modulos\ger_cols.exe'),MOVEFILE_REPLACE_EXISTING); - CopyFile(PChar(p_path_cacic + 'temp\ger_cols.exe'),PChar(p_path_cacic + 'modulos\ger_cols.exe'),false); + CopyFile(PChar(g_oCacic.getCacicPath + 'temp\ger_cols.exe'),PChar(g_oCacic.getCacicPath + 'modulos\ger_cols.exe'),false); sleep(2000); // 2 segundos de espera pela cópia! :) (Rwindows!) - Matar(p_path_cacic+'temp\','ger_cols.exe'); + Matar(g_oCacic.getCacicPath+'temp\','ger_cols.exe'); sleep(2000); // 2 segundos de espera pela deleção! intContaExec := 2; // Forçará uma reexecução de Ger_Cols... End; // Caso tenha sido baixada nova cópia do Agente Principal, esta deverá ser movida para cima da atual pelo Gerente de Coletas... - if (FileExists(p_path_cacic + 'temp\cacic2.exe')) then //AutoUpdate! + if (FileExists(g_oCacic.getCacicPath + 'temp\cacic2.exe')) then //AutoUpdate! Begin // Verifico e excluo o Gerente de Coletas caso a versão seja anterior ao 1º release - v_versao := getVersionInfo(p_path_cacic + 'modulos\ger_cols.exe'); + v_versao := getVersionInfo(g_oCacic.getCacicPath + 'modulos\ger_cols.exe'); if ((copy(v_versao,1,5)='2.0.0') or // Versões anteriores ao 1º Release... (v_versao = '2.0.1.2') or // Tivemos alguns problemas nas versões 2.0.1.2, 2.0.1.3 e 2.0.1.4 (v_versao = '2.0.1.3') or (v_versao = '2.0.1.4') or (v_versao = '0.0.0.0')) then // Provavelmente arquivo corrompido ou versão muito antiga Begin - Matar(p_path_cacic+'modulos\','ger_cols.exe'); + Matar(g_oCacic.getCacicPath+'modulos\','ger_cols.exe'); sleep(2000); // 2 segundos de espera pela deleção! End; @@ -1672,8 +1550,8 @@ begin // A existência de "temp\cacic2.bat" significa AutoUpdate já executado! // Essa verificação foi usada no modelo antigo de AutoUpdate e deve ser mantida // até a total convergência de versões para 2.0.1.16+... - if (FileExists(p_path_cacic + 'temp\cacic2.bat')) then - Matar(p_path_cacic+'temp\','cacic2.bat'); + if (FileExists(g_oCacic.getCacicPath + 'temp\cacic2.bat')) then + Matar(g_oCacic.getCacicPath+'temp\','cacic2.bat'); // O loop 1 foi dedicado a atualizações de versões e afins... // O loop 2 deverá invocar as coletas propriamente ditas... @@ -1785,14 +1663,14 @@ begin NotifyStruc.uCallbackMessage := WM_MYMESSAGE; //User defined message // Tento apagar os arquivos indicadores de ações de coletas - FormularioGeral.Matar(p_path_cacic+'temp\','aguarde_GER.txt'); - FormularioGeral.Matar(p_path_cacic+'temp\','aguarde_INI.txt'); + FormularioGeral.Matar(g_oCacic.getCacicPath+'temp\','aguarde_GER.txt'); + FormularioGeral.Matar(g_oCacic.getCacicPath+'temp\','aguarde_INI.txt'); v_intStatus := NORMAL; // Caso os indicadores de ações de coletas não existam, ativo o ícone normal/desconectado... - if not FileExists(p_path_cacic+'temp\aguarde_GER.txt') and - not FileExists(p_path_cacic+'temp\aguarde_INI.txt') then + if not FileExists(g_oCacic.getCacicPath+'temp\aguarde_GER.txt') and + not FileExists(g_oCacic.getCacicPath+'temp\aguarde_INI.txt') then Begin if not (FormularioGeral.getValorDatMemoria('Configs.ConexaoOK',v_tstrCipherOpened)='S') then Begin @@ -2017,26 +1895,26 @@ begin else lbSemInformacoesPatrimoniais.Visible := false; - st_lb_Etiqueta1.Caption := DeCrypt(XML_RetornaValor('te_etiqueta1', strConfigsPatrimonio)); + st_lb_Etiqueta1.Caption := g_oCacic.deCrypt(XML_RetornaValor('te_etiqueta1', strConfigsPatrimonio)); st_lb_Etiqueta1.Caption := st_lb_Etiqueta1.Caption + IfThen(st_lb_Etiqueta1.Caption='','',':'); st_vl_Etiqueta1.Caption := RetornaValorVetorUON1(GetValorDatMemoria('Patrimonio.id_unid_organizacional_nivel1',v_tstrCipherOpened)); - st_lb_Etiqueta1a.Caption := DeCrypt(XML_RetornaValor('te_etiqueta1a', strConfigsPatrimonio)); + st_lb_Etiqueta1a.Caption := g_oCacic.deCrypt(XML_RetornaValor('te_etiqueta1a', strConfigsPatrimonio)); st_lb_Etiqueta1a.Caption := st_lb_Etiqueta1a.Caption + IfThen(st_lb_Etiqueta1a.Caption='','',':'); st_vl_Etiqueta1a.Caption := RetornaValorVetorUON1a(GetValorDatMemoria('Patrimonio.id_unid_organizacional_nivel1a',v_tstrCipherOpened)); - st_lb_Etiqueta2.Caption := DeCrypt(XML_RetornaValor('te_etiqueta2', strConfigsPatrimonio)); + st_lb_Etiqueta2.Caption := g_oCacic.deCrypt(XML_RetornaValor('te_etiqueta2', strConfigsPatrimonio)); st_lb_Etiqueta2.Caption := st_lb_Etiqueta2.Caption + IfThen(st_lb_Etiqueta2.Caption='','',':'); st_vl_Etiqueta2.Caption := RetornaValorVetorUON2(GetValorDatMemoria('Patrimonio.id_unid_organizacional_nivel2',v_tstrCipherOpened),GetValorDatMemoria('Patrimonio.id_local',v_tstrCipherOpened)); - st_lb_Etiqueta3.Caption := DeCrypt(XML_RetornaValor('te_etiqueta3', strConfigsPatrimonio)); + st_lb_Etiqueta3.Caption := g_oCacic.deCrypt(XML_RetornaValor('te_etiqueta3', strConfigsPatrimonio)); st_lb_Etiqueta3.Caption := st_lb_Etiqueta3.Caption + IfThen(st_lb_Etiqueta3.Caption='','',':'); st_vl_Etiqueta3.Caption := GetValorDatMemoria('Patrimonio.te_localizacao_complementar',v_tstrCipherOpened); - if (DeCrypt(XML_RetornaValor('in_exibir_etiqueta4', strConfigsPatrimonio)) = 'S') then + if (g_oCacic.deCrypt(XML_RetornaValor('in_exibir_etiqueta4', strConfigsPatrimonio)) = 'S') then begin - st_lb_Etiqueta4.Caption := DeCrypt(XML_RetornaValor('te_etiqueta4', strConfigsPatrimonio)); + st_lb_Etiqueta4.Caption := g_oCacic.deCrypt(XML_RetornaValor('te_etiqueta4', strConfigsPatrimonio)); st_lb_Etiqueta4.Caption := st_lb_Etiqueta4.Caption + IfThen(st_lb_Etiqueta4.Caption='','',':'); st_lb_Etiqueta4.Visible := true; st_vl_etiqueta4.Caption := GetValorDatMemoria('Patrimonio.te_info_patrimonio1',v_tstrCipherOpened); @@ -2047,9 +1925,9 @@ begin st_vl_etiqueta4.Visible := false; End; - if (DeCrypt(XML_RetornaValor('in_exibir_etiqueta5', strConfigsPatrimonio)) = 'S') then + if (g_oCacic.deCrypt(XML_RetornaValor('in_exibir_etiqueta5', strConfigsPatrimonio)) = 'S') then begin - st_lb_Etiqueta5.Caption := DeCrypt(XML_RetornaValor('te_etiqueta5', strConfigsPatrimonio)); + st_lb_Etiqueta5.Caption := g_oCacic.deCrypt(XML_RetornaValor('te_etiqueta5', strConfigsPatrimonio)); st_lb_Etiqueta5.Caption := st_lb_Etiqueta5.Caption + IfThen(st_lb_Etiqueta5.Caption='','',':'); st_lb_Etiqueta5.Visible := true; st_vl_etiqueta5.Caption := GetValorDatMemoria('Patrimonio.te_info_patrimonio2',v_tstrCipherOpened); @@ -2061,9 +1939,9 @@ begin End; - if (DeCrypt(XML_RetornaValor('in_exibir_etiqueta6', strConfigsPatrimonio)) = 'S') then + if (g_oCacic.deCrypt(XML_RetornaValor('in_exibir_etiqueta6', strConfigsPatrimonio)) = 'S') then begin - st_lb_Etiqueta6.Caption := DeCrypt(XML_RetornaValor('te_etiqueta6', strConfigsPatrimonio)); + st_lb_Etiqueta6.Caption := g_oCacic.deCrypt(XML_RetornaValor('te_etiqueta6', strConfigsPatrimonio)); st_lb_Etiqueta6.Caption := st_lb_Etiqueta6.Caption + IfThen(st_lb_Etiqueta6.Caption='','',':'); st_lb_Etiqueta6.Visible := true; st_vl_etiqueta6.Caption := GetValorDatMemoria('Patrimonio.te_info_patrimonio3',v_tstrCipherOpened); @@ -2075,9 +1953,9 @@ begin End; - if (DeCrypt(XML_RetornaValor('in_exibir_etiqueta7', strConfigsPatrimonio)) = 'S') then + if (g_oCacic.deCrypt(XML_RetornaValor('in_exibir_etiqueta7', strConfigsPatrimonio)) = 'S') then begin - st_lb_Etiqueta7.Caption := DeCrypt(XML_RetornaValor('te_etiqueta7', strConfigsPatrimonio)); + st_lb_Etiqueta7.Caption := g_oCacic.deCrypt(XML_RetornaValor('te_etiqueta7', strConfigsPatrimonio)); st_lb_Etiqueta7.Caption := st_lb_Etiqueta7.Caption + IfThen(st_lb_Etiqueta7.Caption='','',':'); st_lb_Etiqueta7.Visible := true; st_vl_etiqueta7.Caption := GetValorDatMemoria('Patrimonio.te_info_patrimonio4',v_tstrCipherOpened); @@ -2089,9 +1967,9 @@ begin End; - if (DeCrypt(XML_RetornaValor('in_exibir_etiqueta8', strConfigsPatrimonio)) = 'S') then + if (g_oCacic.deCrypt(XML_RetornaValor('in_exibir_etiqueta8', strConfigsPatrimonio)) = 'S') then begin - st_lb_Etiqueta8.Caption := DeCrypt(XML_RetornaValor('te_etiqueta8', strConfigsPatrimonio)); + st_lb_Etiqueta8.Caption := g_oCacic.deCrypt(XML_RetornaValor('te_etiqueta8', strConfigsPatrimonio)); st_lb_Etiqueta8.Caption := st_lb_Etiqueta8.Caption + IfThen(st_lb_Etiqueta8.Caption='','',':'); st_lb_Etiqueta8.Visible := true; st_vl_etiqueta8.Caption := GetValorDatMemoria('Patrimonio.te_info_patrimonio5',v_tstrCipherOpened); @@ -2103,9 +1981,9 @@ begin End; - if (DeCrypt(XML_RetornaValor('in_exibir_etiqueta9', strConfigsPatrimonio)) = 'S') then + if (g_oCacic.deCrypt(XML_RetornaValor('in_exibir_etiqueta9', strConfigsPatrimonio)) = 'S') then begin - st_lb_Etiqueta9.Caption := DeCrypt(XML_RetornaValor('te_etiqueta9', strConfigsPatrimonio)); + st_lb_Etiqueta9.Caption := g_oCacic.deCrypt(XML_RetornaValor('te_etiqueta9', strConfigsPatrimonio)); st_lb_Etiqueta9.Caption := st_lb_Etiqueta9.Caption + IfThen(st_lb_Etiqueta9.Caption='','',':'); st_lb_Etiqueta9.Visible := true; st_vl_etiqueta9.Caption := GetValorDatMemoria('Patrimonio.te_info_patrimonio6',v_tstrCipherOpened); @@ -2254,7 +2132,7 @@ begin strXML := URLDecode(ARequestInfo.UnparsedParams); intAux := Pos('=',strXML); strXML := copy(strXML,(intAux+1),StrLen(PAnsiChar(strXML))-intAux); - strXML := DeCrypt(strXML); + strXML := g_oCacic.deCrypt(strXML); @@ -2307,42 +2185,44 @@ begin if boolServerON then // Ordeno ao SrCACICsrv que auto-finalize Begin Log_Diario('Desativando Suporte Remoto Seguro.'); - WinExec(PChar(p_path_cacic + 'modulos\srcacicsrv.exe -kill'),SW_HIDE); + WinExec(PChar(g_oCacic.getCacicPath + 'modulos\srcacicsrv.exe -kill'),SW_HIDE); boolServerON := false; End else Begin - log_DEBUG('Invocando "'+p_path_cacic + 'modulos\srcacicsrv.exe"...'); + log_DEBUG('Invocando "'+g_oCacic.getCacicPath + 'modulos\srcacicsrv.exe"...'); Log_Diario('Ativando Suporte Remoto Seguro.'); boolAux := boolCrypt; boolCrypt := true; // Alguns cuidados necessários ao tráfego e recepção de valores pelo Gerente WEB // Some cares about send and receive at Gerente WEB - strPalavraChave := StringReplace(FormularioGeral.getValorDatMemoria('Configs.te_palavra_chave', v_tstrCipherOpened),'+','' ,[rfReplaceAll]); + strPalavraChave := FormularioGeral.getValorDatMemoria('Configs.te_palavra_chave', v_tstrCipherOpened); strPalavraChave := StringReplace(strPalavraChave,' ' ,'' ,[rfReplaceAll]); strPalavraChave := StringReplace(strPalavraChave,'"' ,'' ,[rfReplaceAll]); strPalavraChave := StringReplace(strPalavraChave,'''' ,'' ,[rfReplaceAll]); strPalavraChave := StringReplace(strPalavraChave,'\' ,'' ,[rfReplaceAll]); - strPalavraChave := StringReplace(EnCrypt(strPalavraChave),'+','',[rfReplaceAll]); + strPalavraChave := g_oCacic.enCrypt(strPalavraChave); + strPalavraChave := StringReplace(strPalavraChave,'+','',[rfReplaceAll]); - strTeSO := StringReplace(FormularioGeral.getValorDatMemoria('Configs.TE_SO', v_tstrCipherOpened),' ','',[rfReplaceAll]); - strTeSO := StringReplace(EnCrypt(strTeSO),'+','',[rfReplaceAll]); + strTeSO := trim(StringReplace(FormularioGeral.getValorDatMemoria('Configs.TE_SO', v_tstrCipherOpened),' ','',[rfReplaceAll])); + strTeSO := g_oCacic.enCrypt(strTeSO); + strTeSO := StringReplace(strTeSO,'+','',[rfReplaceAll]); - strTeNodeAddress := StringReplace(FormularioGeral.getValorDatMemoria('TcpIp.TE_NODE_ADDRESS' , v_tstrCipherOpened),' ','' ,[rfReplaceAll]); - strTeNodeAddress := StringReplace(EnCrypt(strTeNodeAddress),'+','',[rfReplaceAll]); + strTeNodeAddress := trim(StringReplace(FormularioGeral.getValorDatMemoria('TcpIp.TE_NODE_ADDRESS' , v_tstrCipherOpened),' ','' ,[rfReplaceAll])); + strTeNodeAddress := g_oCacic.enCrypt(strTeNodeAddress); + strTeNodeAddress := StringReplace(strTeNodeAddress,'+','',[rfReplaceAll]); - log_DEBUG('Invocando "'+p_path_cacic + 'modulos\srcacicsrv.exe -start [' + EnCrypt(FormularioGeral.getValorDatMemoria('Configs.EnderecoServidor', v_tstrCipherOpened)) + ']' + - '[' + EnCrypt(FormularioGeral.getValorDatMemoria('Configs.Endereco_WS' , v_tstrCipherOpened)) + ']' + + log_DEBUG('Invocando "'+g_oCacic.getCacicPath + 'modulos\srcacicsrv.exe -start [' + g_oCacic.enCrypt(FormularioGeral.getValorDatMemoria('Configs.EnderecoServidor', v_tstrCipherOpened)) + ']' + + '[' + g_oCacic.enCrypt(FormularioGeral.getValorDatMemoria('Configs.Endereco_WS' , v_tstrCipherOpened)) + ']' + '[' + strTeSO + ']' + '[' + strTeNodeAddress + ']' + '[' + strPalavraChave + ']' + - '[' + p_path_cacic + 'Temp\aguarde_srCACIC.txt' + ']'); - + '[' + g_oCacic.getCacicPath + 'Temp\aguarde_srCACIC.txt' + ']'); // Detectar versão do Windows antes de fazer a chamada seguinte... try - AssignFile(fileAguarde,p_path_cacic + 'Temp\aguarde_srCACIC.txt'); + AssignFile(fileAguarde,g_oCacic.getCacicPath + 'Temp\aguarde_srCACIC.txt'); {$IOChecks off} Reset(fileAguarde); {Abre o arquivo texto} {$IOChecks on} @@ -2357,12 +2237,12 @@ begin Finally End; - WinExec(PChar(p_path_cacic + 'modulos\srcacicsrv.exe -start [' + EnCrypt(FormularioGeral.getValorDatMemoria('Configs.EnderecoServidor', v_tstrCipherOpened)) + ']' + - '[' + EnCrypt(FormularioGeral.getValorDatMemoria('Configs.Endereco_WS' , v_tstrCipherOpened)) + ']' + + WinExec(PChar(g_oCacic.getCacicPath + 'modulos\srcacicsrv.exe -start [' + g_oCacic.enCrypt(FormularioGeral.getValorDatMemoria('Configs.EnderecoServidor', v_tstrCipherOpened)) + ']' + + '[' + g_oCacic.enCrypt(FormularioGeral.getValorDatMemoria('Configs.Endereco_WS' , v_tstrCipherOpened)) + ']' + '[' + strTeSO + ']' + '[' + strTeNodeAddress + ']' + '[' + strPalavraChave + ']' + - '[' + p_path_cacic + 'Temp\aguarde_srCACIC.txt' + ']'),SW_NORMAL); + '[' + g_oCacic.getCacicPath + 'Temp\aguarde_srCACIC.txt' + ']'),SW_NORMAL); boolCrypt := boolAux; BoolServerON := true; @@ -2374,20 +2254,24 @@ procedure TFormularioGeral.Popup_Menu_ContextoPopup(Sender: TObject); begin VerificaDebugs; if (getValorDatMemoria('Configs.CS_SUPORTE_REMOTO',v_tstrCipherOpened) = 'S') and - (FileExists(p_path_cacic + 'modulos\srcacicsrv.exe')) then + (FileExists(g_oCacic.getCacicPath + 'modulos\srcacicsrv.exe')) then Mnu_SuporteRemoto.Enabled := true else Mnu_SuporteRemoto.Enabled := false; boolServerON := false; - FormularioGeral.Matar(p_path_cacic+'temp\','aguarde_SRCACIC.txt'); - if FileExists(p_path_cacic + 'temp\aguarde_SRCACIC.txt') then + FormularioGeral.Matar(g_oCacic.getCacicPath+'temp\','aguarde_SRCACIC.txt'); + if FileExists(g_oCacic.getCacicPath + 'temp\aguarde_SRCACIC.txt') then Begin - Mnu_SuporteRemoto.Caption := 'Desativar Suporte Remoto'; + Mnu_SuporteRemoto.Caption := 'Suporte Remoto Ativo!'; + Mnu_SuporteRemoto.Enabled := false; boolServerON := true; End else - Mnu_SuporteRemoto.Caption := 'Ativar Suporte Remoto'; + Begin + Mnu_SuporteRemoto.Caption := 'Ativar Suporte Remoto'; + Mnu_SuporteRemoto.Enabled := true; + End; end; diff --git a/mapa/acesso.pas b/mapa/acesso.pas index 533a96d..fbb43dc 100755 --- a/mapa/acesso.pas +++ b/mapa/acesso.pas @@ -20,8 +20,17 @@ unit acesso; interface uses - Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, - StdCtrls, ExtCtrls, dialogs; + Windows, + Messages, + SysUtils, + Variants, + Classes, + Graphics, + Controls, + Forms, + StdCtrls, + ExtCtrls, + dialogs; type TfrmAcesso = class(TForm) @@ -54,7 +63,8 @@ type { Public declarations } end; -var frmAcesso: TfrmAcesso; +var + frmAcesso: TfrmAcesso; implementation uses main_mapa; @@ -71,24 +81,24 @@ begin lbMsg_Erro_Senha.Caption := str_local_Aux; // Envio dos dados ao DataBase... - Request_mapa.Values['nm_acesso'] := frmMapaCacic.EnCrypt(edNomeUsuarioAcesso.Text); - Request_mapa.Values['te_senha'] := frmMapaCacic.EnCrypt(edSenhaAcesso.Text); - Request_mapa.Values['cs_MapaCacic'] := frmMapaCacic.EnCrypt('S'); - Request_mapa.Values['te_versao_mapa'] := frmMapaCacic.EnCrypt(frmMapaCacic.getVersionInfo(ParamStr(0))); + Request_mapa.Values['nm_acesso'] := frmMapaCacic.g_oCacic.enCrypt(edNomeUsuarioAcesso.Text); + Request_mapa.Values['te_senha'] := frmMapaCacic.g_oCacic.EnCrypt(edSenhaAcesso.Text); + Request_mapa.Values['cs_MapaCacic'] := frmMapaCacic.g_oCacic.EnCrypt('S'); + Request_mapa.Values['te_versao_mapa'] := frmMapaCacic.g_oCacic.EnCrypt(frmMapaCacic.getVersionInfo(ParamStr(0))); strRetorno := frmMapaCacic.ComunicaServidor('mapa_acesso.php', Request_mapa, 'Autenticando o Acesso...'); Request_mapa.free; if (frmMapaCacic.XML_RetornaValor('STATUS', strRetorno)='OK') then Begin - str_local_Aux := trim(frmMapaCacic.DeCrypt(frmMapaCacic.XML_RetornaValor('TE_VERSAO_MAPA',strRetorno))); + str_local_Aux := trim(frmMapaCacic.g_oCacic.deCrypt(frmMapaCacic.XML_RetornaValor('TE_VERSAO_MAPA',strRetorno))); if (str_local_Aux <> '') then Begin MessageDLG(#13#10#13#10+'ATENÇÃO! Foi disponibilizada a versão "'+str_local_Aux+'".'+#13#10#13#10+'Acesse o gerente cacic na opção "Repositório" e baixe o programa "MapaCACIC"!'+#13#10,mtWarning,[mbOK],0); btCancela.Click; End; - str_local_Aux := trim(frmMapaCacic.DeCrypt(frmMapaCacic.XML_RetornaValor('ID_USUARIO',strRetorno))); + str_local_Aux := trim(frmMapaCacic.g_oCacic.deCrypt(frmMapaCacic.XML_RetornaValor('ID_USUARIO',strRetorno))); if (str_local_Aux <> '') then Begin frmMapaCacic.strId_usuario := str_local_Aux; @@ -109,7 +119,7 @@ begin if (frmMapaCacic.boolAcessoOK) then Begin - lbAviso.Caption := 'USUÁRIO AUTENTICADO: "' + trim(frmMapaCacic.DeCrypt(frmMapaCacic.XML_RetornaValor('NM_USUARIO_COMPLETO',strRetorno)))+'"'; + lbAviso.Caption := 'USUÁRIO AUTENTICADO: "' + trim(frmMapaCacic.g_oCacic.deCrypt(frmMapaCacic.XML_RetornaValor('NM_USUARIO_COMPLETO',strRetorno)))+'"'; lbAviso.Font.Style := [fsBold]; lbAviso.Font.Color := clGreen; Application.ProcessMessages; @@ -145,7 +155,7 @@ procedure TfrmAcesso.FormCreate(Sender: TObject); begin intPausaPadrao := 3000; //(3 mil milisegundos = 3 segundos) frmAcesso.lbVersao.Caption := 'Versão: ' + frmMapaCacic.GetVersionInfo(ParamStr(0)); - frmMapaCacic.tStringsCipherOpened := frmMapaCacic.CipherOpen(frmMapaCacic.strDatFileName); + frmMapaCacic.tStringsCipherOpened := frmMapaCacic.CipherOpen(frmMapaCacic.g_oCacic.getDatFileName); frmMapaCacic.lbNomeServidorWEB.Caption := 'Servidor: '+frmMapaCacic.GetValorDatMemoria('Configs.EnderecoServidor', frmMapaCacic.tStringsCipherOpened); frmMapaCacic.lbMensagens.Caption := 'Entrada de Dados para Autenticação no Módulo Gerente WEB Cacic'; if (frmMapaCacic.GetValorDatMemoria('TcpIp.TE_NODE_ADDRESS' , frmMapaCacic.tStringsCipherOpened)='') then diff --git a/mapa/main_mapa.pas b/mapa/main_mapa.pas index 3c1dc42..daf86e7 100755 --- a/mapa/main_mapa.pas +++ b/mapa/main_mapa.pas @@ -19,57 +19,40 @@ unit main_mapa; interface -uses IniFiles, - Windows, - Sysutils, // Deve ser colocado após o Windows acima, nunca antes - strutils, - Registry, - LibXmlParser, - XML, - IdTCPConnection, - IdTCPClient, - IdHTTP, - IdBaseComponent, - IdComponent, - WinSock, - NB30, - StdCtrls, - Controls, - Classes, - Forms, - PJVersionInfo, - DCPcrypt2, - DCPrijndael, - DCPbase64, - ExtCtrls, - Graphics, - Dialogs, - CACIC_Library; - -var strCipherClosed, - strCipherOpened, - strPathCacic : string; - -var intPausaPadrao : integer; - -var boolDebugs : boolean; - -var g_oCacic : TCACIC; - -// Some constants that are dependant on the cipher being used -// Assuming MCRYPT_RIJNDAEL_128 (i.e., 128bit blocksize, 256bit keysize) -const constKeySize = 32; // 32 bytes = 256 bits - constBlockSize = 16; // 16 bytes = 128 bits - -// Constantes a serem usadas pela função IsAdmin... -const constSECURITY_NT_AUTHORITY: TSIDIdentifierAuthority = (Value: (0, 0, 0, 0, 0, 5)); - constSECURITY_BUILTIN_DOMAIN_RID = $00000020; - constDOMAIN_ALIAS_RID_ADMINS = $00000220; - -const constCipherKey = 'CacicBrasil'; - constIV = 'abcdefghijklmnop'; - constSeparatorKey = '=CacicIsFree='; // Usada apenas para o cacic2.dat +uses + IniFiles, + Windows, + Sysutils, // Deve ser colocado após o Windows acima, nunca antes + strutils, + Registry, + LibXmlParser, + XML, + IdTCPConnection, + IdTCPClient, + IdHTTP, + IdBaseComponent, + IdComponent, + WinSock, + NB30, + StdCtrls, + Controls, + Classes, + Forms, + PJVersionInfo, + ExtCtrls, + Graphics, + Dialogs, + CACIC_Library; +var + strCipherClosed, + strCipherOpened : string; + +var + intPausaPadrao : integer; + +var + boolDebugs : boolean; type TfrmMapaCacic = class(TForm) @@ -109,15 +92,9 @@ type function GetValorChaveRegEdit(Chave: String): Variant; function GetRootKey(strRootKey: String): HKEY; Function RemoveCaracteresEspeciais(Texto, p_Fill : String; p_start, p_end:integer) : String; - function HomeDrive : string; - Function Implode(p_Array : TStrings ; p_Separador : String) : String; Function CipherClose(p_DatFileName : string; p_tstrCipherOpened : TStrings) : String; - Function Explode(Texto, Separador : String) : TStrings; Function CipherOpen(p_DatFileName : string) : TStrings; Function GetValorDatMemoria(p_Chave : String; p_tstrCipherOpened : TStrings) : String; - function PadWithZeros(const str : string; size : integer) : string; - function EnCrypt(p_Data : String) : String; - function DeCrypt(p_Data : String) : String; procedure MontaCombos(p_strConfigs : String); procedure MontaInterface(p_strConfigs : String); procedure FormClose(Sender: TObject; var Action: TCloseAction); @@ -131,7 +108,6 @@ type function VerFmt(const MS, LS: DWORD): string; function GetFolderDate(Folder: string): TDateTime; procedure CriaFormSenha(Sender: TObject); - function IsAdmin: Boolean; Function ComunicaServidor(URL : String; Request : TStringList; MsgAcao: String) : String; Function XML_RetornaValor(Tag : String; Fonte : String): String; function Parse(p_ClassName, p_SectionName, p_DataName:string; p_Report : TStringList) : String; @@ -166,8 +142,8 @@ type strTe_info_patrimonio6 : String; public boolAcessoOK : boolean; - strId_usuario, - strDatFileName : String; + strId_usuario : String; + g_oCacic : TCACIC; tStringsDadosPatrimonio, tStringsCipherOpened, tStringsTripa1 : TStrings; @@ -266,8 +242,8 @@ var strDataArqLocal, strDataAtual : string; begin try - FileSetAttr (strPathCacic + 'MapaCacic.log',0); // Retira os atributos do arquivo para evitar o erro FILE ACCESS DENIED em máquinas 2000 - AssignFile(HistoricoLog,strPathCacic + 'MapaCacic.log'); {Associa o arquivo a uma variável do tipo TextFile} + FileSetAttr (g_oCacic.getCacicPath + 'MapaCacic.log',0); // Retira os atributos do arquivo para evitar o erro FILE ACCESS DENIED em máquinas 2000 + AssignFile(HistoricoLog,g_oCacic.getCacicPath + 'MapaCacic.log'); {Associa o arquivo a uma variável do tipo TextFile} {$IOChecks off} Reset(HistoricoLog); {Abre o arquivo texto} {$IOChecks on} @@ -277,7 +253,7 @@ begin Append(HistoricoLog); Writeln(HistoricoLog,FormatDateTime('dd/mm hh:nn:ss : ', Now) + '======================> Iniciando o Log <======================='); end; - DateTimeToString(strDataArqLocal, 'yyyymmdd', FileDateToDateTime(Fileage(strPathCacic + 'MapaCacic.log'))); + DateTimeToString(strDataArqLocal, 'yyyymmdd', FileDateToDateTime(Fileage(g_oCacic.getCacicPath + 'MapaCacic.log'))); DateTimeToString(strDataAtual , 'yyyymmdd', Date); if (strDataAtual <> strDataArqLocal) then // Se o arquivo INI não é da data atual... begin @@ -317,7 +293,7 @@ var strDataArqLocal, strDataAtual, v_file_debugs : string; begin try - v_file_debugs := strPathCacic + '\debug_mapa.txt'; + v_file_debugs := g_oCacic.getCacicPath + '\debug_mapa.txt'; FileSetAttr (v_file_debugs,0); // Retira os atributos do arquivo para evitar o erro FILE ACCESS DENIED em máquinas 2000 AssignFile(DebugsFile,v_file_debugs); {Associa o arquivo a uma variável do tipo TextFile} @@ -349,38 +325,6 @@ begin end; end; - -// -Function TfrmMapaCacic.Explode(Texto, Separador : String) : TStrings; -var - strItem : String; - ListaAuxUTILS : TStrings; - NumCaracteres, - TamanhoSeparador, - I : Integer; -Begin - ListaAuxUTILS := TStringList.Create; - strItem := ''; - NumCaracteres := Length(Texto); - TamanhoSeparador := Length(Separador); - I := 1; - While I <= NumCaracteres Do - Begin - If (Copy(Texto,I,TamanhoSeparador) = Separador) or (I = NumCaracteres) Then - Begin - if (I = NumCaracteres) then strItem := strItem + Texto[I]; - ListaAuxUTILS.Add(trim(strItem)); - strItem := ''; - I := I + (TamanhoSeparador-1); - end - Else - strItem := strItem + Texto[I]; - - I := I + 1; - End; - Explode := ListaAuxUTILS; -end; - // Função criada devido a divergências entre os valores retornados pelos métodos dos componentes MSI e seus Reports. function TfrmMapaCacic.Parse(p_ClassName, p_SectionName, p_DataName:string; p_Report : TStringList) : String; var intClasses, intSections, intDatas, v_achei_SectionName, v_array_SectionName_Count : integer; @@ -390,7 +334,7 @@ begin Result := ''; if (p_SectionName <> '') then Begin - v_array_SectionName := explode(p_SectionName,'/'); + v_array_SectionName := g_oCacic.explode(p_SectionName,'/'); v_array_SectionName_Count := v_array_SectionName.Count; End else v_array_SectionName_Count := 0; @@ -464,15 +408,16 @@ procedure TfrmMapaCacic.Finalizar(p_pausa:boolean); Begin Mensagem('Finalizando MapaCacic...',false,0); - CipherClose(strDatFileName, tStringsCipherOpened); + CipherClose(g_oCacic.getDatFileName, tStringsCipherOpened); Apaga_Temps; if p_pausa then sleep(2000); // Pausa de 2 segundos para conclusão de operações de arquivos. Sair; End; + procedure TfrmMapaCacic.Apaga_Temps; begin - Matar(strPathCacic + 'temp\','*.vbs'); - Matar(strPathCacic + 'temp\','*.txt'); + Matar(g_oCacic.getCacicPath + 'temp\','*.vbs'); + Matar(g_oCacic.getCacicPath + 'temp\','*.txt'); end; // function TfrmMapaCacic.LastPos(SubStr, S: string): Integer; @@ -547,7 +492,7 @@ Begin strEnderecoWS := '/cacic2/ws/'; if (trim(strEnderecoServidor)='') then - strEnderecoServidor := Trim(GetValorChaveRegIni('Cacic2','ip_serv_cacic',strPathCacic + 'MapaCacic.ini')); + strEnderecoServidor := Trim(GetValorChaveRegIni('Cacic2','ip_serv_cacic',g_oCacic.getCacicPath + 'MapaCacic.ini')); strEndereco := 'http://' + strEnderecoServidor + strEnderecoWS + URL; @@ -574,9 +519,9 @@ Begin idHTTP1.ReadTimeout := 0; idHTTP1.RecvBufferSize := 32768; idHTTP1.RedirectMaximum := 15; - idHTTP1.Request.UserAgent := EnCrypt('AGENTE_CACIC'); - idHTTP1.Request.Username := EnCrypt('USER_CACIC'); - idHTTP1.Request.Password := EnCrypt('PW_CACIC'); + idHTTP1.Request.UserAgent := g_oCacic.enCrypt('AGENTE_CACIC'); + idHTTP1.Request.Username := g_oCacic.enCrypt('USER_CACIC'); + idHTTP1.Request.Password := g_oCacic.enCrypt('PW_CACIC'); idHTTP1.Request.Accept := 'text/html, */*'; idHTTP1.Request.BasicAuthentication := true; idHTTP1.Request.ContentLength := -1; @@ -665,22 +610,6 @@ var end; end; - -// Pad a string with zeros so that it is a multiple of size -function TfrmMapaCacic.PadWithZeros(const str : string; size : integer) : string; -var - origsize, i : integer; -begin - Result := str; - origsize := Length(Result); - if ((origsize mod size) <> 0) or (origsize = 0) then - begin - SetLength(Result,((origsize div size)+1)*size); - for i := origsize+1 to Length(Result) do - Result[i] := #0; - end; -end; - function TfrmMapaCacic.GetFolderDate(Folder: string): TDateTime; var Rec: TSearchRec; @@ -702,98 +631,6 @@ begin end; end; -// Encrypt a string and return the Base64 encoded result -function TfrmMapaCacic.EnCrypt(p_Data : String) : String; -var - l_Cipher : TDCP_rijndael; - l_Data, l_Key, l_IV : string; -begin - Try - // Pad Key, IV and Data with zeros as appropriate - l_Key := PadWithZeros(constCipherKey,constKeySize); - l_IV := PadWithZeros(constIV,constBlockSize); - l_Data := PadWithZeros(p_Data,constBlockSize); - - // Create the cipher and initialise according to the key length - l_Cipher := TDCP_rijndael.Create(nil); - if Length(constCipherKey) <= 16 then - l_Cipher.Init(l_Key[1],128,@l_IV[1]) - else if Length(constCipherKey) <= 24 then - l_Cipher.Init(l_Key[1],192,@l_IV[1]) - else - l_Cipher.Init(l_Key[1],256,@l_IV[1]); - - // Encrypt the data - l_Cipher.EncryptCBC(l_Data[1],l_Data[1],Length(l_Data)); - - // Free the cipher and clear sensitive information - l_Cipher.Free; - FillChar(l_Key[1],Length(l_Key),0); - - // Return the Base64 encoded result - Result := Base64EncodeStr(l_Data); - Except - log_diario('Erro no Processo de Criptografia'); - End; -end; - -function TfrmMapaCacic.DeCrypt(p_Data : String) : String; -var - l_Cipher : TDCP_rijndael; - l_Data, l_Key, l_IV : string; -begin - Try - // Pad Key and IV with zeros as appropriate - l_Key := PadWithZeros(constCipherKey,constKeySize); - l_IV := PadWithZeros(constIV,constBlockSize); - - // Decode the Base64 encoded string - l_Data := Base64DecodeStr(p_Data); - - // Create the cipher and initialise according to the key length - l_Cipher := TDCP_rijndael.Create(nil); - if Length(constCipherKey) <= 16 then - l_Cipher.Init(l_Key[1],128,@l_IV[1]) - else if Length(constCipherKey) <= 24 then - l_Cipher.Init(l_Key[1],192,@l_IV[1]) - else - l_Cipher.Init(l_Key[1],256,@l_IV[1]); - - // Decrypt the data - l_Cipher.DecryptCBC(l_Data[1],l_Data[1],Length(l_Data)); - - // Free the cipher and clear sensitive information - l_Cipher.Free; - FillChar(l_Key[1],Length(l_Key),0); - log_DEBUG('DeCriptografia(ATIVADA) de "'+p_Data+'" => "'+l_Data+'"'); - // Return the result - Result := trim(l_Data); - Except - log_diario('Erro no Processo de Decriptografia'); - End; -end; - -function TfrmMapaCacic.HomeDrive : string; -var -WinDir : array [0..144] of char; -begin - GetWindowsDirectory (WinDir, 144); - Result := StrPas (WinDir); -end; - -Function TfrmMapaCacic.Implode(p_Array : TStrings ; p_Separador : String) : String; -var intAux : integer; - strAux : string; -Begin - strAux := ''; - For intAux := 0 To p_Array.Count -1 do - Begin - if (strAux<>'') then strAux := strAux + p_Separador; - strAux := strAux + p_Array[intAux]; - End; - Implode := strAux; -end; - Function TfrmMapaCacic.CipherClose(p_DatFileName : string; p_tstrCipherOpened : TStrings) : String; var strCipherOpenImploded : string; txtFileDatFile : TextFile; @@ -806,9 +643,9 @@ begin Rewrite (txtFileDatFile); Append(txtFileDatFile); - strCipherOpenImploded := Implode(p_tstrCipherOpened,'=CacicIsFree='); + strCipherOpenImploded := g_oCacic.implode(p_tstrCipherOpened,'=CacicIsFree='); log_DEBUG('Rotina de Fechamento do cacic2.dat ATIVANDO criptografia.'); - strCipherClosed := EnCrypt(strCipherOpenImploded); + strCipherClosed := g_oCacic.enCrypt(strCipherOpenImploded); log_DEBUG('Rotina de Fechamento do cacic2.dat RESTAURANDO estado da criptografia.'); Writeln(txtFileDatFile,strCipherClosed); {Grava a string Texto no arquivo texto} @@ -840,12 +677,12 @@ begin Readln(v_DatFile,v_strCipherClosed); while not EOF(v_DatFile) do Readln(v_DatFile,v_strCipherClosed); CloseFile(v_DatFile); - strCipherOpened:= DeCrypt(v_strCipherClosed); + strCipherOpened:= g_oCacic.deCrypt(v_strCipherClosed); end; if (trim(strCipherOpened)<>'') then - Result := explode(strCipherOpened,'=CacicIsFree=') + Result := g_oCacic.explode(strCipherOpened,'=CacicIsFree=') else - Result := explode('Configs.ID_SO=CacicIsFree='+ g_oCacic.getWindowsStrId() +'=CacicIsFree=Configs.Endereco_WS=CacicIsFree=/cacic2/ws/','=CacicIsFree='); + Result := g_oCacic.explode('Configs.ID_SO'+g_oCacic.getSeparatorKey+g_oCacic.getWindowsStrId() +g_oCacic.getSeparatorKey+'Configs.Endereco_WS'+g_oCacic.getSeparatorKey+'/cacic2/ws/',g_oCacic.getSeparatorKey); if Result.Count mod 2 = 0 then Result.Add(''); @@ -886,7 +723,7 @@ var RegEditSet: TRegistry; ListaAuxSet : TStrings; I : Integer; begin - ListaAuxSet := Explode(Chave, '\'); + ListaAuxSet := g_oCacic.explode(Chave, '\'); strRootKey := ListaAuxSet[0]; For I := 1 To ListaAuxSet.Count - 2 Do strKey := strKey + ListaAuxSet[I] + '\'; strValue := ListaAuxSet[ListaAuxSet.Count - 1]; @@ -924,7 +761,6 @@ begin RegEditSet.Free; end; - function TfrmMapaCacic.GetRootKey(strRootKey: String): HKEY; begin if Trim(strRootKey) = 'HKEY_LOCAL_MACHINE' Then Result := HKEY_LOCAL_MACHINE @@ -963,19 +799,19 @@ begin strId_unid_organizacional_nivel1 := GetValorDatMemoria('Patrimonio.id_unid_organizacional_nivel1',tStringsCipherOpened); if (strId_unid_organizacional_nivel1='') then - strId_unid_organizacional_nivel1 := DeCrypt(XML.XML_RetornaValor('ID_UON1', p_strConfigs)); + strId_unid_organizacional_nivel1 := g_oCacic.deCrypt(XML.XML_RetornaValor('ID_UON1', p_strConfigs)); strId_unid_organizacional_nivel1a := GetValorDatMemoria('Patrimonio.id_unid_organizacional_nivel1a',tStringsCipherOpened); if (strId_unid_organizacional_nivel1a='') then - strId_unid_organizacional_nivel1a := DeCrypt(XML.XML_RetornaValor('ID_UON1a', p_strConfigs)); + strId_unid_organizacional_nivel1a := g_oCacic.deCrypt(XML.XML_RetornaValor('ID_UON1a', p_strConfigs)); strId_unid_organizacional_nivel2 := GetValorDatMemoria('Patrimonio.id_unid_organizacional_nivel2',tStringsCipherOpened); if (strId_unid_organizacional_nivel2='') then - strId_unid_organizacional_nivel2 := DeCrypt(XML.XML_RetornaValor('ID_UON2', p_strConfigs)); + strId_unid_organizacional_nivel2 := g_oCacic.deCrypt(XML.XML_RetornaValor('ID_UON2', p_strConfigs)); strId_Local := GetValorDatMemoria('Patrimonio.id_local',tStringsCipherOpened); if (strId_Local='') then - strId_Local := DeCrypt(XML.XML_RetornaValor('ID_LOCAL', p_strConfigs)); + strId_Local := g_oCacic.deCrypt(XML.XML_RetornaValor('ID_LOCAL', p_strConfigs)); Try cb_id_unid_organizacional_nivel1.ItemIndex := cb_id_unid_organizacional_nivel1.Items.IndexOf(RetornaValorVetorUON1(strId_unid_organizacional_nivel1)); @@ -991,11 +827,11 @@ begin Except end; - lbEtiqueta1.Caption := DeCrypt(XML.XML_RetornaValor('te_etiqueta1', p_strConfigs)); - lbEtiqueta1a.Caption := DeCrypt(XML.XML_RetornaValor('te_etiqueta1a', p_strConfigs)); + lbEtiqueta1.Caption := g_oCacic.deCrypt(XML.XML_RetornaValor('te_etiqueta1', p_strConfigs)); + lbEtiqueta1a.Caption := g_oCacic.deCrypt(XML.XML_RetornaValor('te_etiqueta1a', p_strConfigs)); strTe_localizacao_complementar := GetValorDatMemoria('Patrimonio.te_localizacao_complementar',tStringsCipherOpened); - if (strTe_localizacao_complementar='') then strTe_localizacao_complementar := DeCrypt(XML.XML_RetornaValor('TE_LOC_COMPL', p_strConfigs)); + if (strTe_localizacao_complementar='') then strTe_localizacao_complementar := g_oCacic.deCrypt(XML.XML_RetornaValor('TE_LOC_COMPL', p_strConfigs)); // Tentarei buscar informação gravada no Registry strTe_info_patrimonio1 := GetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SOFTWARE\Dataprev\Patrimonio\te_info_patrimonio1'); @@ -1003,13 +839,13 @@ begin Begin strTe_info_patrimonio1 := GetValorDatMemoria('Patrimonio.te_info_patrimonio1',tStringsCipherOpened); End; - if (strTe_info_patrimonio1='') then strTe_info_patrimonio1 := DeCrypt(XML.XML_RetornaValor('TE_INFO1', p_strConfigs)); + if (strTe_info_patrimonio1='') then strTe_info_patrimonio1 := g_oCacic.deCrypt(XML.XML_RetornaValor('TE_INFO1', p_strConfigs)); strTe_info_patrimonio2 := GetValorDatMemoria('Patrimonio.te_info_patrimonio2',tStringsCipherOpened); - if (strTe_info_patrimonio2='') then strTe_info_patrimonio2 := DeCrypt(XML.XML_RetornaValor('TE_INFO2', p_strConfigs)); + if (strTe_info_patrimonio2='') then strTe_info_patrimonio2 := g_oCacic.deCrypt(XML.XML_RetornaValor('TE_INFO2', p_strConfigs)); strTe_info_patrimonio3 := GetValorDatMemoria('Patrimonio.te_info_patrimonio3',tStringsCipherOpened); - if (strTe_info_patrimonio3='') then strTe_info_patrimonio3 := DeCrypt(XML.XML_RetornaValor('TE_INFO3', p_strConfigs)); + if (strTe_info_patrimonio3='') then strTe_info_patrimonio3 := g_oCacic.deCrypt(XML.XML_RetornaValor('TE_INFO3', p_strConfigs)); // Tentarei buscar informação gravada no Registry strTe_info_patrimonio4 := GetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SOFTWARE\Dataprev\Patrimonio\te_info_patrimonio4'); @@ -1017,13 +853,13 @@ begin Begin strTe_info_patrimonio4 := GetValorDatMemoria('Patrimonio.te_info_patrimonio4',tStringsCipherOpened); End; - if (strTe_info_patrimonio4='') then strTe_info_patrimonio4 := DeCrypt(XML.XML_RetornaValor('TE_INFO4', p_strConfigs)); + if (strTe_info_patrimonio4='') then strTe_info_patrimonio4 := g_oCacic.deCrypt(XML.XML_RetornaValor('TE_INFO4', p_strConfigs)); strTe_info_patrimonio5 := GetValorDatMemoria('Patrimonio.te_info_patrimonio5',tStringsCipherOpened); - if (strTe_info_patrimonio5='') then strTe_info_patrimonio5 := DeCrypt(XML.XML_RetornaValor('TE_INFO5', p_strConfigs)); + if (strTe_info_patrimonio5='') then strTe_info_patrimonio5 := g_oCacic.deCrypt(XML.XML_RetornaValor('TE_INFO5', p_strConfigs)); strTe_info_patrimonio6 := GetValorDatMemoria('Patrimonio.te_info_patrimonio6',tStringsCipherOpened); - if (strTe_info_patrimonio6='') then strTe_info_patrimonio6 := DeCrypt(XML.XML_RetornaValor('TE_INFO6', p_strConfigs)); + if (strTe_info_patrimonio6='') then strTe_info_patrimonio6 := g_oCacic.deCrypt(XML.XML_RetornaValor('TE_INFO6', p_strConfigs)); end; procedure TfrmMapaCacic.MontaCombos(p_strConfigs : String); @@ -1057,7 +893,7 @@ begin strTagName := '' else if (Parser.CurPartType in [ptContent, ptCData]) and (strTagName='IT1')Then Begin - strAux1 := DeCrypt(Parser.CurContent); + strAux1 := g_oCacic.deCrypt(Parser.CurContent); if (strItemName = 'ID1') then Begin VetorUON1[i].id1 := strAux1; @@ -1089,7 +925,7 @@ begin strTagName := '' else if (Parser.CurPartType in [ptContent, ptCData]) and (strTagName='IT1A')Then Begin - strAux1 := DeCrypt(Parser.CurContent); + strAux1 := g_oCacic.deCrypt(Parser.CurContent); if (strItemName = 'ID1') then Begin VetorUON1a[i].id1 := strAux1; @@ -1135,7 +971,7 @@ begin strTagName := '' else if (Parser.CurPartType in [ptContent, ptCData]) and (strTagName='IT2')Then Begin - strAux1 := DeCrypt(Parser.CurContent); + strAux1 := g_oCacic.deCrypt(Parser.CurContent); if (strItemName = 'ID1A') then Begin VetorUON2[i].id1a := strAux1; @@ -1250,7 +1086,7 @@ begin Log_debug('cb_id_unid_organizacional_nivel1a.ItemIndex = '+intToStr(cb_id_unid_organizacional_nivel1a.ItemIndex)); tstrAux := TStrings.Create; - tstrAux := Explode(VetorUON1aFiltrado[cb_id_unid_organizacional_nivel1a.ItemIndex],'#'); + tstrAux := g_oCacic.explode(VetorUON1aFiltrado[cb_id_unid_organizacional_nivel1a.ItemIndex],'#'); strIdUON1a := tstrAux[0]; strIdLocal := tstrAux[1]; @@ -1297,15 +1133,15 @@ var strIdUON1, tstrListAux : TStringList; tstrAux : TStrings; begin - Matar(strPathCacic,'aguarde_CACIC.txt'); + Matar(g_oCacic.getCacicPath,'aguarde_CACIC.txt'); - if FileExists(strPathCacic + 'aguarde_CACIC.txt') then + if FileExists(g_oCacic.getCacicPath + 'aguarde_CACIC.txt') then MessageDLG(#13#10+'ATENÇÃO!'+#13#10#13#10+ 'Para o envio das informações, é necessário finalizar o Agente Principal do CACIC.',mtError,[mbOK],0) else Begin tstrAux := TStrings.Create; - tstrAux := explode(VetorUON2Filtrado[cb_id_unid_organizacional_nivel2.ItemIndex],'#'); + tstrAux := g_oCacic.explode(VetorUON2Filtrado[cb_id_unid_organizacional_nivel2.ItemIndex],'#'); Try strIdUON1 := VetorUON1[cb_id_unid_organizacional_nivel1.ItemIndex].id1; strIdUON2 := tstrAux[0]; @@ -1313,65 +1149,37 @@ begin Except end; - tstrAux := explode(VetorUON1aFiltrado[cb_id_unid_organizacional_nivel1a.ItemIndex],'#'); + tstrAux := g_oCacic.explode(VetorUON1aFiltrado[cb_id_unid_organizacional_nivel1a.ItemIndex],'#'); Try strIdUON1a := tstrAux[0]; Except end; -<<<<<<< .mine tstrAux.Free; -======= ->>>>>>> .r729 - // Assim, o envio será incondicional! - 01/12/2006 - Anderson Peterle - // if (strAux1 <> strId_unid_organizacional_nivel1) or - // (strAux2 <> strId_unid_organizacional_nivel2) or - // (ed_te_localizacao_complementar.Text <> strTe_localizacao_complementar) or - // (ed_te_info_patrimonio1.Text <> strTe_info_patrimonio1) or - // (ed_te_info_patrimonio2.Text <> strTe_info_patrimonio2) or - // (ed_te_info_patrimonio3.Text <> strTe_info_patrimonio3) or - // (ed_te_info_patrimonio4.Text <> strTe_info_patrimonio4) or - // (ed_te_info_patrimonio5.Text <> strTe_info_patrimonio5) or - // (ed_te_info_patrimonio6.Text <> strTe_info_patrimonio6) then - // begin - -<<<<<<< .mine - Mensagem('Enviando Informações Coletadas ao Banco de Dados...',false,intPausaPadrao div 3); -======= + Mensagem('Enviando Informações Coletadas ao Banco de Dados...',false,intPausaPadrao div 3); + // Envio dos Dados Coletados ao Banco de Dados tstrListAux := TStringList.Create; - tstrListAux.Values['te_node_address'] := frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.TE_NODE_ADDRESS' , frmMapaCacic.tStringsCipherOpened)); - tstrListAux.Values['id_so'] := frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('Configs.ID_SO' , frmMapaCacic.tStringsCipherOpened)); - tstrListAux.Values['te_so'] := frmMapaCacic.EnCrypt(g_oCacic.getWindowsStrId()); - tstrListAux.Values['id_ip_rede'] := frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.ID_IP_REDE' , frmMapaCacic.tStringsCipherOpened)); - tstrListAux.Values['te_ip'] := frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.TE_IP' , frmMapaCacic.tStringsCipherOpened)); - tstrListAux.Values['te_nome_computador'] := frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.TE_NOME_COMPUTADOR' , frmMapaCacic.tStringsCipherOpened)); - tstrListAux.Values['te_workgroup'] := frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.TE_WORKGROUP' , frmMapaCacic.tStringsCipherOpened)); - tstrListAux.Values['id_usuario'] := frmMapaCacic.EnCrypt(frmMapaCacic.strId_usuario); ->>>>>>> .r729 - - // Envio dos Dados Coletados ao Banco de Dados - tstrListAux := TStringList.Create; - tstrListAux.Values['te_node_address'] := frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.TE_NODE_ADDRESS' , frmMapaCacic.tStringsCipherOpened)); - tstrListAux.Values['id_so'] := frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('Configs.ID_SO' , frmMapaCacic.tStringsCipherOpened)); - tstrListAux.Values['te_so'] := frmMapaCacic.EnCrypt(str_te_so); - tstrListAux.Values['id_ip_rede'] := frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.ID_IP_REDE' , frmMapaCacic.tStringsCipherOpened)); - tstrListAux.Values['te_ip'] := frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.TE_IP' , frmMapaCacic.tStringsCipherOpened)); - tstrListAux.Values['te_nome_computador'] := frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.TE_NOME_COMPUTADOR' , frmMapaCacic.tStringsCipherOpened)); - tstrListAux.Values['te_workgroup'] := frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.TE_WORKGROUP' , frmMapaCacic.tStringsCipherOpened)); - tstrListAux.Values['id_usuario'] := frmMapaCacic.EnCrypt(frmMapaCacic.strId_usuario); - - tstrListAux.Values['id_unid_organizacional_nivel1'] := frmMapaCacic.EnCrypt(strIdUON1); - tstrListAux.Values['id_unid_organizacional_nivel1a']:= frmMapaCacic.EnCrypt(strIdUON1A); - tstrListAux.Values['id_unid_organizacional_nivel2'] := frmMapaCacic.EnCrypt(strIdUON2); - tstrListAux.Values['te_localizacao_complementar' ] := frmMapaCacic.EnCrypt(ed_te_localizacao_complementar.Text); - tstrListAux.Values['te_info_patrimonio1' ] := frmMapaCacic.EnCrypt(ed_te_info_patrimonio1.Text); - tstrListAux.Values['te_info_patrimonio2' ] := frmMapaCacic.EnCrypt(ed_te_info_patrimonio2.Text); - tstrListAux.Values['te_info_patrimonio3' ] := frmMapaCacic.EnCrypt(ed_te_info_patrimonio3.Text); - tstrListAux.Values['te_info_patrimonio4' ] := frmMapaCacic.EnCrypt(ed_te_info_patrimonio4.Text); - tstrListAux.Values['te_info_patrimonio5' ] := frmMapaCacic.EnCrypt(ed_te_info_patrimonio5.Text); - tstrListAux.Values['te_info_patrimonio6' ] := frmMapaCacic.EnCrypt(ed_te_info_patrimonio6.Text); + tstrListAux.Values['te_node_address'] := g_oCacic.enCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.TE_NODE_ADDRESS' , frmMapaCacic.tStringsCipherOpened)); + tstrListAux.Values['id_so'] := g_oCacic.enCrypt(frmMapaCacic.GetValorDatMemoria('Configs.ID_SO' , frmMapaCacic.tStringsCipherOpened)); + tstrListAux.Values['te_so'] := g_oCacic.enCrypt(g_oCacic.getWindowsStrId()); + tstrListAux.Values['id_ip_rede'] := g_oCacic.enCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.ID_IP_REDE' , frmMapaCacic.tStringsCipherOpened)); + tstrListAux.Values['te_ip'] := g_oCacic.enCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.TE_IP' , frmMapaCacic.tStringsCipherOpened)); + tstrListAux.Values['te_nome_computador'] := g_oCacic.enCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.TE_NOME_COMPUTADOR' , frmMapaCacic.tStringsCipherOpened)); + tstrListAux.Values['te_workgroup'] := g_oCacic.enCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.TE_WORKGROUP' , frmMapaCacic.tStringsCipherOpened)); + tstrListAux.Values['id_usuario'] := g_oCacic.enCrypt(frmMapaCacic.strId_usuario); + + tstrListAux.Values['id_unid_organizacional_nivel1'] := g_oCacic.enCrypt(strIdUON1); + tstrListAux.Values['id_unid_organizacional_nivel1a']:= g_oCacic.enCrypt(strIdUON1A); + tstrListAux.Values['id_unid_organizacional_nivel2'] := g_oCacic.enCrypt(strIdUON2); + tstrListAux.Values['te_localizacao_complementar' ] := g_oCacic.enCrypt(ed_te_localizacao_complementar.Text); + tstrListAux.Values['te_info_patrimonio1' ] := g_oCacic.enCrypt(ed_te_info_patrimonio1.Text); + tstrListAux.Values['te_info_patrimonio2' ] := g_oCacic.enCrypt(ed_te_info_patrimonio2.Text); + tstrListAux.Values['te_info_patrimonio3' ] := g_oCacic.enCrypt(ed_te_info_patrimonio3.Text); + tstrListAux.Values['te_info_patrimonio4' ] := g_oCacic.enCrypt(ed_te_info_patrimonio4.Text); + tstrListAux.Values['te_info_patrimonio5' ] := g_oCacic.enCrypt(ed_te_info_patrimonio5.Text); + tstrListAux.Values['te_info_patrimonio6' ] := g_oCacic.enCrypt(ed_te_info_patrimonio6.Text); log_DEBUG('Informações para contato com mapa_set_patrimonio:'); log_DEBUG('te_node_address: '+tstrListAux.Values['te_node_address']); @@ -1416,76 +1224,76 @@ procedure TfrmMapaCacic.MontaInterface(p_strConfigs : String); Begin Mensagem('Montando Interface para Coleta de Informações...',false,intPausaPadrao div 3); - lbEtiqueta1.Caption := DeCrypt(XML.XML_RetornaValor('te_etiqueta1', p_strConfigs)); + lbEtiqueta1.Caption := g_oCacic.deCrypt(XML.XML_RetornaValor('te_etiqueta1', p_strConfigs)); lbEtiqueta1.Visible := true; - cb_id_unid_organizacional_nivel1.Hint := DeCrypt(XML.XML_RetornaValor('te_help_etiqueta1', p_strConfigs)); + cb_id_unid_organizacional_nivel1.Hint := g_oCacic.deCrypt(XML.XML_RetornaValor('te_help_etiqueta1', p_strConfigs)); cb_id_unid_organizacional_nivel1.Visible := true; - lbEtiqueta1a.Caption := DeCrypt(XML.XML_RetornaValor('te_etiqueta1a', p_strConfigs)); + lbEtiqueta1a.Caption := g_oCacic.deCrypt(XML.XML_RetornaValor('te_etiqueta1a', p_strConfigs)); lbEtiqueta1a.Visible := true; - cb_id_unid_organizacional_nivel1a.Hint := DeCrypt(XML.XML_RetornaValor('te_help_etiqueta1a', p_strConfigs)); + cb_id_unid_organizacional_nivel1a.Hint := g_oCacic.deCrypt(XML.XML_RetornaValor('te_help_etiqueta1a', p_strConfigs)); cb_id_unid_organizacional_nivel1a.Visible := true; - lbEtiqueta2.Caption := DeCrypt(XML.XML_RetornaValor('te_etiqueta2', p_strConfigs)); + lbEtiqueta2.Caption := g_oCacic.deCrypt(XML.XML_RetornaValor('te_etiqueta2', p_strConfigs)); lbEtiqueta2.Visible := true; - cb_id_unid_organizacional_nivel2.Hint := DeCrypt(XML.XML_RetornaValor('te_help_etiqueta2', p_strConfigs)); + cb_id_unid_organizacional_nivel2.Hint := g_oCacic.deCrypt(XML.XML_RetornaValor('te_help_etiqueta2', p_strConfigs)); cb_id_unid_organizacional_nivel2.Visible := true; - lbEtiqueta3.Caption := DeCrypt(XML.XML_RetornaValor('te_etiqueta3', p_strConfigs)); + lbEtiqueta3.Caption := g_oCacic.deCrypt(XML.XML_RetornaValor('te_etiqueta3', p_strConfigs)); lbEtiqueta3.Visible := true; ed_te_localizacao_complementar.Text := strTe_localizacao_complementar; ed_te_localizacao_complementar.Visible := true; - if (DeCrypt(XML.XML_RetornaValor('in_exibir_etiqueta4', p_strConfigs)) = 'S') then + if (g_oCacic.deCrypt(XML.XML_RetornaValor('in_exibir_etiqueta4', p_strConfigs)) = 'S') then begin - lbEtiqueta4.Caption := DeCrypt(XML.XML_RetornaValor('te_etiqueta4', p_strConfigs)); + lbEtiqueta4.Caption := g_oCacic.deCrypt(XML.XML_RetornaValor('te_etiqueta4', p_strConfigs)); lbEtiqueta4.Visible := true; - ed_te_info_patrimonio1.Hint := DeCrypt(XML.XML_RetornaValor('te_help_etiqueta4', p_strConfigs)); + ed_te_info_patrimonio1.Hint := g_oCacic.deCrypt(XML.XML_RetornaValor('te_help_etiqueta4', p_strConfigs)); ed_te_info_patrimonio1.Text := strTe_info_patrimonio1; ed_te_info_patrimonio1.visible := True; end; - if (DeCrypt(XML.XML_RetornaValor('in_exibir_etiqueta5', p_strConfigs)) = 'S') then + if (g_oCacic.deCrypt(XML.XML_RetornaValor('in_exibir_etiqueta5', p_strConfigs)) = 'S') then begin - lbEtiqueta5.Caption := DeCrypt(XML.XML_RetornaValor('te_etiqueta5', p_strConfigs)); + lbEtiqueta5.Caption := g_oCacic.deCrypt(XML.XML_RetornaValor('te_etiqueta5', p_strConfigs)); lbEtiqueta5.Visible := true; - ed_te_info_patrimonio2.Hint := DeCrypt(XML.XML_RetornaValor('te_help_etiqueta5', p_strConfigs)); + ed_te_info_patrimonio2.Hint := g_oCacic.deCrypt(XML.XML_RetornaValor('te_help_etiqueta5', p_strConfigs)); ed_te_info_patrimonio2.Text := strTe_info_patrimonio2; ed_te_info_patrimonio2.visible := True; end; - if (DeCrypt(XML.XML_RetornaValor('in_exibir_etiqueta6', p_strConfigs)) = 'S') then + if (g_oCacic.deCrypt(XML.XML_RetornaValor('in_exibir_etiqueta6', p_strConfigs)) = 'S') then begin - lbEtiqueta6.Caption := DeCrypt(XML.XML_RetornaValor('te_etiqueta6', p_strConfigs)); + lbEtiqueta6.Caption := g_oCacic.deCrypt(XML.XML_RetornaValor('te_etiqueta6', p_strConfigs)); lbEtiqueta6.Visible := true; - ed_te_info_patrimonio3.Hint := DeCrypt(XML.XML_RetornaValor('te_help_etiqueta6', p_strConfigs)); + ed_te_info_patrimonio3.Hint := g_oCacic.deCrypt(XML.XML_RetornaValor('te_help_etiqueta6', p_strConfigs)); ed_te_info_patrimonio3.Text := strTe_info_patrimonio3; ed_te_info_patrimonio3.visible := True; end; - if (DeCrypt(XML.XML_RetornaValor('in_exibir_etiqueta7', p_strConfigs)) = 'S') then + if (g_oCacic.deCrypt(XML.XML_RetornaValor('in_exibir_etiqueta7', p_strConfigs)) = 'S') then begin - lbEtiqueta7.Caption := DeCrypt(XML.XML_RetornaValor('te_etiqueta7', p_strConfigs)); + lbEtiqueta7.Caption := g_oCacic.deCrypt(XML.XML_RetornaValor('te_etiqueta7', p_strConfigs)); lbEtiqueta7.Visible := true; - ed_te_info_patrimonio4.Hint := DeCrypt(XML.XML_RetornaValor('te_help_etiqueta7', p_strConfigs)); + ed_te_info_patrimonio4.Hint := g_oCacic.deCrypt(XML.XML_RetornaValor('te_help_etiqueta7', p_strConfigs)); ed_te_info_patrimonio4.Text := strTe_info_patrimonio4; ed_te_info_patrimonio4.visible := True; end; - if (DeCrypt(XML.XML_RetornaValor('in_exibir_etiqueta8', p_strConfigs)) = 'S') then + if (g_oCacic.deCrypt(XML.XML_RetornaValor('in_exibir_etiqueta8', p_strConfigs)) = 'S') then begin - lbEtiqueta8.Caption := DeCrypt(XML.XML_RetornaValor('te_etiqueta8', p_strConfigs)); + lbEtiqueta8.Caption := g_oCacic.deCrypt(XML.XML_RetornaValor('te_etiqueta8', p_strConfigs)); lbEtiqueta8.Visible := true; - ed_te_info_patrimonio5.Hint := DeCrypt(XML.XML_RetornaValor('te_help_etiqueta8', p_strConfigs)); + ed_te_info_patrimonio5.Hint := g_oCacic.deCrypt(XML.XML_RetornaValor('te_help_etiqueta8', p_strConfigs)); ed_te_info_patrimonio5.Text := strTe_info_patrimonio5; ed_te_info_patrimonio5.visible := True; end; - if (DeCrypt(XML.XML_RetornaValor('in_exibir_etiqueta9', p_strConfigs)) = 'S') then + if (g_oCacic.deCrypt(XML.XML_RetornaValor('in_exibir_etiqueta9', p_strConfigs)) = 'S') then begin - lbEtiqueta9.Caption := DeCrypt(XML.XML_RetornaValor('te_etiqueta9', p_strConfigs)); + lbEtiqueta9.Caption := g_oCacic.deCrypt(XML.XML_RetornaValor('te_etiqueta9', p_strConfigs)); lbEtiqueta9.Visible := true; - ed_te_info_patrimonio6.Hint := DeCrypt(XML.XML_RetornaValor('te_help_etiqueta9', p_strConfigs)); + ed_te_info_patrimonio6.Hint := g_oCacic.deCrypt(XML.XML_RetornaValor('te_help_etiqueta9', p_strConfigs)); ed_te_info_patrimonio6.Text := strTe_info_patrimonio6; ed_te_info_patrimonio6.visible := True; end; @@ -1508,7 +1316,7 @@ var RegEditGet: TRegistry; begin try Result := ''; - ListaAuxGet := Explode(Chave, '\'); + ListaAuxGet := g_oCacic.explode(Chave, '\'); strRootKey := ListaAuxGet[0]; For I := 1 To ListaAuxGet.Count - 2 Do strKey := strKey + ListaAuxGet[I] + '\'; @@ -1562,45 +1370,6 @@ begin Application.CreateForm(TfrmAcesso, frmAcesso); end; -function TfrmMapaCacic.IsAdmin: Boolean; -var hAccessToken: THandle; - ptgGroups: PTokenGroups; - dwInfoBufferSize: DWORD; - psidAdministrators: PSID; - x: Integer; - bSuccess: BOOL; -begin - Result := False; - bSuccess := OpenThreadToken(GetCurrentThread, TOKEN_QUERY, True, hAccessToken); - if not bSuccess then - begin - if GetLastError = ERROR_NO_TOKEN then - bSuccess := OpenProcessToken(GetCurrentProcess, TOKEN_QUERY, hAccessToken); - end; - if bSuccess then - begin - GetMem(ptgGroups, 1024); - bSuccess := GetTokenInformation(hAccessToken, TokenGroups, ptgGroups, 1024, dwInfoBufferSize); - CloseHandle(hAccessToken); - if bSuccess then - begin - AllocateAndInitializeSid(constSECURITY_NT_AUTHORITY, 2, - constSECURITY_BUILTIN_DOMAIN_RID, - constDOMAIN_ALIAS_RID_ADMINS, - 0, 0, 0, 0, 0, 0, psidAdministrators); - {$R-} - for x := 0 to ptgGroups.GroupCount - 1 do - if EqualSid(psidAdministrators, ptgGroups.Groups[x].Sid) then - begin - Result := True; - Break; - end; - {$R+} - FreeSid(psidAdministrators); - end; - FreeMem(ptgGroups); - end; -end; // Baixada de http://www.infoeng.hpg.ig.com.br/borland_delphi_dicas_2.htm function TfrmMapaCacic.LetrasDrives: string; var @@ -1693,7 +1462,8 @@ End; procedure TfrmMapaCacic.FormActivate(Sender: TObject); var intAux : integer; strLetrasDrives, - strRetorno : String; + strRetorno, + v_strCacicPath : String; Request_mapa : TStringList; begin g_oCacic := TCACIC.Create(); @@ -1708,15 +1478,16 @@ begin Begin // Varrer unidades C:\, D:\ e E:\ ... em busca da estrutura Cacic\cacic2.dat strLetrasDrives := LetrasDrives; - strPathCacic := ''; + + v_strCacicPath := ''; for intAux := 1 to length(strLetrasDrives) do Begin lbMensagens.Caption := 'Procurando Estrutura do Sistema CACIC em "'+strLetrasDrives[intAux] + ':\"'; Log_Debug('Testando "'+strLetrasDrives[intAux] + ':\Cacic\cacic2.dat'+'"'); - if (strPathCacic='') and (SearchFile(strLetrasDrives[intAux] + ':','\Cacic\cacic2.dat')) then + if (v_strCacicPath='') and (SearchFile(strLetrasDrives[intAux] + ':','\Cacic\cacic2.dat')) then Begin - strPathCacic := strLetrasDrives[intAux] + ':\Cacic\'; + v_strCacicPath := strLetrasDrives[intAux] + ':\Cacic\'; lbMensagens.Caption := 'Estrutura Encontrada!'; Log_Debug('Validado "'+strLetrasDrives[intAux] + ':\Cacic\cacic2.dat'+'"'); End @@ -1725,25 +1496,24 @@ begin application.ProcessMessages; End; - if not (strPathCacic = '') then + if not (v_strCacicPath = '') then Begin - Matar(strPathCacic,'aguarde_CACIC.txt'); + g_oCacic.setCacicPath(v_strCacicPath); + Matar(g_oCacic.getCacicPath,'aguarde_CACIC.txt'); - if FileExists(strPathCacic + 'aguarde_CACIC.txt') then + if FileExists(g_oCacic.getCacicPath + 'aguarde_CACIC.txt') then Begin MessageDLG(#13#10+'ATENÇÃO! É necessário finalizar o Agente Principal do CACIC.',mtError,[mbOK],0); Sair; End; - strDatFileName := strPathCacic + 'cacic2.dat'; // Algo como X:\Cacic\cacic2.dat - boolDebugs := false; - if DirectoryExists(strPathCacic + 'Temp\Debugs') then + if DirectoryExists(g_oCacic.getCacicPath + 'Temp\Debugs') then Begin - if (FormatDateTime('ddmmyyyy', GetFolderDate(strPathCacic + 'Temp\Debugs')) = FormatDateTime('ddmmyyyy', date)) then + if (FormatDateTime('ddmmyyyy', GetFolderDate(g_oCacic.getCacicPath + 'Temp\Debugs')) = FormatDateTime('ddmmyyyy', date)) then Begin boolDebugs := true; - log_DEBUG('Pasta "' + strPathCacic + 'Temp\Debugs" com data '+FormatDateTime('dd-mm-yyyy', GetFolderDate(strPathCacic + 'Temp\Debugs'))+' encontrada. DEBUG ativado.'); + log_DEBUG('Pasta "' + g_oCacic.getCacicPath + 'Temp\Debugs" com data '+FormatDateTime('dd-mm-yyyy', GetFolderDate(g_oCacic.getCacicPath + 'Temp\Debugs'))+' encontrada. DEBUG ativado.'); End; End; @@ -1762,14 +1532,14 @@ begin // Povoamento com dados de configurações da interface patrimonial // Solicita ao servidor as configurações para a Coleta de Informações de Patrimônio Request_mapa := TStringList.Create; - Request_mapa.Values['te_node_address'] := frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.TE_NODE_ADDRESS' , frmMapaCacic.tStringsCipherOpened)); - Request_mapa.Values['id_so'] := frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('Configs.ID_SO' , frmMapaCacic.tStringsCipherOpened)); - Request_mapa.Values['te_so'] := frmMapaCacic.EnCrypt(g_oCacic.getWindowsStrId()); - Request_mapa.Values['id_ip_rede'] := frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.ID_IP_REDE' , frmMapaCacic.tStringsCipherOpened)); - Request_mapa.Values['te_ip'] := frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.TE_IP' , frmMapaCacic.tStringsCipherOpened)); - Request_mapa.Values['te_nome_computador']:= frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.TE_NOME_COMPUTADOR', frmMapaCacic.tStringsCipherOpened)); - Request_mapa.Values['te_workgroup'] := frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.TE_WORKGROUP' , frmMapaCacic.tStringsCipherOpened)); - Request_mapa.Values['id_usuario'] := frmMapaCacic.EnCrypt(frmMapaCacic.strId_usuario); + Request_mapa.Values['te_node_address'] := g_oCacic.enCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.TE_NODE_ADDRESS' , frmMapaCacic.tStringsCipherOpened)); + Request_mapa.Values['id_so'] := g_oCacic.enCrypt(frmMapaCacic.GetValorDatMemoria('Configs.ID_SO' , frmMapaCacic.tStringsCipherOpened)); + Request_mapa.Values['te_so'] := g_oCacic.enCrypt(g_oCacic.getWindowsStrId()); + Request_mapa.Values['id_ip_rede'] := g_oCacic.enCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.ID_IP_REDE' , frmMapaCacic.tStringsCipherOpened)); + Request_mapa.Values['te_ip'] := g_oCacic.enCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.TE_IP' , frmMapaCacic.tStringsCipherOpened)); + Request_mapa.Values['te_nome_computador']:= g_oCacic.enCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.TE_NOME_COMPUTADOR', frmMapaCacic.tStringsCipherOpened)); + Request_mapa.Values['te_workgroup'] := g_oCacic.enCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.TE_WORKGROUP' , frmMapaCacic.tStringsCipherOpened)); + Request_mapa.Values['id_usuario'] := g_oCacic.enCrypt(frmMapaCacic.strId_usuario); strRetorno := frmMapaCacic.ComunicaServidor('mapa_get_patrimonio.php', Request_mapa, '.'); -- libgit2 0.21.2